HPCCPlatformWidget.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. "dijit/registry",
  21. "dijit/Tooltip",
  22. "hpcc/_TabContainerWidget",
  23. "hpcc/ESPRequest",
  24. "hpcc/WsAccount",
  25. "hpcc/WsSMC",
  26. "hpcc/GraphWidget",
  27. "dojo/text!../templates/HPCCPlatformWidget.html",
  28. "dijit/layout/BorderContainer",
  29. "dijit/layout/TabContainer",
  30. "dijit/layout/StackContainer",
  31. "dijit/layout/StackController",
  32. "dijit/layout/ContentPane",
  33. "dijit/form/DropDownButton",
  34. "dijit/form/ComboButton",
  35. "dijit/form/TextBox",
  36. "dijit/Menu",
  37. "dijit/MenuSeparator",
  38. "dijit/Toolbar",
  39. "dijit/TooltipDialog",
  40. "hpcc/HPCCPlatformMainWidget",
  41. "hpcc/HPCCPlatformECLWidget",
  42. "hpcc/HPCCPlatformFilesWidget",
  43. "hpcc/HPCCPlatformRoxieWidget",
  44. "hpcc/HPCCPlatformOpsWidget"
  45. ], function (declare, lang, dom,
  46. registry, Tooltip,
  47. _TabContainerWidget, ESPRequest, WsAccount, WsSMC, GraphWidget,
  48. template) {
  49. return declare("HPCCPlatformWidget", [_TabContainerWidget], {
  50. templateString: template,
  51. baseClass: "HPCCPlatformWidget",
  52. postCreate: function (args) {
  53. this.inherited(arguments);
  54. this.searchText = registry.byId(this.id + "FindText");
  55. this.aboutDialog = registry.byId(this.id + "AboutDialog");
  56. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  57. this.stackContainer = registry.byId(this.id + "TabContainer");
  58. this.mainPage = registry.byId(this.id + "_Main");
  59. this.mainStackContainer = registry.byId(this.mainPage.id + "TabContainer");
  60. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  61. },
  62. startup: function (args) {
  63. this.inherited(arguments);
  64. },
  65. getTitle: function () {
  66. return "HPCC Platform";
  67. },
  68. // Hitched actions ---
  69. _onFind: function (evt) {
  70. this.stackContainer.selectChild(this.mainPage);
  71. this.mainStackContainer.selectChild(this.searchPage);
  72. this.searchPage.doSearch(this.searchText.get("value"));
  73. },
  74. _onOpenLegacy: function (evt) {
  75. var win = window.open("\\", "_blank");
  76. win.focus();
  77. },
  78. _onAboutLoaded: false,
  79. _onAbout: function (evt) {
  80. if (!this._onAboutLoaded) {
  81. this._onAboutLoaded = true;
  82. var context = this;
  83. WsSMC.Activity({
  84. }).then(function (response) {
  85. if (lang.exists("ActivityResponse.Build", response)) {
  86. dom.byId(context.id + "ServerVersion").value = response.ActivityResponse.Build;
  87. }
  88. var gc = registry.byId(context.id + "GraphControl");
  89. dom.byId(context.id + "GraphControlVersion").value = gc.getVersion();
  90. });
  91. }
  92. this.aboutDialog.show();
  93. },
  94. _onAboutClose: function (evt) {
  95. this.aboutDialog.hide();
  96. },
  97. createStackControllerTooltip: function (widgetID, text) {
  98. return new Tooltip({
  99. connectId: [this.id + "StackController_" + widgetID],
  100. label: text,
  101. showDelay: 1,
  102. position: ["below"]
  103. });
  104. },
  105. // Implementation ---
  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. this.createStackControllerTooltip(this.id + "_ECL", "ECL");
  117. this.createStackControllerTooltip(this.id + "_Files", "Files");
  118. this.createStackControllerTooltip(this.id + "_Queries", "Published Queries");
  119. this.createStackControllerTooltip(this.id + "_OPS", "Operations");
  120. this.initTab();
  121. },
  122. initTab: function () {
  123. var currSel = this.getSelectedChild();
  124. if (currSel && !currSel.initalized) {
  125. if (currSel.init) {
  126. currSel.init({});
  127. }
  128. }
  129. }
  130. });
  131. });