mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-09 12:08:30 +00:00
config-tools: bugfix for file related issue in UI
1. when using existing configuration, UI show the existing information. 2. remove launch script when removing post-launched VM. 3. new working folder created with no existing files. 4. automatically minimized. Tracked-On: #7450 Signed-off-by: Conghui <conghui.chen@intel.com>
This commit is contained in:
parent
c31cad225c
commit
f172502044
@ -392,6 +392,16 @@ pub fn acrn_read_dir(path: &str, recursive: bool) -> Result<Vec<DirEntry>, Strin
|
|||||||
read_dir(path, recursive).map_err(|e| e.to_string())
|
read_dir(path, recursive).map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn acrn_remove_dir(path: &str) -> Result<(), String> {
|
||||||
|
fs::remove_dir_all(path).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn acrn_remove_file(path: &str) -> Result<(), String> {
|
||||||
|
fs::remove_file(path).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_devtools(window: Window) {
|
pub fn open_devtools(window: Window) {
|
||||||
window.open_devtools()
|
window.open_devtools()
|
||||||
|
@ -19,6 +19,8 @@ fn main() {
|
|||||||
configurator::acrn_is_file,
|
configurator::acrn_is_file,
|
||||||
configurator::acrn_read_dir,
|
configurator::acrn_read_dir,
|
||||||
configurator::acrn_create_dir,
|
configurator::acrn_create_dir,
|
||||||
|
configurator::acrn_remove_dir,
|
||||||
|
configurator::acrn_remove_file,
|
||||||
configurator::open_devtools
|
configurator::open_devtools
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
|
@ -72,7 +72,7 @@ class Configurator {
|
|||||||
return invoke("acrn_write", {filePath, contents})
|
return invoke("acrn_write", {filePath, contents})
|
||||||
}
|
}
|
||||||
|
|
||||||
isFile(filePath: String): Promise<boolean> {
|
isFile(filePath: String): Promise<Boolean> {
|
||||||
return invoke("acrn_is_file", {path: filePath})
|
return invoke("acrn_is_file", {path: filePath})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +84,14 @@ class Configurator {
|
|||||||
return invoke('acrn_create_dir', {path, recursive})
|
return invoke('acrn_create_dir', {path, recursive})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeDir(path: String) {
|
||||||
|
return invoke('acrn_remove_dir', {path})
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFile(path: String) {
|
||||||
|
return invoke('acrn_remove_file', {path})
|
||||||
|
}
|
||||||
|
|
||||||
runPython(code: String, isJSON = false): String | Object {
|
runPython(code: String, isJSON = false): String | Object {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let result = window.pydoide.runPython(code);
|
let result = window.pydoide.runPython(code);
|
||||||
|
@ -11,9 +11,17 @@
|
|||||||
|
|
||||||
<b-accordion free>
|
<b-accordion free>
|
||||||
|
|
||||||
<b-accordion-item visible>
|
<b-accordion-item :visible='showFlag'>
|
||||||
<template #title>
|
<template #title>
|
||||||
|
<div class="d-flex flex-column">
|
||||||
<div class="p-1 ps-3 fs-4">1. Import a board configuration file</div>
|
<div class="p-1 ps-3 fs-4">1. Import a board configuration file</div>
|
||||||
|
<div class="py-2" style="letter-spacing: 0.49px;">
|
||||||
|
{{currentBoardFile}}
|
||||||
|
</div>
|
||||||
|
<div class="py-2" style="letter-spacing: 0.49px;">
|
||||||
|
{{currentBoardManu}} {{CurrentBoardProd}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Board v-model:WorkingFolder="WorkingFolder" v-model:board="board" v-model:schemas="schemas"
|
<Board v-model:WorkingFolder="WorkingFolder" v-model:board="board" v-model:schemas="schemas"
|
||||||
@boardUpdate="boardUpdate"/>
|
@boardUpdate="boardUpdate"/>
|
||||||
@ -21,16 +29,16 @@
|
|||||||
|
|
||||||
<Banner/>
|
<Banner/>
|
||||||
|
|
||||||
<b-accordion-item>
|
<b-accordion-item :visible='showFlag'>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
<div class="p-1 ps-3 fs-4">2. Create new or import an existing scenario</div>
|
<div class="p-1 ps-3 fs-4">2. Create new or import an existing scenario</div>
|
||||||
<div class="py-2" style="letter-spacing: 0.49px;">
|
<div class="py-2" style="letter-spacing: 0.49px;">
|
||||||
Current scenario: {{ scenarioHaveData ? 'scenario.xml' : 'none selected' }}
|
{{ scenarioHaveData ? 'Current scenario: scenario.xml' : '' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Scenario v-if="boardHaveData" :scenario="scenario" @scenarioUpdate="scenarioUpdate"/>
|
<Scenario v-if="boardHaveData" :scenario="scenario" :WorkingFolder="WorkingFolder" @scenarioUpdate="scenarioUpdate"/>
|
||||||
</b-accordion-item>
|
</b-accordion-item>
|
||||||
<Banner>
|
<Banner>
|
||||||
<div style="position: relative">
|
<div style="position: relative">
|
||||||
@ -41,7 +49,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</Banner>
|
</Banner>
|
||||||
|
|
||||||
<b-accordion-item>
|
<b-accordion-item visible>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div class="p-1 ps-3 d-flex w-100 justify-content-between align-items-center">
|
<div class="p-1 ps-3 d-flex w-100 justify-content-between align-items-center">
|
||||||
<div class="fs-4">3. Configure settings for scenario and launch scripts</div>
|
<div class="fs-4">3. Configure settings for scenario and launch scripts</div>
|
||||||
@ -92,11 +100,14 @@ import configurator from "../lib/acrn";
|
|||||||
export default {
|
export default {
|
||||||
name: "Config",
|
name: "Config",
|
||||||
components: {ConfigForm, TabBox, Scenario, Icon, Board, Banner, AngleLeft},
|
components: {ConfigForm, TabBox, Scenario, Icon, Board, Banner, AngleLeft},
|
||||||
props: ['WorkingFolder'],
|
props: { WorkingFolder: {type: String},
|
||||||
|
isNewConfig: {type: String}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateCurrentFormSchema()
|
this.updateCurrentFormSchema()
|
||||||
window.getCurrentFormSchemaData = this.getCurrentFormSchemaData
|
window.getCurrentFormSchemaData = this.getCurrentFormSchemaData
|
||||||
window.getCurrentScenarioData = this.getCurrentScenarioData
|
window.getCurrentScenarioData = this.getCurrentScenarioData
|
||||||
|
this.showFlag = this.isNewConfig === 'true'
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -108,6 +119,10 @@ export default {
|
|||||||
scenario: {},
|
scenario: {},
|
||||||
currentFormSchema: {},
|
currentFormSchema: {},
|
||||||
currentFormData: {},
|
currentFormData: {},
|
||||||
|
currentBoardFile: '',
|
||||||
|
currentBoardManu: '',
|
||||||
|
CurrentBoardProd: '',
|
||||||
|
showFlag: false,
|
||||||
errors: []
|
errors: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -123,10 +138,26 @@ export default {
|
|||||||
back() {
|
back() {
|
||||||
this.$router.back()
|
this.$router.back()
|
||||||
},
|
},
|
||||||
|
updateCurrentBoardInfo() {
|
||||||
|
// update the info in title
|
||||||
|
this.currentBoardFile = 'Current file: ' + this.board['name']
|
||||||
|
let boardContent = this.board.content
|
||||||
|
let reg = /(?<=Manufacturer).+(?=\\n)/
|
||||||
|
let result = boardContent.match(/Manufacturer.+\n/gm)
|
||||||
|
console.log(result)
|
||||||
|
if (result.length > 0) {
|
||||||
|
this.currentBoardManu = result[0]
|
||||||
|
}
|
||||||
|
var result_p = boardContent.match(/Product Name.+\n/gm)
|
||||||
|
if (result_p.length > 0) {
|
||||||
|
this.CurrentBoardProd = result_p[0]
|
||||||
|
}
|
||||||
|
},
|
||||||
boardUpdate(boardInfo, scenarioJSONSchema) {
|
boardUpdate(boardInfo, scenarioJSONSchema) {
|
||||||
this.board = boardInfo;
|
this.board = boardInfo;
|
||||||
this.schemas = scenarioJSONSchema
|
this.schemas = scenarioJSONSchema
|
||||||
this.updateCurrentFormSchema()
|
this.updateCurrentFormSchema()
|
||||||
|
this.updateCurrentBoardInfo()
|
||||||
},
|
},
|
||||||
updateCurrentFormSchema() {
|
updateCurrentFormSchema() {
|
||||||
if (this.activeVMID === -1) {
|
if (this.activeVMID === -1) {
|
||||||
@ -146,6 +177,7 @@ export default {
|
|||||||
},
|
},
|
||||||
scenarioUpdate(scenarioData) {
|
scenarioUpdate(scenarioData) {
|
||||||
this.scenario = scenarioData;
|
this.scenario = scenarioData;
|
||||||
|
this.showFlag = false;
|
||||||
this.updateCurrentFormSchema()
|
this.updateCurrentFormSchema()
|
||||||
this.updateCurrentFormData()
|
this.updateCurrentFormData()
|
||||||
},
|
},
|
||||||
@ -209,14 +241,19 @@ export default {
|
|||||||
msg = "Post-launched VMs require the Service VM. If you proceed, all post-launched VMs and their settings will also be deleted. Are you sure you want to proceed?"
|
msg = "Post-launched VMs require the Service VM. If you proceed, all post-launched VMs and their settings will also be deleted. Are you sure you want to proceed?"
|
||||||
isserivevm = true
|
isserivevm = true
|
||||||
} else {
|
} else {
|
||||||
msg = `Delete this virtual machine VM${this.activeVMID}?`
|
msg = `Delete this virtual machine VM${this.activeVMID}, launch script will alse be deleted if it exists.`
|
||||||
}
|
}
|
||||||
confirm(msg).then((r) => {
|
confirm(msg).then((r) => {
|
||||||
if (r) {
|
if (r) {
|
||||||
if (isserivevm) {
|
if (isserivevm) {
|
||||||
for (let i=postvmlist.length-1; i>=0; i--) {
|
for (let i=postvmlist.length-1; i>=0; i--) {
|
||||||
|
let launchScriptsname = this.WorkingFolder + `launch_user_vm_id${postvmlist[i]}.sh`
|
||||||
|
this.removeLaunchScript(launchScriptsname);
|
||||||
this.scenario.vm.splice(postvmlist[i], 1);
|
this.scenario.vm.splice(postvmlist[i], 1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let launchScriptsname = this.WorkingFolder + `launch_user_vm_id${currentVMIndex}.sh`
|
||||||
|
this.removeLaunchScript(launchScriptsname);
|
||||||
}
|
}
|
||||||
this.vmNameChange('', this.scenario.vm[currentVMIndex].name)
|
this.vmNameChange('', this.scenario.vm[currentVMIndex].name)
|
||||||
this.scenario.vm.splice(currentVMIndex, 1);
|
this.scenario.vm.splice(currentVMIndex, 1);
|
||||||
@ -225,6 +262,16 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
removeLaunchScript(filePath) {
|
||||||
|
console.log(filePath)
|
||||||
|
configurator.isFile(filePath)
|
||||||
|
.then((isFile) => {
|
||||||
|
if (isFile) {
|
||||||
|
configurator.removeFile(filePath)
|
||||||
|
.catch((err) => alert(`Launch script is not exist: ${filePath}`))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
scenarioConfigFormDataUpdate(vmid, data) {
|
scenarioConfigFormDataUpdate(vmid, data) {
|
||||||
if (vmid === -1) {
|
if (vmid === -1) {
|
||||||
this.scenario.hv = data
|
this.scenario.hv = data
|
||||||
@ -285,7 +332,6 @@ export default {
|
|||||||
this.updateCurrentFormData()
|
this.updateCurrentFormData()
|
||||||
// get scenario XML with defaults
|
// get scenario XML with defaults
|
||||||
scenarioXMLData = scenarioWithDefault.xml
|
scenarioXMLData = scenarioWithDefault.xml
|
||||||
debugger
|
|
||||||
// begin write down and verify
|
// begin write down and verify
|
||||||
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -87,10 +87,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
//get init board if it exist, add to history
|
||||||
|
this.getExistBoardPath()
|
||||||
|
.then((filePath) => {
|
||||||
|
if (filePath.length > 0) {
|
||||||
|
console.log("add exist board to history!")
|
||||||
|
configurator.addHistory('Board', filePath)
|
||||||
|
.then(() => {
|
||||||
this.getBoardHistory()
|
this.getBoardHistory()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.importBoard()
|
this.importBoard()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.getBoardHistory()
|
||||||
|
|
||||||
// Todo: auto load board
|
// Todo: auto load board
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -133,8 +145,26 @@ export default {
|
|||||||
.then(() => configurator.addHistory('Board', boardFileNewPath))
|
.then(() => configurator.addHistory('Board', boardFileNewPath))
|
||||||
.then(() => this.getBoardHistory())
|
.then(() => this.getBoardHistory())
|
||||||
})
|
})
|
||||||
|
.catch((err)=> {
|
||||||
|
alert(`Failed to load the file ${filepath}, it may not exist`)
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getExistBoardPath() {
|
||||||
|
// only return filename when using exist configuration.
|
||||||
|
return configurator.readDir(this.WorkingFolder, false)
|
||||||
|
.then((res) => {
|
||||||
|
let boardPath = ''
|
||||||
|
res.map((filepath) => {
|
||||||
|
if (filepath.path.search('board') != -1) {
|
||||||
|
boardPath = filepath.path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// only return the last vaild boardPath
|
||||||
|
return boardPath
|
||||||
|
})
|
||||||
|
},
|
||||||
openBoardFileSelectDialog() {
|
openBoardFileSelectDialog() {
|
||||||
return configurator.openDialog({
|
return configurator.openDialog({
|
||||||
title: "Open Board XML",
|
title: "Open Board XML",
|
||||||
|
@ -57,17 +57,30 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
WorkingFolder: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
scenario: {
|
scenario: {
|
||||||
type: Object
|
type: Object
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
//get init scenario if it exist, add to history
|
||||||
|
this.getExistScenarioPath()
|
||||||
|
.then((filePath) => {
|
||||||
|
if (filePath.length > 0) {
|
||||||
|
configurator.addHistory('Scenario', filePath)
|
||||||
|
.then(()=>{
|
||||||
this.getScenarioHistory().then(() => {
|
this.getScenarioHistory().then(() => {
|
||||||
// delay 2s for board loading
|
// delay 2s for board loading
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loadScenario(true)
|
this.loadScenario(true)
|
||||||
}, 2000);
|
}, 2000);
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.getScenarioHistory()
|
||||||
// Todo: auto load scenario
|
// Todo: auto load scenario
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -89,6 +102,20 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getExistScenarioPath() {
|
||||||
|
// only return filename when using exist configuration.
|
||||||
|
return configurator.readDir(this.WorkingFolder, false)
|
||||||
|
.then((res) => {
|
||||||
|
let scenarioPath = ''
|
||||||
|
res.map((filepath) => {
|
||||||
|
if (filepath.path.search('scenario') != -1) {
|
||||||
|
scenarioPath = filepath.path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// only return the last vaild boardPath
|
||||||
|
return scenarioPath
|
||||||
|
})
|
||||||
|
},
|
||||||
openScenarioFileSelectDialog() {
|
openScenarioFileSelectDialog() {
|
||||||
configurator.openDialog({
|
configurator.openDialog({
|
||||||
title: "Open Existing Scenario XML",
|
title: "Open Existing Scenario XML",
|
||||||
|
@ -52,7 +52,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
nextPage(folderPath) {
|
nextPage(folderPath) {
|
||||||
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath}})
|
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath, isNewConfig: true}})
|
||||||
},
|
},
|
||||||
usingWorkingFolder() {
|
usingWorkingFolder() {
|
||||||
let folderPath = this.WorkingFolder.length ? this.WorkingFolder : this.defaultWorkingFolder;
|
let folderPath = this.WorkingFolder.length ? this.WorkingFolder : this.defaultWorkingFolder;
|
||||||
@ -65,9 +65,16 @@ export default {
|
|||||||
.then((files) => {
|
.then((files) => {
|
||||||
console.log("Directory exists.", files)
|
console.log("Directory exists.", files)
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
confirm("Directory exists, overwrite it?")
|
confirm(`Warning: all existing files in the following working folder will be deleted: \n${folderPath}`)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r) this.nextPage(folderPath)
|
if (r) {
|
||||||
|
configurator.removeDir(folderPath)
|
||||||
|
.then(()=> {
|
||||||
|
configurator.creatDir(folderPath)
|
||||||
|
this.nextPage(folderPath)
|
||||||
|
})
|
||||||
|
.catch((err) => alert(`${err}`))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.nextPage(folderPath)
|
this.nextPage(folderPath)
|
||||||
|
@ -53,10 +53,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
nextPage(folderPath) {
|
nextPage(folderPath) {
|
||||||
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath}})
|
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath, isNewConfig:false}})
|
||||||
},
|
},
|
||||||
usingWorkingFolder() {
|
usingWorkingFolder() {
|
||||||
this.nextPage(this.currentSelected)
|
this.nextPage(this.currentSelected, true)
|
||||||
},
|
},
|
||||||
getHistory() {
|
getHistory() {
|
||||||
configurator.getHistory("WorkingFolder")
|
configurator.getHistory("WorkingFolder")
|
||||||
@ -75,7 +75,7 @@ export default {
|
|||||||
directory: true,
|
directory: true,
|
||||||
multiple: false
|
multiple: false
|
||||||
}).then(
|
}).then(
|
||||||
(folderPath) => configurator.addHistory("WorkingFolder", folderPath)
|
(folderPath) => configurator.addHistory("WorkingFolder", folderPath + window.systemInfo.pathSplit)
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.getHistory()
|
this.getHistory()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user