Files
parcer/src/components/recorder/RightSidePanel.tsx

791 lines
29 KiB
TypeScript
Raw Normal View History

import React, { useState, useCallback, useEffect, useMemo } from 'react';
import { Button, Paper, Box, TextField, IconButton, Tooltip } from "@mui/material";
2024-10-08 18:39:59 +05:30
import { WorkflowFile } from "maxun-core";
2024-06-24 22:42:22 +05:30
import Typography from "@mui/material/Typography";
import { useGlobalInfoStore } from "../../context/globalInfo";
2024-09-08 13:52:01 +05:30
import { PaginationType, useActionContext, LimitType } from '../../context/browserActions';
2025-05-06 15:53:13 +05:30
import { BrowserStep, useBrowserSteps } from '../../context/browserSteps';
import { useSocketStore } from '../../context/socket';
2024-09-08 12:19:11 +05:30
import FormControlLabel from '@mui/material/FormControlLabel';
import FormControl from '@mui/material/FormControl';
import Radio from '@mui/material/Radio';
import RadioGroup from '@mui/material/RadioGroup';
2024-10-08 18:39:59 +05:30
import { getActiveWorkflow } from "../../api/workflow";
2025-01-09 20:15:27 +05:30
import ActionDescriptionBox from '../action/ActionDescriptionBox';
2024-11-10 11:29:06 +05:30
import { useThemeMode } from '../../context/theme-provider';
import { useTranslation } from 'react-i18next';
import { useBrowserDimensionsStore } from '../../context/browserDimensions';
import { emptyWorkflow } from '../../shared/constants';
import { clientListExtractor } from '../../helpers/clientListExtractor';
2025-07-06 16:19:27 +05:30
import { clientSelectorGenerator } from '../../helpers/clientSelectorGenerator';
2024-10-08 17:16:35 +05:30
2024-10-08 17:35:29 +05:30
const fetchWorkflow = (id: string, callback: (response: WorkflowFile) => void) => {
getActiveWorkflow(id).then(
(response) => {
if (response) {
callback(response);
} else {
throw new Error("No workflow found");
}
}
2025-06-26 22:43:42 +05:30
).catch((error) => { console.log(`Failed to fetch workflow:`,error.message) })
2024-10-08 17:35:29 +05:30
};
2024-08-06 06:04:22 +05:30
2024-09-08 07:39:09 +05:30
interface RightSidePanelProps {
onFinishCapture: () => void;
}
2024-10-19 18:44:52 +05:30
export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture }) => {
2024-09-14 02:00:37 +05:30
const [textLabels, setTextLabels] = useState<{ [id: string]: string }>({});
const [errors, setErrors] = useState<{ [id: string]: string }>({});
const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: string]: boolean }>({});
const [confirmedListTextFields, setConfirmedListTextFields] = useState<{ [listId: string]: { [fieldKey: string]: boolean } }>({});
const [showCaptureList, setShowCaptureList] = useState(true);
const [showCaptureScreenshot, setShowCaptureScreenshot] = useState(true);
const [showCaptureText, setShowCaptureText] = useState(true);
const { panelHeight } = useBrowserDimensionsStore();
2025-10-19 22:48:28 +05:30
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog, currentListActionId, setCurrentListActionId, currentTextActionId, setCurrentTextActionId, currentScreenshotActionId, setCurrentScreenshotActionId, isDOMMode, setIsDOMMode, currentSnapshot, setCurrentSnapshot, updateDOMMode, initialUrl, setRecordingUrl, currentTextGroupName } = useGlobalInfoStore();
const {
getText, startGetText, stopGetText,
getList, startGetList, stopGetList,
getScreenshot, startGetScreenshot, stopGetScreenshot,
startPaginationMode, stopPaginationMode,
paginationType, updatePaginationType,
limitType, customLimit, updateLimitType, updateCustomLimit,
stopLimitMode, startLimitMode,
captureStage, setCaptureStage,
showPaginationOptions, setShowPaginationOptions,
showLimitOptions, setShowLimitOptions,
workflow, setWorkflow,
activeAction, setActiveAction,
startAction, finishAction
} = useActionContext();
2025-10-19 22:48:28 +05:30
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField, updateListStepLimit, deleteStepsByActionId, updateListStepData, updateScreenshotStepData, emitActionForStep } = useBrowserSteps();
2024-10-08 17:41:50 +05:30
const { id, socket } = useSocketStore();
const { t } = useTranslation();
2024-06-24 22:42:22 +05:30
const isAnyActionActive = activeAction !== 'none';
2024-10-08 17:36:52 +05:30
const workflowHandler = useCallback((data: WorkflowFile) => {
setWorkflow(data);
}, [setWorkflow]);
2024-10-08 17:36:52 +05:30
useEffect(() => {
if (socket) {
const domModeHandler = (data: any) => {
if (!data.userId || data.userId === id) {
2025-07-06 21:47:01 +05:30
updateDOMMode(true);
}
};
const domcastHandler = (data: any) => {
if (!data.userId || data.userId === id) {
if (data.snapshotData && data.snapshotData.snapshot) {
2025-07-06 21:47:01 +05:30
updateDOMMode(true, data.snapshotData);
}
}
};
socket.on("dom-mode-enabled", domModeHandler);
socket.on("domcast", domcastHandler);
return () => {
socket.off("dom-mode-enabled", domModeHandler);
socket.off("domcast", domcastHandler);
};
}
2025-07-06 21:47:01 +05:30
}, [socket, id, updateDOMMode]);
useEffect(() => {
2024-10-08 18:05:57 +05:30
if (socket) {
socket.on("workflow", workflowHandler);
}
// fetch the workflow every time the id changes
if (id) {
fetchWorkflow(id, workflowHandler);
}
// fetch workflow in 15min intervals
let interval = setInterval(() => {
if (id) {
fetchWorkflow(id, workflowHandler);
}
2024-10-11 18:32:38 +05:30
}, (1000 * 60 * 15));
2024-10-08 18:05:57 +05:30
return () => {
socket?.off("workflow", workflowHandler);
clearInterval(interval);
2024-10-08 18:07:24 +05:30
};
}, [id, socket, workflowHandler]);
2024-10-08 18:07:24 +05:30
useEffect(() => {
2024-10-08 19:12:40 +05:30
const hasPairs = workflow.workflow.length > 0;
if (!hasPairs) {
2024-10-08 19:12:55 +05:30
setShowCaptureList(true);
setShowCaptureScreenshot(true);
setShowCaptureText(true);
return;
2024-10-08 19:12:40 +05:30
}
2024-10-08 19:16:27 +05:30
const hasScrapeListAction = workflow.workflow.some(pair =>
pair.what.some(action => action.action === 'scrapeList')
);
const hasScreenshotAction = workflow.workflow.some(pair =>
pair.what.some(action => action.action === 'screenshot')
);
const hasScrapeSchemaAction = workflow.workflow.some(pair =>
pair.what.some(action => action.action === 'scrapeSchema')
);
2024-10-08 18:53:17 +05:30
setCurrentWorkflowActionsState({
hasScrapeListAction,
hasScreenshotAction,
hasScrapeSchemaAction,
});
setShowCaptureList(true);
setShowCaptureScreenshot(true);
setShowCaptureText(true);
}, [workflow, setCurrentWorkflowActionsState]);
2024-10-08 18:36:19 +05:30
useEffect(() => {
if (socket) {
socket.on('listDataExtracted', (response) => {
if (!isDOMMode) {
const { currentListId, data } = response;
updateListStepData(currentListId, data);
}
});
}
return () => {
socket?.off('listDataExtracted');
};
}, [socket, updateListStepData, isDOMMode]);
2025-06-25 12:50:03 +05:30
useEffect(() => {
if (socket) {
const handleDirectScreenshot = (data: any) => {
const screenshotSteps = browserSteps.filter(step =>
step.type === 'screenshot' && step.actionId === currentScreenshotActionId
);
if (screenshotSteps.length > 0) {
const latestStep = screenshotSteps[screenshotSteps.length - 1];
updateScreenshotStepData(latestStep.id, data.screenshot);
2025-10-19 22:48:28 +05:30
emitActionForStep(latestStep);
2025-06-25 12:50:03 +05:30
}
setCurrentScreenshotActionId('');
};
socket.on('directScreenshotCaptured', handleDirectScreenshot);
return () => {
socket.off('directScreenshotCaptured', handleDirectScreenshot);
};
}
2025-10-19 22:48:28 +05:30
}, [socket, id, notify, t, currentScreenshotActionId, updateScreenshotStepData, setCurrentScreenshotActionId, emitActionForStep, browserSteps]);
2025-06-25 12:50:03 +05:30
const extractDataClientSide = useCallback(
(
listSelector: string,
fields: Record<string, any>,
currentListId: number
) => {
if (isDOMMode && currentSnapshot) {
try {
let iframeElement = document.querySelector(
"#dom-browser-iframe"
) as HTMLIFrameElement;
if (!iframeElement) {
iframeElement = document.querySelector(
"#browser-window iframe"
) as HTMLIFrameElement;
}
if (!iframeElement) {
const browserWindow = document.querySelector("#browser-window");
if (browserWindow) {
iframeElement = browserWindow.querySelector(
"iframe"
) as HTMLIFrameElement;
}
}
if (!iframeElement) {
console.error(
"Could not find the DOM iframe element for extraction"
);
return;
}
const iframeDoc = iframeElement.contentDocument;
if (!iframeDoc) {
console.error("Failed to get iframe document");
return;
}
const extractedData = clientListExtractor.extractListData(
iframeDoc,
listSelector,
fields,
5
);
updateListStepData(currentListId, extractedData);
2025-07-06 16:19:27 +05:30
if (extractedData.length === 0) {
console.warn("⚠️ No data extracted - this might indicate selector issues");
notify("warning", "No data was extracted. Please verify your selections.");
2025-07-06 16:19:27 +05:30
}
} catch (error) {
console.error("Error in client-side data extraction:", error);
notify("error", "Failed to extract data client-side");
}
} else {
if (!socket) {
console.error("Socket not available for backend extraction");
return;
}
try {
socket.emit("extractListData", {
listSelector,
fields,
currentListId,
pagination: { type: "", selector: "" },
});
} catch (error) {
console.error("Error in backend data extraction:", error);
}
}
},
2025-10-19 22:48:28 +05:30
[isDOMMode, currentSnapshot, updateListStepData, socket, notify, currentWorkflowActionsState]
);
2025-10-19 22:48:28 +05:30
useEffect(() => {
if (!getList) return;
2024-10-10 07:07:29 +05:30
2025-10-19 22:48:28 +05:30
const currentListStep = browserSteps.find(
step => step.type === 'list' && step.actionId === currentListActionId
) as (BrowserStep & { type: 'list'; listSelector?: string; fields?: Record<string, any> }) | undefined;
if (!currentListStep || !currentListStep.listSelector || !currentListStep.fields) return;
const fieldCount = Object.keys(currentListStep.fields).length;
if (fieldCount > 0) {
extractDataClientSide(
currentListStep.listSelector,
currentListStep.fields,
currentListStep.id
);
setCurrentWorkflowActionsState({
...currentWorkflowActionsState,
hasScrapeListAction: true
});
}
}, [browserSteps, currentListActionId, getList, extractDataClientSide, setCurrentWorkflowActionsState, currentWorkflowActionsState]);
2024-10-10 07:07:29 +05:30
const handleStartGetText = () => {
2025-05-26 21:41:40 +05:30
const newActionId = `text-${crypto.randomUUID()}`;
2025-05-20 17:58:07 +05:30
setCurrentTextActionId(newActionId);
startGetText();
}
const handleStartGetList = () => {
2025-05-26 21:41:40 +05:30
const newActionId = `list-${crypto.randomUUID()}`;
2025-05-20 17:58:07 +05:30
setCurrentListActionId(newActionId);
startGetList();
}
const handleStartGetScreenshot = () => {
2025-05-26 21:41:40 +05:30
const newActionId = `screenshot-${crypto.randomUUID()}`;
2025-05-20 17:58:07 +05:30
setCurrentScreenshotActionId(newActionId);
startGetScreenshot();
};
2024-08-06 03:25:52 +05:30
const stopCaptureAndEmitGetTextSettings = useCallback(() => {
2025-10-19 22:48:28 +05:30
const currentTextActionStep = browserSteps.find(step => step.type === 'text' && step.actionId === currentTextActionId);
if (!currentTextActionStep) {
notify('error', t('right_panel.errors.no_text_captured'));
return;
}
2024-08-06 03:25:52 +05:30
stopGetText();
2025-10-19 22:48:28 +05:30
if (currentTextActionStep) {
emitActionForStep(currentTextActionStep);
2024-10-10 18:34:04 +05:30
}
2025-05-20 17:58:07 +05:30
setCurrentTextActionId('');
resetInterpretationLog();
finishAction('text');
2024-10-10 18:34:04 +05:30
onFinishCapture();
2025-07-06 21:47:01 +05:30
clientSelectorGenerator.cleanup();
2025-10-19 22:48:28 +05:30
}, [stopGetText, socket, browserSteps, resetInterpretationLog, finishAction, notify, onFinishCapture, t, currentTextActionId, currentTextGroupName, emitActionForStep]);
2024-09-21 17:40:06 +05:30
const resetListState = useCallback(() => {
2024-09-04 05:34:56 +05:30
setShowPaginationOptions(false);
2024-09-08 13:53:22 +05:30
updatePaginationType('');
2024-09-08 14:02:56 +05:30
setShowLimitOptions(false);
2024-09-08 13:53:22 +05:30
updateLimitType('');
updateCustomLimit('');
}, [updatePaginationType, updateLimitType, updateCustomLimit]);
2024-09-08 13:52:23 +05:30
2024-09-04 05:35:16 +05:30
const handleStopGetList = useCallback(() => {
2024-09-04 05:34:56 +05:30
stopGetList();
resetListState();
2024-09-04 05:35:16 +05:30
}, [stopGetList, resetListState]);
2024-08-10 05:04:50 +05:30
const stopCaptureAndEmitGetListSettings = useCallback(() => {
const latestListStep = getLatestListStep(browserSteps);
2025-10-19 22:48:28 +05:30
if (latestListStep) {
extractDataClientSide(latestListStep.listSelector!, latestListStep.fields, latestListStep.id);
2025-10-19 22:48:28 +05:30
setCurrentWorkflowActionsState({
...currentWorkflowActionsState,
hasScrapeListAction: true
});
2025-10-19 22:48:28 +05:30
emitActionForStep(latestListStep);
handleStopGetList();
setCurrentListActionId('');
resetInterpretationLog();
finishAction('list');
onFinishCapture();
clientSelectorGenerator.cleanup();
2024-08-10 05:04:50 +05:30
} else {
notify('error', t('right_panel.errors.unable_create_settings'));
2025-10-19 22:48:28 +05:30
handleStopGetList();
setCurrentListActionId('');
resetInterpretationLog();
finishAction('list');
onFinishCapture();
clientSelectorGenerator.cleanup();
2024-08-10 05:06:43 +05:30
}
2025-10-19 22:48:28 +05:30
}, [socket, notify, handleStopGetList, resetInterpretationLog, finishAction, onFinishCapture, t, browserSteps, extractDataClientSide, setCurrentWorkflowActionsState, currentWorkflowActionsState, emitActionForStep]);
2025-05-06 15:53:13 +05:30
const getLatestListStep = (steps: BrowserStep[]) => {
const listSteps = steps.filter(step => step.type === 'list');
if (listSteps.length === 0) return null;
return listSteps.sort((a, b) => b.id - a.id)[0];
};
2024-10-10 19:29:21 +05:30
const handleConfirmListCapture = useCallback(() => {
switch (captureStage) {
case 'initial':
const hasValidListSelectorForCurrentAction = browserSteps.some(step =>
step.type === 'list' &&
step.actionId === currentListActionId &&
step.listSelector &&
Object.keys(step.fields).length > 0
);
if (!hasValidListSelectorForCurrentAction) {
notify('error', t('right_panel.errors.capture_list_first'));
return;
}
startPaginationMode();
2024-10-10 19:29:21 +05:30
setShowPaginationOptions(true);
setCaptureStage('pagination');
break;
case 'pagination':
if (!paginationType) {
notify('error', t('right_panel.errors.select_pagination'));
2024-10-10 19:29:21 +05:30
return;
}
2025-10-19 22:48:28 +05:30
const currentListStepForPagination = browserSteps.find(
step => step.type === 'list' && step.actionId === currentListActionId
) as (BrowserStep & { type: 'list' }) | undefined;
if (currentListStepForPagination) {
const paginationSelector = currentListStepForPagination.pagination?.selector;
if (['clickNext', 'clickLoadMore'].includes(paginationType) && !paginationSelector) {
notify('error', t('right_panel.errors.select_pagination_element'));
return;
}
2024-10-10 19:29:21 +05:30
}
stopPaginationMode();
setShowPaginationOptions(false);
startLimitMode();
setShowLimitOptions(true);
setCaptureStage('limit');
break;
case 'limit':
if (!limitType || (limitType === 'custom' && !customLimit)) {
notify('error', t('right_panel.errors.select_limit'));
2024-10-10 19:29:21 +05:30
return;
}
const limit = limitType === 'custom' ? parseInt(customLimit) : parseInt(limitType);
if (isNaN(limit) || limit <= 0) {
notify('error', t('right_panel.errors.invalid_limit'));
2024-10-10 19:29:21 +05:30
return;
}
2025-05-06 15:53:13 +05:30
const latestListStep = getLatestListStep(browserSteps);
if (latestListStep) {
updateListStepLimit(latestListStep.id, limit);
}
2024-10-10 19:29:21 +05:30
stopLimitMode();
setShowLimitOptions(false);
stopCaptureAndEmitGetListSettings();
setCaptureStage('complete');
break;
case 'complete':
setCaptureStage('initial');
break;
}
2025-10-19 22:48:28 +05:30
}, [captureStage, paginationType, limitType, customLimit, startPaginationMode, setShowPaginationOptions, setCaptureStage, notify, stopPaginationMode, startLimitMode, setShowLimitOptions, stopLimitMode, stopCaptureAndEmitGetListSettings, t, browserSteps, currentListActionId, updateListStepLimit]);
2024-09-08 13:52:23 +05:30
const handleBackCaptureList = useCallback(() => {
switch (captureStage) {
case 'limit':
stopLimitMode();
setShowLimitOptions(false);
startPaginationMode();
setShowPaginationOptions(true);
setCaptureStage('pagination');
break;
case 'pagination':
stopPaginationMode();
setShowPaginationOptions(false);
setCaptureStage('initial');
break;
}
}, [captureStage, stopLimitMode, startPaginationMode, stopPaginationMode]);
const handlePaginationSettingSelect = (option: PaginationType) => {
updatePaginationType(option);
};
2024-09-14 08:34:31 +05:30
const discardGetText = useCallback(() => {
2024-09-14 08:32:56 +05:30
stopGetText();
2025-05-20 17:58:07 +05:30
2025-10-19 22:48:28 +05:30
if (currentTextActionId) {
2025-05-20 17:58:07 +05:30
deleteStepsByActionId(currentTextActionId);
2025-10-19 22:48:28 +05:30
if (socket) {
socket.emit('removeAction', { actionId: currentTextActionId });
}
2025-05-20 17:58:07 +05:30
}
setCurrentTextActionId('');
2025-07-06 21:47:01 +05:30
clientSelectorGenerator.cleanup();
notify('error', t('right_panel.errors.capture_text_discarded'));
2025-10-19 22:48:28 +05:30
}, [currentTextActionId, browserSteps, stopGetText, deleteStepsByActionId, notify, t, socket]);
2024-09-14 08:38:32 +05:30
2024-09-14 08:34:31 +05:30
const discardGetList = useCallback(() => {
2024-09-14 08:33:23 +05:30
stopGetList();
2025-05-20 17:58:07 +05:30
if (currentListActionId) {
deleteStepsByActionId(currentListActionId);
2025-10-19 22:48:28 +05:30
if (socket) {
socket.emit('removeAction', { actionId: currentListActionId });
}
2025-05-20 17:58:07 +05:30
}
2024-09-14 08:33:23 +05:30
resetListState();
stopPaginationMode();
stopLimitMode();
2024-10-17 00:32:16 +05:30
setShowPaginationOptions(false);
setShowLimitOptions(false);
setCaptureStage('initial');
2025-05-20 17:58:07 +05:30
setCurrentListActionId('');
2025-07-06 21:47:01 +05:30
clientSelectorGenerator.cleanup();
notify('error', t('right_panel.errors.capture_list_discarded'));
2025-10-19 22:48:28 +05:30
}, [currentListActionId, browserSteps, stopGetList, deleteStepsByActionId, resetListState, setShowPaginationOptions, setShowLimitOptions, setCaptureStage, notify, t, stopPaginationMode, stopLimitMode, socket]);
2024-09-14 08:32:56 +05:30
const captureScreenshot = (fullPage: boolean) => {
2025-10-19 22:48:28 +05:30
const screenshotCount = browserSteps.filter(s => s.type === 'screenshot').length + 1;
const screenshotName = `Screenshot ${screenshotCount}`;
2025-06-25 12:50:03 +05:30
const screenshotSettings = {
fullPage,
2025-06-25 12:50:03 +05:30
type: 'png' as const,
2024-08-05 23:24:11 +05:30
timeout: 30000,
2025-06-25 12:50:03 +05:30
animations: 'allow' as const,
caret: 'hide' as const,
scale: 'device' as const,
2025-10-19 22:48:28 +05:30
name: screenshotName,
actionId: currentScreenshotActionId
};
2025-06-25 12:50:03 +05:30
socket?.emit('captureDirectScreenshot', screenshotSettings);
2025-05-20 17:58:07 +05:30
addScreenshotStep(fullPage, currentScreenshotActionId);
stopGetScreenshot();
resetInterpretationLog();
finishAction('screenshot');
onFinishCapture();
2025-10-19 22:48:28 +05:30
clientSelectorGenerator.cleanup();
};
2024-11-10 11:29:06 +05:30
const theme = useThemeMode();
const isDarkMode = theme.darkMode;
2025-03-14 23:47:46 +05:30
2024-06-24 22:42:22 +05:30
return (
2025-11-05 23:44:30 +05:30
<Paper sx={{ height: panelHeight, width: 'auto', alignItems: "center", background: 'inherit' }} id="browser-actions" elevation={0}>
2025-01-09 17:16:14 +05:30
<ActionDescriptionBox isDarkMode={isDarkMode} />
2025-11-05 23:44:30 +05:30
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '13px' }}>
{!isAnyActionActive && (
<>
{showCaptureList && (
<Button
variant="contained"
onClick={handleStartGetList}
>
{t('right_panel.buttons.capture_list')}
</Button>
)}
{showCaptureText && (
<Button
variant="contained"
onClick={handleStartGetText}
>
{t('right_panel.buttons.capture_text')}
</Button>
)}
{showCaptureScreenshot && (
<Button
variant="contained"
onClick={handleStartGetScreenshot}
>
{t('right_panel.buttons.capture_screenshot')}
</Button>
)}
</>
)}
2025-01-09 17:16:14 +05:30
2024-09-08 13:52:01 +05:30
{getList && (
<Box>
2024-10-10 20:16:07 +05:30
<Box display="flex" justifyContent="space-between" gap={2} style={{ margin: '15px' }}>
{(captureStage === 'pagination' || captureStage === 'limit') && (
<Button
variant="outlined"
onClick={handleBackCaptureList}
2025-01-09 17:16:14 +05:30
sx={{
color: '#ff00c3 !important',
borderColor: '#ff00c3 !important',
2025-01-08 20:53:02 +05:30
backgroundColor: 'whitesmoke !important',
2025-01-09 17:16:14 +05:30
}}
>
{t('right_panel.buttons.back')}
</Button>
)}
2025-10-19 22:48:28 +05:30
<Button
variant="outlined"
onClick={handleConfirmListCapture}
sx={{
color: '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: 'whitesmoke !important',
}}
2024-10-10 20:16:07 +05:30
>
{captureStage === 'initial' ? t('right_panel.buttons.confirm_capture') :
2025-01-09 17:16:14 +05:30
captureStage === 'pagination' ? t('right_panel.buttons.confirm_pagination') :
captureStage === 'limit' ? t('right_panel.buttons.confirm_limit') :
t('right_panel.buttons.finish_capture')}
2025-10-19 22:48:28 +05:30
</Button>
2025-01-09 17:16:14 +05:30
<Button
variant="outlined"
color="error"
onClick={discardGetList}
sx={{
color: 'red !important',
borderColor: 'red !important',
2025-01-08 20:53:02 +05:30
backgroundColor: 'whitesmoke !important',
}}
>
{t('right_panel.buttons.discard')}
2024-10-10 20:16:07 +05:30
</Button>
</Box>
{showPaginationOptions && (
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '13px' }}>
<Typography>{t('right_panel.pagination.title')}</Typography>
<Button
variant={paginationType === 'clickNext' ? "contained" : "outlined"}
onClick={() => handlePaginationSettingSelect('clickNext')}
sx={{
color: paginationType === 'clickNext' ? 'whitesmoke !important' : '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: paginationType === 'clickNext' ? '#ff00c3 !important' : 'whitesmoke !important',
}}>
{t('right_panel.pagination.click_next')}
</Button>
<Button
variant={paginationType === 'clickLoadMore' ? "contained" : "outlined"}
onClick={() => handlePaginationSettingSelect('clickLoadMore')}
sx={{
color: paginationType === 'clickLoadMore' ? 'whitesmoke !important' : '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: paginationType === 'clickLoadMore' ? '#ff00c3 !important' : 'whitesmoke !important',
}}>
{t('right_panel.pagination.click_load_more')}
</Button>
<Button
variant={paginationType === 'scrollDown' ? "contained" : "outlined"}
onClick={() => handlePaginationSettingSelect('scrollDown')}
sx={{
color: paginationType === 'scrollDown' ? 'whitesmoke !important' : '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: paginationType === 'scrollDown' ? '#ff00c3 !important' : 'whitesmoke !important',
}}>
{t('right_panel.pagination.scroll_down')}
</Button>
<Button
variant={paginationType === 'scrollUp' ? "contained" : "outlined"}
onClick={() => handlePaginationSettingSelect('scrollUp')}
sx={{
color: paginationType === 'scrollUp' ? 'whitesmoke !important' : '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: paginationType === 'scrollUp' ? '#ff00c3 !important' : 'whitesmoke !important',
}}>
{t('right_panel.pagination.scroll_up')}
</Button>
<Button
variant={paginationType === 'none' ? "contained" : "outlined"}
onClick={() => handlePaginationSettingSelect('none')}
sx={{
color: paginationType === 'none' ? 'whitesmoke !important' : '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: paginationType === 'none' ? '#ff00c3 !important' : 'whitesmoke !important',
}}>
{t('right_panel.pagination.none')}</Button>
</Box>
)}
{showLimitOptions && (
<FormControl>
2025-09-16 11:19:05 +05:30
<Typography variant="h6" sx={{
fontSize: '16px',
fontWeight: 'bold',
mb: 1,
whiteSpace: 'normal',
wordBreak: 'break-word'
}}>
{t('right_panel.limit.title')}
</Typography>
<RadioGroup
value={limitType}
onChange={(e) => updateLimitType(e.target.value as LimitType)}
sx={{
display: 'flex',
flexDirection: 'column',
2025-05-01 02:43:39 +05:30
width: '100%',
}}
>
<FormControlLabel value="10" control={<Radio />} label="10" />
<FormControlLabel value="100" control={<Radio />} label="100" />
<div style={{ display: 'flex', alignItems: 'center' }}>
<FormControlLabel value="custom" control={<Radio />} label={t('right_panel.limit.custom')} />
{limitType === 'custom' && (
<TextField
type="number"
value={customLimit}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(e.target.value);
if (e.target.value === '' || value >= 1) {
updateCustomLimit(e.target.value);
}
}}
inputProps={{
min: 1,
onKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => {
const value = (e.target as HTMLInputElement).value + e.key;
if (parseInt(value) < 1) {
e.preventDefault();
}
}
}}
placeholder={t('right_panel.limit.enter_number')}
sx={{
marginLeft: '10px',
'& input': {
padding: '10px',
},
width: '150px',
background: isDarkMode ? "#1E2124" : 'white',
color: isDarkMode ? "white" : 'black',
}}
/>
)}
</div>
</RadioGroup>
</FormControl>
)}
2024-08-31 01:19:24 +05:30
</Box>
)}
{getText && (
<Box>
2024-08-06 06:04:22 +05:30
<Box display="flex" justifyContent="space-between" gap={2} style={{ margin: '15px' }}>
2025-01-09 17:16:14 +05:30
<Button
variant="outlined"
onClick={stopCaptureAndEmitGetTextSettings}
sx={{
2025-01-08 20:53:02 +05:30
color: '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: 'whitesmoke !important',
}}
>
2025-01-09 17:16:14 +05:30
{t('right_panel.buttons.confirm')}
2025-01-08 20:53:02 +05:30
</Button>
2025-01-09 17:16:14 +05:30
<Button
variant="outlined"
color="error"
onClick={discardGetText}
sx={{
2025-01-08 20:53:02 +05:30
color: '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: 'whitesmoke !important',
}}
>
2025-01-09 17:16:14 +05:30
{t('right_panel.buttons.discard')}
2025-01-08 20:53:02 +05:30
</Button>
2024-08-06 06:04:22 +05:30
</Box>
</Box>
)}
{getScreenshot && (
<Box display="flex" flexDirection="column" gap={2}>
<Button variant="contained" onClick={() => captureScreenshot(true)}>
{t('right_panel.screenshot.capture_fullpage')}
</Button>
<Button variant="contained" onClick={() => captureScreenshot(false)}>
{t('right_panel.screenshot.capture_visible')}
</Button>
2025-01-09 17:16:14 +05:30
<Button
variant="outlined"
color="error"
onClick={() => {
stopGetScreenshot();
setActiveAction('none');
}}
2025-01-09 17:16:14 +05:30
sx={{
2025-01-08 20:53:02 +05:30
color: '#ff00c3 !important',
borderColor: '#ff00c3 !important',
backgroundColor: 'whitesmoke !important',
}}
>
2025-01-09 17:16:14 +05:30
{t('right_panel.buttons.discard')}
2025-01-08 20:53:02 +05:30
</Button>
</Box>
)}
2024-07-25 01:56:31 +05:30
</Box>
2024-06-24 22:42:22 +05:30
</Paper>
);
2025-09-13 18:35:47 +05:30
};