444
444
</v-layout >
445
445
</v-container >
446
446
</v-tab-item >
447
+
448
+ <!-- PACKAGE MANAGER -->
449
+ <v-tab-item >
450
+ <v-container grid-list-md text-xs-center >
451
+ <v-layout row wrap align-center >
452
+ <v-flex xs12 md6 offset-md3 >
453
+ <h3 class =" text-xs-left" >Gestione Pacchetti</h3 >
454
+ <br >
455
+ <v-card >
456
+ <div class =" cardContent" >
457
+ <h3 class =" text-xs-left" > Pacchetti installati:</h3 >
458
+
459
+ <div v-for =" pkgnames in settings.packagesInstalled" >
460
+ <ul >
461
+ <li > nome: {{pkgnames[0][0]}} tipo: {{pkgnames[1]}} <span align =" right" ><v-btn @click =" deletePkg(pkgnames[0][1])" color =" red" dark >
462
+ <v-icon >fas fa-trash</v-icon > Rimuovi
463
+ </v-btn ></span >
464
+ </li >
465
+ </ul >
466
+ </div >
467
+
468
+ </v-card >
469
+ <h3 class =" text-xs-left" > Aggiungi Pacchetto ssh with python</h3 >
470
+ <v-card >
471
+ <div class =" cardContent" >
472
+ <template v-if =" updateStatus == 1 " >
473
+ Caricamento del file:
474
+ <h3 >{{ counter }} %</h3 >
475
+ <br >
476
+ {{ updateStatusText }}
477
+ </template >
478
+ <template v-if =" updateStatus == 2 " >
479
+ </template >
480
+ <template v-if =" updateStatus == 0 " >
481
+ <v-text-field label =" Seleziona il pacchetto da installare" @click =' pickFile' v-model =' fileName' prepend-icon =' attach_file' ></v-text-field >
482
+ <input type =" file" style =" display : none " ref =" file" @change =" onFilePicked" >
483
+ <template v-if =" this .fileObj " >Clicca "CONFERMA" per installare il pacchetto<br ></template >
484
+ <v-btn v-if =" this.fileObj" @click =" uploadPackage" color =" error" >Conferma</v-btn >
485
+ </template >
486
+ </div >
487
+ </v-card >
488
+ </v-flex >
489
+ </v-layout >
490
+ </v-container >
491
+ </v-tab-item >
492
+
447
493
</v-tabs-items >
448
494
<!-- </template>
449
495
<template v-else>
466
512
<script >
467
513
import sidebar from " ../components/Sidebar"
468
514
515
+ function readTextFile (file , callback ) {
516
+ var rawFile = new XMLHttpRequest ();
517
+ rawFile .overrideMimeType (" application/json" );
518
+ rawFile .open (" GET" , file, true );
519
+ rawFile .onreadystatechange = function () {
520
+ if (rawFile .readyState === 4 && rawFile .status == " 200" ) {
521
+ callback (rawFile .responseText );
522
+ }
523
+ }
524
+ rawFile .send (null );
525
+ }
526
+ var packageList = [];// ["pianoooo","pianoo"], ["chitarra","guiitar"], ["flauto","fluute"]];
527
+ var datapkg = readTextFile ( " ./static/music_package.json" , function (text ){
528
+ var datas = JSON .parse (text);
529
+
530
+
531
+ Object .keys (datas[' packages' ]).forEach (function (key ) {
532
+ console .table (' Key : ' + key + ' , Value : ' + datas[' packages' ][key])
533
+ console .table (' Key : name_IT, Value : ' + datas[' packages' ][key][' name_IT' ])
534
+ var names = [datas[' packages' ][key][' name_IT' ], key];
535
+ if (datas[' packages' ][key][' category' ] == ' instrument' ){
536
+ packageList[packageList .length ] = [names, ' instrument' ];
537
+ }
538
+ else if (datas[' packages' ][key][' category' ] == ' animal' ){
539
+ packageList[packageList .length ] = [names, ' animal' ];
540
+ }
541
+ })
542
+ return packageList;
543
+ });
544
+
469
545
export default {
470
546
471
547
components: { sidebar },
@@ -493,6 +569,32 @@ export default {
493
569
this .formdata .append (' file_to_upload' , files[0 ], files[0 ].name );
494
570
495
571
},
572
+
573
+ uploadPackage () {
574
+ let qs = this .$qs
575
+ var pkgName = qs .stringify ({
576
+ ' nameID' : this .fileName ,
577
+ })
578
+
579
+ const config = {
580
+ headers: { ' Content-Type' : ' multipart/form-data' },
581
+ onUploadProgress : progressEvent => {
582
+ this .counter = Math .floor ((progressEvent .loaded * 100 ) / progressEvent .total );
583
+ }
584
+ }
585
+ this .updateStatus = 1
586
+
587
+ this .$axios .post (this .CB + ' /updatePackages' , this .formdata ).then (function (result ) {
588
+ this .uploadCompleted = true ;
589
+ this .uploadInProgress = false ;
590
+ console .dir (result .data );
591
+
592
+ this .updateStatusText = ' Upload completato. Riavvio in corso.'
593
+
594
+ }.bind (this ))
595
+
596
+ },
597
+
496
598
upload () {
497
599
const config = {
498
600
headers: { ' Content-Type' : ' multipart/form-data' },
@@ -512,6 +614,20 @@ export default {
512
614
}.bind (this ))
513
615
514
616
},
617
+
618
+ /* readTextFile(file, callback) {
619
+ var rawFile = new XMLHttpRequest();
620
+ rawFile.overrideMimeType("application/json");
621
+ rawFile.open("GET", file, true);
622
+ rawFile.onreadystatechange = function() {
623
+ if (rawFile.readyState === 4 && rawFile.status == "200") {
624
+ callback(rawFile.responseText);
625
+ }
626
+ }
627
+
628
+ rawFile.send(null);
629
+ },
630
+ */
515
631
restoreConfig () {
516
632
let axios = this .$axios
517
633
let CB = this .CB
@@ -577,7 +693,7 @@ export default {
577
693
this .cb .status = response .data
578
694
this .cb .logs .log = response .data .log
579
695
}.bind (this ))
580
- axios .get (this .CB + ' /info' )
696
+ axioks .get (this .CB + ' /info' )
581
697
.then (function (response ) {
582
698
this .cb .info = response .data
583
699
}.bind (this ))
@@ -586,7 +702,7 @@ export default {
586
702
let axios = this .$axios
587
703
let CB = this .CB
588
704
let status = this .status
589
- axios .get (CB + ' /status' )
705
+ axios .kkget (CB + ' /status' )
590
706
.then (function (response ) {
591
707
if (this .status == 0 && response .status ) {
592
708
this .snackText = ' CoderBot è tornato online'
@@ -610,6 +726,22 @@ export default {
610
726
this .status = 0
611
727
}.bind (this ))
612
728
},
729
+
730
+ deletePkg (pkgNameID ){
731
+ let CBv1 = this .CBv1
732
+ let axios = this .$axios
733
+ let qs = this .$qs
734
+ var pkgName = qs .stringify ({
735
+ ' nameID' : pkgNameID,
736
+ })
737
+ axios .post (CBv1 + ' /deletepkg' , pkgName)
738
+ .then (function () {
739
+ console .log (' Pacchetto rimosso' )
740
+ this .snackText = " Pacchetto rimosso"
741
+ this .snackbar = true
742
+ }.bind (this ))
743
+ },
744
+
613
745
prepopulate : function () {
614
746
let axios = this .$axios
615
747
let settings = this .settings
@@ -687,8 +819,28 @@ export default {
687
819
data .ctrlTurnSpeed = remoteConfig .ctrl_tr_speed
688
820
689
821
data .audioLevel = remoteConfig .audio_volume_level
822
+ // data.packagesInstalled = remoteConfig.packageList
823
+ data .packagesInstalled = remoteConfig .packages_installed
824
+ /* this.readTextFile( "./static/music_package.json" , function(text){
825
+ var datas = JSON.parse(text);
826
+ Object.keys(datas['packages']).forEach(function(key) {
827
+ console.table('Key : ' + key + ', Value : ' + datas['packages'][key])
828
+ console.table('Key : name_IT, Value : ' + datas['packages'][key]['name_IT'])
829
+ var names = [datas['packages'][key]['name_IT'], key];
830
+
831
+ if (datas['packages'][key]['category'] == 'instrument'){
832
+ instrumentlist[instrumentlist.length] = names;
833
+ }
834
+ else if (datas['packages'][key]['category'] == 'animal'){
835
+ animalist[animalist.length] = names;
836
+ }
837
+ })
838
+ return instrumentlist;
839
+ })
840
+ */
690
841
}.bind (this ))
691
842
},
843
+
692
844
save : function () {
693
845
let qs = this .$qs
694
846
let selectedTab = this .tab
@@ -738,6 +890,7 @@ export default {
738
890
' ctrl_tr_speed' : data .ctrlTurnSpeed ,
739
891
740
892
' audio_volume_level' : data .audioLevel ,
893
+ ' packages_installed' : data .packagesInstalled
741
894
})
742
895
axios .post (CBv1 + ' /config' , legacySettings)
743
896
.then (function () {
@@ -784,7 +937,7 @@ export default {
784
937
wifiPsw: null ,
785
938
786
939
audioLevel: null ,
787
-
940
+ packagesInstalled : packageList,
788
941
moveFwdElapse: null ,
789
942
moveFwdSpeed: null ,
790
943
moveTurnElapse: null ,
@@ -834,7 +987,7 @@ export default {
834
987
drawer: null ,
835
988
tab: null ,
836
989
// tabs: ['Generali', 'Rete', 'Movimento', 'Suoni', 'Avanzate'],
837
- tabs: [' Generali' , ' Movimento' , ' Suoni' , ' Avanzate' , ' Test' ,' Audio' ]
990
+ tabs: [' Generali' , ' Movimento' , ' Suoni' , ' Avanzate' , ' Test' ,' Audio' , ' Gestione Pacchetti ' ]
838
991
}
839
992
}
840
993
}
0 commit comments