ResultsWidget.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. require([
  18. "dojo/_base/declare",
  19. "dojo/_base/xhr",
  20. "dojo/dom",
  21. "dijit/layout/_LayoutWidget",
  22. "dijit/_TemplatedMixin",
  23. "dijit/_WidgetsInTemplateMixin",
  24. "dijit/layout/TabContainer",
  25. "dijit/registry",
  26. "hpcc/ESPBase",
  27. "hpcc/ESPWorkunit",
  28. "hpcc/ResultsControl",
  29. "dojo/text!./templates/ResultsWidget.html"
  30. ], function (declare, xhr, dom,
  31. _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, TabContainer, registry,
  32. ESPBase, ESPWorkunit, ResultsControl,
  33. template) {
  34. return declare("ResultsWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  35. templateString: template,
  36. baseClass: "ResultsWidget",
  37. resultsPane: null,
  38. resultsControl: null,
  39. buildRendering: function (args) {
  40. this.inherited(arguments);
  41. },
  42. postCreate: function (args) {
  43. this.inherited(arguments);
  44. this._initControls();
  45. this.resultsPane.resize();
  46. },
  47. startup: function (args) {
  48. this.inherited(arguments);
  49. },
  50. resize: function (args) {
  51. this.inherited(arguments);
  52. this.resultsPane.resize();
  53. },
  54. layout: function (args) {
  55. this.inherited(arguments);
  56. },
  57. // Implementation ---
  58. onErrorClick: function (line, col) {
  59. },
  60. _initControls: function () {
  61. var context = this;
  62. this.resultsPane = registry.byId(this.id + "ResultsPane");
  63. var context = this;
  64. this.resultsControl = new ResultsControl({
  65. resultsSheetID: this.id + "ResultsPane",
  66. sequence: 0,
  67. onErrorClick: function (line, col) {
  68. context.onErrorClick(line, col);
  69. }
  70. });
  71. },
  72. init: function (wuid, sequence, showSourceFiles) {
  73. if (wuid) {
  74. this.wu = new ESPWorkunit({
  75. wuid: wuid
  76. });
  77. var monitorCount = 4;
  78. var context = this;
  79. this.wu.monitor(function () {
  80. if (context.wu.isComplete() || ++monitorCount % 5 == 0) {
  81. if (showSourceFiles) {
  82. context.wu.getInfo({
  83. onGetSourceFiles: function (sourceFiles) {
  84. context.refreshSourceFiles(context.wu);
  85. }
  86. });
  87. } else {
  88. context.wu.getInfo({
  89. onGetResults: function (results) {
  90. context.refresh(context.wu);
  91. }
  92. });
  93. }
  94. }
  95. });
  96. }
  97. },
  98. clear: function () {
  99. this.resultsControl.clear();
  100. },
  101. refresh: function (wu) {
  102. this.resultsControl.refresh(wu);
  103. },
  104. refreshSourceFiles: function (wu) {
  105. this.resultsControl.refreshSourceFiles(wu);
  106. }
  107. });
  108. });