|
@@ -22,7 +22,9 @@ define([
|
|
|
"dojo/_base/array",
|
|
|
"dojo/on",
|
|
|
|
|
|
+ "dijit/registry",
|
|
|
"dijit/form/Button",
|
|
|
+ "dijit/ToolbarSeparator",
|
|
|
|
|
|
"dgrid/OnDemandGrid",
|
|
|
"dgrid/Keyboard",
|
|
@@ -39,7 +41,7 @@ define([
|
|
|
"hpcc/ESPUtil"
|
|
|
|
|
|
], function (declare, lang, i18n, nlsCommon, nlsSpecific, arrayUtil, on,
|
|
|
- Button,
|
|
|
+ registry, Button, ToolbarSeparator,
|
|
|
OnDemandGrid, Keyboard, Selection, selector, tree, ColumnResizer, DijitRegistry,
|
|
|
GridDetailsWidget, ESPActivity, WUDetailsWidget, DFUWUDetailsWidget, ESPUtil) {
|
|
|
return declare("ActivityWidget", [GridDetailsWidget], {
|
|
@@ -48,6 +50,110 @@ define([
|
|
|
gridTitle: nlsSpecific.title,
|
|
|
idProperty: "Wuid",
|
|
|
|
|
|
+ _onPause: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfQueue(item)) {
|
|
|
+ var context = this;
|
|
|
+ item.pause().then(function(response) {
|
|
|
+ context._refreshActionState();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ },
|
|
|
+
|
|
|
+ _onResume: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfQueue(item)) {
|
|
|
+ var context = this;
|
|
|
+ item.resume().then(function (response) {
|
|
|
+ context._refreshActionState();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ },
|
|
|
+
|
|
|
+ _onClear: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfQueue(item)) {
|
|
|
+ item.clear();
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUAbort: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ item.abort();
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUPriority: function (event, priority) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ queue.setPriority(item.Wuid, priority);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUTop: function (event, params) {
|
|
|
+ var selected = this.grid.getSelected();
|
|
|
+ for (var i = selected.length - 1; i >= 0; --i) {
|
|
|
+ var item = selected[i];
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ queue.moveTop(item.Wuid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUUp: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ queue.moveUp(item.Wuid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUDown: function (event, params) {
|
|
|
+ var selected = this.grid.getSelected();
|
|
|
+ for (var i = selected.length - 1; i >= 0; --i) {
|
|
|
+ var item = selected[i];
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ queue.moveDown(item.Wuid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
+ _onWUBottom: function (event, params) {
|
|
|
+ arrayUtil.forEach(this.grid.getSelected(), function (item, idx) {
|
|
|
+ if (this.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ queue.moveBottom(item.Wuid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this._onRefresh();
|
|
|
+ },
|
|
|
+
|
|
|
doSearch: function (searchText) {
|
|
|
this.searchText = searchText;
|
|
|
this.selectChild(this.gridTab);
|
|
@@ -59,8 +165,9 @@ define([
|
|
|
return;
|
|
|
|
|
|
var context = this;
|
|
|
- this.activity.monitor(function (activity) {
|
|
|
+ this.activity.watch("changedCount", function (item, oldValue, newValue) {
|
|
|
context.grid.set("query", {});
|
|
|
+ context._refreshActionState();
|
|
|
});
|
|
|
|
|
|
this._refreshActionState();
|
|
@@ -68,6 +175,90 @@ define([
|
|
|
|
|
|
createGrid: function (domID) {
|
|
|
var context = this;
|
|
|
+
|
|
|
+ this.openButton = registry.byId(this.id + "Open");
|
|
|
+ this.clusterPauseButton = new Button({
|
|
|
+ id: this.id + "PauseButton",
|
|
|
+ label: "Pause",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onPause(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "before");
|
|
|
+ this.clusterResumeButton = new Button({
|
|
|
+ id: this.id + "ResumeButton",
|
|
|
+ label: "Resume",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onResume(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "before");
|
|
|
+ this.clusterClearButton = new Button({
|
|
|
+ id: this.id + "ClearButton",
|
|
|
+ label: "Clear",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onClear(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "before");
|
|
|
+ var tmpSplitter = new ToolbarSeparator().placeAt(this.openButton.domNode, "before");
|
|
|
+
|
|
|
+ this.wuMoveBottomButton = new Button({
|
|
|
+ id: this.id + "MoveBottomButton",
|
|
|
+ label: "Bottom",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUBottom(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuMoveDownButton = new Button({
|
|
|
+ id: this.id + "MoveDownButton",
|
|
|
+ label: "Down",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUDown(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuMoveUpButton = new Button({
|
|
|
+ id: this.id + "MoveUpButton",
|
|
|
+ label: "Up",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUUp(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuMoveTopButton = new Button({
|
|
|
+ id: this.id + "MoveTopButton",
|
|
|
+ label: "Top",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUTop(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ tmpSplitter = new ToolbarSeparator().placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuLowPriorityButton = new Button({
|
|
|
+ id: this.id + "LowPriorityButton",
|
|
|
+ label: "Low",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUPriority(event, "low");
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuNormalPriorityButton = new Button({
|
|
|
+ id: this.id + "NormalPriorityButton",
|
|
|
+ label: "Normal",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUPriority(event, "normal");
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuHighPriorityButton = new Button({
|
|
|
+ id: this.id + "HighPriorityButton",
|
|
|
+ label: "High",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUPriority(event, "high");
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+ tmpSplitter = new ToolbarSeparator().placeAt(this.openButton.domNode, "after");
|
|
|
+ this.wuAbortButton = new Button({
|
|
|
+ id: this.id + "AbortButton",
|
|
|
+ label: "Abort",
|
|
|
+ onClick: function (event) {
|
|
|
+ context._onWUAbort(event);
|
|
|
+ }
|
|
|
+ }).placeAt(this.openButton.domNode, "after");
|
|
|
+
|
|
|
this.noDataMessage = this.i18n.loadingMessage;
|
|
|
this.activity = ESPActivity.Get();
|
|
|
var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
|
|
@@ -78,30 +269,41 @@ define([
|
|
|
col1: selector({
|
|
|
width: 27,
|
|
|
selectorType: 'checkbox',
|
|
|
- disabled: function (item) {
|
|
|
- if (item.__hpcc_type) {
|
|
|
- switch (item.__hpcc_type) {
|
|
|
- case "TargetCluster":
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- },
|
|
|
sortable: false
|
|
|
}),
|
|
|
+ Priority: {
|
|
|
+ renderHeaderCell: function (node) {
|
|
|
+ node.innerHTML = "<img src='../files/img/priority.png'>";
|
|
|
+ },
|
|
|
+ width: 25,
|
|
|
+ sortable: false,
|
|
|
+ formatter: function (Priority) {
|
|
|
+ switch (Priority) {
|
|
|
+ case "high":
|
|
|
+ return "<img src='../files/img/priority_high.png'>";
|
|
|
+ case "low":
|
|
|
+ return "<img src='../files/img/priority_low.png'>";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ },
|
|
|
DisplayName: tree({
|
|
|
label: this.i18n.Target,
|
|
|
- width: 225,
|
|
|
+ width: 270,
|
|
|
sortable: true,
|
|
|
- shouldExpand: function(row, level, previouslyExpanded) {
|
|
|
+ shouldExpand: function (row, level, previouslyExpanded) {
|
|
|
return true;
|
|
|
},
|
|
|
formatter: function (_name, row) {
|
|
|
var img = "../files/";
|
|
|
var name = "";
|
|
|
- if (row.__hpcc_type === "TargetCluster") {
|
|
|
- img += "img/server.png";
|
|
|
- name = row.__hpcc_id;
|
|
|
+ if (context.activity.isInstanceOfQueue(row)) {
|
|
|
+ if (row.isPaused()) {
|
|
|
+ img += "img/server_paused.png";
|
|
|
+ } else {
|
|
|
+ img += "img/server.png";
|
|
|
+ }
|
|
|
+ name = row.getDisplayName();
|
|
|
} else {
|
|
|
img += row.getStateImage();
|
|
|
name = "<a href='#' class='" + context.id + "WuidClick'>" + row.Wuid + "</a>";
|
|
@@ -113,7 +315,10 @@ define([
|
|
|
label: this.i18n.State,
|
|
|
sortable: true,
|
|
|
formatter: function (state, row) {
|
|
|
- if (row.__hpcc_type === "TargetCluster") {
|
|
|
+ if (context.activity.isInstanceOfQueue(row)) {
|
|
|
+ if (row.isPaused()) {
|
|
|
+ return row.StatusDetails;
|
|
|
+ }
|
|
|
return "";
|
|
|
}
|
|
|
if (row.Duration) {
|
|
@@ -126,6 +331,16 @@ define([
|
|
|
},
|
|
|
Owner: { label: this.i18n.Owner, width: 90, sortable: true },
|
|
|
Jobname: { label: this.i18n.JobName, sortable: true }
|
|
|
+ },
|
|
|
+ getSelected: function () {
|
|
|
+ var retVal = [];
|
|
|
+ for (var id in this.selection) {
|
|
|
+ var item = context.activity.resolve(id)
|
|
|
+ if (item) {
|
|
|
+ retVal.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retVal;
|
|
|
}
|
|
|
}, domID);
|
|
|
|
|
@@ -139,28 +354,32 @@ define([
|
|
|
},
|
|
|
|
|
|
createDetail: function (id, row, params) {
|
|
|
- if (row.Server === "DFUserver") {
|
|
|
- return new DFUWUDetailsWidget.fixCircularDependency({
|
|
|
+ if (this.activity.isInstanceOfQueue(row)) {
|
|
|
+ } else if (this.activity.isInstanceOfWorkunit(row)) {
|
|
|
+ if (row.Server === "DFUserver") {
|
|
|
+ return new DFUWUDetailsWidget.fixCircularDependency({
|
|
|
+ id: id,
|
|
|
+ title: row.ID,
|
|
|
+ closable: true,
|
|
|
+ hpcc: {
|
|
|
+ params: {
|
|
|
+ Wuid: row.ID
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return new WUDetailsWidget({
|
|
|
id: id,
|
|
|
- title: row.ID,
|
|
|
+ title: row.Wuid,
|
|
|
closable: true,
|
|
|
hpcc: {
|
|
|
params: {
|
|
|
- Wuid: row.ID
|
|
|
+ Wuid: row.Wuid
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
- return new WUDetailsWidget({
|
|
|
- id: id,
|
|
|
- title: row.Wuid,
|
|
|
- closable: true,
|
|
|
- hpcc: {
|
|
|
- params: {
|
|
|
- Wuid: row.Wuid
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ return null;
|
|
|
},
|
|
|
|
|
|
loadRunning: function (response) {
|
|
@@ -189,7 +408,63 @@ define([
|
|
|
},
|
|
|
|
|
|
refreshActionState: function (selection) {
|
|
|
- this.inherited(arguments);
|
|
|
+ var clusterSelected = false;
|
|
|
+ var wuSelected = false;
|
|
|
+ var clusterPausedSelected = false;
|
|
|
+ var clusterNotPausedSelected = false;
|
|
|
+ var clusterHasItems = false;
|
|
|
+ var wuCanHigh = false;
|
|
|
+ var wuCanNormal = false;
|
|
|
+ var wuCanLow = false;
|
|
|
+ var wuCanUp = false;
|
|
|
+ var wuCanDown = false;
|
|
|
+ var context = this;
|
|
|
+ arrayUtil.forEach(selection, function (item, idx) {
|
|
|
+ if (context.activity.isInstanceOfQueue(item)) {
|
|
|
+ clusterSelected = true;
|
|
|
+ if (item.isPaused()) {
|
|
|
+ clusterPausedSelected = true;
|
|
|
+ } else {
|
|
|
+ clusterNotPausedSelected = true;
|
|
|
+ }
|
|
|
+ if (item.getChildCount()) {
|
|
|
+ clusterHasItems = true;
|
|
|
+ }
|
|
|
+ } else if (context.activity.isInstanceOfWorkunit(item)) {
|
|
|
+ wuSelected = true;
|
|
|
+ var queue = item.get("ESPQueue");
|
|
|
+ if (queue) {
|
|
|
+ if (queue.canChildMoveUp(item.__hpcc_id)) {
|
|
|
+ wuCanUp = true;
|
|
|
+ }
|
|
|
+ if (queue.canChildMoveDown(item.__hpcc_id)) {
|
|
|
+ wuCanDown = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.get("Priority") !== "high") {
|
|
|
+ wuCanHigh = true;
|
|
|
+ }
|
|
|
+ if (item.get("Priority") !== "normal") {
|
|
|
+ wuCanNormal = true;
|
|
|
+ }
|
|
|
+ if (item.get("Priority") !== "low") {
|
|
|
+ wuCanLow = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ this.clusterPauseButton.set("disabled", !clusterNotPausedSelected);
|
|
|
+ this.clusterResumeButton.set("disabled", !clusterPausedSelected);
|
|
|
+ this.clusterClearButton.set("disabled", !clusterHasItems);
|
|
|
+ this.openButton.set("disabled", !wuSelected);
|
|
|
+ this.wuAbortButton.set("disabled", !wuSelected);
|
|
|
+ this.wuHighPriorityButton.set("disabled", !wuCanHigh);
|
|
|
+ this.wuNormalPriorityButton.set("disabled", !wuCanNormal);
|
|
|
+ this.wuLowPriorityButton.set("disabled", !wuCanLow);
|
|
|
+ this.wuMoveTopButton.set("disabled", !wuCanUp);
|
|
|
+ this.wuMoveUpButton.set("disabled", !wuCanUp);
|
|
|
+ this.wuMoveDownButton.set("disabled", !wuCanDown);
|
|
|
+ this.wuMoveBottomButton.set("disabled", !wuCanDown);
|
|
|
}
|
|
|
});
|
|
|
});
|