1<template> 2 <form @submit.prevent="sendForm"> 3 <FileList 4 v-model="incrementalSources" 5 :disabled="!checkIncremental" 6 label="Source files" 7 /> 8 <v-divider /> 9 <FileList 10 v-model="targetBuilds" 11 label="Target files" 12 /> 13 <v-divider /> 14 <OTAOptions 15 :targetDetails="targetDetails" 16 :targetBuilds="targetBuilds" 17 /> 18 <v-divider class="my-5" /> 19 <v-btn 20 block 21 type="submit" 22 > 23 Submit 24 </v-btn> 25 </form> 26</template> 27 28<script> 29import OTAOptions from '@/components/OTAOptions.vue' 30import FileList from '@/components/FileList.vue' 31 32export default { 33 components: { 34 OTAOptions, 35 FileList, 36 }, 37 props: { 38 targetDetails: { 39 type: Array, 40 default: () => [], 41 } 42 }, 43 data() { 44 return { 45 } 46 }, 47 computed: { 48 checkIncremental() { 49 return this.$store.state.otaConfig.isIncremental 50 }, 51 incrementalSources: { 52 get() { 53 return this.$store.state.sourceBuilds 54 }, 55 set(target) { 56 this.$store.commit('SET_SOURCES', target) 57 } 58 }, 59 targetBuilds: { 60 get() { 61 return this.$store.state.targetBuilds 62 }, 63 set(target) { 64 this.$store.commit('SET_TARGETS', target) 65 } 66 } 67 }, 68 created() { 69 this.$emit('update:handler', this.addIncrementalSources, this.addTargetBuilds) 70 }, 71 methods: { 72 /** 73 * Send the configuration to the backend. 74 */ 75 async sendForm() { 76 try { 77 let response_data = await this.$store.state.otaConfig.sendForms( 78 this.targetBuilds, this.incrementalSources); 79 let response_messages = response_data.map(d => d.msg); 80 alert(response_messages.join('\n')) 81 this.$store.state.otaConfig.reset() 82 this.$store.commit('SET_TARGETS', []) 83 this.$store.commit('SET_SOURCES', []) 84 } catch (err) { 85 alert( 86 'Job cannot be started properly for the following reasons: ' + err 87 ) 88 } 89 }, 90 addIncrementalSources (build) { 91 if (!this.incrementalSources.includes(build)) { 92 this.incrementalSources.push(build) 93 } 94 }, 95 addTargetBuilds (build) { 96 if (!this.targetBuilds.includes(build)) { 97 this.targetBuilds.push(build) 98 } 99 } 100 }, 101} 102</script>