628
628
<v-row row wrap align-center >
629
629
<v-col >
630
630
<v-card >
631
- <v-card-title >
632
- {{ $t('message.settings_component_test_title') }}
633
- </v-card-title >
631
+ <v-card-title >
632
+ {{ $t('message.settings_component_test_title') }}
633
+ </v-card-title >
634
634
<v-card-text >
635
- <div id =' test_array' >
636
- <!-- SONAR -->
637
- <v-row row wrap justify-center >
638
- <!-- switch -->
639
- <v-col xs12 offset-md2 md5 >
640
- <v-switch v-bind:label =" $t('message.settings_component_test_sonar')" value =" sonar" v-model =" checkedTests" color =" orange" ></v-switch >
641
- </v-col >
642
- <!-- button state -->
643
- <v-col xs12 md4 >
644
- <span v-if =" cb.logs != null && cb.logs.test != null && cb.logs.test.sonar != 0" >
645
- <!-- passed -->
646
- <span v-if =" cb.logs.test.sonar == 1" >
647
- <v-btn @click =" runTests" slot =" activator" color =" green" dark >
648
- <v-icon icon =" mdi-check" ></v-icon > {{ $t('message.settings_component_test_passed') }}
649
- </v-btn >
650
- </span >
651
- <!-- failed -->
652
- <span v-else >
653
- <v-btn @click =" runTests" slot =" activator" color =" red" dark >
654
- <v-icon icon =" mdi-exclamation" ></v-icon > {{ $t('message.settings_component_test_failed') }}
655
- </v-btn >
656
- </span >
657
- </span >
658
- <!-- not tested -->
659
- <span v-else >
660
- <v-btn @click =" runTests" slot =" activator" color =" grey" dark >
661
- <v-icon icon =" mdi-help" ></v-icon > {{ $t('message.settings_component_test_not_tested') }}
662
- </v-btn >
663
- </span >
664
- </v-col >
665
- </v-row >
666
- <!-- MOTORS -->
635
+ <div id =' test_array' v-for =" test in tests" >
667
636
<v-row row wrap justify-center >
668
- <!-- switch -->
669
637
<v-col xs12 offset-md2 md5 >
670
- <v-switch v-bind:label =" $t('message.settings_component_test_motors')" value =" motors" v-model =" checkedTests" color =" orange" >
671
- </v-switch >
638
+ <v-switch :label =" test.title" :value =" test.name" v-model =" checkedTests[test.name]" color =" orange" ></v-switch >
672
639
</v-col >
673
- <!-- button state -->
674
640
<v-col xs12 md4 >
675
- <span v-if =" cb.logs != null && cb.logs.test != null && cb.logs.test.motors != 0" >
676
- <!-- passed -->
677
- <span v-if =" cb.logs.test.motors== 1" >
678
- <v-btn @click =" runTests" slot =" activator" color =" green" dark >
679
- <v-icon icon =" mdi-check" ></v-icon > {{ $t('message.settings_component_test_passed') }}
680
- </v-btn >
681
- </span >
682
- <!-- failed -->
683
- <span v-else >
684
- <v-btn @click =" runTests" slot =" activator" color =" red" dark >
685
- <v-icon icon =" mdi-exclamation" ></v-icon > {{ $t('message.settings_component_test_failed') }}
686
- </v-btn >
687
- </span >
688
- </span >
689
- <!-- not tested -->
690
- <span v-else >
691
- <v-btn @click =" runTests" slot =" activator" color =" grey" dark >
692
- <v-icon icon =" mdi-help" ></v-icon > {{ $t('message.settings_component_test_not_tested') }}
693
- </v-btn >
694
- </span >
695
- </v-col >
696
- </v-row >
697
-
698
- <!-- SPEAKER -->
699
- <v-row row wrap justify-center >
700
- <!-- switch -->
701
- <v-col xs12 offset-md2 md5 >
702
- <v-switch v-bind:label =" $t('message.settings_component_test_speaker')" value =" speaker" v-model =" checkedTests" color =" orange" >
703
- </v-switch >
704
- </v-col >
705
- <!-- button state -->
706
- <v-col xs12 md4 >
707
- <span v-if =" cb.logs != null && cb.logs.test != null && cb.logs.test.speaker != 0" >
708
- <!-- passed -->
709
- <span v-if =" cb.logs.test.speaker== 1" >
710
- <v-btn @click =" runTests" slot =" activator" color =" green" dark >
711
- <v-icon icon =" mdi-check" ></v-icon > {{ $t('message.settings_component_test_passed') }}
712
- </v-btn >
713
- </span >
714
- <!-- failed -->
715
- <span v-else >
716
- <v-btn @click =" runTests" slot =" activator" color =" red" dark >
717
- <v-icon icon =" mdi-exclamation" ></v-icon > {{ $t('message.settings_component_test_not_failed') }}
718
- </v-btn >
719
- </span >
720
- </span >
721
- <!-- not tested -->
722
- <span v-else >
723
- <v-btn @click =" runTests" slot =" activator" color =" grey" dark >
724
- <v-icon icon =" mdi-help" ></v-icon > {{ $t('message.settings_component_test_not_tested') }}
725
- </v-btn >
726
- </span >
727
- </v-col >
728
- </v-row >
729
-
730
- <!-- OCR -->
731
- <v-row row wrap justify-center >
732
- <!-- switch -->
733
- <v-col xs12 offset-md2 md5 >
734
- <v-switch v-bind:label =" $t('message.settings_component_test_ocr')" value =" ocr" v-model =" checkedTests" color =" orange" >
735
- </v-switch >
736
- </v-col >
737
- <!-- button state -->
738
- <v-col xs12 md4 >
739
- <span v-if =" cb.logs != null && cb.logs.test != null && cb.logs.test.ocr != 0" >
740
- <!-- passed -->
741
- <span v-if =" cb.logs.test.ocr== 1" >
742
- <v-btn @click =" runTests" slot =" activator" color =" green" dark >
743
- <v-icon icon =" mdi-check" ></v-icon > {{ $t('message.settings_component_test_passed') }}
744
- </v-btn >
745
- </span >
746
- <!-- failed -->
747
- <span v-else >
748
- <v-btn @click =" runTests" slot =" activator" color =" red" dark >
749
- <v-icon icon =" mdi-exclamation" ></v-icon > {{ $t('message.settings_component_test_failed') }}
750
- </v-btn >
751
- </span >
752
- </span >
753
- <!-- not tested -->
754
- <span v-else >
755
- <v-btn @click =" runTests" slot =" activator" color =" grey" dark >
756
- <v-icon icon =" mdi-help" ></v-icon > {{ $t('message.settings_component_test_not_tested') }}
757
- </v-btn >
758
- </span >
641
+ <v-chip slot =" activator" :color =" testStatusColor(test.name)" dark >
642
+ <v-icon icon =" mdi-check" ></v-icon > {{ testStatusLabel(test.name) }}
643
+ </v-chip >
759
644
</v-col >
760
645
</v-row >
761
646
</div >
762
- <br >
763
- <v-card-actions >
764
-
765
- <v-btn v-if =" cb.logs != null && !cb.logs.runningTest" block @click =" runTests" slot =" activator" color =" orange" dark >
766
- <v-icon icon =" mdi-animation-play" ></v-icon > {{ $t('message.settings_component_test_run') }}
767
- </v-btn >
768
- <v-btn v-else block disabled >
769
- <v-icon icon =" mdi-clock-outline" ></v-icon > {{ $t('message.settings_component_test_text_1') }}
770
- </v-btn >
771
- </v-card-actions >
772
647
</v-card-text >
648
+ <v-card-actions >
649
+ <v-btn v-if =" !testsRunning" block @click =" runTests" slot =" activator" color =" orange" dark >
650
+ <v-icon icon =" mdi-animation-play" ></v-icon > {{ $t('message.settings_component_test_run') }}
651
+ </v-btn >
652
+ <v-btn v-else block >
653
+ <v-icon icon =" mdi-clock-outline" ></v-icon > {{ $t('message.settings_component_test_text_1') }}
654
+ </v-btn >
655
+ </v-card-actions >
773
656
</v-card >
774
657
</v-col >
775
658
</v-row >
821
704
{{ $t('message.settings_music_packages_add') }}
822
705
</v-card-title >
823
706
<v-card-text >
824
- <template v-if =" updateStatus == 1 " >
825
- <b >{{ $t('message.settings_music_package_installed') }}</b >
826
- <br >
827
- {{ updateStatusText }}
828
- <v-btn @click =" refresh" color =" error" >{{ $t('message.settings_music_packages_update') }}</v-btn >
829
- </template >
830
- <template v-if =" updateStatus == 2 || updateStatus == 3 " >
831
- <b >{{ $t('message.settings_music_packages_installation_failed') }}</b >
832
- <br >
833
- {{ updateStatusText }}
834
- <v-btn @click =" refresh" color =" error" >{{ $t('message.settings_music_packages_update') }}</v-btn >
835
- </template >
836
707
<template v-if =" updateStatus == 0 " >
837
- <v-text-field label =" $t('message.settings_music_packages_select')" @click =' pickFile' v-model =' fileName'
708
+ <v-text-field : label =" $t('message.settings_music_packages_select')" @click =' pickFile' v-model =' fileName'
838
709
prepend-icon =' attach_file' ></v-text-field >
839
710
<input type =" file" style =" display : none " ref =" file" @change =" onFilePicked" >
840
711
<template v-if =" this .fileObj " >{{ $t('message.settings_music_packages_install_confirm_text') }}<br ></template >
@@ -907,6 +778,7 @@ import useVuelidate from '@vuelidate/core';
907
778
import {
908
779
required , alpha , integer , decimal , between , minValue , maxValue
909
780
} from ' @vuelidate/validators' ;
781
+ import i18n from ' ../i18n' ;
910
782
911
783
import sidebar from ' ./Sidebar.vue' ;
912
784
@@ -964,8 +836,7 @@ export default {
964
836
},
965
837
requirePassword () {
966
838
return this .settings .adminPassword != null && this .settings .adminPassword != ' ' && ! this .passwordVerified ;
967
- }
968
-
839
+ },
969
840
},
970
841
methods: {
971
842
pickFile () {
@@ -981,23 +852,25 @@ export default {
981
852
this .formdata .append (' file_to_upload' , files[0 ], files[0 ].name );
982
853
},
983
854
uploadPackage () {
984
- /*
985
- const qs = this.$qs;
986
- const pkgName = qs.stringify({
987
- nameID: this.fileName,
988
- });
989
- */
990
- this .$coderbot .updatePackages (this .formData ).then ((result ) => {
991
- this .updateStatus = result .data ;
855
+ this .$coderbot .uploadMusicPackage (this .formdata ).then ((result ) => {
856
+ console .log (result);
857
+ this .updateStatus = 0 ;
992
858
this .uploadCompleted = true ;
993
859
this .uploadInProgress = false ;
860
+ this .fileObj = null ;
861
+ this .fileName = null ;
994
862
this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_1' );
995
- if (this .updateStatus == 2 ) {
996
- this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_2' );
997
- }
998
- if (this .updateStatus == 3 ) {
999
- this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_3' );
1000
- }
863
+ this .$coderbot .loadMusicPackages ().then (() => {
864
+ this .musicPackages = this .$store .getters .musicPackages ;
865
+ });
866
+ }).catch ((result ) => {
867
+ console .log (result);
868
+ this .updateStatus = 0 ;
869
+ this .uploadCompleted = true ;
870
+ this .uploadInProgress = false ;
871
+ this .fileObj = null ;
872
+ this .fileName = null ;
873
+ this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_3' );
1001
874
});
1002
875
},
1003
876
upload () {
@@ -1017,27 +890,8 @@ export default {
1017
890
});
1018
891
},
1019
892
refresh () {
1020
- window .location .reload ();
1021
- /*
1022
- readTextFile
1023
- this.musicPackages = packageList
1024
- this.$http.get('vue/index.html#/settings').then((results) => {
1025
- console.log(results.data.data);
1026
- }, (results) => {
1027
- console.log('ERROR');
1028
- console.log(results);
1029
- });
1030
- readTextFile(file, callback) {
1031
- var rawFile = new XMLHttpRequest();
1032
- rawFile.overrideMimeType("application/json");
1033
- rawFile.open("GET", file, true);
1034
- rawFile.onreadystatechange = function() {
1035
- if (rawFile.readyState === 4 && rawFile.status == "200") {
1036
- callback(rawFile.responseText);
1037
- }
1038
- }
1039
- rawFile.send(null);
1040
- */
893
+ this .$coderbot .loadMusicPackages ();
894
+ this .musicPackages = this .$store .getters .musicPackages ;
1041
895
},
1042
896
pollWifiStatus () {
1043
897
this .$wifi_connect .status ().then ((result ) => {
@@ -1058,12 +912,14 @@ export default {
1058
912
});
1059
913
},
1060
914
runTests () {
1061
- this .cb .logs .runningTest = true ;
1062
- this .$coderbot .test (this .checkedTests ).then ((response ) => {
1063
- this .cb .logs .test = response .data ;
915
+ this .runningTest = true ;
916
+ let tests = Object .values (this .checkedTests );
917
+ this .$coderbot .test (tests).then ((response ) => {
918
+ console .log (response .data );
919
+ this .testResults = response .data ;
1064
920
this .snackText = ' Running tests' ;
1065
921
this .snackbar = true ;
1066
- this .cb . logs . runningTest = false ;
922
+ this .testsRunning = false ;
1067
923
});
1068
924
},
1069
925
reset () {
@@ -1093,6 +949,9 @@ export default {
1093
949
console .log (' Pacchetto rimosso' );
1094
950
this .snackText = this .$i18n .t (' message.settings_music_package_removed' );
1095
951
this .snackbar = true ;
952
+ this .$coderbot .loadMusicPackages ().then (() => {
953
+ this .musicPackages = this .$store .getters .musicPackages ;
954
+ });
1096
955
});
1097
956
},
1098
957
save () {
@@ -1141,6 +1000,26 @@ export default {
1141
1000
}
1142
1001
}
1143
1002
},
1003
+ testStatusColor (name ) {
1004
+ switch (this .testResults [name]) {
1005
+ case 1 :
1006
+ return " green" ;
1007
+ case - 1 :
1008
+ return " red" ;
1009
+ case 0 :
1010
+ return " default" ;
1011
+ }
1012
+ },
1013
+ testStatusLabel (name ) {
1014
+ switch (this .testResults [name]) {
1015
+ case 1 :
1016
+ return this .$i18n .t (' message.settings_component_test_passed' );
1017
+ case - 1 :
1018
+ return this .$i18n .t (' message.settings_component_test_failed' );
1019
+ case 0 :
1020
+ return this .$i18n .t (' message.settings_component_test_not_tested' );
1021
+ }
1022
+ },
1144
1023
toggleSidebar () {
1145
1024
const currentStatus = this .$store .getters .drawerStatus ;
1146
1025
this .$store .commit (' toggleDrawer' , ! currentStatus);
@@ -1264,6 +1143,7 @@ export default {
1264
1143
cb: {
1265
1144
info: {},
1266
1145
status: {},
1146
+ logs: {},
1267
1147
},
1268
1148
drawer: null ,
1269
1149
tab: null ,
@@ -1284,6 +1164,19 @@ export default {
1284
1164
this .$i18n .t (' message.settings_tabs_audio' ),
1285
1165
this .$i18n .t (' message.settings_tabs_music_packages' )
1286
1166
],
1167
+ tests: [
1168
+ { name: " sonar" , title: this .$i18n .t (' message.settings_component_test_sonar' ) },
1169
+ { name: " motors" , title: this .$i18n .t (' message.settings_component_test_motors' ) },
1170
+ { name: " speaker" , title: this .$i18n .t (' message.settings_component_test_speaker' ) },
1171
+ { name: " OCR" , title: this .$i18n .t (' message.settings_component_test_ocr' ) },
1172
+ ],
1173
+ testResults: {
1174
+ sonar: null ,
1175
+ motors: null ,
1176
+ speaker: null ,
1177
+ OCR : null ,
1178
+ },
1179
+ testsRunning: false ,
1287
1180
networks: [],
1288
1181
wifi_status: null ,
1289
1182
wifi_pwd_show: false ,
0 commit comments