HPCCPlatformWidget.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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-style",
  21. "dijit/registry",
  22. "dijit/Tooltip",
  23. "dojox/widget/UpgradeBar",
  24. "hpcc/_TabContainerWidget",
  25. "hpcc/ESPRequest",
  26. "hpcc/WsAccount",
  27. "hpcc/WsSMC",
  28. "hpcc/GraphWidget",
  29. "dojo/text!../templates/HPCCPlatformWidget.html",
  30. "dijit/layout/BorderContainer",
  31. "dijit/layout/TabContainer",
  32. "dijit/layout/StackContainer",
  33. "dijit/layout/StackController",
  34. "dijit/layout/ContentPane",
  35. "dijit/form/DropDownButton",
  36. "dijit/form/ComboButton",
  37. "dijit/form/TextBox",
  38. "dijit/Menu",
  39. "dijit/MenuSeparator",
  40. "dijit/Toolbar",
  41. "dijit/TooltipDialog",
  42. "hpcc/HPCCPlatformMainWidget",
  43. "hpcc/HPCCPlatformECLWidget",
  44. "hpcc/HPCCPlatformFilesWidget",
  45. "hpcc/HPCCPlatformRoxieWidget",
  46. "hpcc/HPCCPlatformOpsWidget"
  47. ], function (declare, lang, dom, domStyle,
  48. registry, Tooltip,
  49. UpgradeBar,
  50. _TabContainerWidget, ESPRequest, WsAccount, WsSMC, GraphWidget,
  51. template) {
  52. return declare("HPCCPlatformWidget", [_TabContainerWidget], {
  53. templateString: template,
  54. baseClass: "HPCCPlatformWidget",
  55. banner: "",
  56. upgradeBar: null,
  57. postCreate: function (args) {
  58. this.inherited(arguments);
  59. this.searchText = registry.byId(this.id + "FindText");
  60. this.aboutDialog = registry.byId(this.id + "AboutDialog");
  61. this.setBannerDialog = registry.byId(this.id + "SetBannerDialog");
  62. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  63. this.stackContainer = registry.byId(this.id + "TabContainer");
  64. this.mainPage = registry.byId(this.id + "_Main");
  65. this.errWarnPage = registry.byId(this.id + "_ErrWarn");
  66. this.mainStackContainer = registry.byId(this.mainPage.id + "TabContainer");
  67. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  68. this.upgradeBar = new UpgradeBar({
  69. notifications: [],
  70. noRemindButton: ""
  71. });
  72. },
  73. startup: function (args) {
  74. this.inherited(arguments);
  75. domStyle.set(dom.byId(this.id + "StackController_stub_ErrWarn").parentNode.parentNode, {
  76. visibility: "hidden"
  77. });
  78. },
  79. // Implementation ---
  80. parseBuildString: function (build) {
  81. this.build = {};
  82. this.build.orig = build;
  83. this.build.prefix = "";
  84. this.build.postfix = "";
  85. var verArray = build.split("[");
  86. if (verArray.length > 1) {
  87. this.build.postfix = verArray[1].split("]")[0];
  88. }
  89. verArray = verArray[0].split("_");
  90. if (verArray.length > 1) {
  91. this.build.prefix = verArray[0];
  92. verArray.splice(0, 1);
  93. }
  94. this.build.version = verArray.join("_");
  95. },
  96. refreshActivityResponse: function(response) {
  97. if (lang.exists("ActivityResponse.Build", response)) {
  98. this.parseBuildString(response.ActivityResponse.Build);
  99. this.banner = lang.exists("ActivityResponse.BannerContent", response) ? response.ActivityResponse.BannerContent : "";
  100. if (this.banner) {
  101. this.upgradeBar.notify("<div style='text-align:center'><b>" + this.banner + "</b></div>");
  102. this.upgradeBar.show();
  103. }
  104. }
  105. },
  106. init: function (params) {
  107. if (this.inherited(arguments))
  108. return;
  109. var context = this;
  110. WsAccount.MyAccount({
  111. }).then(function (response) {
  112. if (lang.exists("MyAccountResponse.username", response)) {
  113. dom.byId(context.id + "UserID").innerHTML = response.MyAccountResponse.username;
  114. }
  115. });
  116. WsSMC.Activity({
  117. }).then(function (response) {
  118. context.refreshActivityResponse(response);
  119. });
  120. this.createStackControllerTooltip(this.id + "_ECL", "ECL");
  121. this.createStackControllerTooltip(this.id + "_Files", "Files");
  122. this.createStackControllerTooltip(this.id + "_Queries", "Published Queries");
  123. this.createStackControllerTooltip(this.id + "_OPS", "Operations");
  124. this.initTab();
  125. },
  126. initTab: function () {
  127. var currSel = this.getSelectedChild();
  128. if (currSel && !currSel.initalized) {
  129. if (currSel.init) {
  130. currSel.init({});
  131. }
  132. }
  133. },
  134. getTitle: function () {
  135. return "HPCC Platform";
  136. },
  137. // Hitched actions ---
  138. _onFind: function (evt) {
  139. this.stackContainer.selectChild(this.mainPage);
  140. this.mainStackContainer.selectChild(this.searchPage);
  141. this.searchPage.doSearch(this.searchText.get("value"));
  142. },
  143. _onOpenLegacy: function (evt) {
  144. var win = window.open("\\", "_blank");
  145. win.focus();
  146. },
  147. _onOpenReleaseNotes: function (evt) {
  148. var win = window.open("http://hpccsystems.com/download/free-community-edition-known-limitations#" + this.build.version, "_blank");
  149. win.focus();
  150. },
  151. _onOpenErrWarn: function (evt) {
  152. this.stackContainer.selectChild(this.errWarnPage);
  153. },
  154. _onAboutLoaded: false,
  155. _onAbout: function (evt) {
  156. if (!this._onAboutLoaded) {
  157. this._onAboutLoaded = true;
  158. dom.byId(this.id + "ServerVersion").value = this.build.version;
  159. var gc = registry.byId(this.id + "GraphControl");
  160. dom.byId(this.id + "GraphControlVersion").value = gc.getVersion();
  161. }
  162. this.aboutDialog.show();
  163. },
  164. _onAboutClose: function (evt) {
  165. this.aboutDialog.hide();
  166. },
  167. _onSetBanner: function (evt) {
  168. dom.byId(this.id + "BannerText").value = this.banner;
  169. this.setBannerDialog.show();
  170. },
  171. _onSetBannerOk: function (evt) {
  172. var context = this;
  173. WsSMC.Activity({
  174. request: {
  175. FromSubmitBtn: true,
  176. BannerAction: dom.byId(this.id + "BannerText").value != "",
  177. EnableChatURL: 0,
  178. BannerContent: dom.byId(this.id + "BannerText").value,
  179. BannerColor: "red",
  180. BannerSize: 4,
  181. BannerScroll: 2
  182. }
  183. }).then(function (response) {
  184. context.refreshActivityResponse(response);
  185. });
  186. this.setBannerDialog.hide();
  187. },
  188. _onSetBannerCancel: function (evt) {
  189. this.setBannerDialog.hide();
  190. },
  191. createStackControllerTooltip: function (widgetID, text) {
  192. return new Tooltip({
  193. connectId: [this.id + "StackController_" + widgetID],
  194. label: text,
  195. showDelay: 1,
  196. position: ["below"]
  197. });
  198. }
  199. });
  200. });