add boolean to ignore folderId sorting, show all files on drive cleaner

This commit is contained in:
Marie 2025-05-07 09:06:50 +02:00
parent 216ab3aea7
commit da54742291
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
2 changed files with 8 additions and 5 deletions

View file

@ -46,6 +46,7 @@ export const paramDef = {
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) }, type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
sort: { type: 'string', nullable: true, enum: ['+createdAt', '-createdAt', '+name', '-name', '+size', '-size', null] }, sort: { type: 'string', nullable: true, enum: ['+createdAt', '-createdAt', '+name', '-name', '+size', '-size', null] },
searchQuery: { type: 'string', default: '' }, searchQuery: { type: 'string', default: '' },
notShowAll: { type: 'boolean', default: true },
}, },
required: [], required: [],
} as const; } as const;
@ -63,10 +64,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.driveFilesRepository.createQueryBuilder('file'), ps.sinceId, ps.untilId)
.andWhere('file.userId = :userId', { userId: me.id }); .andWhere('file.userId = :userId', { userId: me.id });
if (ps.folderId) { if (ps.notShowAll) {
query.andWhere('file.folderId = :folderId', { folderId: ps.folderId }); if (ps.folderId) {
} else { query.andWhere('file.folderId = :folderId', { folderId: ps.folderId });
query.andWhere('file.folderId IS NULL'); } else {
query.andWhere('file.folderId IS NULL');
}
} }
if (ps.searchQuery.length > 0) { if (ps.searchQuery.length > 0) {

View file

@ -68,7 +68,7 @@ const sortMode = ref('+size');
const pagination = { const pagination = {
endpoint: 'drive/files' as const, endpoint: 'drive/files' as const,
limit: 10, limit: 10,
params: computed(() => ({ sort: sortMode.value })), params: computed(() => ({ sort: sortMode.value, notShowAll: false })),
offsetMode: true, offsetMode: true,
}; };