DFUSearchWidget.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. "hpcc/ECLSourceWidget",
  31. "hpcc/TargetSelectWidget",
  32. "hpcc/GraphWidget",
  33. "hpcc/ResultsWidget",
  34. "hpcc/InfoGridWidget",
  35. "hpcc/ESPWorkunit",
  36. "dojo/text!../templates/DFUSearchWidget.html"
  37. ], function (declare, xhr, dom,
  38. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, Textarea, TitlePane, registry,
  39. EclSourceWidget, TargetSelectWidget, GraphWidget, ResultsWidget, InfoGridWidget, Workunit,
  40. template) {
  41. return declare("DFUSearchWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  42. templateString: template,
  43. baseClass: "DFUSearchWidget",
  44. borderContainer: null,
  45. tabContainer: null,
  46. resultsWidget: null,
  47. resultsWidgetLoaded: false,
  48. filesWidget: null,
  49. filesWidgetLoaded: false,
  50. timersWidget: null,
  51. timersWidgetLoaded: false,
  52. graphsWidget: null,
  53. graphsWidgetLoaded: false,
  54. sourceWidget: null,
  55. sourceWidgetLoaded: false,
  56. playgroundWidget: null,
  57. playgroundWidgetLoaded: false,
  58. xmlWidget: null,
  59. xmlWidgetLoaded: false,
  60. wu: null,
  61. loaded: false,
  62. buildRendering: function (args) {
  63. this.inherited(arguments);
  64. },
  65. postCreate: function (args) {
  66. this.inherited(arguments);
  67. this.borderContainer = registry.byId(this.id + "BorderContainer");
  68. //this.tabContainer = registry.byId(this.id + "TabContainer");
  69. //this.resultsWidget = registry.byId(this.id + "Results");
  70. //this.filesWidget = registry.byId(this.id + "Files");
  71. //this.timersWidget = registry.byId(this.id + "Timers");
  72. // this.graphsWidget = registry.byId(this.id + "Graphs");
  73. //this.sourceWidget = registry.byId(this.id + "Source");
  74. //this.playgroundWidget = registry.byId(this.id + "Playground");
  75. //this.xmlWidget = registry.byId(this.id + "XML");
  76. //this.infoGridWidget = registry.byId(this.id + "InfoContainer");
  77. var context = this;
  78. /* this.tabContainer.watch("selectedChildWidget", function (name, oval, nval) {
  79. if (nval.id == context.id + "Results" && !context.resultsWidgetLoaded) {
  80. context.resultsWidgetLoaded = true;
  81. context.resultsWidget.init({
  82. Wuid: context.wu.wuid
  83. });
  84. } else if (nval.id == context.id + "Files" && !context.filesWidgetLoaded) {
  85. context.filesWidgetLoaded = true;
  86. context.filesWidget.init({
  87. Wuid: context.wu.wuid,
  88. SourceFiles: true
  89. });
  90. } else if (nval.id == context.id + "Timers" && !context.timersWidgetLoaded) {
  91. context.timersWidgetLoaded = true;
  92. context.timersWidget.init({
  93. Wuid: context.wu.wuid
  94. });
  95. } else if (nval.id == context.id + "Graphs" && !context.graphsWidgetLoaded) {
  96. context.graphsWidgetLoaded = true;
  97. context.graphsWidget.init({
  98. Wuid: context.wu.wuid
  99. });
  100. } else if (nval.id == context.id + "Source" && !context.sourceWidgetLoaded) {
  101. context.sourceWidgetLoaded = true;
  102. context.sourceWidget.init({
  103. Wuid: context.wu.wuid
  104. });
  105. } else if (nval.id == context.id + "Playground" && !context.playgroundWidgetLoaded) {
  106. context.playgroundWidgetLoaded = true;
  107. context.playgroundWidget.init({
  108. Wuid: context.wu.wuid
  109. });
  110. } else if (nval.id == context.id + "XML" && !context.xmlWidgetLoaded) {
  111. context.xmlWidgetLoaded = true;
  112. context.xmlWidget.init({
  113. Wuid: context.wu.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. // Hitched actions ---
  129. _onSave: function (event) {
  130. },
  131. _onReset: function (event) {
  132. },
  133. _onClone: function (event) {
  134. },
  135. _onDelete: function (event) {
  136. },
  137. _onAbort: function (event) {
  138. },
  139. _onResubmit: function (event) {
  140. },
  141. _onRestart: function (event) {
  142. },
  143. _onPublish: function (event) {
  144. },
  145. // Implementation ---
  146. init: function (params) {
  147. if (this.initalized)
  148. return;
  149. this.initalized = true;
  150. //dom.byId("showWuid").innerHTML = params.Wuid;
  151. if (params.Wuid) {
  152. //dom.byId(this.id + "Wuid").innerHTML = params.Wuid;
  153. this.wu = new Workunit({
  154. wuid: params.Wuid
  155. });
  156. var context = this;
  157. this.wu.monitor(function (workunit) {
  158. context.monitorWorkunit(workunit);
  159. });
  160. }
  161. // this.infoGridWidget.init(params);
  162. },
  163. resetPage: function () {
  164. },
  165. objectToText: function (obj) {
  166. var text = ""
  167. for (var key in obj) {
  168. text += "<tr><td>" + key + ":</td>";
  169. if (typeof obj[key] == "object") {
  170. text += "[<br/>";
  171. for (var i = 0; i < obj[key].length; ++i) {
  172. text += this.objectToText(obj[key][i]);
  173. }
  174. text += "<br/>]<br/>";
  175. } else {
  176. text += "<td>" + obj[key] + "</td></tr>";
  177. }
  178. }
  179. return text;
  180. },
  181. monitorWorkunit: function (response) {
  182. if (!this.loaded) {
  183. //dom.byId(this.id + "WUInfoResponse").innerHTML = this.objectToText(response);
  184. //dom.byId("showStateIdImage").src = this.wu.getStateImage();
  185. //dom.byId("showStateIdImage").title = response.State;
  186. //dom.byId("showStateReadOnly").innerHTML = response.State;
  187. //dom.byId("showAction").innerHTML = response.ActionId;
  188. // dom.byId("showOwner").innerHTML = response.Owner;
  189. //dom.byId("showScope").value = response.Scope;
  190. //dom.byId("showJobName").value = response.Jobname;
  191. //dom.byId("showCluster").innerHTML = response.Cluster;
  192. this.loaded = true;
  193. }
  194. var context = this;
  195. if (this.wu.isComplete()) {
  196. this.wu.getInfo({
  197. onGetResults: function (response) {
  198. },
  199. onGetSourceFiles: function (response) {
  200. },
  201. onGetTimers: function (response) {
  202. },
  203. onGetGraphs: function (response) {
  204. },
  205. onAfterSend: function (response) {
  206. //dom.byId(context.id + "WUInfoResponse").innerHTML = context.objectToText(response);
  207. }
  208. });
  209. }
  210. }
  211. });
  212. });