HPCCPlatformWidget.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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/_TemplatedMixin",
  21. "dijit/_WidgetsInTemplateMixin",
  22. "dijit/registry",
  23. "dijit/Tooltip",
  24. "hpcc/_TabContainerWidget",
  25. "hpcc/ESPRequest",
  26. "hpcc/WsAccount",
  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. _TemplatedMixin, _WidgetsInTemplateMixin, registry, Tooltip,
  47. _TabContainerWidget, ESPRequest, WsAccount,
  48. template) {
  49. return declare("HPCCPlatformWidget", [_TabContainerWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  50. templateString: template,
  51. baseClass: "HPCCPlatformWidget",
  52. postCreate: function (args) {
  53. this.inherited(arguments);
  54. this.searchText = registry.byId(this.id + "FindText");
  55. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  56. this.stackContainer = registry.byId(this.id + "TabContainer");
  57. this.mainPage = registry.byId(this.id + "_Main");
  58. this.mainStackContainer = registry.byId(this.mainPage.id + "TabContainer");
  59. this.searchPage = registry.byId(this.id + "_Main" + "_Search");
  60. },
  61. startup: function (args) {
  62. this.inherited(arguments);
  63. },
  64. getTitle: function () {
  65. return "HPCC Platform";
  66. },
  67. // Hitched actions ---
  68. _onFind: function (evt) {
  69. this.stackContainer.selectChild(this.mainPage);
  70. this.mainStackContainer.selectChild(this.searchPage);
  71. this.searchPage.doSearch(this.searchText.get("value"));
  72. },
  73. _onOpenLegacy: function (evt) {
  74. var win = window.open("\\", "_blank");
  75. win.focus();
  76. },
  77. _onAbout: function (evt) {
  78. },
  79. createStackControllerTooltip: function (widgetID, text) {
  80. return new Tooltip({
  81. connectId: [this.id + "StackController_" + widgetID],
  82. label: text,
  83. showDelay: 1,
  84. position: ["below"]
  85. });
  86. },
  87. // Implementation ---
  88. init: function (params) {
  89. if (this.initalized)
  90. return;
  91. this.initalized = true;
  92. var context = this;
  93. WsAccount.MyAccount({
  94. }).then(function (response) {
  95. if (lang.exists("MyAccountResponse.username", response)) {
  96. dom.byId(context.id + "UserID").innerHTML = response.MyAccountResponse.username;
  97. }
  98. },
  99. function (error) {
  100. });
  101. this.createStackControllerTooltip(this.id + "_ECL", "ECL");
  102. this.createStackControllerTooltip(this.id + "_Files", "Files");
  103. this.createStackControllerTooltip(this.id + "_Queries", "Published Queries");
  104. this.createStackControllerTooltip(this.id + "_OPS", "Operations");
  105. this.initTab();
  106. },
  107. initTab: function () {
  108. var currSel = this.getSelectedChild();
  109. if (currSel && !currSel.initalized) {
  110. if (currSel.init) {
  111. currSel.init(currSel.params);
  112. }
  113. }
  114. }
  115. });
  116. });