|
@@ -17,6 +17,19 @@
|
|
const infos = ref()
|
|
const infos = ref()
|
|
const listInfos = ref(null)
|
|
const listInfos = ref(null)
|
|
const isSendingTestEmail = ref(false)
|
|
const isSendingTestEmail = ref(false)
|
|
|
|
+ const fieldErrors = ref({
|
|
|
|
+ restrictList: null,
|
|
|
|
+ restrictRule: null,
|
|
|
|
+ })
|
|
|
|
+ const _settings = ref({
|
|
|
|
+ checkForUpdate: appSettings.checkForUpdate,
|
|
|
|
+ useEncryption: appSettings.useEncryption,
|
|
|
|
+ restrictRegistration: appSettings.restrictRegistration,
|
|
|
|
+ restrictList: appSettings.restrictList,
|
|
|
|
+ restrictRule: appSettings.restrictRule,
|
|
|
|
+ disableRegistration: appSettings.disableRegistration,
|
|
|
|
+ enableSso: appSettings.enableSso,
|
|
|
|
+ })
|
|
|
|
|
|
/**
|
|
/**
|
|
* Saves a setting on the backend
|
|
* Saves a setting on the backend
|
|
@@ -24,9 +37,46 @@
|
|
* @param {any} value
|
|
* @param {any} value
|
|
*/
|
|
*/
|
|
function saveSetting(setting, value) {
|
|
function saveSetting(setting, value) {
|
|
|
|
+ fieldErrors.value[setting] = null
|
|
|
|
+
|
|
appSettingService.update(setting, value).then(response => {
|
|
appSettingService.update(setting, value).then(response => {
|
|
|
|
+ appSettings[setting] = value
|
|
useNotifyStore().success({ type: 'is-success', text: trans('settings.forms.setting_saved') })
|
|
useNotifyStore().success({ type: 'is-success', text: trans('settings.forms.setting_saved') })
|
|
})
|
|
})
|
|
|
|
+ .catch(error => {
|
|
|
|
+ if( error.response.status === 422 ) {
|
|
|
|
+ fieldErrors.value[setting] = error.response.data.message
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ notify.error(error);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Saves a setting on the backend
|
|
|
|
+ * @param {string} preference
|
|
|
|
+ * @param {any} value
|
|
|
|
+ */
|
|
|
|
+ function saveOrDeleteSetting(setting, value) {
|
|
|
|
+ if (value == '') {
|
|
|
|
+ fieldErrors.value[setting] = null
|
|
|
|
+
|
|
|
|
+ appSettingService.delete(setting, { returnError: true }).then(response => {
|
|
|
|
+ appSettings[setting] = ''
|
|
|
|
+ useNotifyStore().success({ type: 'is-success', text: trans('settings.forms.setting_saved') })
|
|
|
|
+ })
|
|
|
|
+ .catch(error => {
|
|
|
|
+ // appSettings[setting] = oldValue
|
|
|
|
+
|
|
|
|
+ if( error.response.status !== 404 ) {
|
|
|
|
+ notify.error(error);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ saveSetting(setting, value)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,7 +97,23 @@
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- onMounted(() => {
|
|
|
|
|
|
+ onMounted(async () => {
|
|
|
|
+ appSettingService.get({ returnError: true })
|
|
|
|
+ .then(response => {
|
|
|
|
+ // we reset those two because they are not registered on server side
|
|
|
|
+ // in order to be able to set them to blank
|
|
|
|
+ _settings.value.restrictList = ''
|
|
|
|
+ _settings.value.restrictRule = ''
|
|
|
|
+
|
|
|
|
+ response.data.forEach(setting => {
|
|
|
|
+ appSettings[setting.key] = setting.value
|
|
|
|
+ _settings.value[setting.key] = setting.value
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ .catch(error => {
|
|
|
|
+ notify.alert({ text: trans('errors.data_cannot_be_refreshed_from_server') })
|
|
|
|
+ })
|
|
|
|
+
|
|
systemService.getSystemInfos({returnError: true}).then(response => {
|
|
systemService.getSystemInfos({returnError: true}).then(response => {
|
|
infos.value = response.data.common
|
|
infos.value = response.data.common
|
|
})
|
|
})
|
|
@@ -66,7 +132,7 @@
|
|
<form>
|
|
<form>
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('settings.general') }}</h4>
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('settings.general') }}</h4>
|
|
<!-- Check for update -->
|
|
<!-- Check for update -->
|
|
- <FormCheckbox v-model="appSettings.checkForUpdate" @update:model-value="val => saveSetting('checkForUpdate', val)" fieldName="checkForUpdate" label="commons.check_for_update" help="commons.check_for_update_help" />
|
|
|
|
|
|
+ <FormCheckbox v-model="_settings.checkForUpdate" @update:model-value="val => saveSetting('checkForUpdate', val)" fieldName="checkForUpdate" label="commons.check_for_update" help="commons.check_for_update_help" />
|
|
<VersionChecker />
|
|
<VersionChecker />
|
|
<div class="field">
|
|
<div class="field">
|
|
<!-- <h5 class="title is-5">{{ $t('settings.security') }}</h5> -->
|
|
<!-- <h5 class="title is-5">{{ $t('settings.security') }}</h5> -->
|
|
@@ -86,12 +152,18 @@
|
|
</div>
|
|
</div>
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('settings.security') }}</h4>
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('settings.security') }}</h4>
|
|
<!-- protect db -->
|
|
<!-- protect db -->
|
|
- <FormCheckbox v-model="appSettings.useEncryption" @update:model-value="val => saveSetting('useEncryption', val)" fieldName="useEncryption" label="admin.forms.use_encryption.label" help="admin.forms.use_encryption.help" />
|
|
|
|
|
|
+ <FormCheckbox v-model="_settings.useEncryption" @update:model-value="val => saveSetting('useEncryption', val)" fieldName="useEncryption" label="admin.forms.use_encryption.label" help="admin.forms.use_encryption.help" />
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('admin.registrations') }}</h4>
|
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('admin.registrations') }}</h4>
|
|
|
|
+ <!-- restrict registration -->
|
|
|
|
+ <FormCheckbox v-model="_settings.restrictRegistration" @update:model-value="val => saveSetting('restrictRegistration', val)" fieldName="restrictRegistration" :isDisabled="appSettings.disableRegistration" label="admin.forms.restrict_registration.label" help="admin.forms.restrict_registration.help" />
|
|
|
|
+ <!-- restrict list -->
|
|
|
|
+ <FormField v-model="_settings.restrictList" @change:model-value="val => saveOrDeleteSetting('restrictList', val)" :fieldError="fieldErrors.restrictList" fieldName="restrictList" :isDisabled="!appSettings.restrictRegistration || appSettings.disableRegistration" label="admin.forms.restrict_list.label" help="admin.forms.restrict_list.help" :isIndented="true" />
|
|
|
|
+ <!-- restrict rule -->
|
|
|
|
+ <FormField v-model="_settings.restrictRule" @change:model-value="val => saveOrDeleteSetting('restrictRule', val)" :fieldError="fieldErrors.restrictRule" fieldName="restrictRule" :isDisabled="!appSettings.restrictRegistration || appSettings.disableRegistration" label="admin.forms.restrict_rule.label" help="admin.forms.restrict_rule.help" :isIndented="true" leftIcon="slash" rightIcon="slash" />
|
|
<!-- disable registration -->
|
|
<!-- disable registration -->
|
|
- <FormCheckbox v-model="appSettings.disableRegistration" @update:model-value="val => saveSetting('disableRegistration', val)" fieldName="disableRegistration" label="admin.forms.disable_registration.label" help="admin.forms.disable_registration.help" />
|
|
|
|
|
|
+ <FormCheckbox v-model="_settings.disableRegistration" @update:model-value="val => saveSetting('disableRegistration', val)" fieldName="disableRegistration" label="admin.forms.disable_registration.label" help="admin.forms.disable_registration.help" />
|
|
<!-- disable SSO registration -->
|
|
<!-- disable SSO registration -->
|
|
- <FormCheckbox v-model="appSettings.enableSso" @update:model-value="val => saveSetting('enableSso', val)" fieldName="enableSso" label="admin.forms.enable_sso.label" help="admin.forms.enable_sso.help" />
|
|
|
|
|
|
+ <FormCheckbox v-model="_settings.enableSso" @update:model-value="val => saveSetting('enableSso', val)" fieldName="enableSso" label="admin.forms.enable_sso.label" help="admin.forms.enable_sso.help" />
|
|
</form>
|
|
</form>
|
|
<h4 class="title is-4 pt-5 has-text-grey-light">{{ $t('commons.environment') }}</h4>
|
|
<h4 class="title is-4 pt-5 has-text-grey-light">{{ $t('commons.environment') }}</h4>
|
|
<div v-if="infos" class="about-debug box is-family-monospace is-size-7">
|
|
<div v-if="infos" class="about-debug box is-family-monospace is-size-7">
|