mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-14 07:48:37 +02:00
Update Vue front-end according to the new API definition and paths
This commit is contained in:
@ -1,37 +1,38 @@
|
||||
<template>
|
||||
<form-wrapper>
|
||||
<form @submit.prevent="handleSubmit" @change="handleSubmit" @keydown="form.onKeydown($event)">
|
||||
<!-- <form @submit.prevent="handleSubmit" @change="handleSubmit" @keydown="form.onKeydown($event)"> -->
|
||||
<form>
|
||||
<h4 class="title is-4">{{ $t('settings.general') }}</h4>
|
||||
<!-- Language -->
|
||||
<form-select :options="langs" :form="form" fieldName="lang" :label="$t('settings.forms.language.label')" :help="$t('settings.forms.language.help')" />
|
||||
<form-select v-on:lang="saveSetting('lang', $event)" :options="langs" :form="form" fieldName="lang" :label="$t('settings.forms.language.label')" :help="$t('settings.forms.language.help')" />
|
||||
<!-- display mode -->
|
||||
<form-toggle :choices="layouts" :form="form" fieldName="displayMode" :label="$t('settings.forms.display_mode.label')" :help="$t('settings.forms.display_mode.help')" />
|
||||
<form-toggle v-on:displayMode="saveSetting('displayMode', $event)" :choices="layouts" :form="form" fieldName="displayMode" :label="$t('settings.forms.display_mode.label')" :help="$t('settings.forms.display_mode.help')" />
|
||||
<!-- show icon -->
|
||||
<form-checkbox :form="form" fieldName="showAccountsIcons" :label="$t('settings.forms.show_accounts_icons.label')" :help="$t('settings.forms.show_accounts_icons.help')" />
|
||||
<form-checkbox v-on:showAccountsIcons="saveSetting('showAccountsIcons', $event)" :form="form" fieldName="showAccountsIcons" :label="$t('settings.forms.show_accounts_icons.label')" :help="$t('settings.forms.show_accounts_icons.help')" />
|
||||
|
||||
<h4 class="title is-4 pt-4">{{ $t('groups.groups') }}</h4>
|
||||
<!-- default group -->
|
||||
<form-select :options="groups" :form="form" fieldName="defaultGroup" :label="$t('settings.forms.default_group.label')" :help="$t('settings.forms.default_group.help')" />
|
||||
<form-select v-on:defaultGroup="saveSetting('defaultGroup', $event)" :options="groups" :form="form" fieldName="defaultGroup" :label="$t('settings.forms.default_group.label')" :help="$t('settings.forms.default_group.help')" />
|
||||
<!-- retain active group -->
|
||||
<form-checkbox :form="form" fieldName="rememberActiveGroup" :label="$t('settings.forms.remember_active_group.label')" :help="$t('settings.forms.remember_active_group.help')" />
|
||||
<form-checkbox v-on:rememberActiveGroup="saveSetting('rememberActiveGroup', $event)" :form="form" fieldName="rememberActiveGroup" :label="$t('settings.forms.remember_active_group.label')" :help="$t('settings.forms.remember_active_group.help')" />
|
||||
|
||||
<h4 class="title is-4 pt-4">{{ $t('settings.security') }}</h4>
|
||||
<!-- auto lock -->
|
||||
<form-select :options="kickUserAfters" :form="form" fieldName="kickUserAfter" :label="$t('settings.forms.auto_lock.label')" :help="$t('settings.forms.auto_lock.help')" />
|
||||
<form-select v-on:kickUserAfter="saveSetting('kickUserAfter', $event)" :options="kickUserAfters" :form="form" fieldName="kickUserAfter" :label="$t('settings.forms.auto_lock.label')" :help="$t('settings.forms.auto_lock.help')" />
|
||||
<!-- protect db -->
|
||||
<form-checkbox :form="form" fieldName="useEncryption" :label="$t('settings.forms.use_encryption.label')" :help="$t('settings.forms.use_encryption.help')" />
|
||||
<!-- token as dot -->
|
||||
<form-checkbox :form="form" fieldName="showTokenAsDot" :label="$t('settings.forms.show_token_as_dot.label')" :help="$t('settings.forms.show_token_as_dot.help')" />
|
||||
<!-- close token on copy -->
|
||||
<form-checkbox :form="form" fieldName="closeTokenOnCopy" :label="$t('settings.forms.close_token_on_copy.label')" :help="$t('settings.forms.close_token_on_copy.help')" />
|
||||
<form-checkbox v-on:useEncryption="saveSetting('useEncryption', $event)" :form="form" fieldName="useEncryption" :label="$t('settings.forms.use_encryption.label')" :help="$t('settings.forms.use_encryption.help')" />
|
||||
<!-- otp as dot -->
|
||||
<form-checkbox v-on:showOtpAsDot="saveSetting('showOtpAsDot', $event)" :form="form" fieldName="showOtpAsDot" :label="$t('settings.forms.show_otp_as_dot.label')" :help="$t('settings.forms.show_otp_as_dot.help')" />
|
||||
<!-- close otp on copy -->
|
||||
<form-checkbox v-on:closeOtpOnCopy="saveSetting('closeOtpOnCopy', $event)" :form="form" fieldName="closeOtpOnCopy" :label="$t('settings.forms.close_otp_on_copy.label')" :help="$t('settings.forms.close_otp_on_copy.help')" />
|
||||
|
||||
<h4 class="title is-4 pt-4">{{ $t('settings.data_input') }}</h4>
|
||||
<!-- basic qrcode -->
|
||||
<form-checkbox :form="form" fieldName="useBasicQrcodeReader" :label="$t('settings.forms.use_basic_qrcode_reader.label')" :help="$t('settings.forms.use_basic_qrcode_reader.help')" />
|
||||
<form-checkbox v-on:useBasicQrcodeReader="saveSetting('useBasicQrcodeReader', $event)" :form="form" fieldName="useBasicQrcodeReader" :label="$t('settings.forms.use_basic_qrcode_reader.label')" :help="$t('settings.forms.use_basic_qrcode_reader.help')" />
|
||||
<!-- direct capture -->
|
||||
<form-checkbox :form="form" fieldName="useDirectCapture" :label="$t('settings.forms.useDirectCapture.label')" :help="$t('settings.forms.useDirectCapture.help')" />
|
||||
<form-checkbox v-on:useDirectCapture="saveSetting('useDirectCapture', $event)" :form="form" fieldName="useDirectCapture" :label="$t('settings.forms.useDirectCapture.label')" :help="$t('settings.forms.useDirectCapture.help')" />
|
||||
<!-- default capture mode -->
|
||||
<form-select :options="captureModes" :form="form" fieldName="defaultCaptureMode" :label="$t('settings.forms.defaultCaptureMode.label')" :help="$t('settings.forms.defaultCaptureMode.help')" />
|
||||
<form-select v-on:defaultCaptureMode="saveSetting('defaultCaptureMode', $event)" :options="captureModes" :form="form" fieldName="defaultCaptureMode" :label="$t('settings.forms.defaultCaptureMode.label')" :help="$t('settings.forms.defaultCaptureMode.help')" />
|
||||
</form>
|
||||
</form-wrapper>
|
||||
</template>
|
||||
@ -61,8 +62,8 @@
|
||||
return {
|
||||
form: new Form({
|
||||
lang: '',
|
||||
showTokenAsDot: null,
|
||||
closeTokenOnCopy: null,
|
||||
showOtpAsDot: null,
|
||||
closeOtpOnCopy: null,
|
||||
useBasicQrcodeReader: null,
|
||||
showAccountsIcons: null,
|
||||
displayMode: '',
|
||||
@ -84,7 +85,7 @@
|
||||
],
|
||||
kickUserAfters: [
|
||||
{ text: this.$t('settings.forms.never'), value: '0' },
|
||||
{ text: this.$t('settings.forms.on_token_copy'), value: '-1' },
|
||||
{ text: this.$t('settings.forms.on_otp_copy'), value: '-1' },
|
||||
{ text: this.$t('settings.forms.1_minutes'), value: '1' },
|
||||
{ text: this.$t('settings.forms.5_minutes'), value: '5' },
|
||||
{ text: this.$t('settings.forms.10_minutes'), value: '10' },
|
||||
@ -105,28 +106,46 @@
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.form.fill(this.$root.appSettings)
|
||||
async mounted() {
|
||||
const { data } = await this.form.get('/api/settings')
|
||||
|
||||
this.form.fillWithKeyValueObject(data)
|
||||
this.form.lang = this.$root.$i18n.locale
|
||||
this.form.setOriginal()
|
||||
this.fetchGroups()
|
||||
},
|
||||
|
||||
methods : {
|
||||
handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
console.log(e)
|
||||
|
||||
this.form.post('/api/settings/options', {returnError: false})
|
||||
.then(response => {
|
||||
// this.form.post('/api/settings/options', {returnError: false})
|
||||
// .then(response => {
|
||||
|
||||
this.$notify({ type: 'is-success', text: response.data.message })
|
||||
// this.$notify({ type: 'is-success', text: response.data.message })
|
||||
|
||||
if(response.data.settings.lang !== this.$root.$i18n.locale) {
|
||||
// if(response.data.settings.lang !== this.$root.$i18n.locale) {
|
||||
// this.$router.go()
|
||||
// }
|
||||
// else {
|
||||
// this.$root.appSettings = response.data.settings
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
saveSetting(settingName, event) {
|
||||
|
||||
this.axios.put('/api/settings/' + settingName, { value: event }).then(response => {
|
||||
this.$notify({ type: 'is-success', text: this.$t('settings.forms.setting_saved') })
|
||||
|
||||
if(settingName === 'lang' && response.data.value !== this.$root.$i18n.locale) {
|
||||
this.$router.go()
|
||||
}
|
||||
else {
|
||||
this.$root.appSettings = response.data.settings
|
||||
this.$root.appSettings[response.data.key] = response.data.value
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
fetchGroups() {
|
||||
|
Reference in New Issue
Block a user