DFUWUDetailsWidget.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. "dijit/layout/_LayoutWidget",
  21. "dijit/_TemplatedMixin",
  22. "dijit/_WidgetsInTemplateMixin",
  23. "dijit/layout/BorderContainer",
  24. "dijit/layout/TabContainer",
  25. "dijit/layout/ContentPane",
  26. "dijit/Toolbar",
  27. "dijit/form/Textarea",
  28. "dijit/TitlePane",
  29. "dijit/registry",
  30. "dijit/ProgressBar",
  31. "hpcc/ECLSourceWidget",
  32. "hpcc/TargetSelectWidget",
  33. "hpcc/SampleSelectWidget",
  34. "hpcc/GraphWidget",
  35. "hpcc/ResultsWidget",
  36. "hpcc/InfoGridWidget",
  37. "hpcc/ESPDFUWorkunit",
  38. "dojo/text!../templates/DFUWUDetailsWidget.html"
  39. ], function (declare, xhr, dom,
  40. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, Textarea, TitlePane, registry, ProgressBar,
  41. EclSourceWidget, TargetSelectWidget, SampleSelectWidget, GraphWidget, ResultsWidget, InfoGridWidget, DFUWorkunit,
  42. template) {
  43. return declare("DFUWUDetailsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  44. templateString: template,
  45. baseClass: "DFUWUDetailsWidget",
  46. borderContainer: null,
  47. tabContainer: null,
  48. resultsWidget: null,
  49. resultsWidgetLoaded: false,
  50. filesWidget: null,
  51. filesWidgetLoaded: false,
  52. timersWidget: null,
  53. timersWidgetLoaded: false,
  54. graphsWidget: null,
  55. graphsWidgetLoaded: false,
  56. sourceWidget: null,
  57. sourceWidgetLoaded: false,
  58. playgroundWidget: null,
  59. playgroundWidgetLoaded: false,
  60. xmlWidget: null,
  61. xmlWidgetLoaded: false,
  62. legacyPane: null,
  63. legacyPaneLoaded: 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.legacyPane = registry.byId(this.id + "Legacy");
  74. this.xmlWidget = registry.byId(this.id + "XML");
  75. var context = this;
  76. this.tabContainer.watch("selectedChildWidget", function (name, oval, nval) {
  77. if (nval.id == context.id + "Content" && !context.resultWidgetLoaded) {
  78. context.resultWidgetLoaded = true;
  79. context.resultWidget.init({
  80. result: context.logicalFile.result
  81. });
  82. } else if (nval.id == context.id + "Source" && !context.sourceWidgetLoaded) {
  83. context.sourceWidgetLoaded = true;
  84. context.sourceWidget.init({
  85. ECL: context.logicalFile.DFUInfoResponse.Ecl
  86. });
  87. } else if (nval.id == context.id + "DEF" && !context.defWidgetLoaded) {
  88. context.logicalFile.fetchDEF(function (response) {
  89. context.defWidgetLoaded = true;
  90. context.defWidget.init({
  91. ECL: response
  92. });
  93. });
  94. } else if (nval.id == context.id + "XML" && !context.xmlWidgetLoaded) {
  95. context.wu.fetchXML(function (response) {
  96. context.xmlWidgetLoaded = true;
  97. context.xmlWidget.init({
  98. ECL: response
  99. });
  100. });
  101. } else if (nval.id == context.id + "FileParts" && !context.filePartsWidgetLoaded) {
  102. context.filePartsWidgetLoaded = true;
  103. context.filePartsWidget.init({
  104. fileParts: lang.exists("logicalFile.DFUInfoResponse.DFUFileParts.DFUPart", context) ? context.logicalFile.DFUInfoResponse.DFUFileParts.DFUPart : []
  105. });
  106. } else if (nval.id == context.id + "Workunit" && !context.workunitWidgetLoaded) {
  107. context.workunitWidgetLoaded = true;
  108. context.workunitWidget.init({
  109. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  110. });
  111. } else if (nval.id == context.id + "DFUWorkunit" && !context.workunitWidgetLoaded) {
  112. context.dfuWorkunitWidgetLoaded = true;
  113. context.dfuWorkunitWidget.init({
  114. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  115. });
  116. } else if (nval.id == context.id + "Legacy" && !context.legacyPaneLoaded) {
  117. context.legacyPaneLoaded = true;
  118. context.legacyPane.set("content", dojo.create("iframe", {
  119. src: "/FileSpray/GetDFUWorkunit?wuid=" + context.wu.Wuid,
  120. style: "border: 0; width: 100%; height: 100%"
  121. }));
  122. }
  123. });
  124. },
  125. startup: function (args) {
  126. this.inherited(arguments);
  127. },
  128. //TODO
  129. /*showProgress: function(event){
  130. alert(response.PercentDone);
  131. numParts = Math.floor(100/10);
  132. jsProgressBar.update({maximum:numParts, progress:response.PercentDone});
  133. for (var i = response.PercentDone; i <= numParts; i++){
  134. timer = setTimeout(
  135. "jsProgressBar.update({progress: " + i + "})", (i+1)*1000 //1000ms of 1
  136. )
  137. }
  138. },*/
  139. resize: function (args) {
  140. this.inherited(arguments);
  141. this.borderContainer.resize();
  142. },
  143. layout: function (args) {
  144. this.inherited(arguments);
  145. },
  146. // Hitched actions ---
  147. _onSave: function (event) {
  148. },
  149. _onDelete: function (event) {
  150. },
  151. // Implementation ---
  152. init: function (params) {
  153. //dom.byId("showWuid").innerHTML = params.Wuid;
  154. if (params.Wuid) {
  155. registry.byId(this.id + "Summary").set("title", params.Wuid);
  156. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  157. this.wu = new DFUWorkunit({
  158. Wuid: params.Wuid
  159. });
  160. var context = this;
  161. this.wu.monitor(function (workunit) {
  162. context.monitorDFUWorkunit(workunit);
  163. });
  164. }
  165. // this.infoGridWidget.init(params);
  166. },
  167. resetPage: function () {
  168. },
  169. objectToText: function (obj) {
  170. var text = ""
  171. for (var key in obj) {
  172. text += "<tr><td>" + key + ":</td>";
  173. if (typeof obj[key] == "object") {
  174. text += "[<br>";
  175. for (var i = 0; i < obj[key].length; ++i) {
  176. text += this.objectToText(obj[key][i]);
  177. }
  178. text += "<br>]<br>";
  179. } else {
  180. text += "<td>" + obj[key] + "</td></tr>";
  181. }
  182. }
  183. return text;
  184. },
  185. _onSave: function (event) {
  186. var protectedCheckbox = registry.byId(this.id + "Protected");
  187. var context = this;
  188. this.wu.update({
  189. //Description: dom.byId(context.id + "Description").value,
  190. //obname: dom.byId(context.id + "JobName").value,
  191. Protected: protectedCheckbox.get("value")
  192. }, null, {
  193. load: function (response) {
  194. context.monitor();
  195. }
  196. });
  197. },
  198. _onAbort: function (event) {
  199. var context = this;
  200. this.wu.abort({
  201. load: function (response) {
  202. context.monitor();
  203. }
  204. });
  205. },
  206. _onResubmit: function (event) {
  207. var context = this;
  208. this.wu.resubmit({
  209. load: function (response) {
  210. context.monitor();
  211. }
  212. });
  213. },
  214. _onModify: function (event) {
  215. var context = this;
  216. this.wu.resubmit({
  217. load: function (response) {
  218. context.monitor();
  219. }
  220. });
  221. },
  222. monitorDFUWorkunit: function (response) {
  223. if (!this.loaded) {
  224. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  225. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  226. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  227. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  228. registry.byId(this.id + "Modify").set("disabled", !this.wu.isComplete());
  229. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  230. dom.byId(this.id + "ID").innerHTML = response.ID;
  231. dom.byId(this.id + "JobName").value = response.JobName;
  232. dom.byId(this.id + "Queue").innerHTML = response.Queue;
  233. dom.byId(this.id + "Command").innerHTML = response.Command;
  234. dom.byId(this.id + "TimeStarted").innerHTML = response.TimeStarted;
  235. dom.byId(this.id + "TimeStopped").innerHTML = response.TimeStopped;
  236. dom.byId(this.id + "ProgressBar").value = response.PercentDone;
  237. dom.byId(this.id + "ProgressMessage").innerHTML = response.ProgressMessage;
  238. dom.byId(this.id + "SummaryMessage").innerHTML = response.SummaryMessage;
  239. dom.byId(this.id + "SourceLogicalName").innerHTML = response.SourceLogicalName;
  240. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  241. dom.byId(this.id + "DestIP").innerHTML = response.DestIP;
  242. dom.byId(this.id + "DestFilePath").innerHTML = response.DestFilePath;
  243. dom.byId(this.id + "DestFormat").innerHTML = response.DestFormat;
  244. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  245. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  246. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  247. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  248. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  249. dom.byId(this.id + "AutoRefresh").innerHTML = response.AutoRefresh;
  250. this.loaded = true;
  251. }
  252. var context = this;
  253. if (this.wu.isComplete()) {
  254. this.wu.getInfo({
  255. onGetResults: function (response) {
  256. },
  257. onGetSourceFiles: function (response) {
  258. },
  259. onGetTimers: function (response) {
  260. },
  261. onGetGraphs: function (response) {
  262. },
  263. onGetAll: function (response) {
  264. }
  265. });
  266. }
  267. }
  268. });
  269. });