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>
|
|
|
|
<router-link :to="{ name: RouteName.MODERATION }">{{ $t("Moderation") }}</router-link>
|
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
|
|
|
<router-link :to="{ name: RouteName.USERS }">{{ $t("Users") }}</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<div v-if="users">
|
|
|
|
<b-table
|
|
|
|
:data="users.elements"
|
|
|
|
:loading="$apollo.queries.users.loading"
|
|
|
|
paginated
|
|
|
|
backend-pagination
|
|
|
|
backend-filtering
|
|
|
|
detailed
|
|
|
|
: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>
|
|
|
|
<template slot="searchable" slot-scope="props">
|
|
|
|
<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"
|
|
|
|
:to="{ name: RouteName.ADMIN_USER_PROFILE, params: { id: props.row.id } }"
|
|
|
|
: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>
|
|
|
|
<b-table-column field="locale" :label="$t('Language')" :centered="true" v-slot="props">
|
|
|
|
{{ props.row.locale }}
|
|
|
|
</b-table-column>
|
2020-06-25 09:36:35 +00:00
|
|
|
|
|
|
|
<template slot="detail" slot-scope="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";
|
|
|
|
|
|
|
|
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,
|
|
|
|
page: 1,
|
|
|
|
limit: USERS_PER_PAGE,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Users extends Vue {
|
|
|
|
page = 1;
|
2020-07-09 15:24:28 +00:00
|
|
|
|
2020-06-11 17:13:21 +00:00
|
|
|
email = "";
|
|
|
|
|
|
|
|
USERS_PER_PAGE = USERS_PER_PAGE;
|
2020-07-09 15:24:28 +00:00
|
|
|
|
2020-06-11 17:13:21 +00:00
|
|
|
RouteName = RouteName;
|
|
|
|
|
|
|
|
async onPageChange(page: number) {
|
|
|
|
this.page = page;
|
|
|
|
await this.$apollo.queries.users.fetchMore({
|
|
|
|
variables: {
|
|
|
|
email: this.email,
|
|
|
|
page: this.page,
|
|
|
|
limit: USERS_PER_PAGE,
|
|
|
|
},
|
|
|
|
updateQuery: (previousResult, { fetchMoreResult }) => {
|
|
|
|
if (!fetchMoreResult) return previousResult;
|
|
|
|
const newFollowings = fetchMoreResult.users.elements;
|
|
|
|
return {
|
|
|
|
users: {
|
|
|
|
__typename: previousResult.users.__typename,
|
|
|
|
total: previousResult.users.total,
|
|
|
|
elements: [...previousResult.users.elements, ...newFollowings],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-13 18:39:59 +00:00
|
|
|
onFiltersChange({ email }: { email: string }): void {
|
2020-06-11 17:13:21 +00:00
|
|
|
this.email = email;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</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>
|