ActivityWidget.js 5.7 KB

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