π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
<template>
<div class="page-card">
<header>
<h1>{{ t('admin.users.title') }}</h1>
</header>
<DataTable v-if="rows?.length" :headers="headers" :rows="rows || []">
<template #username="{ cell }"> <UserAvatar :user="cell?.data as User" /> {{ (cell?.data as User).username }} </template>
<template #action="{ cell }">
<NuxtLink :to="`/dashboard/admin/users/${(cell?.data as User).id}`"><Icon name="view" /></NuxtLink>
</template>
</DataTable>
<div v-else>{{ t('admin.users.noUsers') }}</div>
</div>
</template>
<script setup lang="ts">
import { useAdminStore } from '~/stores/admin.store';
import type { User } from '~/stores';
const adminStore = useAdminStore();
const { t } = useI18nT();
const { numericDate } = useDateFormatters();
const headers = computed(() => [
{ label: t('admin.users.headers.name'), key: 'username' },
{ label: t('admin.users.headers.firstname'), key: 'firstname' },
{ label: t('admin.users.headers.lastname'), key: 'lastname' },
{ label: t('admin.users.headers.email'), key: 'email' },
{ label: t('admin.users.headers.role'), key: 'role' },
{ label: t('admin.users.headers.createdAt'), key: 'created_at' },
{ label: t('admin.users.headers.action'), key: 'action' },
]);
const rows = computed(() =>
adminStore.users?.map(u => {
return {
username: {
type: 'slot' as const,
data: u,
},
firstname: { content: u.firstname, type: 'text' as const },
lastname: { content: u.lastname, type: 'text' as const },
email: { content: u.email, type: 'text' as const },
role: { content: u.role == 2 ? `<tag class="red">Admin</tag>` : `<tag class="blue">User</tag>`, type: 'html' as const },
created_at: { content: numericDate(u.created_timestamp), type: 'text' as const },
action: { type: 'slot' as const, data: { id: u.id } },
};
}),
);
</script>