LFDetailsWidget.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/dom",
  20. "dojo/dom-class",
  21. "dijit/layout/_LayoutWidget",
  22. "dijit/_TemplatedMixin",
  23. "dijit/_WidgetsInTemplateMixin",
  24. "dijit/layout/BorderContainer",
  25. "dijit/layout/TabContainer",
  26. "dijit/layout/ContentPane",
  27. "dijit/Toolbar",
  28. "dijit/TooltipDialog",
  29. "dijit/form/SimpleTextarea",
  30. "dijit/form/Button",
  31. "dijit/TitlePane",
  32. "dijit/registry",
  33. "hpcc/ResultWidget",
  34. "hpcc/ECLSourceWidget",
  35. "hpcc/FilePartsWidget",
  36. "hpcc/WUDetailsWidget",
  37. "hpcc/DFUWUDetailsWidget",
  38. "hpcc/ESPLogicalFile",
  39. "dojo/text!../templates/LFDetailsWidget.html"
  40. ], function (declare, lang, dom, domClass,
  41. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, TooltipDialog, SimpleTextarea, Button, TitlePane, registry,
  42. ResultWidget, EclSourceWidget, FilePartsWidget, WUDetailsWidget, DFUWUDetailsWidget,
  43. ESPLogicalFile,
  44. template) {
  45. return declare("LFDetailsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  46. templateString: template,
  47. baseClass: "LFDetailsWidget",
  48. borderContainer: null,
  49. tabContainer: null,
  50. resultWidget: null,
  51. resultWidgetLoaded: false,
  52. sourceWidget: null,
  53. sourceWidgetLoaded: false,
  54. defWidget: null,
  55. defWidgetLoaded: false,
  56. xmlWidget: null,
  57. xmlWidgetLoaded: false,
  58. filePartsWidget: null,
  59. filePartsWidgetLoaded: false,
  60. workunitWidget: null,
  61. workunitWidgetLoaded: false,
  62. dfuWorkunitWidget: null,
  63. dfuWorkunitWidgetLoaded: false,
  64. legacyPane: null,
  65. legacyPaneLoaded: false,
  66. logicalFile: null,
  67. prevState: "",
  68. initiated: false,
  69. buildRendering: function (args) {
  70. this.inherited(arguments);
  71. },
  72. postCreate: function (args) {
  73. this.inherited(arguments);
  74. this.borderContainer = registry.byId(this.id + "BorderContainer");
  75. this.tabContainer = registry.byId(this.id + "TabContainer");
  76. this.resultWidget = registry.byId(this.id + "Content");
  77. this.sourceWidget = registry.byId(this.id + "Source");
  78. this.defWidget = registry.byId(this.id + "DEF");
  79. this.xmlWidget = registry.byId(this.id + "XML");
  80. this.filePartsWidget = registry.byId(this.id + "FileParts");
  81. this.workunitWidget = registry.byId(this.id + "Workunit");
  82. this.dfuWorkunitWidget = registry.byId(this.id + "DFUWorkunit");
  83. this.legacyPane = registry.byId(this.id + "Legacy");
  84. var context = this;
  85. this.tabContainer.watch("selectedChildWidget", function (name, oval, nval) {
  86. if (nval.id == context.id + "Content" && !context.resultWidgetLoaded) {
  87. context.resultWidgetLoaded = true;
  88. context.resultWidget.init({
  89. result: context.logicalFile.result
  90. });
  91. } else if (nval.id == context.id + "Source" && !context.sourceWidgetLoaded) {
  92. context.sourceWidgetLoaded = true;
  93. context.sourceWidget.init({
  94. ECL: context.logicalFile.DFUInfoResponse.Ecl
  95. });
  96. } else if (nval.id == context.id + "DEF" && !context.defWidgetLoaded) {
  97. context.logicalFile.fetchDEF(function (response) {
  98. context.defWidgetLoaded = true;
  99. context.defWidget.init({
  100. ECL: response
  101. });
  102. });
  103. } else if (nval.id == context.id + "XML" && !context.xmlWidgetLoaded) {
  104. context.logicalFile.fetchXML(function (response) {
  105. context.xmlWidgetLoaded = true;
  106. context.xmlWidget.init({
  107. ECL: response
  108. });
  109. });
  110. } else if (nval.id == context.id + "FileParts" && !context.filePartsWidgetLoaded) {
  111. context.filePartsWidgetLoaded = true;
  112. context.filePartsWidget.init({
  113. fileParts: lang.exists("logicalFile.DFUInfoResponse.DFUFileParts.DFUPart", context) ? context.logicalFile.DFUInfoResponse.DFUFileParts.DFUPart : []
  114. });
  115. } else if (nval.id == context.id + "Workunit" && !context.workunitWidgetLoaded) {
  116. context.workunitWidgetLoaded = true;
  117. context.workunitWidget.init({
  118. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  119. });
  120. } else if (nval.id == context.id + "DFUWorkunit" && !context.workunitWidgetLoaded) {
  121. context.dfuWorkunitWidgetLoaded = true;
  122. context.dfuWorkunitWidget.init({
  123. Wuid: context.logicalFile.DFUInfoResponse.Wuid
  124. });
  125. } else if (nval.id == context.id + "Legacy" && !context.legacyPaneLoaded) {
  126. context.legacyPaneLoaded = true;
  127. context.legacyPane.set("content", dojo.create("iframe", {
  128. src: "/WsDfu/DFUInfo?Name=" + context.logicalFile.logicalName + "&Cluster=" + context.logicalFile.cluster,
  129. style: "border: 0; width: 100%; height: 100%"
  130. }));
  131. }
  132. });
  133. },
  134. startup: function (args) {
  135. this.inherited(arguments);
  136. },
  137. resize: function (args) {
  138. this.inherited(arguments);
  139. this.borderContainer.resize();
  140. },
  141. layout: function (args) {
  142. this.inherited(arguments);
  143. },
  144. // Hitched actions ---
  145. _onSave: function (event) {
  146. var context = this;
  147. this.logicalFile.save(dom.byId(context.id + "Description").value, {
  148. onGetAll: function (response) {
  149. context.refreshFileDetails(response);
  150. }
  151. });
  152. },
  153. _onRename: function (event) {
  154. var context = this;
  155. this.logicalFile.rename(dom.byId(this.id + "LogicalFileName2").innerHTML, {
  156. onGetAll: function (response) {
  157. context.refreshFileDetails(response);
  158. }
  159. });
  160. },
  161. _onDelete: function (event) {
  162. this.logicalFile.doDelete({
  163. load: function (response) {
  164. //TODO
  165. }
  166. });
  167. },
  168. _onCopy: function (event) {
  169. this.logicalFile.copy({
  170. load: function (response) {
  171. //TODO
  172. }
  173. });
  174. },
  175. _onDespray: function (event) {
  176. var context = this;
  177. this.logicalFile.despray({
  178. load: function (response) {
  179. }
  180. });
  181. },
  182. // Implementation ---
  183. init: function (params) {
  184. if (!this.initiated) {
  185. this.initiated = true;
  186. if (params.Name) {
  187. dom.byId(this.id + "LogicalFileName").innerHTML = params.Name;
  188. //dom.byId(this.id + "LogicalFileName2").value = params.Name;
  189. this.logicalFile = new ESPLogicalFile({
  190. cluster: params.Cluster,
  191. logicalName: params.Name
  192. });
  193. this.refreshPage();
  194. }
  195. }
  196. },
  197. showMessage: function (msg) {
  198. },
  199. /*isComplete: function () {
  200. return true;
  201. },*/
  202. refreshPage: function () {
  203. var context = this;
  204. this.logicalFile.getInfo({
  205. onGetAll: function (response) {
  206. context.refreshFileDetails(response);
  207. }
  208. });
  209. },
  210. refreshFileDetails: function (fileDetails) {
  211. if (fileDetails.Wuid && fileDetails.Wuid[0] == "D" && this.workunitWidget) {
  212. this.tabContainer.removeChild(this.workunitWidget);
  213. this.workunitWidget.destroyRecursive();
  214. this.workunitWidget = null;
  215. } else if (this.dfuWorkunitWidget) {
  216. this.tabContainer.removeChild(this.dfuWorkunitWidget);
  217. this.dfuWorkunitWidget.destroyRecursive();
  218. this.dfuWorkunitWidget = null;
  219. }
  220. registry.byId(this.id + "Summary").set("title", fileDetails.Filename);
  221. //registry.byId(this.id + "Summary").set("iconClass", "iconRefresh");
  222. //domClass.remove(this.id + "Test");
  223. //domClass.add(this.id + "Test", "iconRefresh");
  224. dom.byId(this.id + "Owner").innerHTML = fileDetails.Owner;
  225. dom.byId(this.id + "Description").value = fileDetails.Description;
  226. dom.byId(this.id + "JobName").innerHTML = fileDetails.JobName;
  227. dom.byId(this.id + "Wuid").innerHTML = fileDetails.Wuid;
  228. dom.byId(this.id + "Modification").innerHTML = fileDetails.Modified + " (UTC/GMT)";
  229. dom.byId(this.id + "Directory").innerHTML = fileDetails.Dir;
  230. dom.byId(this.id + "RecordSize").innerHTML = fileDetails.RecordSize;
  231. dom.byId(this.id + "Count").innerHTML = fileDetails.RecordCount;
  232. this.resultWidget.set("title", "Content " + "(" + fileDetails.RecordCount + ")");
  233. dom.byId(this.id + "Filesize").innerHTML = fileDetails.Filesize;
  234. dom.byId(this.id + "Pathmask").innerHTML = fileDetails.PathMask;
  235. }
  236. });
  237. });