Files
parcer/src/api/recording.ts

94 lines
2.5 KiB
TypeScript
Raw Normal View History

2024-06-09 01:06:04 +05:30
import { AxiosResponse } from "axios";
const axios = require('axios').default;
export const startRecording = async() : Promise<string> => {
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 '';
}
};
2024-06-09 01:06:22 +05:30
export const stopRecording = async (id: string): Promise<void> => {
await axios.get(`http://localhost:8080/record/stop/${id}`)
.then((response : AxiosResponse<boolean>) => {
})
.catch((error: any) => {
});
};
2024-06-09 01:06:38 +05:30
export const getActiveBrowserId = async(): Promise<string> => {
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 '';
}
};
2024-06-09 01:06:58 +05:30
export const interpretCurrentRecording = async(): Promise<boolean> => {
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;
}
};
2024-06-09 01:07:17 +05:30
export const stopCurrentInterpretation = async(): Promise<void> => {
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);
}
};
2024-06-09 01:07:30 +05:30
export const getCurrentUrl = async (): Promise<string | null> => {
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;
}
};
2024-06-09 01:07:37 +05:30
export const getCurrentTabs = async (): Promise<string[] | null> => {
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;
}
};