DFUWUDetailsWidget.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. wu: null,
  65. loaded: false,
  66. buildRendering: function (args) {
  67. this.inherited(arguments);
  68. },
  69. postCreate: function (args) {
  70. this.inherited(arguments);
  71. this.borderContainer = registry.byId(this.id + "BorderContainer");
  72. this.tabContainer = registry.byId(this.id + "TabContainer");
  73. this.xmlWidget = registry.byId(this.id + "XML");
  74. var context = this;
  75. this.tabContainer.watch("selectedChildWidget", function (name, oval, nval) {
  76. if (nval.id == context.id + "Content" && !context.resultWidgetLoaded) {
  77. context.resultWidgetLoaded = true;
  78. context.resultWidget.init({
  79. result: context.logicalFile.result
  80. });
  81. } else if (nval.id == context.id + "Source" && !context.sourceWidgetLoaded) {
  82. context.sourceWidgetLoaded = true;
  83. context.sourceWidget.init({
  84. ECL: context.logicalFile.DFUInfoResponse.Ecl
  85. });
  86. } else if (nval.id == context.id + "DEF" && !context.defWidgetLoaded) {
  87. context.logicalFile.fetchDEF(function (response) {
  88. context.defWidgetLoaded = true;
  89. context.defWidget.init({
  90. ECL: response
  91. });
  92. });
  93. } else if (nval.id == context.id + "XML" && !context.xmlWidgetLoaded) {
  94. context.wu.fetchXML(function (response) {
  95. context.xmlWidgetLoaded = true;
  96. context.xmlWidget.init({
  97. ECL: response
  98. });
  99. });
  100. } else if (nval.id == context.id + "FileParts" && !context.filePartsWidgetLoaded) {
  101. context.filePartsWidgetLoaded = true;
  102. context.filePartsWidget.init({
  103. fileParts: lang.exists("logicalFile.DFUInfoResponse.DFUFileParts.DFUPart", context) ? context.logicalFile.DFUInfoResponse.DFUFileParts.DFUPart : []
  104. });
  105. } else if (nval.id == context.id + "Workunit" && !context.workunitWidgetLoaded) {
  106. context.workunitWidgetLoaded = true;
  107. context.workunitWidget.init({
  108. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  109. });
  110. } else if (nval.id == context.id + "DFUWorkunit" && !context.workunitWidgetLoaded) {
  111. context.dfuWorkunitWidgetLoaded = true;
  112. context.dfuWorkunitWidget.init({
  113. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  114. });
  115. }
  116. });
  117. },
  118. startup: function (args) {
  119. this.inherited(arguments);
  120. },
  121. resize: function (args) {
  122. this.inherited(arguments);
  123. this.borderContainer.resize();
  124. },
  125. layout: function (args) {
  126. this.inherited(arguments);
  127. },
  128. // Implementation ---
  129. init: function (params) {
  130. if (this.initalized)
  131. return;
  132. this.initalized = true;
  133. //dom.byId("showWuid").innerHTML = params.Wuid;
  134. if (params.Wuid) {
  135. registry.byId(this.id + "Summary").set("title", params.Wuid);
  136. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  137. this.wu = new DFUWorkunit({
  138. Wuid: params.Wuid
  139. });
  140. var context = this;
  141. this.wu.monitor(function (workunit) {
  142. context.monitorDFUWorkunit(workunit);
  143. });
  144. }
  145. // this.infoGridWidget.init(params);
  146. },
  147. objectToText: function (obj) {
  148. var text = ""
  149. for (var key in obj) {
  150. text += "<tr><td>" + key + ":</td>";
  151. if (typeof obj[key] == "object") {
  152. text += "[<br/>";
  153. for (var i = 0; i < obj[key].length; ++i) {
  154. text += this.objectToText(obj[key][i]);
  155. }
  156. text += "<br/>]<br/>";
  157. } else {
  158. text += "<td>" + obj[key] + "</td></tr>";
  159. }
  160. }
  161. return text;
  162. },
  163. // Hitched actions ---
  164. resetPage: function () {
  165. },
  166. _onDelete: function (event) {
  167. },
  168. _onSave: function (event) {
  169. var protectedCheckbox = registry.byId(this.id + "Protected");
  170. var context = this;
  171. this.wu.update({
  172. //Description: dom.byId(context.id + "Description").value,
  173. //obname: dom.byId(context.id + "JobName").value,
  174. Protected: protectedCheckbox.get("value")
  175. }, null, {
  176. load: function (response) {
  177. context.monitor();
  178. }
  179. });
  180. },
  181. _onAbort: function (event) {
  182. var context = this;
  183. this.wu.abort({
  184. load: function (response) {
  185. context.monitor();
  186. }
  187. });
  188. },
  189. _onResubmit: function (event) {
  190. var context = this;
  191. this.wu.resubmit({
  192. load: function (response) {
  193. context.monitor();
  194. }
  195. });
  196. },
  197. _onModify: function (event) {
  198. var context = this;
  199. this.wu.resubmit({
  200. load: function (response) {
  201. context.monitor();
  202. }
  203. });
  204. },
  205. monitorDFUWorkunit: function (response) {
  206. if (!this.loaded) {
  207. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  208. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  209. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  210. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  211. registry.byId(this.id + "Modify").set("disabled", !this.wu.isComplete());
  212. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  213. dom.byId(this.id + "ID").innerHTML = response.ID;
  214. dom.byId(this.id + "ClusterName").value = response.ClusterName;
  215. dom.byId(this.id + "JobName").value = response.JobName;
  216. dom.byId(this.id + "Queue").innerHTML = response.Queue;
  217. dom.byId(this.id + "TimeStarted").innerHTML = response.TimeStarted;
  218. dom.byId(this.id + "TimeStopped").innerHTML = response.TimeStopped;
  219. //dom.byId(this.id + "ProgressBar").value = response.PercentDone;
  220. dom.byId(this.id + "ProgressMessage").innerHTML = response.ProgressMessage;
  221. dom.byId(this.id + "SummaryMessage").innerHTML = response.SummaryMessage;
  222. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  223. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  224. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  225. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  226. //dom.byId(this.id + "AutoRefresh").innerHTML = response.AutoRefresh;
  227. if (!response.AutoRefresh) {
  228. dom.byId(this.id + "AutoRefresh").innerHTML = "false";
  229. }
  230. if (response.Command == "6") {
  231. domClass.add(this.id + "ExportGroup", "hidden");
  232. dom.byId(this.id + "Command").innerHTML = "Spray";
  233. dom.byId(this.id + "SourceIP").innerHTML = response.SourceIP;
  234. dom.byId(this.id + "SourceFilePath").innerHTML = response.SourceFilePath;
  235. dom.byId(this.id + "SourceRecordSize").innerHTML = response.SourceRecordSize;
  236. dom.byId(this.id + "SourceFormat").innerHTML = response.SourceFormat;
  237. dom.byId(this.id + "SourceNumParts").innerHTML = response.SourceNumParts;
  238. dom.byId(this.id + "SourceDirectory").innerHTML = response.SourceDirectory;
  239. dom.byId(this.id + "DestGroupName").innerHTML = response.DestGroupName;
  240. dom.byId(this.id + "DestLogicalName").innerHTML = response.DestLogicalName;
  241. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  242. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  243. } else {
  244. domClass.add(this.id + "ImportGroup", "hidden");
  245. domClass.add(this.id + "ClusterLine", "hidden");
  246. dom.byId(this.id + "Command").innerHTML = "Despray";
  247. dom.byId(this.id + "SourceLogicalName").innerHTML = response.SourceLogicalName;
  248. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  249. dom.byId(this.id + "DestIP").innerHTML = response.DestIP;
  250. dom.byId(this.id + "DestFilePath").innerHTML = response.DestFilePath;
  251. dom.byId(this.id + "DestFormat").innerHTML = response.DestFormat;
  252. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  253. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  254. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  255. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  256. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  257. }
  258. //start progress bar
  259. //end progress bar
  260. this.loaded = true;
  261. }
  262. var context = this;
  263. if (this.wu.isComplete()) {
  264. this.wu.getInfo({
  265. onGetResults: function (response) {
  266. },
  267. onGetSourceFiles: function (response) {
  268. },
  269. onGetTimers: function (response) {
  270. },
  271. onGetGraphs: function (response) {
  272. },
  273. onGetAll: function (response) {
  274. }
  275. });
  276. }
  277. }
  278. });
  279. });