summaryrefslogtreecommitdiff
path: root/packages/client/src/pages/admin/database.vue
blob: c1088afd775c52b27bfb9d9582c13d3ddfebbaf2 (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
<template>
<MkSpacer :content-max="800" :margin-min="16" :margin-max="32">
	<FormSuspense v-slot="{ result: database }" :p="databasePromiseFactory">
		<MkKeyValue v-for="table in database" :key="table[0]" oneline style="margin: 1em 0;">
			<template #key>{{ table[0] }}</template>
			<template #value>{{ bytes(table[1].size) }} ({{ number(table[1].count) }} recs)</template>
		</MkKeyValue>
	</FormSuspense>
</MkSpacer>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import FormSuspense from '@/components/form/suspense.vue';
import MkKeyValue from '@/components/key-value.vue';
import * as os from '@/os';
import * as symbols from '@/symbols';
import bytes from '@/filters/bytes';
import number from '@/filters/number';

export default defineComponent({
	components: {
		FormSuspense,
		MkKeyValue,
	},

	emits: ['info'],

	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.database,
				icon: 'fas fa-database',
				bg: 'var(--bg)',
			},
			databasePromiseFactory: () => os.api('admin/get-table-stats', {}).then(res => Object.entries(res).sort((a, b) => b[1].size - a[1].size)),
		}
	},

	mounted() {
		this.$emit('info', this[symbols.PAGE_INFO]);
	},

	methods: {
		bytes, number,
	}
});
</script>