mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 04:44:28 +00:00
fix(webui): fix pagination in file browser list mode
This commit is contained in:
@@ -741,6 +741,7 @@ describe('SearchService', () => {
|
|||||||
|
|
||||||
// Search files recursively
|
// Search files recursively
|
||||||
const resultRecursive = await searchService.search(rootFolder.id, {
|
const resultRecursive = await searchService.search(rootFolder.id, {
|
||||||
|
conditions: [],
|
||||||
recursively: true,
|
recursively: true,
|
||||||
assetType: 'file',
|
assetType: 'file',
|
||||||
operator: 'AND',
|
operator: 'AND',
|
||||||
@@ -752,6 +753,7 @@ describe('SearchService', () => {
|
|||||||
|
|
||||||
// Search files non-recursively
|
// Search files non-recursively
|
||||||
const resultNonRecursive = await searchService.search(rootFolder.id, {
|
const resultNonRecursive = await searchService.search(rootFolder.id, {
|
||||||
|
conditions: [],
|
||||||
recursively: false,
|
recursively: false,
|
||||||
assetType: 'file',
|
assetType: 'file',
|
||||||
operator: 'AND',
|
operator: 'AND',
|
||||||
@@ -773,6 +775,8 @@ describe('SearchService', () => {
|
|||||||
return [{ count: 2500n }]
|
return [{ count: 2500n }]
|
||||||
}
|
}
|
||||||
// For main query, just run it or return mock
|
// For main query, just run it or return mock
|
||||||
|
// We must cast to any because we are proxying the raw sql parameter
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return target.$queryRaw(prismaSql as any)
|
return target.$queryRaw(prismaSql as any)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -784,10 +788,14 @@ describe('SearchService', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// We must cast mockPrisma proxy as any because the type signature of SearchService
|
||||||
|
// expects a full PrismaClient instance, whereas we only mocked $queryRaw.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const localSearchService = new SearchService(mockPrisma as any)
|
const localSearchService = new SearchService(mockPrisma as any)
|
||||||
const { rootFolder } = await setupBasicAssets()
|
const { rootFolder } = await setupBasicAssets()
|
||||||
|
|
||||||
const result = await localSearchService.search(rootFolder.id, {
|
const result = await localSearchService.search(rootFolder.id, {
|
||||||
|
conditions: [],
|
||||||
recursively: true,
|
recursively: true,
|
||||||
assetType: 'file',
|
assetType: 'file',
|
||||||
operator: 'AND',
|
operator: 'AND',
|
||||||
|
|||||||
@@ -191,7 +191,9 @@ export class SearchService {
|
|||||||
|
|
||||||
if (totalCount < 2000) {
|
if (totalCount < 2000) {
|
||||||
countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`)
|
countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`)
|
||||||
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build())
|
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(
|
||||||
|
countBuilder.build(),
|
||||||
|
)
|
||||||
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
||||||
} else {
|
} else {
|
||||||
pageInfo.totalSize = -1
|
pageInfo.totalSize = -1
|
||||||
@@ -380,7 +382,9 @@ export class SearchService {
|
|||||||
|
|
||||||
if (totalCount < 2000) {
|
if (totalCount < 2000) {
|
||||||
countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`)
|
countBuilder.select(Prisma.sql`SUM(COALESCE(a.size_byte, 0))::bigint as sum`)
|
||||||
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build())
|
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(
|
||||||
|
countBuilder.build(),
|
||||||
|
)
|
||||||
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
||||||
} else {
|
} else {
|
||||||
pageInfo.totalSize = -1
|
pageInfo.totalSize = -1
|
||||||
@@ -413,7 +417,9 @@ export class SearchService {
|
|||||||
countBuilder.addWhere(Prisma.sql`a.name ILIKE ${'%' + valStr + '%'}`)
|
countBuilder.addWhere(Prisma.sql`a.name ILIKE ${'%' + valStr + '%'}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(countBuilder.build())
|
const sumRes = await this.prismaClient.$queryRaw<{ sum: bigint | null }[]>(
|
||||||
|
countBuilder.build(),
|
||||||
|
)
|
||||||
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
pageInfo.totalSize = Number(sumRes[0]?.sum || 0)
|
||||||
} else {
|
} else {
|
||||||
pageInfo.totalSize = -1
|
pageInfo.totalSize = -1
|
||||||
|
|||||||
@@ -261,7 +261,8 @@ export function FileBrowserGridView({
|
|||||||
<ChevronRight className="h-4 w-4" />
|
<ChevronRight className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
<span>
|
<span>
|
||||||
{formatCount(count, !isFolder)}{showSize ? ` • ${formatSize(size)}` : ''}
|
{formatCount(count, !isFolder)}
|
||||||
|
{showSize ? ` • ${formatSize(size)}` : ''}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ export function FileBrowserListView({
|
|||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 overflow-x-auto" onClick={handleEmptyAreaClick}>
|
<div className="w-full overflow-x-auto" onClick={handleEmptyAreaClick}>
|
||||||
<div
|
<div
|
||||||
className="w-full relative"
|
className="w-full relative"
|
||||||
style={{
|
style={{
|
||||||
@@ -406,7 +406,8 @@ export function FileBrowserListView({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm font-medium text-muted-foreground whitespace-nowrap">
|
<span className="text-sm font-medium text-muted-foreground whitespace-nowrap">
|
||||||
{formatCount(count, !isFolder)}{showSize ? ` • ${formatSize(size)}` : ''}
|
{formatCount(count, !isFolder)}
|
||||||
|
{showSize ? ` • ${formatSize(size)}` : ''}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 bg-card" />
|
<div className="flex-1 bg-card" />
|
||||||
|
|||||||
Reference in New Issue
Block a user