mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
config_tools: fix new working folder cancel button
fix new working folder cancel button Tracked-On: #6691 Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
parent
7be26940f7
commit
47337f55f5
@ -54,6 +54,27 @@ export default {
|
|||||||
nextPage(folderPath) {
|
nextPage(folderPath) {
|
||||||
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath, isNewConfig: true}})
|
this.$router.push({name: 'Config', params: {WorkingFolder: folderPath, isNewConfig: true}})
|
||||||
},
|
},
|
||||||
|
cleanOldFiles(files) {
|
||||||
|
let promises = [];
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
let arr = files[i].path.split(window.systemInfo.pathSplit)
|
||||||
|
let basename = arr[arr.length - 1]
|
||||||
|
console.log("file: ", basename)
|
||||||
|
if (basename === 'scenario.xml' ||
|
||||||
|
/^.*\.board\.xml$/.test(basename) ||
|
||||||
|
/^launch.*\.sh$/.test(basename)) {
|
||||||
|
console.log("removing: ", files[i].path)
|
||||||
|
promises.push(
|
||||||
|
configurator.removeFile(files[i].path)
|
||||||
|
.then(() => {
|
||||||
|
console.log("removed: ", files[i].path)
|
||||||
|
})
|
||||||
|
.catch((err) => alert(`${err}`))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.all(promises);
|
||||||
|
},
|
||||||
usingWorkingFolder() {
|
usingWorkingFolder() {
|
||||||
let folderPath = this.WorkingFolder.length ? this.WorkingFolder : this.defaultWorkingFolder;
|
let folderPath = this.WorkingFolder.length ? this.WorkingFolder : this.defaultWorkingFolder;
|
||||||
if (folderPath[0] === '~') {
|
if (folderPath[0] === '~') {
|
||||||
@ -66,33 +87,29 @@ export default {
|
|||||||
|
|
||||||
configurator.readDir(folderPath, false)
|
configurator.readDir(folderPath, false)
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
|
// dir exists, check dir files exists
|
||||||
console.log("Directory exists.", files)
|
console.log("Directory exists.", files)
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
|
// confirm clean old files
|
||||||
confirm(`Warning: delete previous config files in the following working folder: \n${folderPath}?`)
|
confirm(`Warning: delete previous config files in the following working folder: \n${folderPath}?`)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r) {
|
// user cancel the operation
|
||||||
for (let i = 0; i < files.length; i++) {
|
if (!r) {
|
||||||
let arr = files[i].path.split(window.systemInfo.pathSplit)
|
return
|
||||||
let basename = arr[arr.length-1]
|
|
||||||
console.log("file: ", basename)
|
|
||||||
if (basename === 'scenario.xml' ||
|
|
||||||
/^.*\.board\.xml$/.test(basename) ||
|
|
||||||
/^launch.*\.sh$/.test(basename)) {
|
|
||||||
console.log("removing: ", files[i].path)
|
|
||||||
configurator.removeFile(files[i].path)
|
|
||||||
.catch((err) => alert(`${err}`))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
// user confirm the operation
|
||||||
.then(() => {
|
this.cleanOldFiles(files)
|
||||||
this.nextPage(folderPath)
|
.then(() => {
|
||||||
|
this.nextPage(folderPath)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
// dir is empty, no operation
|
||||||
this.nextPage(folderPath)
|
this.nextPage(folderPath)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
// dir not exists, create dir
|
||||||
console.log(error)
|
console.log(error)
|
||||||
configurator.creatDir(folderPath)
|
configurator.creatDir(folderPath)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user