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

67 lines
3.0 KiB
Vue
Raw Normal View History

<template>
<form-wrapper>
2020-03-11 16:32:19 +01:00
<div class="tags has-addons">
<span class="tag is-dark">2FAuth</span>
<span class="tag is-info">v{{ $root.appVersion }}</span>
2020-03-11 16:32:19 +01:00
</div>
2020-02-28 12:05:27 +01:00
<form @submit.prevent="handleSubmit" @change="handleSubmit" @keydown="form.onKeydown($event)">
<form-select :options="langs" :form="form" fieldName="lang" :label="$t('settings.forms.language.label')" :help="$t('settings.forms.language.help')" />
<form-select :options="layouts" :form="form" fieldName="displayMode" :label="$t('settings.forms.display_mode.label')" :help="$t('settings.forms.display_mode.help')" />
2020-02-27 16:58:04 +01:00
<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-switch :form="form" fieldName="closeTokenOnCopy" :label="$t('settings.forms.close_token_on_copy.label')" :help="$t('settings.forms.close_token_on_copy.help')" />
2020-04-02 10:43:05 +02:00
<form-switch :form="form" fieldName="useBasicQrcodeReader" :label="$t('settings.forms.use_basic_qrcode_reader.label')" :help="$t('settings.forms.use_basic_qrcode_reader.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,
showTokenAsDot: this.$root.appSettings.showTokenAsDot,
closeTokenOnCopy: this.$root.appSettings.closeTokenOnCopy,
2020-04-02 10:43:05 +02:00
useBasicQrcodeReader: this.$root.appSettings.useBasicQrcodeReader,
displayMode: this.$root.appSettings.displayMode,
}),
langs: [
2020-02-27 09:37:23 +01:00
{ text: this.$t('languages.en'), value: 'en' },
{ text: this.$t('languages.fr'), value: 'fr' },
],
layouts: [
{ text: this.$t('settings.forms.grid'), value: 'grid' },
{ text: this.$t('settings.forms.list'), value: 'list' },
]
}
},
methods : {
handleSubmit(e) {
e.preventDefault()
this.form.post('/api/settings/options', {returnError: true})
.then(response => {
2020-02-28 12:05:27 +01:00
this.$notify({ type: 'is-success', text: response.data.message })
2020-02-28 12:05:27 +01:00
if(response.data.settings.lang !== this.$root.$i18n.locale) {
this.$router.go()
}
2020-02-28 22:21:48 +01:00
else {
this.$root.appSettings = response.data.settings
2020-02-28 22:21:48 +01:00
}
})
.catch(error => {
2020-02-28 22:21:48 +01:00
this.$notify({ type: 'is-danger', text: error.response.data.message })
});
}
},
}
</script>