mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-08 08:26:55 +00:00
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 <weiyix.feng@intel.com>
This commit is contained in:
parent
b22e3da6c6
commit
62c48f5802
@ -64,12 +64,15 @@
|
|||||||
<TabBox
|
<TabBox
|
||||||
:scenario="scenario"
|
:scenario="scenario"
|
||||||
:activeVMID="activeVMID"
|
:activeVMID="activeVMID"
|
||||||
|
:errors="errors"
|
||||||
@tabActive="switchTab"
|
@tabActive="switchTab"
|
||||||
@addVM="addVM"
|
@addVM="addVM"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="errors">
|
<div v-if="errors.hasOwnProperty(activeVMID)">
|
||||||
<div class="px-4" style="color: red" v-for="error in errors">{{ error.message }}</div>
|
<div class="px-4" style="color: red" v-for="error in errors[activeVMID]">
|
||||||
|
{{ error.severity }}: {{ error.message }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<ConfigForm
|
<ConfigForm
|
||||||
@ -184,7 +187,7 @@ export default {
|
|||||||
scenarioUpdate(scenarioData) {
|
scenarioUpdate(scenarioData) {
|
||||||
let scenarioXMLData = this.scenarioToXML(scenarioData)
|
let scenarioXMLData = this.scenarioToXML(scenarioData)
|
||||||
let all_errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
let all_errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
||||||
this.errors = all_errors.semantic_errors
|
this.errors = this.translateErrors(all_errors, scenarioData)
|
||||||
this.scenario = scenarioData;
|
this.scenario = scenarioData;
|
||||||
this.showFlag = false;
|
this.showFlag = false;
|
||||||
this.updateCurrentFormSchema()
|
this.updateCurrentFormSchema()
|
||||||
@ -385,6 +388,39 @@ export default {
|
|||||||
}
|
}
|
||||||
return scenarioWithDefault
|
return scenarioWithDefault
|
||||||
},
|
},
|
||||||
|
translateErrors(errors, scenarioData) {
|
||||||
|
let formErrors = {}
|
||||||
|
|
||||||
|
let translate = error => {
|
||||||
|
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() {
|
saveScenario() {
|
||||||
if (_.isEmpty(this.scenario.vm)) {
|
if (_.isEmpty(this.scenario.vm)) {
|
||||||
alert("Please add at least one VM")
|
alert("Please add at least one VM")
|
||||||
@ -427,36 +463,40 @@ export default {
|
|||||||
|
|
||||||
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
// validate scenario and clean up the launch script
|
||||||
stepDone = 1
|
stepDone = 1
|
||||||
console.log("validate settings...")
|
console.log("validate settings...")
|
||||||
let all_errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
let all_errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
||||||
this.errors = all_errors.semantic_errors
|
// noinspection JSUnresolvedVariable
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
this.errors = this.translateErrors(all_errors, this.scenario)
|
||||||
|
// noinspection JSUnresolvedVariable
|
||||||
if (all_errors.syntactic_errors.length !== 0 || all_errors.semantic_errors.length !== 0) {
|
if (all_errors.syntactic_errors.length !== 0 || all_errors.semantic_errors.length !== 0) {
|
||||||
throw new Error("validation failed")
|
throw new Error("validation failed")
|
||||||
}
|
}
|
||||||
console.log("validation ok")
|
console.log("validation ok")
|
||||||
stepDone = 2
|
stepDone = 2
|
||||||
return this.cleanLaunchScript()
|
return this.cleanLaunchScript()
|
||||||
}).then(() => {
|
})
|
||||||
if (needSaveLaunchScript) {
|
.then(() => {
|
||||||
let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData)
|
// generate launch script
|
||||||
let writeDone = []
|
if (needSaveLaunchScript) {
|
||||||
for (let filename in launchScripts) {
|
let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData)
|
||||||
writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename]))
|
let writeDone = []
|
||||||
}
|
for (let filename in launchScripts) {
|
||||||
return Promise.all(writeDone)
|
writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename]))
|
||||||
} else {
|
}
|
||||||
return
|
return Promise.all(writeDone)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
// show success message
|
||||||
if (!_.isEmpty(result)) {
|
if (!_.isEmpty(result)) {
|
||||||
stepDone = 3
|
stepDone = 3
|
||||||
}
|
}
|
||||||
alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`)
|
alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
// show error message
|
||||||
console.log("error" + err)
|
console.log("error" + err)
|
||||||
let outmsg = ''
|
let outmsg = ''
|
||||||
for (var i = 0; i < stepDone; i++)
|
for (var i = 0; i < stepDone; i++)
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="TabSplitter"></div>
|
<div class="TabSplitter"></div>
|
||||||
|
|
||||||
<div class="d-inline-block p-3 pt-2 Tab" :class="{Active:activeVMID===pre.id}"
|
<div class="d-inline-block p-3 pt-2 Tab position-relative" :class="{Active:activeVMID===pre.id}"
|
||||||
:key="pre.id" v-for="pre in vms.PRE_LAUNCHED_VM" @click="active(pre.id)">
|
:key="pre.id" v-for="pre in vms.PRE_LAUNCHED_VM" @click="active(pre.id)">
|
||||||
|
<div class="position-absolute" style="right: 3px;top:5px;" v-if="errors.hasOwnProperty(pre.id)">
|
||||||
|
<Icon size="18px" color="red" style="cursor: pointer;">
|
||||||
|
<ExclamationCircle/>
|
||||||
|
</Icon>
|
||||||
|
</div>
|
||||||
<div style="font-size:22px">
|
<div style="font-size:22px">
|
||||||
{{ pre.name }}
|
{{ pre.name }}
|
||||||
</div>
|
</div>
|
||||||
@ -24,9 +29,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="d-inline-block p-3 pt-2 Tab" :class="{Active:activeVMID===service.id}"
|
<div class="d-inline-block p-3 pt-2 Tab position-relative" :class="{Active:activeVMID===service.id}"
|
||||||
:key="service.id" v-for="service in vms.SERVICE_VM"
|
:key="service.id" v-for="service in vms.SERVICE_VM"
|
||||||
@click="active(service.id)">
|
@click="active(service.id)">
|
||||||
|
<div class="position-absolute" style="right: 3px;top:5px;" v-if="errors.hasOwnProperty(service.id)">
|
||||||
|
<Icon size="18px" color="red" style="cursor: pointer;">
|
||||||
|
<ExclamationCircle/>
|
||||||
|
</Icon>
|
||||||
|
</div>
|
||||||
<div style="font-size:22px">
|
<div style="font-size:22px">
|
||||||
{{ service.name }}
|
{{ service.name }}
|
||||||
</div>
|
</div>
|
||||||
@ -34,9 +44,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="d-inline-block p-3 pt-2 Tab" :class="{Active:activeVMID===post.id}"
|
<div class="d-inline-block p-3 pt-2 Tab position-relative" :class="{Active:activeVMID===post.id}"
|
||||||
:key="post.id" v-for="post in vms.POST_LAUNCHED_VM"
|
:key="post.id" v-for="post in vms.POST_LAUNCHED_VM"
|
||||||
@click="active(post.id)">
|
@click="active(post.id)">
|
||||||
|
<div class="position-absolute" style="right: 3px;top:5px;" v-if="errors.hasOwnProperty(post.id)">
|
||||||
|
<Icon size="18px" color="red" style="cursor: pointer;">
|
||||||
|
<ExclamationCircle/>
|
||||||
|
</Icon>
|
||||||
|
</div>
|
||||||
<div style="font-size:22px">
|
<div style="font-size:22px">
|
||||||
{{ post.name }}
|
{{ post.name }}
|
||||||
</div>
|
</div>
|
||||||
@ -53,12 +68,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {Icon} from "@vicons/utils";
|
||||||
|
import {ExclamationCircle} from "@vicons/fa";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TabBox",
|
name: "TabBox",
|
||||||
|
components: {Icon, ExclamationCircle},
|
||||||
props: {
|
props: {
|
||||||
scenario: {
|
scenario: {
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
|
errors: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
activeVMID: {type: Number}
|
activeVMID: {type: Number}
|
||||||
},
|
},
|
||||||
emits: ['tabActive', 'addVM'],
|
emits: ['tabActive', 'addVM'],
|
||||||
|
Loading…
Reference in New Issue
Block a user