diff --git a/package.json b/package.json index 75350f1f..1cfa1894 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "lodash": "^4.17.21", "loglevel": "^1.8.0", "loglevel-plugin-remote": "^0.6.8", - "maxun-core": "^0.0.15", "minio": "^8.0.1", "moment-timezone": "^0.5.45", "node-cron": "^3.0.3", diff --git a/src/components/run/RunContent.tsx b/src/components/run/RunContent.tsx index 781fba70..55a69ba8 100644 --- a/src/components/run/RunContent.tsx +++ b/src/components/run/RunContent.tsx @@ -38,16 +38,16 @@ interface RunContentProps { export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRef, abortRunHandler }: RunContentProps) => { const { t } = useTranslation(); const [tab, setTab] = React.useState('output'); - + const [schemaData, setSchemaData] = useState([]); const [schemaColumns, setSchemaColumns] = useState([]); - + const [listData, setListData] = useState([]); const [listColumns, setListColumns] = useState([]); const [currentListIndex, setCurrentListIndex] = useState(0); const [expandedView, setExpandedView] = useState(null); - + const [viewMode, setViewMode] = useState<'horizontal' | 'vertical'>('vertical'); const [legacyData, setLegacyData] = useState([]); @@ -61,10 +61,10 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe useEffect(() => { if (!row.serializableOutput) return; - if (!row.serializableOutput.scrapeSchema && - !row.serializableOutput.scrapeList && - Object.keys(row.serializableOutput).length > 0) { - + if (!row.serializableOutput.scrapeSchema && + !row.serializableOutput.scrapeList && + Object.keys(row.serializableOutput).length > 0) { + setIsLegacyData(true); processLegacyData(row.serializableOutput); return; @@ -75,7 +75,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe if (row.serializableOutput.scrapeSchema && Object.keys(row.serializableOutput.scrapeSchema).length > 0) { processDataCategory(row.serializableOutput.scrapeSchema, setSchemaData, setSchemaColumns); } - + if (row.serializableOutput.scrapeList) { processScrapeList(row.serializableOutput.scrapeList); } @@ -83,7 +83,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const processLegacyData = (legacyOutput: Record) => { let allData: any[] = []; - + Object.keys(legacyOutput).forEach(key => { const data = legacyOutput[key]; if (Array.isArray(data)) { @@ -93,13 +93,13 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe allData = [...allData, ...filteredData]; } }); - + if (allData.length > 0) { const allColumns = new Set(); allData.forEach(item => { Object.keys(item).forEach(key => allColumns.add(key)); }); - + setLegacyData(allData); setLegacyColumns(Array.from(allColumns)); } @@ -111,7 +111,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe setColumns: React.Dispatch> ) => { let allData: any[] = []; - + Object.keys(categoryData).forEach(key => { const data = categoryData[key]; if (Array.isArray(data)) { @@ -121,13 +121,13 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe allData = [...allData, ...filteredData]; } }); - + if (allData.length > 0) { const allColumns = new Set(); allData.forEach(item => { Object.keys(item).forEach(key => allColumns.add(key)); }); - + setData(allData); setColumns(Array.from(allColumns)); } @@ -136,22 +136,22 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const processScrapeList = (scrapeListData: any) => { const tablesList: any[][] = []; const columnsList: string[][] = []; - + if (Array.isArray(scrapeListData)) { scrapeListData.forEach(tableData => { if (Array.isArray(tableData) && tableData.length > 0) { const filteredData = tableData.filter(row => Object.values(row).some(value => value !== undefined && value !== "") ); - + if (filteredData.length > 0) { tablesList.push(filteredData); - + const tableColumns = new Set(); filteredData.forEach(item => { Object.keys(item).forEach(key => tableColumns.add(key)); }); - + columnsList.push(Array.from(tableColumns)); } } @@ -163,21 +163,21 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const filteredData = tableData.filter(row => Object.values(row).some(value => value !== undefined && value !== "") ); - + if (filteredData.length > 0) { tablesList.push(filteredData); - + const tableColumns = new Set(); filteredData.forEach(item => { Object.keys(item).forEach(key => tableColumns.add(key)); }); - + columnsList.push(Array.from(tableColumns)); } } }); } - + setListData(tablesList); setListColumns(columnsList); setCurrentListIndex(0); @@ -217,7 +217,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe document.body.appendChild(link); link.click(); document.body.removeChild(link); - + setTimeout(() => { URL.revokeObjectURL(url); }, 100); @@ -225,7 +225,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const downloadAllJSON = () => { let allData; - + if (isLegacyData) { allData = { data: legacyData }; } else { @@ -234,7 +234,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe list: listData.flat(), }; } - + const blob = new Blob([JSON.stringify(allData, null, 2)], { type: 'application/json;charset=utf-8;' }); const url = URL.createObjectURL(blob); @@ -265,12 +265,12 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe ) => { if (!isPaginatedList && data.length === 0) return null; if (isPaginatedList && (listData.length === 0 || currentListIndex >= listData.length)) return null; - + const currentData = isPaginatedList ? listData[currentListIndex] : data; const currentColumns = isPaginatedList ? listColumns[currentListIndex] : columns; - + if (!currentData || currentData.length === 0) return null; - + return ( {isPaginatedList ? ( - 1 + 1 ? `Table ${currentListIndex + 1} of ${listData.length} (${currentData.length} ${currentData.length === 1 ? 'item' : 'items'})` : `${currentData.length} ${currentData.length === 1 ? 'item' : 'items'}` - } - size="small" - sx={{ ml: 2, backgroundColor: '#FF00C3', color: 'white' }} + } + size="small" + sx={{ ml: 2, backgroundColor: '#FF00C3', color: 'white' }} /> ) : ( - )} @@ -308,7 +308,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe startIcon={} onClick={() => { if (isPaginatedList) { - downloadCSV(currentData, currentColumns, `list_table_${currentListIndex+1}.csv`); + downloadCSV(currentData, currentColumns, `list_table_${currentListIndex + 1}.csv`); } else { downloadCSV(data, columns, csvFilename); } @@ -321,7 +321,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe startIcon={} onClick={() => { if (isPaginatedList) { - downloadJSON(currentData, `list_table_${currentListIndex+1}.json`); + downloadJSON(currentData, `list_table_${currentListIndex + 1}.json`); } else { downloadJSON(data, jsonFilename); } @@ -331,14 +331,14 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe JSON - + {isPaginatedList && listData.length > 1 && ( - - - + @@ -780,7 +780,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe {t('run_content.loading')} ) : (!hasData && !hasScreenshots - ? {t('run_content.empty_output')} + ? {t('run_content.empty_output')} : null)} {hasData && ( @@ -791,23 +791,23 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe {t('run_content.captured_data.title')} - setViewMode('horizontal')} color={viewMode === 'horizontal' ? 'primary' : 'default'} sx={{ color: viewMode === 'horizontal' ? '#FF00C3' : 'inherit' }} > - setViewMode('vertical')} color={viewMode === 'vertical' ? 'primary' : 'default'} sx={{ color: viewMode === 'vertical' ? '#FF00C3' : 'inherit' }} > - - + {isLegacyData && ( viewMode === 'vertical' ? ( renderDataTable( @@ -843,7 +843,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe ) )} - + {!isLegacyData && ( viewMode === 'vertical' ? ( <> @@ -855,27 +855,27 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe 'schema_data.csv', 'schema_data.json' )} - + {listData.length > 0 && renderDataTable( - [], - [], + [], + [], t('run_content.captured_data.list_title'), , 'list_data.csv', 'list_data.json', - true + true )} ) : ( {(() => { const dataCategoriesCount = [ - schemaData.length > 0, - listData.length > 0, + schemaData.length > 0, + listData.length > 0, ].filter(Boolean).length; - + const columnWidth = dataCategoriesCount === 1 ? 12 : dataCategoriesCount === 2 ? 6 : 4; - + return ( <> {schemaData.length > 0 && ( @@ -891,18 +891,18 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe )} )} - + {listData.length > 0 && ( {renderDataCard( - [], - [], + [], + [], t('run_content.captured_data.list_title'), , 'list', 'list_data.csv', 'list_data.json', - true + true )} )} @@ -912,14 +912,14 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe ) )} - + {renderExpandedView('schema')} {renderExpandedView('legacy')} - + {listData.map((_, index) => renderExpandedView(`list-${index}`))} )} - + {hasScreenshots && ( <> @@ -927,21 +927,21 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe {t('run_content.captured_screenshot.title')} - - setViewMode('horizontal')} color={viewMode === 'horizontal' ? 'primary' : 'default'} sx={{ color: viewMode === 'horizontal' ? '#FF00C3' : 'inherit' }} > - setViewMode('vertical')} color={viewMode === 'vertical' ? 'primary' : 'default'} sx={{ color: viewMode === 'vertical' ? '#FF00C3' : 'inherit' }} @@ -951,7 +951,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe - + {viewMode === 'vertical' ? ( <> {Object.keys(row.binaryOutput).map((key, index) => { @@ -967,7 +967,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe - Screenshot {index+1} + Screenshot {index + 1} @@ -985,15 +985,15 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe - {`Screenshot @@ -1033,16 +1033,16 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe /> - {`Screenshot