Feat: コントロールパネル内のファイル一覧でファイル名と説明で検索できるように(#14789)

This commit is contained in:
tetsuya-ki 2024-10-19 15:11:38 +00:00
parent 58419e1621
commit 0c59948828
2 changed files with 24 additions and 0 deletions

View File

@ -43,6 +43,8 @@ export const paramDef = {
default: null, default: null,
description: 'The local host is represented with `null`.', description: 'The local host is represented with `null`.',
}, },
name: { type: 'string', nullable: true },
comment: { type: 'string', nullable: true },
}, },
required: [], required: [],
} as const; } as const;
@ -81,6 +83,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} }
} }
if (ps.name) {
// 前方一致検索(%と_は無害化)
query.andWhere('file.name ilike :name', { name: ps.name.replaceAll('%', '\\%').replaceAll('_', '\\_') + '%' });
}
if (ps.comment) {
// 前方一致検索(%と_は無害化)
query.andWhere('file.comment ilike :comment', { comment: ps.comment.replaceAll('%', '\\%').replaceAll('_', '\\_') + '%' });
}
const files = await query.limit(ps.limit).getMany(); const files = await query.limit(ps.limit).getMany();
return await this.driveFileEntityService.packMany(files, { detail: true, withUser: true, self: true }); return await this.driveFileEntityService.packMany(files, { detail: true, withUser: true, self: true });

View File

@ -28,6 +28,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>MIME type</template> <template #label>MIME type</template>
</MkInput> </MkInput>
</div> </div>
<div class="inputs" style="display: flex; gap: var(--MI-margin); flex-wrap: wrap;">
<MkInput v-model="name" :debounce="true" type="search" style="margin: 0; flex: 1;">
<template #label>File Name</template>
</MkInput>
<MkInput v-model="comment" :debounce="true" type="search" style="margin: 0; flex: 1;">
<template #label>Comment</template>
</MkInput>
</div>
<MkFileListForAdmin :pagination="pagination" :viewMode="viewMode"/> <MkFileListForAdmin :pagination="pagination" :viewMode="viewMode"/>
</div> </div>
</MkSpacer> </MkSpacer>
@ -51,6 +59,8 @@ const type = ref<string | null>(null);
const searchHost = ref(''); const searchHost = ref('');
const userId = ref(''); const userId = ref('');
const viewMode = ref('grid'); const viewMode = ref('grid');
const name = ref('');
const comment = ref('');
const pagination = { const pagination = {
endpoint: 'admin/drive/files' as const, endpoint: 'admin/drive/files' as const,
limit: 10, limit: 10,
@ -59,6 +69,8 @@ const pagination = {
userId: (userId.value && userId.value !== '') ? userId.value : null, userId: (userId.value && userId.value !== '') ? userId.value : null,
origin: origin.value, origin: origin.value,
hostname: (searchHost.value && searchHost.value !== '') ? searchHost.value : null, hostname: (searchHost.value && searchHost.value !== '') ? searchHost.value : null,
name: (name.value && name.value !== '') ? name.value : null,
comment: (comment.value && comment.value !== '') ? comment.value : null,
})), })),
}; };