|
@@ -19,72 +19,82 @@ define([
|
|
|
"dojo/i18n",
|
|
|
"dojo/i18n!./nls/hpcc",
|
|
|
"dojo/dom",
|
|
|
- "dojo/dom-attr",
|
|
|
- "dojo/dom-class",
|
|
|
+ "dojo/query",
|
|
|
"dojo/topic",
|
|
|
-
|
|
|
- "dijit/layout/_LayoutWidget",
|
|
|
- "dijit/_TemplatedMixin",
|
|
|
- "dijit/_WidgetsInTemplateMixin",
|
|
|
"dijit/registry",
|
|
|
|
|
|
+ "hpcc/_Widget",
|
|
|
+ "hpcc/_TabContainerWidget",
|
|
|
+ "hpcc/DelayLoadWidget",
|
|
|
+ "hpcc/ECLSourceWidget",
|
|
|
"hpcc/WsPackageMaps",
|
|
|
|
|
|
"dojo/text!../templates/PackageMapValidateWidget.html",
|
|
|
|
|
|
- "dijit/form/Form",
|
|
|
- "dijit/form/Button",
|
|
|
- "dijit/form/RadioButton",
|
|
|
- "dijit/form/Select",
|
|
|
- "dijit/form/SimpleTextarea"
|
|
|
-], function (declare, lang, i18n, nlsHPCC, dom, domAttr, domClass, topic,
|
|
|
- _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, registry,
|
|
|
- WsPackageMaps, template) {
|
|
|
- return declare("PackageMapValidateWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
|
|
|
+ "dijit/layout/BorderContainer",
|
|
|
+ "dijit/layout/TabContainer",
|
|
|
+ "dijit/layout/ContentPane",
|
|
|
+ "dijit/form/Button"
|
|
|
+], function (declare, lang, i18n, nlsHPCC, dom, query, topic, registry,
|
|
|
+ _Widget, _TabContainerWidget, DelayLoadWidget, EclSourceWidget, WsPackageMaps,
|
|
|
+ template) {
|
|
|
+ return declare("PackageMapValidateWidget", [_TabContainerWidget], {
|
|
|
templateString: template,
|
|
|
baseClass: "PackageMapValidateWidget",
|
|
|
i18n: nlsHPCC,
|
|
|
- validateForm: null,
|
|
|
- targetSelect: null,
|
|
|
- packageContent: null,
|
|
|
- validateResult: null,
|
|
|
- validateButton: null,
|
|
|
- targets: null,
|
|
|
- processes: new Array(),
|
|
|
+
|
|
|
initalized: false,
|
|
|
+ targets: null,
|
|
|
|
|
|
- buildRendering: function (args) {
|
|
|
- this.inherited(arguments);
|
|
|
+ targetSelectControl: null,
|
|
|
+ processSelectControl: null,
|
|
|
+ validateButton: null,
|
|
|
+ editorControl: null,
|
|
|
+ resultControl: null,
|
|
|
+
|
|
|
+ validatePackageMapContentWidget: null,
|
|
|
+ validatePackageMapContentWidgetLoaded: false,
|
|
|
+
|
|
|
+ constructor: function() {
|
|
|
+ this.processes = new Array();
|
|
|
},
|
|
|
|
|
|
- postCreate: function (args) {
|
|
|
+ buildRendering: function (args) {
|
|
|
this.inherited(arguments);
|
|
|
- this.validateForm = registry.byId(this.id + "ValidatePM");
|
|
|
- this.targetSelect = registry.byId(this.id + "TargetSelect");
|
|
|
- this.processSelect = registry.byId(this.id + "ProcessSelect");
|
|
|
- this.packageContent = registry.byId(this.id + "Package");
|
|
|
- this.validateButton = registry.byId(this.id + "Validate");
|
|
|
- this.validateResult = registry.byId(this.id + "ValidateResult");
|
|
|
},
|
|
|
|
|
|
startup: function (args) {
|
|
|
this.inherited(arguments);
|
|
|
},
|
|
|
|
|
|
- resize: function (args) {
|
|
|
+ destroy: function (args) {
|
|
|
this.inherited(arguments);
|
|
|
},
|
|
|
|
|
|
- layout: function (args) {
|
|
|
+ getTitle: function () {
|
|
|
+ return this.i18n.ValidateActivePackageMap;
|
|
|
+ },
|
|
|
+
|
|
|
+ postCreate: function (args) {
|
|
|
this.inherited(arguments);
|
|
|
+ this.targetSelectControl = registry.byId(this.id + "TargetSelect");
|
|
|
+ this.processSelectControl = registry.byId(this.id + "ProcessSelect");
|
|
|
+ this.validateButton = registry.byId(this.id + "ValidateBtn");
|
|
|
+ this.validatePackageMapContentWidget = registry.byId(this.id + "_ValidatePackageMapContent");
|
|
|
},
|
|
|
|
|
|
- init: function (params, targets) {
|
|
|
+ // init this page
|
|
|
+ init: function (params) {
|
|
|
if (this.initalized)
|
|
|
return;
|
|
|
+
|
|
|
this.initalized = true;
|
|
|
- this.validateResult.set('style', 'visibility:hidden');
|
|
|
- this.initSelections(targets);
|
|
|
+ if (params.params.targets !== undefined)
|
|
|
+ this.initSelections(params.params.targets);
|
|
|
+
|
|
|
+ this.editorControl = registry.byId(this.id + "Source");
|
|
|
+ this.editorControl.init(params);
|
|
|
+ this.initResultDisplay();
|
|
|
},
|
|
|
|
|
|
initSelections: function (targets) {
|
|
@@ -92,98 +102,110 @@ define([
|
|
|
if (this.targets.length > 0) {
|
|
|
var defaultTarget = 0;
|
|
|
for (var i = 0; i < this.targets.length; ++i) {
|
|
|
- if ((defaultTarget == 0) && (this.targets[i].Type == 'roxie'))
|
|
|
+ if ((defaultTarget === 0) && (this.targets[i].Type === 'roxie'))
|
|
|
defaultTarget = i; //first roxie
|
|
|
- this.targetSelect.options.push({label: this.targets[i].Name, value: this.targets[i].Name});
|
|
|
+ this.targetSelectControl.options.push({label: this.targets[i].Name, value: this.targets[i].Name});
|
|
|
+ }
|
|
|
+ this.targetSelectControl.set("value", this.targets[defaultTarget].Name);
|
|
|
+ if (this.targets[defaultTarget].Processes !== undefined)
|
|
|
+ this.updateProcessSelections(this.targets[defaultTarget], '');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ updateProcessSelections: function (target, targetName) {
|
|
|
+ this.processSelectControl.removeOption(this.processSelectControl.getOptions());
|
|
|
+ if (target !== null)
|
|
|
+ this.addProcessSelections(target.Processes.Item);
|
|
|
+ else {
|
|
|
+ for (var i = 0; i < this.targets.length; ++i) {
|
|
|
+ var target = this.targets[i];
|
|
|
+ if ((target.Processes !== undefined) && (targetName === target.Name)) {
|
|
|
+ this.addProcessSelections(target.Processes.Item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- this.targetSelect.set("value", this.targets[defaultTarget].Name);
|
|
|
- if (this.targets[defaultTarget].Processes != undefined)
|
|
|
- this.updateProcessSelections(this.targets[defaultTarget].Name);
|
|
|
}
|
|
|
+ this.processSelectControl.options.push({label: this.i18n.ANY, value: 'ANY' });
|
|
|
+ this.processSelectControl.set("value", '');
|
|
|
},
|
|
|
|
|
|
addProcessSelections: function (processes) {
|
|
|
+ this.processes.length = 0;
|
|
|
for (var i = 0; i < processes.length; ++i) {
|
|
|
var process = processes[i];
|
|
|
- if ((this.processes != null) && (this.processes.indexOf(process) != -1))
|
|
|
+ if ((this.processes !== null) && (this.processes.indexOf(process) !== -1))
|
|
|
continue;
|
|
|
this.processes.push(process);
|
|
|
- this.processSelect.options.push({label: process, value: process});
|
|
|
+ this.processSelectControl.options.push({label: process, value: process});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- updateProcessSelections: function (targetName) {
|
|
|
- this.processSelect.removeOption(this.processSelect.getOptions());
|
|
|
- for (var i = 0; i < this.targets.length; ++i) {
|
|
|
- var target = this.targets[i];
|
|
|
- if ((target.Processes != undefined) && ((targetName == '') || (targetName == target.Name)))
|
|
|
- this.addProcessSelections(target.Processes.Item);
|
|
|
- }
|
|
|
- this.processSelect.options.push({label: this.i18n.ANY, value: 'ANY' });
|
|
|
- this.processSelect.set("value", '');
|
|
|
+ initResultDisplay: function () {
|
|
|
+ this.resultControl = registry.byId(this.id + "Result");
|
|
|
+ this.resultControl.init({sourceMode: 'text/plain', readOnly: true});
|
|
|
+ this.resultControl.setText(this.i18n.ValidateResultHere);
|
|
|
},
|
|
|
|
|
|
- addArrayToText: function (arrayTitle, arrayItems, text) {
|
|
|
- if ((arrayItems.Item != undefined) && (arrayItems.Item.length > 0)) {
|
|
|
- text += arrayTitle + ":\n";
|
|
|
- for (i=0;i<arrayItems.Item.length;i++)
|
|
|
- text += " " + arrayItems.Item[i] + "\n";
|
|
|
- text += "\n";
|
|
|
+ // init tab
|
|
|
+ initTab: function () {
|
|
|
+ var currSel = this.getSelectedChild();
|
|
|
+ if (!this.validatePackageMapContentWidgetLoaded && (currSel.id === this.validatePackageMapContentWidget.id)) {
|
|
|
+ this.validatePackageMapContentWidgetLoaded = true;
|
|
|
+ this.validatePackageMapContentWidget.init({
|
|
|
+ targets: this.targets
|
|
|
+ });
|
|
|
}
|
|
|
- return text;
|
|
|
},
|
|
|
|
|
|
- validateResponseToText: function (response) {
|
|
|
- var text = "";
|
|
|
- if (!lang.exists("Errors", response) || (response.Errors.length < 1))
|
|
|
- text += this.i18n.NoErrorFound;
|
|
|
- else
|
|
|
- text = this.addArrayToText(this.i18n.Errors, response.Errors, text);
|
|
|
- if (!lang.exists("Warnings", response) || (response.Warnings.length < 1))
|
|
|
- text += this.i18n.Warnings;
|
|
|
- else
|
|
|
- text = this.addArrayToText(this.i18n.Warnings, response.Warnings, text);
|
|
|
-
|
|
|
- text += "\n";
|
|
|
- text = this.addArrayToText(this.i18n.QueriesNoPackage, response.queries.Unmatched, text);
|
|
|
- text = this.addArrayToText(this.i18n.PackagesNoQuery, response.packages.Unmatched, text);
|
|
|
- text = this.addArrayToText(this.i18n.FilesNoPackage, response.files.Unmatched, text);
|
|
|
- return text;
|
|
|
+ // action
|
|
|
+ _onChangeTarget: function (event) {
|
|
|
+ this.targetSelected = this.targetSelectControl.getValue();
|
|
|
+ this.updateProcessSelections(null, this.targetSelected);
|
|
|
},
|
|
|
|
|
|
- _onChangeTarget: function (event) {
|
|
|
- this.processes.length = 0;
|
|
|
- this.targetSelected = this.targetSelect.getValue();
|
|
|
- this.updateProcessSelections(this.targetSelected);
|
|
|
- },
|
|
|
-
|
|
|
- _onValidate: function (event) {
|
|
|
- var request = { target: this.targetSelect.getValue() };
|
|
|
- var type = this.validateForm.attr('value').ValidateType;
|
|
|
- if (type == 'ActivePM') {
|
|
|
- request['active'] = true;
|
|
|
- request['process'] = this.processSelect.getValue();
|
|
|
- } else {
|
|
|
- var content = this.packageContent.getValue();
|
|
|
- if (content == '') {
|
|
|
- alert(this.i18n.PackageContentNotSet);
|
|
|
- return;
|
|
|
+ _onChangeProcess: function (event) {
|
|
|
+ var process = this.processSelectControl.getValue();
|
|
|
+ if (process === 'ANY')
|
|
|
+ process = '*';
|
|
|
+
|
|
|
+ var context = this;
|
|
|
+ this.editorControl.setText('');
|
|
|
+ WsPackageMaps.getPackage({
|
|
|
+ target: this.targetSelectControl.getValue(),
|
|
|
+ process: process
|
|
|
+ }, {
|
|
|
+ load: function (content) {
|
|
|
+ if (content !== '') {
|
|
|
+ context.editorControl.setText(content);;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (errMsg, errStack) {
|
|
|
+ context.showErrors(errMsg, errStack);
|
|
|
}
|
|
|
- request['content'] = content;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ _onValidate: function (evt) {
|
|
|
+ var content = this.editorControl.getText();
|
|
|
+ if (content === '') {
|
|
|
+ alert(this.i18n.PackageContentNotSet);
|
|
|
+ return;
|
|
|
}
|
|
|
+ var request = { target: this.targetSelectControl.getValue() };
|
|
|
+ request['content'] = content;
|
|
|
+
|
|
|
var context = this;
|
|
|
- this.validateResult.setValue("");
|
|
|
+ this.resultControl.setText("");
|
|
|
this.validateButton.set("disabled", true);
|
|
|
WsPackageMaps.validatePackage(request, {
|
|
|
load: function (response) {
|
|
|
var responseText = context.validateResponseToText(response);
|
|
|
- if (responseText == '')
|
|
|
- context.validateResult.setValue(context.i18n.Empty);
|
|
|
+ if (responseText === '')
|
|
|
+ context.resultControl.setText(context.i18n.Empty);
|
|
|
else {
|
|
|
responseText = context.i18n.ValidateResult + responseText;
|
|
|
- context.validateResult.setValue(responseText);
|
|
|
+ context.resultControl.setText(responseText);
|
|
|
}
|
|
|
- context.validateResult.set('style', 'visibility:visible');
|
|
|
context.validateButton.set("disabled", false);
|
|
|
},
|
|
|
error: function (errMsg, errStack) {
|
|
@@ -193,6 +215,34 @@ define([
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ validateResponseToText: function (response) {
|
|
|
+ var text = "";
|
|
|
+ if (!lang.exists("Errors", response) || (response.Errors.length < 1))
|
|
|
+ text += this.i18n.NoErrorFound;
|
|
|
+ else
|
|
|
+ text = this.addArrayToText(this.i18n.Errors, response.Errors, text);
|
|
|
+ if (!lang.exists("Warnings", response) || (response.Warnings.length < 1))
|
|
|
+ text += this.i18n.NoWarningFound;
|
|
|
+ else
|
|
|
+ text = this.addArrayToText(this.i18n.Warnings, response.Warnings, text);
|
|
|
+
|
|
|
+ text += "\n";
|
|
|
+ text = this.addArrayToText(this.i18n.QueriesNoPackage, response.queries.Unmatched, text);
|
|
|
+ text = this.addArrayToText(this.i18n.PackagesNoQuery, response.packages.Unmatched, text);
|
|
|
+ text = this.addArrayToText(this.i18n.FilesNoPackage, response.files.Unmatched, text);
|
|
|
+ return text;
|
|
|
+ },
|
|
|
+
|
|
|
+ addArrayToText: function (arrayTitle, arrayItems, text) {
|
|
|
+ if ((arrayItems.Item !== undefined) && (arrayItems.Item.length > 0)) {
|
|
|
+ text += arrayTitle + ":\n";
|
|
|
+ for (var i=0;i<arrayItems.Item.length;i++)
|
|
|
+ text += " " + arrayItems.Item[i] + "\n";
|
|
|
+ text += "\n";
|
|
|
+ }
|
|
|
+ return text;
|
|
|
+ },
|
|
|
+
|
|
|
showErrors: function (errMsg, errStack) {
|
|
|
topic.publish("hpcc/brToaster", {
|
|
|
Severity: "Error",
|