Hangar/frontend/pages/authors.vue

67 lines
2.1 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] }"
2021-03-26 11:58:47 +08:00
multi-sort
: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 }">
<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 }">
<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';
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' },
];
head() {
return {
title: this.$t('pages.authors'),
};
}
2021-03-28 06:41:20 +08:00
get url(): string {
return 'authors';
}
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-22 01:19:00 +08:00
</script>
<style lang="scss" scoped></style>