2020-05-10 09:42:31 +00:00
|
|
|
<template>
|
2021-04-22 13:29:33 +00:00
|
|
|
<FormBase class="relaycxt">
|
|
|
|
<FormButton @click="addRelay" primary><i class="fas fa-plus"></i> {{ $ts.addRelay }}</FormButton>
|
2020-05-10 09:42:31 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
<div class="_formItem" v-for="relay in relays" :key="relay.inbox">
|
|
|
|
<div class="_formPanel" style="padding: 16px;">
|
2020-05-10 09:42:31 +00:00
|
|
|
<div>{{ relay.inbox }}</div>
|
|
|
|
<div>{{ $t(`_relayStatus.${relay.status}`) }}</div>
|
2021-04-22 13:29:33 +00:00
|
|
|
<MkButton class="button" inline danger @click="remove(relay.inbox)"><i class="fas fa-trash-alt"></i> {{ $ts.remove }}</MkButton>
|
2020-05-10 09:42:31 +00:00
|
|
|
</div>
|
2021-04-22 13:29:33 +00:00
|
|
|
</div>
|
|
|
|
</FormBase>
|
2020-05-10 09:42:31 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
2021-04-22 13:29:33 +00:00
|
|
|
import FormBase from '@client/components/form/base.vue';
|
|
|
|
import FormButton from '@client/components/form/button.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import * as os from '@client/os';
|
2021-04-10 03:54:12 +00:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-05-10 09:42:31 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-05-10 09:42:31 +00:00
|
|
|
components: {
|
2021-04-22 13:29:33 +00:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
2020-05-10 09:42:31 +00:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-05-10 09:42:31 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 03:54:12 +00:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.relays,
|
2021-04-22 13:29:33 +00:00
|
|
|
icon: 'fas fa-globe',
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
2020-05-10 09:42:31 +00:00
|
|
|
relays: [],
|
|
|
|
inbox: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.refresh();
|
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-05-10 09:42:31 +00:00
|
|
|
methods: {
|
2021-04-22 13:29:33 +00: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 11:12:00 +00:00
|
|
|
os.api('admin/relays/add', {
|
2020-05-10 09:42:31 +00:00
|
|
|
inbox
|
|
|
|
}).then((relay: any) => {
|
|
|
|
this.refresh();
|
2020-05-15 11:51:16 +00:00
|
|
|
}).catch((e: any) => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-05-15 11:51:16 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e.message || e
|
|
|
|
});
|
2020-05-10 09:42:31 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
remove(inbox: string) {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('admin/relays/remove', {
|
2020-05-10 09:42:31 +00:00
|
|
|
inbox
|
|
|
|
}).then(() => {
|
|
|
|
this.refresh();
|
2020-05-15 11:51:16 +00:00
|
|
|
}).catch((e: any) => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-05-15 11:51:16 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e.message || e
|
|
|
|
});
|
2020-05-10 09:42:31 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
refresh() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('admin/relays/list').then((relays: any) => {
|
2020-05-10 09:42:31 +00:00
|
|
|
this.relays = relays;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 13:29:33 +00:00
|
|
|
|
2020-05-10 09:42:31 +00:00
|
|
|
</style>
|