ECLPlaygroundResultsWidget.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. "hpcc/_TabContainerWidget",
  22. "hpcc/ESPWorkunit",
  23. "hpcc/ResultWidget",
  24. "hpcc/LFDetailsWidget",
  25. "hpcc/VizWidget",
  26. "dojo/text!../templates/ECLPlaygroundResultsWidget.html",
  27. "dijit/layout/TabContainer"
  28. ], function (declare, lang, dom,
  29. registry,
  30. _TabContainerWidget, ESPWorkunit, ResultWidget, LFDetailsWidget, VizWidget,
  31. template) {
  32. return declare("ECLPlaygroundResultsWidget", [_TabContainerWidget], {
  33. templateString: template,
  34. baseClass: "ECLPlaygroundResultsWidget",
  35. selectedTab: null,
  36. TabPosition: "bottom",
  37. onErrorClick: function (line, col) {
  38. },
  39. initTab: function () {
  40. var currSel = this.getSelectedChild();
  41. if (currSel && !currSel.initalized) {
  42. currSel.init(currSel.params);
  43. }
  44. },
  45. ensurePane: function (id, title, params) {
  46. var retVal = registry.byId(id);
  47. if (!retVal) {
  48. if (lang.exists("Wuid", params) && lang.exists("Sequence", params)) {
  49. retVal = new ResultWidget({
  50. id: id,
  51. title: title,
  52. params: params
  53. });
  54. }
  55. this.addChild(retVal);
  56. }
  57. return retVal;
  58. },
  59. init: function (params) {
  60. if (this.inherited(arguments))
  61. return;
  62. if (params.Wuid) {
  63. this.wu = ESPWorkunit.Get(params.Wuid);
  64. var monitorCount = 4;
  65. var context = this;
  66. this.wu.monitor(function () {
  67. if (context.wu.isComplete() || ++monitorCount % 5 == 0) {
  68. context.wu.getInfo({
  69. onGetResults: function (results) {
  70. if (!params.SourceFiles) {
  71. for (var i = 0; i < results.length; ++i) {
  72. var tab = context.ensurePane(context.id + "_result" + i, results[i].Name, {
  73. Wuid: results[i].Wuid,
  74. Sequence: results[i].Sequence
  75. });
  76. if (i == 0) {
  77. context.initTab();
  78. }
  79. }
  80. }
  81. }
  82. });
  83. var currSel = context.getSelectedChild();
  84. if (currSel && currSel.refresh) {
  85. currSel.refresh();
  86. }
  87. }
  88. });
  89. }
  90. },
  91. clear: function () {
  92. this.removeAllChildren();
  93. this.selectedTab = null;
  94. this.initalized = false;
  95. },
  96. refresh: function (wu) {
  97. if (this.workunit != wu) {
  98. this.clear();
  99. this.workunit = wu;
  100. this.init({
  101. Wuid: wu.Wuid
  102. });
  103. }
  104. }
  105. });
  106. });