2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-04-22 22:29:33 +09:00
|
|
|
<div class="lknzcolw">
|
|
|
|
<div class="users">
|
2021-10-02 23:11:21 +09:00
|
|
|
<div class="inputs">
|
|
|
|
<MkSelect v-model="sort" style="flex: 1;">
|
2021-04-22 22:29:33 +09:00
|
|
|
<template #label>{{ $ts.sort }}</template>
|
|
|
|
<option value="-createdAt">{{ $ts.registeredDate }} ({{ $ts.ascendingOrder }})</option>
|
|
|
|
<option value="+createdAt">{{ $ts.registeredDate }} ({{ $ts.descendingOrder }})</option>
|
|
|
|
<option value="-updatedAt">{{ $ts.lastUsed }} ({{ $ts.ascendingOrder }})</option>
|
|
|
|
<option value="+updatedAt">{{ $ts.lastUsed }} ({{ $ts.descendingOrder }})</option>
|
|
|
|
</MkSelect>
|
2021-10-02 23:11:21 +09:00
|
|
|
<MkSelect v-model="state" style="flex: 1;">
|
2021-04-22 22:29:33 +09:00
|
|
|
<template #label>{{ $ts.state }}</template>
|
|
|
|
<option value="all">{{ $ts.all }}</option>
|
|
|
|
<option value="available">{{ $ts.normal }}</option>
|
|
|
|
<option value="admin">{{ $ts.administrator }}</option>
|
|
|
|
<option value="moderator">{{ $ts.moderator }}</option>
|
|
|
|
<option value="silenced">{{ $ts.silence }}</option>
|
|
|
|
<option value="suspended">{{ $ts.suspend }}</option>
|
|
|
|
</MkSelect>
|
2021-10-02 23:11:21 +09:00
|
|
|
<MkSelect v-model="origin" style="flex: 1;">
|
2021-04-22 22:29:33 +09:00
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
</div>
|
2021-10-02 23:11:21 +09:00
|
|
|
<div class="inputs">
|
|
|
|
<MkInput v-model="searchUsername" style="flex: 1;" type="text" spellcheck="false" @update:modelValue="$refs.users.reload()">
|
2021-10-10 15:19:16 +09:00
|
|
|
<template #prefix>@</template>
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.username }}</template>
|
2021-04-22 22:29:33 +09:00
|
|
|
</MkInput>
|
2022-01-10 20:17:38 +09:00
|
|
|
<MkInput v-model="searchHost" style="flex: 1;" type="text" spellcheck="false" :disabled="pagination.params.origin === 'local'" @update:modelValue="$refs.users.reload()">
|
2021-10-10 15:19:16 +09:00
|
|
|
<template #prefix>@</template>
|
2021-08-06 22:29:19 +09:00
|
|
|
<template #label>{{ $ts.host }}</template>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkInput>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
|
2022-02-09 13:38:54 +09:00
|
|
|
<MkPagination v-slot="{items}" ref="paginationComponent" :pagination="pagination" class="users">
|
2021-11-19 19:36:12 +09:00
|
|
|
<button v-for="user in items" :key="user.id" class="user _panel _button _gap" @click="show(user)">
|
2021-04-22 22:29:33 +09:00
|
|
|
<MkAvatar class="avatar" :user="user" :disable-link="true" :show-indicator="true"/>
|
|
|
|
<div class="body">
|
|
|
|
<header>
|
|
|
|
<MkUserName class="name" :user="user"/>
|
|
|
|
<span class="acct">@{{ acct(user) }}</span>
|
2021-11-19 19:36:12 +09:00
|
|
|
<span v-if="user.isAdmin" class="staff"><i class="fas fa-bookmark"></i></span>
|
|
|
|
<span v-if="user.isModerator" class="staff"><i class="far fa-bookmark"></i></span>
|
|
|
|
<span v-if="user.isSilenced" class="punished"><i class="fas fa-microphone-slash"></i></span>
|
|
|
|
<span v-if="user.isSuspended" class="punished"><i class="fas fa-snowflake"></i></span>
|
2021-04-22 22:29:33 +09:00
|
|
|
</header>
|
|
|
|
<div>
|
|
|
|
<span>{{ $ts.lastUsed }}: <MkTime v-if="user.updatedAt" :time="user.updatedAt" mode="detail"/></span>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
2021-04-22 22:29:33 +09:00
|
|
|
<div>
|
|
|
|
<span>{{ $ts.registeredDate }}: <MkTime :time="user.createdAt" mode="detail"/></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</MkPagination>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-09 13:38:54 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import { acct } from '@/filters/user';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
|
|
|
import { lookupUser } from '@/scripts/lookup-user';
|
2022-02-09 13:38:54 +09:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
|
|
|
|
let paginationComponent = $ref<InstanceType<typeof MkPagination>>();
|
|
|
|
|
|
|
|
let sort = $ref('+createdAt');
|
|
|
|
let state = $ref('all');
|
|
|
|
let origin = $ref('local');
|
|
|
|
let searchUsername = $ref('');
|
|
|
|
let searchHost = $ref('');
|
|
|
|
const pagination = {
|
|
|
|
endpoint: 'admin/show-users' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
sort: sort,
|
|
|
|
state: state,
|
|
|
|
origin: origin,
|
|
|
|
username: searchUsername,
|
|
|
|
hostname: searchHost,
|
|
|
|
})),
|
|
|
|
offsetMode: true
|
|
|
|
};
|
|
|
|
|
|
|
|
function searchUser() {
|
|
|
|
os.selectUser().then(user => {
|
|
|
|
show(user);
|
|
|
|
});
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-02-09 13:38:54 +09:00
|
|
|
async function addUser() {
|
|
|
|
const { canceled: canceled1, result: username } = await os.inputText({
|
|
|
|
title: i18n.ts.username,
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
|
|
|
const { canceled: canceled2, result: password } = await os.inputText({
|
|
|
|
title: i18n.ts.password,
|
|
|
|
type: 'password'
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('admin/accounts/create', {
|
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
}).then(res => {
|
|
|
|
paginationComponent.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function show(user) {
|
|
|
|
os.pageWindow(`/user-info/${user.id}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: computed(() => ({
|
|
|
|
title: i18n.ts.users,
|
|
|
|
icon: 'fas fa-users',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
actions: [{
|
|
|
|
icon: 'fas fa-search',
|
|
|
|
text: i18n.ts.search,
|
|
|
|
handler: searchUser
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
text: i18n.ts.addUser,
|
|
|
|
handler: addUser
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-search',
|
|
|
|
text: i18n.ts.lookup,
|
|
|
|
handler: lookupUser
|
|
|
|
}],
|
|
|
|
})),
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 22:29:33 +09:00
|
|
|
.lknzcolw {
|
2020-01-30 04:37:25 +09:00
|
|
|
> .users {
|
2021-04-22 22:29:33 +09:00
|
|
|
margin: var(--margin);
|
2021-10-02 23:11:21 +09:00
|
|
|
|
|
|
|
> .inputs {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
margin-right: 16px;
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
|
|
|
> .users {
|
|
|
|
margin-top: var(--margin);
|
|
|
|
|
|
|
|
> .user {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
align-items: center;
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .avatar {
|
|
|
|
width: 60px;
|
|
|
|
height: 60px;
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .body {
|
|
|
|
margin-left: 0.3em;
|
|
|
|
padding: 0 8px;
|
|
|
|
flex: 1;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
font-size: 14px;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> header {
|
|
|
|
> .name {
|
|
|
|
font-weight: bold;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .acct {
|
|
|
|
margin-left: 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
2020-04-13 23:27:12 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .staff {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: var(--badge);
|
|
|
|
}
|
2020-04-13 23:27:12 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .punished {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
color: #4dabf7;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|