HPCCPlatformWidget.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. "dojo/text!../templates/HPCCPlatformWidget.html",
  26. "dijit/layout/BorderContainer",
  27. "dijit/layout/TabContainer",
  28. "dijit/layout/StackContainer",
  29. "dijit/layout/StackController",
  30. "dijit/layout/ContentPane",
  31. "dijit/form/DropDownButton",
  32. "dijit/form/ComboButton",
  33. "dijit/form/TextBox",
  34. "dijit/Menu",
  35. "dijit/MenuSeparator",
  36. "dijit/Toolbar",
  37. "dijit/TooltipDialog",
  38. "hpcc/HPCCPlatformMainWidget",
  39. "hpcc/HPCCPlatformECLWidget",
  40. "hpcc/HPCCPlatformFilesWidget",
  41. "hpcc/HPCCPlatformRoxieWidget",
  42. "hpcc/HPCCPlatformOpsWidget"
  43. ], function (declare, lang, dom,
  44. registry, Tooltip,
  45. _TabContainerWidget, ESPRequest, WsAccount,
  46. template) {
  47. return declare("HPCCPlatformWidget", [_TabContainerWidget], {
  48. templateString: template,
  49. baseClass: "HPCCPlatformWidget",
  50. postCreate: function (args) {
  51. this.inherited(arguments);
  52. this.searchText = registry.byId(this.id + "FindText");
  53. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  54. this.stackContainer = registry.byId(this.id + "TabContainer");
  55. this.mainPage = registry.byId(this.id + "_Main");
  56. this.mainStackContainer = registry.byId(this.mainPage.id + "TabContainer");
  57. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  58. },
  59. startup: function (args) {
  60. this.inherited(arguments);
  61. },
  62. getTitle: function () {
  63. return "HPCC Platform";
  64. },
  65. // Hitched actions ---
  66. _onFind: function (evt) {
  67. this.stackContainer.selectChild(this.mainPage);
  68. this.mainStackContainer.selectChild(this.searchPage);
  69. this.searchPage.doSearch(this.searchText.get("value"));
  70. },
  71. _onOpenLegacy: function (evt) {
  72. var win = window.open("\\", "_blank");
  73. win.focus();
  74. },
  75. _onAbout: function (evt) {
  76. },
  77. createStackControllerTooltip: function (widgetID, text) {
  78. return new Tooltip({
  79. connectId: [this.id + "StackController_" + widgetID],
  80. label: text,
  81. showDelay: 1,
  82. position: ["below"]
  83. });
  84. },
  85. // Implementation ---
  86. init: function (params) {
  87. if (this.inherited(arguments))
  88. return;
  89. var context = this;
  90. WsAccount.MyAccount({
  91. }).then(function (response) {
  92. if (lang.exists("MyAccountResponse.username", response)) {
  93. dom.byId(context.id + "UserID").innerHTML = response.MyAccountResponse.username;
  94. }
  95. },
  96. function (error) {
  97. });
  98. this.createStackControllerTooltip(this.id + "_ECL", "ECL");
  99. this.createStackControllerTooltip(this.id + "_Files", "Files");
  100. this.createStackControllerTooltip(this.id + "_Queries", "Published Queries");
  101. this.createStackControllerTooltip(this.id + "_OPS", "Operations");
  102. this.initTab();
  103. },
  104. initTab: function () {
  105. var currSel = this.getSelectedChild();
  106. if (currSel && !currSel.initalized) {
  107. if (currSel.init) {
  108. currSel.init({});
  109. }
  110. }
  111. }
  112. });
  113. });