This commit is contained in:
syuilo 2023-05-01 17:09:07 +09:00
parent 5b7482d8f4
commit 25580e8afc
2 changed files with 30 additions and 31 deletions

View File

@ -3,25 +3,32 @@
<MkStickyContainer> <MkStickyContainer>
<template #header><XHeader :tabs="headerTabs"/></template> <template #header><XHeader :tabs="headerTabs"/></template>
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32"> <MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
<FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
<FormSuspense :p="init"> <FormSuspense :p="init">
<div class="_gaps_m"> <div class="_gaps_m">
<FormSection first> <MkSwitch v-model="enableRegistration">
<div class="_gaps_m"> <template #label>{{ i18n.ts.enableRegistration }}</template>
<MkInput v-model="tosUrl"> </MkSwitch>
<template #prefix><i class="ti ti-link"></i></template>
<template #label>{{ i18n.ts.tosUrl }}</template> <MkSwitch v-model="emailRequiredForSignup">
</MkInput> <template #label>{{ i18n.ts.emailRequiredForSignup }}</template>
<MkTextarea v-model="preservedUsernames"> </MkSwitch>
<template #label>{{ i18n.ts.preservedUsernames }}</template>
<template #caption>{{ i18n.ts.preservedUsernamesDescription }}</template> <FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
</MkTextarea>
<MkTextarea v-model="sensitiveWords"> <MkInput v-model="tosUrl">
<template #label>{{ i18n.ts.sensitiveWords }}</template> <template #prefix><i class="ti ti-link"></i></template>
<template #caption>{{ i18n.ts.sensitiveWordsDescription }}</template> <template #label>{{ i18n.ts.tosUrl }}</template>
</MkTextarea> </MkInput>
</div>
</FormSection> <MkTextarea v-model="preservedUsernames">
<template #label>{{ i18n.ts.preservedUsernames }}</template>
<template #caption>{{ i18n.ts.preservedUsernamesDescription }}</template>
</MkTextarea>
<MkTextarea v-model="sensitiveWords">
<template #label>{{ i18n.ts.sensitiveWords }}</template>
<template #caption>{{ i18n.ts.sensitiveWordsDescription }}</template>
</MkTextarea>
</div> </div>
</FormSuspense> </FormSuspense>
</MkSpacer> </MkSpacer>
@ -52,12 +59,16 @@ import { definePageMetadata } from '@/scripts/page-metadata';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import FormLink from '@/components/form/link.vue'; import FormLink from '@/components/form/link.vue';
let enableRegistration: boolean = $ref(false);
let emailRequiredForSignup: boolean = $ref(false);
let sensitiveWords: string = $ref(''); let sensitiveWords: string = $ref('');
let preservedUsernames: string = $ref(''); let preservedUsernames: string = $ref('');
let tosUrl: string | null = $ref(null); let tosUrl: string | null = $ref(null);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await os.api('admin/meta');
enableRegistration = !meta.disableRegistration;
emailRequiredForSignup = meta.emailRequiredForSignup;
sensitiveWords = meta.sensitiveWords.join('\n'); sensitiveWords = meta.sensitiveWords.join('\n');
preservedUsernames = meta.preservedUsernames.join('\n'); preservedUsernames = meta.preservedUsernames.join('\n');
tosUrl = meta.tosUrl; tosUrl = meta.tosUrl;
@ -65,6 +76,8 @@ async function init() {
function save() { function save() {
os.apiWithDialog('admin/update-meta', { os.apiWithDialog('admin/update-meta', {
disableRegistration: !enableRegistration,
emailRequiredForSignup,
tosUrl, tosUrl,
sensitiveWords: sensitiveWords.split('\n'), sensitiveWords: sensitiveWords.split('\n'),
preservedUsernames: preservedUsernames.split('\n'), preservedUsernames: preservedUsernames.split('\n'),

View File

@ -31,14 +31,6 @@
<FormSection> <FormSection>
<div class="_gaps_s"> <div class="_gaps_s">
<MkSwitch v-model="enableRegistration">
<template #label>{{ i18n.ts.enableRegistration }}</template>
</MkSwitch>
<MkSwitch v-model="emailRequiredForSignup">
<template #label>{{ i18n.ts.emailRequiredForSignup }}</template>
</MkSwitch>
<MkSwitch v-model="enableChartsForRemoteUser"> <MkSwitch v-model="enableChartsForRemoteUser">
<template #label>{{ i18n.ts.enableChartsForRemoteUser }}</template> <template #label>{{ i18n.ts.enableChartsForRemoteUser }}</template>
</MkSwitch> </MkSwitch>
@ -174,8 +166,6 @@ let defaultLightTheme: any = $ref(null);
let defaultDarkTheme: any = $ref(null); let defaultDarkTheme: any = $ref(null);
let pinnedUsers: string = $ref(''); let pinnedUsers: string = $ref('');
let cacheRemoteFiles: boolean = $ref(false); let cacheRemoteFiles: boolean = $ref(false);
let enableRegistration: boolean = $ref(false);
let emailRequiredForSignup: boolean = $ref(false);
let enableServiceWorker: boolean = $ref(false); let enableServiceWorker: boolean = $ref(false);
let enableChartsForRemoteUser: boolean = $ref(false); let enableChartsForRemoteUser: boolean = $ref(false);
let enableChartsForFederatedInstances: boolean = $ref(false); let enableChartsForFederatedInstances: boolean = $ref(false);
@ -198,8 +188,6 @@ async function init() {
maintainerEmail = meta.maintainerEmail; maintainerEmail = meta.maintainerEmail;
pinnedUsers = meta.pinnedUsers.join('\n'); pinnedUsers = meta.pinnedUsers.join('\n');
cacheRemoteFiles = meta.cacheRemoteFiles; cacheRemoteFiles = meta.cacheRemoteFiles;
enableRegistration = !meta.disableRegistration;
emailRequiredForSignup = meta.emailRequiredForSignup;
enableServiceWorker = meta.enableServiceWorker; enableServiceWorker = meta.enableServiceWorker;
enableChartsForRemoteUser = meta.enableChartsForRemoteUser; enableChartsForRemoteUser = meta.enableChartsForRemoteUser;
enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances; enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances;
@ -223,8 +211,6 @@ function save() {
maintainerEmail, maintainerEmail,
pinnedUsers: pinnedUsers.split('\n'), pinnedUsers: pinnedUsers.split('\n'),
cacheRemoteFiles, cacheRemoteFiles,
disableRegistration: !enableRegistration,
emailRequiredForSignup,
enableServiceWorker, enableServiceWorker,
enableChartsForRemoteUser, enableChartsForRemoteUser,
enableChartsForFederatedInstances, enableChartsForFederatedInstances,