|
@@ -26,11 +26,13 @@ require([
|
|
|
"dijit/registry",
|
|
|
|
|
|
"hpcc/WsTopology",
|
|
|
+ "hpcc/WsWorkunits",
|
|
|
+ "hpcc/FileSpray",
|
|
|
|
|
|
"dojo/text!./templates/TargetSelectWidget.html"
|
|
|
], function (declare, lang, arrayUtil, dom,
|
|
|
_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, Select, registry,
|
|
|
- WsTopology,
|
|
|
+ WsTopology, WsWorkunits, FileSpray,
|
|
|
template) {
|
|
|
return declare("TargetSelectWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
|
|
|
templateString: template,
|
|
@@ -66,17 +68,26 @@ require([
|
|
|
if (this.initalized)
|
|
|
return;
|
|
|
this.initalized = true;
|
|
|
+ this.targetSelectControl.options = [];
|
|
|
|
|
|
if (params.Target) {
|
|
|
this._value = params.Target;
|
|
|
}
|
|
|
if (params.includeBlank) {
|
|
|
this.includeBlank = params.includeBlank;
|
|
|
+ this.targetSelectControl.options.push({
|
|
|
+ label: " ",
|
|
|
+ value: ""
|
|
|
+ });
|
|
|
}
|
|
|
if (params.Groups === true) {
|
|
|
this.loadGroups();
|
|
|
} else if (params.DropZones === true) {
|
|
|
this.loadDropZones();
|
|
|
+ } else if (params.WUState === true) {
|
|
|
+ this.loadWUState();
|
|
|
+ } else if (params.DFUState === true) {
|
|
|
+ this.loadDFUState();
|
|
|
} else {
|
|
|
this.loadTargets();
|
|
|
}
|
|
@@ -109,6 +120,9 @@ require([
|
|
|
},
|
|
|
|
|
|
_setValueAttr: function (target) {
|
|
|
+ if (target === null) {
|
|
|
+ target = "";
|
|
|
+ }
|
|
|
if (target !== null && this._value != target) {
|
|
|
this._value = target;
|
|
|
this.targetSelectControl.set("value", target);
|
|
@@ -123,19 +137,19 @@ require([
|
|
|
return this._value;
|
|
|
},
|
|
|
|
|
|
+ resetDefaultSelection: function () {
|
|
|
+ if (this._value == "") {
|
|
|
+ this._value = this.targetSelectControl.options[0].value;
|
|
|
+ }
|
|
|
+ this.targetSelectControl.set("value", this._value);
|
|
|
+ },
|
|
|
+
|
|
|
loadDropZones: function () {
|
|
|
var context = this;
|
|
|
WsTopology.TpServiceQuery({
|
|
|
load: function (response) {
|
|
|
if (lang.exists("TpServiceQueryResponse.ServiceList.TpDropZones.TpDropZone", response)) {
|
|
|
var targetData = response.TpServiceQueryResponse.ServiceList.TpDropZones.TpDropZone;
|
|
|
- context.targetSelectControl.options = [];
|
|
|
- if (context.includeBlank) {
|
|
|
- context.targetSelectControl.options.push({
|
|
|
- label: "",
|
|
|
- value: ""
|
|
|
- });
|
|
|
- }
|
|
|
for (var i = 0; i < targetData.length; ++i) {
|
|
|
context.targetSelectControl.options.push({
|
|
|
label: targetData[i].Name,
|
|
@@ -143,11 +157,7 @@ require([
|
|
|
machine: targetData[i].TpMachines.TpMachine[0]
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- if (context._value == "") {
|
|
|
- context._value = context.targetSelectControl.options[0].value;
|
|
|
- }
|
|
|
- context.targetSelectControl.set("value", context._value);
|
|
|
+ context.resetDefaultSelection();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -159,42 +169,56 @@ require([
|
|
|
load: function (response) {
|
|
|
if (lang.exists("TpGroupQueryResponse.TpGroups.TpGroup", response)) {
|
|
|
var targetData = response.TpGroupQueryResponse.TpGroups.TpGroup;
|
|
|
- context.targetSelectControl.options = [];
|
|
|
- if (context.includeBlank) {
|
|
|
- context.targetSelectControl.options.push({
|
|
|
- label: "",
|
|
|
- value: ""
|
|
|
- });
|
|
|
- }
|
|
|
for (var i = 0; i < targetData.length; ++i) {
|
|
|
context.targetSelectControl.options.push({
|
|
|
label: targetData[i].Name,
|
|
|
value: targetData[i].Name
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- if (context._value == "") {
|
|
|
- context._value = context.targetSelectControl.options[0].value;
|
|
|
- }
|
|
|
- context.targetSelectControl.set("value", context._value);
|
|
|
+ context.resetDefaultSelection();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ loadWUState: function() {
|
|
|
+ for (var key in WsWorkunits.States) {
|
|
|
+ this.targetSelectControl.options.push({
|
|
|
+ label: WsWorkunits.States[key],
|
|
|
+ value: WsWorkunits.States[key]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.resetDefaultSelection();
|
|
|
+ },
|
|
|
+
|
|
|
+ loadDFUState: function () {
|
|
|
+ for (var key in FileSpray.States) {
|
|
|
+ this.targetSelectControl.options.push({
|
|
|
+ label: FileSpray.States[key],
|
|
|
+ value: FileSpray.States[key]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.resetDefaultSelection();
|
|
|
+ },
|
|
|
+
|
|
|
+ LogicalFileSearchType: function() {
|
|
|
+ this.targetSelectControl.options.push({
|
|
|
+ label: "Created",
|
|
|
+ value: "Created"
|
|
|
+ });
|
|
|
+ this.targetSelectControl.options.push({
|
|
|
+ label: "Used",
|
|
|
+ value: "Referenced"
|
|
|
+ });
|
|
|
+ this.resetDefaultSelection();
|
|
|
+ },
|
|
|
+
|
|
|
loadTargets: function () {
|
|
|
var context = this;
|
|
|
WsTopology.TpTargetClusterQuery({
|
|
|
load: function (response) {
|
|
|
if (lang.exists("TpTargetClusterQueryResponse.TpTargetClusters.TpTargetCluster", response)) {
|
|
|
var targetData = response.TpTargetClusterQueryResponse.TpTargetClusters.TpTargetCluster;
|
|
|
- context.targetSelectControl.options = [];
|
|
|
- if (context.includeBlank) {
|
|
|
- context.targetSelectControl.options.push({
|
|
|
- label: "",
|
|
|
- value: ""
|
|
|
- });
|
|
|
- }
|
|
|
var has_hthor = false;
|
|
|
for (var i = 0; i < targetData.length; ++i) {
|
|
|
context.targetSelectControl.options.push({
|
|
@@ -208,13 +232,12 @@ require([
|
|
|
|
|
|
if (!context.includeBlank && context._value == "") {
|
|
|
if (has_hthor) {
|
|
|
- context.setValue("hthor");
|
|
|
+ context._value = "hthor";
|
|
|
} else {
|
|
|
context._value = context.targetSelectControl.options[0].value;
|
|
|
}
|
|
|
- } else {
|
|
|
- context.targetSelectControl.set("value", context._value);
|
|
|
}
|
|
|
+ context.resetDefaultSelection();
|
|
|
}
|
|
|
}
|
|
|
});
|