Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: display simulation results only if a train is selected or get data is ready #10035

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ const SimulationResults = ({
}
}, [extViewport]);

if ((!selectedTrainSchedule || !trainSimulation) && !projectionData) {
return null;
}

return (
<div className="simulation-results">
{/* SIMULATION : STICKY BAR */}
Expand Down Expand Up @@ -184,78 +188,72 @@ const SimulationResults = ({
</div>
</ResizableSection>

{/* TRAIN : SPACE SPEED CHART */}
{selectedTrainRollingStock && trainSimulation && pathProperties && selectedTrainSchedule && (
<div className="osrd-simulation-container speedspacechart-container">
<div
className="chart-container"
style={{
height: `${speedSpaceChartContainerHeight + HANDLE_TAB_RESIZE_HEIGHT}px`,
}}
>
<SpeedSpaceChartContainer
trainSimulation={trainSimulation}
selectedTrainPowerRestrictions={selectedTrainPowerRestrictions}
rollingStock={selectedTrainRollingStock}
pathProperties={pathProperties}
heightOfSpeedSpaceChartContainer={speedSpaceChartContainerHeight}
setHeightOfSpeedSpaceChartContainer={setSpeedSpaceChartContainerHeight}
{selectedTrainSchedule && trainSimulation && (
<>
{/* TRAIN : SPACE SPEED CHART */}
{selectedTrainRollingStock && pathProperties && (
<div className="osrd-simulation-container speedspacechart-container">
<div
className="chart-container"
style={{
height: `${speedSpaceChartContainerHeight + HANDLE_TAB_RESIZE_HEIGHT}px`,
}}
>
<SpeedSpaceChartContainer
trainSimulation={trainSimulation}
selectedTrainPowerRestrictions={selectedTrainPowerRestrictions}
rollingStock={selectedTrainRollingStock}
pathProperties={pathProperties}
heightOfSpeedSpaceChartContainer={speedSpaceChartContainerHeight}
setHeightOfSpeedSpaceChartContainer={setSpeedSpaceChartContainerHeight}
/>
</div>
</div>
)}

{/* SIMULATION : MAP */}
<div className="simulation-map">
<SimulationResultsMap
setExtViewport={setExtViewport}
geometry={pathProperties?.geometry}
trainSimulation={{
...trainSimulation,
trainId: selectedTrainSchedule.id,
startTime: selectedTrainSchedule.start_time,
}}
pathItemsCoordinates={pathItemsCoordinates}
setMapCanvas={setMapCanvas}
/>
</div>
</div>
)}

{/* SIMULATION : MAP */}
<div className="simulation-map">
<SimulationResultsMap
setExtViewport={setExtViewport}
geometry={pathProperties?.geometry}
trainSimulation={
selectedTrainSchedule && trainSimulation
? {
...trainSimulation,
trainId: selectedTrainSchedule.id,
startTime: selectedTrainSchedule.start_time,
}
: undefined
}
pathItemsCoordinates={pathItemsCoordinates}
setMapCanvas={setMapCanvas}
/>
</div>

{/* TIME STOPS TABLE */}
<div className="time-stop-outputs">
<p className="mt-2 mb-3 ml-3 font-weight-bold">{t('timetableOutput')}</p>
<TimesStopsOutput
simulatedTrain={trainSimulation}
trainSummary={selectedTrainSummary}
operationalPoints={pathProperties?.operationalPoints}
selectedTrainSchedule={selectedTrainSchedule}
path={path}
dataIsLoading={formattedOpPointsLoading}
/>
</div>
{/* TIME STOPS TABLE */}
<div className="time-stop-outputs">
<p className="mt-2 mb-3 ml-3 font-weight-bold">{t('timetableOutput')}</p>
<TimesStopsOutput
simulatedTrain={trainSimulation}
trainSummary={selectedTrainSummary}
operationalPoints={pathProperties?.operationalPoints}
selectedTrainSchedule={selectedTrainSchedule}
path={path}
dataIsLoading={formattedOpPointsLoading}
/>
</div>

{/* SIMULATION EXPORT BUTTONS */}
{selectedTrainSchedule &&
trainSimulation &&
pathProperties &&
selectedTrainRollingStock &&
operationalPoints &&
path &&
infraId && (
<SimulationResultExport
path={path}
scenarioData={scenarioData}
train={selectedTrainSchedule}
simulatedTrain={trainSimulation}
pathElectrifications={pathProperties.electrifications}
operationalPoints={operationalPoints}
rollingStock={selectedTrainRollingStock}
mapCanvas={mapCanvas}
/>
)}
{/* SIMULATION EXPORT BUTTONS */}
{pathProperties && selectedTrainRollingStock && operationalPoints && path && infraId && (
<SimulationResultExport
path={path}
scenarioData={scenarioData}
train={selectedTrainSchedule}
simulatedTrain={trainSimulation}
pathElectrifications={pathProperties.electrifications}
operationalPoints={operationalPoints}
rollingStock={selectedTrainRollingStock}
mapCanvas={mapCanvas}
/>
)}
</>
)}
</div>
);
};
Expand Down
Loading