2021-01-22 01:19:00 +08:00
|
|
|
<template>
|
2021-01-31 02:37:54 +08:00
|
|
|
<v-data-table
|
|
|
|
:headers="headers"
|
2021-03-28 06:41:20 +08:00
|
|
|
:items="users.result"
|
2021-01-31 02:37:54 +08:00
|
|
|
: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] }"
|
2021-03-26 11:58:47 +08:00
|
|
|
multi-sort
|
2021-01-31 02:37:54 +08:00
|
|
|
:loading="loading"
|
|
|
|
class="elevation-1"
|
2021-01-31 10:00:11 +08:00
|
|
|
>
|
2021-03-28 01:45:01 +08:00
|
|
|
<template #item.username="{ item }">
|
2021-03-29 04:40:13 +08:00
|
|
|
<NuxtLink :to="'/' + item.name">{{ item.name }}</NuxtLink>
|
2021-03-28 01:45:01 +08:00
|
|
|
</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-01-31 10:00:11 +08:00
|
|
|
<template #item.roles="{ item }">
|
2021-03-29 04:40:13 +08:00
|
|
|
<span v-for="role in item.roles" :key="role.roleId" :style="{ backgroundColor: role.color }" class="user-role-badge">{{ role.title }}</span>
|
2021-01-31 10:00:11 +08:00
|
|
|
</template>
|
2021-02-05 04:30:47 +08:00
|
|
|
<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>
|
2021-01-31 10:00:11 +08:00
|
|
|
</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';
|
2021-01-31 02:37:54 +08:00
|
|
|
import { Context } from '@nuxt/types';
|
|
|
|
import { PaginatedResult, User } from 'hangar-api';
|
2021-03-28 06:41:20 +08:00
|
|
|
import { DataTableHeader } from 'vuetify';
|
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 AuthorsPage extends UserListPage {
|
2021-03-29 04:10:41 +08:00
|
|
|
// TODO i18n for headers
|
2021-02-05 04:30:47 +08:00
|
|
|
headers: DataTableHeader[] = [
|
2021-03-26 11:58:47 +08:00
|
|
|
{ text: '', value: 'pic', sortable: false },
|
2021-03-28 01:45:01 +08:00
|
|
|
{ text: 'Username', value: 'username' },
|
2021-03-26 11:58:47 +08:00
|
|
|
{ text: 'Roles', value: 'roles', sortable: false },
|
2021-01-31 10:00:11 +08:00
|
|
|
{ text: 'Joined', value: 'joinDate' },
|
|
|
|
{ text: 'Projects', value: 'projectCount' },
|
2021-01-31 02:37:54 +08:00
|
|
|
];
|
|
|
|
|
2021-02-08 07:19:16 +08:00
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
title: this.$t('pages.authors'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-03-28 06:41:20 +08:00
|
|
|
get url(): string {
|
|
|
|
return 'authors';
|
2021-01-31 02:37:54 +08:00
|
|
|
}
|
|
|
|
|
2021-03-28 06:41:20 +08:00
|
|
|
async asyncData({ $api, $util }: Context) {
|
|
|
|
const users = await $api.request<PaginatedResult<User>>('authors', false).catch<any>($util.handlePageRequestError);
|
|
|
|
return { users };
|
2021-01-31 02:37:54 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-22 01:19:00 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|