2020-10-29 15:41:40 -07:00
|
|
|
<template>
|
2020-12-30 15:03:30 -08:00
|
|
|
<NotFound v-if="!$isGranted('panel') && !$isGranted('users')"/>
|
2020-11-16 11:43:44 -08:00
|
|
|
<div v-else>
|
2020-10-29 15:41:40 -07:00
|
|
|
<h2>
|
|
|
|
<Icon v="user-cog"/>
|
|
|
|
<T>admin.header</T>
|
|
|
|
</h2>
|
|
|
|
|
2021-06-09 23:45:13 -07:00
|
|
|
<p>Stats counted: {{$datetime(stats.calculatedAt)}}</p>
|
|
|
|
|
2020-12-30 15:03:30 -08:00
|
|
|
<section v-if="$isGranted('users')">
|
2021-11-26 10:51:45 -08:00
|
|
|
<details class="border mb-3" @click="usersShown = true">
|
2020-11-24 16:11:17 -08:00
|
|
|
<summary class="bg-light p-3">
|
|
|
|
<Icon v="users"/>
|
|
|
|
Users
|
2021-11-26 10:37:35 -08:00
|
|
|
({{stats.users.overall}} overall, {{stats.users.admins}} admins)
|
2020-11-24 16:11:17 -08:00
|
|
|
</summary>
|
2021-11-26 10:51:45 -08:00
|
|
|
<div class="border-top" v-if="usersShown">
|
2021-11-26 10:37:35 -08:00
|
|
|
<div class="input-group mt-4">
|
|
|
|
<input class="form-control" v-model="userFilter" :placeholder="$t('crud.filterLong')"/>
|
|
|
|
<button :class="['btn', adminsFilter ? 'btn-secondary' : 'btn-outline-secondary']"
|
|
|
|
@click="adminsFilter = !adminsFilter"
|
|
|
|
>
|
|
|
|
Only admins
|
|
|
|
</button>
|
|
|
|
<button :class="['btn', localeFilter ? 'btn-secondary' : 'btn-outline-secondary']"
|
|
|
|
@click="localeFilter = !localeFilter"
|
|
|
|
>
|
|
|
|
Only this version
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<ServerTable
|
|
|
|
endpoint="/admin/users"
|
|
|
|
:query="{filter: userFilterDelayed || undefined, localeFilter: localeFilter || undefined, adminsFilter: adminsFilter || undefined}"
|
2021-12-11 01:58:13 -08:00
|
|
|
:columns="5"
|
2021-11-26 10:37:35 -08:00
|
|
|
count
|
|
|
|
>
|
|
|
|
<template v-slot:header>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>admin.user.user</T>
|
|
|
|
</th>
|
2021-12-11 01:58:13 -08:00
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>admin.user.createdAt</T>
|
|
|
|
</th>
|
2021-11-26 10:37:35 -08:00
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>admin.user.email</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>admin.user.roles</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>admin.user.profiles</T>
|
|
|
|
</th>
|
|
|
|
</template>
|
2020-10-29 15:41:40 -07:00
|
|
|
|
2021-11-26 10:37:35 -08:00
|
|
|
<template v-slot:row="s">
|
|
|
|
<td>
|
2021-11-26 11:06:21 -08:00
|
|
|
<a :href="'https://pronouns.page/@' + s.el.username">@{{s.el.username}}</a>
|
2021-11-26 10:37:35 -08:00
|
|
|
</td>
|
2021-12-11 01:58:13 -08:00
|
|
|
<td>
|
|
|
|
{{$datetime($ulidTime(s.el.id))}}
|
|
|
|
</td>
|
2021-11-26 10:37:35 -08:00
|
|
|
<td>
|
|
|
|
<p>
|
|
|
|
<a :href="`mailto:${s.el.email}`" target="_blank" rel="noopener">
|
|
|
|
{{s.el.email}}
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
<!--
|
|
|
|
<ul v-if="s.el.socialConnections.length" class="list-inline">
|
|
|
|
<li v-for="conn in s.el.socialConnections" class="list-inline-item">
|
|
|
|
<Icon :v="socialProviders[conn].icon || conn" set="b"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
-->
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Roles :user="s.el"/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<ul class="list-unstyled">
|
|
|
|
<li v-for="locale in s.el.profiles" v-if="locales[locale]">
|
|
|
|
<LocaleLink :link="`/@${s.el.username}`" :locale="locale">
|
|
|
|
{{ locales[locale].name }}
|
|
|
|
</LocaleLink>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</td>
|
|
|
|
</template>
|
|
|
|
</ServerTable>
|
2020-11-24 16:11:17 -08:00
|
|
|
</div>
|
|
|
|
</details>
|
|
|
|
</section>
|
|
|
|
|
2021-04-10 04:04:16 -07:00
|
|
|
<ChartSet name="users" :data="stats.users.chart" init="cumulative"/>
|
2021-04-08 15:43:57 -07:00
|
|
|
|
2022-01-03 08:45:18 -08:00
|
|
|
<Chart label="number of profiles by locale" :data="profilesByLocale" type="bar" :options="{
|
|
|
|
indexAxis: 'y',
|
|
|
|
responsive: true,
|
|
|
|
interaction: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'y',
|
|
|
|
},
|
|
|
|
}"/>
|
2021-09-09 01:46:17 -07:00
|
|
|
|
2021-07-11 04:01:56 -07:00
|
|
|
<section>
|
|
|
|
<Icon v="id-card"/>
|
2021-10-14 05:49:21 -07:00
|
|
|
Cards in queue for generation:
|
|
|
|
{{ stats.cardsQueue }}
|
2021-07-11 04:01:56 -07:00
|
|
|
</section>
|
|
|
|
|
2021-11-28 03:19:37 -08:00
|
|
|
<section>
|
|
|
|
<Icon v="user-secret"/>
|
|
|
|
Impersonate <button class="btn btn-primary btn-sm" @click="impersonate('example@pronouns.page')">@example</button>
|
|
|
|
</section>
|
|
|
|
|
2021-07-24 10:18:39 -07:00
|
|
|
<section v-if="$isGranted('users')">
|
2021-06-16 07:48:24 -07:00
|
|
|
<h3>
|
|
|
|
<Icon v="siren-on"/>
|
2021-07-24 10:18:39 -07:00
|
|
|
Abuse reports
|
2021-06-16 07:48:24 -07:00
|
|
|
</h3>
|
2021-07-24 10:18:39 -07:00
|
|
|
<Table :data="abuseReports" :columns="4">
|
|
|
|
<template v-slot:header>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
Suspicious account
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
Reported by
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
Comment
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
Action
|
|
|
|
</th>
|
|
|
|
</template>
|
|
|
|
|
2022-01-08 05:38:42 -08:00
|
|
|
<template v-slot:row="s"><template v-if="s && s.el.susUsername">
|
2021-06-16 07:48:24 -07:00
|
|
|
<td>
|
2021-07-24 10:43:17 -07:00
|
|
|
<a :href="`https://pronouns.page/@${s.el.susUsername}`" target="_blank" rel="noopener">@{{s.el.susUsername}}</a>
|
2021-07-24 10:18:39 -07:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span v-if="s.el.isAutomatic" class="badge bg-info">
|
|
|
|
Keyword found
|
|
|
|
</span>
|
2021-07-24 10:43:17 -07:00
|
|
|
<a v-else :href="`https://pronouns.page/@${s.el.reporterUsername}`" target="_blank" rel="noopener">@{{s.el.reporterUsername}}</a>
|
2021-07-24 10:18:39 -07:00
|
|
|
<small>({{$datetime($ulidTime(s.el.id))}})</small>
|
|
|
|
</td>
|
2022-01-08 05:38:42 -08:00
|
|
|
<td class="small" v-html="s.el.isAutomatic ? formatComment(s.el.comment) : s.el.comment"></td>
|
2021-06-16 07:48:24 -07:00
|
|
|
<td>
|
2021-07-24 10:18:39 -07:00
|
|
|
<span v-if="s.el.isHandled" class="badge bg-success">
|
|
|
|
Case closed
|
|
|
|
</span>
|
|
|
|
<a v-else href="#" class="badge bg-light text-success border border-success"
|
|
|
|
@click.prevent="handleReport(s.el.id)"
|
2021-06-16 07:48:24 -07:00
|
|
|
>
|
|
|
|
<Icon v="thumbs-up"/>
|
|
|
|
I checked the profile, it's OK.
|
|
|
|
</a>
|
|
|
|
</td>
|
|
|
|
</template></template>
|
|
|
|
</Table>
|
|
|
|
</section>
|
|
|
|
|
2020-11-24 16:11:17 -08:00
|
|
|
<section v-for="(locale, k) in stats.locales" :key="k">
|
|
|
|
<details class="border mb-3" open>
|
|
|
|
<summary class="bg-light p-3">
|
|
|
|
<LocaleLink :locale="k" link="/">{{locale.name}}</LocaleLink>
|
|
|
|
</summary>
|
|
|
|
<div class="p-3 border-top d-flex justify-content-between flex-column flex-md-row">
|
|
|
|
<div class="flex-grow-1">
|
|
|
|
<h4 class="h5">
|
|
|
|
<Icon v="id-card"/>
|
|
|
|
Profiles
|
|
|
|
</h4>
|
|
|
|
{{locale.profiles}}
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow-1">
|
|
|
|
<h4 class="h5">
|
|
|
|
<Icon v="tags"/>
|
|
|
|
Pronouns
|
|
|
|
</h4>
|
2020-11-27 11:30:21 -08:00
|
|
|
<ListExpandable :data="locale.pronouns"/>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow-1">
|
|
|
|
<h4 class="h5">
|
|
|
|
<Icon v="flag"/>
|
|
|
|
Flags
|
|
|
|
</h4>
|
|
|
|
<ListExpandable :data="locale.flags"/>
|
2020-11-24 16:11:17 -08:00
|
|
|
</div>
|
|
|
|
<div class="flex-grow-1">
|
|
|
|
<h4 class="h5">
|
|
|
|
<Icon v="atom-alt"/>
|
|
|
|
Dictionary
|
|
|
|
</h4>
|
|
|
|
<ul class="list-unstyled">
|
|
|
|
<li>
|
|
|
|
<strong>Approved</strong>: {{locale.nouns.approved}}
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<strong>Awaiting</strong>: {{locale.nouns.awaiting}}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-08 15:43:57 -07:00
|
|
|
<div class="p-3 border-top">
|
2021-04-10 04:04:16 -07:00
|
|
|
<ChartSet name="profiles" :data="locale.chart"/>
|
2021-04-08 15:43:57 -07:00
|
|
|
</div>
|
2020-11-24 16:11:17 -08:00
|
|
|
</details>
|
|
|
|
</section>
|
2020-10-29 15:41:40 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-11-26 10:37:35 -08:00
|
|
|
import {head} from "../src/helpers";
|
2021-12-14 06:15:27 -08:00
|
|
|
import {socialProviders} from "../src/socialProviders";
|
2020-10-29 15:41:40 -07:00
|
|
|
|
|
|
|
export default {
|
2020-11-02 12:45:45 -08:00
|
|
|
data() {
|
2020-11-27 11:30:21 -08:00
|
|
|
return {
|
|
|
|
socialProviders,
|
2020-12-22 02:05:33 -08:00
|
|
|
userFilter: '',
|
2021-11-26 08:08:10 -08:00
|
|
|
userFilterDelayed: '',
|
|
|
|
userFilterDelayHandle: undefined,
|
2020-12-30 15:03:30 -08:00
|
|
|
localeFilter: true,
|
|
|
|
adminsFilter: false,
|
2021-11-26 10:51:45 -08:00
|
|
|
usersShown: false,
|
2020-11-27 11:30:21 -08:00
|
|
|
}
|
2020-11-02 12:45:45 -08:00
|
|
|
},
|
2020-10-29 15:41:40 -07:00
|
|
|
async asyncData({ app, store }) {
|
2020-12-30 15:03:30 -08:00
|
|
|
let stats = { users: {}};
|
|
|
|
try {
|
|
|
|
stats = await app.$axios.$get(`/admin/stats`);
|
|
|
|
} catch {}
|
2020-11-24 16:11:17 -08:00
|
|
|
|
2021-07-24 10:18:39 -07:00
|
|
|
let abuseReports = [];
|
2021-06-16 07:48:24 -07:00
|
|
|
try {
|
2021-07-24 10:18:39 -07:00
|
|
|
abuseReports = await app.$axios.$get(`/admin/reports`);
|
2021-06-16 07:48:24 -07:00
|
|
|
} catch {}
|
|
|
|
|
2020-10-29 15:41:40 -07:00
|
|
|
return {
|
2020-11-24 16:11:17 -08:00
|
|
|
stats,
|
2021-07-24 10:18:39 -07:00
|
|
|
abuseReports,
|
2020-10-29 15:41:40 -07:00
|
|
|
};
|
|
|
|
},
|
2021-04-04 17:39:58 -07:00
|
|
|
methods: {
|
2021-07-24 10:18:39 -07:00
|
|
|
async handleReport(id) {
|
|
|
|
await this.$confirm('Are you sure you want to mark this report as handled?', 'success');
|
|
|
|
await this.$post(`/admin/reports/handle/${id}`);
|
|
|
|
this.abuseReports = this.abuseReports.map(r => {
|
|
|
|
if (r.id === id) { r.isHandled = true; }
|
|
|
|
return r;
|
|
|
|
});
|
2021-06-16 07:48:24 -07:00
|
|
|
},
|
2021-11-28 03:19:37 -08:00
|
|
|
async impersonate(email) {
|
|
|
|
const { token } = await this.$axios.$get(`/admin/impersonate/${encodeURIComponent(email)}`);
|
|
|
|
this.$cookies.set('impersonator', this.$cookies.get('token'));
|
|
|
|
this.$cookies.set('token', token);
|
|
|
|
this.$router.push('/' + this.config.user.route);
|
|
|
|
setTimeout(() => window.location.reload(), 500);
|
|
|
|
},
|
2022-01-08 05:38:42 -08:00
|
|
|
formatComment(comment) {
|
|
|
|
return comment
|
|
|
|
.split(', ')
|
|
|
|
.map(x => x.replace(/^(.*) \((.*)\)$/, '<dfn title="$2">$1</dfn>'))
|
|
|
|
.join(', ');
|
|
|
|
},
|
2021-11-26 08:08:10 -08:00
|
|
|
},
|
|
|
|
computed: {
|
2021-09-09 01:46:17 -07:00
|
|
|
profilesByLocale() {
|
|
|
|
const r = {};
|
|
|
|
for (let locale of Object.values(this.stats.locales).sort((a, b) => b.profiles - a.profiles)) {
|
|
|
|
r[locale.name] = locale.profiles;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
},
|
2020-12-22 02:05:33 -08:00
|
|
|
},
|
2021-11-26 08:08:10 -08:00
|
|
|
watch: {
|
|
|
|
userFilter() {
|
|
|
|
if (this.userFilterDelayHandle !== undefined) {
|
|
|
|
clearInterval(this.userFilterDelayHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.userFilterDelayHandle = setTimeout(() => {
|
|
|
|
this.userFilterDelayed = this.userFilter;
|
|
|
|
}, 500);
|
|
|
|
},
|
|
|
|
},
|
2020-10-29 15:41:40 -07:00
|
|
|
head() {
|
|
|
|
return head({
|
|
|
|
title: this.$t('admin.header'),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|