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