From b9d75fcc617dc3ea2847db655c3abf018828e255 Mon Sep 17 00:00:00 2001 From: Weiyi Feng Date: Mon, 6 Jun 2022 16:13:24 +0800 Subject: [PATCH] config_tools: fix vmNameChange event never called issue fix vmNameChange event never called issue Tracked-On: #6691 Signed-off-by: Weiyi Feng --- .../configurator/src/pages/Config.vue | 76 ++++++++++--------- .../src/pages/Config/ConfigForm.vue | 20 +++-- 2 files changed, 53 insertions(+), 43 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 ba56dca49..db054c49d 100644 --- a/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue +++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue @@ -304,7 +304,7 @@ export default { }, vmNameChange(newname, oldname) { let hvdata = this.scenario.hv - if (hvdata.FEATURES.hasOwnProperty('IVSHMEM')) { + if (hvdata.hasOwnProperty('FEATURES') && hvdata.FEATURES.hasOwnProperty('IVSHMEM')) { for (let key in hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION) { let region = hvdata.FEATURES.IVSHMEM.IVSHMEM_REGION[key] for (let key1 in region.IVSHMEM_VMS.IVSHMEM_VM) { @@ -382,7 +382,9 @@ export default { } let errorFlag = false errorFlag = this.confirmVmName() - if (errorFlag) {return} + if (errorFlag) { + return + } this.assignVMID() let msg = [ "scenario xml saved\n", @@ -414,44 +416,44 @@ export default { // begin write down and verify configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData) - .then(() => { - stepDone = 1 - console.log("validate settings...") - this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData) - // noinspection ExceptionCaughtLocallyJS - if (this.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(() => { + stepDone = 1 + console.log("validate settings...") + this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData) + // noinspection ExceptionCaughtLocallyJS + if (this.errors.length !== 0) { + throw new Error("validation failed") } - }) - .then((result) => { - if (!_.isEmpty(result)) { - stepDone = 3 + 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 } - alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`) - }) - .catch((err)=>{ - console.log("error" + err) - let outmsg = '' - for (var i = 0; i < stepDone; i++) - outmsg += msg[i] - for (i = stepDone; i < totalMsg; i++) - outmsg += errmsg[i] - alert(`${outmsg} \n Please check your configuration`) }) + .then((result) => { + if (!_.isEmpty(result)) { + stepDone = 3 + } + alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`) + }) + .catch((err) => { + console.log("error" + err) + let outmsg = '' + for (var i = 0; i < stepDone; i++) + outmsg += msg[i] + for (i = stepDone; i < totalMsg; i++) + outmsg += errmsg[i] + alert(`${outmsg} \n Please check your configuration`) + }) } } } diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue index c08a81d65..04e0e8237 100644 --- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue +++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue @@ -67,6 +67,7 @@ export default { }, data() { return { + vmNameCache: '', currentFormMode: 'BasicConfigType', formProps: { "inline": false, @@ -123,14 +124,21 @@ export default { dataChange({newValue, oldValue}) { let newID = newValue.hasOwnProperty('@id') ? newValue['@id'] : -1; let oldID = oldValue.hasOwnProperty('@id') ? oldValue['@id'] : -1; - if (newID === oldID) { - if (oldValue.name !== newValue.name) { - this.$emit('vmNameChange', newValue.name, oldValue.name) - } + if (newID === oldID) { + // skip hv settings + if (newID !== -1) { + if (this.vmNameCache !== newValue.name) { + this.$emit('vmNameChange', newValue.name, this.vmNameCache) + this.vmNameCache = newValue.name; + } + } this.$emit('scenarioConfigFormDataUpdate', newID, newValue) + } else { + if (newID !== -1) { + this.vmNameCache = newValue.name + } } - // this.$emit('update:scenarioData', this.formData) } } } @@ -227,7 +235,7 @@ export default { background: white; } -.notice{ +.notice { padding: 1rem 0; } \ No newline at end of file