From 01e33120d62f498b3158e90989cdb64fabc7b11f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 9 Oct 2024 23:09:42 +0530 Subject: [PATCH] feat: use id instead of file name (wip) --- src/api/storage.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/api/storage.ts b/src/api/storage.ts index 913c7d85..e72d400d 100644 --- a/src/api/storage.ts +++ b/src/api/storage.ts @@ -32,13 +32,13 @@ export const getStoredRuns = async (): Promise => { } }; -export const deleteRecordingFromStorage = async (fileName: string): Promise => { +export const deleteRecordingFromStorage = async (id: string): Promise => { try { - const response = await axios.delete(`http://localhost:8080/storage/recordings/${fileName}`); + const response = await axios.delete(`http://localhost:8080/storage/recordings/${id}`); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't delete stored recording ${fileName}`); + throw new Error(`Couldn't delete stored recording ${id}`); } } catch(error: any) { console.log(error); @@ -46,13 +46,13 @@ export const deleteRecordingFromStorage = async (fileName: string): Promise => { +export const deleteRunFromStorage = async (id: string): Promise => { try { - const response = await axios.delete(`http://localhost:8080/storage/runs/${fileName}`); + const response = await axios.delete(`http://localhost:8080/storage/runs/${id}`); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't delete stored recording ${fileName}`); + throw new Error(`Couldn't delete stored recording ${id}`); } } catch(error: any) { console.log(error); @@ -60,13 +60,13 @@ export const deleteRunFromStorage = async (fileName: string): Promise = } }; -export const editRecordingFromStorage = async (browserId: string, fileName: string): Promise => { +export const editRecordingFromStorage = async (browserId: string, robotId: string): Promise => { try { - const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${fileName}`); + const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${robotId}`); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't edit stored recording ${fileName}`); + throw new Error(`Couldn't edit stored recording ${robotId}`); } } catch(error: any) { console.log(error); @@ -74,15 +74,15 @@ export const editRecordingFromStorage = async (browserId: string, fileName: stri } }; -export const createRunForStoredRecording = async (fileName: string, settings: RunSettings): Promise => { +export const createRunForStoredRecording = async (id: string, settings: RunSettings): Promise => { try { const response = await axios.put( - `http://localhost:8080/storage/runs/${fileName}`, + `http://localhost:8080/storage/runs/${id}`, {...settings}); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't create a run for a recording ${fileName}`); + throw new Error(`Couldn't create a run for a recording ${id}`); } } catch(error: any) { console.log(error); @@ -90,13 +90,13 @@ export const createRunForStoredRecording = async (fileName: string, settings: Ru } } -export const interpretStoredRecording = async (fileName: string, runId: string): Promise => { +export const interpretStoredRecording = async (runId: string): Promise => { try { - const response = await axios.post(`http://localhost:8080/storage/runs/run/${fileName}/${runId}`); + const response = await axios.post(`http://localhost:8080/storage/runs/run/${runId}`); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't run a recording ${fileName}`); + throw new Error(`Couldn't run a recording ${runId}`); } } catch(error: any) { console.log(error); @@ -104,13 +104,13 @@ export const interpretStoredRecording = async (fileName: string, runId: string): } } -export const notifyAboutAbort = async (fileName: string, runId:string): Promise => { +export const notifyAboutAbort = async (runId:string): Promise => { try { - const response = await axios.post(`http://localhost:8080/storage/runs/abort/${fileName}/${runId}`); + const response = await axios.post(`http://localhost:8080/storage/runs/abort/${runId}`); if (response.status === 200) { return response.data; } else { - throw new Error(`Couldn't abort a running recording ${fileName} with id ${runId}`); + throw new Error(`Couldn't abort a running recording with id ${runId}`); } } catch(error: any) { console.log(error);