|
36 | 36 | <h3 class="text-xs-left">Sistema </h3> |
37 | 37 | <v-card> |
38 | 38 | <div class="cardContent"> |
39 | | - |
40 | 39 | <v-select v-model="settings.progLevel" :items="blocklyToolboxItems" label="Livello Toolbox Blockly"></v-select> |
41 | 40 | <!--<v-text-field v-model="settings.cbName" label="Nome CoderBot"></v-text-field> |
42 | 41 | <br>--> |
43 | 42 | <div v-for="(value, key, index) in cb.info"> |
44 | 43 | {{ key }}: <code>{{ value }}</code> |
45 | 44 | </div> |
46 | | - Vue app commit build: <code> {{ lastCommit }} </code> |
| 45 | + Vue app commit build: <code> {{ lastCommit }} </code> |
47 | 46 | </div> |
48 | 47 | </v-card> |
49 | 48 | <br> |
|
79 | 78 | <v-card> |
80 | 79 | <div class="cardContent"> |
81 | 80 | <template v-if="updateStatus==1"> |
82 | | - Caricamento del file: |
83 | | - <h3>{{ counter }} %</h3> |
84 | | - <br> |
85 | | - {{ updateStatusText }} |
86 | | - |
87 | | - </template> |
88 | | - <template v-if="updateStatus==2"> |
89 | | - |
90 | | - </template> |
| 81 | + Caricamento del file: |
| 82 | + <h3>{{ counter }} %</h3> |
| 83 | + <br> |
| 84 | + {{ updateStatusText }} |
| 85 | + </template> |
| 86 | + <template v-if="updateStatus==2"> |
| 87 | + </template> |
91 | 88 | <template v-if="updateStatus==0"> |
92 | | - |
93 | 89 | <v-text-field label="Seleziona il pacchetto di aggiornamento" @click='pickFile' v-model='fileName' prepend-icon='attach_file'></v-text-field> |
94 | 90 | <input type="file" style="display: none" ref="file" @change="onFilePicked"> |
95 | 91 | <template v-if="this.fileObj"> Qualsiasi pacchetto di aggiornamento esistente verrà sovrascritto. CoderBot verrà riavviato per applicare l'aggiornamento.<br></template> |
96 | | - |
97 | 92 | <v-btn v-if="this.fileObj" @click="upload" color="error">Conferma</v-btn> |
98 | 93 | </template> |
99 | 94 | </div> |
@@ -252,36 +247,21 @@ export default { |
252 | 247 | }, |
253 | 248 | onFilePicked(e) { |
254 | 249 | const files = e.target.files |
255 | | - if (files[0] !== undefined) { |
256 | | - this.fileName = files[0].name |
257 | | - if (this.fileName.lastIndexOf('.') <= 0) { |
258 | | - return |
259 | | - } |
260 | | - const fr = new FileReader() |
261 | | - fr.readAsDataURL(files[0]) |
262 | | - fr.addEventListener('load', function() { |
263 | | - this.fileUrl = fr.result |
264 | | - this.fileObj = files[0] |
265 | | - }.bind(this)) |
266 | | - } else { |
267 | | - this.fileName = '' |
268 | | - this.fileObj = '' |
269 | | - this.fileUrl = '' |
270 | | - } |
| 250 | + this.fileName = files[0].name |
| 251 | + this.fileObj = files[0] |
| 252 | + this.formdata = new FormData(); |
| 253 | + this.formdata.append('file_to_upload', files[0], files[0].name); |
271 | 254 | }, |
272 | 255 | upload() { |
273 | | - var formdata = new FormData(); |
274 | | - formdata.append('file_to_upload', this.fileObj) |
275 | 256 | const config = { |
276 | 257 | headers: { 'Content-Type': 'multipart/form-data' }, |
277 | 258 | onUploadProgress: progressEvent => { |
278 | 259 | this.counter = Math.floor((progressEvent.loaded * 100) / progressEvent.total); |
279 | | -
|
280 | 260 | } |
281 | 261 | } |
282 | 262 | this.updateStatus = 1 |
283 | 263 |
|
284 | | - this.$axios.post(this.CB + '/updateFromPackage', formdata, config).then(function(result) { |
| 264 | + this.$axios.post(this.CB + '/updateFromPackage', this.formdata, config).then(function(result) { |
285 | 265 | this.uploadCompleted = true; |
286 | 266 | this.uploadInProgress = false; |
287 | 267 | console.dir(result.data); |
@@ -503,6 +483,8 @@ export default { |
503 | 483 | }, |
504 | 484 | data() { |
505 | 485 | return { |
| 486 | + formdata: null, |
| 487 | + files: null, |
506 | 488 | status: null, |
507 | 489 | lastCommit: process.env.lastCommit, |
508 | 490 | CB: process.env.CB_ENDPOINT + process.env.APIv2, |
|
0 commit comments