import { Box, Tabs, Typography, Tab } 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 {Buffer} from 'buffer'; import { useEffect } from "react"; import AssignmentIcon from '@mui/icons-material/Assignment'; 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'); useEffect(() => { setTab(tab); }, [interpretationInProgress]) return ( setTab(newTab)} aria-label="run-content-tabs">
{interpretationInProgress ? currentLog : row.log}
{interpretationInProgress ? : null} Interpreter settings { Object.keys(row.interpreterSettings).map((setting, index) => { if (setting === 'params') { return (
Recording parameters { Object.keys(row.interpreterSettings.params).map((param, index) => { return ( {/*@ts-ignore*/} {param}: {row.interpreterSettings.params[param].toString()} ) }) }
) } return ( {/*@ts-ignore*/} {setting}: {row.interpreterSettings[setting].toString()} ) }) }
{ !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.'}
                  
) })}
} {row.binaryOutput && Object.keys(row.binaryOutput).length !== 0 &&
Binary output { Object.keys(row.binaryOutput).map((key) => { try { const binaryBuffer = JSON.parse(row.binaryOutput[key].data); const b64 = Buffer.from(binaryBuffer.data).toString('base64'); return ( {key}: Download {key} ) } catch (e) { console.log(e) return {key}: The image failed to render } })}
}
); }