From 0a63e802a9f163ac39823c1adc4d4b815ecb5a04 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 24 Jun 2024 22:38:29 +0530 Subject: [PATCH] feat: run content --- src/components/molecules/RunContent.tsx | 170 ++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 src/components/molecules/RunContent.tsx diff --git a/src/components/molecules/RunContent.tsx b/src/components/molecules/RunContent.tsx new file mode 100644 index 00000000..8c493faf --- /dev/null +++ b/src/components/molecules/RunContent.tsx @@ -0,0 +1,170 @@ +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 + + } + })} +
+ } +
+ + + ); +}