From 75c3b5c833f640b4d5a6e2a45ca3a8724540c190 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 19 Mar 2025 22:42:28 +0000 Subject: [PATCH] use page size param in front end --- admin_ui/src/store.ts | 7 ++++++- piccolo_admin/endpoints.py | 2 +- piccolo_admin/example/app.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/admin_ui/src/store.ts b/admin_ui/src/store.ts index cae0e6b1..279e9dce 100644 --- a/admin_ui/src/store.ts +++ b/admin_ui/src/store.ts @@ -23,7 +23,7 @@ export default createStore({ currentTableName: undefined, darkMode: false, filterParams: {} as { [key: string]: any }, - pageSize: 15, + pageSize: 0, rowCount: 0, rows: [], schema: undefined as i.Schema | undefined, @@ -154,6 +154,11 @@ export default createStore({ ) const data = response.data as i.RowCountAPIResponse context.commit("updateRowCount", data.count) + + if (!context.state.pageSize) { + context.commit("updatePageSize", data.page_size) + } + return data }, async fetchRows(context) { diff --git a/piccolo_admin/endpoints.py b/piccolo_admin/endpoints.py index 6405a070..e5bf6fa6 100644 --- a/piccolo_admin/endpoints.py +++ b/piccolo_admin/endpoints.py @@ -1187,7 +1187,7 @@ def create_admin( session_expiry: timedelta = timedelta(hours=1), max_session_expiry: timedelta = timedelta(days=7), increase_expiry: t.Optional[timedelta] = timedelta(minutes=20), - page_size: int = 15, + page_size: t.Literal[5, 15, 30, 50, 100] = 15, read_only: bool = False, rate_limit_provider: t.Optional[RateLimitProvider] = None, production: bool = False, diff --git a/piccolo_admin/example/app.py b/piccolo_admin/example/app.py index 865aaaea..9b89b384 100644 --- a/piccolo_admin/example/app.py +++ b/piccolo_admin/example/app.py @@ -264,6 +264,7 @@ secret_table=AuthenticatorSecret, ), ], + page_size=30, )