2020-06-11 17:13:21 +00:00
|
|
|
<template>
|
2020-06-25 09:36:35 +00:00
|
|
|
<div>
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li>
|
2020-11-30 09:24:11 +00:00
|
|
|
<router-link :to="{ name: RouteName.MODERATION }">{{
|
|
|
|
$t("Moderation")
|
|
|
|
}}</router-link>
|
2020-06-25 09:36:35 +00:00
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
2020-11-30 09:24:11 +00:00
|
|
|
<router-link :to="{ name: RouteName.USERS }">{{
|
|
|
|
$t("Users")
|
|
|
|
}}</router-link>
|
2020-06-25 09:36:35 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<div v-if="users">
|
|
|
|
<b-table
|
|
|
|
:data="users.elements"
|
|
|
|
:loading="$apollo.queries.users.loading"
|
|
|
|
paginated
|
|
|
|
backend-pagination
|
|
|
|
backend-filtering
|
|
|
|
detailed
|
2021-05-12 16:10:07 +00:00
|
|
|
:current-page.sync="page"
|
|
|
|
:aria-next-label="$t('Next page')"
|
|
|
|
:aria-previous-label="$t('Previous page')"
|
|
|
|
:aria-page-label="$t('Page')"
|
|
|
|
:aria-current-label="$t('Current page')"
|
2020-06-25 09:36:35 +00:00
|
|
|
:show-detail-icon="true"
|
|
|
|
:total="users.total"
|
|
|
|
:per-page="USERS_PER_PAGE"
|
2020-08-27 13:41:48 +00:00
|
|
|
:has-detailed-visible="(row) => row.actors.length > 0"
|
2020-06-25 09:36:35 +00:00
|
|
|
@page-change="onPageChange"
|
|
|
|
@filters-change="onFiltersChange"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
<b-table-column field="id" width="40" numeric v-slot="props">
|
|
|
|
{{ props.row.id }}
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="email" :label="$t('Email')" searchable>
|
2021-04-16 16:13:17 +00:00
|
|
|
<template #searchable="props">
|
2020-08-18 13:50:50 +00:00
|
|
|
<b-input
|
|
|
|
v-model="props.filters.email"
|
|
|
|
:placeholder="$t('Search…')"
|
|
|
|
icon="magnify"
|
|
|
|
size="is-small"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template v-slot:default="props">
|
2020-06-25 09:36:35 +00:00
|
|
|
<router-link
|
|
|
|
class="user-profile"
|
2020-11-30 09:24:11 +00:00
|
|
|
:to="{
|
|
|
|
name: RouteName.ADMIN_USER_PROFILE,
|
|
|
|
params: { id: props.row.id },
|
|
|
|
}"
|
2020-06-25 09:36:35 +00:00
|
|
|
:class="{ disabled: props.row.disabled }"
|
|
|
|
>
|
|
|
|
{{ props.row.email }}
|
|
|
|
</router-link>
|
2020-08-18 13:50:50 +00:00
|
|
|
</template>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column
|
|
|
|
field="confirmedAt"
|
|
|
|
:label="$t('Confirmed at')"
|
|
|
|
:centered="true"
|
|
|
|
v-slot="props"
|
|
|
|
>
|
|
|
|
<template v-if="props.row.confirmedAt">
|
|
|
|
{{ props.row.confirmedAt | formatDateTimeString }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ $t("Not confirmed") }}
|
|
|
|
</template>
|
|
|
|
</b-table-column>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-table-column
|
|
|
|
field="locale"
|
|
|
|
:label="$t('Language')"
|
|
|
|
:centered="true"
|
|
|
|
v-slot="props"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ props.row.locale }}
|
|
|
|
</b-table-column>
|
2020-06-25 09:36:35 +00:00
|
|
|
|
2021-04-16 16:13:17 +00:00
|
|
|
<template #detail="props">
|
2020-06-11 17:13:21 +00:00
|
|
|
<router-link
|
2020-06-25 09:36:35 +00:00
|
|
|
class="profile"
|
|
|
|
v-for="actor in props.row.actors"
|
|
|
|
:key="actor.id"
|
|
|
|
:to="{ name: RouteName.ADMIN_PROFILE, params: { id: actor.id } }"
|
2020-06-11 17:13:21 +00:00
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
<article class="media">
|
|
|
|
<figure class="media-left">
|
2020-08-18 13:50:50 +00:00
|
|
|
<p class="image is-32x32" v-if="actor.avatar">
|
2020-06-25 09:36:35 +00:00
|
|
|
<img :src="actor.avatar.url" />
|
|
|
|
</p>
|
2020-08-18 13:50:50 +00:00
|
|
|
<b-icon v-else size="is-medium" icon="account-circle" />
|
2020-06-25 09:36:35 +00:00
|
|
|
</figure>
|
|
|
|
<div class="media-content">
|
|
|
|
<div class="content">
|
|
|
|
<strong v-if="actor.name">{{ actor.name }}</strong>
|
|
|
|
<small>@{{ actor.preferredUsername }}</small>
|
|
|
|
<p>{{ actor.summary }}</p>
|
|
|
|
</div>
|
2020-06-11 17:13:21 +00:00
|
|
|
</div>
|
2020-06-25 09:36:35 +00:00
|
|
|
</article>
|
|
|
|
</router-link>
|
|
|
|
</template>
|
|
|
|
</b-table>
|
|
|
|
</div>
|
2020-06-11 17:13:21 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from "vue-property-decorator";
|
|
|
|
import { LIST_USERS } from "../../graphql/user";
|
|
|
|
import RouteName from "../../router/name";
|
2021-05-12 16:10:07 +00:00
|
|
|
import VueRouter from "vue-router";
|
|
|
|
const { isNavigationFailure, NavigationFailureType } = VueRouter;
|
2020-06-11 17:13:21 +00:00
|
|
|
|
|
|
|
const USERS_PER_PAGE = 10;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
users: {
|
|
|
|
query: LIST_USERS,
|
2020-08-27 09:53:24 +00:00
|
|
|
fetchPolicy: "cache-and-network",
|
2020-06-11 17:13:21 +00:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
email: this.email,
|
2021-05-12 16:10:07 +00:00
|
|
|
page: this.page,
|
2020-06-11 17:13:21 +00:00
|
|
|
limit: USERS_PER_PAGE,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Users extends Vue {
|
|
|
|
USERS_PER_PAGE = USERS_PER_PAGE;
|
2020-07-09 15:24:28 +00:00
|
|
|
|
2020-06-11 17:13:21 +00:00
|
|
|
RouteName = RouteName;
|
|
|
|
|
2021-05-12 16:10:07 +00:00
|
|
|
get page(): number {
|
|
|
|
return parseInt((this.$route.query.page as string) || "1", 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
set page(page: number) {
|
|
|
|
this.pushRouter({ page: page.toString() });
|
|
|
|
}
|
|
|
|
|
|
|
|
get email(): string {
|
|
|
|
return (this.$route.query.email as string) || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
set email(email: string) {
|
|
|
|
this.pushRouter({ email });
|
|
|
|
}
|
|
|
|
|
2020-11-27 18:27:44 +00:00
|
|
|
async onPageChange(page: number): Promise<void> {
|
2020-06-11 17:13:21 +00:00
|
|
|
this.page = page;
|
|
|
|
await this.$apollo.queries.users.fetchMore({
|
|
|
|
variables: {
|
|
|
|
email: this.email,
|
|
|
|
page: this.page,
|
|
|
|
limit: USERS_PER_PAGE,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-13 18:39:59 +00:00
|
|
|
onFiltersChange({ email }: { email: string }): void {
|
2020-06-11 17:13:21 +00:00
|
|
|
this.email = email;
|
|
|
|
}
|
2021-05-12 16:10:07 +00:00
|
|
|
|
|
|
|
private async pushRouter(args: Record<string, string>): Promise<void> {
|
|
|
|
try {
|
|
|
|
await this.$router.push({
|
|
|
|
name: RouteName.USERS,
|
|
|
|
query: { ...this.$route.query, ...args },
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
if (isNavigationFailure(e, NavigationFailureType.redirected)) {
|
|
|
|
throw Error(e.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-11 17:13:21 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-06-19 17:27:10 +00:00
|
|
|
a.profile,
|
|
|
|
a.user-profile {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
2020-06-11 17:13:21 +00:00
|
|
|
a.disabled {
|
|
|
|
color: $danger;
|
|
|
|
text-decoration: line-through;
|
|
|
|
}
|
|
|
|
</style>
|