2020-05-10 11:42:31 +02:00
|
|
|
<template>
|
2021-04-22 15:29:33 +02:00
|
|
|
<FormBase class="relaycxt">
|
|
|
|
<FormButton @click="addRelay" primary><i class="fas fa-plus"></i> {{ $ts.addRelay }}</FormButton>
|
2020-05-10 11:42:31 +02:00
|
|
|
|
2021-09-29 17:50:45 +02:00
|
|
|
<div class="_debobigegoItem" v-for="relay in relays" :key="relay.inbox">
|
|
|
|
<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-03-23 09:30:14 +01:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
2021-09-29 17:50:45 +02:00
|
|
|
import MkInput from '@client/components/form/input.vue';
|
|
|
|
import FormBase from '@client/components/debobigego/base.vue';
|
|
|
|
import FormButton from '@client/components/debobigego/button.vue';
|
2021-03-23 09:30:14 +01:00
|
|
|
import * as os from '@client/os';
|
2021-04-10 05:54:12 +02:00
|
|
|
import * as symbols from '@client/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',
|
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() {
|
|
|
|
const { canceled, result: inbox } = await os.dialog({
|
|
|
|
title: this.$ts.addRelay,
|
|
|
|
input: {
|
|
|
|
placeholder: this.$ts.inboxUrl
|
|
|
|
}
|
|
|
|
});
|
|
|
|
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) => {
|
2020-10-17 13:12:00 +02:00
|
|
|
os.dialog({
|
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) => {
|
2020-10-17 13:12:00 +02:00
|
|
|
os.dialog({
|
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>
|