Merge pull request #314 from getmaxun/reset-browser
feat: reset remote browser recording state
This commit is contained in:
@@ -162,6 +162,7 @@
|
|||||||
"confirm_limit": "Bestätigen",
|
"confirm_limit": "Bestätigen",
|
||||||
"finish_capture": "Erfassung abschließen",
|
"finish_capture": "Erfassung abschließen",
|
||||||
"back": "Zurück",
|
"back": "Zurück",
|
||||||
|
"reset": "Starten Sie die Aufnahme neu",
|
||||||
"finish": "Fertig",
|
"finish": "Fertig",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"delete": "Löschen"
|
"delete": "Löschen"
|
||||||
@@ -226,10 +227,14 @@
|
|||||||
},
|
},
|
||||||
"browser_recording": {
|
"browser_recording": {
|
||||||
"modal": {
|
"modal": {
|
||||||
"confirm_discard": "Sind Sie sicher, dass Sie die Aufnahme verwerfen möchten?"
|
"confirm_discard": "Sind Sie sicher, dass Sie die Aufnahme verwerfen möchten?",
|
||||||
},
|
"confirm_reset": "Sind Sie sicher, dass Sie zurücksetzen möchten?",
|
||||||
|
"reset_warning": "Dadurch werden alle vorherigen Aufnahmen in der aktuellen Sitzung gelöscht. Die Aufnahmesitzung wird für dieselbe Website neu gestartet."
|
||||||
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"terminated": "Aktuelle Aufnahme wurde beendet"
|
"terminated": "Aktuelle Aufnahme wurde beendet",
|
||||||
|
"environment_reset": "Browser-Umgebung wurde zurückgesetzt",
|
||||||
|
"reset_successful": "Alle Aufnahmen erfolgreich zurückgesetzt und zum Ausgangszustand zurückgekehrt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interpretation_log": {
|
"interpretation_log": {
|
||||||
|
|||||||
@@ -161,8 +161,10 @@
|
|||||||
"confirm_capture": "Confirm Capture",
|
"confirm_capture": "Confirm Capture",
|
||||||
"confirm_pagination": "Confirm",
|
"confirm_pagination": "Confirm",
|
||||||
"confirm_limit": "Confirm",
|
"confirm_limit": "Confirm",
|
||||||
|
"confirm_reset": "Confirm",
|
||||||
"finish_capture": "Finish Capture",
|
"finish_capture": "Finish Capture",
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
|
"reset": "Restart Recording",
|
||||||
"finish": "Finish",
|
"finish": "Finish",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"delete": "Delete"
|
"delete": "Delete"
|
||||||
@@ -227,10 +229,14 @@
|
|||||||
},
|
},
|
||||||
"browser_recording": {
|
"browser_recording": {
|
||||||
"modal": {
|
"modal": {
|
||||||
"confirm_discard": "Are you sure you want to discard the recording?"
|
"confirm_discard": "Are you sure you want to discard the recording?",
|
||||||
|
"confirm_reset": "Are you sure you want to restart the recording?",
|
||||||
|
"reset_warning": "This will clear all previous captures in the current session. The recording session will restart for the same website."
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"terminated": "Current Recording was terminated"
|
"terminated": "Current Recording was terminated",
|
||||||
|
"environment_reset": "Browser environment has been reset",
|
||||||
|
"reset_successful": "Successfully reset all captures and returned to initial state"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interpretation_log": {
|
"interpretation_log": {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@
|
|||||||
"confirm_limit": "Confirmar",
|
"confirm_limit": "Confirmar",
|
||||||
"finish_capture": "Finalizar Captura",
|
"finish_capture": "Finalizar Captura",
|
||||||
"back": "Atrás",
|
"back": "Atrás",
|
||||||
|
"reset": "Reiniciar",
|
||||||
"finish": "Finalizar",
|
"finish": "Finalizar",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"delete": "Eliminar"
|
"delete": "Eliminar"
|
||||||
@@ -227,10 +228,14 @@
|
|||||||
},
|
},
|
||||||
"browser_recording": {
|
"browser_recording": {
|
||||||
"modal": {
|
"modal": {
|
||||||
"confirm_discard": "¿Está seguro de que desea descartar la grabación?"
|
"confirm_discard": "¿Está seguro de que desea descartar la grabación?",
|
||||||
|
"confirm_reset": "¿Está seguro de que desea reiniciar?",
|
||||||
|
"reset_warning": "Esto borrará todas las capturas anteriores de la sesión actual. La sesión de grabación se reiniciará para el mismo sitio web."
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"terminated": "La grabación actual fue terminada"
|
"terminated": "La grabación actual fue terminada",
|
||||||
|
"environment_reset": "El entorno del navegador ha sido reiniciado",
|
||||||
|
"reset_successful": "Se reiniciaron correctamente todas las capturas y se volvió al estado inicial"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interpretation_log": {
|
"interpretation_log": {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@
|
|||||||
"confirm_limit": "確認",
|
"confirm_limit": "確認",
|
||||||
"finish_capture": "取得を完了",
|
"finish_capture": "取得を完了",
|
||||||
"back": "戻る",
|
"back": "戻る",
|
||||||
|
"reset": "リセット",
|
||||||
"finish": "完了",
|
"finish": "完了",
|
||||||
"cancel": "キャンセル",
|
"cancel": "キャンセル",
|
||||||
"delete": "削除"
|
"delete": "削除"
|
||||||
@@ -227,10 +228,14 @@
|
|||||||
},
|
},
|
||||||
"browser_recording": {
|
"browser_recording": {
|
||||||
"modal": {
|
"modal": {
|
||||||
"confirm_discard": "録画を破棄してもよろしいですか?"
|
"confirm_discard": "録画を破棄してもよろしいですか?",
|
||||||
|
"confirm_reset": "リセットしてもよろしいですか?",
|
||||||
|
"reset_warning": "これにより、現在のセッションの以前のキャプチャがすべてクリアされます。同じ Web サイトの記録セッションが再開されます。"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"terminated": "現在の録画は終了しました"
|
"terminated": "現在の録画は終了しました",
|
||||||
|
"environment_reset": "ブラウザー環境がリセットされました",
|
||||||
|
"reset_successful": "すべてのキャプチャーを正常にリセットし、初期状態に戻りました"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interpretation_log": {
|
"interpretation_log": {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@
|
|||||||
"confirm_limit": "确认",
|
"confirm_limit": "确认",
|
||||||
"finish_capture": "完成捕获",
|
"finish_capture": "完成捕获",
|
||||||
"back": "返回",
|
"back": "返回",
|
||||||
|
"reset": "重置",
|
||||||
"finish": "完成",
|
"finish": "完成",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"delete": "删除"
|
"delete": "删除"
|
||||||
@@ -227,10 +228,14 @@
|
|||||||
},
|
},
|
||||||
"browser_recording": {
|
"browser_recording": {
|
||||||
"modal": {
|
"modal": {
|
||||||
"confirm_discard": "您确定要放弃录制吗?"
|
"confirm_discard": "您确定要放弃此录制吗?",
|
||||||
|
"confirm_reset": "您确定要重置吗?",
|
||||||
|
"reset_warning": "这将清除当前会话中的所有先前捕获。录制会话将针对同一网站重新启动。"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"terminated": "当前录制已终止"
|
"terminated": "当前录制已终止",
|
||||||
|
"environment_reset": "浏览器环境已重置",
|
||||||
|
"reset_successful": "已成功重置所有捕获并返回初始状态"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interpretation_log": {
|
"interpretation_log": {
|
||||||
|
|||||||
@@ -1,18 +1,44 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { Grid, Button, Box, Typography } from '@mui/material';
|
import { Grid, Button, Box, Typography, IconButton, Menu, MenuItem, ListItemText } from '@mui/material';
|
||||||
import { SaveRecording } from "../recorder/SaveRecording";
|
import { SaveRecording } from "../recorder/SaveRecording";
|
||||||
import { useGlobalInfoStore } from '../../context/globalInfo';
|
import { useGlobalInfoStore } from '../../context/globalInfo';
|
||||||
|
import { useActionContext } from '../../context/browserActions';
|
||||||
|
import { useBrowserSteps } from '../../context/browserSteps';
|
||||||
import { stopRecording } from "../../api/recording";
|
import { stopRecording } from "../../api/recording";
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { GenericModal } from "../ui/GenericModal";
|
import { GenericModal } from "../ui/GenericModal";
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { emptyWorkflow } from '../../shared/constants';
|
||||||
|
import { useSocketStore } from '../../context/socket';
|
||||||
|
import { MoreHoriz } from '@mui/icons-material';
|
||||||
|
|
||||||
const BrowserRecordingSave = () => {
|
const BrowserRecordingSave = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [openModal, setOpenModal] = useState<boolean>(false);
|
const [openDiscardModal, setOpenDiscardModal] = useState<boolean>(false);
|
||||||
const { recordingName, browserId, setBrowserId, notify } = useGlobalInfoStore();
|
const [openResetModal, setOpenResetModal] = useState<boolean>(false);
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||||
|
const { recordingName, browserId, initialUrl, setRecordingUrl, setBrowserId, notify, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const { socket } = useSocketStore();
|
||||||
|
|
||||||
|
const {
|
||||||
|
stopGetText,
|
||||||
|
stopGetList,
|
||||||
|
stopGetScreenshot,
|
||||||
|
stopPaginationMode,
|
||||||
|
stopLimitMode,
|
||||||
|
setCaptureStage,
|
||||||
|
updatePaginationType,
|
||||||
|
updateLimitType,
|
||||||
|
updateCustomLimit,
|
||||||
|
setShowLimitOptions,
|
||||||
|
setShowPaginationOptions,
|
||||||
|
setWorkflow,
|
||||||
|
} = useActionContext();
|
||||||
|
|
||||||
|
const { browserSteps, deleteBrowserStep } = useBrowserSteps();
|
||||||
|
|
||||||
const goToMainMenu = async () => {
|
const goToMainMenu = async () => {
|
||||||
if (browserId) {
|
if (browserId) {
|
||||||
await stopRecording(browserId);
|
await stopRecording(browserId);
|
||||||
@@ -22,6 +48,58 @@ const BrowserRecordingSave = () => {
|
|||||||
navigate('/');
|
navigate('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const performReset = () => {
|
||||||
|
stopGetText();
|
||||||
|
stopGetList();
|
||||||
|
stopGetScreenshot();
|
||||||
|
stopPaginationMode();
|
||||||
|
stopLimitMode();
|
||||||
|
|
||||||
|
setShowLimitOptions(false);
|
||||||
|
setShowPaginationOptions(false);
|
||||||
|
setCaptureStage('initial');
|
||||||
|
|
||||||
|
updatePaginationType('');
|
||||||
|
updateLimitType('');
|
||||||
|
updateCustomLimit('');
|
||||||
|
|
||||||
|
setCurrentWorkflowActionsState({
|
||||||
|
hasScrapeListAction: false,
|
||||||
|
hasScreenshotAction: false,
|
||||||
|
hasScrapeSchemaAction: false
|
||||||
|
});
|
||||||
|
|
||||||
|
setWorkflow(emptyWorkflow);
|
||||||
|
|
||||||
|
resetInterpretationLog();
|
||||||
|
|
||||||
|
// Clear all browser steps
|
||||||
|
browserSteps.forEach(step => {
|
||||||
|
deleteBrowserStep(step.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
socket?.emit('new-recording');
|
||||||
|
socket.emit('input:url', initialUrl);
|
||||||
|
// Update the URL in the navbar to match
|
||||||
|
setRecordingUrl(initialUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the reset confirmation modal
|
||||||
|
setOpenResetModal(false);
|
||||||
|
|
||||||
|
// Notify user
|
||||||
|
notify('info', t('browser_recording.notifications.environment_reset'));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container>
|
<Grid container>
|
||||||
<Grid item xs={12} md={3} lg={3}>
|
<Grid item xs={12} md={3} lg={3}>
|
||||||
@@ -40,7 +118,7 @@ const BrowserRecordingSave = () => {
|
|||||||
height: "48px"
|
height: "48px"
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setOpenModal(true)}
|
onClick={() => setOpenDiscardModal(true)}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="error"
|
color="error"
|
||||||
sx={{
|
sx={{
|
||||||
@@ -53,15 +131,62 @@ const BrowserRecordingSave = () => {
|
|||||||
>
|
>
|
||||||
{t('right_panel.buttons.discard')}
|
{t('right_panel.buttons.discard')}
|
||||||
</Button>
|
</Button>
|
||||||
<GenericModal isOpen={openModal} onClose={() => setOpenModal(false)} modalStyle={modalStyle}>
|
|
||||||
|
{/* Reset Button */}
|
||||||
|
<IconButton
|
||||||
|
aria-label="options"
|
||||||
|
size="small"
|
||||||
|
onClick={handleClick}
|
||||||
|
style={{
|
||||||
|
color: 'whitesmoke',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MoreHoriz />
|
||||||
|
</IconButton>
|
||||||
|
<Menu
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={Boolean(anchorEl)}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
<MenuItem onClick={() => { setOpenResetModal(true); handleClose(); }}>
|
||||||
|
<ListItemText>{t('right_panel.buttons.reset')}</ListItemText>
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<SaveRecording fileName={recordingName} />
|
||||||
|
|
||||||
|
{/* Discard Confirmation Modal */}
|
||||||
|
<GenericModal isOpen={openDiscardModal} onClose={() => setOpenDiscardModal(false)} modalStyle={modalStyle}>
|
||||||
<Box p={2}>
|
<Box p={2}>
|
||||||
<Typography variant="h6">{t('browser_recording.modal.confirm_discard')}</Typography>
|
<Typography variant="h6">{t('browser_recording.modal.confirm_discard')}</Typography>
|
||||||
<Box display="flex" justifyContent="space-between" mt={2}>
|
<Box display="flex" justifyContent="space-between" mt={2}>
|
||||||
<Button onClick={goToMainMenu} variant="contained" color="error">
|
<Button onClick={goToMainMenu} variant="contained" color="error">
|
||||||
{t('right_panel.buttons.discard')}
|
{t('right_panel.buttons.discard')}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button onClick={() => setOpenDiscardModal(false)} variant="outlined">
|
||||||
|
{t('right_panel.buttons.cancel')}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</GenericModal>
|
||||||
|
|
||||||
|
{/* Reset Confirmation Modal */}
|
||||||
|
<GenericModal isOpen={openResetModal} onClose={() => setOpenResetModal(false)} modalStyle={modalStyle}>
|
||||||
|
<Box p={2}>
|
||||||
|
<Typography variant="h6">{t('browser_recording.modal.confirm_reset')}</Typography>
|
||||||
|
<Typography variant="body2" sx={{ mt: 1, mb: 2 }}>
|
||||||
|
{t('browser_recording.modal.reset_warning')}
|
||||||
|
</Typography>
|
||||||
|
<Box display="flex" justifyContent="space-between" mt={2}>
|
||||||
|
<Button
|
||||||
|
onClick={performReset}
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
{t('right_panel.buttons.confirm_reset')}
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setOpenModal(false)}
|
onClick={() => setOpenResetModal(false)}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
sx={{
|
sx={{
|
||||||
color: '#ff00c3 !important',
|
color: '#ff00c3 !important',
|
||||||
@@ -73,12 +198,11 @@ const BrowserRecordingSave = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</GenericModal>
|
</GenericModal>
|
||||||
<SaveRecording fileName={recordingName} />
|
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default BrowserRecordingSave;
|
export default BrowserRecordingSave;
|
||||||
|
|
||||||
|
|||||||
@@ -45,13 +45,12 @@ interface RightSidePanelProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture }) => {
|
export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture }) => {
|
||||||
const [workflow, setWorkflow] = useState<WorkflowFile>(emptyWorkflow);
|
|
||||||
const [textLabels, setTextLabels] = useState<{ [id: string]: string }>({});
|
const [textLabels, setTextLabels] = useState<{ [id: string]: string }>({});
|
||||||
const [errors, setErrors] = useState<{ [id: string]: string }>({});
|
const [errors, setErrors] = useState<{ [id: string]: string }>({});
|
||||||
const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: string]: boolean }>({});
|
const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: string]: boolean }>({});
|
||||||
const [confirmedListTextFields, setConfirmedListTextFields] = useState<{ [listId: string]: { [fieldKey: string]: boolean } }>({});
|
const [confirmedListTextFields, setConfirmedListTextFields] = useState<{ [listId: string]: { [fieldKey: string]: boolean } }>({});
|
||||||
const [showPaginationOptions, setShowPaginationOptions] = useState(false);
|
// const [showPaginationOptions, setShowPaginationOptions] = useState(false);
|
||||||
const [showLimitOptions, setShowLimitOptions] = useState(false);
|
// const [showLimitOptions, setShowLimitOptions] = useState(false);
|
||||||
const [showCaptureList, setShowCaptureList] = useState(true);
|
const [showCaptureList, setShowCaptureList] = useState(true);
|
||||||
const [showCaptureScreenshot, setShowCaptureScreenshot] = useState(true);
|
const [showCaptureScreenshot, setShowCaptureScreenshot] = useState(true);
|
||||||
const [showCaptureText, setShowCaptureText] = useState(true);
|
const [showCaptureText, setShowCaptureText] = useState(true);
|
||||||
@@ -61,7 +60,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
||||||
|
|
||||||
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore();
|
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore();
|
||||||
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode, captureStage, setCaptureStage } = useActionContext();
|
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode, captureStage, setCaptureStage, showPaginationOptions, setShowPaginationOptions, showLimitOptions, setShowLimitOptions, workflow, setWorkflow } = useActionContext();
|
||||||
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField } = useBrowserSteps();
|
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField } = useBrowserSteps();
|
||||||
const { id, socket } = useSocketStore();
|
const { id, socket } = useSocketStore();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -69,7 +68,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const workflowHandler = useCallback((data: WorkflowFile) => {
|
const workflowHandler = useCallback((data: WorkflowFile) => {
|
||||||
setWorkflow(data);
|
setWorkflow(data);
|
||||||
//setRecordingLength(data.workflow.length);
|
//setRecordingLength(data.workflow.length);
|
||||||
}, [workflow])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const { notify, setRecordings, browserId, setBrowserId, recordingUrl, setRecordingUrl, recordingName, setRecordingName, recordingId, setRecordingId } = useGlobalInfoStore();
|
const { notify, setRecordings, browserId, setBrowserId, setInitialUrl, recordingUrl, setRecordingUrl, recordingName, setRecordingName, recordingId, setRecordingId } = useGlobalInfoStore();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleChangePage = (event: unknown, newPage: number) => {
|
const handleChangePage = (event: unknown, newPage: number) => {
|
||||||
@@ -142,6 +142,11 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
|||||||
handleStartRecording();
|
handleStartRecording();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setBrowserRecordingUrl = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setInitialUrl(event.target.value);
|
||||||
|
setRecordingUrl(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
fetchRecordings();
|
fetchRecordings();
|
||||||
@@ -307,7 +312,7 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
|
|||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
value={recordingUrl}
|
value={recordingUrl}
|
||||||
onChange={(e: any) => setRecordingUrl(e.target.value)}
|
onChange={setBrowserRecordingUrl}
|
||||||
style={{ marginBottom: '20px', marginTop: '20px' }}
|
style={{ marginBottom: '20px', marginTop: '20px' }}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React, { createContext, useContext, useState, ReactNode } from 'react';
|
import React, { createContext, useContext, useState, ReactNode } from 'react';
|
||||||
import { useSocketStore } from './socket';
|
import { useSocketStore } from './socket';
|
||||||
|
import { WorkflowFile } from 'maxun-core';
|
||||||
|
import { emptyWorkflow } from '../shared/constants';
|
||||||
|
|
||||||
export type PaginationType = 'scrollDown' | 'scrollUp' | 'clickNext' | 'clickLoadMore' | 'none' | '';
|
export type PaginationType = 'scrollDown' | 'scrollUp' | 'clickNext' | 'clickLoadMore' | 'none' | '';
|
||||||
export type LimitType = '10' | '100' | 'custom' | '';
|
export type LimitType = '10' | '100' | 'custom' | '';
|
||||||
@@ -13,8 +15,14 @@ interface ActionContextProps {
|
|||||||
limitMode: boolean;
|
limitMode: boolean;
|
||||||
paginationType: PaginationType;
|
paginationType: PaginationType;
|
||||||
limitType: LimitType;
|
limitType: LimitType;
|
||||||
|
workflow: WorkflowFile;
|
||||||
customLimit: string;
|
customLimit: string;
|
||||||
captureStage: CaptureStage;
|
captureStage: CaptureStage;
|
||||||
|
showPaginationOptions: boolean;
|
||||||
|
showLimitOptions: boolean;
|
||||||
|
setWorkflow: (workflow: WorkflowFile) => void;
|
||||||
|
setShowPaginationOptions: (show: boolean) => void;
|
||||||
|
setShowLimitOptions: (show: boolean) => void;
|
||||||
setCaptureStage: (stage: CaptureStage) => void;
|
setCaptureStage: (stage: CaptureStage) => void;
|
||||||
startPaginationMode: () => void;
|
startPaginationMode: () => void;
|
||||||
startGetText: () => void;
|
startGetText: () => void;
|
||||||
@@ -34,6 +42,7 @@ interface ActionContextProps {
|
|||||||
const ActionContext = createContext<ActionContextProps | undefined>(undefined);
|
const ActionContext = createContext<ActionContextProps | undefined>(undefined);
|
||||||
|
|
||||||
export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
||||||
|
const [workflow, setWorkflow] = useState<WorkflowFile>(emptyWorkflow);
|
||||||
const [getText, setGetText] = useState<boolean>(false);
|
const [getText, setGetText] = useState<boolean>(false);
|
||||||
const [getList, setGetList] = useState<boolean>(false);
|
const [getList, setGetList] = useState<boolean>(false);
|
||||||
const [getScreenshot, setGetScreenshot] = useState<boolean>(false);
|
const [getScreenshot, setGetScreenshot] = useState<boolean>(false);
|
||||||
@@ -43,6 +52,8 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
const [limitType, setLimitType] = useState<LimitType>('');
|
const [limitType, setLimitType] = useState<LimitType>('');
|
||||||
const [customLimit, setCustomLimit] = useState<string>('');
|
const [customLimit, setCustomLimit] = useState<string>('');
|
||||||
const [captureStage, setCaptureStage] = useState<CaptureStage>('initial');
|
const [captureStage, setCaptureStage] = useState<CaptureStage>('initial');
|
||||||
|
const [showPaginationOptions, setShowPaginationOptions] = useState(false);
|
||||||
|
const [showLimitOptions, setShowLimitOptions] = useState(false);
|
||||||
|
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
|
||||||
@@ -94,8 +105,14 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
limitMode,
|
limitMode,
|
||||||
paginationType,
|
paginationType,
|
||||||
limitType,
|
limitType,
|
||||||
|
workflow,
|
||||||
customLimit,
|
customLimit,
|
||||||
captureStage,
|
captureStage,
|
||||||
|
showPaginationOptions,
|
||||||
|
showLimitOptions,
|
||||||
|
setWorkflow,
|
||||||
|
setShowPaginationOptions,
|
||||||
|
setShowLimitOptions,
|
||||||
setCaptureStage,
|
setCaptureStage,
|
||||||
startGetText,
|
startGetText,
|
||||||
stopGetText,
|
stopGetText,
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ interface GlobalInfo {
|
|||||||
setRecordingId: (newId: string | null) => void;
|
setRecordingId: (newId: string | null) => void;
|
||||||
recordingName: string;
|
recordingName: string;
|
||||||
setRecordingName: (recordingName: string) => void;
|
setRecordingName: (recordingName: string) => void;
|
||||||
|
initialUrl: string;
|
||||||
|
setInitialUrl: (initialUrl: string) => void;
|
||||||
recordingUrl: string;
|
recordingUrl: string;
|
||||||
setRecordingUrl: (recordingUrl: string) => void;
|
setRecordingUrl: (recordingUrl: string) => void;
|
||||||
currentWorkflowActionsState: {
|
currentWorkflowActionsState: {
|
||||||
@@ -49,6 +51,7 @@ class GlobalInfoStore implements Partial<GlobalInfo> {
|
|||||||
recordings: string[] = [];
|
recordings: string[] = [];
|
||||||
rerenderRuns = false;
|
rerenderRuns = false;
|
||||||
recordingName = '';
|
recordingName = '';
|
||||||
|
initialUrl = 'https://';
|
||||||
recordingUrl = 'https://';
|
recordingUrl = 'https://';
|
||||||
currentWorkflowActionsState = {
|
currentWorkflowActionsState = {
|
||||||
hasScrapeListAction: false,
|
hasScrapeListAction: false,
|
||||||
@@ -72,6 +75,7 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
|
|||||||
const [recordingLength, setRecordingLength] = useState<number>(globalInfoStore.recordingLength);
|
const [recordingLength, setRecordingLength] = useState<number>(globalInfoStore.recordingLength);
|
||||||
const [recordingId, setRecordingId] = useState<string | null>(globalInfoStore.recordingId);
|
const [recordingId, setRecordingId] = useState<string | null>(globalInfoStore.recordingId);
|
||||||
const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName);
|
const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName);
|
||||||
|
const [initialUrl, setInitialUrl] = useState<string>(globalInfoStore.initialUrl);
|
||||||
const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl);
|
const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl);
|
||||||
const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState);
|
const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState);
|
||||||
const [shouldResetInterpretationLog, setShouldResetInterpretationLog] = useState<boolean>(globalInfoStore.shouldResetInterpretationLog);
|
const [shouldResetInterpretationLog, setShouldResetInterpretationLog] = useState<boolean>(globalInfoStore.shouldResetInterpretationLog);
|
||||||
@@ -119,6 +123,8 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
|
|||||||
setRecordingId,
|
setRecordingId,
|
||||||
recordingName,
|
recordingName,
|
||||||
setRecordingName,
|
setRecordingName,
|
||||||
|
initialUrl,
|
||||||
|
setInitialUrl,
|
||||||
recordingUrl,
|
recordingUrl,
|
||||||
setRecordingUrl,
|
setRecordingUrl,
|
||||||
currentWorkflowActionsState,
|
currentWorkflowActionsState,
|
||||||
|
|||||||
Reference in New Issue
Block a user