1<template> 2 <ul> 3 <h3>Build Library</h3> 4 <UploadFile @file-uploaded="fetchTargetList" /> 5 <BuildTable 6 v-if="targetDetails && targetDetails.length>0" 7 :builds="targetDetails" 8 /> 9 <li 10 v-for="targetDetail in targetDetails" 11 :key="targetDetail.file_name" 12 > 13 <div> 14 <h3> Build File Name: {{ targetDetail.file_name }} </h3> 15 <strong> Uploaded time: </strong> {{ formDate(targetDetail.time) }} 16 <br> 17 <strong> Build ID: </strong> {{ targetDetail.build_id }} 18 <br> 19 <strong> Build Version: </strong> {{ targetDetail.build_version }} 20 <br> 21 <strong> Build Flavor: </strong> {{ targetDetail.build_flavor }} 22 <br> 23 <v-btn 24 :disabled="!isIncremental" 25 @click="selectIncremental(targetDetail.path)" 26 > 27 Select as Incremental File 28 </v-btn> 29   30 <v-btn @click="selectTarget(targetDetail.path)"> 31 Select as Target File 32 </v-btn> 33 </div> 34 <v-divider class="my-5" /> 35 </li> 36 <v-btn @click="updateBuildLib"> 37 Refresh the build Library (use with cautions) 38 </v-btn> 39 </ul> 40</template> 41 42<script> 43import UploadFile from '@/components/UploadFile.vue' 44import BuildTable from '@/components/BuildTable.vue' 45import ApiService from '../services/ApiService.js' 46import FormDate from '@/services/FormDate.js' 47 48export default { 49 components: { 50 UploadFile, 51 BuildTable 52 }, 53 props: { 54 isIncremental: { 55 type: Boolean, 56 required: true 57 } 58 }, 59 data() { 60 return { 61 incrementalSource: '', 62 targetBuild: '', 63 targetDetails: [] 64 } 65 }, 66 mounted () { 67 this.fetchTargetList() 68 }, 69 methods: { 70 /** 71 * Fetch the build list from backend. 72 */ 73 async fetchTargetList() { 74 try { 75 this.targetDetails = await ApiService.getBuildList() 76 this.$emit('update:targetDetails', this.targetDetails) 77 } catch (err) { 78 alert( 79 "Cannot fetch Android Builds list from the backend, for the following reasons:" 80 + err 81 ) 82 } 83 }, 84 /** 85 * Let the backend reload the builds from disk. This will overwrite the 86 * original upload time. 87 */ 88 async updateBuildLib() { 89 try { 90 this.targetDetails = await ApiService.reconstructBuildList(); 91 this.$emit('update:targetDetails', this.targetDetails); 92 } catch (err) { 93 alert( 94 "Cannot fetch Android Builds list from the backend, for the following reasons: " 95 + err 96 ) 97 } 98 }, 99 selectTarget(path) { 100 this.targetBuild = path 101 this.$emit('update:targetBuild', path) 102 }, 103 selectIncremental(path) { 104 this.incrementalSource = path 105 this.$emit('update:incrementalSource', path) 106 }, 107 formDate(unixTime) { 108 return FormDate.formDate(unixTime) 109 } 110 }, 111} 112</script> 113 114<style scoped> 115ul > li { 116 list-style: none 117} 118</style>