DFUWUDetailsWidget.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. if (this.initalized)
  140. return;
  141. this.initalized = true;
  142. //dom.byId("showWuid").innerHTML = params.Wuid;
  143. if (params.Wuid) {
  144. registry.byId(this.id + "Summary").set("title", params.Wuid);
  145. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  146. this.wu = new DFUWorkunit({
  147. Wuid: params.Wuid
  148. });
  149. var context = this;
  150. this.wu.monitor(function (workunit) {
  151. context.monitorDFUWorkunit(workunit);
  152. });
  153. }
  154. // this.infoGridWidget.init(params);
  155. },
  156. objectToText: function (obj) {
  157. var text = ""
  158. for (var key in obj) {
  159. text += "<tr><td>" + key + ":</td>";
  160. if (typeof obj[key] == "object") {
  161. text += "[<br/>";
  162. for (var i = 0; i < obj[key].length; ++i) {
  163. text += this.objectToText(obj[key][i]);
  164. }
  165. text += "<br/>]<br/>";
  166. } else {
  167. text += "<td>" + obj[key] + "</td></tr>";
  168. }
  169. }
  170. return text;
  171. },
  172. // Hitched actions ---
  173. resetPage: function () {
  174. },
  175. _onDelete: function (event) {
  176. },
  177. _onSave: function (event) {
  178. var protectedCheckbox = registry.byId(this.id + "Protected");
  179. var context = this;
  180. this.wu.update({
  181. //Description: dom.byId(context.id + "Description").value,
  182. //obname: dom.byId(context.id + "JobName").value,
  183. Protected: protectedCheckbox.get("value")
  184. }, null, {
  185. load: function (response) {
  186. context.monitor();
  187. }
  188. });
  189. },
  190. _onAbort: function (event) {
  191. var context = this;
  192. this.wu.abort({
  193. load: function (response) {
  194. context.monitor();
  195. }
  196. });
  197. },
  198. _onResubmit: function (event) {
  199. var context = this;
  200. this.wu.resubmit({
  201. load: function (response) {
  202. context.monitor();
  203. }
  204. });
  205. },
  206. _onModify: function (event) {
  207. var context = this;
  208. this.wu.resubmit({
  209. load: function (response) {
  210. context.monitor();
  211. }
  212. });
  213. },
  214. monitorDFUWorkunit: function (response) {
  215. if (!this.loaded) {
  216. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  217. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  218. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  219. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  220. registry.byId(this.id + "Modify").set("disabled", !this.wu.isComplete());
  221. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  222. dom.byId(this.id + "ID").innerHTML = response.ID;
  223. dom.byId(this.id + "ClusterName").value = response.ClusterName;
  224. dom.byId(this.id + "JobName").value = response.JobName;
  225. dom.byId(this.id + "Queue").innerHTML = response.Queue;
  226. dom.byId(this.id + "TimeStarted").innerHTML = response.TimeStarted;
  227. dom.byId(this.id + "TimeStopped").innerHTML = response.TimeStopped;
  228. //dom.byId(this.id + "ProgressBar").value = response.PercentDone;
  229. dom.byId(this.id + "ProgressMessage").innerHTML = response.ProgressMessage;
  230. dom.byId(this.id + "SummaryMessage").innerHTML = response.SummaryMessage;
  231. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  232. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  233. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  234. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  235. //dom.byId(this.id + "AutoRefresh").innerHTML = response.AutoRefresh;
  236. if (!response.AutoRefresh) {
  237. dom.byId(this.id + "AutoRefresh").innerHTML = "false";
  238. }
  239. if (response.Command == "6") {
  240. domClass.add(this.id + "ExportGroup", "hidden");
  241. dom.byId(this.id + "Command").innerHTML = "Spray";
  242. dom.byId(this.id + "SourceIP").innerHTML = response.SourceIP;
  243. dom.byId(this.id + "SourceFilePath").innerHTML = response.SourceFilePath;
  244. dom.byId(this.id + "SourceRecordSize").innerHTML = response.SourceRecordSize;
  245. dom.byId(this.id + "SourceFormat").innerHTML = response.SourceFormat;
  246. dom.byId(this.id + "SourceNumParts").innerHTML = response.SourceNumParts;
  247. dom.byId(this.id + "SourceDirectory").innerHTML = response.SourceDirectory;
  248. dom.byId(this.id + "DestGroupName").innerHTML = response.DestGroupName;
  249. dom.byId(this.id + "DestLogicalName").innerHTML = response.DestLogicalName;
  250. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  251. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  252. } else {
  253. domClass.add(this.id + "ImportGroup", "hidden");
  254. domClass.add(this.id + "ClusterLine", "hidden");
  255. dom.byId(this.id + "Command").innerHTML = "Despray";
  256. dom.byId(this.id + "SourceLogicalName").innerHTML = response.SourceLogicalName;
  257. dom.byId(this.id + "DestDirectory").innerHTML = response.DestDirectory;
  258. dom.byId(this.id + "DestIP").innerHTML = response.DestIP;
  259. dom.byId(this.id + "DestFilePath").innerHTML = response.DestFilePath;
  260. dom.byId(this.id + "DestFormat").innerHTML = response.DestFormat;
  261. dom.byId(this.id + "DestNumParts").innerHTML = response.DestNumParts;
  262. dom.byId(this.id + "MonitorSub").innerHTML = response.MonitorSub;
  263. dom.byId(this.id + "Overwrite").innerHTML = response.Overwrite;
  264. dom.byId(this.id + "Replicate").innerHTML = response.Replicate;
  265. dom.byId(this.id + "Compress").innerHTML = response.Compress;
  266. }
  267. //start progress bar
  268. //end progress bar
  269. this.loaded = true;
  270. }
  271. var context = this;
  272. if (this.wu.isComplete()) {
  273. this.wu.getInfo({
  274. onGetResults: function (response) {
  275. },
  276. onGetSourceFiles: function (response) {
  277. },
  278. onGetTimers: function (response) {
  279. },
  280. onGetGraphs: function (response) {
  281. },
  282. onGetAll: function (response) {
  283. }
  284. });
  285. }
  286. }
  287. });
  288. });