misskey/packages/frontend/src/pages/admin/email-settings.vue

144 lines
4.0 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkStickyContainer>
2023-03-02 20:47:24 +09:00
<template #header><XHeader :tabs="headerTabs"/></template>
2023-05-19 20:52:15 +09:00
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="32">
<FormSuspense :p="init">
2023-01-06 13:40:17 +09:00
<div class="_gaps_m">
2023-01-07 14:59:54 +09:00
<MkSwitch v-model="enableEmail">
<template #label>{{ i18n.ts.enableEmail }} ({{ i18n.ts.recommended }})</template>
<template #caption>{{ i18n.ts.emailConfigInfo }}</template>
2023-01-07 14:59:54 +09:00
</MkSwitch>
<template v-if="enableEmail">
2023-01-07 15:09:46 +09:00
<MkInput v-model="email" type="email">
<template #label>{{ i18n.ts.emailAddress }}</template>
2023-01-07 15:09:46 +09:00
</MkInput>
<FormSection>
<template #label>{{ i18n.ts.smtpConfig }}</template>
2023-01-05 21:04:56 +09:00
2023-01-06 13:40:17 +09:00
<div class="_gaps_m">
2023-05-19 20:52:15 +09:00
<FormSplit :minWidth="280">
2023-01-07 15:09:46 +09:00
<MkInput v-model="smtpHost">
2023-01-05 21:04:56 +09:00
<template #label>{{ i18n.ts.smtpHost }}</template>
2023-01-07 15:09:46 +09:00
</MkInput>
<MkInput v-model="smtpPort" type="number">
2023-01-05 21:04:56 +09:00
<template #label>{{ i18n.ts.smtpPort }}</template>
2023-01-07 15:09:46 +09:00
</MkInput>
2023-01-05 21:04:56 +09:00
</FormSplit>
2023-05-19 20:52:15 +09:00
<FormSplit :minWidth="280">
2023-01-07 15:09:46 +09:00
<MkInput v-model="smtpUser">
2023-01-05 21:04:56 +09:00
<template #label>{{ i18n.ts.smtpUser }}</template>
2023-01-07 15:09:46 +09:00
</MkInput>
<MkInput v-model="smtpPass" type="password">
2023-01-05 21:04:56 +09:00
<template #label>{{ i18n.ts.smtpPass }}</template>
2023-01-07 15:09:46 +09:00
</MkInput>
2023-01-05 21:04:56 +09:00
</FormSplit>
<FormInfo>{{ i18n.ts.emptyToDisableSmtpAuth }}</FormInfo>
2023-01-07 14:59:54 +09:00
<MkSwitch v-model="smtpSecure">
2023-01-05 21:04:56 +09:00
<template #label>{{ i18n.ts.smtpSecure }}</template>
<template #caption>{{ i18n.ts.smtpSecureInfo }}</template>
2023-01-07 14:59:54 +09:00
</MkSwitch>
2023-01-05 21:04:56 +09:00
</div>
</FormSection>
</template>
</div>
</FormSuspense>
</MkSpacer>
2023-03-02 20:47:24 +09:00
<template #footer>
<div :class="$style.footer">
2023-05-19 20:52:15 +09:00
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="16">
2023-03-02 20:47:24 +09:00
<div class="_buttons">
<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
<MkButton rounded @click="testEmail"><i class="ti ti-send"></i> {{ i18n.ts.testEmail }}</MkButton>
</div>
</MkSpacer>
</div>
</template>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { } from 'vue';
import XHeader from './_header_.vue';
2023-01-07 14:59:54 +09:00
import MkSwitch from '@/components/MkSwitch.vue';
2023-01-07 15:09:46 +09:00
import MkInput from '@/components/MkInput.vue';
import FormInfo from '@/components/MkInfo.vue';
2021-12-30 21:47:48 +09:00
import FormSuspense from '@/components/form/suspense.vue';
import FormSplit from '@/components/form/split.vue';
import FormSection from '@/components/form/section.vue';
2023-09-19 16:37:43 +09:00
import * as os from '@/os.js';
import { fetchInstance, instance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
2023-03-02 20:47:24 +09:00
import MkButton from '@/components/MkButton.vue';
let enableEmail: boolean = $ref(false);
let email: any = $ref(null);
let smtpSecure: boolean = $ref(false);
let smtpHost: string = $ref('');
let smtpPort: number = $ref(0);
let smtpUser: string = $ref('');
let smtpPass: string = $ref('');
async function init() {
const meta = await os.api('admin/meta');
enableEmail = meta.enableEmail;
email = meta.email;
smtpSecure = meta.smtpSecure;
smtpHost = meta.smtpHost;
smtpPort = meta.smtpPort;
smtpUser = meta.smtpUser;
smtpPass = meta.smtpPass;
}
async function testEmail() {
const { canceled, result: destination } = await os.inputText({
title: i18n.ts.destination,
type: 'email',
2023-04-27 19:43:00 +09:00
default: instance.maintainerEmail ?? '',
placeholder: 'test@example.com',
minLength: 1,
});
if (canceled) return;
os.apiWithDialog('admin/send-email', {
to: destination,
subject: 'Test email',
text: 'Yo',
});
}
function save() {
os.apiWithDialog('admin/update-meta', {
enableEmail,
email,
smtpSecure,
smtpHost,
smtpPort,
smtpUser,
smtpPass,
}).then(() => {
fetchInstance();
});
}
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.emailServer,
icon: 'ti ti-mail',
});
</script>
2023-03-02 20:47:24 +09:00
<style lang="scss" module>
.footer {
-webkit-backdrop-filter: var(--blur, blur(15px));
backdrop-filter: var(--blur, blur(15px));
}
</style>