WUDetailsWidget.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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/lang",
  19. "dojo/i18n",
  20. "dojo/i18n!./nls/common",
  21. "dojo/i18n!./nls/WUDetailsWidget",
  22. "dojo/dom",
  23. "dojo/dom-form",
  24. "dojo/dom-attr",
  25. "dojo/request/iframe",
  26. "dojo/dom-class",
  27. "dojo/query",
  28. "dojo/store/Memory",
  29. "dojo/store/Observable",
  30. "dijit/registry",
  31. "dgrid/OnDemandGrid",
  32. "dgrid/Keyboard",
  33. "dgrid/Selection",
  34. "dgrid/selector",
  35. "dgrid/extensions/ColumnResizer",
  36. "dgrid/extensions/DijitRegistry",
  37. "hpcc/_TabContainerWidget",
  38. "hpcc/ESPWorkunit",
  39. "hpcc/ESPRequest",
  40. "hpcc/ECLSourceWidget",
  41. "hpcc/TargetSelectWidget",
  42. "hpcc/GraphsWidget",
  43. "hpcc/ResultsWidget",
  44. "hpcc/SourceFilesWidget",
  45. "hpcc/InfoGridWidget",
  46. "hpcc/LogsWidget",
  47. "hpcc/TimingPageWidget",
  48. "hpcc/ECLPlaygroundWidget",
  49. "hpcc/VizWidget",
  50. "hpcc/WsWorkunits",
  51. "dojo/text!../templates/WUDetailsWidget.html",
  52. "dijit/layout/BorderContainer",
  53. "dijit/layout/TabContainer",
  54. "dijit/layout/ContentPane",
  55. "dijit/form/Form",
  56. "dijit/form/Textarea",
  57. "dijit/form/Button",
  58. "dijit/Toolbar",
  59. "dijit/TooltipDialog",
  60. "dijit/TitlePane",
  61. "dijit/form/TextBox",
  62. "dijit/Dialog",
  63. "dijit/form/SimpleTextarea",
  64. "hpcc/TableContainer"
  65. ], function (declare, lang, i18n, nlsCommon, nlsSpecific, dom, domForm, domAttr, iframe, domClass, query, Memory, Observable,
  66. registry,
  67. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  68. _TabContainerWidget, ESPWorkunit, ESPRequest, EclSourceWidget, TargetSelectWidget, GraphsWidget, ResultsWidget, SourceFilesWidget, InfoGridWidget, LogsWidget, TimingPageWidget, ECLPlaygroundWidget, VizWidget, WsWorkunits,
  69. template) {
  70. return declare("WUDetailsWidget", [_TabContainerWidget], {
  71. templateString: template,
  72. baseClass: "WUDetailsWidget",
  73. i18n: lang.mixin(nlsCommon, nlsSpecific),
  74. summaryWidget: null,
  75. resultsWidget: null,
  76. resultsWidgetLoaded: false,
  77. filesWidget: null,
  78. filesWidgetLoaded: false,
  79. timersWidget: null,
  80. timersWidgetLoaded: false,
  81. graphsWidget: null,
  82. graphsWidgetLoaded: false,
  83. vizWidget: null,
  84. vizWidgetLoaded: false,
  85. sourceWidget: null,
  86. sourceWidgetLoaded: false,
  87. logsWidget: null,
  88. logsWidgetLoaded: false,
  89. playgroundWidget: null,
  90. playgroundWidgetLoaded: false,
  91. xmlWidget: null,
  92. xmlWidgetLoaded: false,
  93. publishForm: null,
  94. wu: null,
  95. buildVersion: null,
  96. espIPAddress: null,
  97. thorIPAddress: null,
  98. zapDescription: null,
  99. warnHistory: null,
  100. warnTimings: null,
  101. prevState: "",
  102. postCreate: function (args) {
  103. this.inherited(arguments);
  104. this.summaryWidget = registry.byId(this.id + "_Summary");
  105. this.variablesWidget = registry.byId(this.id + "_Variables");
  106. this.resultsWidget = registry.byId(this.id + "_Results");
  107. this.filesWidget = registry.byId(this.id + "_Files");
  108. this.vizWidget = registry.byId(this.id + "_Visualize");
  109. this.timersWidget = registry.byId(this.id + "_Timers");
  110. this.graphsWidget = registry.byId(this.id + "_Graphs");
  111. this.sourceWidget = registry.byId(this.id + "_Source");
  112. this.logsWidget = registry.byId(this.id + "_Logs");
  113. this.playgroundWidget = registry.byId(this.id + "_Playground");
  114. this.xmlWidget = registry.byId(this.id + "_XML");
  115. this.publishForm = registry.byId(this.id + "PublishForm");
  116. this.zapDescription = registry.byId(this.id + "ZapDescription");
  117. this.warnHistory = registry.byId(this.id + "WarnHistory");
  118. this.warnTimings = registry.byId(this.id + "WarnTimings");
  119. this.infoGridWidget = registry.byId(this.id + "InfoContainer");
  120. this.zapDialog = registry.byId(this.id + "ZapDialog");
  121. },
  122. startup: function (args) {
  123. this.inherited(arguments);
  124. var store = new Memory({
  125. idProperty: "Id",
  126. data: []
  127. });
  128. this.variablesStore = Observable(store);
  129. this.variablesGrid = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry])({
  130. allowSelectAll: true,
  131. columns: {
  132. Name: { label: "Name", width: 360 },
  133. Value: { label: "Value" }
  134. },
  135. store: this.variablesStore
  136. }, this.id + "VariablesGrid");
  137. this.variablesGrid.startup();
  138. },
  139. destroy: function (args) {
  140. this.zapDialog.destroyRecursive();
  141. this.inherited(arguments);
  142. },
  143. getTitle: function () {
  144. return this.i18n.title;
  145. },
  146. _onCancelDialog: function (){
  147. this.zapDialog.hide();
  148. },
  149. // Hitched actions ---
  150. _onSave: function (event) {
  151. var protectedCheckbox = registry.byId(this.id + "Protected");
  152. var context = this;
  153. this.wu.update({
  154. Description: dom.byId(context.id + "Description").value,
  155. Jobname: dom.byId(context.id + "Jobname").value,
  156. Protected: protectedCheckbox.get("value")
  157. }, null);
  158. },
  159. _onRefresh: function (event) {
  160. this.wu.refresh(true);
  161. },
  162. _onClone: function (event) {
  163. this.wu.clone();
  164. },
  165. _onDelete: function (event) {
  166. this.wu.doDelete();
  167. },
  168. _onResubmit: function (event) {
  169. this.wu.resubmit();
  170. },
  171. _onSetToFailed: function (event) {
  172. this.wu.setToFailed();
  173. },
  174. _onAbort: function (event) {
  175. this.wu.abort();
  176. },
  177. _onRestart: function (event) {
  178. this.wu.restart();
  179. },
  180. _onPublish: function (event) {
  181. if (this.publishForm.validate()) {
  182. registry.byId(this.id + "Publish").closeDropDown();
  183. this.wu.publish(dom.byId(this.id + "Jobname2").value, dom.byId(this.id + "RemoteDali").value);
  184. }
  185. },
  186. onZapReport: function (event) {
  187. var context = this;
  188. WsWorkunits.WUGetZAPInfo({
  189. request: {
  190. WUID: this.wu.Wuid
  191. }
  192. }).then(function (response) {
  193. context.zapDialog.show();
  194. if (lang.exists("WUGetZAPInfoResponse", response)) {
  195. context.updateInput("ZapWUID", null, response.WUGetZAPInfoResponse.WUID);
  196. context.updateInput("BuildVersion", null, response.WUGetZAPInfoResponse.BuildVersion);
  197. context.updateInput("ESPIPAddress", null, response.WUGetZAPInfoResponse.ESPIPAddress);
  198. context.updateInput("ThorIPAddress", null, response.WUGetZAPInfoResponse.ThorIPAddress);
  199. context.buildVersion = response.WUGetZAPInfoResponse.BuildVersion;
  200. context.espIPAddress = response.WUGetZAPInfoResponse.ESPIPAddress;
  201. context.thorIPAddress = response.WUGetZAPInfoResponse.ThorIPAddress;
  202. }
  203. });
  204. },
  205. // Implementation ---
  206. init: function (params) {
  207. if (this.inherited(arguments))
  208. return;
  209. if (params.Wuid) {
  210. this.summaryWidget.set("title", params.Wuid);
  211. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  212. this.wu = ESPWorkunit.Get(params.Wuid);
  213. var data = this.wu.getData();
  214. for (var key in data) {
  215. this.updateInput(key, null, data[key]);
  216. }
  217. var context = this;
  218. this.wu.watch(function (name, oldValue, newValue) {
  219. context.updateInput(name, oldValue, newValue);
  220. });
  221. this.wu.refresh();
  222. }
  223. this.infoGridWidget.init(params);
  224. this.selectChild(this.summaryWidget, true);
  225. },
  226. initTab: function () {
  227. if (!this.wu) {
  228. return
  229. }
  230. var currSel = this.getSelectedChild();
  231. if (currSel.id == this.resultsWidget.id && !this.resultsWidgetLoaded) {
  232. this.resultsWidgetLoaded = true;
  233. this.resultsWidget.init({
  234. Wuid: this.wu.Wuid
  235. });
  236. } else if (currSel.id == this.filesWidget.id && !this.filesWidgetLoaded) {
  237. this.filesWidgetLoaded = true;
  238. this.filesWidget.init({
  239. Wuid: this.wu.Wuid,
  240. SourceFiles: true
  241. });
  242. } else if (currSel.id == this.timersWidget.id && !this.timersWidgetLoaded) {
  243. this.timersWidgetLoaded = true;
  244. this.timersWidget.init({
  245. Wuid: this.wu.Wuid
  246. });
  247. } else if (currSel.id == this.graphsWidget.id && !this.graphsWidgetLoaded) {
  248. this.graphsWidgetLoaded = true;
  249. this.graphsWidget.init({
  250. Wuid: this.wu.Wuid
  251. });
  252. } else if (currSel.id == this.vizWidget.id && !this.vizWidgetLoaded) {
  253. this.vizWidgetLoaded = true;
  254. this.vizWidget.init({
  255. Wuid: this.wu.Wuid
  256. });
  257. } else if (currSel.id == this.sourceWidget.id && !this.sourceWidgetLoaded) {
  258. this.sourceWidgetLoaded = true;
  259. this.sourceWidget.init({
  260. Wuid: this.wu.Wuid
  261. });
  262. } else if (currSel.id == this.logsWidget.id && !this.logsWidgetLoaded) {
  263. this.logsWidgetLoaded = true;
  264. this.logsWidget.init({
  265. Wuid: this.wu.Wuid
  266. });
  267. } else if (currSel.id == this.playgroundWidget.id && !this.playgroundWidgetLoaded) {
  268. this.playgroundWidgetLoaded = true;
  269. this.playgroundWidget.init({
  270. Wuid: this.wu.Wuid,
  271. Target: this.wu.Cluster
  272. });
  273. } else if (currSel.id == this.xmlWidget.id && !this.xmlWidgetLoaded) {
  274. this.xmlWidgetLoaded = true;
  275. this.xmlWidget.init({
  276. Wuid: this.wu.Wuid
  277. });
  278. }
  279. },
  280. resetPage: function () {
  281. },
  282. objectToText: function (obj) {
  283. var text = ""
  284. for (var key in obj) {
  285. text += "<tr><td>" + key + ":</td>";
  286. if (typeof obj[key] == "object") {
  287. text += "[<br/>";
  288. for (var i = 0; i < obj[key].length; ++i) {
  289. text += this.objectToText(obj[key][i]);
  290. }
  291. text += "<br/>]<br/>";
  292. } else {
  293. text += "<td>" + obj[key] + "</td></tr>";
  294. }
  295. }
  296. return text;
  297. },
  298. updateInput: function (name, oldValue, newValue) {
  299. var registryNode = registry.byId(this.id + name);
  300. if (registryNode) {
  301. registryNode.set("value", newValue);
  302. } else {
  303. var domElem = dom.byId(this.id + name);
  304. if (domElem) {
  305. switch (domElem.tagName) {
  306. case "SPAN":
  307. case "DIV":
  308. domAttr.set(this.id + name, "innerHTML", newValue);
  309. break;
  310. case "INPUT":
  311. case "TEXTAREA":
  312. domAttr.set(this.id + name, "value", newValue);
  313. break;
  314. default:
  315. alert(domElem.tagName);
  316. }
  317. }
  318. }
  319. if (name === "Protected") {
  320. dom.byId(this.id + "ProtectedImage").src = this.wu.getProtectedImage();
  321. } else if (name === "Jobname") {
  322. this.updateInput("Jobname2", oldValue, newValue);
  323. } else if (name === "VariableCount" && newValue) {
  324. this.variablesWidget.set("title", "Variables " + "(" + newValue + ")");
  325. } else if (name === "variables") {
  326. this.variablesWidget.set("title", "Variables " + "(" + newValue.length + ")");
  327. this.variablesStore.setData(newValue);
  328. this.variablesGrid.refresh();
  329. } else if (name === "ResultCount" && newValue) {
  330. this.resultsWidget.set("title", "Outputs " + "(" + newValue + ")");
  331. } else if (name === "results") {
  332. this.resultsWidget.set("title", "Outputs " + "(" + newValue.length + ")");
  333. var tooltip = "";
  334. for (var key in newValue) {
  335. if (tooltip != "")
  336. tooltip += "\n";
  337. tooltip += newValue[key].Name;
  338. if (newValue[key].Value)
  339. tooltip += " " + newValue[key].Value;
  340. }
  341. this.resultsWidget.set("tooltip", tooltip);
  342. } else if (name === "SourceFileCount" && newValue) {
  343. this.filesWidget.set("title", "Inputs " + "(" + newValue + ")");
  344. } else if (name === "sourceFiles") {
  345. this.filesWidget.set("title", "Inputs " + "(" + newValue.length + ")");
  346. var tooltip = "";
  347. for (var i = 0; i < newValue.length; ++i) {
  348. if (tooltip != "")
  349. tooltip += "\n";
  350. tooltip += newValue[i].Name;
  351. }
  352. this.filesWidget.set("tooltip", tooltip);
  353. } else if (name === "TimerCount" && newValue) {
  354. this.timersWidget.set("title", "Timers " + "(" + newValue + ")");
  355. } else if (name === "timers") {
  356. this.timersWidget.set("title", "Timers " + "(" + newValue.length + ")");
  357. var tooltip = "";
  358. for (var i = 0; i < newValue.length; ++i) {
  359. if (newValue[i].GraphName)
  360. continue;
  361. if (newValue[i].Name == "Process")
  362. dom.byId(this.id + "Time").innerHTML = newValue[i].Value;
  363. if (tooltip != "")
  364. tooltip += "\n";
  365. tooltip += newValue[i].Name;
  366. if (newValue[i].Value)
  367. tooltip += " " + newValue[i].Value;
  368. }
  369. this.timersWidget.set("tooltip", tooltip);
  370. } else if (name === "GraphCount" && newValue) {
  371. this.graphsWidget.set("title", "Graphs " + "(" + newValue + ")");
  372. } else if (name === "graphs") {
  373. this.graphsWidget.set("title", "Graphs " + "(" + newValue.length + ")");
  374. var tooltip = "";
  375. for (var i = 0; i < newValue.length; ++i) {
  376. if (tooltip != "")
  377. tooltip += "\n";
  378. tooltip += newValue[i].Name;
  379. if (newValue[i].Time)
  380. tooltip += " " + newValue[i].Time;
  381. }
  382. this.graphsWidget.set("tooltip", tooltip);
  383. } else if (name === "StateID") {
  384. this.refreshActionState();
  385. } else if (name === "ActionEx") {
  386. this.refreshActionState();
  387. } else if (name === "hasCompleted") {
  388. this.checkIfComplete();
  389. }
  390. },
  391. refreshActionState: function () {
  392. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  393. registry.byId(this.id + "Clone").set("disabled", !this.wu.isComplete());
  394. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  395. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  396. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  397. registry.byId(this.id + "Restart").set("disabled", !this.wu.isComplete());
  398. registry.byId(this.id + "Publish").set("disabled", !this.wu.isComplete());
  399. registry.byId(this.id + "Jobname").set("readOnly", !this.wu.isComplete());
  400. registry.byId(this.id + "Description").set("readOnly", !this.wu.isComplete());
  401. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  402. this.summaryWidget.set("iconClass", this.wu.getStateIconClass());
  403. domClass.remove(this.id + "StateIdImage");
  404. domClass.add(this.id + "StateIdImage", this.wu.getStateIconClass());
  405. },
  406. checkIfComplete: function() {
  407. var context = this;
  408. if (this.wu.isComplete()) {
  409. this.wu.getInfo({
  410. onGetVariables: function (response) {
  411. },
  412. onAfterSend: function (response) {
  413. var helpersCount = 0;
  414. if (response.Helpers && response.Helpers.ECLHelpFile) {
  415. helpersCount += response.Helpers.ECLHelpFile.length;
  416. }
  417. if (response.ThorLogList && response.ThorLogList.ThorLogInfo) {
  418. helpersCount += response.ThorLogList.ThorLogInfo.length;
  419. }
  420. if (response.HasArchiveQuery) {
  421. helpersCount += 1;
  422. }
  423. context.logsWidget.set("title", "Helpers " + "(" + helpersCount + ")");
  424. }
  425. });
  426. }
  427. },
  428. monitorWorkunit: function (response) {
  429. }
  430. });
  431. });