2020-05-10 18:42:31 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
2023-01-06 09:41:14 +09:00
|
|
|
<div v-for="relay in relays" :key="relay.inbox" class="relaycxt _panel" style="padding: 16px;">
|
2022-06-20 17:38:49 +09:00
|
|
|
<div>{{ relay.inbox }}</div>
|
|
|
|
<div class="status">
|
2022-12-19 19:01:30 +09:00
|
|
|
<i v-if="relay.status === 'accepted'" class="ti ti-check icon accepted"></i>
|
|
|
|
<i v-else-if="relay.status === 'rejected'" class="ti ti-ban icon rejected"></i>
|
|
|
|
<i v-else class="ti ti-clock icon requesting"></i>
|
2022-06-20 17:38:49 +09:00
|
|
|
<span>{{ $t(`_relayStatus.${relay.status}`) }}</span>
|
|
|
|
</div>
|
2022-12-19 19:01:30 +09:00
|
|
|
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton>
|
2020-05-10 18:42:31 +09:00
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-05-10 18:42:31 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2022-06-20 17:38:49 +09:00
|
|
|
import XHeader from './_header_.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-05-18 01:30:49 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
let relays: any[] = $ref([]);
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
async function addRelay() {
|
|
|
|
const { canceled, result: inbox } = await os.inputText({
|
|
|
|
title: i18n.ts.addRelay,
|
|
|
|
type: 'url',
|
2022-06-20 17:38:49 +09:00
|
|
|
placeholder: i18n.ts.inboxUrl,
|
2022-05-18 01:30:49 +09:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.api('admin/relays/add', {
|
2022-06-20 17:38:49 +09:00
|
|
|
inbox,
|
2022-05-18 01:30:49 +09:00
|
|
|
}).then((relay: any) => {
|
|
|
|
refresh();
|
|
|
|
}).catch((err: any) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: err.message || err,
|
2022-05-18 01:30:49 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
function remove(inbox: string) {
|
|
|
|
os.api('admin/relays/remove', {
|
2022-06-20 17:38:49 +09:00
|
|
|
inbox,
|
2022-05-18 01:30:49 +09:00
|
|
|
}).then(() => {
|
|
|
|
refresh();
|
|
|
|
}).catch((err: any) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: err.message || err,
|
2022-05-18 01:30:49 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
function refresh() {
|
|
|
|
os.api('admin/relays/list').then((relayList: any) => {
|
|
|
|
relays = relayList;
|
|
|
|
});
|
|
|
|
}
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-05-18 01:30:49 +09:00
|
|
|
refresh();
|
2020-05-10 18:42:31 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
asFullButton: true,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-plus',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: i18n.ts.addRelay,
|
|
|
|
handler: addRelay,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.relays,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-planet',
|
2020-05-10 18:42:31 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2022-12-27 18:29:39 +09:00
|
|
|
<style lang="scss" scoped>
|
2022-01-03 03:17:28 +09:00
|
|
|
.relaycxt {
|
|
|
|
> .status {
|
|
|
|
margin: 8px 0;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
|
|
|
|
|
|
|
&.accepted {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-01-03 03:17:28 +09:00
|
|
|
&.rejected {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 18:42:31 +09:00
|
|
|
</style>
|