2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
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>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSpacer :contentMax="900">
|
2023-03-02 06:38:45 +01:00
|
|
|
<div class="_gaps">
|
|
|
|
<div :class="$style.inputs">
|
|
|
|
<MkSelect v-model="sort" style="flex: 1;">
|
|
|
|
<template #label>{{ i18n.ts.sort }}</template>
|
|
|
|
<option value="-createdAt">{{ i18n.ts.registeredDate }} ({{ i18n.ts.ascendingOrder }})</option>
|
|
|
|
<option value="+createdAt">{{ i18n.ts.registeredDate }} ({{ i18n.ts.descendingOrder }})</option>
|
|
|
|
<option value="-updatedAt">{{ i18n.ts.lastUsed }} ({{ i18n.ts.ascendingOrder }})</option>
|
|
|
|
<option value="+updatedAt">{{ i18n.ts.lastUsed }} ({{ i18n.ts.descendingOrder }})</option>
|
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model="state" style="flex: 1;">
|
|
|
|
<template #label>{{ i18n.ts.state }}</template>
|
|
|
|
<option value="all">{{ i18n.ts.all }}</option>
|
|
|
|
<option value="available">{{ i18n.ts.normal }}</option>
|
|
|
|
<option value="admin">{{ i18n.ts.administrator }}</option>
|
|
|
|
<option value="moderator">{{ i18n.ts.moderator }}</option>
|
|
|
|
<option value="suspended">{{ i18n.ts.suspend }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model="origin" style="flex: 1;">
|
|
|
|
<template #label>{{ i18n.ts.instance }}</template>
|
|
|
|
<option value="combined">{{ i18n.ts.all }}</option>
|
|
|
|
<option value="local">{{ i18n.ts.local }}</option>
|
|
|
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
|
|
|
</MkSelect>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.inputs">
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkInput v-model="searchUsername" style="flex: 1;" type="text" :spellcheck="false" @update:modelValue="$refs.users.reload()">
|
2023-03-02 06:38:45 +01:00
|
|
|
<template #prefix>@</template>
|
|
|
|
<template #label>{{ i18n.ts.username }}</template>
|
|
|
|
</MkInput>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkInput v-model="searchHost" style="flex: 1;" type="text" :spellcheck="false" :disabled="pagination.params.origin === 'local'" @update:modelValue="$refs.users.reload()">
|
2023-03-02 06:38:45 +01:00
|
|
|
<template #prefix>@</template>
|
|
|
|
<template #label>{{ i18n.ts.host }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-03-02 06:38:45 +01:00
|
|
|
<MkPagination v-slot="{items}" ref="paginationComponent" :pagination="pagination">
|
|
|
|
<div :class="$style.users">
|
2023-08-13 14:02:25 +02:00
|
|
|
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${dateString(user.updatedAt)}`" :class="$style.user" :to="`/admin/user/${user.id}`">
|
2023-01-09 01:43:28 +01:00
|
|
|
<MkUserCardMini :user="user"/>
|
2022-06-22 16:40:53 +02:00
|
|
|
</MkA>
|
2023-03-02 06:38:45 +01:00
|
|
|
</div>
|
|
|
|
</MkPagination>
|
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>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { computed, shallowRef, ref } from 'vue';
|
2022-06-20 10:38:49 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2023-01-07 07:09:46 +01:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
2023-12-27 07:55:09 +01:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { lookupUser } from '@/scripts/lookup-user.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2022-08-30 17:24:33 +02:00
|
|
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { dateString } from '@/filters/date.js';
|
2022-02-09 05:38:54 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const paginationComponent = shallowRef<InstanceType<typeof MkPagination>>();
|
2022-02-09 05:38:54 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const sort = ref('+createdAt');
|
|
|
|
const state = ref('all');
|
|
|
|
const origin = ref('local');
|
|
|
|
const searchUsername = ref('');
|
|
|
|
const searchHost = ref('');
|
2022-02-09 05:38:54 +01:00
|
|
|
const pagination = {
|
|
|
|
endpoint: 'admin/show-users' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
2023-12-07 06:42:09 +01:00
|
|
|
sort: sort.value,
|
|
|
|
state: state.value,
|
|
|
|
origin: origin.value,
|
|
|
|
username: searchUsername.value,
|
|
|
|
hostname: searchHost.value,
|
2022-02-09 05:38:54 +01:00
|
|
|
})),
|
2022-06-20 10:38:49 +02:00
|
|
|
offsetMode: true,
|
2023-12-27 07:55:09 +01:00
|
|
|
};
|
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 => {
|
2023-12-07 06:42:09 +01:00
|
|
|
paginationComponent.value.reload();
|
2022-02-09 05:38:54 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function show(user) {
|
2023-08-13 14:02:25 +02:00
|
|
|
os.pageWindow(`/admin/user/${user.id}`);
|
2022-02-09 05:38:54 +01:00
|
|
|
}
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerActions = computed(() => [{
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-search',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: i18n.ts.search,
|
|
|
|
handler: searchUser,
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-plus',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: i18n.ts.addUser,
|
|
|
|
handler: addUser,
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-search',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: i18n.ts.lookup,
|
|
|
|
handler: lookupUser,
|
|
|
|
}]);
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.users,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-users',
|
2022-06-20 10:38:49 +02:00
|
|
|
})));
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
2023-03-02 06:38:45 +01:00
|
|
|
<style lang="scss" module>
|
|
|
|
.inputs {
|
|
|
|
display: flex;
|
|
|
|
gap: 8px;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
2021-10-02 16:11:21 +02:00
|
|
|
|
2023-03-02 06:38:45 +01:00
|
|
|
.users {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
|
|
|
|
grid-gap: 12px;
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2023-03-02 06:38:45 +01:00
|
|
|
> .user:hover {
|
|
|
|
text-decoration: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|