summaryrefslogtreecommitdiff
path: root/src/client/pages/instance/queue.vue
blob: 031bda2bed8510ac55d75b2716502252b00802c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<FormBase>
	<XQueue :connection="connection" domain="inbox">
		<template #title>In</template>
	</XQueue>
	<XQueue :connection="connection" domain="deliver">
		<template #title>Out</template>
	</XQueue>
	<FormButton @click="clear()" danger><i class="fas fa-trash-alt"></i> {{ $ts.clearQueue }}</FormButton>
</FormBase>
</template>

<script lang="ts">
import { defineComponent, markRaw } from 'vue';
import MkButton from '@client/components/ui/button.vue';
import XQueue from './queue.chart.vue';
import FormBase from '@client/components/debobigego/base.vue';
import FormButton from '@client/components/debobigego/button.vue';
import * as os from '@client/os';
import * as symbols from '@client/symbols';

export default defineComponent({
	components: {
		FormBase,
		FormButton,
		MkButton,
		XQueue,
	},

	emits: ['info'],

	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.jobQueue,
				icon: 'fas fa-clipboard-list',
			},
			connection: markRaw(os.stream.useChannel('queueStats')),
		}
	},

	mounted() {
		this.$emit('info', this[symbols.PAGE_INFO]);

		this.$nextTick(() => {
			this.connection.send('requestLog', {
				id: Math.random().toString().substr(2, 8),
				length: 200
			});
		});
	},

	beforeUnmount() {
		this.connection.dispose();
	},

	methods: {
		clear() {
			os.dialog({
				type: 'warning',
				title: this.$ts.clearQueueConfirmTitle,
				text: this.$ts.clearQueueConfirmText,
				showCancelButton: true
			}).then(({ canceled }) => {
				if (canceled) return;

				os.apiWithDialog('admin/queue/clear', {});
			});
		}
	}
});
</script>