Merge "Add support for chain OTA generation."
This commit is contained in:
80
tools/otagui/src/components/ChainOTAOptions.vue
Normal file
80
tools/otagui/src/components/ChainOTAOptions.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<form @submit.prevent="sendForm">
|
||||
<FileList
|
||||
v-model="targetBuilds"
|
||||
label="Target files"
|
||||
:movable="true"
|
||||
/>
|
||||
<v-divider />
|
||||
<OTAOptions
|
||||
:targetDetails="targetDetails"
|
||||
:targetBuilds="targetBuilds"
|
||||
@update:otaConfig="otaConfig=$event"
|
||||
/>
|
||||
<v-divider class="my-5" />
|
||||
<v-btn
|
||||
block
|
||||
type="submit"
|
||||
>
|
||||
Submit
|
||||
</v-btn>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OTAOptions from '@/components/OTAOptions.vue'
|
||||
import FileList from '@/components/FileList.vue'
|
||||
import { OTAConfiguration } from '@/services/JobSubmission.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
OTAOptions,
|
||||
FileList,
|
||||
},
|
||||
props: {
|
||||
targetDetails: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
targetBuilds: [],
|
||||
otaConfig: new OTAConfiguration(),
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$emit('update:isIncremental', false)
|
||||
this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds)
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* Send the configuration to the backend.
|
||||
*/
|
||||
async sendForm() {
|
||||
if (this.targetBuilds.length<2) {
|
||||
alert(
|
||||
'At least two OTA packeges has to be given!'
|
||||
)
|
||||
return
|
||||
}
|
||||
try {
|
||||
let response_messages = await this.otaConfig
|
||||
.sendChainForms(this.targetBuilds)
|
||||
alert(response_messages.join('\n'))
|
||||
this.otaConfig.reset()
|
||||
} catch (err) {
|
||||
alert(
|
||||
'Job cannot be started properly for the following reasons: ' + err
|
||||
)
|
||||
}
|
||||
},
|
||||
addIncrementalSources (build) {},
|
||||
addTargetBuilds (build) {
|
||||
if (!this.targetBuilds.includes(build)) {
|
||||
this.targetBuilds.push(build)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -14,13 +14,48 @@
|
||||
{{ build }}
|
||||
</option>
|
||||
</select>
|
||||
<v-btn
|
||||
<v-row
|
||||
class="my-2"
|
||||
:disabled="!selected"
|
||||
@click="deleteSelected"
|
||||
>
|
||||
Remove selected item
|
||||
</v-btn>
|
||||
<v-col
|
||||
cols="12"
|
||||
md="4"
|
||||
>
|
||||
<v-btn
|
||||
:disabled="!selected"
|
||||
block
|
||||
@click="deleteSelected"
|
||||
>
|
||||
Remove selected item
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-col
|
||||
cols="12"
|
||||
md="4"
|
||||
>
|
||||
<v-btn
|
||||
v-if="movable"
|
||||
:disabled="!selected"
|
||||
block
|
||||
@click="moveSelected(-1)"
|
||||
>
|
||||
🔼
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-col
|
||||
cols="12"
|
||||
md="4"
|
||||
>
|
||||
<v-btn
|
||||
v-if="movable"
|
||||
:disabled="!selected"
|
||||
block
|
||||
@click="moveSelected(1)"
|
||||
>
|
||||
🔽
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -33,6 +68,10 @@ export default {
|
||||
modelValue: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
movable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -61,6 +100,18 @@ export default {
|
||||
)
|
||||
}
|
||||
this.selected = null
|
||||
},
|
||||
moveSelected(direction) {
|
||||
let selectedIndex = this.modelValue.indexOf(this.selected)
|
||||
if (selectedIndex + direction > this.modelValue.length ||
|
||||
selectedIndex + direction < 0) {
|
||||
return
|
||||
}
|
||||
let tempArray = Array.from(this.modelValue)
|
||||
let temp = this.modelValue[selectedIndex]
|
||||
tempArray[selectedIndex] = tempArray[selectedIndex + direction]
|
||||
tempArray[selectedIndex + direction] = temp
|
||||
this.$emit("update:modelValue", tempArray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,28 @@ export class OTAConfiguration {
|
||||
return responses
|
||||
}
|
||||
|
||||
/**
|
||||
* Take in an ordered list of target builds and generate OTA packages between
|
||||
* them in order. For example, if there are n target builds, there will be
|
||||
* n-1 OTA packages.
|
||||
* @param {Array<String>} targetBuilds
|
||||
* @return Array<String>
|
||||
*/
|
||||
async sendChainForms(targetBuilds) {
|
||||
const responses = []
|
||||
this.isIncremental = true
|
||||
for (let i = 0; i < targetBuilds.length-1; i++) {
|
||||
try {
|
||||
let response =
|
||||
await this.sendForm(targetBuilds[i+1], targetBuilds[i])
|
||||
responses.push(response)
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
return responses
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an OTA package generation from target build to incremental source.
|
||||
* Throw an error if not succeed, otherwise will return the message from
|
||||
|
||||
@@ -42,12 +42,14 @@
|
||||
<script>
|
||||
import SingleOTAOptions from '@/components/SingleOTAOptions.vue'
|
||||
import BatchOTAOptions from '@/components/BatchOTAOptions.vue'
|
||||
import ChainOTAOptions from '@/components/ChainOTAOptions.vue'
|
||||
import BuildLibrary from '@/components/BuildLibrary.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SingleOTAOptions,
|
||||
BatchOTAOptions,
|
||||
ChainOTAOptions,
|
||||
BuildLibrary,
|
||||
},
|
||||
data() {
|
||||
@@ -58,7 +60,8 @@ export default {
|
||||
refresh: false,
|
||||
tabs: [
|
||||
{label: 'Single OTA', component: 'SingleOTAOptions'},
|
||||
{label: 'Batch OTA', component: 'BatchOTAOptions'}
|
||||
{label: 'Batch OTA', component: 'BatchOTAOptions'},
|
||||
{label: 'Chain OTA', component: 'ChainOTAOptions'}
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user