From 30bfe509061b968d6aab3e8ccf85c6437dcb1a63 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 31 Jul 2024 19:47:52 +0530 Subject: [PATCH] feat: body css --- src/api/storage.ts | 120 +++++++++++++++++++++++++++++++++++++++++++++ src/index.css | 6 +++ 2 files changed, 126 insertions(+) create mode 100644 src/api/storage.ts diff --git a/src/api/storage.ts b/src/api/storage.ts new file mode 100644 index 00000000..acae2121 --- /dev/null +++ b/src/api/storage.ts @@ -0,0 +1,120 @@ +import { default as axios } from "axios"; +import { WorkflowFile } from "@wbr-project/wbr-interpret"; +import { RunSettings } from "../components/molecules/RunSettings"; +import { CreateRunResponse } from "../pages/MainPage"; + +export const getStoredRecordings = async (): Promise => { + try { + const response = await axios.get('http://localhost:8080/storage/recordings'); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t retrieve stored recordings'); + } + } catch(error: any) { + console.log(error); + return null; + } +}; + +export const getStoredRuns = async (): Promise => { + try { + const response = await axios.get('http://localhost:8080/storage/runs'); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t retrieve stored recordings'); + } + } catch(error: any) { + console.log(error); + return null; + } +}; + +export const deleteRecordingFromStorage = async (fileName: string): Promise => { + try { + const response = await axios.delete(`http://localhost:8080/storage/recordings/${fileName}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't delete stored recording ${fileName}`); + } + } catch(error: any) { + console.log(error); + return false; + } +}; + +export const deleteRunFromStorage = async (fileName: string): Promise => { + try { + const response = await axios.delete(`http://localhost:8080/storage/runs/${fileName}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't delete stored recording ${fileName}`); + } + } catch(error: any) { + console.log(error); + return false; + } +}; + +export const editRecordingFromStorage = async (browserId: string, fileName: string): Promise => { + try { + const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${fileName}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't edit stored recording ${fileName}`); + } + } catch(error: any) { + console.log(error); + return null; + } +}; + +export const createRunForStoredRecording = async (fileName: string, settings: RunSettings): Promise => { + try { + const response = await axios.put( + `http://localhost:8080/storage/runs/${fileName}`, + {...settings}); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't create a run for a recording ${fileName}`); + } + } catch(error: any) { + console.log(error); + return {browserId: '', runId: ''}; + } +} + +export const interpretStoredRecording = async (fileName: string, runId: string): Promise => { + try { + const response = await axios.post(`http://localhost:8080/storage/runs/run/${fileName}/${runId}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't run a recording ${fileName}`); + } + } catch(error: any) { + console.log(error); + return false; + } +} + +export const notifyAboutAbort = async (fileName: string, runId:string): Promise => { + try { + const response = await axios.post(`http://localhost:8080/storage/runs/abort/${fileName}/${runId}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error(`Couldn't abort a running recording ${fileName} with id ${runId}`); + } + } catch(error: any) { + console.log(error); + return false; + } +} + + diff --git a/src/index.css b/src/index.css index 21808ea5..1d4c3871 100644 --- a/src/index.css +++ b/src/index.css @@ -5,6 +5,12 @@ body { sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + width: 100%; + height: 100%; + margin: 0; + padding: 0; + scrollbar-gutter: stable; + overflow: hidden; } code {