summaryrefslogtreecommitdiff
path: root/packages/client/src/pages/admin/queue.vue
blob: 656b18199fb7f1d9f3670de7cc3e3c654e9978f0 (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
<template>
<MkSpacer :content-max="800">
	<XQueue :connection="connection" domain="inbox">
		<template #title>In</template>
	</XQueue>
	<XQueue :connection="connection" domain="deliver">
		<template #title>Out</template>
	</XQueue>
	<MkButton danger @click="clear()"><i class="fas fa-trash-alt"></i> {{ i18n.ts.clearQueue }}</MkButton>
</MkSpacer>
</template>

<script lang="ts" setup>
import { markRaw, onMounted, onBeforeUnmount, nextTick } from 'vue';
import MkButton from '@/components/ui/button.vue';
import XQueue from './queue.chart.vue';
import * as os from '@/os';
import { stream } from '@/stream';
import * as symbols from '@/symbols';
import * as config from '@/config';
import { i18n } from '@/i18n';

const connection = markRaw(stream.useChannel('queueStats'));

function clear() {
	os.confirm({
		type: 'warning',
		title: i18n.ts.clearQueueConfirmTitle,
		text: i18n.ts.clearQueueConfirmText,
	}).then(({ canceled }) => {
		if (canceled) return;

		os.apiWithDialog('admin/queue/clear');
	});
}

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

onBeforeUnmount(() => {
	connection.dispose();
});

defineExpose({
	[symbols.PAGE_INFO]: {
		title: i18n.ts.jobQueue,
		icon: 'fas fa-clipboard-list',
		bg: 'var(--bg)',
		actions: [{
			asFullButton: true,
			icon: 'fas fa-up-right-from-square',
			text: i18n.ts.dashboard,
			handler: () => {
				window.open(config.url + '/queue', '_blank');
			},
		}],
	}
});
</script>