5858 <h3 class =" text-xs-left" > Azioni </h3 >
5959 <v-card >
6060 <div class =" cardContent" >
61- <v-btn @click =" shutdown" color =" info" ><v-icon >fas fa-power-off</v-icon > Spegni</v-btn >
62- <v-btn @click =" reboot" color =" info" ><v-icon >fas fa-redo</v-icon > Riavvia</v-btn >
63- <v-btn @click =" restoreConfig" color =" warning" ><v-icon >fas fa-redo</v-icon > Ripristina Impostazioni</v-btn >
64-
61+ <v-btn @click =" shutdown" color =" info" >
62+ <v-icon >fas fa-power-off</v-icon > Spegni
63+ </v-btn >
64+ <v-btn @click =" reboot" color =" info" >
65+ <v-icon >fas fa-redo</v-icon > Riavvia
66+ </v-btn >
67+ <v-btn @click =" restoreConfig" color =" warning" >
68+ <v-icon >fas fa-redo</v-icon > Ripristina Impostazioni
69+ </v-btn >
6570 <!--
6671 <v-btn color="warning">Aggiorna</v-btn>
6772 <v-btn color="error">Ripristina ad Impostazioni di fabbrica</v-btn>-->
6873 </div >
6974 </v-card >
75+ <br >
76+ <h3 class =" text-xs-left" > Aggiornamento </h3 >
77+ <v-card >
78+ <div class =" cardContent" >
79+ {{ counter }} %
80+ {{ updateStatusText }}
81+ <template v-if =" updateStatus == 0 " >
82+ <v-text-field label =" Seleziona il pacchetto di aggiornamento" @click =' pickFile' v-model =' fileName' prepend-icon =' attach_file' ></v-text-field >
83+ <input type =" file" style =" display : none " ref =" file" @change =" onFilePicked" >
84+ <v-btn @click =" upload" color =" error" >Conferma</v-btn >
85+ </template >
86+ </div >
87+ </v-card >
7088 <br ><br >
7189 </v-flex >
7290 </v-layout >
@@ -216,7 +234,48 @@ export default {
216234 this .prepopulate ();
217235 },
218236 methods: {
219- restoreConfig (){
237+ pickFile () {
238+ this .$refs .file .click ()
239+ },
240+ onFilePicked (e ) {
241+ const files = e .target .files
242+ if (files[0 ] !== undefined ) {
243+ this .fileName = files[0 ].name
244+ if (this .fileName .lastIndexOf (' .' ) <= 0 ) {
245+ return
246+ }
247+ const fr = new FileReader ()
248+ fr .readAsDataURL (files[0 ])
249+ fr .addEventListener (' load' , function () {
250+ this .fileUrl = fr .result
251+ this .fileObj = files[0 ]
252+ }.bind (this ))
253+ } else {
254+ this .fileName = ' '
255+ this .fileObj = ' '
256+ this .fileUrl = ' '
257+ }
258+ },
259+ upload () {
260+ console .log (this .fileObj )
261+ var formdata = new FormData ();
262+ formdata .append (' file_to_upload' , this .fileObj )
263+ const config = {
264+ headers: { ' Content-Type' : ' multipart/form-data' },
265+ onUploadProgress : progressEvent => {
266+ this .counter = Math .floor ((progressEvent .loaded * 100 ) / progressEvent .total );
267+ }
268+ }
269+ this .$axios .post (this .CB + ' /uploadFile' , formdata, config).then (result => {
270+ this .uploadCompleted = true ;
271+ this .uploadInProgress = false ;
272+ console .dir (result .data );
273+ this .updateStatusText = ' Upload completato. Aggiornamento in corso...'
274+ this .updateStatus = 1
275+ })
276+
277+ },
278+ restoreConfig () {
220279 let axios = this .$axios
221280 let CB = this .CB
222281 axios .post (CB + ' /restoreSettings' )
@@ -403,14 +462,14 @@ export default {
403462 ' prog_level' : data .progLevel ,
404463
405464 ' move_fw_elapse' : data .moveFwdElapse ,
406- ' move_fw_speed' : data .moveFwdSpeed ,
407- ' move_tr_elapse' : data .moveTurnElapse ,
408- ' move_tr_speed' : data .moveTurnSpeed ,
465+ ' move_fw_speed' : data .moveFwdSpeed ,
466+ ' move_tr_elapse' : data .moveTurnElapse ,
467+ ' move_tr_speed' : data .moveTurnSpeed ,
409468
410- ' ctrl_fw_elapse' : data .ctrlFwdElapse ,
411- ' ctrl_fw_speed' : data .ctrlFwdSpeed ,
412- ' ctrl_tr_elapse' : data .ctrlTurnElapse ,
413- ' ctrl_tr_speed' : data .ctrlTurnSpeed ,
469+ ' ctrl_fw_elapse' : data .ctrlFwdElapse ,
470+ ' ctrl_fw_speed' : data .ctrlFwdSpeed ,
471+ ' ctrl_tr_elapse' : data .ctrlTurnElapse ,
472+ ' ctrl_tr_speed' : data .ctrlTurnSpeed ,
414473 })
415474 axios .post (CBv1 + ' /config' , legacySettings)
416475 .then (function () {
@@ -433,6 +492,12 @@ export default {
433492 CBv1: process .env .CB_ENDPOINT ,
434493 snackbar: null ,
435494 snackText: null ,
495+ fileName: ' ' ,
496+ fileObj: ' ' ,
497+ fileUrl: ' ' ,
498+ counter: 0 ,
499+ updateStatusText: ' ' ,
500+ updateStatus: 0 ,
436501 // TODO: Prepopulate this
437502 settings: {
438503 cbName: ' CoderBot di Antonio' ,
@@ -443,29 +508,29 @@ export default {
443508 wifiSSID: null ,
444509 wifiPsw: null ,
445510
446- moveFwdElapse : null ,
447- moveFwdSpeed : null ,
448- moveTurnElapse : null ,
449- moveTurnSpeed : null ,
450- ctrlFwdElapse : null ,
451- ctrlFwdSpeed : null ,
452- ctrlTurnElapse : null ,
453- ctrlTurnSpeed : null ,
511+ moveFwdElapse: null ,
512+ moveFwdSpeed: null ,
513+ moveTurnElapse: null ,
514+ moveTurnSpeed: null ,
515+ ctrlFwdElapse: null ,
516+ ctrlFwdSpeed: null ,
517+ ctrlTurnElapse: null ,
518+ ctrlTurnSpeed: null ,
454519
455520 motorMode: null ,
456521 trimFactor: null ,
457522 startSound: null ,
458523 stopSound: null ,
459524 shutterSound: null ,
460525 startupProgram: null ,
461- progLevel: null
526+ progLevel: null ,
462527 },
463528
464529 blocklyToolboxItems: [
465- {text: ' Movimento' , value: ' basic_move' },
466- {text: ' Base' , value: ' basic' },
467- {text: ' Standard' , value: ' std' },
468- {text: ' Avanzate' , value: ' adv' },
530+ { text: ' Movimento' , value: ' basic_move' },
531+ { text: ' Base' , value: ' basic' },
532+ { text: ' Standard' , value: ' std' },
533+ { text: ' Avanzate' , value: ' adv' },
469534 ],
470535 cb: {
471536 info: {
@@ -499,9 +564,12 @@ export default {
499564 padding : 16px ;
500565}
501566
502- .fa , .fas , .fab {
567+ .fa ,
568+ .fas ,
569+ .fab {
503570 font-weight : 600 ;
504571 margin-right : 7px ;
505- text-size :10px ;
572+ text-size : 10px ;
506573}
574+
507575 </style >
0 commit comments