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