summaryrefslogtreecommitdiff
path: root/src/client/pages/apps.vue
blob: 03c6707f950c03cc48a010430e60fb50638603ed (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
<div>
	<portal to="icon"><fa :icon="faPlug"/></portal>
	<portal to="title">{{ $t('installedApps') }}</portal>

	<mk-pagination :pagination="pagination" class="bfomjevm" ref="list">
		<template #empty>
			<div class="_fullinfo">
				<img src="https://xn--931a.moe/assets/info.jpg" class="_ghost"/>
				<div>{{ $t('nothing') }}</div>
			</div>
		</template>
		<template #default="{items}">
			<div class="token _panel" v-for="token in items" :key="token.id">
				<img class="icon" :src="token.iconUrl" alt=""/>
				<div class="body">
					<div class="name">{{ token.name }}</div>
					<div class="description">{{ token.description }}</div>
					<div class="_keyValue">
						<div>{{ $t('installedDate') }}:</div>
						<div><mk-time :time="token.createdAt"/></div>
					</div>
					<div class="_keyValue">
						<div>{{ $t('lastUsedDate') }}:</div>
						<div><mk-time :time="token.lastUsedAt"/></div>
					</div>
					<div class="actions">
						<button class="_button" @click="revoke(token)"><fa :icon="faTrashAlt"/></button>
					</div>
				</div>
			</div>
		</template>
	</mk-pagination>
</div>
</template>

<script lang="ts">
import Vue from 'vue';
import { faTrashAlt, faPlug } from '@fortawesome/free-solid-svg-icons';
import MkPagination from '../components/ui/pagination.vue';

export default Vue.extend({
	metaInfo() {
		return {
			title: this.$t('installedApps') as string
		};
	},

	components: {
		MkPagination
	},

	data() {
		return {
			pagination: {
				endpoint: 'i/apps',
				limit: 100,
				params: {
					sort: '+lastUsedAt'
				}
			},
			faTrashAlt, faPlug
		};
	},

	methods: {
		revoke(token) {
			this.$root.api('i/revoke-token', { tokenId: token.id }).then(() => {
				this.$refs.list.reload();
			});
		}
	}
});
</script>

<style lang="scss" scoped>
.bfomjevm {
	> .token {
		display: flex;
		padding: 16px;

		> .icon {
			display: block;
			flex-shrink: 0;
			margin: 0 12px 0 0;
			width: 50px;
			height: 50px;
			border-radius: 8px;
		}

		> .body {
			width: calc(100% - 62px);
			position: relative;

			> .name {
				font-weight: bold;
			}
		}
	}
}
</style>