2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="900">
|
|
|
|
<div class="lknzcolw">
|
|
|
|
<div class="users">
|
|
|
|
<div class="inputs">
|
|
|
|
<MkSelect v-model="sort" style="flex: 1;">
|
|
|
|
<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>
|
|
|
|
<MkSelect v-model="state" style="flex: 1;">
|
|
|
|
<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>
|
|
|
|
<MkSelect v-model="origin" style="flex: 1;">
|
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkSelect>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
<div class="inputs">
|
|
|
|
<MkInput v-model="searchUsername" style="flex: 1;" type="text" spellcheck="false" @update:modelValue="$refs.users.reload()">
|
|
|
|
<template #prefix>@</template>
|
|
|
|
<template #label>{{ $ts.username }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="searchHost" style="flex: 1;" type="text" spellcheck="false" :disabled="pagination.params.origin === 'local'" @update:modelValue="$refs.users.reload()">
|
|
|
|
<template #prefix>@</template>
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
|
|
|
</MkInput>
|
2021-04-22 15:29:33 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
<MkPagination v-slot="{items}" ref="paginationComponent" :pagination="pagination" class="users">
|
2022-06-22 16:40:53 +02:00
|
|
|
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${new Date(user.updatedAt).toLocaleString()}`" class="user" :to="`/user-info/${user.id}`" :behavior="'window'">
|
|
|
|
<MkUserCardMini :user="user"/>
|
|
|
|
</MkA>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkPagination>
|
2021-04-22 15:29:33 +02:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-09 05:38:54 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2022-06-20 10:38:49 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { lookupUser } from '@/scripts/lookup-user';
|
2022-02-09 05:38:54 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-06-22 16:40:53 +02:00
|
|
|
import MkUserCardMini from '@/components/user-card-mini.vue';
|
2022-02-09 05:38:54 +01:00
|
|
|
|
|
|
|
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,
|
|
|
|
})),
|
2022-06-20 10:38:49 +02:00
|
|
|
offsetMode: true,
|
2022-02-09 05:38:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function searchUser() {
|
|
|
|
os.selectUser().then(user => {
|
|
|
|
show(user);
|
|
|
|
});
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-02-09 05:38:54 +01: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,
|
2022-06-20 10:38:49 +02:00
|
|
|
type: 'password',
|
2022-02-09 05:38:54 +01:00
|
|
|
});
|
|
|
|
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}`);
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
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,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.users,
|
|
|
|
icon: 'fas fa-users',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
})));
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 15:29:33 +02:00
|
|
|
.lknzcolw {
|
2020-01-29 20:37:25 +01:00
|
|
|
> .users {
|
2021-10-02 16:11:21 +02:00
|
|
|
|
|
|
|
> .inputs {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
margin-right: 16px;
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 15:29:33 +02:00
|
|
|
|
|
|
|
> .users {
|
|
|
|
margin-top: var(--margin);
|
2022-06-22 16:40:53 +02:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
|
|
|
|
grid-gap: 12px;
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-06-22 16:40:53 +02:00
|
|
|
> .user:hover {
|
|
|
|
text-decoration: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|