config_tools: reformat Board.vue

reformat Board.vue

Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2022-06-05 23:06:19 +08:00 committed by acrnsi-robot
parent 8ac076a540
commit fb91ad9a1a

View File

@ -63,7 +63,7 @@ import NewBoard from "./NewBoard.vue";
export default { export default {
name: "Board", name: "Board",
components: { NewBoard }, components: {NewBoard},
props: { props: {
WorkingFolder: { WorkingFolder: {
type: String type: String
@ -89,19 +89,19 @@ export default {
mounted() { mounted() {
//get init board if it exist, add to history //get init board if it exist, add to history
this.getExistBoardPath() this.getExistBoardPath()
.then((filePath) => { .then((filePath) => {
if (filePath.length > 0) { if (filePath.length > 0) {
console.log("add exist board to history!") console.log("add exist board to history!")
configurator.addHistory('Board', filePath) configurator.addHistory('Board', filePath)
.then(() => { .then(() => {
this.getBoardHistory() this.getBoardHistory()
.then(() => { .then(() => {
this.importBoard() this.importBoard()
}) })
}) })
} }
}) })
this.getBoardHistory() this.getBoardHistory()
// Todo: auto load board // Todo: auto load board
}, },
@ -114,16 +114,16 @@ export default {
importBoardButton() { importBoardButton() {
if (this.imported) { if (this.imported) {
this.openBoardFileSelectDialog() this.openBoardFileSelectDialog()
.then((filePath) => { .then((filePath) => {
if (filePath.length > 0) { if (filePath.length > 0) {
if (this.currentSelectedBoard.length > 0) { if (this.currentSelectedBoard.length > 0) {
if (filePath != this.currentSelectedBoard) { if (filePath !== this.currentSelectedBoard) {
this.showBoardOverwrite = true; this.showBoardOverwrite = true;
}
} }
} }
} this.newFilePath = filePath
this.newFilePath = filePath })
})
} else { } else {
this.importBoard() this.importBoard()
} }
@ -132,9 +132,9 @@ export default {
let filepath = '' let filepath = ''
if (useNewFile) { if (useNewFile) {
filepath = this.newFilePath filepath = this.newFilePath
if (filepath != this.currentSelectedBoard) { if (filepath !== this.currentSelectedBoard) {
configurator.removeFile(this.currentSelectedBoard) configurator.removeFile(this.currentSelectedBoard)
.catch((err) => alert(`${err}`)) .catch((err) => alert(`${err}`))
} }
} else { } else {
filepath = this.currentSelectedBoard filepath = this.currentSelectedBoard
@ -149,25 +149,25 @@ export default {
.then(() => configurator.addHistory('Board', boardFileNewPath)) .then(() => configurator.addHistory('Board', boardFileNewPath))
.then(() => this.getBoardHistory()) .then(() => this.getBoardHistory())
}) })
.catch((err)=> { .catch((err) => {
alert(`Loading ${filepath} failed: ${err}`) alert(`Loading ${filepath} failed: ${err}`)
console.log(err) console.log(err)
}) })
} }
}, },
getExistBoardPath() { getExistBoardPath() {
// only return filename when using exist configuration. // only return filename when using exist configuration.
return configurator.readDir(this.WorkingFolder, false) return configurator.readDir(this.WorkingFolder, false)
.then((res) => { .then((res) => {
let boardPath = '' let boardPath = ''
res.map((filepath) => { res.map((filepath) => {
if (filepath.path.search('\\.board\\.xml') != -1) { if (filepath.path.search('\\.board\\.xml') !== -1) {
boardPath = filepath.path boardPath = filepath.path
} }
}) })
// only return the last vaild boardPath // only return the last vaild boardPath
return boardPath return boardPath
}) })
}, },
openBoardFileSelectDialog() { openBoardFileSelectDialog() {
return configurator.openDialog({ return configurator.openDialog({
@ -179,8 +179,8 @@ export default {
}, },
browseForFile() { browseForFile() {
this.openBoardFileSelectDialog() this.openBoardFileSelectDialog()
.then((filePath) => configurator.addHistory('Board', filePath)) .then((filePath) => configurator.addHistory('Board', filePath))
.then(() => this.getBoardHistory()) .then(() => this.getBoardHistory())
}, },
getBoardHistory() { getBoardHistory() {
return configurator.getHistory("Board") return configurator.getHistory("Board")