2FAuth/resources/js/views/settings/Options.vue

56 lines
1.8 KiB
Vue
Raw Normal View History

<template>
2020-02-13 08:50:20 +01:00
<form-wrapper :fail="fail" :success="success">
2020-02-28 12:05:27 +01:00
<form @submit.prevent="handleSubmit" @change="handleSubmit" @keydown="form.onKeydown($event)">
2020-02-27 16:58:04 +01:00
<form-select :options="options" :form="form" fieldName="lang" :label="$t('settings.forms.language.label')" :help="$t('settings.forms.language.help')" />
<form-switch :form="form" fieldName="showTokenAsDot" :label="$t('settings.forms.show_token_as_dot.label')" :help="$t('settings.forms.show_token_as_dot.help')" />
</form>
</form-wrapper>
</template>
<script>
import Form from './../../components/Form'
export default {
data(){
return {
success: '',
fail: '',
form: new Form({
lang: this.$root.$i18n.locale,
2020-02-27 16:58:04 +01:00
showTokenAsDot: Boolean(Number(appSettings.showTokenAsDot)),
}),
options: [
2020-02-27 09:37:23 +01:00
{ text: this.$t('languages.en'), value: 'en' },
{ text: this.$t('languages.fr'), value: 'fr' },
]
}
},
methods : {
handleSubmit(e) {
e.preventDefault()
this.fail = ''
this.success = ''
this.form.post('/api/settings/options', {returnError: true})
.then(response => {
2020-02-28 12:05:27 +01:00
this.success = response.data.message
if(response.data.settings.lang !== this.$root.$i18n.locale) {
this.$router.go()
}
2020-02-28 22:21:48 +01:00
else {
appSettings = response.data.settings
}
})
.catch(error => {
2020-02-28 22:21:48 +01:00
2020-02-28 12:05:27 +01:00
this.fail = error.response.data.message
});
}
},
}
</script>