DFUSearchWidget.js 8.7 KB

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