2020-05-10 11:42:31 +02:00
|
|
|
<template>
|
2022-01-02 19:17:28 +01:00
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<div v-for="relay in relays" :key="relay.inbox" class="relaycxt _panel _block" style="padding: 16px;">
|
|
|
|
<div>{{ relay.inbox }}</div>
|
|
|
|
<div class="status">
|
|
|
|
<i v-if="relay.status === 'accepted'" class="fas fa-check icon accepted"></i>
|
|
|
|
<i v-else-if="relay.status === 'rejected'" class="fas fa-ban icon rejected"></i>
|
|
|
|
<i v-else class="fas fa-clock icon requesting"></i>
|
|
|
|
<span>{{ $t(`_relayStatus.${relay.status}`) }}</span>
|
2020-05-10 11:42:31 +02:00
|
|
|
</div>
|
2022-05-17 18:30:49 +02:00
|
|
|
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="fas fa-trash-alt"></i> {{ i18n.ts.remove }}</MkButton>
|
2021-04-22 15:29:33 +02:00
|
|
|
</div>
|
2022-01-02 19:17:28 +01:00
|
|
|
</MkSpacer>
|
2020-05-10 11:42:31 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-17 18:30:49 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-05-17 18:30:49 +02:00
|
|
|
import { i18n } from '@/i18n';
|
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',
|
|
|
|
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
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
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', {
|
|
|
|
inbox
|
|
|
|
}).then(() => {
|
|
|
|
refresh();
|
|
|
|
}).catch((err: any) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: err.message || err
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
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-05-17 18:30:49 +02:00
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.ts.relays,
|
|
|
|
icon: 'fas fa-globe',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
actions: [{
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
text: i18n.ts.addRelay,
|
|
|
|
handler: addRelay,
|
|
|
|
}],
|
2020-05-10 11:42:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-01-02 19:17:28 +01:00
|
|
|
.relaycxt {
|
|
|
|
> .status {
|
|
|
|
margin: 8px 0;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
|
|
|
|
|
|
|
&.accepted {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-01-02 19:17:28 +01:00
|
|
|
&.rejected {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-10 11:42:31 +02:00
|
|
|
</style>
|