summaryrefslogtreecommitdiff
path: root/src/client/pages/instance/queue.vue
blob: 7a2204e5198ec8c75b482b6d1404cb4100ee5370 (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
73
74
75
76
77
78
79
<template>
<div>
	<portal to="icon"><fa :icon="faExchangeAlt"/></portal>
	<portal to="title">{{ $t('jobQueue') }}</portal>

	<x-queue :connection="connection" domain="inbox">
		<template #title><fa :icon="faExchangeAlt"/> In</template>
	</x-queue>
	<x-queue :connection="connection" domain="deliver">
		<template #title><fa :icon="faExchangeAlt"/> Out</template>
	</x-queue>
	<section class="_card">
		<div class="_content">
			<mk-button @click="clear()"><fa :icon="faTrashAlt"/> {{ $t('clearQueue') }}</mk-button>
		</div>
	</section>
</div>
</template>

<script lang="ts">
import Vue from 'vue';
import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import MkButton from '../../components/ui/button.vue';
import XQueue from './queue.queue.vue';

export default Vue.extend({
	metaInfo() {
		return {
			title: `${this.$t('jobQueue')} | ${this.$t('instance')}`
		};
	},

	components: {
		MkButton,
		XQueue,
	},

	data() {
		return {
			connection: this.$root.stream.useSharedConnection('queueStats'),
			faExchangeAlt, faTrashAlt
		}
	},

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

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

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

				this.$root.api('admin/queue/clear', {}).then(() => {
					this.$root.dialog({
						type: 'success',
						iconOnly: true, autoClose: true
					});
				});
			});
		}
	}
});
</script>