Merge "Add support for reuse configuration in OTA generator."

This commit is contained in:
Treehugger Robot
2021-08-19 20:45:53 +00:00
committed by Gerrit Code Review
8 changed files with 170 additions and 52 deletions

View File

@@ -2,7 +2,7 @@
<form @submit.prevent="sendForm"> <form @submit.prevent="sendForm">
<FileList <FileList
v-model="incrementalSources" v-model="incrementalSources"
:disabled="!otaConfig.isIncremental" :disabled="!checkIncremental"
label="Source files" label="Source files"
/> />
<v-divider /> <v-divider />
@@ -14,7 +14,6 @@
<OTAOptions <OTAOptions
:targetDetails="targetDetails" :targetDetails="targetDetails"
:targetBuilds="targetBuilds" :targetBuilds="targetBuilds"
@update:otaConfig="otaConfig=$event"
/> />
<v-divider class="my-5" /> <v-divider class="my-5" />
<v-btn <v-btn
@@ -29,7 +28,6 @@
<script> <script>
import OTAOptions from '@/components/OTAOptions.vue' import OTAOptions from '@/components/OTAOptions.vue'
import FileList from '@/components/FileList.vue' import FileList from '@/components/FileList.vue'
import { OTAConfiguration } from '@/services/JobSubmission.js'
export default { export default {
components: { components: {
@@ -44,25 +42,30 @@ export default {
}, },
data() { data() {
return { return {
incrementalSources: [],
targetBuilds: [],
otaConfig: new OTAConfiguration(),
} }
}, },
computed: { computed: {
checkIncremental() { checkIncremental() {
return this.otaConfig.isIncremental return this.$store.state.otaConfig.isIncremental
}, },
}, incrementalSources: {
watch: { get() {
checkIncremental: { return this.$store.state.sourceBuilds
handler: function () {
this.$emit('update:isIncremental', this.checkIncremental)
}, },
set(target) {
this.$store.commit('SET_SOURCES', target)
}
}, },
targetBuilds: {
get() {
return this.$store.state.targetBuilds
},
set(target) {
this.$store.commit('SET_TARGETS', target)
}
}
}, },
created() { created() {
this.$emit('update:isIncremental', this.checkIncremental)
this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds) this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds)
}, },
methods: { methods: {
@@ -71,10 +74,12 @@ export default {
*/ */
async sendForm() { async sendForm() {
try { try {
let response_messages = await this.otaConfig.sendForms( let response_messages = await this.$store.state.otaConfig.sendForms(
this.targetBuilds, this.incrementalSources) this.targetBuilds, this.incrementalSources)
alert(response_messages.join('\n')) 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) { } catch (err) {
alert( alert(
'Job cannot be started properly for the following reasons: ' + err 'Job cannot be started properly for the following reasons: ' + err

View File

@@ -9,7 +9,6 @@
<OTAOptions <OTAOptions
:targetDetails="targetDetails" :targetDetails="targetDetails"
:targetBuilds="targetBuilds" :targetBuilds="targetBuilds"
@update:otaConfig="otaConfig=$event"
/> />
<v-divider class="my-5" /> <v-divider class="my-5" />
<v-btn <v-btn
@@ -24,7 +23,6 @@
<script> <script>
import OTAOptions from '@/components/OTAOptions.vue' import OTAOptions from '@/components/OTAOptions.vue'
import FileList from '@/components/FileList.vue' import FileList from '@/components/FileList.vue'
import { OTAConfiguration } from '@/services/JobSubmission.js'
export default { export default {
components: { components: {
@@ -39,12 +37,33 @@ export default {
}, },
data() { data() {
return { 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() { 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) this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds)
}, },
methods: { methods: {
@@ -59,10 +78,11 @@ export default {
return return
} }
try { try {
let response_messages = await this.otaConfig let response_messages = await this.$store.state.otaConfig
.sendChainForms(this.targetBuilds) .sendChainForms(this.targetBuilds)
alert(response_messages.join('\n')) alert(response_messages.join('\n'))
this.otaConfig.reset() this.$store.state.otaConfig.reset()
this.$store.commit('SET_TARGETS', [])
} catch (err) { } catch (err) {
alert( alert(
'Job cannot be started properly for the following reasons: ' + err 'Job cannot be started properly for the following reasons: ' + err

View File

@@ -15,10 +15,12 @@
<div v-if="otaConfig.isPartial"> <div v-if="otaConfig.isPartial">
<v-divider /> <v-divider />
<h3>Select Partitions</h3> <h3>Select Partitions</h3>
<PartialCheckbox <div v-if="targetDetails.length!==0">
v-model="otaConfig.partial" <PartialCheckbox
:labels="updatablePartitions" v-model="otaConfig.partial"
/> :labels="updatablePartitions"
/>
</div>
<v-divider /> <v-divider />
</div> </div>
<v-btn <v-btn
@@ -51,7 +53,7 @@
import BaseInput from '@/components/BaseInput.vue' import BaseInput from '@/components/BaseInput.vue'
import BaseCheckbox from '@/components/BaseCheckbox.vue' import BaseCheckbox from '@/components/BaseCheckbox.vue'
import PartialCheckbox from '@/components/PartialCheckbox.vue' import PartialCheckbox from '@/components/PartialCheckbox.vue'
import { OTAConfiguration, OTABasicFlags, OTAExtraFlags } from '@/services/JobSubmission.js' import { OTABasicFlags, OTAExtraFlags } from '@/services/JobSubmission.js'
export default { export default {
components: { components: {
@@ -71,7 +73,7 @@ export default {
}, },
data () { data () {
return { return {
otaConfig: new OTAConfiguration(), otaConfig: null,
moreOptions: false, moreOptions: false,
basicFlags: OTABasicFlags, basicFlags: OTABasicFlags,
extraFlags: OTAExtraFlags extraFlags: OTAExtraFlags
@@ -93,14 +95,29 @@ export default {
) )
return target[0].partitions return target[0].partitions
}, },
checkIncremental() {
return this.$store.state.otaConfig.isIncremental
}
}, },
watch: { watch: {
otaConfig: { otaConfig: {
handler () { handler () {
this.$emit('update:otaConfig', this.otaConfig) this.$store.commit('SET_CONFIG', this.otaConfig)
}, },
deep: true deep: true
},
checkIncremental: {
handler () {
// In chain OTA, this option will be set outside this components
console.log('changed')
this.otaConfig.isIncremental = this.checkIncremental
}
} }
},
created() {
// This option only need to be synced once because this will not be
// modified outside this components
this.otaConfig = this.$store.state.otaConfig
} }
} }
</script> </script>

View File

@@ -64,10 +64,20 @@ export default {
} }
}, },
mounted() { mounted() {
// Set the default value to be true once mounted // Set the default value to be true once mounted if nothing has been selected
for (let key of this.labels) { if (this.modelValue.length === 0) {
this.partitionSelected.set(key, true) 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: { methods: {
updateSelected(newSelect) { updateSelected(newSelect) {

View File

@@ -1,7 +1,7 @@
<template> <template>
<form @submit.prevent="sendForm"> <form @submit.prevent="sendForm">
<FileSelect <FileSelect
v-if="otaConfig.isIncremental" v-if="checkIncremental"
v-model="incrementalSource" v-model="incrementalSource"
label="Select the source file" label="Select the source file"
:options="targetDetails" :options="targetDetails"
@@ -14,7 +14,6 @@
<OTAOptions <OTAOptions
:targetDetails="targetDetails" :targetDetails="targetDetails"
:targetBuilds="[targetBuild]" :targetBuilds="[targetBuild]"
@update:otaConfig="otaConfig=$event"
/> />
<v-divider class="my-5" /> <v-divider class="my-5" />
<v-btn <v-btn
@@ -29,7 +28,6 @@
<script> <script>
import OTAOptions from '@/components/OTAOptions.vue' import OTAOptions from '@/components/OTAOptions.vue'
import FileSelect from '@/components/FileSelect.vue' import FileSelect from '@/components/FileSelect.vue'
import { OTAConfiguration } from '@/services/JobSubmission.js'
export default { export default {
components: { components: {
@@ -44,25 +42,30 @@ export default {
}, },
data() { data() {
return { return {
incrementalSource: '',
targetBuild: '',
otaConfig: new OTAConfiguration(),
} }
}, },
computed: { computed: {
checkIncremental() { checkIncremental() {
return this.otaConfig.isIncremental return this.$store.state.otaConfig.isIncremental
}, },
}, incrementalSource: {
watch: { get() {
checkIncremental: { return this.$store.state.sourceBuilds[0]
handler: function () {
this.$emit('update:isIncremental', this.checkIncremental)
}, },
set(target) {
this.$store.commit('SET_SOURCE', target)
}
}, },
targetBuild: {
get() {
return this.$store.state.targetBuilds[0]
},
set(target) {
this.$store.commit('SET_TARGET', target)
}
}
}, },
created() { created() {
this.$emit('update:isIncremental', this.checkIncremental)
this.$emit('update:handler', this.setIncrementalSource, this.setTargetBuild) this.$emit('update:handler', this.setIncrementalSource, this.setTargetBuild)
}, },
methods: { methods: {
@@ -71,10 +74,12 @@ export default {
*/ */
async sendForm() { async sendForm() {
try { try {
let response_message = await this.otaConfig.sendForm( let response_message = await this.$store.state.otaConfig.sendForm(
this.targetBuild, this.incrementalSource) this.targetBuild, this.incrementalSource)
alert(response_message) alert(response_message)
this.otaConfig.reset() this.$store.state.otaConfig.reset()
this.$store.commit('SET_TARGETS', [])
this.$store.commit('SET_SOURCES', [])
} catch (err) { } catch (err) {
alert( alert(
'Job cannot be started properly for the following reasons: ' + err 'Job cannot be started properly for the following reasons: ' + err

View File

@@ -1,8 +1,55 @@
import { createStore } from 'vuex' import { createStore } from 'vuex'
import { OTAConfiguration, OTAExtraFlags } from '@/services/JobSubmission.js'
export default createStore({ export default createStore({
state: {}, state: {
mutations: {}, otaConfig: new OTAConfiguration(),
targetBuilds: [],
sourceBuilds: []
},
mutations: {
REUSE_CONFIG(state, config) {
state.otaConfig.verbose = config.verbose
state.otaConfig.isIncremental = config.isIncremental
state.otaConfig.partial = config.partial
state.otaConfig.isPartial = config.isPartial
state.targetBuilds = [config.target]
if (config.isIncremental)
state.sourceBuilds = [config.incremental]
const extra =
config.extra.split('--')
.filter((s) => s!=='')
.map((s) => s.trimRight())
extra.forEach( (key) => {
if (OTAExtraFlags.filter((flags) => flags.key == key)) {
state.otaConfig[key] = true
} else {
state.extra += key
}
})
},
SET_CONFIG(state, config) {
state.otaConfig = config
},
RESET_CONFIG(state) {
state.otaConfig = new OTAConfiguration()
},
SET_TARGET(state, target) {
state.targetBuilds = [target]
},
SET_SOURCE(state, target) {
state.sourceBuilds = [target]
},
SET_TARGETS(state, targets) {
state.targetBuilds = targets
},
SET_SOURCES(state, targets) {
state.sourceBuilds = targets
},
SET_ISINCREMENTAL(state, isIncremental) {
state.otaConfig.isIncremental = isIncremental
}
},
actions: {}, actions: {},
modules: {} modules: {}
}) })

View File

@@ -17,7 +17,6 @@
:is="currentTab" :is="currentTab"
class="tab-component" class="tab-component"
:targetDetails="targetDetails" :targetDetails="targetDetails"
@update:isIncremental="isIncremental = $event"
@update:handler="setHandler" @update:handler="setHandler"
/> />
</v-col> </v-col>
@@ -30,7 +29,7 @@
<!-- the key-binding refresh has to be used to reload the methods--> <!-- the key-binding refresh has to be used to reload the methods-->
<BuildLibrary <BuildLibrary
:refresh="refresh" :refresh="refresh"
:isIncremental="isIncremental" :isIncremental="checkIncremental"
@update:incrementalSource="addIncrementalSource" @update:incrementalSource="addIncrementalSource"
@update:targetBuild="addTargetBuild" @update:targetBuild="addTargetBuild"
@update:targetDetails="targetDetails = $event" @update:targetDetails="targetDetails = $event"
@@ -55,7 +54,6 @@ export default {
data() { data() {
return { return {
targetDetails: [], targetDetails: [],
isIncremental: false,
currentTab: 'SingleOTAOptions', currentTab: 'SingleOTAOptions',
refresh: false, refresh: false,
tabs: [ tabs: [
@@ -65,6 +63,11 @@ export default {
], ],
} }
}, },
computed: {
checkIncremental() {
return this.$store.state.otaConfig.isIncremental
},
},
methods: { methods: {
setHandler(addIncrementalSource, addTargetBuild) { setHandler(addIncrementalSource, addTargetBuild) {
this.refresh = true, this.refresh = true,

View File

@@ -5,6 +5,14 @@
:job="job" :job="job"
:build-detail="true" :build-detail="true"
/> />
<router-link :to="{name: 'Create'}">
<v-btn
block
@click="updateConfig()"
>
Reuse this configuration.
</v-btn>
</router-link>
<v-divider class="my-5" /> <v-divider class="my-5" />
<div> <div>
<h3>STDERR</h3> <h3>STDERR</h3>
@@ -95,6 +103,9 @@ export default {
if (this.job.status == 'Running') { if (this.job.status == 'Running') {
setTimeout(this.updateStatus, 1000) setTimeout(this.updateStatus, 1000)
} }
},
updateConfig() {
this.$store.commit("REUSE_CONFIG", this.job)
} }
}, },
} }