58
58
<h3 class =" text-xs-left" > Azioni </h3 >
59
59
<v-card >
60
60
<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 >
65
70
<!--
66
71
<v-btn color="warning">Aggiorna</v-btn>
67
72
<v-btn color="error">Ripristina ad Impostazioni di fabbrica</v-btn>-->
68
73
</div >
69
74
</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 >
70
88
<br ><br >
71
89
</v-flex >
72
90
</v-layout >
@@ -216,7 +234,48 @@ export default {
216
234
this .prepopulate ();
217
235
},
218
236
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 () {
220
279
let axios = this .$axios
221
280
let CB = this .CB
222
281
axios .post (CB + ' /restoreSettings' )
@@ -403,14 +462,14 @@ export default {
403
462
' prog_level' : data .progLevel ,
404
463
405
464
' 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 ,
409
468
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 ,
414
473
})
415
474
axios .post (CBv1 + ' /config' , legacySettings)
416
475
.then (function () {
@@ -433,6 +492,12 @@ export default {
433
492
CBv1: process .env .CB_ENDPOINT ,
434
493
snackbar: null ,
435
494
snackText: null ,
495
+ fileName: ' ' ,
496
+ fileObj: ' ' ,
497
+ fileUrl: ' ' ,
498
+ counter: 0 ,
499
+ updateStatusText: ' ' ,
500
+ updateStatus: 0 ,
436
501
// TODO: Prepopulate this
437
502
settings: {
438
503
cbName: ' CoderBot di Antonio' ,
@@ -443,29 +508,29 @@ export default {
443
508
wifiSSID: null ,
444
509
wifiPsw: null ,
445
510
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 ,
454
519
455
520
motorMode: null ,
456
521
trimFactor: null ,
457
522
startSound: null ,
458
523
stopSound: null ,
459
524
shutterSound: null ,
460
525
startupProgram: null ,
461
- progLevel: null
526
+ progLevel: null ,
462
527
},
463
528
464
529
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' },
469
534
],
470
535
cb: {
471
536
info: {
@@ -499,9 +564,12 @@ export default {
499
564
padding : 16px ;
500
565
}
501
566
502
- .fa , .fas , .fab {
567
+ .fa ,
568
+ .fas ,
569
+ .fab {
503
570
font-weight : 600 ;
504
571
margin-right : 7px ;
505
- text-size :10px ;
572
+ text-size : 10px ;
506
573
}
574
+
507
575
</style >
0 commit comments