Skip to content

Commit

Permalink
fixup! front: display simulation results only if a train is selected …
Browse files Browse the repository at this point in the history
…or get data is ready
  • Loading branch information
clarani committed Dec 13, 2024
1 parent 3ee8d11 commit 9bca048
Showing 1 changed file with 82 additions and 79 deletions.
161 changes: 82 additions & 79 deletions front/src/applications/operationalStudies/views/SimulationResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ const SimulationResults = ({
)}

{/* SIMULATION : SPACE TIME CHART */}
<ResizableSection
height={manchetteWithSpaceTimeChartHeight}
setHeight={setManchetteWithSpaceTimeChartHeight}
minHeight={MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT}
>
<div
className="simulation-warped-map d-flex flex-row align-items-stretch mb-2"
style={{ height: manchetteWithSpaceTimeChartHeight }}
{projectionData && projectionData.projectedTrains.length > 0 && (
<ResizableSection
height={manchetteWithSpaceTimeChartHeight}
setHeight={setManchetteWithSpaceTimeChartHeight}
minHeight={MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT}
>
{projectionData && projectionData.projectedTrains.length > 0 && (
<div
className="simulation-warped-map d-flex flex-row align-items-stretch mb-2"
style={{ height: manchetteWithSpaceTimeChartHeight }}
>
<>
<button
type="button"
Expand Down Expand Up @@ -184,82 +184,85 @@ const SimulationResults = ({
</div>
</div>
</>
</div>
</ResizableSection>
)}

{selectedTrainSchedule && (
<>
{/* TRAIN : SPACE SPEED CHART */}
{selectedTrainRollingStock && trainSimulation && 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>
)}
</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}
{/* SIMULATION : MAP */}
<div className="simulation-map">
<SimulationResultsMap
setExtViewport={setExtViewport}
geometry={pathProperties?.geometry}
trainSimulation={
trainSimulation
? {
...trainSimulation,
trainId: selectedTrainSchedule.id,
startTime: selectedTrainSchedule.start_time,
}
: undefined
}
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 */}
{trainSimulation &&
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

0 comments on commit 9bca048

Please sign in to comment.