ResultsWidget.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/xhr",
  19. "dojo/dom",
  20. "dijit/layout/_LayoutWidget",
  21. "dijit/_TemplatedMixin",
  22. "dijit/_WidgetsInTemplateMixin",
  23. "dijit/layout/TabContainer",
  24. "dijit/registry",
  25. "hpcc/ESPBase",
  26. "hpcc/ESPWorkunit",
  27. "hpcc/ResultsControl",
  28. "dojo/text!../templates/ResultsWidget.html"
  29. ], function (declare, xhr, dom,
  30. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, TabContainer, registry,
  31. ESPBase, ESPWorkunit, ResultsControl,
  32. template) {
  33. return declare("ResultsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  34. templateString: template,
  35. baseClass: "ResultsWidget",
  36. resultsPane: null,
  37. resultsControl: null,
  38. buildRendering: function (args) {
  39. this.inherited(arguments);
  40. },
  41. postCreate: function (args) {
  42. this.inherited(arguments);
  43. this._initControls();
  44. this.resultsPane.resize();
  45. },
  46. startup: function (args) {
  47. this.inherited(arguments);
  48. },
  49. resize: function (args) {
  50. this.inherited(arguments);
  51. this.resultsPane.resize();
  52. },
  53. layout: function (args) {
  54. this.inherited(arguments);
  55. },
  56. // Implementation ---
  57. onErrorClick: function (line, col) {
  58. },
  59. _initControls: function () {
  60. var context = this;
  61. this.resultsPane = registry.byId(this.id + "ResultsPane");
  62. var context = this;
  63. this.resultsControl = new ResultsControl({
  64. resultsSheetID: this.id + "ResultsPane",
  65. sequence: 0,
  66. onErrorClick: function (line, col) {
  67. context.onErrorClick(line, col);
  68. }
  69. });
  70. },
  71. init: function (params) {
  72. if (params.Wuid) {
  73. this.wu = new ESPWorkunit({
  74. wuid: params.Wuid
  75. });
  76. var monitorCount = 4;
  77. var context = this;
  78. this.wu.monitor(function () {
  79. if (context.wu.isComplete() || ++monitorCount % 5 == 0) {
  80. if (params.SourceFiles) {
  81. context.wu.getInfo({
  82. onGetSourceFiles: function (sourceFiles) {
  83. context.refreshSourceFiles(context.wu);
  84. }
  85. });
  86. } else {
  87. context.wu.getInfo({
  88. onGetResults: function (results) {
  89. context.refresh(context.wu);
  90. }
  91. });
  92. }
  93. }
  94. });
  95. }
  96. },
  97. clear: function () {
  98. this.resultsControl.clear();
  99. },
  100. refresh: function (wu) {
  101. this.resultsControl.refresh(wu);
  102. },
  103. refreshSourceFiles: function (wu) {
  104. this.resultsControl.refreshSourceFiles(wu);
  105. }
  106. });
  107. });