WUDetailsWidget.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. if (!this.vizWidget.supportsSvg()) {
  110. this.vizWidget.set("disabled", true);
  111. }
  112. this.timersWidget = registry.byId(this.id + "_Timers");
  113. this.graphsWidget = registry.byId(this.id + "_Graphs");
  114. this.sourceWidget = registry.byId(this.id + "_Source");
  115. this.logsWidget = registry.byId(this.id + "_Logs");
  116. this.playgroundWidget = registry.byId(this.id + "_Playground");
  117. this.xmlWidget = registry.byId(this.id + "_XML");
  118. this.publishForm = registry.byId(this.id + "PublishForm");
  119. this.zapDescription = registry.byId(this.id + "ZapDescription");
  120. this.warnHistory = registry.byId(this.id + "WarnHistory");
  121. this.warnTimings = registry.byId(this.id + "WarnTimings");
  122. this.infoGridWidget = registry.byId(this.id + "InfoContainer");
  123. this.zapDialog = registry.byId(this.id + "ZapDialog");
  124. },
  125. startup: function (args) {
  126. this.inherited(arguments);
  127. var store = new Memory({
  128. idProperty: "Id",
  129. data: []
  130. });
  131. this.variablesStore = Observable(store);
  132. this.variablesGrid = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry])({
  133. allowSelectAll: true,
  134. columns: {
  135. Name: { label: "Name", width: 360 },
  136. Value: { label: "Value" }
  137. },
  138. store: this.variablesStore
  139. }, this.id + "VariablesGrid");
  140. this.variablesGrid.startup();
  141. },
  142. destroy: function (args) {
  143. this.zapDialog.destroyRecursive();
  144. this.inherited(arguments);
  145. },
  146. getTitle: function () {
  147. return this.i18n.title;
  148. },
  149. _onCancelDialog: function (){
  150. this.zapDialog.hide();
  151. },
  152. // Hitched actions ---
  153. _onSave: function (event) {
  154. var protectedCheckbox = registry.byId(this.id + "Protected");
  155. var context = this;
  156. this.wu.update({
  157. Description: dom.byId(context.id + "Description").value,
  158. Jobname: dom.byId(context.id + "Jobname").value,
  159. Protected: protectedCheckbox.get("value")
  160. }, null);
  161. },
  162. _onRefresh: function (event) {
  163. this.wu.refresh(true);
  164. },
  165. _onClone: function (event) {
  166. this.wu.clone();
  167. },
  168. _onDelete: function (event) {
  169. this.wu.doDelete();
  170. },
  171. _onResubmit: function (event) {
  172. this.wu.resubmit();
  173. },
  174. _onSetToFailed: function (event) {
  175. this.wu.setToFailed();
  176. },
  177. _onAbort: function (event) {
  178. this.wu.abort();
  179. },
  180. _onRestart: function (event) {
  181. this.wu.restart();
  182. },
  183. _onPublish: function (event) {
  184. if (this.publishForm.validate()) {
  185. registry.byId(this.id + "Publish").closeDropDown();
  186. this.wu.publish(dom.byId(this.id + "Jobname2").value, dom.byId(this.id + "RemoteDali").value);
  187. }
  188. },
  189. onZapReport: function (event) {
  190. var context = this;
  191. WsWorkunits.WUGetZAPInfo({
  192. request: {
  193. WUID: this.wu.Wuid
  194. }
  195. }).then(function (response) {
  196. context.zapDialog.show();
  197. if (lang.exists("WUGetZAPInfoResponse", response)) {
  198. context.updateInput("ZapWUID", null, response.WUGetZAPInfoResponse.WUID);
  199. context.updateInput("BuildVersion", null, response.WUGetZAPInfoResponse.BuildVersion);
  200. context.updateInput("ESPIPAddress", null, response.WUGetZAPInfoResponse.ESPIPAddress);
  201. context.updateInput("ThorIPAddress", null, response.WUGetZAPInfoResponse.ThorIPAddress);
  202. context.buildVersion = response.WUGetZAPInfoResponse.BuildVersion;
  203. context.espIPAddress = response.WUGetZAPInfoResponse.ESPIPAddress;
  204. context.thorIPAddress = response.WUGetZAPInfoResponse.ThorIPAddress;
  205. }
  206. });
  207. },
  208. // Implementation ---
  209. init: function (params) {
  210. if (this.inherited(arguments))
  211. return;
  212. if (params.Wuid) {
  213. this.summaryWidget.set("title", params.Wuid);
  214. dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  215. this.wu = ESPWorkunit.Get(params.Wuid);
  216. var data = this.wu.getData();
  217. for (var key in data) {
  218. this.updateInput(key, null, data[key]);
  219. }
  220. var context = this;
  221. this.wu.watch(function (name, oldValue, newValue) {
  222. context.updateInput(name, oldValue, newValue);
  223. });
  224. this.wu.refresh();
  225. }
  226. this.infoGridWidget.init(params);
  227. this.selectChild(this.summaryWidget, true);
  228. },
  229. initTab: function () {
  230. if (!this.wu) {
  231. return
  232. }
  233. var currSel = this.getSelectedChild();
  234. if (currSel.id == this.resultsWidget.id && !this.resultsWidgetLoaded) {
  235. this.resultsWidgetLoaded = true;
  236. this.resultsWidget.init({
  237. Wuid: this.wu.Wuid
  238. });
  239. } else if (currSel.id == this.filesWidget.id && !this.filesWidgetLoaded) {
  240. this.filesWidgetLoaded = true;
  241. this.filesWidget.init({
  242. Wuid: this.wu.Wuid,
  243. SourceFiles: true
  244. });
  245. } else if (currSel.id == this.timersWidget.id && !this.timersWidgetLoaded) {
  246. this.timersWidgetLoaded = true;
  247. this.timersWidget.init({
  248. Wuid: this.wu.Wuid
  249. });
  250. } else if (currSel.id == this.graphsWidget.id && !this.graphsWidgetLoaded) {
  251. this.graphsWidgetLoaded = true;
  252. this.graphsWidget.init({
  253. Wuid: this.wu.Wuid
  254. });
  255. } else if (currSel.id == this.vizWidget.id && !this.vizWidgetLoaded) {
  256. this.vizWidgetLoaded = true;
  257. this.vizWidget.init({
  258. Wuid: this.wu.Wuid
  259. });
  260. } else if (currSel.id == this.sourceWidget.id && !this.sourceWidgetLoaded) {
  261. this.sourceWidgetLoaded = true;
  262. this.sourceWidget.init({
  263. Wuid: this.wu.Wuid
  264. });
  265. } else if (currSel.id == this.logsWidget.id && !this.logsWidgetLoaded) {
  266. this.logsWidgetLoaded = true;
  267. this.logsWidget.init({
  268. Wuid: this.wu.Wuid
  269. });
  270. } else if (currSel.id == this.playgroundWidget.id && !this.playgroundWidgetLoaded) {
  271. this.playgroundWidgetLoaded = true;
  272. this.playgroundWidget.init({
  273. Wuid: this.wu.Wuid,
  274. Target: this.wu.Cluster
  275. });
  276. } else if (currSel.id == this.xmlWidget.id && !this.xmlWidgetLoaded) {
  277. this.xmlWidgetLoaded = true;
  278. this.xmlWidget.init({
  279. Wuid: this.wu.Wuid
  280. });
  281. }
  282. },
  283. resetPage: function () {
  284. },
  285. objectToText: function (obj) {
  286. var text = ""
  287. for (var key in obj) {
  288. text += "<tr><td>" + key + ":</td>";
  289. if (typeof obj[key] == "object") {
  290. text += "[<br/>";
  291. for (var i = 0; i < obj[key].length; ++i) {
  292. text += this.objectToText(obj[key][i]);
  293. }
  294. text += "<br/>]<br/>";
  295. } else {
  296. text += "<td>" + obj[key] + "</td></tr>";
  297. }
  298. }
  299. return text;
  300. },
  301. updateInput: function (name, oldValue, newValue) {
  302. var registryNode = registry.byId(this.id + name);
  303. if (registryNode) {
  304. registryNode.set("value", newValue);
  305. } else {
  306. var domElem = dom.byId(this.id + name);
  307. if (domElem) {
  308. switch (domElem.tagName) {
  309. case "SPAN":
  310. case "DIV":
  311. domAttr.set(this.id + name, "innerHTML", newValue);
  312. break;
  313. case "INPUT":
  314. case "TEXTAREA":
  315. domAttr.set(this.id + name, "value", newValue);
  316. break;
  317. default:
  318. alert(domElem.tagName);
  319. }
  320. }
  321. }
  322. if (name === "Protected") {
  323. dom.byId(this.id + "ProtectedImage").src = this.wu.getProtectedImage();
  324. } else if (name === "Jobname") {
  325. this.updateInput("Jobname2", oldValue, newValue);
  326. } else if (name === "VariableCount" && newValue) {
  327. this.variablesWidget.set("title", "Variables " + "(" + newValue + ")");
  328. } else if (name === "variables") {
  329. this.variablesWidget.set("title", "Variables " + "(" + newValue.length + ")");
  330. this.variablesStore.setData(newValue);
  331. this.variablesGrid.refresh();
  332. } else if (name === "ResultCount" && newValue) {
  333. this.resultsWidget.set("title", "Outputs " + "(" + newValue + ")");
  334. } else if (name === "results") {
  335. this.resultsWidget.set("title", "Outputs " + "(" + newValue.length + ")");
  336. var tooltip = "";
  337. for (var key in newValue) {
  338. if (tooltip != "")
  339. tooltip += "\n";
  340. tooltip += newValue[key].Name;
  341. if (newValue[key].Value)
  342. tooltip += " " + newValue[key].Value;
  343. }
  344. this.resultsWidget.set("tooltip", tooltip);
  345. } else if (name === "SourceFileCount" && newValue) {
  346. this.filesWidget.set("title", "Inputs " + "(" + newValue + ")");
  347. } else if (name === "sourceFiles") {
  348. this.filesWidget.set("title", "Inputs " + "(" + newValue.length + ")");
  349. var tooltip = "";
  350. for (var i = 0; i < newValue.length; ++i) {
  351. if (tooltip != "")
  352. tooltip += "\n";
  353. tooltip += newValue[i].Name;
  354. }
  355. this.filesWidget.set("tooltip", tooltip);
  356. } else if (name === "TimerCount" && newValue) {
  357. this.timersWidget.set("title", "Timers " + "(" + newValue + ")");
  358. } else if (name === "timers") {
  359. this.timersWidget.set("title", "Timers " + "(" + newValue.length + ")");
  360. var tooltip = "";
  361. for (var i = 0; i < newValue.length; ++i) {
  362. if (newValue[i].GraphName)
  363. continue;
  364. if (newValue[i].Name == "Process")
  365. dom.byId(this.id + "Time").innerHTML = newValue[i].Value;
  366. if (tooltip != "")
  367. tooltip += "\n";
  368. tooltip += newValue[i].Name;
  369. if (newValue[i].Value)
  370. tooltip += " " + newValue[i].Value;
  371. }
  372. this.timersWidget.set("tooltip", tooltip);
  373. } else if (name === "GraphCount" && newValue) {
  374. this.graphsWidget.set("title", "Graphs " + "(" + newValue + ")");
  375. } else if (name === "graphs") {
  376. this.graphsWidget.set("title", "Graphs " + "(" + newValue.length + ")");
  377. var tooltip = "";
  378. for (var i = 0; i < newValue.length; ++i) {
  379. if (tooltip != "")
  380. tooltip += "\n";
  381. tooltip += newValue[i].Name;
  382. if (newValue[i].Time)
  383. tooltip += " " + newValue[i].Time;
  384. }
  385. this.graphsWidget.set("tooltip", tooltip);
  386. } else if (name === "StateID") {
  387. this.refreshActionState();
  388. } else if (name === "ActionEx") {
  389. this.refreshActionState();
  390. } else if (name === "hasCompleted") {
  391. this.checkIfComplete();
  392. }
  393. },
  394. refreshActionState: function () {
  395. registry.byId(this.id + "Save").set("disabled", !this.wu.isComplete());
  396. registry.byId(this.id + "Clone").set("disabled", !this.wu.isComplete());
  397. registry.byId(this.id + "Delete").set("disabled", !this.wu.isComplete());
  398. registry.byId(this.id + "Abort").set("disabled", this.wu.isComplete());
  399. registry.byId(this.id + "Resubmit").set("disabled", !this.wu.isComplete());
  400. registry.byId(this.id + "Restart").set("disabled", !this.wu.isComplete());
  401. registry.byId(this.id + "Publish").set("disabled", !this.wu.isComplete());
  402. registry.byId(this.id + "Jobname").set("readOnly", !this.wu.isComplete());
  403. registry.byId(this.id + "Description").set("readOnly", !this.wu.isComplete());
  404. registry.byId(this.id + "Protected").set("readOnly", !this.wu.isComplete());
  405. this.summaryWidget.set("iconClass", this.wu.getStateIconClass());
  406. domClass.remove(this.id + "StateIdImage");
  407. domClass.add(this.id + "StateIdImage", this.wu.getStateIconClass());
  408. },
  409. checkIfComplete: function() {
  410. var context = this;
  411. if (this.wu.isComplete()) {
  412. this.wu.getInfo({
  413. onGetVariables: function (response) {
  414. },
  415. onAfterSend: function (response) {
  416. var helpersCount = 0;
  417. if (response.Helpers && response.Helpers.ECLHelpFile) {
  418. helpersCount += response.Helpers.ECLHelpFile.length;
  419. }
  420. if (response.ThorLogList && response.ThorLogList.ThorLogInfo) {
  421. helpersCount += response.ThorLogList.ThorLogInfo.length;
  422. }
  423. if (response.HasArchiveQuery) {
  424. helpersCount += 1;
  425. }
  426. context.logsWidget.set("title", "Helpers " + "(" + helpersCount + ")");
  427. }
  428. });
  429. }
  430. },
  431. monitorWorkunit: function (response) {
  432. }
  433. });
  434. });