hippofish/packages/client/src/pages/admin/instance-block.vue

86 lines
2.3 KiB
Vue
Raw Normal View History

<template>
2023-04-08 02:01:42 +02:00
<MkStickyContainer>
<template #header
><MkPageHeader
:actions="headerActions"
:tabs="headerTabs"
:display-back-button="true"
/></template>
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
2023-04-30 17:39:01 +02:00
<MkTab v-model="tab" class="_formBlock">
<option value="block">{{ i18n.ts.blockedInstances }}</option>
<option value="silence">{{ i18n.ts.silencedInstances }}</option>
</MkTab>
2023-04-08 02:01:42 +02:00
<FormSuspense :p="init">
2023-04-30 14:08:45 +02:00
<FormTextarea
v-if="tab === 'block'"
v-model="blockedHosts"
class="_formBlock"
>
2023-04-08 02:01:42 +02:00
<span>{{ i18n.ts.blockedInstances }}</span>
<template #caption>{{
i18n.ts.blockedInstancesDescription
}}</template>
</FormTextarea>
2023-04-30 14:08:45 +02:00
<FormTextarea
v-else-if="tab === 'silence'"
v-model="silencedHosts"
class="_formBlock"
>
2023-04-30 13:27:55 +02:00
<span>{{ i18n.ts.silencedInstances }}</span>
<template #caption>{{
i18n.ts.silencedInstancesDescription
}}</template>
</FormTextarea>
2023-04-08 02:01:42 +02:00
<FormButton primary class="_formBlock" @click="save"
><i class="ph-floppy-disk-back ph-bold ph-lg"></i>
{{ i18n.ts.save }}</FormButton
>
</FormSuspense>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
2023-04-08 02:01:42 +02:00
import {} from "vue";
import FormButton from "@/components/MkButton.vue";
import FormTextarea from "@/components/form/textarea.vue";
import FormSuspense from "@/components/form/suspense.vue";
2023-04-30 17:39:01 +02:00
import MkTab from "@/components/MkTab.vue";
2023-04-08 02:01:42 +02:00
import * as os from "@/os";
import { fetchInstance } from "@/instance";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
2023-04-08 02:01:42 +02:00
let blockedHosts: string = $ref("");
2023-04-30 13:27:55 +02:00
let silencedHosts: string = $ref("");
let tab = $ref("block");
async function init() {
2023-04-08 02:01:42 +02:00
const meta = await os.api("admin/meta");
2023-04-30 13:27:55 +02:00
if (meta) {
blockedHosts = meta.blockedHosts.join("\n");
silencedHosts = meta.silencedHosts.join("\n");
}
}
function save() {
2023-04-08 02:01:42 +02:00
os.apiWithDialog("admin/update-meta", {
blockedHosts: blockedHosts.split("\n").map((h) => h.trim()) || [],
2023-04-30 13:27:55 +02:00
silencedHosts: silencedHosts.split("\n").map((h) => h.trim()) || [],
}).then(() => {
fetchInstance();
});
}
const headerActions = $computed(() => []);
2023-04-30 17:39:01 +02:00
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.instanceBlocking,
2023-04-08 02:01:42 +02:00
icon: "ph-prohibit ph-bold ph-lg",
});
</script>