From c57bb60fcbda35cd2cf4a234036bfc4c7f92c796 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Thu, 30 Nov 2023 09:51:30 +0100 Subject: [PATCH] commentary --- Webserver/src/routes/admin/+page.svelte | 129 ++++++++++++++++--- Webserver/src/routes/api/redirect/+server.ts | 9 ++ 2 files changed, 121 insertions(+), 17 deletions(-) diff --git a/Webserver/src/routes/admin/+page.svelte b/Webserver/src/routes/admin/+page.svelte index cfb22e8..3352d1c 100644 --- a/Webserver/src/routes/admin/+page.svelte +++ b/Webserver/src/routes/admin/+page.svelte @@ -1,34 +1,47 @@ +

Matrix Control Panel

+
+
+
+
+ + +
+
- + + + +
+
+ > + + + + /> + + +
+
- + + + + + /> + + - + + + + + /> + + +
+
+
+ {#each matrix as row} @@ -475,6 +569,7 @@ {/each}
+
{ + // Get endpoint on main API from searchparams const params = url.searchParams; const endpoint = params.get('endpoint'); + // Return if param not found if (endpoint === null) return json({ success: false } as APIResponse); + // Call API and respond with new data const api_call = await fetch(`http://localhost:8080/${endpoint}`); const data = await api_call.json() as APIResponse; return json(data); }; +// POST Endpoint for redirection API export const POST: RequestHandler = async ({ request }) => { + // Get data from form const formData = await request.formData(); const endpoint = formData.get('endpoint'); + // Return if endpoint not found if (endpoint === null) return json({ success: false } as APIResponse); + // Remove endpoint to save on datatransfer formData.delete('endpoint'); + // Call API and respond with new data const api_call = await fetch(`http://localhost:8080/${endpoint}`, { method: 'POST', mode: 'cors',