feat: モデログを検索できるように
This commit is contained in:
parent
3c5ed0ffbb
commit
3c6f07fc8c
|
@ -4,6 +4,7 @@
|
|||
- Feat: ノートの下書き機能
|
||||
|
||||
### Client
|
||||
- Feat: モデログを検索できるように
|
||||
- Enhance: 設定の自動バックアップをオンにした直後に自動バックアップするように
|
||||
- Enhance: ファイルアップロード前にキャプション設定を行えるように
|
||||
- Enhance: ページネーション(一覧表示)の並び順を逆にできるように
|
||||
|
|
|
@ -9,6 +9,7 @@ import type { ModerationLogsRepository } from '@/models/_.js';
|
|||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ModerationLogEntityService } from '@/core/entities/ModerationLogEntityService.js';
|
||||
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -67,6 +68,7 @@ export const paramDef = {
|
|||
untilDate: { type: 'integer' },
|
||||
type: { type: 'string', nullable: true },
|
||||
userId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
search: { type: 'string', nullable: true },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
@ -81,19 +83,24 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('report'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate);
|
||||
const query = this.queryService.makePaginationQuery(this.moderationLogsRepository.createQueryBuilder('log'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate);
|
||||
|
||||
if (ps.type != null) {
|
||||
query.andWhere('report.type = :type', { type: ps.type });
|
||||
query.andWhere('log.type = :type', { type: ps.type });
|
||||
}
|
||||
|
||||
if (ps.userId != null) {
|
||||
query.andWhere('report.userId = :userId', { userId: ps.userId });
|
||||
query.andWhere('log.userId = :userId', { userId: ps.userId });
|
||||
}
|
||||
|
||||
const reports = await query.limit(ps.limit).getMany();
|
||||
if (ps.search != null) {
|
||||
const escapedSearch = sqlLikeEscape(ps.search);
|
||||
query.andWhere('log.info::text ILIKE :search', { search: `%${escapedSearch}%` });
|
||||
}
|
||||
|
||||
return await this.moderationLogEntityService.packMany(reports);
|
||||
const logs = await query.limit(ps.limit).getMany();
|
||||
|
||||
return await this.moderationLogEntityService.packMany(logs);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,22 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkSelect v-model="order" :class="$style.order" :items="[{ label: i18n.ts._order.newest, value: 'newest' }, { label: i18n.ts._order.oldest, value: 'oldest' }]">
|
||||
<template #prefix><i class="ti ti-arrows-sort"></i></template>
|
||||
</MkSelect>
|
||||
<MkButton v-if="canSearch" v-tooltip="i18n.ts.search" iconOnly transparent rounded :active="search" @click="search = !search"><i class="ti ti-search"></i></MkButton>
|
||||
<MkButton v-if="canSearch" v-tooltip="i18n.ts.search" iconOnly transparent rounded :active="searchOpened" @click="searchOpened = !searchOpened"><i class="ti ti-search"></i></MkButton>
|
||||
<MkButton v-if="canFilter" v-tooltip="i18n.ts.filter" iconOnly transparent rounded :active="filterOpened" @click="filterOpened = !filterOpened"><i class="ti ti-filter"></i></MkButton>
|
||||
<MkButton v-tooltip="i18n.ts.dateAndTime" iconOnly transparent rounded :active="date != null" @click="date = date == null ? Date.now() : null"><i class="ti ti-calendar-clock"></i></MkButton>
|
||||
<MkButton v-tooltip="i18n.ts.reload" iconOnly transparent rounded @click="emit('reload')"><i class="ti ti-refresh"></i></MkButton>
|
||||
</div>
|
||||
|
||||
<MkInput
|
||||
v-if="searchOpened"
|
||||
v-model="q"
|
||||
type="search"
|
||||
debounce
|
||||
>
|
||||
<template #label>{{ i18n.ts.search }}</template>
|
||||
<template #prefix><i class="ti ti-search"></i></template>
|
||||
</MkInput>
|
||||
|
||||
<MkInput
|
||||
v-if="date != null"
|
||||
type="date"
|
||||
|
@ -50,7 +60,7 @@ const emit = defineEmits<{
|
|||
(ev: 'reload'): void;
|
||||
}>();
|
||||
|
||||
const search = ref(false);
|
||||
const searchOpened = ref(false);
|
||||
const filterOpened = ref(props.filterOpened);
|
||||
|
||||
const order = defineModel<'newest' | 'oldest'>('order', {
|
||||
|
@ -60,6 +70,10 @@ const order = defineModel<'newest' | 'oldest'>('order', {
|
|||
const date = defineModel<number | null>('date', {
|
||||
default: null,
|
||||
});
|
||||
|
||||
const q = defineModel<string | null>('q', {
|
||||
default: null,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
|
|
@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<PageWithHeader :actions="headerActions" :tabs="headerTabs">
|
||||
<div class="_spacer" style="--MI_SPACER-w: 900px;">
|
||||
<div class="_gaps">
|
||||
<MkPaginationControl v-model:order="order" v-model:date="date" canFilter @reload="paginator.reload()">
|
||||
<MkPaginationControl v-model:order="order" v-model:date="date" v-model:q="q" canSearch canFilter @reload="paginator.reload()">
|
||||
<MkSelect v-model="type" style="margin: 0; flex: 1;">
|
||||
<template #label>{{ i18n.ts.type }}</template>
|
||||
<option :value="null">{{ i18n.ts.all }}</option>
|
||||
|
@ -20,7 +20,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkPaginationControl>
|
||||
|
||||
<component :is="prefer.s.enablePullToRefresh ? MkPullToRefresh : 'div'" :refresher="() => paginator.reload()">
|
||||
<MkTl :events="timeline" groupBy="d">
|
||||
<MkLoading v-if="paginator.fetching.value"/>
|
||||
|
||||
<MkError v-else-if="paginator.error.value" @retry="paginator.init()"/>
|
||||
|
||||
<MkTl v-else :events="timeline" groupBy="d">
|
||||
<template #left="{ event }">
|
||||
<div>
|
||||
<MkAvatar :user="event.user" style="width: 26px; height: 26px;"/>
|
||||
|
@ -59,6 +63,7 @@ const order = ref<'newest' | 'oldest'>('newest');
|
|||
const date = ref<number | null>(null);
|
||||
const type = ref<string | null>(null);
|
||||
const moderatorId = ref('');
|
||||
const q = ref<string | null>(null);
|
||||
|
||||
const paginator = usePagination({
|
||||
ctx: {
|
||||
|
@ -68,6 +73,7 @@ const paginator = usePagination({
|
|||
params: computed(() => ({
|
||||
type: type.value,
|
||||
userId: moderatorId.value === '' ? null : moderatorId.value,
|
||||
search: q.value,
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue