Skip to content

Commit

Permalink
Add local results
Browse files Browse the repository at this point in the history
  • Loading branch information
Derstilon committed Oct 21, 2022
1 parent b1eef5e commit 8b31c6b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
19 changes: 15 additions & 4 deletions src/WrapperApp/components/Simulation/SimulationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ export default function SimulationPanel(props: SimulationPanelProps) {
useEffect(() => {
if (canLoadResultsData) {
setLoadedResults();
setLocalSimulationData(resultsProvider);
setLocalResultsSimulationData(resultsProvider);
const newLocalData = resultsProvider;
newLocalData.forEach(data => {
data.status = StatusState.LOCAL;
});
setLocalSimulationData(newLocalData);
setLocalResultsSimulationData(newLocalData);
} else {
setLocalSimulationData(localResultsSimulationData ?? []);
}
Expand Down Expand Up @@ -155,7 +159,14 @@ export default function SimulationPanel(props: SimulationPanelProps) {
.catch(() => {
setBackendAlive(false);
});
}, [controller.signal, getSimulations, isBackendAlive, sendHelloWorld, updateSimulationInfo]);
}, [
controller.signal,
sendHelloWorld,
updateSimulationInfo,
setSimulationIDInterval,
isBackendAlive,
setBackendAlive
]);

useInterval(updateSimulationInfo, simulationIDInterval, true);

Expand Down Expand Up @@ -287,7 +298,7 @@ export default function SimulationPanel(props: SimulationPanelProps) {
</Card>
<SimulationPanelGrid
simulationsStatusData={simulationsStatusData}
localSimulationData={[]}
localSimulationData={localSimulationData}
handleLoadResults={(id, simulation) => {
if (id === null) props.goToResults?.call(null);
else setResultsSimulationData(simulation);
Expand Down
16 changes: 11 additions & 5 deletions src/WrapperApp/components/Simulation/SimulationStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export default function SimulationStatus({
return 'info.main';
case StatusState.SUCCESS:
return 'success.main';
case StatusState.LOCAL:
return 'warning.main';
default:
return '';
}
Expand Down Expand Up @@ -136,10 +138,12 @@ export default function SimulationStatus({
<CardHeader
title={`${simulation.name}`}
subheader={`${simulation.creationDate.toLocaleString('en-US').split(' ')[0]} ${
simulation.creationDate.toTimeString().split(' ')[0]
simulation.creationDate?.toTimeString
? simulation.creationDate.toTimeString().split(' ')[0]
: '00:00:00'
} - ${
simulation.status === StatusState.SUCCESS &&
simulation.completionDate.toTimeString
simulation.completionDate?.toTimeString
? simulation.completionDate.toTimeString().split(' ')[0]
: '?'
}`}
Expand All @@ -160,9 +164,11 @@ export default function SimulationStatus({
}}
/>
{simulation.metadata &&
Object.entries(simulation.metadata).map(([key, value]) => (
<Chip key={key} variant='outlined' label={`${key}: ${value}`} />
))}
Object.entries(simulation.metadata)
.filter(([key, value]) => key != 'type')
.map(([key, value]) => (
<Chip key={key} variant='outlined' label={`${key}: ${value}`} />
))}
<Chip variant='outlined' label={`cores: ${simulation.cores}`} />
</Box>
<TableContainer
Expand Down
3 changes: 2 additions & 1 deletion src/services/ShSimulatorService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export enum StatusState {
PENDING = 'PENDING',
PROGRESS = 'PROGRESS',
FAILURE = 'FAILURE',
SUCCESS = 'SUCCESS'
SUCCESS = 'SUCCESS',
LOCAL = 'LOCAL'
}
interface ResShStatusPending extends IResponseMsg {
state: StatusState.PENDING;
Expand Down

0 comments on commit 8b31c6b

Please sign in to comment.