make account samba work again
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
1e67a0feca
commit
fa4a18fbbb
|
@ -43,7 +43,7 @@ const hasData = computed({
|
|||
|
||||
const initialDataLoaded = ref(false);
|
||||
const formUrlCreate = ref(null);
|
||||
const formUrlUpdate = ref(`LdapConfigs/${1}`);
|
||||
const formUrlUpdate = ref(null);
|
||||
const formCustomFn = ref(null);
|
||||
|
||||
const onTestConection = async () => {
|
||||
|
|
|
@ -7,13 +7,20 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const arrayData = useArrayData('AccountSamba');
|
||||
|
||||
const formModel = ref(null);
|
||||
|
||||
const URL_UPDATE = `SambaConfigs/${1}`;
|
||||
const URL_CREATE = `SambaConfigs`;
|
||||
|
||||
const DEFAULT_DATA = {
|
||||
id: 1,
|
||||
hasData: false,
|
||||
|
@ -33,15 +40,15 @@ const hasData = computed({
|
|||
get: () => initialData.value.hasData,
|
||||
set: (val) => {
|
||||
initialData.value.hasData = val;
|
||||
if (!val) customFn.value = deleteMailForward;
|
||||
else customFn.value = null;
|
||||
if (!val) formCustomFn.value = deleteMailForward;
|
||||
else formCustomFn.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
const initialDataLoaded = ref(false);
|
||||
const urlCreate = ref(null);
|
||||
const urlUpdate = ref(`SambaConfigs/${1}`);
|
||||
const customFn = ref(null);
|
||||
const formUrlCreate = ref(null);
|
||||
const formUrlUpdate = ref(null);
|
||||
const formCustomFn = ref(null);
|
||||
|
||||
const onTestConection = async () => {
|
||||
try {
|
||||
|
@ -52,22 +59,25 @@ const onTestConection = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const getInitialLdapConfig = async () => {
|
||||
const getInitialSambaConfig = async () => {
|
||||
try {
|
||||
initialDataLoaded.value = false;
|
||||
const { data } = await axios.get(urlUpdate.value);
|
||||
const { data } = await axios.get(URL_UPDATE);
|
||||
initialData.value = data;
|
||||
hasData.value = true;
|
||||
return data;
|
||||
} catch (error) {
|
||||
hasData.value = false;
|
||||
console.error('Error fetching initial LDAP config', error);
|
||||
arrayData.destroy();
|
||||
console.error('Error fetching initial Samba config', error);
|
||||
return null;
|
||||
} finally {
|
||||
if (hasData.value) urlCreate.value = null;
|
||||
else {
|
||||
urlUpdate.value = null;
|
||||
urlCreate.value = `SambaConfigs`;
|
||||
if (hasData.value) {
|
||||
formUrlUpdate.value = URL_UPDATE;
|
||||
formUrlCreate.value = null;
|
||||
} else {
|
||||
formUrlUpdate.value = null;
|
||||
formUrlCreate.value = URL_CREATE;
|
||||
}
|
||||
initialDataLoaded.value = true;
|
||||
}
|
||||
|
@ -75,7 +85,7 @@ const getInitialLdapConfig = async () => {
|
|||
|
||||
const deleteMailForward = async () => {
|
||||
try {
|
||||
await axios.delete(urlUpdate.value);
|
||||
await axios.delete(URL_UPDATE);
|
||||
initialData.value = { ...DEFAULT_DATA };
|
||||
hasData.value = false;
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
|
@ -84,7 +94,7 @@ const deleteMailForward = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
onMounted(async () => await getInitialLdapConfig());
|
||||
onMounted(async () => await getInitialSambaConfig());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -95,22 +105,22 @@ onMounted(async () => await getInitialLdapConfig());
|
|||
:key="initialDataLoaded"
|
||||
model="AccountSamba"
|
||||
:form-initial-data="initialData"
|
||||
:url-create="urlCreate"
|
||||
:url-update="urlUpdate"
|
||||
:save-fn="customFn"
|
||||
:url-create="formUrlCreate"
|
||||
:url-update="formUrlUpdate"
|
||||
:save-fn="formCustomFn"
|
||||
auto-load
|
||||
@on-data-saved="getInitialLdapConfig()"
|
||||
@on-data-saved="getInitialSambaConfig()"
|
||||
>
|
||||
<template #moreActions>
|
||||
<QBtn
|
||||
class="q-ml-none"
|
||||
color="primary"
|
||||
:label="t('ldap.testConnection')"
|
||||
:label="t('samba.testConnection')"
|
||||
:disable="formModel.hasChanges"
|
||||
@click="onTestConection()"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('ldap.testConnection') }}
|
||||
{{ t('samba.testConnection') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</template>
|
||||
|
@ -118,7 +128,7 @@ onMounted(async () => await getInitialLdapConfig());
|
|||
<VnRow class="row q-gutter-md">
|
||||
<div class="col">
|
||||
<QCheckbox
|
||||
:label="t('ldap.enableSync')"
|
||||
:label="t('samba.enableSync')"
|
||||
v-model="data.hasData"
|
||||
@update:model-value="($event) => (hasData = $event)"
|
||||
:toggle-indeterminate="false"
|
||||
|
|
Loading…
Reference in New Issue