From 1ec526c9a0fec62b72a30a79651bce9ad78a64f5 Mon Sep 17 00:00:00 2001 From: lishutong Date: Thu, 19 Aug 2021 05:26:07 +0000 Subject: [PATCH] Add support for reuse configuration in OTA generator. Use vuex to store the otaConfig, now the history configurations can be reused in the job detail page. Also the targetBuilds, incrementalSources are not stored in vuex as well. Once the targetBuilds are chosen, it will not lose the states when switching the tab between singleOTA, batchOTA and chainOTA. Test: npm run test:unit Change-Id: I563ac0c79fd0cedd5e71e8722b956545f6624551 --- .../otagui/src/components/BatchOTAOptions.vue | 35 +++++++------ .../otagui/src/components/ChainOTAOptions.vue | 34 ++++++++++--- tools/otagui/src/components/OTAOptions.vue | 31 ++++++++--- .../otagui/src/components/PartialCheckbox.vue | 16 ++++-- .../src/components/SingleOTAOptions.vue | 35 +++++++------ tools/otagui/src/store/index.js | 51 ++++++++++++++++++- tools/otagui/src/views/JobConfigure.vue | 9 ++-- tools/otagui/src/views/JobDetails.vue | 11 ++++ 8 files changed, 170 insertions(+), 52 deletions(-) diff --git a/tools/otagui/src/components/BatchOTAOptions.vue b/tools/otagui/src/components/BatchOTAOptions.vue index 6f3126018..fcbc6e01b 100644 --- a/tools/otagui/src/components/BatchOTAOptions.vue +++ b/tools/otagui/src/components/BatchOTAOptions.vue @@ -2,7 +2,7 @@
@@ -14,7 +14,6 @@ import OTAOptions from '@/components/OTAOptions.vue' import FileList from '@/components/FileList.vue' -import { OTAConfiguration } from '@/services/JobSubmission.js' export default { components: { @@ -44,25 +42,30 @@ export default { }, data() { return { - incrementalSources: [], - targetBuilds: [], - otaConfig: new OTAConfiguration(), } }, computed: { checkIncremental() { - return this.otaConfig.isIncremental + return this.$store.state.otaConfig.isIncremental }, - }, - watch: { - checkIncremental: { - handler: function () { - this.$emit('update:isIncremental', this.checkIncremental) + incrementalSources: { + get() { + return this.$store.state.sourceBuilds }, + set(target) { + this.$store.commit('SET_SOURCES', target) + } }, + targetBuilds: { + get() { + return this.$store.state.targetBuilds + }, + set(target) { + this.$store.commit('SET_TARGETS', target) + } + } }, created() { - this.$emit('update:isIncremental', this.checkIncremental) this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds) }, methods: { @@ -71,10 +74,12 @@ export default { */ async sendForm() { try { - let response_messages = await this.otaConfig.sendForms( + let response_messages = await this.$store.state.otaConfig.sendForms( this.targetBuilds, this.incrementalSources) alert(response_messages.join('\n')) - this.otaConfig.reset() + this.$store.state.otaConfig.reset() + this.$store.commit('SET_TARGETS', []) + this.$store.commit('SET_SOURCES', []) } catch (err) { alert( 'Job cannot be started properly for the following reasons: ' + err diff --git a/tools/otagui/src/components/ChainOTAOptions.vue b/tools/otagui/src/components/ChainOTAOptions.vue index d4e394436..37d44f733 100644 --- a/tools/otagui/src/components/ChainOTAOptions.vue +++ b/tools/otagui/src/components/ChainOTAOptions.vue @@ -9,7 +9,6 @@ import OTAOptions from '@/components/OTAOptions.vue' import FileList from '@/components/FileList.vue' -import { OTAConfiguration } from '@/services/JobSubmission.js' export default { components: { @@ -39,12 +37,33 @@ export default { }, data() { return { - targetBuilds: [], - otaConfig: new OTAConfiguration(), + } + }, + computed: { + checkIncremental() { + return this.$store.state.otaConfig.isIncremental + }, + targetBuilds: { + get() { + return this.$store.state.targetBuilds + }, + set(target) { + this.$store.commit('SET_TARGETS', target) + } + } + }, + watch: { + checkIncremental: { + handler() { + // The isIncremental flag has to be set false all the time + this.$store.commit('SET_ISINCREMENTAL', false) + this.$store.commit('SET_SOURCES', []) + } } }, created() { - this.$emit('update:isIncremental', false) + this.$store.commit('SET_ISINCREMENTAL', false) + this.$store.commit('SET_SOURCES', []) this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds) }, methods: { @@ -59,10 +78,11 @@ export default { return } try { - let response_messages = await this.otaConfig + let response_messages = await this.$store.state.otaConfig .sendChainForms(this.targetBuilds) alert(response_messages.join('\n')) - this.otaConfig.reset() + this.$store.state.otaConfig.reset() + this.$store.commit('SET_TARGETS', []) } catch (err) { alert( 'Job cannot be started properly for the following reasons: ' + err diff --git a/tools/otagui/src/components/OTAOptions.vue b/tools/otagui/src/components/OTAOptions.vue index 6aee09fe0..86dee0921 100644 --- a/tools/otagui/src/components/OTAOptions.vue +++ b/tools/otagui/src/components/OTAOptions.vue @@ -15,10 +15,12 @@

Select Partitions

- +
+ +
\ No newline at end of file diff --git a/tools/otagui/src/components/PartialCheckbox.vue b/tools/otagui/src/components/PartialCheckbox.vue index 9e716c36a..8d350fe70 100644 --- a/tools/otagui/src/components/PartialCheckbox.vue +++ b/tools/otagui/src/components/PartialCheckbox.vue @@ -64,10 +64,20 @@ export default { } }, mounted() { - // Set the default value to be true once mounted - for (let key of this.labels) { - this.partitionSelected.set(key, true) + // Set the default value to be true once mounted if nothing has been selected + if (this.modelValue.length === 0) { + for (let key of this.labels) { + this.partitionSelected.set(key, true) + } + } else { + for (let key of this.labels) { + this.partitionSelected.set(key, false) + } + for (let key of this.modelValue) { + this.partitionSelected.set(key, true) + } } + this.$emit('update:modelValue', this.modelValue) }, methods: { updateSelected(newSelect) { diff --git a/tools/otagui/src/components/SingleOTAOptions.vue b/tools/otagui/src/components/SingleOTAOptions.vue index 39addf8fc..02d6b84ce 100644 --- a/tools/otagui/src/components/SingleOTAOptions.vue +++ b/tools/otagui/src/components/SingleOTAOptions.vue @@ -1,7 +1,7 @@