DFUWUDetailsWidget.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/xhr",
  19. "dojo/dom",
  20. "dojo/dom-class",
  21. "dojo/dom-style",
  22. "dijit/layout/_LayoutWidget",
  23. "dijit/_TemplatedMixin",
  24. "dijit/_WidgetsInTemplateMixin",
  25. "dijit/layout/BorderContainer",
  26. "dijit/layout/TabContainer",
  27. "dijit/layout/ContentPane",
  28. "dijit/Toolbar",
  29. "dijit/form/Textarea",
  30. "dijit/TitlePane",
  31. "dijit/registry",
  32. "dijit/ProgressBar",
  33. "hpcc/ECLSourceWidget",
  34. "hpcc/TargetSelectWidget",
  35. "hpcc/SampleSelectWidget",
  36. "hpcc/GraphWidget",
  37. "hpcc/ResultsWidget",
  38. "hpcc/InfoGridWidget",
  39. "hpcc/ESPDFUWorkunit",
  40. "dojo/text!../templates/DFUWUDetailsWidget.html"
  41. ], function (declare, xhr, dom, domClass, domStyle,
  42. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, Textarea, TitlePane, registry, ProgressBar,
  43. EclSourceWidget, TargetSelectWidget, SampleSelectWidget, GraphWidget, ResultsWidget, InfoGridWidget, DFUWorkunit,
  44. template) {
  45. return declare("DFUWUDetailsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  46. templateString: template,
  47. baseClass: "DFUWUDetailsWidget",
  48. borderContainer: null,
  49. tabContainer: null,
  50. resultsWidget: null,
  51. resultsWidgetLoaded: false,
  52. filesWidget: null,
  53. filesWidgetLoaded: false,
  54. timersWidget: null,
  55. timersWidgetLoaded: false,
  56. graphsWidget: null,
  57. graphsWidgetLoaded: false,
  58. sourceWidget: null,
  59. sourceWidgetLoaded: false,
  60. playgroundWidget: null,
  61. playgroundWidgetLoaded: false,
  62. xmlWidget: null,
  63. xmlWidgetLoaded: false,
  64. legacyPane: null,
  65. legacyPaneLoaded: false,
  66. wu: null,
  67. loaded: false,
  68. buildRendering: function (args) {
  69. this.inherited(arguments);
  70. },
  71. postCreate: function (args) {
  72. this.inherited(arguments);
  73. this.borderContainer = registry.byId(this.id + "BorderContainer");
  74. this.tabContainer = registry.byId(this.id + "TabContainer");
  75. this.legacyPane = registry.byId(this.id + "Legacy");
  76. this.xmlWidget = registry.byId(this.id + "XML");
  77. var context = this;
  78. this.tabContainer.watch("selectedChildWidget", function (name, oval, nval) {
  79. if (nval.id == context.id + "Content" && !context.resultWidgetLoaded) {
  80. context.resultWidgetLoaded = true;
  81. context.resultWidget.init({
  82. result: context.logicalFile.result
  83. });
  84. } else if (nval.id == context.id + "Source" && !context.sourceWidgetLoaded) {
  85. context.sourceWidgetLoaded = true;
  86. context.sourceWidget.init({
  87. ECL: context.logicalFile.DFUInfoResponse.Ecl
  88. });
  89. } else if (nval.id == context.id + "DEF" && !context.defWidgetLoaded) {
  90. context.logicalFile.fetchDEF(function (response) {
  91. context.defWidgetLoaded = true;
  92. context.defWidget.init({
  93. ECL: response
  94. });
  95. });
  96. } else if (nval.id == context.id + "XML" && !context.xmlWidgetLoaded) {
  97. context.wu.fetchXML(function (response) {
  98. context.xmlWidgetLoaded = true;
  99. context.xmlWidget.init({
  100. ECL: response
  101. });
  102. });
  103. } else if (nval.id == context.id + "FileParts" && !context.filePartsWidgetLoaded) {
  104. context.filePartsWidgetLoaded = true;
  105. context.filePartsWidget.init({
  106. fileParts: lang.exists("logicalFile.DFUInfoResponse.DFUFileParts.DFUPart", context) ? context.logicalFile.DFUInfoResponse.DFUFileParts.DFUPart : []
  107. });
  108. } else if (nval.id == context.id + "Workunit" && !context.workunitWidgetLoaded) {
  109. context.workunitWidgetLoaded = true;
  110. context.workunitWidget.init({
  111. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  112. });
  113. } else if (nval.id == context.id + "DFUWorkunit" && !context.workunitWidgetLoaded) {
  114. context.dfuWorkunitWidgetLoaded = true;
  115. context.dfuWorkunitWidget.init({
  116. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  117. });
  118. } else if (nval.id == context.id + "Legacy" && !context.legacyPaneLoaded) {
  119. context.legacyPaneLoaded = true;
  120. context.legacyPane.set("content", dojo.create("iframe", {
  121. src: "/FileSpray/GetDFUWorkunit?wuid=" + context.wu.Wuid,
  122. style: "border: 0; width: 100%; height: 100%"
  123. }));
  124. }
  125. });
  126. },
  127. startup: function (args) {
  128. this.inherited(arguments);
  129. },
  130. resize: function (args) {
  131. this.inherited(arguments);
  132. this.borderContainer.resize();
  133. },
  134. layout: function (args) {
  135. this.inherited(arguments);
  136. },
  137. // Implementation ---
  138. init: function (params) {
  139. //dom.byId("showWuid").innerHTML = params.Wuid;
  140. if (params.Wuid) {
  141. registry.byId(this.id + "Summary").set("title", params.Wuid);
  142. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  143. this.wu = new DFUWorkunit({
  144. Wuid: params.Wuid
  145. });
  146. var context = this;
  147. this.wu.monitor(function (workunit) {
  148. context.monitorDFUWorkunit(workunit);
  149. });
  150. }
  151. // this.infoGridWidget.init(params);
  152. },
  153. objectToText: function (obj) {
  154. var text = ""
  155. for (var key in obj) {
  156. text += "<tr><td>" + key + ":</td>";
  157. if (typeof obj[key] == "object") {
  158. text += "[<br>";
  159. for (var i = 0; i < obj[key].length; ++i) {
  160. text += this.objectToText(obj[key][i]);
  161. }
  162. text += "<br>]<br>";
  163. } else {
  164. text += "<td>" + obj[key] + "</td></tr>";
  165. }
  166. }
  167. return text;
  168. },
  169. // Hitched actions ---
  170. resetPage: function () {
  171. },
  172. _onDelete: function (event) {
  173. },
  174. _onSave: function (event) {
  175. var protectedCheckbox = registry.byId(this.id + "Protected");
  176. var context = this;
  177. this.wu.update({
  178. //Description: dom.byId(context.id + "Description").value,
  179. //obname: dom.byId(context.id + "JobName").value,
  180. Protected: protectedCheckbox.get("value")
  181. }, null, {
  182. load: function (response) {
  183. context.monitor();
  184. }
  185. });
  186. },
  187. _onAbort: function (event) {
  188. var context = this;
  189. this.wu.abort({
  190. load: function (response) {
  191. context.monitor();
  192. }
  193. });
  194. },
  195. _onResubmit: function (event) {
  196. var context = this;
  197. this.wu.resubmit({
  198. load: function (response) {
  199. context.monitor();
  200. }
  201. });
  202. },
  203. _onModify: function (event) {
  204. var context = this;
  205. this.wu.resubmit({
  206. load: function (response) {
  207. context.monitor();
  208. }
  209. });
  210. },
  211. monitorDFUWorkunit: function (response) {
  212. if (!this.loaded) {
  213. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  214. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  215. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  216. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  217. registry.byId(this.id + "Modify").set("disabled", !this.wu.isComplete());
  218. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  219. dom.byId(this.id + "ID").innerHTML = response.ID;
  220. dom.byId(this.id + "ClusterName").value = response.ClusterName;
  221. dom.byId(this.id + "JobName").value = response.JobName;
  222. dom.byId(this.id + "Queue").innerHTML = response.Queue;
  223. dom.byId(this.id + "TimeStarted").innerHTML = response.TimeStarted;
  224. dom.byId(this.id + "TimeStopped").innerHTML = response.TimeStopped;
  225. //dom.byId(this.id + "ProgressBar").value = response.PercentDone;
  226. dom.byId(this.id + "ProgressMessage").innerHTML = response.ProgressMessage;
  227. dom.byId(this.id + "SummaryMessage").innerHTML = response.SummaryMessage;
  228. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  229. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  230. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  231. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  232. //dom.byId(this.id + "AutoRefresh").innerHTML = response.AutoRefresh;
  233. if (!response.AutoRefresh) {
  234. dom.byId(this.id + "AutoRefresh").innerHTML = "false";
  235. }
  236. if (response.Command == "6") {
  237. domClass.add(this.id + "ExportGroup", "hidden");
  238. dom.byId(this.id + "Command").innerHTML = "Spray";
  239. dom.byId(this.id + "SourceIP").innerHTML = response.SourceIP;
  240. dom.byId(this.id + "SourceFilePath").innerHTML = response.SourceFilePath;
  241. dom.byId(this.id + "SourceRecordSize").innerHTML = response.SourceRecordSize;
  242. dom.byId(this.id + "SourceFormat").innerHTML = response.SourceFormat;
  243. dom.byId(this.id + "SourceNumParts").innerHTML = response.SourceNumParts;
  244. dom.byId(this.id + "SourceDirectory").innerHTML = response.SourceDirectory;
  245. dom.byId(this.id + "DestGroupName").innerHTML = response.DestGroupName;
  246. dom.byId(this.id + "DestLogicalName").innerHTML = response.DestLogicalName;
  247. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  248. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  249. } else {
  250. domClass.add(this.id + "ImportGroup", "hidden");
  251. domClass.add(this.id + "ClusterLine", "hidden");
  252. dom.byId(this.id + "Command").innerHTML = "Despray";
  253. dom.byId(this.id + "SourceLogicalName").innerHTML = response.SourceLogicalName;
  254. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  255. dom.byId(this.id + "DestIP").innerHTML = response.DestIP;
  256. dom.byId(this.id + "DestFilePath").innerHTML = response.DestFilePath;
  257. dom.byId(this.id + "DestFormat").innerHTML = response.DestFormat;
  258. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  259. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  260. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  261. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  262. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  263. }
  264. //start progress bar
  265. //end progress bar
  266. this.loaded = true;
  267. }
  268. var context = this;
  269. if (this.wu.isComplete()) {
  270. this.wu.getInfo({
  271. onGetResults: function (response) {
  272. },
  273. onGetSourceFiles: function (response) {
  274. },
  275. onGetTimers: function (response) {
  276. },
  277. onGetGraphs: function (response) {
  278. },
  279. onGetAll: function (response) {
  280. }
  281. });
  282. }
  283. }
  284. });
  285. });