Merge pull request #282 from getmaxun/outpre-fix

feat: add output preview data reset functionality
This commit is contained in:
Karishma
2024-12-22 19:32:26 +05:30
committed by GitHub
8 changed files with 46 additions and 3 deletions

View File

@@ -245,11 +245,15 @@
"mimetype": "Medientyp: ", "mimetype": "Medientyp: ",
"image_below": "Bild wird unten angezeigt:", "image_below": "Bild wird unten angezeigt:",
"separator": "--------------------------------------------------" "separator": "--------------------------------------------------"
},
"notifications": {
"reset_success": "Vorschau erfolgreich zurückgesetzt"
} }
}, },
"interpretation_buttons": { "interpretation_buttons": {
"buttons": { "buttons": {
"preview": "Vorschau der Ausgabedaten anzeigen", "preview": "Vorschau der Ausgabedaten anzeigen",
"reset": "Zurücksetzen",
"yes": "Ja", "yes": "Ja",
"no": "Nein" "no": "Nein"
}, },

View File

@@ -246,11 +246,15 @@
"mimetype": "mimetype: ", "mimetype": "mimetype: ",
"image_below": "Image is rendered below:", "image_below": "Image is rendered below:",
"separator": "--------------------------------------------------" "separator": "--------------------------------------------------"
},
"notifications": {
"reset_success": "Output Preview reset successfully"
} }
}, },
"interpretation_buttons": { "interpretation_buttons": {
"buttons": { "buttons": {
"preview": "Get Preview of Output Data", "preview": "Get Preview of Output Data",
"reset": "Reset",
"yes": "Yes", "yes": "Yes",
"no": "No" "no": "No"
}, },

View File

@@ -251,6 +251,7 @@
"interpretation_buttons": { "interpretation_buttons": {
"buttons": { "buttons": {
"preview": "Obtener Vista Previa de Datos de Salida", "preview": "Obtener Vista Previa de Datos de Salida",
"reset": "Restablecer",
"yes": "Sí", "yes": "Sí",
"no": "No" "no": "No"
}, },
@@ -264,6 +265,9 @@
"use_previous": "¿Desea usar su selección anterior como condición para realizar esta acción?", "use_previous": "¿Desea usar su selección anterior como condición para realizar esta acción?",
"previous_action": "Su acción anterior fue: ", "previous_action": "Su acción anterior fue: ",
"element_text": "en un elemento con texto " "element_text": "en un elemento con texto "
},
"notifications": {
"reset_success": "Vista previa restablecida correctamente"
} }
}, },
"recording_page": { "recording_page": {

View File

@@ -246,11 +246,15 @@
"mimetype": "MIMEタイプ: ", "mimetype": "MIMEタイプ: ",
"image_below": "画像は以下に表示されます:", "image_below": "画像は以下に表示されます:",
"separator": "--------------------------------------------------" "separator": "--------------------------------------------------"
},
"notifications": {
"reset_success": "出力プレビューが正常にリセットされました"
} }
}, },
"interpretation_buttons": { "interpretation_buttons": {
"buttons": { "buttons": {
"preview": "出力データのプレビューを取得", "preview": "出力データのプレビューを取得",
"reset": "リセット",
"yes": "はい", "yes": "はい",
"no": "いいえ" "no": "いいえ"
}, },

View File

@@ -246,11 +246,15 @@
"mimetype": "MIME类型", "mimetype": "MIME类型",
"image_below": "图片显示如下:", "image_below": "图片显示如下:",
"separator": "--------------------------------------------------" "separator": "--------------------------------------------------"
},
"notifications": {
"reset_success": "输出预览已成功重置"
} }
}, },
"interpretation_buttons": { "interpretation_buttons": {
"buttons": { "buttons": {
"preview": "获取输出数据预览", "preview": "获取输出数据预览",
"reset": "重置",
"yes": "是", "yes": "是",
"no": "否" "no": "否"
}, },

View File

@@ -35,7 +35,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
const { width } = useBrowserDimensionsStore(); const { width } = useBrowserDimensionsStore();
const { socket } = useSocketStore(); const { socket } = useSocketStore();
const { currentWorkflowActionsState } = useGlobalInfoStore(); const { currentWorkflowActionsState, shouldResetInterpretationLog, notify } = useGlobalInfoStore();
const toggleDrawer = (newOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => { const toggleDrawer = (newOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
if ( if (
@@ -94,6 +94,14 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
setCustomValue(event.target.value); setCustomValue(event.target.value);
}; };
useEffect(() => {
if (shouldResetInterpretationLog) {
setLog('');
setTableData([]);
setBinaryData(null);
}
}, [shouldResetInterpretationLog]);
useEffect(() => { useEffect(() => {
socket?.on('log', handleLog); socket?.on('log', handleLog);
socket?.on('serializableCallback', handleSerializableCallback); socket?.on('serializableCallback', handleSerializableCallback);

View File

@@ -57,7 +57,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({}); const [hoverStates, setHoverStates] = useState<{ [id: string]: boolean }>({});
const [browserStepIdList, setBrowserStepIdList] = useState<number[]>([]); const [browserStepIdList, setBrowserStepIdList] = useState<number[]>([]);
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState } = 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 } = 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();
@@ -225,8 +225,9 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
if (hasTextSteps) { if (hasTextSteps) {
socket?.emit('action', { action: 'scrapeSchema', settings }); socket?.emit('action', { action: 'scrapeSchema', settings });
} }
resetInterpretationLog();
onFinishCapture(); onFinishCapture();
}, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps]); }, [stopGetText, getTextSettingsObject, socket, browserSteps, confirmedTextSteps, resetInterpretationLog]);
const getListSettingsObject = useCallback(() => { const getListSettingsObject = useCallback(() => {
let settings: { let settings: {

View File

@@ -32,6 +32,8 @@ interface GlobalInfo {
hasScreenshotAction: boolean; hasScreenshotAction: boolean;
hasScrapeSchemaAction: boolean; hasScrapeSchemaAction: boolean;
}) => void; }) => void;
shouldResetInterpretationLog: boolean;
resetInterpretationLog: () => void;
}; };
class GlobalInfoStore implements Partial<GlobalInfo> { class GlobalInfoStore implements Partial<GlobalInfo> {
@@ -53,6 +55,7 @@ class GlobalInfoStore implements Partial<GlobalInfo> {
hasScreenshotAction: false, hasScreenshotAction: false,
hasScrapeSchemaAction: false, hasScrapeSchemaAction: false,
}; };
shouldResetInterpretationLog = false;
}; };
const globalInfoStore = new GlobalInfoStore(); const globalInfoStore = new GlobalInfoStore();
@@ -71,6 +74,7 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName); const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName);
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 notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => { const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => {
setNotification({ severity, message, isOpen: true }); setNotification({ severity, message, isOpen: true });
@@ -87,6 +91,14 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
} }
} }
const resetInterpretationLog = () => {
setShouldResetInterpretationLog(true);
// Reset the flag after a short delay to allow components to respond
setTimeout(() => {
setShouldResetInterpretationLog(false);
}, 100);
}
return ( return (
<globalInfoContext.Provider <globalInfoContext.Provider
value={{ value={{
@@ -111,6 +123,8 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
setRecordingUrl, setRecordingUrl,
currentWorkflowActionsState, currentWorkflowActionsState,
setCurrentWorkflowActionsState, setCurrentWorkflowActionsState,
shouldResetInterpretationLog,
resetInterpretationLog,
}} }}
> >
{children} {children}