diff --git a/frontend/src/routes/(loggedin)/app/prober/+page.svelte b/frontend/src/routes/(loggedin)/app/prober/+page.svelte index 51567cb..57488f8 100644 --- a/frontend/src/routes/(loggedin)/app/prober/+page.svelte +++ b/frontend/src/routes/(loggedin)/app/prober/+page.svelte @@ -1,7 +1,7 @@ - -
-

Add Prober

-
-{#if !isProcessing} - {#if formResult?.status === 'error'} - - {/if} - {#if formResult?.status === 'ok'} - - {/if} -{:else} - - -{/if} -
-
-
-
- -
-
- - -
-
diff --git a/frontend/src/routes/(loggedin)/app/prober/api-handler.js b/frontend/src/routes/(loggedin)/app/prober/api-handler.js index bd40b38..a3e257b 100644 --- a/frontend/src/routes/(loggedin)/app/prober/api-handler.js +++ b/frontend/src/routes/(loggedin)/app/prober/api-handler.js @@ -8,10 +8,14 @@ export const loadData = async (state) => { return json.data.items ?? []; }; -export const deleteData = async (id) => { - const response = await fetch(apiUri(`/api/v1/prober/${id}`), { - method: 'DELETE', - credentials: 'include' +export const createProber = async (name) => { + const response = await fetch(apiUri('/api/v1/prober'), { + method: 'POST', + credentials: 'include', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ name }) }); const json = await response.json(); return json; @@ -30,6 +34,15 @@ export const editProber = async (id, name) => { return json; }; +export const deleteProber = async (id) => { + const response = await fetch(apiUri(`/api/v1/prober/${id}`), { + method: 'DELETE', + credentials: 'include' + }); + const json = await response.json(); + return json; +}; + const getParams = ({ pageNumber, rowsPerPage, sort, filters }) => { let params = `page=${pageNumber}&limit=${rowsPerPage}`; diff --git a/handler/routes.go b/handler/routes.go index cfa493f..032ea5f 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -13,7 +13,7 @@ func V1Api(app *fiber.App) { v1 := app.Group("/api/v1") v1.Get("/prober", Prober) - v1.Post("/prober", Prober) + v1.Post("/prober", CookieProtected, Prober) v1.Patch("/prober/:id", CookieProtected, Prober) v1.Delete("/prober/:id", CookieProtected, Prober) v1.Get("/nodes", MoneroNodes)