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