Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 097e8c0

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Add support for reuse configuration in OTA generator."
2 parents 54f2464 + 1ec526c commit 097e8c0

File tree

8 files changed

+170
-52
lines changed

8 files changed

+170
-52
lines changed

tools/otagui/src/components/BatchOTAOptions.vue

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<form @submit.prevent="sendForm">
33
<FileList
44
v-model="incrementalSources"
5-
:disabled="!otaConfig.isIncremental"
5+
:disabled="!checkIncremental"
66
label="Source files"
77
/>
88
<v-divider />
@@ -14,7 +14,6 @@
1414
<OTAOptions
1515
:targetDetails="targetDetails"
1616
:targetBuilds="targetBuilds"
17-
@update:otaConfig="otaConfig=$event"
1817
/>
1918
<v-divider class="my-5" />
2019
<v-btn
@@ -29,7 +28,6 @@
2928
<script>
3029
import OTAOptions from '@/components/OTAOptions.vue'
3130
import FileList from '@/components/FileList.vue'
32-
import { OTAConfiguration } from '@/services/JobSubmission.js'
3331
3432
export default {
3533
components: {
@@ -44,25 +42,30 @@ export default {
4442
},
4543
data() {
4644
return {
47-
incrementalSources: [],
48-
targetBuilds: [],
49-
otaConfig: new OTAConfiguration(),
5045
}
5146
},
5247
computed: {
5348
checkIncremental() {
54-
return this.otaConfig.isIncremental
49+
return this.$store.state.otaConfig.isIncremental
5550
},
56-
},
57-
watch: {
58-
checkIncremental: {
59-
handler: function () {
60-
this.$emit('update:isIncremental', this.checkIncremental)
51+
incrementalSources: {
52+
get() {
53+
return this.$store.state.sourceBuilds
6154
},
55+
set(target) {
56+
this.$store.commit('SET_SOURCES', target)
57+
}
6258
},
59+
targetBuilds: {
60+
get() {
61+
return this.$store.state.targetBuilds
62+
},
63+
set(target) {
64+
this.$store.commit('SET_TARGETS', target)
65+
}
66+
}
6367
},
6468
created() {
65-
this.$emit('update:isIncremental', this.checkIncremental)
6669
this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds)
6770
},
6871
methods: {
@@ -71,10 +74,12 @@ export default {
7174
*/
7275
async sendForm() {
7376
try {
74-
let response_messages = await this.otaConfig.sendForms(
77+
let response_messages = await this.$store.state.otaConfig.sendForms(
7578
this.targetBuilds, this.incrementalSources)
7679
alert(response_messages.join('\n'))
77-
this.otaConfig.reset()
80+
this.$store.state.otaConfig.reset()
81+
this.$store.commit('SET_TARGETS', [])
82+
this.$store.commit('SET_SOURCES', [])
7883
} catch (err) {
7984
alert(
8085
'Job cannot be started properly for the following reasons: ' + err

tools/otagui/src/components/ChainOTAOptions.vue

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<OTAOptions
1010
:targetDetails="targetDetails"
1111
:targetBuilds="targetBuilds"
12-
@update:otaConfig="otaConfig=$event"
1312
/>
1413
<v-divider class="my-5" />
1514
<v-btn
@@ -24,7 +23,6 @@
2423
<script>
2524
import OTAOptions from '@/components/OTAOptions.vue'
2625
import FileList from '@/components/FileList.vue'
27-
import { OTAConfiguration } from '@/services/JobSubmission.js'
2826
2927
export default {
3028
components: {
@@ -39,12 +37,33 @@ export default {
3937
},
4038
data() {
4139
return {
42-
targetBuilds: [],
43-
otaConfig: new OTAConfiguration(),
40+
}
41+
},
42+
computed: {
43+
checkIncremental() {
44+
return this.$store.state.otaConfig.isIncremental
45+
},
46+
targetBuilds: {
47+
get() {
48+
return this.$store.state.targetBuilds
49+
},
50+
set(target) {
51+
this.$store.commit('SET_TARGETS', target)
52+
}
53+
}
54+
},
55+
watch: {
56+
checkIncremental: {
57+
handler() {
58+
// The isIncremental flag has to be set false all the time
59+
this.$store.commit('SET_ISINCREMENTAL', false)
60+
this.$store.commit('SET_SOURCES', [])
61+
}
4462
}
4563
},
4664
created() {
47-
this.$emit('update:isIncremental', false)
65+
this.$store.commit('SET_ISINCREMENTAL', false)
66+
this.$store.commit('SET_SOURCES', [])
4867
this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds)
4968
},
5069
methods: {
@@ -59,10 +78,11 @@ export default {
5978
return
6079
}
6180
try {
62-
let response_messages = await this.otaConfig
81+
let response_messages = await this.$store.state.otaConfig
6382
.sendChainForms(this.targetBuilds)
6483
alert(response_messages.join('\n'))
65-
this.otaConfig.reset()
84+
this.$store.state.otaConfig.reset()
85+
this.$store.commit('SET_TARGETS', [])
6686
} catch (err) {
6787
alert(
6888
'Job cannot be started properly for the following reasons: ' + err

tools/otagui/src/components/OTAOptions.vue

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
<div v-if="otaConfig.isPartial">
1616
<v-divider />
1717
<h3>Select Partitions</h3>
18-
<PartialCheckbox
19-
v-model="otaConfig.partial"
20-
:labels="updatablePartitions"
21-
/>
18+
<div v-if="targetDetails.length!==0">
19+
<PartialCheckbox
20+
v-model="otaConfig.partial"
21+
:labels="updatablePartitions"
22+
/>
23+
</div>
2224
<v-divider />
2325
</div>
2426
<v-btn
@@ -51,7 +53,7 @@
5153
import BaseInput from '@/components/BaseInput.vue'
5254
import BaseCheckbox from '@/components/BaseCheckbox.vue'
5355
import PartialCheckbox from '@/components/PartialCheckbox.vue'
54-
import { OTAConfiguration, OTABasicFlags, OTAExtraFlags } from '@/services/JobSubmission.js'
56+
import { OTABasicFlags, OTAExtraFlags } from '@/services/JobSubmission.js'
5557
5658
export default {
5759
components: {
@@ -71,7 +73,7 @@ export default {
7173
},
7274
data () {
7375
return {
74-
otaConfig: new OTAConfiguration(),
76+
otaConfig: null,
7577
moreOptions: false,
7678
basicFlags: OTABasicFlags,
7779
extraFlags: OTAExtraFlags
@@ -93,14 +95,29 @@ export default {
9395
)
9496
return target[0].partitions
9597
},
98+
checkIncremental() {
99+
return this.$store.state.otaConfig.isIncremental
100+
}
96101
},
97102
watch: {
98103
otaConfig: {
99104
handler () {
100-
this.$emit('update:otaConfig', this.otaConfig)
105+
this.$store.commit('SET_CONFIG', this.otaConfig)
101106
},
102107
deep: true
108+
},
109+
checkIncremental: {
110+
handler () {
111+
// In chain OTA, this option will be set outside this components
112+
console.log('changed')
113+
this.otaConfig.isIncremental = this.checkIncremental
114+
}
103115
}
116+
},
117+
created() {
118+
// This option only need to be synced once because this will not be
119+
// modified outside this components
120+
this.otaConfig = this.$store.state.otaConfig
104121
}
105122
}
106123
</script>

tools/otagui/src/components/PartialCheckbox.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,20 @@ export default {
6464
}
6565
},
6666
mounted() {
67-
// Set the default value to be true once mounted
68-
for (let key of this.labels) {
69-
this.partitionSelected.set(key, true)
67+
// Set the default value to be true once mounted if nothing has been selected
68+
if (this.modelValue.length === 0) {
69+
for (let key of this.labels) {
70+
this.partitionSelected.set(key, true)
71+
}
72+
} else {
73+
for (let key of this.labels) {
74+
this.partitionSelected.set(key, false)
75+
}
76+
for (let key of this.modelValue) {
77+
this.partitionSelected.set(key, true)
78+
}
7079
}
80+
this.$emit('update:modelValue', this.modelValue)
7181
},
7282
methods: {
7383
updateSelected(newSelect) {

tools/otagui/src/components/SingleOTAOptions.vue

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<form @submit.prevent="sendForm">
33
<FileSelect
4-
v-if="otaConfig.isIncremental"
4+
v-if="checkIncremental"
55
v-model="incrementalSource"
66
label="Select the source file"
77
:options="targetDetails"
@@ -14,7 +14,6 @@
1414
<OTAOptions
1515
:targetDetails="targetDetails"
1616
:targetBuilds="[targetBuild]"
17-
@update:otaConfig="otaConfig=$event"
1817
/>
1918
<v-divider class="my-5" />
2019
<v-btn
@@ -29,7 +28,6 @@
2928
<script>
3029
import OTAOptions from '@/components/OTAOptions.vue'
3130
import FileSelect from '@/components/FileSelect.vue'
32-
import { OTAConfiguration } from '@/services/JobSubmission.js'
3331
3432
export default {
3533
components: {
@@ -44,25 +42,30 @@ export default {
4442
},
4543
data() {
4644
return {
47-
incrementalSource: '',
48-
targetBuild: '',
49-
otaConfig: new OTAConfiguration(),
5045
}
5146
},
5247
computed: {
5348
checkIncremental() {
54-
return this.otaConfig.isIncremental
49+
return this.$store.state.otaConfig.isIncremental
5550
},
56-
},
57-
watch: {
58-
checkIncremental: {
59-
handler: function () {
60-
this.$emit('update:isIncremental', this.checkIncremental)
51+
incrementalSource: {
52+
get() {
53+
return this.$store.state.sourceBuilds[0]
6154
},
55+
set(target) {
56+
this.$store.commit('SET_SOURCE', target)
57+
}
6258
},
59+
targetBuild: {
60+
get() {
61+
return this.$store.state.targetBuilds[0]
62+
},
63+
set(target) {
64+
this.$store.commit('SET_TARGET', target)
65+
}
66+
}
6367
},
6468
created() {
65-
this.$emit('update:isIncremental', this.checkIncremental)
6669
this.$emit('update:handler', this.setIncrementalSource, this.setTargetBuild)
6770
},
6871
methods: {
@@ -71,10 +74,12 @@ export default {
7174
*/
7275
async sendForm() {
7376
try {
74-
let response_message = await this.otaConfig.sendForm(
77+
let response_message = await this.$store.state.otaConfig.sendForm(
7578
this.targetBuild, this.incrementalSource)
7679
alert(response_message)
77-
this.otaConfig.reset()
80+
this.$store.state.otaConfig.reset()
81+
this.$store.commit('SET_TARGETS', [])
82+
this.$store.commit('SET_SOURCES', [])
7883
} catch (err) {
7984
alert(
8085
'Job cannot be started properly for the following reasons: ' + err

tools/otagui/src/store/index.js

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,55 @@
11
import { createStore } from 'vuex'
2+
import { OTAConfiguration, OTAExtraFlags } from '@/services/JobSubmission.js'
23

34
export default createStore({
4-
state: {},
5-
mutations: {},
5+
state: {
6+
otaConfig: new OTAConfiguration(),
7+
targetBuilds: [],
8+
sourceBuilds: []
9+
},
10+
mutations: {
11+
REUSE_CONFIG(state, config) {
12+
state.otaConfig.verbose = config.verbose
13+
state.otaConfig.isIncremental = config.isIncremental
14+
state.otaConfig.partial = config.partial
15+
state.otaConfig.isPartial = config.isPartial
16+
state.targetBuilds = [config.target]
17+
if (config.isIncremental)
18+
state.sourceBuilds = [config.incremental]
19+
const extra =
20+
config.extra.split('--')
21+
.filter((s) => s!=='')
22+
.map((s) => s.trimRight())
23+
extra.forEach( (key) => {
24+
if (OTAExtraFlags.filter((flags) => flags.key == key)) {
25+
state.otaConfig[key] = true
26+
} else {
27+
state.extra += key
28+
}
29+
})
30+
},
31+
SET_CONFIG(state, config) {
32+
state.otaConfig = config
33+
},
34+
RESET_CONFIG(state) {
35+
state.otaConfig = new OTAConfiguration()
36+
},
37+
SET_TARGET(state, target) {
38+
state.targetBuilds = [target]
39+
},
40+
SET_SOURCE(state, target) {
41+
state.sourceBuilds = [target]
42+
},
43+
SET_TARGETS(state, targets) {
44+
state.targetBuilds = targets
45+
},
46+
SET_SOURCES(state, targets) {
47+
state.sourceBuilds = targets
48+
},
49+
SET_ISINCREMENTAL(state, isIncremental) {
50+
state.otaConfig.isIncremental = isIncremental
51+
}
52+
},
653
actions: {},
754
modules: {}
855
})

0 commit comments

Comments
 (0)