aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/src/components/AuthTokenList.vue
blob: dbe3b9596d80cba52ead8af01fce157e9bc91b48 (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
<!--
  - SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: AGPL-3.0-or-later
-->

<template>
	<table id="app-tokens-table" class="token-list">
		<thead>
			<tr>
				<th class="token-list__header-device">
					{{ t('settings', 'Device') }}
				</th>
				<th class="toke-list__header-activity">
					{{ t('settings', 'Last activity') }}
				</th>
				<th>
					<span class="hidden-visually">
						{{ t('settings', 'Actions') }}
					</span>
				</th>
			</tr>
		</thead>
		<tbody class="token-list__body">
			<AuthToken v-for="token in sortedTokens"
				:key="token.id"
				:token="token" />
		</tbody>
	</table>
</template>

<script lang="ts">
import { translate as t } from '@nextcloud/l10n'
import { defineComponent } from 'vue'
import { useAuthTokenStore } from '../store/authtoken'

import AuthToken from './AuthToken.vue'

export default defineComponent({
	name: 'AuthTokenList',
	components: {
		AuthToken,
	},
	setup() {
		const authTokenStore = useAuthTokenStore()
		return { authTokenStore }
	},
	computed: {
		sortedTokens() {
			return [...this.authTokenStore.tokens].sort((t1, t2) => t2.lastActivity - t1.lastActivity)
		},
	},
	methods: {
		t,
	},
})
</script>

<style lang="scss" scoped>
.token-list {
	width: 100%;
	min-height: 50px;
	padding-top: 5px;
	max-width: fit-content;

	th {
		padding-block: 10px;
		padding-inline-start: 10px;
	}

	#{&}__header-device {
		padding-inline-start: 50px; // 44px icon + 6px padding
	}
	&__header-activity {
		text-align: end;
	}
}
</style>