From 8eb1bbda3fc4bc95abf2b1cc1d3e624ff76331f1 Mon Sep 17 00:00:00 2001 From: Weiyi Feng Date: Wed, 15 Jun 2022 19:02:50 +0800 Subject: [PATCH] config_tools: add error icon in tabBox when validate failed add error icon in tabBox when validate failed Tracked-On: #6691 Signed-off-by: Weiyi Feng --- .../configurator/src/pages/Config.vue | 74 ++++++++++++++----- .../src/pages/Config/ConfigForm/TabBox.vue | 28 ++++++- 2 files changed, 82 insertions(+), 20 deletions(-) diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue index c1ebddee9..bc3748b04 100644 --- a/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue +++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue @@ -64,12 +64,15 @@ -
-
{{ error.message }}
+
+
+ {{ error.severity }}: {{ error.message }} +
{ + error.paths.forEach(path => { + let formPath = path.split('/')[2]; + // translate form path to scenario vmid + let vmid = -1 + if (formPath === 'hv') { + vmid = -1 + } else if (formPath === 'vm') { + vmid = scenarioData.vm[0]['@id'] + } else if (/vm\[\d+]/.test(formPath)) { + let vmIndex = /vm\[(\d+)]/.exec(formPath)[1] + vmIndex = parseInt(vmIndex) - 1 + vmid = scenarioData.vm[vmIndex]['@id'] + } + if (!formErrors.hasOwnProperty(vmid)) { + formErrors[vmid] = [] + } + formErrors[vmid].push(error) + }) + } + + if (errors.syntactic_errors.length > 0) { + errors.syntactic_errors.forEach(translate) + } + if (errors.semantic_errors.length !== 0) { + errors.semantic_errors.forEach(translate) + } + + return formErrors + }, saveScenario() { if (_.isEmpty(this.scenario.vm)) { alert("Please add at least one VM") @@ -427,36 +463,40 @@ export default { configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData) .then(() => { + // validate scenario and clean up the launch script stepDone = 1 console.log("validate settings...") let all_errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData) - this.errors = all_errors.semantic_errors - // noinspection ExceptionCaughtLocallyJS + // noinspection JSUnresolvedVariable + this.errors = this.translateErrors(all_errors, this.scenario) + // noinspection JSUnresolvedVariable if (all_errors.syntactic_errors.length !== 0 || all_errors.semantic_errors.length !== 0) { throw new Error("validation failed") } console.log("validation ok") stepDone = 2 return this.cleanLaunchScript() - }).then(() => { - if (needSaveLaunchScript) { - let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData) - let writeDone = [] - for (let filename in launchScripts) { - writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename])) - } - return Promise.all(writeDone) - } else { - return - } - }) + }) + .then(() => { + // generate launch script + if (needSaveLaunchScript) { + let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData) + let writeDone = [] + for (let filename in launchScripts) { + writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename])) + } + return Promise.all(writeDone) + } + }) .then((result) => { + // show success message if (!_.isEmpty(result)) { stepDone = 3 } alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`) }) .catch((err) => { + // show error message console.log("error" + err) let outmsg = '' for (var i = 0; i < stepDone; i++) diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/TabBox.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/TabBox.vue index a8751f2e9..18a599155 100644 --- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/TabBox.vue +++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/TabBox.vue @@ -8,8 +8,13 @@
-
+
+ + + +
{{ pre.name }}
@@ -24,9 +29,14 @@
-
+
+ + + +
{{ service.name }}
@@ -34,9 +44,14 @@
-
+
+ + + +
{{ post.name }}
@@ -53,12 +68,19 @@