Add SaveIndicator to user directory settings
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import { ref, onMounted, inject } from 'vue';
|
import { ref, onMounted, inject, useTemplateRef } from 'vue';
|
||||||
import { Switch } from '@cloudron/pankow';
|
import { Switch } from '@cloudron/pankow';
|
||||||
|
import SaveIndicator from '../components/SaveIndicator.vue';
|
||||||
import Section from '../components/Section.vue';
|
import Section from '../components/Section.vue';
|
||||||
import SettingsItem from '../components/SettingsItem.vue';
|
import SettingsItem from '../components/SettingsItem.vue';
|
||||||
import UserDirectoryModel from '../models/UserDirectoryModel.js';
|
import UserDirectoryModel from '../models/UserDirectoryModel.js';
|
||||||
@@ -11,8 +12,8 @@ const features = inject('features');
|
|||||||
const userDirectoryModel = UserDirectoryModel.create();
|
const userDirectoryModel = UserDirectoryModel.create();
|
||||||
|
|
||||||
const busy = ref(false);
|
const busy = ref(false);
|
||||||
const editableUserProfiles = ref(false);
|
|
||||||
const mandatory2FA = ref(false);
|
const mandatory2FA = ref(false);
|
||||||
|
const mandatory2FASaveIndicator = useTemplateRef('mandatory2FASaveIndicator');
|
||||||
|
|
||||||
async function onToggleMandatory2FA(value) {
|
async function onToggleMandatory2FA(value) {
|
||||||
busy.value = true;
|
busy.value = true;
|
||||||
@@ -20,19 +21,28 @@ async function onToggleMandatory2FA(value) {
|
|||||||
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: value, lockUserProfiles: !editableUserProfiles.value });
|
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: value, lockUserProfiles: !editableUserProfiles.value });
|
||||||
if (error) {
|
if (error) {
|
||||||
mandatory2FA.value = !value;
|
mandatory2FA.value = !value;
|
||||||
|
mandatory2FASaveIndicator.value.error();
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
mandatory2FASaveIndicator.value.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
busy.value = false;
|
busy.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const editableUserProfiles = ref(false);
|
||||||
|
const editableUserProfilesSaveIndicator = useTemplateRef('editableUserProfilesSaveIndicator');
|
||||||
|
|
||||||
async function onToggleEditableUserProfiles(value) {
|
async function onToggleEditableUserProfiles(value) {
|
||||||
busy.value = true;
|
busy.value = true;
|
||||||
|
|
||||||
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: mandatory2FA.value, lockUserProfiles: !value });
|
const [error] = await userDirectoryModel.setGlobalProfileConfig({ mandatory2FA: mandatory2FA.value, lockUserProfiles: !value });
|
||||||
if (error) {
|
if (error) {
|
||||||
editableUserProfiles.value = !value;
|
editableUserProfiles.value = !value;
|
||||||
|
editableUserProfilesSaveIndicator.value.error();
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
editableUserProfilesSaveIndicator.value.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
busy.value = false;
|
busy.value = false;
|
||||||
@@ -54,11 +64,13 @@ onMounted(async () => {
|
|||||||
<SettingsItem>
|
<SettingsItem>
|
||||||
<div>{{ $t('users.settings.allowProfileEditCheckbox') }} <sup><a href="https://docs.cloudron.io/user-directory/#lock-profile" target="_blank"><i class="fa fa-question-circle"></i></a></sup></div>
|
<div>{{ $t('users.settings.allowProfileEditCheckbox') }} <sup><a href="https://docs.cloudron.io/user-directory/#lock-profile" target="_blank"><i class="fa fa-question-circle"></i></a></sup></div>
|
||||||
<Switch v-model="editableUserProfiles" @change="onToggleEditableUserProfiles" :disabled="busy || !features.profileConfig"/>
|
<Switch v-model="editableUserProfiles" @change="onToggleEditableUserProfiles" :disabled="busy || !features.profileConfig"/>
|
||||||
|
<SaveIndicator ref="editableUserProfilesSaveIndicator"/>
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
|
|
||||||
<SettingsItem>
|
<SettingsItem>
|
||||||
<div>{{ $t('users.settings.require2FACheckbox') }}</div>
|
<div>{{ $t('users.settings.require2FACheckbox') }}</div>
|
||||||
<Switch v-model="mandatory2FA" @change="onToggleMandatory2FA" :disabled="busy || !features.profileConfig"/>
|
<Switch v-model="mandatory2FA" @change="onToggleMandatory2FA" :disabled="busy || !features.profileConfig"/>
|
||||||
|
<SaveIndicator ref="mandatory2FASaveIndicator"/>
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user