Skip to content

Commit

Permalink
close #20
Browse files Browse the repository at this point in the history
  • Loading branch information
previ committed Jun 28, 2022
1 parent 89a16f5 commit e0c2e6e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/common/coderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class CoderBot {
data.ctrlTurnElapse = remoteConfig.ctrl_tr_elapse;
data.ctrlTurnSpeed = remoteConfig.ctrl_tr_speed;
data.audioLevel = remoteConfig.audio_volume_level;
data.adminPassword = remoteConfig.admin_password;
this.$store.commit('setSettings', data);
}

Expand Down Expand Up @@ -214,6 +215,7 @@ class CoderBot {
ctrl_tr_elapse: settings.ctrlTurnElapse,
ctrl_tr_speed: settings.ctrlTurnSpeed,
audio_volume_level: settings.audioLevel,
admin_password: settings.adminPassword,
});
this.$store.commit('setSettings', settings);
return this.$axios.post(`${this.CBv1}/config`, legacySettings);
Expand Down
42 changes: 40 additions & 2 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
</v-dialog>
</div>
</v-card>
<br>
<h3 class="text-xs-left"> {{ $t('message.settings_actions_update_title') }} </h3>
<v-card>
<div class="cardContent">
Expand All @@ -133,7 +132,17 @@
</template>
</div>
</v-card>
<br/><br/>
<br><br>
<h3 class="text-xs-left">{{ $t('message.settings_admin_password_title') }}</h3>
<v-card>
<div class="cardContent">
<v-text-field v-model="settings.adminPassword"
v-bind:label="$t('message.settings_admin_password')"
@input="$v.settings.motorMode.$touch"
/>
</div>
</v-card>
</v-flex>
</v-layout>
</v-container>
Expand Down Expand Up @@ -621,6 +630,26 @@
</v-tab-item>
</v-tabs-items>
</v-main>
<!-- Admin password dialog -->
<v-dialog v-model="adminPassword_dialog" max-width="290" persistent>
<v-card>
<v-card-title class="headline">{{ $t("message.settings_admin_password_verify_title") }}</v-card-title>
<v-card-text>
{{ $t("message.settings_admin_password_verify") }}
<v-text-field v-model="adminPassword"
/>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" text="text" @click="adminPassword_dialog=false; $router.go(-1);">
{{ $t("message.cancel") }}
</v-btn>
<v-btn color="green darken-1" text="text" @click="checkAdminPassword()">
{{ $t("message.ok") }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- Confirm exit dialog -->
<v-dialog v-model="confirm_exit_dialog" max-width="290">
<v-card>
Expand Down Expand Up @@ -672,6 +701,7 @@ export default {
this.settings.cnnModels = this.$store.getters.cnnModels;
this.cb.info = this.$store.getters.info;
this.cb.status = this.$store.getters.status;
this.adminPassword_dialog = this.settings.adminPassword != null && this.settings.adminPassword != '';
},
beforeRouteLeave(to, from, next) {
if (this.$v.$anyDirty) {
Expand Down Expand Up @@ -911,6 +941,11 @@ export default {
startupProgram: true,
progLevel: false
};
},
checkAdminPassword() {
if (this.settings.adminPassword == this.adminPassword) {
this.adminPassword_dialog = false;
}
}
},
data() {
Expand Down Expand Up @@ -969,6 +1004,7 @@ export default {
shutterSound: null,
startupProgram: null,
progLevel: null,
adminPassword: null,
},
cb: {
logs: {
Expand Down Expand Up @@ -1000,6 +1036,8 @@ export default {
dirty: false,
confirm_exit_dialog: null,
router_next: null,
adminPassword: null,
adminPassword_dialog: true,
};
},
validations() {
Expand Down Expand Up @@ -1129,7 +1167,7 @@ export default {
}
},
};
}
},
};
</script>
<style scoped>
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@
"settings_toolbax_advanced": "Avanzate",
"settings_confirm_exit_text": "Le modifiche apportate andranno perse, comfermi di voler cambiare pagina?",
"settings_restart_needed": "Per rendere effettive le modifiche, riavviare CdoerBot.",
"settings_admin_password_verify_title": "Accesso riservato",
"settings_admin_password_verify": "Inserire la password di amministrazione.",
"settings_admin_password_title": "Password di amministrazione.",
"settings_admin_password": "passoword",
"validation_integer": "Inserire un numero intero (1234)",
"validation_decimal": "Inserire un numero decimale (12.34)",
"validation_integer_positive": "Inserire un numero intero maggiore o uguale a 0",
Expand Down
5 changes: 3 additions & 2 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ const routes = [
}
},
{
name: 'gallery',
name: 'settings',
path: '/settings',
component: settings,
meta: {
title: `CoderBot - ${i18n.t('message.settings')}`,
}
},
},
{
name: 'gallery',
path: '/gallery',
component: gallery,
meta: {
Expand Down

0 comments on commit e0c2e6e

Please sign in to comment.