From 9a3c46e9accb29a07fc51a315fd160ab3ceb791f Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Mon, 13 Jan 2025 09:33:01 +0000 Subject: [PATCH] store/cockpitApi: blueprint pagination Add blueprint list pagination support --- src/store/cockpitApi.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/store/cockpitApi.ts b/src/store/cockpitApi.ts index 3977d378..ef0332ef 100644 --- a/src/store/cockpitApi.ts +++ b/src/store/cockpitApi.ts @@ -49,7 +49,7 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({ >({ queryFn: async (queryArgs) => { try { - const { name, search } = queryArgs; + const { name, search, offset, limit } = queryArgs; const blueprintsDir = await getBlueprintsPath(); @@ -92,6 +92,11 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({ return true; }); + let paginatedBlueprints = blueprints; + if (offset !== undefined && limit !== undefined) { + paginatedBlueprints = blueprints.slice(offset, offset + limit); + } + let first = ''; let last = ''; @@ -109,7 +114,7 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({ first: first, last: last, }, - data: blueprints, + data: paginatedBlueprints, }, }; } catch (error) {