diff --git a/src/ReductionHistory.tsx b/src/ReductionHistory.tsx index 8c540dc..af32d70 100644 --- a/src/ReductionHistory.tsx +++ b/src/ReductionHistory.tsx @@ -18,8 +18,13 @@ import { InputLabel, SelectChangeEvent, Box, + Tooltip, styled, } from '@mui/material'; +import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'; +import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; +import HighlightOffIcon from '@mui/icons-material/HighlightOff'; +import WarningAmberIcon from '@mui/icons-material/WarningAmber'; import { instruments } from './InstrumentData'; interface Run { @@ -135,33 +140,48 @@ const ReductionHistory: React.FC = () => { return fileName; }; - const formatReductionStatus = (status: string, statusMessage: string): string => { - let formattedSatatus = status; - if (status === 'NOT_STARTED') { - formattedSatatus = 'NOT STARTED'; - } - - if (statusMessage && statusMessage.trim().length > 0) { - formattedSatatus += ` - ${statusMessage}`; - } + const ReductionStatusIcon = ({ state, statusMessage }: { state: string; statusMessage: string }): JSX.Element => { + let IconComponent; + let color; - return formattedSatatus; - }; - - const getStatusColor = (state: string): string => { switch (state) { - case 'UNSUCCESSFUL': case 'ERROR': - return '#F88888'; // Light red background + IconComponent = ErrorOutlineIcon; + color = 'red'; + break; case 'SUCCESSFUL': - return '#9BE19B'; // Light green background + IconComponent = CheckCircleOutlineIcon; + color = 'green'; + break; + case 'UNSUCCESSFUL': + IconComponent = WarningAmberIcon; + color = 'orange'; + break; case 'NOT_STARTED': - return '#F9F995'; // Light yellow background + IconComponent = HighlightOffIcon; + color = 'grey'; + break; default: - return 'inherit'; // Default background color + IconComponent = ErrorOutlineIcon; + color = 'disabled'; + statusMessage = 'Unknown status'; } + return ( + +
+ +
+
+ ); }; + const StyledTableCell = styled(TableCell)(({ theme }) => ({ + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + minWidth: 160, + })); + return (
@@ -190,7 +210,8 @@ const ReductionHistory: React.FC = () => { - + + { > Experiment Number - - + + { > Reduction Input - - - handleSort('reduction_state')} - > - Reduction Status - - - + + { > Run Start - - + + { > Run End - - Title - + + Title + { > Reduction Start - - + + { > Reduction End - - + + { > Reduction Outputs - + {reductions.map((reduction, index) => ( + + + {reduction.runs[0].experiment_number} {extractFileName(reduction.runs[0].filename)} - - {formatReductionStatus(reduction.reduction_state, reduction.reduction_status_message)} - {formatDateTime(reduction.runs[0].run_start)} {formatDateTime(reduction.runs[0].run_end)} {reduction.runs[0].title}