2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-05-10 11:42:31 +02:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSpacer :contentMax="800">
|
2023-01-09 09:18:45 +01:00
|
|
|
<div class="_gaps">
|
|
|
|
<div v-for="relay in relays" :key="relay.inbox" class="relaycxt _panel" style="padding: 16px;">
|
|
|
|
<div>{{ relay.inbox }}</div>
|
2023-05-27 04:35:26 +02:00
|
|
|
<div style="margin: 8px 0;">
|
2023-09-30 21:53:52 +02:00
|
|
|
<i v-if="relay.status === 'accepted'" class="ph-check ph-bold ph-lg" :class="$style.icon" style="color: var(--success);"></i>
|
|
|
|
<i v-else-if="relay.status === 'rejected'" class="ph-prohibit ph-bold ph-lg" :class="$style.icon" style="color: var(--error);"></i>
|
|
|
|
<i v-else class="ph-clock ph-bold ph-lg" :class="$style.icon"></i>
|
2023-04-01 07:01:57 +02:00
|
|
|
<span>{{ i18n.t(`_relayStatus.${relay.status}`) }}</span>
|
2023-01-09 09:18:45 +01:00
|
|
|
</div>
|
2023-09-30 21:53:52 +02:00
|
|
|
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="ph-trash ph-bold ph-lg"></i> {{ i18n.ts.remove }}</MkButton>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2020-05-10 11:42:31 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-05-10 11:42:31 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2022-06-20 10:38:49 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
let relays: any[] = $ref([]);
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
async function addRelay() {
|
|
|
|
const { canceled, result: inbox } = await os.inputText({
|
|
|
|
title: i18n.ts.addRelay,
|
|
|
|
type: 'url',
|
2022-06-20 10:38:49 +02:00
|
|
|
placeholder: i18n.ts.inboxUrl,
|
2022-05-17 18:30:49 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.api('admin/relays/add', {
|
2022-06-20 10:38:49 +02:00
|
|
|
inbox,
|
2022-05-17 18:30:49 +02:00
|
|
|
}).then((relay: any) => {
|
|
|
|
refresh();
|
|
|
|
}).catch((err: any) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: err.message || err,
|
2022-05-17 18:30:49 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
function remove(inbox: string) {
|
|
|
|
os.api('admin/relays/remove', {
|
2022-06-20 10:38:49 +02:00
|
|
|
inbox,
|
2022-05-17 18:30:49 +02:00
|
|
|
}).then(() => {
|
|
|
|
refresh();
|
|
|
|
}).catch((err: any) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: err.message || err,
|
2022-05-17 18:30:49 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
function refresh() {
|
|
|
|
os.api('admin/relays/list').then((relayList: any) => {
|
|
|
|
relays = relayList;
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
refresh();
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
asFullButton: true,
|
2023-09-30 21:53:52 +02:00
|
|
|
icon: 'ph-plus ph-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: i18n.ts.addRelay,
|
|
|
|
handler: addRelay,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.relays,
|
2023-11-03 23:20:53 +01:00
|
|
|
icon: 'ph-planet ph-bold ph-lg',
|
2020-05-10 11:42:31 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-05-27 04:35:26 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
2022-01-02 19:17:28 +01:00
|
|
|
}
|
2020-05-10 11:42:31 +02:00
|
|
|
</style>
|