2020-05-10 11:42:31 +02:00
|
|
|
<template>
|
2021-04-22 15:29:33 +02:00
|
|
|
<FormBase class="relaycxt">
|
2021-11-19 11:36:12 +01:00
|
|
|
<FormButton primary @click="addRelay"><i class="fas fa-plus"></i> {{ $ts.addRelay }}</FormButton>
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-for="relay in relays" :key="relay.inbox" class="_debobigegoItem">
|
2021-09-29 17:50:45 +02:00
|
|
|
<div class="_debobigegoPanel" style="padding: 16px;">
|
2020-05-10 11:42:31 +02:00
|
|
|
<div>{{ relay.inbox }}</div>
|
|
|
|
<div>{{ $t(`_relayStatus.${relay.status}`) }}</div>
|
2021-04-22 15:29:33 +02:00
|
|
|
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="fas fa-trash-alt"></i> {{ $ts.remove }}</MkButton>
|
2020-05-10 11:42:31 +02:00
|
|
|
</div>
|
2021-04-22 15:29:33 +02:00
|
|
|
</div>
|
|
|
|
</FormBase>
|
2020-05-10 11:42:31 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import FormBase from '@/components/debobigego/base.vue';
|
|
|
|
import FormButton from '@/components/debobigego/button.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-05-10 11:42:31 +02:00
|
|
|
components: {
|
2021-04-22 15:29:33 +02:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
2020-05-10 11:42:31 +02:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
},
|
|
|
|
|
2021-04-22 15:29:33 +02:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-05-10 11:42:31 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 02:47:36 +01:00
|
|
|
title: this.$ts.relays,
|
2021-04-22 15:29:33 +02:00
|
|
|
icon: 'fas fa-globe',
|
2021-10-10 08:19:16 +02:00
|
|
|
bg: 'var(--bg)',
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2020-05-10 11:42:31 +02:00
|
|
|
relays: [],
|
|
|
|
inbox: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.refresh();
|
|
|
|
},
|
|
|
|
|
2021-04-22 15:29:33 +02:00
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-05-10 11:42:31 +02:00
|
|
|
methods: {
|
2021-04-22 15:29:33 +02:00
|
|
|
async addRelay() {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled, result: inbox } = await os.inputText({
|
2021-04-22 15:29:33 +02:00
|
|
|
title: this.$ts.addRelay,
|
2021-11-18 10:45:58 +01:00
|
|
|
type: 'url',
|
|
|
|
placeholder: this.$ts.inboxUrl
|
2021-04-22 15:29:33 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 13:12:00 +02:00
|
|
|
os.api('admin/relays/add', {
|
2020-05-10 11:42:31 +02:00
|
|
|
inbox
|
|
|
|
}).then((relay: any) => {
|
|
|
|
this.refresh();
|
2020-05-15 13:51:16 +02:00
|
|
|
}).catch((e: any) => {
|
2021-11-18 10:45:58 +01:00
|
|
|
os.alert({
|
2020-05-15 13:51:16 +02:00
|
|
|
type: 'error',
|
|
|
|
text: e.message || e
|
|
|
|
});
|
2020-05-10 11:42:31 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
remove(inbox: string) {
|
2020-10-17 13:12:00 +02:00
|
|
|
os.api('admin/relays/remove', {
|
2020-05-10 11:42:31 +02:00
|
|
|
inbox
|
|
|
|
}).then(() => {
|
|
|
|
this.refresh();
|
2020-05-15 13:51:16 +02:00
|
|
|
}).catch((e: any) => {
|
2021-11-18 10:45:58 +01:00
|
|
|
os.alert({
|
2020-05-15 13:51:16 +02:00
|
|
|
type: 'error',
|
|
|
|
text: e.message || e
|
|
|
|
});
|
2020-05-10 11:42:31 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
refresh() {
|
2020-10-17 13:12:00 +02:00
|
|
|
os.api('admin/relays/list').then((relays: any) => {
|
2020-05-10 11:42:31 +02:00
|
|
|
this.relays = relays;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2020-05-10 11:42:31 +02:00
|
|
|
</style>
|