-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathOSRDStdcmResults.tsx
89 lines (84 loc) · 3.39 KB
/
OSRDStdcmResults.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React, { useState } from 'react';
import SpaceTimeChart from 'modules/simulationResult/components/SpaceTimeChart/withOSRDData';
import SpeedSpaceChart from 'modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChart';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { getPresentSimulation, getSelectedTrain } from 'reducers/osrdsimulation/selectors';
import { AllowancesSettings } from 'reducers/osrdsimulation/types';
import { SimulationReport } from 'common/api/osrdEditoastApi';
const OSRDStcdmResults = () => {
const { t } = useTranslation(['translation', 'operationalStudies/manageTrainSchedule']);
const [showSpeedSpaceChart, setShowSpeedSpaceChart] = useState(false);
const [spaceTimeChartHeight, setSpaceTimeChartHeight] = useState(450);
const [speedSpaceChartHeight, setSpeedSpaceChartHeight] = useState(450);
const selectedTrain = useSelector(getSelectedTrain);
const simulation = useSelector(getPresentSimulation);
// by default, we show the ecoblocks for stdcm (if existing)
const allowancesSettings = (simulation.trains as SimulationReport[]).reduce((acc, train) => {
acc[train.id] = train.eco?.route_aspects
? {
base: true,
baseBlocks: false,
eco: true,
ecoBlocks: true,
}
: {
base: true,
baseBlocks: true,
eco: false,
ecoBlocks: false,
};
return acc;
}, {} as AllowancesSettings);
return (
<main className="osrd-config-mastcontainer" style={{ height: '115vh' }}>
<div className="osrd-simulation-container mb-2 simulation-results">
<div className="osrd-config-item mb-2">
<div className="osrd-simulation-container mb-2">
<p className="mt-2 mb-3 ml-4 font-weight-bold">
{t('operationalStudies/manageTrainSchedule:spaceTimeGraphic')}
</p>
<div
className="spacetimechart-container mt-2"
style={{ height: `${spaceTimeChartHeight}px` }}
>
<SpaceTimeChart
allowancesSettings={allowancesSettings}
initialHeightOfSpaceTimeChart={450}
onSetBaseHeightOfSpaceTimeChart={setSpaceTimeChartHeight}
/>
</div>
</div>
<div className="osrd-config-item-container">
<div
role="button"
tabIndex={-1}
className="btn d-flex align-items-center mb-1 font-weight-bold"
onClick={() => setShowSpeedSpaceChart(!showSpeedSpaceChart)}
>
{t('operationalStudies/manageTrainSchedule:spaceSpeedGraphic')}
<i
className={
showSpeedSpaceChart ? 'icons-arrow-up ml-auto' : 'icons-arrow-down ml-auto'
}
/>
</div>
{showSpeedSpaceChart && selectedTrain && (
<div
className="speedspacechart-container"
style={{ height: `${speedSpaceChartHeight}px`, marginBottom: '50px' }}
>
<SpeedSpaceChart
initialHeight={450}
onSetChartBaseHeight={setSpeedSpaceChartHeight}
selectedTrain={selectedTrain}
/>
</div>
)}
</div>
</div>
</div>
</main>
);
};
export default OSRDStcdmResults;