From a6c6916bf6de88d5c2b20cea159ee31c0fb098a0 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:06:04 +0530 Subject: [PATCH 01/12] feat: start recording --- src/api/recording.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/api/recording.ts diff --git a/src/api/recording.ts b/src/api/recording.ts new file mode 100644 index 00000000..cc1aa980 --- /dev/null +++ b/src/api/recording.ts @@ -0,0 +1,18 @@ +import { AxiosResponse } from "axios"; + +const axios = require('axios').default; + + +export const startRecording = async() : Promise => { + try { + const response = await axios.get('http://localhost:8080/record/start') + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t start recording'); + } + } catch(error: any) { + return ''; + } +}; + From 7018e7dde0955bafb726373209f87335a6843d11 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:06:22 +0530 Subject: [PATCH 02/12] feat: stop recording --- src/api/recording.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/recording.ts b/src/api/recording.ts index cc1aa980..b8247b53 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -16,3 +16,11 @@ export const startRecording = async() : Promise => { } }; +export const stopRecording = async (id: string): Promise => { + await axios.get(`http://localhost:8080/record/stop/${id}`) + .then((response : AxiosResponse) => { + }) + .catch((error: any) => { + }); +}; + From 7b4d213a062955ba4dfbd353aafe26e4373f5685 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:06:38 +0530 Subject: [PATCH 03/12] feat: get active browser id --- src/api/recording.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/recording.ts b/src/api/recording.ts index b8247b53..89ae4dfe 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -24,3 +24,16 @@ export const stopRecording = async (id: string): Promise => { }); }; +export const getActiveBrowserId = async(): Promise => { + try { + const response = await axios.get('http://localhost:8080/record/active'); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t get active browser'); + } + } catch(error: any) { + return ''; + } +}; + From 920d351ccf0a318f01423559b4418a1a5e4d5de8 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:06:58 +0530 Subject: [PATCH 04/12] feat: interpret current recording --- src/api/recording.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/recording.ts b/src/api/recording.ts index 89ae4dfe..c399ca1b 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -37,3 +37,17 @@ export const getActiveBrowserId = async(): Promise => { } }; +export const interpretCurrentRecording = async(): Promise => { + try { + const response = await axios.get('http://localhost:8080/record/interpret'); + if (response.status === 200) { + return true; + } else { + throw new Error('Couldn\'t interpret current recording'); + } + } catch(error: any) { + console.log(error); + return false; + } +}; + From 812f2b10051c1f54865b39b87dd2b0f88e1816a8 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:07:17 +0530 Subject: [PATCH 05/12] feat: stop current interpretation --- src/api/recording.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/recording.ts b/src/api/recording.ts index c399ca1b..6730b6bb 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -51,3 +51,16 @@ export const interpretCurrentRecording = async(): Promise => { } }; +export const stopCurrentInterpretation = async(): Promise => { + try { + const response = await axios.get('http://localhost:8080/record/interpret/stop'); + if (response.status === 200) { + return; + } else { + throw new Error('Couldn\'t interpret current recording'); + } + } catch(error: any) { + console.log(error); + } +}; + From 823a708c276e24aa94021e05e4cba567561f04c1 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:07:30 +0530 Subject: [PATCH 06/12] feat: get current url --- src/api/recording.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/recording.ts b/src/api/recording.ts index 6730b6bb..186ef74b 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -64,3 +64,18 @@ export const stopCurrentInterpretation = async(): Promise => { } }; +export const getCurrentUrl = async (): Promise => { + try { + const response = await axios.get('http://localhost:8080/record/active/url'); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t retrieve stored recordings'); + } + } catch(error: any) { + console.log(error); + return null; + } +}; + + From 8b82414345db826a104dc9a05e4deb70903b7ecd Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:07:37 +0530 Subject: [PATCH 07/12] feat: get current tabs --- src/api/recording.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/recording.ts b/src/api/recording.ts index 186ef74b..9105de6f 100644 --- a/src/api/recording.ts +++ b/src/api/recording.ts @@ -78,4 +78,16 @@ export const getCurrentUrl = async (): Promise => { } }; - +export const getCurrentTabs = async (): Promise => { + try { + const response = await axios.get('http://localhost:8080/record/active/tabs'); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Couldn\'t retrieve stored recordings'); + } + } catch(error: any) { + console.log(error); + return null; + } +}; From 56ab7a3062c5fafb40f7fa68afe83640aa4c952e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:08:04 +0530 Subject: [PATCH 08/12] feat: get active workflow --- src/api/workflow.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/api/workflow.ts diff --git a/src/api/workflow.ts b/src/api/workflow.ts new file mode 100644 index 00000000..ab89675c --- /dev/null +++ b/src/api/workflow.ts @@ -0,0 +1,19 @@ +import { WhereWhatPair, WorkflowFile } from "@wbr-project/wbr-interpret"; +import { emptyWorkflow } from "../shared/constants"; + +const axios = require('axios').default; + +export const getActiveWorkflow = async(id: string) : Promise => { + try { + const response = await axios.get(`http://localhost:8080/workflow/${id}`) + if (response.status === 200) { + return response.data; + } else { + throw new Error('Something went wrong when fetching a recorded workflow'); + } + } catch(error: any) { + console.log(error); + return emptyWorkflow; + } +}; + From 505d2652b0bbd6a20cc467d4636bc8ed699599eb Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:08:34 +0530 Subject: [PATCH 09/12] feat: get active workflow params --- src/api/workflow.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/workflow.ts b/src/api/workflow.ts index ab89675c..b90a95be 100644 --- a/src/api/workflow.ts +++ b/src/api/workflow.ts @@ -17,3 +17,17 @@ export const getActiveWorkflow = async(id: string) : Promise => { } }; +export const getParamsOfActiveWorkflow = async(id: string) : Promise => { + try { + const response = await axios.get(`http://localhost:8080/workflow/params/${id}`) + if (response.status === 200) { + return response.data; + } else { + throw new Error('Something went wrong when fetching the parameters of the recorded workflow'); + } + } catch(error: any) { + console.log(error); + return null; + } +}; + From f0629418ec1f2471e4c4dfc30b487b328dccb172 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:08:55 +0530 Subject: [PATCH 10/12] feat: del workflow pair --- src/api/workflow.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/workflow.ts b/src/api/workflow.ts index b90a95be..822e23f8 100644 --- a/src/api/workflow.ts +++ b/src/api/workflow.ts @@ -31,3 +31,17 @@ export const getParamsOfActiveWorkflow = async(id: string) : Promise => { + try { + const response = await axios.delete(`http://localhost:8080/workflow/pair/${index}`); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Something went wrong when fetching an updated workflow'); + } + } catch (error: any) { + console.log(error); + return emptyWorkflow; + } +}; + From 1af5e4ce731e1d286c34ffd07eadd472006cb34d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:09:10 +0530 Subject: [PATCH 11/12] feat: add workflow pair --- src/api/workflow.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/api/workflow.ts b/src/api/workflow.ts index 822e23f8..be9c2186 100644 --- a/src/api/workflow.ts +++ b/src/api/workflow.ts @@ -45,3 +45,19 @@ export const deletePair = async(index: number): Promise => { } }; +export const AddPair = async(index: number, pair: WhereWhatPair): Promise => { + try { + const response = await axios.post(`http://localhost:8080/workflow/pair/${index}`, { + pair, + }, {headers: {'Content-Type': 'application/json'}}); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Something went wrong when fetching an updated workflow'); + } + } catch (error: any) { + console.log(error); + return emptyWorkflow; + } +}; + From 87e1e1db205094e0c726fc34290a0ba5a2f34e96 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 9 Jun 2024 01:09:21 +0530 Subject: [PATCH 12/12] feat: update workflow pair --- src/api/workflow.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/workflow.ts b/src/api/workflow.ts index be9c2186..212737cb 100644 --- a/src/api/workflow.ts +++ b/src/api/workflow.ts @@ -61,3 +61,18 @@ export const AddPair = async(index: number, pair: WhereWhatPair): Promise => { + try { + const response = await axios.put(`http://localhost:8080/workflow/pair/${index}`, { + pair, + }, {headers: {'Content-Type': 'application/json'}}); + if (response.status === 200) { + return response.data; + } else { + throw new Error('Something went wrong when fetching an updated workflow'); + } + } catch (error: any) { + console.log(error); + return emptyWorkflow; + } +};