HPCCPlatformWidget.js 4.3 KB

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