From 54a850b0f3f7fa7e0decb749a7740cc8310bb265 Mon Sep 17 00:00:00 2001 From: Rohit Date: Mon, 7 Jul 2025 22:50:34 +0530 Subject: [PATCH 1/6] feat: revamp cap text output preview ui --- src/components/run/InterpretationLog.tsx | 72 ++++++++++++++---------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/src/components/run/InterpretationLog.tsx b/src/components/run/InterpretationLog.tsx index 0f1f1185..faf965e9 100644 --- a/src/components/run/InterpretationLog.tsx +++ b/src/components/run/InterpretationLog.tsx @@ -379,49 +379,63 @@ export const InterpretationLog: React.FC = ({ isOpen, se )} {(activeTab === availableTabs.findIndex(tab => tab.id === 'captureText') || singleContentType === 'captureText') && captureTextData.length > 0 && ( - - - - - {getCaptureTextColumns.map((column) => ( + + +
+ + - {column} + Label - ))} - - - - {captureTextData.map((row, idx) => ( - - {getCaptureTextColumns.map((column) => ( + + Value + + + + + {getCaptureTextColumns.map((column, index) => ( + + + {column} + - {row[column]} + {captureTextData[0][column]} - ))} - - ))} - -
-
+ + ))} + + + + )} From c8b8262818d78e76c0dd93cb027da05523a22a67 Mon Sep 17 00:00:00 2001 From: Rohit Date: Mon, 7 Jul 2025 22:57:17 +0530 Subject: [PATCH 2/6] feat: revamp cap text run ui --- src/components/run/RunContent.tsx | 82 ++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/src/components/run/RunContent.tsx b/src/components/run/RunContent.tsx index 25eb5063..2ad3be11 100644 --- a/src/components/run/RunContent.tsx +++ b/src/components/run/RunContent.tsx @@ -27,6 +27,7 @@ import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import 'highlight.js/styles/github.css'; import { useTranslation } from "react-i18next"; +import { useThemeMode } from "../../context/theme-provider"; interface RunContentProps { row: Data, @@ -54,6 +55,8 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const [legacyColumns, setLegacyColumns] = useState([]); const [isLegacyData, setIsLegacyData] = useState(false); + const { darkMode } = useThemeMode(); + useEffect(() => { setTab(tab); }, [interpretationInProgress]); @@ -262,8 +265,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe if (!currentData || currentData.length === 0) return null; - const downloadData = isPaginatedList ? currentData : data; - const downloadColumns = isPaginatedList ? currentColumns : columns; + const isSchemaData = title.toLowerCase().includes('text') || title.toLowerCase().includes('schema'); return ( @@ -283,7 +285,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe @@ -338,6 +340,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe onClick={() => navigateListTable('next')} disabled={currentListIndex === listData.length - 1} sx={{ + borderColor: '#FF00C3', color: currentListIndex === listData.length - 1 ? 'gray' : '#FF00C3', '&.Mui-disabled': { borderColor: 'rgba(0, 0, 0, 0.12)' @@ -353,21 +356,66 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe - {(isPaginatedList ? currentColumns : columns).map((column) => ( - {column} - ))} + {isSchemaData ? ( + <> + + Label + + + Value + + + ) : ( + (isPaginatedList ? currentColumns : columns).map((column) => ( + + {column} + + )) + )} - {(isPaginatedList ? currentData : data).map((row, index) => ( - - {(isPaginatedList ? currentColumns : columns).map((column) => ( - - {row[column] === undefined || row[column] === "" ? "-" : row[column]} + {isSchemaData ? ( + currentColumns.map((column) => ( + + + {column} - ))} - - ))} + + {currentData[0][column] === undefined || currentData[0][column] === "" ? "-" : currentData[0][column]} + + + )) + ) : ( + currentData.map((row, index) => ( + + {(isPaginatedList ? currentColumns : columns).map((column) => ( + + {row[column] === undefined || row[column] === "" ? "-" : row[column]} + + ))} + + )) + )}
From 708f846245cacb08f28b82fb2a46d08fcb0ad70e Mon Sep 17 00:00:00 2001 From: Rohit Date: Tue, 8 Jul 2025 13:40:55 +0530 Subject: [PATCH 3/6] feat: structure text data for csv format --- src/components/run/RunContent.tsx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/run/RunContent.tsx b/src/components/run/RunContent.tsx index 2ad3be11..38491854 100644 --- a/src/components/run/RunContent.tsx +++ b/src/components/run/RunContent.tsx @@ -194,17 +194,27 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe }; // Function to convert table data to CSV format - const convertToCSV = (data: any[], columns: string[]): string => { - const header = columns.join(','); - const rows = data.map(row => - columns.map(col => JSON.stringify(row[col] || "", null, 2)).join(',') - ); - return [header, ...rows].join('\n'); + const convertToCSV = (data: any[], columns: string[], isSchemaData: boolean = false): string => { + if (isSchemaData) { + // For schema data, export as Label-Value pairs + const header = 'Label,Value'; + const rows = columns.map(column => + `"${column}","${data[0][column] || ""}"` + ); + return [header, ...rows].join('\n'); + } else { + // For regular table data, export as normal table + const header = columns.join(','); + const rows = data.map(row => + columns.map(col => JSON.stringify(row[col] || "", null, 2)).join(',') + ); + return [header, ...rows].join('\n'); + } }; // Function to download a specific dataset as CSV - const downloadCSV = (data: any[], columns: string[], filename: string) => { - const csvContent = convertToCSV(data, columns); + const downloadCSV = (data: any[], columns: string[], filename: string, isSchemaData: boolean = false) => { + const csvContent = convertToCSV(data, columns, isSchemaData); const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); @@ -304,7 +314,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe