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

[Assistants] Add pagination #772

Merged
merged 10 commits into from
Feb 5, 2024
Merged

[Assistants] Add pagination #772

merged 10 commits into from
Feb 5, 2024

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Feb 4, 2024

Add pagination to assistants page

Lightmode Darkmode Mobile
Screenshot 2024-02-04 at 3 30 03 PM Screenshot 2024-02-04 at 3 30 07 PM Screenshot 2024-02-04 at 3 30 31 PM

@mishig25 mishig25 force-pushed the assistnats_pagination branch from fec5d55 to d5ee312 Compare February 4, 2024 15:02
@mishig25 mishig25 force-pushed the assistnats_pagination branch from d5ee312 to cc012bb Compare February 4, 2024 15:06
@mishig25 mishig25 requested review from nsarrazin and gary149 February 4, 2024 15:07
@@ -3,20 +3,36 @@ import { ENABLE_ASSISTANTS } from "$env/static/private";
import { collections } from "$lib/server/database.js";
import type { Assistant } from "$lib/types/Assistant";
import { redirect } from "@sveltejs/kit";
import type { Filter } from "mongodb";

const NUM_PER_PAGE = 10;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gary149 change this number to what's appropriate

src/lib/components/PaginationArrow.svelte Outdated Show resolved Hide resolved
export let isDisabled = false;
</script>

<button
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a link <a> to prev/next page (vs button with click event)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in 53ed09b


const numTotalPages = Math.ceil(numTotalItems / numItemsPerPage);

$: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit complex 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from hub. I will see what should be done for simplification

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in 914dbd9

<PaginationArrow
direction="previous"
isDisabled={pageIndex - 1 < 0}
onClick={handleClickDirection}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for javascript, next/before should be links

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in 53ed09b

Comment on lines 30 to 34
const onPaginationChange = (newPageIndex: number) => {
pageIndex = newPageIndex;
const newUrl = new URL($page.url);
newUrl.searchParams.set("p", newPageIndex.toString());
goto(newUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove that too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled in 53ed09b

@gary149 gary149 self-requested a review February 4, 2024 18:56
Copy link
Collaborator

@gary149 gary149 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

@mishig25 mishig25 merged commit 25a7ba5 into main Feb 5, 2024
3 checks passed
@mishig25 mishig25 deleted the assistnats_pagination branch February 5, 2024 09:15
ice91 pushed a commit to ice91/chat-ui that referenced this pull request Oct 30, 2024
* [Assistants] Add pagination

* Update src/lib/components/PaginationArrow.svelte

Co-authored-by: Victor Muštar <victor.mustar@gmail.com>

* format

* Simplify by using a href

* this statement needs to be reactive

* simplify pagination

* update disabled

* Update src/routes/assistants/+page.server.ts

---------

Co-authored-by: Victor Muštar <victor.mustar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants