From b55331994621491be2618d69be250aa0f0bf68db Mon Sep 17 00:00:00 2001 From: Lars Steudle Date: Mon, 2 Sep 2024 10:45:44 +0200 Subject: [PATCH 1/2] fixed fetch of constraint and student group, delete unused pages --- .../(resources)/studentGroups/+page.svelte | 4 ++-- .../admin/(resources)/studentGroups/+page.ts | 3 ++- web/src/routes/admin/constraints/+page.svelte | 3 ++- .../constraints/[signatureId]/+page.svelte | 5 ----- .../admin/constraints/[signatureId]/+page.ts | 17 ----------------- 5 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 web/src/routes/admin/constraints/[signatureId]/+page.svelte delete mode 100644 web/src/routes/admin/constraints/[signatureId]/+page.ts diff --git a/web/src/routes/admin/(resources)/studentGroups/+page.svelte b/web/src/routes/admin/(resources)/studentGroups/+page.svelte index 2cba6c835..77ba2a324 100644 --- a/web/src/routes/admin/(resources)/studentGroups/+page.svelte +++ b/web/src/routes/admin/(resources)/studentGroups/+page.svelte @@ -42,8 +42,8 @@ async function deleteGroup(id: string) { await deleteStudentGroup(id); - studentGroups = - (await getStudentGroups({ page: 0, size: 50, sort: ['name,asc'] }).then(({ content }) => content)) || []; + const size = await getStudentGroups({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); + studentGroups = await getStudentGroups({ page: 0, size, sort: ['name,asc'] }).then(({ content }) => content ?? []); } diff --git a/web/src/routes/admin/(resources)/studentGroups/+page.ts b/web/src/routes/admin/(resources)/studentGroups/+page.ts index 06fdd9a66..edd0731ba 100644 --- a/web/src/routes/admin/(resources)/studentGroups/+page.ts +++ b/web/src/routes/admin/(resources)/studentGroups/+page.ts @@ -2,8 +2,9 @@ import { getGrades, getStudentGroups, getStudents } from '$lib/sdk/fetch-client' import type { PageLoad } from './$types'; export const load = (async () => { + const size = await getStudentGroups({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); return { - studentGroups: await getStudentGroups({ page: 0, size: 50, sort: ['name,asc'] }).then(({ content }) => content), + studentGroups: await getStudentGroups({ page: 0, size, sort: ['name,asc'] }).then(({ content }) => content), students: await getStudents({ page: 0, size: 40 }).then(({ content }) => content), grades: await getGrades({ sort: ['name,asc'] }), meta: { diff --git a/web/src/routes/admin/constraints/+page.svelte b/web/src/routes/admin/constraints/+page.svelte index 82156ffc0..c7a5cd330 100644 --- a/web/src/routes/admin/constraints/+page.svelte +++ b/web/src/routes/admin/constraints/+page.svelte @@ -14,8 +14,9 @@ let reloadTable = false; const getConstraints = async () => { + const size = await getConstraintSignatures({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); return { - constraints: await getConstraintSignatures({ page: 0, size: 50 }).then(({ content }) => content), + constraints: await getConstraintSignatures({ page: 0, size }).then(({ content }) => content), }; }; diff --git a/web/src/routes/admin/constraints/[signatureId]/+page.svelte b/web/src/routes/admin/constraints/[signatureId]/+page.svelte deleted file mode 100644 index 6401e0761..000000000 --- a/web/src/routes/admin/constraints/[signatureId]/+page.svelte +++ /dev/null @@ -1,5 +0,0 @@ - - -
{JSON.stringify(data.constraintSignature)}
diff --git a/web/src/routes/admin/constraints/[signatureId]/+page.ts b/web/src/routes/admin/constraints/[signatureId]/+page.ts deleted file mode 100644 index 88a21afed..000000000 --- a/web/src/routes/admin/constraints/[signatureId]/+page.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { getConstraintSignature } from '$lib/sdk/fetch-client'; -import { error } from '@sveltejs/kit'; -import type { PageLoad } from './$types'; - -export const load = (async ({ params }) => { - try { - const constraintSignature = await getConstraintSignature(params.signatureId); - return { - constraintSignature, - meta: { - title: `Constraint Signature — ${constraintSignature.name}`, - }, - }; - } catch { - error(404, { message: `Constraint signature with id ${params.signatureId} not found` }); - } -}) satisfies PageLoad; From 459b9567bf0d15a9be48df841fc3faf3f6d87bcb Mon Sep 17 00:00:00 2001 From: Lars Steudle Date: Mon, 2 Sep 2024 11:52:39 +0200 Subject: [PATCH 2/2] suggestions --- web/src/routes/admin/(resources)/studentGroups/+page.svelte | 2 +- web/src/routes/admin/(resources)/studentGroups/+page.ts | 2 +- web/src/routes/admin/constraints/+page.svelte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/routes/admin/(resources)/studentGroups/+page.svelte b/web/src/routes/admin/(resources)/studentGroups/+page.svelte index 77ba2a324..8ec495e15 100644 --- a/web/src/routes/admin/(resources)/studentGroups/+page.svelte +++ b/web/src/routes/admin/(resources)/studentGroups/+page.svelte @@ -42,7 +42,7 @@ async function deleteGroup(id: string) { await deleteStudentGroup(id); - const size = await getStudentGroups({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); + const { totalElements: size } = await getStudentGroups({ page: 0, size: 1 }); studentGroups = await getStudentGroups({ page: 0, size, sort: ['name,asc'] }).then(({ content }) => content ?? []); } diff --git a/web/src/routes/admin/(resources)/studentGroups/+page.ts b/web/src/routes/admin/(resources)/studentGroups/+page.ts index edd0731ba..1dc7988d5 100644 --- a/web/src/routes/admin/(resources)/studentGroups/+page.ts +++ b/web/src/routes/admin/(resources)/studentGroups/+page.ts @@ -2,7 +2,7 @@ import { getGrades, getStudentGroups, getStudents } from '$lib/sdk/fetch-client' import type { PageLoad } from './$types'; export const load = (async () => { - const size = await getStudentGroups({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); + const { totalElements: size } = await getStudentGroups({ page: 0, size: 1 }); return { studentGroups: await getStudentGroups({ page: 0, size, sort: ['name,asc'] }).then(({ content }) => content), students: await getStudents({ page: 0, size: 40 }).then(({ content }) => content), diff --git a/web/src/routes/admin/constraints/+page.svelte b/web/src/routes/admin/constraints/+page.svelte index c7a5cd330..4fe030f34 100644 --- a/web/src/routes/admin/constraints/+page.svelte +++ b/web/src/routes/admin/constraints/+page.svelte @@ -14,7 +14,7 @@ let reloadTable = false; const getConstraints = async () => { - const size = await getConstraintSignatures({ page: 0, size: 1 }).then(({ totalElements }) => totalElements); + const { totalElements: size } = await getConstraintSignatures({ page: 0, size: 1 }); return { constraints: await getConstraintSignatures({ page: 0, size }).then(({ content }) => content), };