Merge branch 'develop' into ui-fix

This commit is contained in:
Amit Chauhan
2024-12-08 05:46:00 +05:30
committed by GitHub
29 changed files with 451 additions and 116 deletions

View File

@@ -1,4 +1,4 @@
import { Box, Button, Stack, Typography } from "@mui/material";
import { Box, Button, Stack, Typography, CircularProgress } from "@mui/material";
import { PlayCircle } from "@mui/icons-material";
import React, { useCallback, useEffect, useState } from "react";
import { interpretCurrentRecording, stopCurrentInterpretation } from "../../api/recording";
@@ -105,9 +105,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
const finished = await interpretCurrentRecording();
setInfo({ ...info, running: false });
if (finished) {
notify('info', 'Interpretation finished');
notify('info', 'Run finished');
} else {
notify('error', 'Interpretation failed to start');
notify('error', 'Run failed to start');
}
}
};
@@ -139,7 +139,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
disabled={info.running}
sx={{ display: 'grid' }}
>
{info.running ? 'Extracting data...please wait' : 'Get Preview of Output Data'}
{info.running ? <Box sx={{ display: 'flex', alignItems: 'center' }}>
<CircularProgress size={22} color="inherit" sx={{ marginRight: '10px' }} /> Extracting data...please wait for 10secs to 1min
</Box> : 'Get Preview of Output Data'}
</Button>
<GenericModal
onClose={() => { }}

View File

@@ -168,6 +168,7 @@ export const NavBar: React.FC<NavBarProps> = ({ recordingName, isRecording }) =>
);
return (
<NavBarWrapper mode={darkMode ? 'dark' : 'light'}>
{renderBrandSection()}
{user && (
@@ -183,6 +184,8 @@ export const NavBar: React.FC<NavBarProps> = ({ recordingName, isRecording }) =>
)}
</ControlsContainer>
)}
</NavBarWrapper>
);
};

View File

@@ -151,9 +151,6 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
row.name.toLowerCase().includes(searchTerm.toLowerCase())
);
return (
<React.Fragment>
<Box display="flex" justifyContent="space-between" alignItems="center">
@@ -249,25 +246,25 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
<TableCell key={column.id} align={column.align}>
<OptionsButton
handleEdit={() => handleEditRobot(row.id, row.name, row.params || [])}
handleDuplicate={() => {
handleDuplicateRobot(row.id, row.name, row.params || []);
}}
handleDelete={() => {
checkRunsForRecording(row.id).then((result: boolean) => {
if (result) {
notify('warning', 'Cannot delete recording as it has active runs');
notify('warning', 'Cannot delete robot as it has associated runs');
}
})
deleteRecordingFromStorage(row.id).then((result: boolean) => {
if (result) {
setRows([]);
notify('success', 'Recording deleted successfully');
notify('success', 'Robot deleted successfully');
fetchRecordings();
}
})
}}
handleDuplicate={() => {
handleDuplicateRobot(row.id, row.name, row.params || []);
}}
/>
</TableCell>
);
@@ -420,18 +417,18 @@ const OptionsButton = ({ handleEdit, handleDelete, handleDuplicate }: OptionsBut
</ListItemIcon>
<ListItemText>Edit</ListItemText>
</MenuItem>
<MenuItem onClick={() => { handleDelete(); handleClose(); }}>
<ListItemIcon>
<DeleteForever fontSize="small" />
</ListItemIcon>
<ListItemText>Delete</ListItemText>
</MenuItem>
<MenuItem onClick={() => { handleDuplicate(); handleClose(); }}>
<ListItemIcon>
<ContentCopy fontSize="small" />
</ListItemIcon>
<ListItemText>Duplicate</ListItemText>
</MenuItem>
<MenuItem onClick={() => { handleDelete(); handleClose(); }}>
<ListItemIcon>
<DeleteForever fontSize="small" />
</ListItemIcon>
<ListItemText>Delete</ListItemText>
</MenuItem>
</Menu>
</>
);

View File

@@ -155,9 +155,13 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
label="Robot Limit"
type="number"
value={robot.recording.workflow[0].what[0].args[0].limit || ''}
onChange={(e) =>
handleLimitChange(parseInt(e.target.value, 10) || 0)
}
onChange={(e) =>{
const value = parseInt(e.target.value, 10);
if (value >= 1) {
handleLimitChange(value);
}
}}
inputProps={{ min: 1 }}
style={{ marginBottom: '20px' }}
/>
)}

View File

@@ -46,7 +46,7 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
};
const exitRecording = useCallback(async () => {
notify('success', 'Recording saved successfully');
notify('success', 'Robot saved successfully');
if (browserId) {
await stopRecording(browserId);
}

View File

@@ -36,9 +36,9 @@ const ApiKeyManager = () => {
const [copySuccess, setCopySuccess] = useState<boolean>(false);
const { notify } = useGlobalInfoStore();
useEffect(() => {
const fetchApiKey = async () => {
@@ -53,7 +53,7 @@ const ApiKeyManager = () => {
};
fetchApiKey();
}, []);
const generateApiKey = async () => {
@@ -61,7 +61,7 @@ const ApiKeyManager = () => {
try {
const { data } = await axios.post(`${apiUrl}/auth/generate-api-key`);
setApiKey(data.api_key);
notify('success', `Generated API Key successfully`);
} catch (error: any) {
notify('error', `Failed to generate API Key - ${error.message}`);
@@ -88,11 +88,25 @@ const ApiKeyManager = () => {
navigator.clipboard.writeText(apiKey);
setCopySuccess(true);
setTimeout(() => setCopySuccess(false), 2000);
notify('info', 'Copied to clipboard');
notify('info', 'Copied API Key successfully');
}
};
if (loading) return <CircularProgress />;
if (loading) {
return (
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
width: '100vw',
}}
>
<CircularProgress />
</Box>
);
}
return (
<Container sx={{ alignSelf: 'flex-start' }}>

View File

@@ -55,6 +55,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
const [showCaptureScreenshot, setShowCaptureScreenshot] = useState(true);
const [showCaptureText, setShowCaptureText] = useState(true);
const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({});
const [browserStepIdList, setBrowserStepIdList] = useState<number[]>([]);
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState } = useGlobalInfoStore();
const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode, captureStage, setCaptureStage } = useActionContext();
@@ -196,12 +197,18 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
const getTextSettingsObject = useCallback(() => {
const settings: Record<string, { selector: string; tag?: string;[key: string]: any }> = {};
browserSteps.forEach(step => {
if (browserStepIdList.includes(step.id)) {
return;
}
if (step.type === 'text' && step.label && step.selectorObj?.selector) {
settings[step.label] = step.selectorObj;
}
setBrowserStepIdList(prevList => [...prevList, step.id]);
});
return settings;
}, [browserSteps]);
}, [browserSteps, browserStepIdList]);
const stopCaptureAndEmitGetTextSettings = useCallback(() => {
@@ -212,6 +219,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
}
stopGetText();
const settings = getTextSettingsObject();
console.log("SETTINGS", settings);
const hasTextSteps = browserSteps.some(step => step.type === 'text');
if (hasTextSteps) {
socket?.emit('action', { action: 'scrapeSchema', settings });