Hangar/frontend/pages/staff.vue

65 lines
1.9 KiB
Vue
Raw Normal View History

2021-01-22 01:19:00 +08:00
<template>
<v-data-table
:headers="headers"
2021-03-28 06:41:20 +08:00
:items="users.result"
:options.sync="options"
2021-03-28 06:41:20 +08:00
:server-items-length="users.pagination.count"
:items-per-page="25"
:footer-props="{ itemsPerPageOptions: [5, 15, 25] }"
multi-sort
:loading="loading"
class="elevation-1"
2021-02-05 04:30:47 +08:00
>
2021-03-28 06:41:20 +08:00
<template #item.username="{ item }">
{{ item.name }}
</template>
2021-02-11 19:01:45 +08:00
<template #item.pic="{ item }">
<UserAvatar :username="item.name" :avatar-url="$util.avatarUrl(item.name)" clazz="user-avatar-xs" />
</template>
2021-02-05 04:30:47 +08:00
<template #item.roles="{ item }">
{{ item.roles.map((r) => r.title).join(', ') }}
</template>
<template #item.joinDate="{ item }">
2021-02-11 19:01:45 +08:00
{{ $util.prettyDate(item.joinDate) }}
2021-02-05 04:30:47 +08:00
</template>
</v-data-table>
2021-01-22 01:19:00 +08:00
</template>
<script lang="ts">
2021-03-28 06:41:20 +08:00
import { Component } from 'nuxt-property-decorator';
import { PaginatedResult, User } from 'hangar-api';
2021-03-28 06:41:20 +08:00
import { DataTableHeader } from 'vuetify';
import { Context } from '@nuxt/types';
2021-03-20 15:24:17 +08:00
import { UserAvatar } from '~/components/users';
2021-03-28 06:41:20 +08:00
import { UserListPage } from '~/components/mixins';
2021-02-13 14:36:53 +08:00
2021-02-11 19:01:45 +08:00
@Component({
components: { UserAvatar },
})
2021-03-28 06:41:20 +08:00
export default class StaffPage extends UserListPage {
2021-02-05 04:30:47 +08:00
headers: DataTableHeader[] = [
2021-03-28 06:41:20 +08:00
{ text: '', value: 'pic', sortable: false },
{ text: 'Username', value: 'username' },
{ text: 'Roles', value: 'roles', sortable: false },
2021-02-05 04:30:47 +08:00
{ text: 'Joined', value: 'joinDate' },
];
head() {
return {
title: this.$t('pages.staff'),
};
}
2021-03-28 06:41:20 +08:00
get url(): string {
return 'staff';
}
2021-03-28 06:41:20 +08:00
async asyncData({ $api, $util }: Context) {
const users = await $api.request<PaginatedResult<User>>('staff', false).catch<any>($util.handlePageRequestError);
return { users };
}
}
2021-01-22 01:19:00 +08:00
</script>
<style lang="scss" scoped></style>