summaryrefslogtreecommitdiff
path: root/src/client/widgets/notifications.vue
blob: 490c4d758f85267406c9ba060470e90c9a5afce9 (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
<template>
<MkContainer :style="`height: ${props.height}px;`" :show-header="props.showHeader" :scrollable="true">
	<template #header><Fa :icon="faBell"/>{{ $t('notifications') }}</template>
	<template #func><button @click="configure()" class="_button"><Fa :icon="faCog"/></button></template>

	<div>
		<XNotifications :include-types="props.includingTypes"/>
	</div>
</MkContainer>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { faBell, faCog } from '@fortawesome/free-solid-svg-icons';
import MkContainer from '@/components/ui/container.vue';
import XNotifications from '@/components/notifications.vue';
import define from './define';
import * as os from '@/os';

const widget = define({
	name: 'notifications',
	props: () => ({
		showHeader: {
			type: 'boolean',
			default: true,
		},
		height: {
			type: 'number',
			default: 300,
		},
		includingTypes: {
			type: 'array',
			hidden: true,
			default: null,
		},
	})
});

export default defineComponent({
	extends: widget,

	components: {
		MkContainer,
		XNotifications,
	},

	data() {
		return {
			faBell, faCog
		};
	},

	methods: {
		async configure() {
			os.popup(await import('@/components/notification-setting-window.vue'), {
				includingTypes: this.props.includingTypes,
			}, {
				done: async (res) => {
					const { includingTypes } = res;
					this.props.includingTypes = includingTypes;
					this.save();
				}
			}, 'closed');
		}
	}
});
</script>