ActivityWidget.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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/_base/array",
  20. "dojo/on",
  21. "dijit/form/Button",
  22. "dgrid/OnDemandGrid",
  23. "dgrid/Keyboard",
  24. "dgrid/Selection",
  25. "dgrid/selector",
  26. "dgrid/extensions/ColumnResizer",
  27. "dgrid/extensions/DijitRegistry",
  28. "hpcc/GridDetailsWidget",
  29. "hpcc/ESPWorkunit",
  30. "hpcc/ESPDFUWorkunit",
  31. "hpcc/WsSMC",
  32. "hpcc/WUDetailsWidget",
  33. "hpcc/DFUWUDetailsWidget",
  34. "hpcc/ESPUtil"
  35. ], function (declare, lang, arrayUtil, on,
  36. Button,
  37. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  38. GridDetailsWidget, ESPWorkunit, ESPDFUWorkunit, WsSMC, WUDetailsWidget, DFUWUDetailsWidget, ESPUtil) {
  39. return declare("ActivityWidget", [GridDetailsWidget], {
  40. gridTitle: "Activity",
  41. idProperty: "Wuid",
  42. doSearch: function (searchText) {
  43. this.searchText = searchText;
  44. this.selectChild(this.gridTab);
  45. this.refreshGrid();
  46. },
  47. init: function (params) {
  48. if (this.inherited(arguments))
  49. return;
  50. this._refreshActionState();
  51. },
  52. getTitle: function () {
  53. return "Activity";
  54. },
  55. createGrid: function (domID) {
  56. var context = this;
  57. var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  58. allowSelectAll: true,
  59. deselectOnRefresh: false,
  60. store: WsSMC.CreateActivityStore(),
  61. columns: {
  62. col1: selector({ width: 27, selectorType: 'checkbox' }),
  63. Wuid: {
  64. label: "Active workunit", width: 180, sortable: true,
  65. formatter: function (Wuid, row) {
  66. var wu = row.Server === "DFUserver" ? ESPDFUWorkunit.Get(Wuid) : ESPWorkunit.Get(Wuid);
  67. return "<img src='../files/" + wu.getStateImage() + "'>&nbsp;<a href='#' class='" + context.id + "WuidClick'>" + Wuid + "</a>";
  68. }
  69. },
  70. ClusterName: { label: "Target", width: 108, sortable: true },
  71. State: {
  72. label: "State", width: 180, sortable: true, formatter: function (state, row) {
  73. return state + (row.Duration ? " (" + row.Duration + ")" : "");
  74. }
  75. },
  76. Owner: { label: "Owner", width: 90, sortable: true },
  77. Jobname: { label: "Job Name", sortable: true }
  78. }
  79. }, domID);
  80. var context = this;
  81. on(document, "." + this.id + "WuidClick:click", function (evt) {
  82. if (context._onRowDblClick) {
  83. var row = retVal.row(evt).data;
  84. context._onRowDblClick(row);
  85. }
  86. });
  87. return retVal;
  88. },
  89. createDetail: function (id, row, params) {
  90. if (row.Server === "DFUserver") {
  91. return new DFUWUDetailsWidget.fixCircularDependency({
  92. id: id,
  93. title: row.ID,
  94. closable: true,
  95. hpcc: {
  96. params: {
  97. Wuid: row.ID
  98. }
  99. }
  100. });
  101. }
  102. return new WUDetailsWidget({
  103. id: id,
  104. title: row.Wuid,
  105. closable: true,
  106. hpcc: {
  107. params: {
  108. Wuid: row.Wuid
  109. }
  110. }
  111. });
  112. },
  113. loadRunning: function (response) {
  114. var items = lang.getObject("ActivityResponse.Running", false, response)
  115. if (items) {
  116. var context = this;
  117. arrayUtil.forEach(items, function (item, idx) {
  118. context.store.add({
  119. id: "ActivityRunning" + idx,
  120. ClusterName: item.ClusterName,
  121. Wuid: item.Wuid,
  122. Owner: item.Owner,
  123. Jobname: item.Owner,
  124. Summary: item.Name + " (" + prefix + ")",
  125. _type: "LogicalFile",
  126. _name: item.Name
  127. });
  128. });
  129. return items.length;
  130. }
  131. return 0;
  132. },
  133. refreshGrid: function (args) {
  134. var context = this;
  135. this.grid.set("query", {
  136. });
  137. /*
  138. WsSMC.Activity({
  139. request: {
  140. }
  141. }).then(function (response) {
  142. var items = lang.getObject("ActivityResponse.Running.ActiveWorkunit", false, response);
  143. arrayUtil.forEach(items, function (item, idx) {
  144. lang.mixin(item, {
  145. State: item.State + " (" + item.Duration + ")"
  146. });
  147. });
  148. context.store.setData(items);
  149. context.grid.refresh();
  150. });
  151. */
  152. },
  153. refreshActionState: function (selection) {
  154. this.inherited(arguments);
  155. }
  156. });
  157. });