Sharkey/packages/frontend/src/pages/admin/relays.vue

92 lines
2.2 KiB
Vue
Raw Normal View History

<template>
<MkStickyContainer>
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 14:52:15 +03:00
<MkSpacer :contentMax="800">
2023-01-09 10:18:45 +02: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 05:35:26 +03:00
<div style="margin: 8px 0;">
<i v-if="relay.status === 'accepted'" class="ti ti-check" :class="$style.icon" style="color: var(--success);"></i>
<i v-else-if="relay.status === 'rejected'" class="ti ti-ban" :class="$style.icon" style="color: var(--error);"></i>
<i v-else class="ti ti-clock" :class="$style.icon"></i>
2023-04-01 08:01:57 +03:00
<span>{{ i18n.t(`_relayStatus.${relay.status}`) }}</span>
2023-01-09 10:18:45 +02:00
</div>
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton>
</div>
</div>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { } from 'vue';
import XHeader from './_header_.vue';
import MkButton from '@/components/MkButton.vue';
2021-11-11 19:02:25 +02:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
let relays: any[] = $ref([]);
async function addRelay() {
const { canceled, result: inbox } = await os.inputText({
title: i18n.ts.addRelay,
type: 'url',
placeholder: i18n.ts.inboxUrl,
});
if (canceled) return;
os.api('admin/relays/add', {
inbox,
}).then((relay: any) => {
refresh();
}).catch((err: any) => {
os.alert({
type: 'error',
text: err.message || err,
});
});
}
function remove(inbox: string) {
os.api('admin/relays/remove', {
inbox,
}).then(() => {
refresh();
}).catch((err: any) => {
os.alert({
type: 'error',
text: err.message || err,
});
});
}
function refresh() {
os.api('admin/relays/list').then((relayList: any) => {
relays = relayList;
});
}
refresh();
const headerActions = $computed(() => [{
asFullButton: true,
icon: 'ti ti-plus',
text: i18n.ts.addRelay,
handler: addRelay,
}]);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.relays,
icon: 'ti ti-planet',
});
</script>
2023-05-27 05:35:26 +03:00
<style lang="scss" module>
.icon {
width: 1em;
margin-right: 0.75em;
2022-01-02 20:17:28 +02:00
}
</style>