Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Document Count Display Issue and Loading Progress Bar Size in Pagination #212

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ export class FindWorkspaceDocumentsResponse {

@ApiProperty({ type: String, description: "The ID of last document" })
cursor: string | null;

@ApiProperty({ type: Number, description: "The number of total documents" })
totalLength: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class WorkspaceDocumentsService {
additionalOptions.cursor = { id: cursor };
}

const totalLength = await this.prismaService.document.count({
where: {
workspaceId,
},
});

const documentList = await this.prismaService.document.findMany({
take: pageSize + 1,
where: {
Expand Down Expand Up @@ -90,6 +96,7 @@ export class WorkspaceDocumentsService {
return {
documents: mergedDocumentList,
cursor: documentList.length > pageSize ? documentList[pageSize].id : null,
totalLength,
};
}

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/layouts/WorkspaceLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const Main = styled("main", { shouldForwardProp: (prop) => prop !== "open" })<{
open?: boolean;
}>(({ theme, open }) => ({
flexGrow: 1,
padding: theme.spacing(3),
paddingLeft: theme.spacing(3),
paddingRight: theme.spacing(3),
paddingTop: theme.spacing(3),
transition: theme.transitions.create("margin", {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/api/types/workspaceDocument.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Document } from "./document";

export class GetWorkspaceDocumentListResponse {
cursor: string | null;
totalLength: number;
documents: Array<Document>;
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/pages/workspace/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function WorkspaceIndex() {
<Typography variant="h5" fontWeight="bold">
{workspace?.title}{" "}
<Typography component="span" variant="inherit" color="primary">
{documentPageList?.pages[0].documents.length}
{documentPageList?.pages[0].totalLength}
</Typography>
</Typography>
<Button
Expand All @@ -60,7 +60,7 @@ function WorkspaceIndex() {
</Stack>
<Stack
style={{
maxHeight: "calc(100vh - 160px)",
maxHeight: "calc(100vh - 144px)",
overflow: "auto",
}}
>
Expand All @@ -69,8 +69,8 @@ function WorkspaceIndex() {
loadMore={() => fetchNextPage()}
hasMore={hasNextPage}
loader={
<Stack className="loader" key={0}>
<CircularProgress size="sm" />
<Stack className="loader" key={0} alignItems="center">
<CircularProgress size={20} />
</Stack>
}
useWindow={false}
Expand Down