Skip to content

Commit

Permalink
Fix Document Count Display Issue and Loading Progress Bar Size in Pag…
Browse files Browse the repository at this point in the history
…ination (#212)
  • Loading branch information
devleejb authored Jun 25, 2024
1 parent 3d58f83 commit 89dc5d5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
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

0 comments on commit 89dc5d5

Please sign in to comment.