406
406
<v-radio v-bind:label =" $t('message.settings_network_mode_client')" value =" client" ></v-radio >
407
407
<v-radio v-bind:label =" $t('message.settings_network_mode_ap')" value =" ap" >
408
408
</v-radio >
409
- <v-text-field v-model =" settings.wifiSSID" v-bind:label =" $t('message.settings_network_ssid')" ></v-text-field >
410
- <v-text-field v-model =" settings.wifiPsw" v-bind:label =" $t('message.settings_network_password')" ></v-text-field >
411
409
</v-radio-group >
410
+ <div v-if =" settings.wifiMode=='client'" >
411
+ <v-select
412
+ :disabled =" settings.wifiMode!='client'"
413
+ v-model =" settings.wifiSSID"
414
+ :items =" networks"
415
+ item-title =" ssid"
416
+ item-value =" ssid"
417
+ v-bind:label =" $t('message.settings_network_ssid')"
418
+ single-line
419
+ >
420
+ </v-select >
421
+ <v-text-field
422
+ :disabled =" settings.wifiMode!='client'"
423
+ v-model =" settings.wifiPsw"
424
+ :append-icon =" wifi_pwd_show ? 'mdi-eye' : 'mdi-eye-off'"
425
+ :type =" wifi_pwd_show ? 'text' : 'password'"
426
+ @click:append =" wifi_pwd_show = !wifi_pwd_show"
427
+ v-bind:label =" $t('message.settings_network_password')" ></v-text-field >
428
+ </div >
412
429
<!-- v-card-actions>
413
430
<v-btn color="primary" @click.stop="dialog = true" block>Salva</v-btn>
414
431
<v-dialog v-model="dialog" max-width="290">
@@ -733,6 +750,18 @@ export default {
733
750
setup () {
734
751
return {
735
752
v$: useVuelidate (),
753
+ cameraExposureModes: [
754
+ { text: ' Auto' , key: ' auto' },
755
+ { text: ' Sports' , key: ' sports' },
756
+ { text: ' Night' , key: ' night' },
757
+ { text: ' Fixed FPS' , key: ' fixedfps' },
758
+ { text: ' Anti shake' , key: ' antishake' },
759
+ { text: ' Very long' , key: ' verylong' }
760
+ ],
761
+ hardware_version_items: [
762
+ { key: ' 4' , text: ' 4.0 (legacy)' },
763
+ { key: ' 5' , text: ' 5.0 (latest)' }
764
+ ],
736
765
};
737
766
},
738
767
mounted () {
@@ -747,6 +776,9 @@ export default {
747
776
this .cb .info = this .$store .getters .info ;
748
777
this .cb .status = this .$store .getters .status ;
749
778
this .adminPassword_dialog = this .settings .adminPassword != null && this .settings .adminPassword != ' ' ;
779
+ this .$wifi_connect .networks ().then ((result ) => {
780
+ this .networks = result .data ;
781
+ });
750
782
},
751
783
beforeRouteLeave (to , from , next ) {
752
784
if (this .v$ .$anyDirty ) {
@@ -781,7 +813,6 @@ export default {
781
813
this .uploadCompleted = true ;
782
814
this .uploadInProgress = false ;
783
815
this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_1' );
784
- console .dir (result .data );
785
816
if (this .updateStatus == 2 ) {
786
817
this .updateStatusText = this .$i18n .t (' message.settings_music_packages_text_2' );
787
818
}
@@ -803,7 +834,6 @@ export default {
803
834
this .$$coderbot .updateFromPackage (this .formdata , config).then ((result ) => {
804
835
this .uploadCompleted = true ;
805
836
this .uploadInProgress = false ;
806
- console .dir (result .data );
807
837
this .updateStatusText = this .$i18n .t (' message.settings_packages_text_1' );
808
838
});
809
839
},
@@ -910,7 +940,6 @@ export default {
910
940
if (this .v$ .$invalid ) {
911
941
this .snackText = this .$i18n .t (' message.settings_errors' );
912
942
this .snackbar = true ;
913
- console .log (this .v$ );
914
943
} else {
915
944
/* eslint-disable func-names, object-shorthand, prefer-arrow-callback */
916
945
const needRestart = this .needRestart ();
@@ -930,25 +959,24 @@ export default {
930
959
console .log (' set dirty false' );
931
960
});
932
961
if (this .v$ .settings .wifiMode .$dirty || this .v$ .settings .wifiSSID .$dirty || this .v$ .settings .wifiPsw .$dirty ) {
933
- this .$coderbot .saveWifiParams (this .settings .wifiMode , this .settings .wifiSSID , this .settings .wifiPsw )
934
- .then (() => {
935
- console .log (' Sent' );
936
- this .snackText = this .$i18n .t (' message.settings_network_updated' );
937
- this .snackbar = true ;
938
- });
962
+ if (this .settings .wifiMode == " client" ) {
963
+ this .$wifi_connect .connect (this .settings .wifiSSID , " " , this .settings .wifiPsw )
964
+ .then (() => {
965
+ console .log (' connect Sent' );
966
+ this .snackText = this .$i18n .t (' message.settings_network_updated' );
967
+ this .snackbar = true ;
968
+ });
969
+ } else {
970
+ this .$wifi_connect .disconnect (this .settings .wifiSSID )
971
+ .then (() => {
972
+ console .log (' disconnect Sent' );
973
+ this .snackText = this .$i18n .t (' message.settings_network_updated' );
974
+ this .snackbar = true ;
975
+ });
976
+ }
939
977
}
940
978
}
941
979
},
942
- saveWifi () {
943
- // Send post with URL encoded parameters
944
- this .$coderbot .saveWifiParams (this .settings .wifiMode , this .settings .wifiSSID , this .settings .wifiPsw )
945
- .then (() => {
946
- console .log (' Sent' );
947
- this .snackText = this .$i18n .t (' message.settings_network_updated' );
948
- this .snackbar = true ;
949
- });
950
- console .log (` save wifi config - ssid: ${ this .settings .wifiSSID } pwd: ${ this .settings .wifiPsw } ` );
951
- },
952
980
toggleSidebar () {
953
981
const currentStatus = this .$store .getters .drawerStatus ;
954
982
this .$store .commit (' toggleDrawer' , ! currentStatus);
@@ -1075,18 +1103,8 @@ export default {
1075
1103
this .$i18n .t (' message.settings_tabs_audio' ),
1076
1104
this .$i18n .t (' message.settings_tabs_music_packages' )
1077
1105
],
1078
- cameraExposureModes: [
1079
- { text: ' Auto' , key: ' auto' },
1080
- { text: ' Sports' , key: ' sports' },
1081
- { text: ' Night' , key: ' night' },
1082
- { text: ' Fixed FPS' , key: ' fixedfps' },
1083
- { text: ' Anti shake' , key: ' antishake' },
1084
- { text: ' Very long' , key: ' verylong' }
1085
- ],
1086
- hardware_version_items: [
1087
- { key: ' 4' , text: ' 4.0 (legacy)' },
1088
- { key: ' 5' , text: ' 5.0 (latest)' }
1089
- ]
1106
+ networks: [],
1107
+ wifi_pwd_show: false ,
1090
1108
};
1091
1109
},
1092
1110
validations () {
0 commit comments