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"; import { Data } from "./RunsTable"; import { TabPanel, TabContext } from "@mui/lab"; import SettingsIcon from '@mui/icons-material/Settings'; import ImageIcon from '@mui/icons-material/Image'; import ArticleIcon from '@mui/icons-material/Article'; 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'; import 'highlight.js/styles/github.css'; interface RunContentProps { row: Data, currentLog: string, interpretationInProgress: boolean, logEndRef: React.RefObject, abortRunHandler: () => void, } 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 ( setTab(newTab)} aria-label="run-content-tabs"> {/* */}
{interpretationInProgress ? currentLog : row.log}
{interpretationInProgress ? : 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 &&
Captured Data {Object.keys(row.serializableOutput).map((key) => { return ( ) })} {tableData.length > 0 ? ( {columns.map((column) => ( {column} ))} {tableData.map((row, index) => ( {columns.map((column) => ( {row[column]} ))} ))}
) : (
                    {JSON.stringify(row.serializableOutput, null, 2)}
                  
)}
} {row.binaryOutput && Object.keys(row.binaryOutput).length !== 0 &&
Captured Screenshot {Object.keys(row.binaryOutput).map((key) => { try { const imageUrl = row.binaryOutput[key]; return ( Download Screenshot {key} ) } catch (e) { console.log(e) return {key}: The image failed to render } })}
}
); }