diff --git a/src/components/molecules/RunContent.tsx b/src/components/molecules/RunContent.tsx index c70eec7b..5374f978 100644 --- a/src/components/molecules/RunContent.tsx +++ b/src/components/molecules/RunContent.tsx @@ -1,4 +1,4 @@ -import { Box, Tabs, Typography, Tab } from "@mui/material"; +import { Box, Tabs, Typography, Tab, Paper } from "@mui/material"; import Highlight from "react-highlight"; import Button from "@mui/material/Button"; import * as React from "react"; @@ -8,8 +8,14 @@ import SettingsIcon from '@mui/icons-material/Settings'; import ImageIcon from '@mui/icons-material/Image'; import ArticleIcon from '@mui/icons-material/Article'; import { Buffer } from 'buffer'; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import AssignmentIcon from '@mui/icons-material/Assignment'; +import Table from '@mui/material/Table'; +import TableBody from '@mui/material/TableBody'; +import TableCell from '@mui/material/TableCell'; +import TableContainer from '@mui/material/TableContainer'; +import TableHead from '@mui/material/TableHead'; +import TableRow from '@mui/material/TableRow'; interface RunContentProps { row: Data, @@ -21,11 +27,26 @@ interface RunContentProps { export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRef, abortRunHandler }: RunContentProps) => { const [tab, setTab] = React.useState('log'); + const [tableData, setTableData] = useState([]); + const [columns, setColumns] = useState([]); useEffect(() => { setTab(tab); }, [interpretationInProgress]) + useEffect(() => { + if (row.serializableOutput && Object.keys(row.serializableOutput).length > 0) { + const firstKey = Object.keys(row.serializableOutput)[0]; + const data = row.serializableOutput[firstKey]; + if (Array.isArray(data)) { + setTableData(data); + if (data.length > 0) { + setColumns(Object.keys(data[0])); + } + } + } + }, [row.serializableOutput]); + return ( @@ -102,34 +123,50 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe || (Object.keys(row.serializableOutput).length === 0 && Object.keys(row.binaryOutput).length === 0) ? The output is empty. : null} +{!row || !row.serializableOutput || !row.binaryOutput + || (Object.keys(row.serializableOutput).length === 0 && Object.keys(row.binaryOutput).length === 0) + ? The output is empty. : null} + {row.serializableOutput && Object.keys(row.serializableOutput).length !== 0 &&
- Serializable output - {Object.keys(row.serializableOutput).map((key) => { - return ( -
- - {key}: - Download - - -
-                        {row.serializableOutput[key] ? JSON.stringify(row.serializableOutput[key], null, 2)
-                          : 'The output is empty.'}
-                      
-
-
- ) - })} + Serializable output + + {tableData.length > 0 ? ( + + + + + {columns.map((column) => ( + {column} + ))} + + + + {tableData.map((row, index) => ( + + {columns.map((column) => ( + {row[column]} + ))} + + ))} + +
+
+ ) : ( + +
+                    {JSON.stringify(row.serializableOutput, null, 2)}
+                  
+
+ )}
} {row.binaryOutput