diff --git a/dashboard/src/components/SettingsItem.vue b/dashboard/src/components/SettingsItem.vue index 7cd2c588b..985452bd7 100644 --- a/dashboard/src/components/SettingsItem.vue +++ b/dashboard/src/components/SettingsItem.vue @@ -3,23 +3,31 @@ - + + + + + + \ No newline at end of file diff --git a/dashboard/src/models/TasksModel.js b/dashboard/src/models/TasksModel.js index 741d6aa58..28f7bea86 100644 --- a/dashboard/src/models/TasksModel.js +++ b/dashboard/src/models/TasksModel.js @@ -7,7 +7,7 @@ function create() { const accessToken = localStorage.token; return { - async wait(id) { + async wait(id, progressHandler = function () {}) { while(true) { let result; try { @@ -16,8 +16,11 @@ function create() { return [e]; } + console.log(result.body) if (!result.body.active) return [result.body.error, result.body.result]; + progressHandler(result.body); + await sleep(2000); } }, diff --git a/dashboard/src/views/EmailsView.vue b/dashboard/src/views/EmailsView.vue index 017164b62..ee8ca8f14 100644 --- a/dashboard/src/views/EmailsView.vue +++ b/dashboard/src/views/EmailsView.vue @@ -5,17 +5,19 @@ const i18n = useI18n(); const t = i18n.t; import { ref, onMounted, useTemplateRef } from 'vue'; -import { Button, TableView, InputDialog, FormGroup, TextInput, InputGroup, Switch, ButtonGroup, SingleSelect } from 'pankow'; +import { Button, TableView, ProgressBar, InputDialog, FormGroup, TextInput, InputGroup, Switch, ButtonGroup, SingleSelect } from 'pankow'; import { prettyDecimalSize } from 'pankow/utils'; import Section from '../components/Section.vue'; import SettingsItem from '../components/SettingsItem.vue'; import DomainsModel from '../models/DomainsModel.js'; import MailModel from '../models/MailModel.js'; import ProfileModel from '../models/ProfileModel.js'; +import TasksModel from '../models/TasksModel.js'; const domainsModel = DomainsModel.create(); const mailModel = MailModel.create(); const profileModel = ProfileModel.create(); +const tasksModel = TasksModel.create(); const inputDialog = useTemplateRef('inputDialog'); const columns = { @@ -36,8 +38,6 @@ const blocklist = ref([]); const allowlist = ref([]); const dnsblZones = ref([]); const dnsblZonesString = ref(''); -const locationSubdomain = ref(''); -const locationDomain = ref(''); const currentLocationSubdomain = ref(''); const currentLocationDomain = ref(''); const spamCustomConfig = ref(''); @@ -129,6 +129,33 @@ async function onSendTestMail(domain) { window.pankow.notify({ text: 'Mail sent', type: 'success' }); } + +// mail server location +const locationSubdomain = ref(''); +const locationDomain = ref(''); +const locationChangeBusy = ref(false); +const locationChangeMessage = ref(''); +const locationChangeProgress = ref(0); + +async function onChangeMailDomain() { + locationChangeBusy.value = true; + locationChangeMessage.value = ''; + locationChangeProgress.value = 0; + + const [error, result] = await mailModel.setLocation(locationSubdomain.value, locationDomain.value); + if (error) return console.error(error); + + await tasksModel.wait(result, (result) => { + locationChangeMessage.value = result.message; + locationChangeProgress.value = result.percent; + }); + + locationChangeBusy.value = false; + locationChangeMessage.value = ''; + locationChangeProgress.value = 0; +} + + async function onChangeMailboxSharing(value) { const [error] = await mailModel.setMailboxSharing(value); if (error) { @@ -250,17 +277,21 @@ onMounted(async () => { - + {{ $t('emails.settings.location') }} - - + + - {{ $t('main.dialog.save') }} + {{ $t('main.dialog.save') }} + + + {{ locationChangeMessage }} +