feat: pass id everywhereeeeeeee
This commit is contained in:
@@ -15,7 +15,7 @@ import { ScheduleSettings } from "../components/molecules/ScheduleSettings";
|
|||||||
import { IntegrationSettings } from "../components/molecules/IntegrationSettings";
|
import { IntegrationSettings } from "../components/molecules/IntegrationSettings";
|
||||||
|
|
||||||
interface MainPageProps {
|
interface MainPageProps {
|
||||||
handleEditRecording: (fileName: string) => void;
|
handleEditRecording: (id: string, fileName: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateRunResponse {
|
export interface CreateRunResponse {
|
||||||
@@ -32,6 +32,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
|
|
||||||
const [content, setContent] = React.useState('recordings');
|
const [content, setContent] = React.useState('recordings');
|
||||||
const [sockets, setSockets] = React.useState<Socket[]>([]);
|
const [sockets, setSockets] = React.useState<Socket[]>([]);
|
||||||
|
const [runningRecordingId, setRunningRecordingId] = React.useState('');
|
||||||
const [runningRecordingName, setRunningRecordingName] = React.useState('');
|
const [runningRecordingName, setRunningRecordingName] = React.useState('');
|
||||||
const [currentInterpretationLog, setCurrentInterpretationLog] = React.useState('');
|
const [currentInterpretationLog, setCurrentInterpretationLog] = React.useState('');
|
||||||
const [ids, setIds] = React.useState<CreateRunResponse>({
|
const [ids, setIds] = React.useState<CreateRunResponse>({
|
||||||
@@ -45,7 +46,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
|
|
||||||
const abortRunHandler = (runId: string) => {
|
const abortRunHandler = (runId: string) => {
|
||||||
aborted = true;
|
aborted = true;
|
||||||
notifyAboutAbort(runningRecordingName, runId).then(async (response) => {
|
notifyAboutAbort(runId).then(async (response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
notify('success', `Interpretation of ${runningRecordingName} aborted successfully`);
|
notify('success', `Interpretation of ${runningRecordingName} aborted successfully`);
|
||||||
await stopRecording(ids.browserId);
|
await stopRecording(ids.browserId);
|
||||||
@@ -55,12 +56,13 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const setFileName = (fileName: string) => {
|
const setRecordingInfo = (id: string, name: string) => {
|
||||||
setRunningRecordingName(fileName);
|
setRunningRecordingId(id);
|
||||||
|
setRunningRecordingName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const readyForRunHandler = useCallback((browserId: string, runId: string) => {
|
const readyForRunHandler = useCallback((browserId: string, runId: string) => {
|
||||||
interpretStoredRecording(runningRecordingName, runId).then(async (interpretation: boolean) => {
|
interpretStoredRecording(runId).then(async (interpretation: boolean) => {
|
||||||
if (!aborted) {
|
if (!aborted) {
|
||||||
if (interpretation) {
|
if (interpretation) {
|
||||||
notify('success', `Interpretation of ${runningRecordingName} succeeded`);
|
notify('success', `Interpretation of ${runningRecordingName} succeeded`);
|
||||||
@@ -82,7 +84,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
}, [currentInterpretationLog])
|
}, [currentInterpretationLog])
|
||||||
|
|
||||||
const handleRunRecording = useCallback((settings: RunSettings) => {
|
const handleRunRecording = useCallback((settings: RunSettings) => {
|
||||||
createRunForStoredRecording(runningRecordingName, settings).then(({ browserId, runId }: CreateRunResponse) => {
|
createRunForStoredRecording(runningRecordingId, settings).then(({ browserId, runId }: CreateRunResponse) => {
|
||||||
setIds({ browserId, runId });
|
setIds({ browserId, runId });
|
||||||
const socket =
|
const socket =
|
||||||
io(`http://localhost:8080/${browserId}`, {
|
io(`http://localhost:8080/${browserId}`, {
|
||||||
@@ -98,7 +100,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
} else {
|
} else {
|
||||||
notify('error', `Failed to run recording: ${runningRecordingName}`);
|
notify('error', `Failed to run recording: ${runningRecordingName}`);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return (socket: Socket, browserId: string, runId: string) => {
|
return (socket: Socket, browserId: string, runId: string) => {
|
||||||
socket.off('ready-for-run', () => readyForRunHandler(browserId, runId));
|
socket.off('ready-for-run', () => readyForRunHandler(browserId, runId));
|
||||||
socket.off('debugMessage', debugMessageHandler);
|
socket.off('debugMessage', debugMessageHandler);
|
||||||
@@ -133,7 +135,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
|
|||||||
return <Recordings
|
return <Recordings
|
||||||
handleEditRecording={handleEditRecording}
|
handleEditRecording={handleEditRecording}
|
||||||
handleRunRecording={handleRunRecording}
|
handleRunRecording={handleRunRecording}
|
||||||
setFileName={setFileName}
|
setRecordingInfo={setRecordingInfo}
|
||||||
handleScheduleRecording={handleScheduleRecording}
|
handleScheduleRecording={handleScheduleRecording}
|
||||||
handleIntegrateRecording={handleIntegrateRecording}
|
handleIntegrateRecording={handleIntegrateRecording}
|
||||||
/>;
|
/>;
|
||||||
|
|||||||
Reference in New Issue
Block a user