2021-04-22 15:29:33 +02:00
|
|
|
<template>
|
2021-12-30 13:47:48 +01:00
|
|
|
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
|
2021-04-22 15:29:33 +02:00
|
|
|
<FormSuspense :p="init">
|
2021-12-30 13:47:48 +01:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSwitch v-model="enableEmail" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.enableEmail }}</template>
|
|
|
|
<template #caption>{{ $ts.emailConfigInfo }}</template>
|
|
|
|
</FormSwitch>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2021-12-30 13:47:48 +01:00
|
|
|
<template v-if="enableEmail">
|
|
|
|
<FormInput v-model="email" type="email" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.emailAddress }}</template>
|
|
|
|
</FormInput>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2021-12-30 13:47:48 +01:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ $ts.smtpConfig }}</template>
|
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput v-model="smtpHost" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.smtpHost }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="smtpPort" type="number" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.smtpPort }}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput v-model="smtpUser" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.smtpUser }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="smtpPass" type="password" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.smtpPass }}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormInfo class="_formBlock">{{ $ts.emptyToDisableSmtpAuth }}</FormInfo>
|
|
|
|
<FormSwitch v-model="smtpSecure" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.smtpSecure }}</template>
|
|
|
|
<template #caption>{{ $ts.smtpSecureInfo }}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
</FormSection>
|
|
|
|
</template>
|
|
|
|
</div>
|
2021-04-22 15:29:33 +02:00
|
|
|
</FormSuspense>
|
2021-12-30 13:47:48 +01:00
|
|
|
</MkSpacer>
|
2021-04-22 15:29:33 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-12-30 13:47:48 +01:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormInput from '@/components/form/input.vue';
|
|
|
|
import FormInfo from '@/components/ui/info.vue';
|
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSplit from '@/components/form/split.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-02-28 19:51:31 +01:00
|
|
|
import { fetchInstance } from '@/instance';
|
2021-04-22 15:29:33 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
FormSwitch,
|
|
|
|
FormInput,
|
2021-12-30 13:47:48 +01:00
|
|
|
FormSplit,
|
|
|
|
FormSection,
|
2021-04-22 15:29:33 +02:00
|
|
|
FormInfo,
|
|
|
|
FormSuspense,
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: this.$ts.emailServer,
|
2021-10-10 08:19:16 +02:00
|
|
|
icon: 'fas fa-envelope',
|
|
|
|
bg: 'var(--bg)',
|
2021-12-30 13:47:48 +01:00
|
|
|
actions: [{
|
|
|
|
asFullButton: true,
|
|
|
|
text: this.$ts.testEmail,
|
|
|
|
handler: this.testEmail,
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-check',
|
|
|
|
text: this.$ts.save,
|
|
|
|
handler: this.save,
|
|
|
|
}],
|
2021-04-22 15:29:33 +02:00
|
|
|
},
|
|
|
|
enableEmail: false,
|
|
|
|
email: null,
|
|
|
|
smtpSecure: false,
|
|
|
|
smtpHost: '',
|
|
|
|
smtpPort: 0,
|
|
|
|
smtpUser: '',
|
|
|
|
smtpPass: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async init() {
|
2022-03-24 17:50:28 +01:00
|
|
|
const meta = await os.api('admin/meta');
|
2021-04-22 15:29:33 +02:00
|
|
|
this.enableEmail = meta.enableEmail;
|
|
|
|
this.email = meta.email;
|
|
|
|
this.smtpSecure = meta.smtpSecure;
|
|
|
|
this.smtpHost = meta.smtpHost;
|
|
|
|
this.smtpPort = meta.smtpPort;
|
|
|
|
this.smtpUser = meta.smtpUser;
|
|
|
|
this.smtpPass = meta.smtpPass;
|
|
|
|
},
|
|
|
|
|
|
|
|
async testEmail() {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled, result: destination } = await os.inputText({
|
2021-04-22 15:29:33 +02:00
|
|
|
title: this.$ts.destination,
|
2021-11-18 10:45:58 +01:00
|
|
|
type: 'email',
|
|
|
|
placeholder: this.$instance.maintainerEmail
|
2021-04-22 15:29:33 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('admin/send-email', {
|
|
|
|
to: destination,
|
|
|
|
subject: 'Test email',
|
|
|
|
text: 'Yo'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
|
|
|
enableEmail: this.enableEmail,
|
|
|
|
email: this.email,
|
|
|
|
smtpSecure: this.smtpSecure,
|
|
|
|
smtpHost: this.smtpHost,
|
|
|
|
smtpPort: this.smtpPort,
|
|
|
|
smtpUser: this.smtpUser,
|
|
|
|
smtpPass: this.smtpPass,
|
|
|
|
}).then(() => {
|
2022-02-28 19:51:31 +01:00
|
|
|
fetchInstance();
|
2021-04-22 15:29:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|