diff --git a/front/README.md b/front/README.md
index b594a7eed26..7d1013b1b24 100644
--- a/front/README.md
+++ b/front/README.md
@@ -111,7 +111,6 @@ organized in folders.
**The components propose the main JS/TS file and eventually another folder with same name containing
some minors subcomponents linked to.**
-- [customget/](#isolated-space-time-chart-for-research-needs-customget)
- components/
- views/
- [editor/](#infrastructure-editor-editor)
@@ -200,11 +199,6 @@ This is an implementation reference for all map concerns. It aims to display all
a ready-to-use map component reference. When adding a new common layer inside an application map
component, please add it first to this application.
-### Isolated space-time chart for research needs `customGET/`
-
-_EXPERIMENTATION_ This application, which is not intended to remain as is, is a space-time graph fed
-by external data, to be used for thesis work on optimization.
-
## Common components `/src/common`
All common code (and shared components) supposed to be in `common/`.
diff --git a/front/public/locales/de/home/home.json b/front/public/locales/de/home/home.json
index 230d805ae20..9c1e40315a4 100644
--- a/front/public/locales/de/home/home.json
+++ b/front/public/locales/de/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Visualisierung JSON GET",
"editor": "Infrastrukturverlag",
"map": "Kartografie",
"operationalStudies": "Eisenbahnbetriebsstudien",
diff --git a/front/public/locales/en/customget.json b/front/public/locales/en/customget.json
deleted file mode 100644
index 1e404fc7257..00000000000
--- a/front/public/locales/en/customget.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "badJSON": "The JSON file is malformed",
- "emptyFile": "The file is empty",
- "noData": "Please import data using the + button",
- "notJSONFormat": "The file is not in JSON format ",
- "results": "Results",
- "uploadFile": "Import"
-}
diff --git a/front/public/locales/en/home/home.json b/front/public/locales/en/home/home.json
index 4ca036caf5f..2bef41f2c2f 100644
--- a/front/public/locales/en/home/home.json
+++ b/front/public/locales/en/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "JSON Space-Time diagram viewer",
"editor": "Infrastructure editor",
"map": "Map viewer",
"operationalStudies": "Operational studies",
diff --git a/front/public/locales/en/translation.json b/front/public/locales/en/translation.json
index c9a848be352..b440163e274 100644
--- a/front/public/locales/en/translation.json
+++ b/front/public/locales/en/translation.json
@@ -359,5 +359,10 @@
"show-more-ranges_other": "See {{count}} additional track sections"
}
}
+ },
+ "jsonUpload": {
+ "badJSON": "The JSON file is malformed",
+ "emptyFile": "The file is empty",
+ "notJSONFormat": "The file is not in JSON format "
}
}
diff --git a/front/public/locales/es/home/home.json b/front/public/locales/es/home/home.json
index 5d1e49946e1..db4a4bc72e8 100644
--- a/front/public/locales/es/home/home.json
+++ b/front/public/locales/es/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Visualización JSON GET",
"editor": "Editor de infraestructuras",
"map": "Cartografía",
"operationalStudies": "Estudios operativos",
diff --git a/front/public/locales/fr/customget.json b/front/public/locales/fr/customget.json
deleted file mode 100644
index 5094afe12d6..00000000000
--- a/front/public/locales/fr/customget.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "badJSON": "Le fichier JSON est malformé",
- "emptyFile": "Le fichier est vide",
- "noData": "Veuillez importer des données à l'aide du bouton +",
- "notJSONFormat": "Le fichier n'est pas au format JSON",
- "results": "Résultats",
- "uploadFile": "Importer"
-}
diff --git a/front/public/locales/fr/home/home.json b/front/public/locales/fr/home/home.json
index 00baec2dee4..2e211417314 100644
--- a/front/public/locales/fr/home/home.json
+++ b/front/public/locales/fr/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Visualisation JSON GET",
"editor": "Éditeur d'infrastructure",
"map": "Cartographie",
"operationalStudies": "Études d'exploitation",
diff --git a/front/public/locales/fr/translation.json b/front/public/locales/fr/translation.json
index 3375c91fa28..aacae0e0c85 100644
--- a/front/public/locales/fr/translation.json
+++ b/front/public/locales/fr/translation.json
@@ -359,5 +359,11 @@
"show-more-ranges_other": "Voir {{count}} sections de lignes de plus"
}
}
+ },
+ "jsonUpload": {
+ "badJSON": "Le fichier JSON est malformé",
+ "emptyFile": "Le fichier est vide",
+ "notJSONFormat": "Le fichier n'est pas au format JSON"
}
+
}
diff --git a/front/public/locales/it/home/home.json b/front/public/locales/it/home/home.json
index 07c77262cd8..d763f6fe5bb 100644
--- a/front/public/locales/it/home/home.json
+++ b/front/public/locales/it/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Visualizzazione JSON GET",
"editor": "Editor di infrastrutture",
"map": "Mappatura",
"operationalStudies": "Studi operativi",
diff --git a/front/public/locales/jp/home/home.json b/front/public/locales/jp/home/home.json
index 18d51f99062..a9ef0ec3096 100644
--- a/front/public/locales/jp/home/home.json
+++ b/front/public/locales/jp/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "ビジュアライゼーション JSON GET",
"editor": "インフラストラクチャー編集部",
"map": "マッピング",
"operationalStudies": "オペレーションスタディ",
diff --git a/front/public/locales/ru/home/home.json b/front/public/locales/ru/home/home.json
index 459932de0bb..c5dfa364425 100644
--- a/front/public/locales/ru/home/home.json
+++ b/front/public/locales/ru/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Визуализация JSON GET",
"editor": "Редактор инфраструктуры",
"map": "Составление карт",
"operationalStudies": "Эксплуатационные исследования",
diff --git a/front/public/locales/uk/home/home.json b/front/public/locales/uk/home/home.json
index 49294ffda8d..25aeee3b952 100644
--- a/front/public/locales/uk/home/home.json
+++ b/front/public/locales/uk/home/home.json
@@ -1,5 +1,4 @@
{
- "customget": "Візуалізація JSON GET",
"editor": "Редактор інфраструктури",
"map": "Картографування",
"operationalStudies": "Експлуатаційні дослідження",
diff --git a/front/src/applications/customget/Home.jsx b/front/src/applications/customget/Home.jsx
deleted file mode 100644
index 3de03e90c0f..00000000000
--- a/front/src/applications/customget/Home.jsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Route, Routes } from 'react-router-dom';
-
-import MastNavItemSNCF from 'common/BootstrapSNCF/MastNavItemSNCF';
-import MastNavSNCF from 'common/BootstrapSNCF/MastNavSNCF';
-import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
-import React from 'react';
-import logo from 'assets/pictures/home/customget.svg';
-import { useTranslation } from 'react-i18next';
-import { useDispatch } from 'react-redux';
-import { updateSimulation } from 'reducers/osrdsimulation/actions';
-import convertData from 'applications/customget/components/convertData';
-
-import CustomGET from 'applications/customget/views/CustomGET';
-
-import './Home.scss';
-import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
-import UploadFileModal from './components/uploadFileModal';
-
-function HomeCustomGET() {
- const { t } = useTranslation(['customget', 'home/home']);
- const { openModal, closeModal } = useModal();
- const dispatch = useDispatch();
-
- const handleSubmit = async (file) => {
- closeModal();
- if (file) {
- dispatch(
- updateSimulation({
- trains: convertData(JSON.parse(file)),
- })
- );
- }
- };
-
- return (
-
-
-
-
-
-
-
- }
- />
-
-
- } />
-
-
- );
-}
-
-export default HomeCustomGET;
diff --git a/front/src/applications/customget/Home.scss b/front/src/applications/customget/Home.scss
deleted file mode 100644
index 3af933f797b..00000000000
--- a/front/src/applications/customget/Home.scss
+++ /dev/null
@@ -1,7 +0,0 @@
-.customget-home {
- .mast-nav-sncf-items {
- .mastnav-item {
- cursor: pointer;
- }
- }
-}
\ No newline at end of file
diff --git a/front/src/applications/customget/components/ChartHelpers.jsx b/front/src/applications/customget/components/ChartHelpers.jsx
deleted file mode 100644
index 6da12b4bf00..00000000000
--- a/front/src/applications/customget/components/ChartHelpers.jsx
+++ /dev/null
@@ -1,208 +0,0 @@
-import * as d3 from 'd3';
-
-import { sec2time } from 'utils/timeManipulation';
-
-export const sec2d3datetime = (time) => d3.timeParse('%H:%M:%S')(sec2time(time));
-
-/* eslint-disable no-bitwise */
-export const colorModelToHex = (color) =>
- `rgba(${(color >> 16) & 0xff}, ${(color >> 8) & 0xff}, ${color & 0xff}, ${(color >> 24) & 0xff})`;
-/* eslint-enable no-bitwise */
-
-/**
- * returns Contextualized offset not depending on days ahead
- *
- * @param {*} seconds
- * @return {*}
- */
-export const offsetSeconds = (seconds) => {
- if (seconds > 85399) {
- return seconds - 86400;
- }
- if (seconds < 0) {
- return seconds + 86400;
- }
- return seconds;
-};
-
-export const getDirection = (data) =>
- data[0] && data[0][0].position < data[data.length - 1][data[data.length - 1].length - 1].position;
-
-export const defineTime = (extent) => d3.scaleTime().domain(extent);
-
-export const defineLinear = (max, pctMarge = 0, origin = 0) =>
- d3.scaleLinear().domain([origin - max * pctMarge, max + max * pctMarge]);
-
-export const formatStepsWithTime = (data) =>
- data.map((step) => ({ ...step, time: sec2d3datetime(step.time) }));
-
-export const formatStepsWithTimeMulti = (data) =>
- data.map((section) =>
- section.map((step) => ({ time: sec2d3datetime(step.time), position: step.position }))
- );
-
-export const formatRouteAspects = (data = []) =>
- data.map((step) => ({
- ...step,
- time_start: sec2d3datetime(step.time_start),
- time_end: sec2d3datetime(step.time_end),
- color: colorModelToHex(step.color),
- }));
-
-/**
- * Signal Aspects (state of signals in the simulation depending on time)
- * need some formatting before inclusion in consolidatedSimulation
- * @param {Array} data
- * @returns
- */
-export const formatSignalAspects = (data = []) =>
- data.map((step) => ({
- ...step,
- time_start: sec2d3datetime(step.time_start),
- time_end: sec2d3datetime(step.time_end),
- color: colorModelToHex(step.color),
- }));
-
-export const makeStairCase = (data) => {
- const newData = [];
- const { length } = data;
- data.forEach((step, idx) => {
- newData.push(step);
- if (idx < length - 1) {
- newData.push({
- time: data[idx + 1].time,
- position: step.position,
- });
- }
- });
- return newData;
-};
-
-// Time shift a train
-export const timeShiftTrain = (train, value) => ({
- ...train,
- base: {
- head_positions: train.base.head_positions.map((section) =>
- section.map((step) => ({ ...step, time: offsetSeconds(step.time + value) }))
- ),
- tail_positions: train.base.tail_positions.map((section) =>
- section.map((step) => ({ ...step, time: offsetSeconds(step.time + value) }))
- ),
- stops: train.base.stops.map((stop) => ({ ...stop, time: offsetSeconds(stop.time + value) })),
- },
-});
-
-// Merge two curves for creating area between
-export const mergeDatasArea = (data1, data2, keyValues) => {
- const areas = data1.map((data1Section, sectionIdx) => {
- const points = [];
- for (let i = 0; i <= data1Section.length; i += 2) {
- points.push({
- [keyValues[0]]: data1Section[i][keyValues[0]],
- value0: data1Section[i][keyValues[1]],
- value1: data2[sectionIdx][i][keyValues[1]],
- });
- if (data1Section[i + 1] && data2[sectionIdx][i + 1]) {
- points.push({
- [keyValues[0]]: data2[sectionIdx][i + 1][keyValues[0]],
- value0: data1Section[i + 1][keyValues[1]],
- value1: data2[sectionIdx][i + 1][keyValues[1]],
- });
- }
- if (data1Section[i + 2] && data2[sectionIdx][i + 2]) {
- points.push({
- [keyValues[0]]: data2[sectionIdx][i + 1][keyValues[0]],
- value0: data1Section[i + 1][keyValues[1]],
- value1: data2[sectionIdx][i + 2][keyValues[1]],
- });
- points.push({
- [keyValues[0]]: data1Section[i + 1][keyValues[0]],
- value0: data1Section[i + 1][keyValues[1]],
- value1: data2[sectionIdx][i + 2][keyValues[1]],
- });
- }
- }
- return points;
- });
- return areas;
-};
-export const mergeDatasAreaConstant = (data1, data2, keyValues) =>
- data1.map((step) => ({
- [keyValues[0]]: step[keyValues[0]],
- value0: step[keyValues[1]],
- value1: data2,
- }));
-
-// Transform little arrays of data (staircases values like emergency or indication)
-// along all steps values
-export const expandAndFormatData = (reference, dataToExpand) =>
- reference.map((step) => {
- const idx = dataToExpand.findIndex((item) => item.position >= step.position);
- return {
- position: step.position,
- value:
- dataToExpand[idx - 1] !== undefined ? dataToExpand[idx - 1].speed : dataToExpand[idx].speed,
- };
- });
-
-export const gridX = (x, height) => d3.axisBottom(x).ticks(10).tickSize(-height).tickFormat('');
-
-export const gridY = (y, width) => d3.axisLeft(y).ticks(10).tickSize(-width).tickFormat('');
-
-// Interpolation of cursor based on space position
-export const interpolateOnPosition = (dataSimulation, keyValues, positionLocal) => {
- const bisect = d3.bisector((d) => d[keyValues[0]]).left;
- const index = bisect(dataSimulation.speed, positionLocal, 1);
- const bisection = [dataSimulation.speed[index - 1], dataSimulation.speed[index]];
- if (bisection[1]) {
- const distance = bisection[1].position - bisection[0].position;
- const distanceFromPosition = positionLocal - bisection[0].position;
- const proportion = distanceFromPosition / distance;
- return sec2d3datetime(d3.interpolateNumber(bisection[0].time, bisection[1].time)(proportion));
- }
- return false;
-};
-
-// Interpolation of cursor based on time position
-export const interpolateOnTime = (dataSimulation, keyValues, listValues, timePositionLocal) => {
- const bisect = d3.bisector((d) => d[keyValues[0]]).left;
- const positionInterpolated = {};
- listValues.forEach((listValue) => {
- let bisection;
- // If not array of array
- if (listValue === 'speed' || listValue === 'speeds') {
- if (
- dataSimulation[listValue] &&
- dataSimulation[listValue][0] &&
- timePositionLocal >= dataSimulation[listValue][0][keyValues[0]]
- ) {
- const index = bisect(dataSimulation[listValue], timePositionLocal, 1);
- bisection = [dataSimulation[listValue][index - 1], dataSimulation[listValue][index]];
- }
- } else if (dataSimulation[listValue]) {
- // Array of array
- dataSimulation[listValue].forEach((section) => {
- const index = bisect(section, timePositionLocal, 1);
- if (
- index !== section.length &&
- section[0] &&
- timePositionLocal >= section[0][keyValues[0]]
- ) {
- bisection = [section[index - 1], section[index]];
- }
- });
- }
- if (bisection && bisection[1]) {
- const duration = bisection[1].time - bisection[0].time;
- const timePositionFromTime = timePositionLocal - bisection[0].time;
- const proportion = timePositionFromTime / duration;
- positionInterpolated[listValue] = {
- position: d3.interpolateNumber(bisection[0].position, bisection[1].position)(proportion),
- speed: d3.interpolateNumber(bisection[0].speed, bisection[1].speed)(proportion) * 3.6,
- time: timePositionLocal,
- };
- }
- });
-
- return positionInterpolated;
-};
diff --git a/front/src/applications/customget/components/ChartModal.jsx b/front/src/applications/customget/components/ChartModal.jsx
deleted file mode 100644
index a15fdc3185c..00000000000
--- a/front/src/applications/customget/components/ChartModal.jsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import 'applications/customget/components/ChartModal.scss';
-
-import React, { useEffect, useState, useCallback } from 'react';
-import { useDispatch } from 'react-redux';
-
-import PropTypes from 'prop-types';
-import { updateMustRedraw } from 'reducers/osrdsimulation/actions';
-import { useTranslation } from 'react-i18next';
-
-function ChartModal(props) {
- const { type, setShowModal, trainName, offsetTimeByDragging } = props;
- const dispatch = useDispatch();
- const { t } = useTranslation(['simulation']);
- const [offset, setOffset] = useState('');
-
- // ADN: just do an upadteSimulation, should do the rest
- const sendOffset = useCallback(
- ({ key }) => {
- if (key === 'Enter') {
- setShowModal('');
- const seconds = parseInt(type === '-' ? offset * -1 : offset, 10);
- offsetTimeByDragging(seconds);
- dispatch(updateMustRedraw(true));
- }
- },
- [setShowModal, offsetTimeByDragging, dispatch, offset, type]
- );
-
- useEffect(() => {
- window.addEventListener('keydown', sendOffset);
- return () => {
- window.removeEventListener('keydown', sendOffset);
- };
- }, [offset, sendOffset]);
-
- return (
-
-
-
- {t('simulation:ManualOffset')}
- {trainName}
-
-
-
{type}
-
setShowModal('')}
- onChange={(e) => setOffset(e.target.value.replace(/\D/g, ''))} // Filter non digit chars
- value={offset}
- />
-
s
-
-
-
- );
-}
-
-ChartModal.propTypes = {
- type: PropTypes.string.isRequired,
- trainName: PropTypes.string.isRequired,
- setShowModal: PropTypes.func.isRequired,
- offsetTimeByDragging: PropTypes.func.isRequired,
-};
-
-export default ChartModal;
diff --git a/front/src/applications/customget/components/ChartModal.scss b/front/src/applications/customget/components/ChartModal.scss
deleted file mode 100644
index 8c4af0ae618..00000000000
--- a/front/src/applications/customget/components/ChartModal.scss
+++ /dev/null
@@ -1,53 +0,0 @@
-.osrd-simulation-chart-modal {
- display: flex;
- position: absolute;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- background-color: rgba(255, 255, 255, 0.75);
- .chart-modal-box {
- display: flex;
- justify-content: center;
- flex-wrap: wrap;
- position: relative;
- border-radius: 4px;
- padding: 1em;
- .chart-modal-type-title {
- text-align: center;
- flex-basis: 100%;
- font-size: 1.5rem;
- }
- .chart-modal-input {
- display: flex;
- align-items: center;
- .chart-modal-type-label {
- color: #4d4f53;
- font-weight: bold;
- font-size: 3rem;
- margin-right: 1rem;
- }
- input {
- border: none;
- border-bottom: 4px solid #d7d7d7;
- color: #333;
- background: none;
- font-size: 2rem;
- font-weight: bold;
- padding-right: 1.5rem;
- width: 8rem;
- text-align: right;
- &:focus {
- outline: none;
- }
- }
- .chart-modal-type-unit {
- content: 's';
- color: #747678;
- font-weight: bold;
- font-size: 2rem;
- margin-left: -1rem;
- }
- }
- }
-}
diff --git a/front/src/applications/customget/components/SpaceTimeChart/createChart.jsx b/front/src/applications/customget/components/SpaceTimeChart/createChart.jsx
deleted file mode 100644
index faf196ea10a..00000000000
--- a/front/src/applications/customget/components/SpaceTimeChart/createChart.jsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import * as d3 from 'd3';
-import { defineLinear, defineTime } from 'applications/customget/components/ChartHelpers';
-import defineChart from 'applications/customget/components/defineChart';
-
-export default function createChart(
- chart,
- chartID,
- dataSimulation,
- heightOfSpaceTimeChart,
- keyValues,
- ref,
- reset,
- rotate
-) {
- d3.select(`#${chartID}`).remove();
-
- const dataSimulationTime = d3.extent(
- [].concat(
- ...dataSimulation.map((train) =>
- d3.extent(
- [].concat(
- ...train.headPosition.map((section) => d3.extent(section, (step) => step[keyValues[0]]))
- )
- )
- )
- )
- );
-
- const dataSimulationLinearMax = d3.max([
- d3.max(
- [].concat(
- ...dataSimulation.map((train) =>
- d3.max(
- train.headPosition.map((section) => d3.max(section.map((step) => step[keyValues[1]])))
- )
- )
- )
- ),
- d3.max(
- [].concat(
- ...dataSimulation.map((train) =>
- d3.max(
- train.headPosition.map((section) => d3.max(section.map((step) => step[keyValues[1]])))
- )
- )
- )
- ),
- ]);
-
- const defineX =
- chart === undefined || reset ? defineTime(dataSimulationTime, keyValues[0]) : chart.x;
- const defineY =
- chart === undefined || reset ? defineLinear(dataSimulationLinearMax, 0.05) : chart.y;
-
- const width = parseInt(d3.select(`#container-${chartID}`).style('width'), 10);
- const chartLocal = defineChart(
- width,
- heightOfSpaceTimeChart,
- defineX,
- defineY,
- ref,
- rotate,
- keyValues,
- chartID
- );
- return chart === undefined || reset ? chartLocal : { ...chartLocal, x: chart.x, y: chart.y };
-}
diff --git a/front/src/applications/customget/components/SpaceTimeChart/createTrain.jsx b/front/src/applications/customget/components/SpaceTimeChart/createTrain.jsx
deleted file mode 100644
index d2f00939850..00000000000
--- a/front/src/applications/customget/components/SpaceTimeChart/createTrain.jsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { formatStepsWithTimeMulti } from 'applications/customget/components/ChartHelpers';
-
-export default function createTrain(dispatch, keyValues, simulationTrains) {
- // Prepare data
- const dataSimulation = simulationTrains.map((train, trainNumber) => {
- const dataSimulationTrain = {};
- dataSimulationTrain.id = train.id;
- dataSimulationTrain.name = train.name;
- dataSimulationTrain.color = train.color;
- dataSimulationTrain.trainNumber = trainNumber;
- dataSimulationTrain.headPosition = formatStepsWithTimeMulti(train.base.head_positions);
- dataSimulationTrain.tailPosition = formatStepsWithTimeMulti(train.base.tail_positions);
-
- return dataSimulationTrain;
- });
- return dataSimulation;
-}
diff --git a/front/src/applications/customget/components/SpaceTimeChart/drawTrain.jsx b/front/src/applications/customget/components/SpaceTimeChart/drawTrain.jsx
deleted file mode 100644
index 10bfcb274c2..00000000000
--- a/front/src/applications/customget/components/SpaceTimeChart/drawTrain.jsx
+++ /dev/null
@@ -1,147 +0,0 @@
-import * as d3 from 'd3';
-
-import { getDirection } from 'applications/customget/components/ChartHelpers';
-import { makeTrainListWithAllTrainsOffset } from 'applications/operationalStudies/components/SimulationResults/ChartHelpers/ChartHelpers';
-
-import drawCurve from 'applications/customget/components/drawCurve';
-import drawText from 'applications/customget/components/drawText';
-import {
- updateDepartureArrivalTimes,
- updateContextMenu,
- updateMustRedraw,
- updateSelectedTrainId,
-} from 'reducers/osrdsimulation/actions';
-
-export default function drawTrain(
- chart,
- dispatch,
- dataSimulation,
- isPathSelected,
- isSelected,
- keyValues,
- allowancesSettings,
- offsetTimeByDragging,
- rotate,
- setDragEnding,
- setDragOffset,
- simulation
-) {
- const groupID = `spaceTime-${dataSimulation.trainNumber}`;
-
- const initialDrag = rotate ? chart.y.invert(0) : chart.x.invert(0);
-
- let dragFullOffset = 0;
-
- const getDragOffsetValue = (offset) =>
- rotate
- ? Math.floor((chart.y.invert(offset) - initialDrag) / 1000)
- : Math.floor((chart.x.invert(offset) - initialDrag) / 1000);
-
- /**
- * Compute, in sceonds, the offset to drill down to the parent through setDragOffset passed hook
- *
- */
- const dragTimeOffset = (offset) => {
- const value = getDragOffsetValue(offset);
- setDragOffset(value);
- };
-
- /**
- * Apply a contextual translation on a viz group on the chart.
- * @todo pure it, pass chartID, rotate as params
- *
- * @param {int} offset
- */
- const applyTrainCurveTranslation = (offset) => {
- const translation = rotate ? `0,${offset}` : `${offset},0`;
- d3.select(`#${groupID}`).attr('transform', `translate(${translation})`);
- };
- let debounceTimeoutId;
- function debounceUpdateDepartureArrivalTimes(computedDepartureArrivalTimes, interval) {
- clearTimeout(debounceTimeoutId);
- debounceTimeoutId = setTimeout(() => {
- dispatch(updateDepartureArrivalTimes(computedDepartureArrivalTimes));
- }, interval);
- }
-
- const drag = d3
- .drag()
- .on('end', () => {
- dragTimeOffset(dragFullOffset, true);
- setDragEnding(true);
- dispatch(updateMustRedraw(true));
- })
- .on('start', () => {
- dragFullOffset = 0;
- dispatch(updateSelectedTrainId(dataSimulation.id));
- })
- .on('drag', () => {
- dragFullOffset += rotate ? d3.event.dy : d3.event.dx;
- const value = getDragOffsetValue(dragFullOffset);
- const newDepartureArrivalTimes = makeTrainListWithAllTrainsOffset(simulation.trains, value);
- debounceUpdateDepartureArrivalTimes(newDepartureArrivalTimes, 15);
- applyTrainCurveTranslation(dragFullOffset);
- });
-
- chart.drawZone
- .append('g')
- .attr('id', groupID)
- .attr('class', 'chartTrain')
- .call(drag)
- .on('contextmenu', () => {
- d3.event.preventDefault();
- dispatch(
- updateContextMenu({
- id: dataSimulation.id,
- xPos: d3.event.layerX,
- yPos: d3.event.layerY,
- })
- );
- dispatch(updateSelectedTrainId(dataSimulation.id));
- dispatch(updateMustRedraw(true));
- });
-
- // Test direction to avoid displaying block
- const direction = getDirection(dataSimulation.headPosition);
- dataSimulation.headPosition.forEach((headPositionSection) =>
- drawCurve(
- chart,
- `${isSelected && 'selected'} head`,
- headPositionSection,
- groupID,
- 'curveLinear',
- keyValues,
- 'headPosition',
- rotate,
- isSelected
- )
- );
- dataSimulation.tailPosition.forEach((tailPositionSection) =>
- drawCurve(
- chart,
- `${isSelected && 'selected'} tail`,
- tailPositionSection,
- groupID,
- 'curveLinear',
- keyValues,
- 'tailPosition',
- rotate,
- isSelected
- )
- );
-
- drawText(
- chart,
- direction,
- groupID,
- isSelected,
- `${isPathSelected ? '🎢' : ''} ${dataSimulation.name}`, // text
- dataSimulation.headPosition[0] &&
- dataSimulation.headPosition[0][0] &&
- dataSimulation.headPosition[0][0].time, // x
- dataSimulation.headPosition[0] &&
- dataSimulation.headPosition[0][0] &&
- dataSimulation.headPosition[0][0].position,
- dataSimulation.color // y
- );
-}
diff --git a/front/src/applications/customget/components/consts.jsx b/front/src/applications/customget/components/consts.jsx
deleted file mode 100644
index 56a98d5907c..00000000000
--- a/front/src/applications/customget/components/consts.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-export const LIST_VALUES_NAME_SPACE_TIME = ['headPosition', 'tailPosition'];
-export const LIST_VALUES_NAME_SPEED_SPACE = ['speed', 'margins_speed', 'eco_speed'];
-export const LIST_VALUES_NAME_SPACE_CURVES_SLOPES = ['slopesCurve'];
-
-// Signal Base is the Signaling system chosen for results display
-
-export const SIGNAL_BASE_DEFAULT = 'BAL3';
-
-export const LIST_VALUES_SIGNAL_BASE = ['BAL3'];
diff --git a/front/src/applications/customget/components/convertData.jsx b/front/src/applications/customget/components/convertData.jsx
deleted file mode 100644
index f82bb19af5c..00000000000
--- a/front/src/applications/customget/components/convertData.jsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { SNCFCOLORSONLY } from 'applications/operationalStudies/consts';
-
-const randomColor = () => {
- const colors = Object.values(SNCFCOLORSONLY);
- const len = colors.length;
- const idx = Math.floor(Math.random() * len);
- return colors[idx];
-};
-
-const convertStops = (points) => {
- const steps = [];
- points.forEach((section) =>
- section.forEach((step) => {
- steps.push(step);
- })
- );
- let beforeStepName;
- let beforeStepTime;
- const newStepList = [];
- steps.forEach((step) => {
- if (step.label !== beforeStepName) {
- newStepList.push({
- duration: 0,
- name: step.label,
- position: step.position,
- time: step.time,
- type: step.type,
- });
- } else {
- newStepList.splice(-1);
- newStepList.push({
- duration: step.time - beforeStepTime,
- name: step.label,
- position: step.position,
- time: beforeStepTime,
- type: step.type,
- });
- }
- beforeStepTime = step.time;
- beforeStepName = step.label;
- });
- return newStepList;
-};
-
-const convertData = (trains) => {
- const newData = trains
- .filter(
- (train) =>
- train.space_time_curves[0].points[0].length > 1 &&
- train.space_time_curves[1].points[0].length > 1
- )
- .map((train, idx) => ({
- id: idx,
- name: train.name ? train.name : train.train_metadata.name,
- color: randomColor(),
- labels: [],
- path: 0,
- vmax: [],
- slopes: [],
- curves: [],
- speeds: [],
- base: {
- head_positions: train.space_time_curves[0].points.map((section) =>
- section.map((step) => ({
- time: step.time,
- position: step.position,
- }))
- ),
- tail_positions: train.space_time_curves[1].points.map((section) =>
- section.map((step) => ({
- time: step.time,
- position: step.position,
- }))
- ),
- stops: convertStops(train.space_time_curves[0].points),
- route_aspects: [],
- signals: [],
- },
- }));
- return newData;
-};
-
-export default convertData;
diff --git a/front/src/applications/customget/components/defineChart.jsx b/front/src/applications/customget/components/defineChart.jsx
deleted file mode 100644
index c3c2147aa7b..00000000000
--- a/front/src/applications/customget/components/defineChart.jsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import * as d3 from 'd3';
-import { gridX, gridY } from 'applications/customget/components/ChartHelpers';
-import nextId from 'react-id-generator';
-import svgDefs from 'applications/customget/components/svgDefs';
-
-const defineChart = (svgWidth, svgHeight, defineX, defineY, ref, rotate, keyValues, id) => {
- const margin = {
- top: 1,
- right: 1,
- bottom: 30,
- left: 55,
- };
- const width = svgWidth - margin.left - margin.right;
- const height = svgHeight - margin.top - margin.bottom;
-
- // Container for easy removing
- const svg = d3
- .select(ref.current)
- .append('div')
- .attr('id', id)
- .append('svg')
- // .attr('width', width + margin.left + margin.right)
- // .attr('height', height + margin.top + margin.bottom)
- .attr(
- 'viewBox',
- `0 0 ${width + margin.left + margin.right} ${height + margin.top + margin.bottom}`
- )
- // .attr('perserveAspectRatio', 'xMinYMid')
- .append('g')
- .attr('transform', `translate(${margin.left},${margin.top})`);
-
- // adding defs
- const defs = svg.append('defs');
- svgDefs(defs);
-
- // Add X axis
- const x = defineX.range([0, width]);
- const axisBottomX =
- !rotate && keyValues[0] === 'time'
- ? d3.axisBottom(x).tickFormat(d3.timeFormat('%H:%M:%S'))
- : d3.axisBottom(x);
- const xAxis = svg.append('g').attr('transform', `translate(0,${height})`).call(axisBottomX);
- const xAxisGrid = svg
- .append('g')
- .attr('transform', `translate(0,${height})`)
- .attr('class', 'grid')
- .call(gridX(x, height));
- const originalScaleX = x; // We need to keep a ref on that to not double translation
-
- // Add Y axis
- const y = defineY.range([height, 0]);
- const axisLeftY =
- rotate && keyValues[0] === 'time'
- ? d3.axisLeft(y).tickFormat(d3.timeFormat('%H:%M:%S'))
- : d3.axisLeft(y);
- const yAxis = svg.append('g').call(axisLeftY);
- const yAxisGrid = svg.append('g').attr('class', 'grid').call(gridY(y, width));
- const originalScaleY = y; // We need to keep a ref on that to not double translation
-
- // Create clip path to hide everything out of this area
- const idClip = `clip-${nextId()}`;
- defs
- .append('SVG:clipPath')
- .attr('id', idClip)
- .append('SVG:rect')
- .attr('width', width)
- .attr('height', height)
- .attr('x', 0)
- .attr('y', 0);
-
- // background for zooming capabilities
- svg
- .append('rect')
- .attr('class', 'zoomable')
- .attr('width', width)
- .attr('height', height)
- .style('fill', 'none')
- .style('pointer-events', 'all');
-
- // define drawZones along type (line, area, etc.)
- const drawZone = svg.append('g').attr('clip-path', `url(#${idClip})`);
-
- return {
- width,
- height,
- margin,
- x,
- xAxis,
- xAxisGrid,
- y,
- yAxis,
- yAxisGrid,
- svg,
- drawZone,
- originalScaleX,
- originalScaleY,
- };
-};
-
-export default defineChart;
diff --git a/front/src/applications/customget/components/drawCurve.jsx b/front/src/applications/customget/components/drawCurve.jsx
deleted file mode 100644
index 65ccc394035..00000000000
--- a/front/src/applications/customget/components/drawCurve.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import * as d3 from 'd3';
-
-const drawCurve = (
- chart,
- classes,
- dataSimulation,
- groupID,
- interpolation,
- keyValues,
- name,
- rotate,
- isSelected = true
-) => {
- const drawZone = chart.drawZone.select(`#${groupID}`);
- drawZone
- .append('path')
- .attr('class', `line zoomable ${classes}`)
- .datum(dataSimulation)
- .attr('fill', 'none')
- .attr('stroke-width', 1)
- .attr(
- 'd',
- d3
- .line()
- .x((d) => chart.x(rotate ? d[keyValues[1]] : d[keyValues[0]]))
- .y((d) => chart.y(rotate ? d[keyValues[0]] : d[keyValues[1]]))
- .curve(d3[interpolation])
- );
-
- if (isSelected) {
- drawZone
- .append('circle')
- .attr('class', `pointer ${classes}`)
- .attr('id', `pointer-${name}`)
- .attr('transform', 'translate(-0.5,0)')
- .attr('r', 3)
- .style('opacity', 0);
- }
-};
-
-export default drawCurve;
diff --git a/front/src/applications/customget/components/drawGuideLines.jsx b/front/src/applications/customget/components/drawGuideLines.jsx
deleted file mode 100644
index e3bb350a572..00000000000
--- a/front/src/applications/customget/components/drawGuideLines.jsx
+++ /dev/null
@@ -1,24 +0,0 @@
-const drawGuideLines = (chart) => {
- chart.svg.selectAll('.guideLines').remove();
-
- // dashed lineguides
- chart.svg
- .append('line')
- .attr('id', 'vertical-line')
- .attr('class', 'guideLines')
- .attr('x1', 0)
- .attr('y1', chart.height)
- .attr('x2', 0)
- .attr('y2', 0);
-
- chart.svg
- .append('line')
- .attr('id', 'horizontal-line')
- .attr('class', 'guideLines')
- .attr('x1', 0)
- .attr('y1', 0)
- .attr('x2', chart.width)
- .attr('y2', 0);
-};
-
-export default drawGuideLines;
diff --git a/front/src/applications/customget/components/drawText.jsx b/front/src/applications/customget/components/drawText.jsx
deleted file mode 100644
index 7627fbfbd7e..00000000000
--- a/front/src/applications/customget/components/drawText.jsx
+++ /dev/null
@@ -1,17 +0,0 @@
-const drawText = (chart, direction, groupID, isSelected, text, x, y, color = '#333333') => {
- const drawZone = chart.drawZone.select(`#${groupID}`);
- drawZone
- .append('text')
- .attr('class', `curve-label ${isSelected && 'selected'}`)
- .attr('x', direction ? chart.x(x) : chart.x(x))
- .attr('y', direction ? chart.y(y) + 15 : chart.y(y) - 5)
- .text(text);
- drawZone
- .append('circle')
- .attr('cx', direction ? chart.x(x) - 8 : chart.x(x))
- .attr('cy', direction ? chart.y(y) + 10 : chart.y(y) - 5)
- .attr('r', '5px')
- .style('fill', color);
-};
-
-export default drawText;
diff --git a/front/src/applications/customget/components/enableInteractivity.jsx b/front/src/applications/customget/components/enableInteractivity.jsx
deleted file mode 100644
index 5ab782f9394..00000000000
--- a/front/src/applications/customget/components/enableInteractivity.jsx
+++ /dev/null
@@ -1,326 +0,0 @@
-import * as d3 from 'd3';
-
-import {
- gridX,
- gridY,
- interpolateOnPosition,
- interpolateOnTime,
-} from 'applications/customget/components/ChartHelpers';
-import {
- updateChartXGEV,
- updateContextMenu,
- updateMustRedraw,
- updateTimePositionValues,
-} from 'reducers/osrdsimulation/actions';
-
-import { LIST_VALUES_NAME_SPACE_TIME } from 'applications/customget/components/consts';
-import drawGuideLines from 'applications/customget/components/drawGuideLines';
-import { store } from 'Store';
-
-export const displayGuide = (chart, opacity) => {
- chart.svg.selectAll('#vertical-line').style('opacity', opacity);
- chart.svg.selectAll('#horizontal-line').style('opacity', opacity);
- chart.svg.selectAll('.pointer').style('opacity', opacity);
-};
-
-export const updatePointers = (chart, keyValues, listValues, positionValues, rotate) => {
- listValues.forEach((name) => {
- if (positionValues[name]) {
- chart.svg
- .selectAll(`#pointer-${name}`)
- .attr(
- 'cx',
- rotate
- ? chart.x(positionValues[name][keyValues[1]])
- : chart.x(positionValues[name][keyValues[0]])
- )
- .attr(
- 'cy',
- rotate
- ? chart.y(positionValues[name][keyValues[0]])
- : chart.y(positionValues[name][keyValues[1]])
- );
- }
- });
-};
-
-const updateChart = (chart, keyValues, rotate) => {
- // recover the new scale & test if movement under 0
- /* const newX = (d3.event.sourceEvent.shiftKey && rotate)
- || ((chart.x.domain()[0] - d3.event.transform.x) < 0 && d3.event.transform.k === 1 && rotate)
- ? chart.x
- : d3.event.transform.rescaleX(chart.x);
- const newY = (d3.event.sourceEvent.shiftKey && !rotate)
- || ((chart.y.domain()[0] + d3.event.transform.y) < 0 && d3.event.transform.k === 1 && !rotate)
- ? chart.y
- : d3.event.transform.rescaleY(chart.y); */
-
- const newX =
- d3.event.sourceEvent.shiftKey && rotate ? chart.x : d3.event.transform.rescaleX(chart.x);
- const newY =
- d3.event.sourceEvent.shiftKey && !rotate ? chart.y : d3.event.transform.rescaleY(chart.y);
-
- // update axes with these new boundaries
- const axisBottomX =
- !rotate && keyValues[0] === 'time'
- ? d3.axisBottom(newX).tickFormat(d3.timeFormat('%H:%M:%S'))
- : d3.axisBottom(newX);
- const axisLeftY =
- rotate && keyValues[0] === 'time'
- ? d3.axisLeft(newY).tickFormat(d3.timeFormat('%H:%M:%S'))
- : d3.axisLeft(newY);
- chart.xAxis.call(axisBottomX);
- chart.yAxis.call(axisLeftY);
-
- chart.xAxisGrid.call(gridX(newX, chart.height));
- chart.yAxisGrid.call(gridY(newY, chart.width));
-
- // update lines & areas
- chart.drawZone.selectAll('.line').attr(
- 'd',
- d3
- .line()
- .x((d) => newX(rotate ? d[keyValues[1]] : d[keyValues[0]]))
- .y((d) => newY(rotate ? d[keyValues[0]] : d[keyValues[1]]))
- );
-
- chart.drawZone
- .selectAll('rect.route-aspect')
- .attr('x', (d) => newX(rotate ? d[`${keyValues[1]}_start`] : d[`${keyValues[0]}_start`]))
- .attr(
- 'y',
- (d) =>
- newY(rotate ? d[`${keyValues[0]}_start`] : d[`${keyValues[1]}_start`]) -
- (rotate
- ? newY(d[`${keyValues[0]}_end`] - d[`${keyValues[0]}_start`])
- : newY(d[`${keyValues[1]}_end`]) - newY(d[`${keyValues[1]}_start`])) *
- -1
- )
- .attr('width', (d) =>
- rotate
- ? newX(d[`${keyValues[1]}_end`]) - newX(d[`${keyValues[1]}_start`])
- : newX(d[`${keyValues[0]}_end`]) - newX(d[`${keyValues[0]}_start`])
- )
- .attr(
- 'height',
- (d) =>
- (rotate
- ? newY(d[`${keyValues[0]}_end`]) - newY(d[`${keyValues[0]}_start`])
- : newY(d[`${keyValues[1]}_end`]) - newY(d[`${keyValues[1]}_start`])) * -1
- );
-
- chart.drawZone.selectAll('.area').attr(
- 'd',
- rotate
- ? d3
- .area()
- .y((d) => newY(d[keyValues[0]]))
- .x0((d) => newX(d.value0))
- .x1((d) => newX(d.value1))
- .curve(keyValues[0] === 'time' ? d3.curveStepAfter : d3.curveLinear)
- : d3
- .area()
- .x((d) => newX(d[keyValues[0]]))
- .y0((d) => newY(d.value0))
- .y1((d) => newY(d.value1))
- .curve(keyValues[0] === 'time' ? d3.curveStepAfter : d3.curveLinear)
- );
-
- // OPERATIONNAL POINTS
- if (rotate) {
- chart.drawZone
- .selectAll('#get-operationalPointsZone .op-line')
- .attr('x1', (d) => newX(d))
- .attr('x2', (d) => newX(d));
- chart.drawZone.selectAll('#get-operationalPointsZone .op-text').attr('x', (d) => newX(d));
- chart.drawZone
- .selectAll('#gev-operationalPointsZone .op-line')
- .attr('y1', (d) => newY(d))
- .attr('y2', (d) => newY(d));
- chart.drawZone.selectAll('#gev-operationalPointsZone .op-text').attr('y', (d) => newY(d));
- } else {
- chart.drawZone
- .selectAll('#get-operationalPointsZone .op-line')
- .attr('y1', (d) => newY(d))
- .attr('y2', (d) => newY(d));
- chart.drawZone.selectAll('#get-operationalPointsZone .op-text').attr('y', (d) => newY(d));
- chart.drawZone
- .selectAll('#gev-operationalPointsZone .op-line')
- .attr('x1', (d) => newX(d))
- .attr('x2', (d) => newX(d));
- chart.drawZone.selectAll('#gev-operationalPointsZone .op-text').attr('x', (d) => newX(d));
- }
-
- chart.drawZone.selectAll('.curve-label').attr('transform', d3.event.transform);
-
- chart.drawZone
- .selectAll('.conflictsPoints')
- .attr('cx', (d) => newX(rotate ? d[keyValues[1]] : d[keyValues[0]]))
- .attr('cy', (d) => newY(rotate ? d[keyValues[0]] : d[keyValues[1]]));
- return { newX, newY };
-};
-
-// Factorizes func to update VerticalLine on 3 charts: SpaceTime, SpeedSpaceChart, SpaceCurvesSlopes
-export const traceVerticalLine = (
- chart,
- dataSimulation,
- keyValues,
- listValues,
- positionValues,
- refValueName,
- rotate,
- timePosition
-) => {
- if (chart !== undefined && d3.event === null) {
- displayGuide(chart, 1);
- if (rotate) {
- chart.svg
- .selectAll('#horizontal-line')
- .attr(
- 'y1',
- chart.y(
- keyValues[0] !== 'time' && positionValues.speed
- ? positionValues.speed.position
- : timePosition
- )
- )
- .attr(
- 'y2',
- chart.y(
- keyValues[0] !== 'time' && positionValues.speed
- ? positionValues.speed.position
- : timePosition
- )
- );
- } else {
- chart.svg
- .selectAll('#vertical-line')
- .attr(
- 'x1',
- chart.x(
- keyValues[0] !== 'time' && positionValues.speed
- ? positionValues.speed.position
- : timePosition
- )
- )
- .attr(
- 'x2',
- chart.x(
- keyValues[0] !== 'time' && positionValues.speed
- ? positionValues.speed.position
- : timePosition
- )
- );
- }
-
- updatePointers(chart, keyValues, listValues, positionValues, rotate);
- }
-};
-
-const enableInteractivity = (
- chart,
- dataSimulation,
- dispatch,
- keyValues,
- listValues,
- positionValues,
- rotate,
- setChart,
- setYPosition,
- setZoomLevel,
- yPosition,
- zoomLevel
-) => {
- let newHoverPosition;
-
- let lastChartX;
- const zoom = d3
- .zoom(newHoverPosition)
- .scaleExtent([0.5, 20]) // This control how much you can unzoom (x0.5) and zoom (x20)
- .extent([
- [0, 0],
- [chart.width, chart.height],
- ])
- .on('zoom', () => {
- dispatch(updateContextMenu(undefined));
- // Permit zoom if shift pressed, if only move or if factor > .5
- if (d3.event.sourceEvent.ctrlKey || d3.event.sourceEvent.shiftKey) {
- /* || d3.event.transform.k >= 1
- || zoomLevel >= 0.25)) { */
- d3.event.sourceEvent.preventDefault();
- setZoomLevel(zoomLevel * d3.event.transform.k);
- setYPosition(yPosition + d3.event.transform.y);
- const zoomFunctions = updateChart(chart, keyValues, rotate);
- const newChart = { ...chart, x: zoomFunctions.newX, y: zoomFunctions.newY };
- lastChartX = zoomFunctions.newX;
- setChart(newChart);
- }
- })
- .filter(() => (d3.event.button === 0 || d3.event.button === 1) && d3.event.ctrlKey)
- .on('end', () => {
- if (keyValues[1] === 'speed' || keyValues[1] === 'gradient') {
- dispatch(updateChartXGEV(lastChartX));
- }
- dispatch(updateMustRedraw(true));
- });
-
- let debounceTimeoutId;
-
- function debounceUpdateTimePositionValues(timePositionLocal, immediatePositionsValues, interval) {
- clearTimeout(debounceTimeoutId);
- debounceTimeoutId = setTimeout(() => {
- dispatch(updateTimePositionValues(timePositionLocal, null));
- }, interval);
- }
-
- const mousemove = () => {
- // If GET && not playing
- const { osrdsimulation } = store.getState();
- if (!osrdsimulation.isPlaying) {
- if (keyValues[0] === 'time') {
- // recover coordinate we need
- const timePositionLocal = rotate
- ? chart.y.invert(d3.mouse(d3.event.currentTarget)[1])
- : chart.x.invert(d3.mouse(d3.event.currentTarget)[0]);
-
- debounceUpdateTimePositionValues(timePositionLocal, null, 15);
- const immediatePositionsValuesForPointer = interpolateOnTime(
- dataSimulation,
- keyValues,
- LIST_VALUES_NAME_SPACE_TIME,
- timePositionLocal
- );
- updatePointers(chart, keyValues, listValues, immediatePositionsValuesForPointer, rotate);
- // useless: will be called by traceVerticalLine on positionValue useEffect
- //
- } else {
- // If GEV
- const positionLocal = rotate
- ? chart.y.invert(d3.mouse(d3.event.currentTarget)[1])
- : chart.x.invert(d3.mouse(d3.event.currentTarget)[0]);
- const timePositionLocal = interpolateOnPosition(dataSimulation, keyValues, positionLocal);
- if (timePositionLocal) {
- debounceUpdateTimePositionValues(timePositionLocal, null, 15);
- }
- }
-
- // Update guideLines
- chart.svg
- .selectAll('#vertical-line')
- .attr('x1', d3.mouse(d3.event.currentTarget)[0])
- .attr('x2', d3.mouse(d3.event.currentTarget)[0]);
- chart.svg
- .selectAll('#horizontal-line')
- .attr('y1', d3.mouse(d3.event.currentTarget)[1])
- .attr('y2', d3.mouse(d3.event.currentTarget)[1]);
- }
- };
-
- chart.svg // .selectAll('.zoomable')
- .on('mouseover', () => displayGuide(chart, 1))
- .on('mousemove', () => mousemove())
- .call(zoom);
- drawGuideLines(chart);
-};
-
-export default enableInteractivity;
diff --git a/front/src/applications/customget/components/svgDefs.jsx b/front/src/applications/customget/components/svgDefs.jsx
deleted file mode 100644
index fd2e39d6e74..00000000000
--- a/front/src/applications/customget/components/svgDefs.jsx
+++ /dev/null
@@ -1,44 +0,0 @@
-const svgDefs = (defs) => {
- const hatchSize = 4;
- const rotation = 45;
-
- // Diagonal hatching
- defs
- .append('pattern')
- .attr('id', 'hatchPatternGray')
- .attr('width', hatchSize)
- .attr('height', hatchSize)
- .attr('patternTransform', `rotate(${rotation})`)
- .attr('patternUnits', 'userSpaceOnUse')
- .append('rect')
- .attr('width', hatchSize / 2)
- .attr('height', hatchSize)
- .style('fill', '#d7d7d7');
-
- defs
- .append('pattern')
- .attr('id', 'hatchPatternDarkGray')
- .attr('width', hatchSize)
- .attr('height', hatchSize)
- .attr('patternTransform', `rotate(${rotation})`)
- .attr('patternUnits', 'userSpaceOnUse')
- .append('rect')
- .attr('width', hatchSize / 2)
- .attr('height', hatchSize)
- .style('fill', '#747678');
-
- defs
- .append('pattern')
- .attr('id', 'hatchPatternBlue')
- .attr('width', hatchSize)
- .attr('height', hatchSize)
- .attr('patternTransform', `rotate(${rotation})`)
- .attr('patternUnits', 'userSpaceOnUse')
- .append('rect')
- .attr('width', hatchSize / 2)
- .attr('height', hatchSize)
- .style('fill', '#82be00')
- .style('opacity', '0.1');
-};
-
-export default svgDefs;
diff --git a/front/src/applications/customget/testdata/manal_results_get.json b/front/src/applications/customget/testdata/manal_results_get.json
deleted file mode 100644
index 915e61a2b25..00000000000
--- a/front/src/applications/customget/testdata/manal_results_get.json
+++ /dev/null
@@ -1 +0,0 @@
-[{"train_metadata": {"name": "Train_0"}, "space_time_curves": [{"curve_metadata": {"name": "actual"}, "points": [[{"type": "station", "label": "Station_A", "position": 0, "time": 301}, {"type": "Station", "label": "Station_B", "position": 5900, "time": 530}, {"type": "station", "label": "Station_B", "position": 5900, "time": 932}, {"type": "switch", "label": "P1", "position": 7914, "time": 1027}, {"type": "switch", "label": "P1", "position": 7914, "time": 1027}, {"type": "Station", "label": "Station_D", "position": 11800, "time": 1169}]]}, {"curve_metadata": {"name": "planned"}, "points": [[{"type": "station", "label": "Station_A", "position": 0, "time": 0}, {"type": "Station", "label": "Station_B", "position": 5900, "time": 242}, {"type": "station", "label": "Station_B", "position": 5900, "time": 644}, {"type": "switch", "label": "P1", "position": 7914, "time": 744}, {"type": "switch", "label": "P1", "position": 7914, "time": 744}, {"type": "Station", "label": "Station_D", "position": 11800, "time": 886}]]}]}, {"train_metadata": {"name": "Train_1"}, "space_time_curves": [{"curve_metadata": {"name": "actual"}, "points": [[{"type": "station", "label": "Station_A", "position": 0, "time": 0}], [{"type": "switch", "label": "P1", "position": 7991, "time": 541}, {"type": "switch", "label": "P1", "position": 7991, "time": 541}, {"type": "station", "label": "Station_D", "position": 11800, "time": 686}]]}, {"curve_metadata": {"name": "planned"}, "points": [[{"type": "station", "label": "Station_A", "position": 0, "time": 0}], [{"type": "switch", "label": "P1", "position": 7991, "time": 541}, {"type": "switch", "label": "P1", "position": 7991, "time": 541}, {"type": "station", "label": "Station_D", "position": 11800, "time": 686}]]}]}]
\ No newline at end of file
diff --git a/front/src/applications/customget/views/CustomGET.jsx b/front/src/applications/customget/views/CustomGET.jsx
deleted file mode 100644
index 4b4e7d7bca8..00000000000
--- a/front/src/applications/customget/views/CustomGET.jsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import './CustomGET.scss';
-import React, { useEffect, useState } from 'react';
-import {
- updateConsolidatedSimulation,
- updateMustRedraw,
- updateSelectedProjection,
- updateSelectedTrainId,
- updateSimulation,
-} from 'reducers/osrdsimulation/actions';
-import { useDispatch, useSelector } from 'react-redux';
-
-import { Rnd } from 'react-rnd';
-import TimeTable from 'applications/customget/views/TimeTable';
-import TrainList from 'applications/customget/views/TrainList';
-import TimeButtons from 'applications/customget/views/TimeButtons';
-import TrainDetails from 'applications/customget/views/TrainDetails';
-import createTrain from 'applications/customget/components/SpaceTimeChart/createTrain';
-import { useTranslation } from 'react-i18next';
-import DeprecatedSpaceTimeChart from 'applications/customget/views/DeprecatedSpaceTimeChart';
-
-export const KEY_VALUES_FOR_CONSOLIDATED_SIMULATION = ['time', 'position'];
-
-export const trainscheduleURI = '/train_schedule/';
-
-function CustomGET() {
- const { t } = useTranslation(['translation', 'simulation']);
-
- const [heightOfSpaceTimeChart, setHeightOfSpaceTimeChart] = useState(400);
- const [initialHeightOfSpaceTimeChart, setInitialHeightOfSpaceTimeChart] =
- useState(heightOfSpaceTimeChart);
-
- const simulation = useSelector((state) => state.osrdsimulation.simulation.present);
- const dispatch = useDispatch();
-
- useEffect(() => {
- dispatch(updateSimulation({ trains: [] }));
- dispatch(updateSelectedTrainId(undefined));
- return function cleanup() {
- dispatch(updateSelectedProjection(undefined));
- dispatch(updateSimulation({ trains: [] }));
- };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
- // With this hook we update and store
- // the consolidatedSimuation (simualtion stucture for the selected train)
- useEffect(() => {
- const consolidatedSimulation = createTrain(
- dispatch,
- KEY_VALUES_FOR_CONSOLIDATED_SIMULATION,
- simulation.trains,
- t
- );
- // Store it to allow time->position logic to be hosted by redux
- dispatch(updateConsolidatedSimulation(consolidatedSimulation));
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [simulation]);
-
- return (
-
- {!simulation || simulation.trains.length === 0 ? (
-
-
{t('customget:noData')}
-
- ) : (
-
-
-
-
-
- {simulation.trains.length > 0 ? : null}
-
-
-
-
-
-
-
- {simulation.trains.length > 0 && (
- setInitialHeightOfSpaceTimeChart(heightOfSpaceTimeChart)}
- onResize={(e, dir, refToElement, delta) => {
- setHeightOfSpaceTimeChart(initialHeightOfSpaceTimeChart + delta.height);
- }}
- onResizeStop={() => {
- dispatch(updateMustRedraw(true));
- }}
- >
-
-
- )}
-
-
-
-
-
-
-
-
- {simulation.trains.length > 0 ? : null}
-
-
-
-
-
-
- )}
-
- );
-}
-
-export default CustomGET;
diff --git a/front/src/applications/customget/views/CustomGET.scss b/front/src/applications/customget/views/CustomGET.scss
deleted file mode 100644
index 0c6898983ee..00000000000
--- a/front/src/applications/customget/views/CustomGET.scss
+++ /dev/null
@@ -1,26 +0,0 @@
-.customget {
- .simulation-trainlist {
- max-height: none;
- }
- .train-name-timetable {
- color: var(--white);
- border-radius: var(--border-radius);
- }
- .timetable {
- .cell-inner {
- min-height: 2rem;
- font-size: 0.9rem;
- }
- }
- .chartTrain {
- .selected {
- stroke-width: 2;
- }
- }
- .curve-label {
- font-weight: normal;
- &.selected {
- font-weight: bold;
- }
- }
-}
diff --git a/front/src/applications/customget/views/DeprecatedSpaceTimeChart.jsx b/front/src/applications/customget/views/DeprecatedSpaceTimeChart.jsx
deleted file mode 100644
index d90d9ae59ef..00000000000
--- a/front/src/applications/customget/views/DeprecatedSpaceTimeChart.jsx
+++ /dev/null
@@ -1,296 +0,0 @@
-import * as d3 from 'd3';
-
-import React, { useEffect, useRef, useState } from 'react';
-import enableInteractivity, {
- traceVerticalLine,
-} from 'applications/customget/components/enableInteractivity';
-import { interpolateOnTime, timeShiftTrain } from 'applications/customget/components/ChartHelpers';
-import {
- updateChart,
- updateContextMenu,
- updateMustRedraw,
- updatePositionValues,
-} from 'reducers/osrdsimulation/actions';
-import { useDispatch, useSelector } from 'react-redux';
-
-import { CgLoadbar } from 'react-icons/cg';
-import ChartModal from 'applications/customget/components/ChartModal';
-import { GiResize } from 'react-icons/gi';
-import { LIST_VALUES_NAME_SPACE_TIME } from 'applications/customget/components/consts';
-import PropTypes from 'prop-types';
-import createChart from 'applications/customget/components/SpaceTimeChart/createChart';
-import createTrain from 'applications/customget/components/SpaceTimeChart/createTrain';
-import drawTrain from 'applications/customget/components/SpaceTimeChart/drawTrain';
-import { persistentUpdateSimulation } from 'reducers/osrdsimulation/simulation';
-import { useTranslation } from 'react-i18next';
-
-const CHART_ID = 'SpaceTimeChart';
-
-const drawAxisTitle = (chart, rotate) => {
- chart.drawZone
- .append('text')
- .attr('class', 'axis-unit')
- .attr('text-anchor', 'end')
- .attr('transform', rotate ? 'rotate(0)' : 'rotate(-90)')
- .attr('x', rotate ? chart.width - 10 : -10)
- .attr('y', rotate ? chart.height - 10 : 20)
- .text('KM');
-};
-
-export default function DeprecatedSpaceTimeChart(props) {
- const { heightOfSpaceTimeChart } = props;
- const ref = useRef();
- const dispatch = useDispatch();
- const { t } = useTranslation(['allowances']);
- const {
- allowancesSettings,
- mustRedraw,
- positionValues,
- selectedProjection,
- selectedTrain,
- timePosition,
- consolidatedSimulation,
- } = useSelector((state) => state.osrdsimulation);
- const simulation = useSelector((state) => state.osrdsimulation.simulation.present);
- const keyValues = ['time', 'position'];
- const [rotate, setRotate] = useState(false);
- const [chart, setChart] = useState(undefined);
- const [resetChart, setResetChart] = useState(false);
- const [zoomLevel, setZoomLevel] = useState(1);
- const [yPosition, setYPosition] = useState(0);
- const [dataSimulation, setDataSimulation] = useState(undefined);
- const [showModal, setShowModal] = useState('');
- const [dragOffset, setDragOffset] = useState(0);
- const [, setDragEnding] = useState(false);
-
- const handleKey = ({ key }) => {
- if (['+', '-'].includes(key)) {
- setShowModal(key);
- }
- };
-
- const offsetTimeByDragging = (offset) => {
- const trains = Array.from(simulation.trains);
- trains[selectedTrain] = timeShiftTrain(trains[selectedTrain], offset);
- dispatch(persistentUpdateSimulation({ ...simulation, trains }));
- };
-
- const toggleRotation = () => {
- d3.select(`#${CHART_ID}`).remove();
- setChart({ ...chart, x: chart.y, y: chart.x });
- setRotate(!rotate);
- dispatch(updateMustRedraw(true));
- };
-
- const drawOPs = (chartLocal) => {
- const operationalPointsZone = chartLocal.drawZone
- .append('g')
- .attr('id', 'get-operationalPointsZone');
- simulation.trains[selectedTrain].base.stops.forEach((stop) => {
- operationalPointsZone
- .append('line')
- .datum(stop.position)
- .attr('id', `op-${stop.id}`)
- .attr('class', 'op-line')
- .attr('x1', rotate ? (d) => chartLocal.x(d) : 0)
- .attr('y1', rotate ? 0 : (d) => chartLocal.y(d))
- .attr('x2', rotate ? (d) => chartLocal.x(d) : chartLocal.width)
- .attr('y2', rotate ? chartLocal.height : (d) => chartLocal.y(d));
- operationalPointsZone
- .append('text')
- .datum(stop.position)
- .attr('class', 'op-text')
- .text(`${stop.name || 'Unknown'} ${Math.round(stop.position) / 1000}`)
- .attr('x', rotate ? (d) => chartLocal.x(d) : 0)
- .attr('y', rotate ? 0 : (d) => chartLocal.y(d))
- .attr('text-anchor', 'center')
- .attr('dx', 5)
- .attr('dy', rotate ? 15 : -5);
- });
- };
-
- const drawAllTrains = (reset, forceRedraw = false, newDataSimulation = undefined) => {
- const currentDataSimulation = newDataSimulation || dataSimulation;
-
- if (mustRedraw || forceRedraw) {
- const chartLocal = createChart(
- chart,
- CHART_ID,
- currentDataSimulation,
- heightOfSpaceTimeChart,
- keyValues,
- ref,
- reset,
- rotate
- );
-
- chartLocal.svg.on('click', () => {
- dispatch(updateContextMenu(undefined));
- });
-
- drawOPs(chartLocal);
-
- drawAxisTitle(chartLocal, rotate);
- currentDataSimulation.forEach((train, idx) => {
- drawTrain(
- chartLocal,
- dispatch,
- train,
- train.id === selectedProjection?.id,
- idx === selectedTrain,
- keyValues,
- allowancesSettings,
- offsetTimeByDragging,
- rotate,
- setDragEnding,
- setDragOffset,
- simulation
- );
- });
- enableInteractivity(
- chartLocal,
- currentDataSimulation[selectedTrain],
- dispatch,
- keyValues,
- LIST_VALUES_NAME_SPACE_TIME,
- positionValues,
- rotate,
- setChart,
- setYPosition,
- setZoomLevel,
- yPosition,
- zoomLevel
- );
- // findConflicts(chartLocal, dataSimulation, rotate);
- setChart(chartLocal);
- dispatch(updateChart({ ...chartLocal, rotate }));
- dispatch(updateMustRedraw(false));
- setResetChart(false);
- }
- };
-
- useEffect(() => {
- setDataSimulation(createTrain(dispatch, keyValues, simulation.trains, t));
- setTimeout(() => {
- dispatch(updateMustRedraw(true));
- }, 0);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
- useEffect(() => {
- // ADN, entire fonction operation is subject to one condition, so aopply this condition before OR write clear and first condition to return (do nothing)
- offsetTimeByDragging(dragOffset);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [dragOffset]);
-
- useEffect(() => {
- setResetChart(true);
- }, [consolidatedSimulation]);
-
- useEffect(() => {
- setDataSimulation(createTrain(dispatch, keyValues, simulation.trains, t));
- if (dataSimulation) {
- drawAllTrains(resetChart);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [mustRedraw, rotate, selectedTrain, consolidatedSimulation]);
-
- // ADN: trigger a redraw on every simulation change. This is the right pattern.
- useEffect(() => {
- setDataSimulation(createTrain(dispatch, keyValues, simulation.trains, t));
- const newDataSimulation = createTrain(dispatch, keyValues, simulation.trains, t);
- if (dataSimulation) {
- // ADN drawAllTrain already traceVerticalLines
-
- drawAllTrains(resetChart, true, newDataSimulation);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [simulation.trains]);
-
- useEffect(() => {
- if (timePosition && dataSimulation && dataSimulation[selectedTrain]) {
- // ADN: too heavy, dispatch on release (dragEnd), careful with dispatch !
- const newPositionValues = interpolateOnTime(
- dataSimulation[selectedTrain],
- keyValues,
- LIST_VALUES_NAME_SPACE_TIME,
- timePosition
- );
- dispatch(updatePositionValues(newPositionValues));
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [chart, mustRedraw]);
-
- useEffect(() => {
- if (dataSimulation) {
- traceVerticalLine(
- chart,
- dataSimulation[selectedTrain],
- keyValues,
- LIST_VALUES_NAME_SPACE_TIME,
- positionValues,
- 'headPosition',
- rotate,
- timePosition
- );
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [positionValues]);
-
- useEffect(() => {
- let timeOutFunctionId;
- const timeOutResize = () => {
- clearTimeout(timeOutFunctionId);
- timeOutFunctionId = setTimeout(() => dispatch(updateMustRedraw(true)), 500);
- };
- window.addEventListener('keydown', handleKey);
- window.addEventListener('resize', timeOutResize);
- return () => {
- window.removeEventListener('keydown', handleKey);
- window.removeEventListener('resize', timeOutResize);
- };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
- return (
-
- {showModal !== '' ? (
-
- ) : null}
-
-
-
-
-
-
-
- );
-}
-
-DeprecatedSpaceTimeChart.propTypes = {
- heightOfSpaceTimeChart: PropTypes.number.isRequired,
-};
diff --git a/front/src/applications/customget/views/TimeButtons.jsx b/front/src/applications/customget/views/TimeButtons.jsx
deleted file mode 100644
index 9e1bdb7882a..00000000000
--- a/front/src/applications/customget/views/TimeButtons.jsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import { FaBackward, FaPause, FaPlay, FaStop } from 'react-icons/fa';
-import React, { useState } from 'react';
-import { datetime2time, sec2datetime, time2datetime } from 'utils/timeManipulation';
-import { updateIsPlaying, updateTimePositionValues } from 'reducers/osrdsimulation/actions';
-import { useDispatch, useSelector } from 'react-redux';
-import { getSelectedTrain } from 'reducers/osrdsimulation/selectors';
-import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
-
-// transform a speed ratio (X2 X10 X20, etc.) to interval time & step to bypass
-const factor2ms = (factor) => {
- const ms = Math.round(1000 / factor);
- const steps = ms < 100 ? Math.round((1 / ms) * 100) : 1;
- return { ms, steps };
-};
-
-export default function TimeButtons() {
- const dispatch = useDispatch();
- const { timePosition } = useSelector((state) => state.osrdsimulation);
- const selectedTrain = useSelector(getSelectedTrain);
- const [playInterval, setPlayInterval] = useState(undefined);
- const [playReverse, setPlayReverse] = useState(false);
- const [simulationSpeed, setSimulationSpeed] = useState(1);
-
- const stop = () => {
- clearInterval(playInterval);
- setPlayInterval(undefined);
- dispatch(updateTimePositionValues(sec2datetime(selectedTrain.base.stops[0].time)));
- dispatch(updateIsPlaying(false));
- };
- const pause = () => {
- clearInterval(playInterval);
- setPlayInterval(undefined);
- dispatch(updateIsPlaying(false));
- };
- const play = (playReverseLocal, simulationSpeedLocal = simulationSpeed) => {
- clearInterval(playInterval); // Kill interval playing if concerned
- setPlayInterval(undefined);
- const factor = factor2ms(simulationSpeedLocal);
- let i = timePosition.getTime() / 1000;
- const playIntervalLocal = setInterval(() => {
- if (playReverseLocal) {
- i -= factor.steps;
- } else {
- i += factor.steps;
- }
- dispatch(updateTimePositionValues(new Date(i * 1000)));
- }, factor.ms);
- setPlayInterval(playIntervalLocal);
- dispatch(updateIsPlaying(true));
- };
-
- const changeReverse = () => {
- setPlayReverse(!playReverse);
- if (playInterval) {
- play(!playReverse);
- }
- };
-
- const changeSimulationSpeed = (speedFactor) => {
- setSimulationSpeed(speedFactor);
- if (playInterval) {
- play(playReverse, speedFactor);
- }
- };
-
- const changeTimePosition = (e) => {
- dispatch(updateTimePositionValues(time2datetime(e.target.value)));
- };
-
- return (
-
-
-
-
-
-
- {playInterval ? (
-
- ) : (
-
- )}
- changeSimulationSpeed(e.target.value)}
- seconds
- sm
- />
-
- );
-}
diff --git a/front/src/applications/customget/views/TimeTable.jsx b/front/src/applications/customget/views/TimeTable.jsx
deleted file mode 100644
index ae4d9707aff..00000000000
--- a/front/src/applications/customget/views/TimeTable.jsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import React from 'react';
-import nextId from 'react-id-generator';
-import { sec2time } from 'utils/timeManipulation';
-import { useSelector } from 'react-redux';
-import { useTranslation } from 'react-i18next';
-import { getSelectedTrain } from 'reducers/osrdsimulation/selectors';
-import { BsArrowRightShort } from 'react-icons/bs';
-import signalIcon from 'assets/pictures/layersicons/layer_signal_open.svg';
-import stopIcon from 'assets/pictures/layersicons/ops.svg';
-
-function type2icon(type) {
- switch (type) {
- case 'stop':
- return
;
- case 'signal':
- return
;
- default:
- return type;
- }
-}
-
-function formatStops(stop, idx) {
- return (
- 0 ? 'font-weight-bold' : ''}`}>
-
- {idx}
- |
-
- {Math.round(stop.position / 100) / 10}
- |
-
- {type2icon(stop.type)}
- |
-
- {stop.name || 'Unknown'}
- |
-
- {sec2time(stop.time)}
- |
-
- {stop.duration > 0 && sec2time(stop.time + stop.duration)}
- |
-
- {stop.duration > 0 ? `${stop.duration}s` : null}
- |
-
- );
-}
-
-export default function TimeTable() {
- const { t } = useTranslation(['simulation']);
- const { departureArrivalTimes } = useSelector((state) => state.osrdsimulation);
- const train = useSelector(getSelectedTrain);
- const trainStops = train.base.stops;
-
- return (
- <>
-
-
- {departureArrivalTimes[train.id].name}
-
-
{sec2time(departureArrivalTimes[train.id].departure)}
-
-
-
-
{sec2time(departureArrivalTimes[train.id].arrival)}
-
-
-
-
-
-
- n° |
-
- KM
- |
-
- TYPE
- |
-
- {t('simulation:stopPlace')}
- |
-
- {t('simulation:stopTime')}
- |
-
- {t('simulation:departureTime')}
- |
-
- {t('simulation:stopStopTime')}
- |
-
-
- {trainStops.map((stop, idx) => formatStops(stop, idx, train))}
-
-
-
- >
- );
-}
diff --git a/front/src/applications/customget/views/TrainDetails.jsx b/front/src/applications/customget/views/TrainDetails.jsx
deleted file mode 100644
index 7268cb4afca..00000000000
--- a/front/src/applications/customget/views/TrainDetails.jsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import React from 'react';
-import { useSelector } from 'react-redux';
-import { useTranslation } from 'react-i18next';
-
-export default function TrainDetails() {
- const { positionValues, timePosition } = useSelector((state) => state.osrdsimulation);
-
- const { t } = useTranslation(['simulation']);
-
- return (
-
- {positionValues.headPosition && timePosition && (
- <>
-
-
{t('trainDetails.headPosition')}
- {positionValues.headPosition && Math.round(positionValues.headPosition.position) / 1000}
- km
-
-
-
{t('trainDetails.speed')}
- {positionValues.speed && Math.round(positionValues.speed.speed)}
- km/h
-
- >
- )}
-
- );
-}
diff --git a/front/src/applications/customget/views/TrainList.jsx b/front/src/applications/customget/views/TrainList.jsx
deleted file mode 100644
index 0e8ec413611..00000000000
--- a/front/src/applications/customget/views/TrainList.jsx
+++ /dev/null
@@ -1,235 +0,0 @@
-import React, { useEffect, useState } from 'react';
-import { sec2datetime, sec2time, time2datetime } from 'utils/timeManipulation';
-import {
- updateMustRedraw,
- updateSelectedTrainId,
- updateSimulation,
-} from 'reducers/osrdsimulation/actions';
-import { useDispatch, useSelector } from 'react-redux';
-import { getSelectedTrain } from 'reducers/osrdsimulation/selectors';
-
-import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
-import PropTypes from 'prop-types';
-import nextId from 'react-id-generator';
-import { timeShiftTrain } from 'applications/customget/components/ChartHelpers';
-import { useDebounce } from 'utils/helpers';
-import { useTranslation } from 'react-i18next';
-
-function InputName(props) {
- const { name, changeTrainName, idx, typeOfInputFocused } = props;
- const [localName, setLocalName] = useState(name);
- const handleChange = (value) => {
- setLocalName(value);
- changeTrainName(value, idx);
- };
-
- return (
- handleChange(e.target.value)}
- value={localName}
- noMargin
- focus={typeOfInputFocused === 'name'}
- sm
- />
- );
-}
-
-function InputTime(props) {
- const { time, changeTrainStartTime, idx, typeOfInputFocused } = props;
- const [localTime, setLocalTime] = useState(time);
- const handleChange = (value) => {
- setLocalTime(value);
- changeTrainStartTime(value, idx);
- };
-
- return (
- handleChange(e.target.value)}
- value={localTime}
- noMargin
- focus={typeOfInputFocused === 'time'}
- sm
- />
- );
-}
-
-export default function TrainsList() {
- const { departureArrivalTimes } = useSelector((state) => state.osrdsimulation);
- const selectedTrain = useSelector(getSelectedTrain);
- const simulation = useSelector((state) => state.osrdsimulation.simulation.present);
- const dispatch = useDispatch();
- const [formattedList, setFormattedList] = useState(null);
- const [trainNameClickedIDX, setTrainNameClickedIDX] = useState(undefined);
- const [typeOfInputFocused, setTypeOfInputFocused] = useState(undefined);
- const [inputName, setInputName] = useState(undefined);
- const [inputTime, setInputTime] = useState(undefined);
- const [onInput, setOnInput] = useState(false);
-
- const { t } = useTranslation(['simulation']);
-
- const changeSelectedTrain = (idx, typeOfInputToFocus) => {
- dispatch(updateSelectedTrainId(idx));
- setTrainNameClickedIDX(idx);
- setTypeOfInputFocused(typeOfInputToFocus);
- dispatch(updateMustRedraw(true));
- };
-
- const changeTrainName = (newName, idx) => {
- setOnInput(true);
- setInputName(newName);
- const newTrain = { ...simulation.trains[idx], name: newName };
- dispatch(
- updateSimulation({
- ...simulation,
- trains: simulation.trains.map((train, currentIdx) =>
- idx === currentIdx ? newTrain : train
- ),
- })
- );
- };
-
- const changeTrainStartTime = (newStartTime, idx) => {
- setOnInput(true);
- setInputTime(newStartTime);
- const offset = Math.floor(
- (time2datetime(newStartTime) - sec2datetime(simulation.trains[idx].base.stops[0].time)) / 1000
- );
- const trains = Array.from(simulation.trains);
- trains[idx] = timeShiftTrain(trains[selectedTrain], offset);
- dispatch(updateSimulation({ ...simulation, trains }));
- };
-
- const debouncedInputName = useDebounce(inputName, 500);
- const debouncedInputTime = useDebounce(inputTime, 500);
-
- const formatTrainsList = () => {
- const newFormattedList = departureArrivalTimes.map((train, idx) => (
-
-
-
-
-
- |
-
-
- changeSelectedTrain(train.id, 'name', train.name, sec2time(train.departure))
- }
- tabIndex={0}
- >
- {trainNameClickedIDX === idx ? (
-
- ) : (
- train.name
- )}
-
- |
-
-
- changeSelectedTrain(train.id, 'time', train.name, sec2time(train.departure))
- }
- tabIndex={0}
- >
- {trainNameClickedIDX === idx ? (
-
- ) : (
- sec2time(train.departure)
- )}
-
- |
-
- {sec2time(train.arrival)}
- |
-
- ));
- return newFormattedList;
- };
-
- useEffect(() => {
- if (debouncedInputName) {
- setOnInput(false);
- dispatch(updateMustRedraw(true));
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [debouncedInputName]);
-
- useEffect(() => {
- if (debouncedInputTime) {
- setOnInput(false);
- dispatch(updateMustRedraw(true));
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [debouncedInputTime]);
-
- useEffect(() => {
- if (!onInput) {
- setFormattedList(formatTrainsList());
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [selectedTrain, departureArrivalTimes, trainNameClickedIDX, typeOfInputFocused]);
-
- return (
- <>
-
-
-
- {`${t('simulation:trainList')} (${departureArrivalTimes.length})`}
-
-
-
-
-
-
-
-
-
- {t('simulation:name')}
- |
-
- {t('simulation:start')}
- |
-
- {t('simulation:stop')}
- |
-
-
- {formattedList}
-
-
-
- >
- );
-}
-
-InputName.propTypes = {
- changeTrainName: PropTypes.func.isRequired,
- idx: PropTypes.number.isRequired,
- name: PropTypes.string.isRequired,
- typeOfInputFocused: PropTypes.string.isRequired,
-};
-
-InputTime.propTypes = {
- changeTrainStartTime: PropTypes.func.isRequired,
- idx: PropTypes.number.isRequired,
- time: PropTypes.string.isRequired,
- typeOfInputFocused: PropTypes.string.isRequired,
-};
diff --git a/front/src/applications/operationalStudies/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx b/front/src/applications/operationalStudies/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
index 7386a024a8f..699a99553c7 100644
--- a/front/src/applications/operationalStudies/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
+++ b/front/src/applications/operationalStudies/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx
@@ -9,7 +9,6 @@ import MemoStationSelector from 'applications/operationalStudies/components/Impo
import { setFailure } from 'reducers/main';
import StationCard from 'common/StationCard';
import { formatIsoDate } from 'utils/date';
-import UploadFileModal from 'applications/customget/components/uploadFileModal';
import { ModalContext } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
import {
ImportedTrainSchedule,
@@ -24,6 +23,7 @@ import {
TrackLocation,
} from 'common/api/osrdEditoastApi';
import { getGraouTrainSchedules } from 'common/api/graouApi';
+import UploadFileModal from 'common/uploadFileModal';
interface ImportTrainScheduleConfigProps {
infraId: number;
diff --git a/front/src/assets/pictures/home/customget.svg b/front/src/assets/pictures/home/customget.svg
deleted file mode 100644
index d46dc796cad..00000000000
--- a/front/src/assets/pictures/home/customget.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/front/src/common/InfraSelector/InfraSelectorModalBodyEdition.tsx b/front/src/common/InfraSelector/InfraSelectorModalBodyEdition.tsx
index 445b9fa0b63..f6284c19b1d 100644
--- a/front/src/common/InfraSelector/InfraSelectorModalBodyEdition.tsx
+++ b/front/src/common/InfraSelector/InfraSelectorModalBodyEdition.tsx
@@ -27,17 +27,17 @@ const InfraSelectorModalBodyEdition = ({
const validateFile = async (fileToValidate: File) => {
if (fileToValidate.type !== 'application/json') {
- setErrorMessage(t('customget:notJSONFormat'));
+ setErrorMessage(t('jsonUpload.notJSONFormat'));
return false;
}
if (fileToValidate.size === 0) {
- setErrorMessage(t('customget:emptyFile'));
+ setErrorMessage(t('jsonUpload.emptyFile'));
return false;
}
try {
JSON.parse(await fileToValidate.text());
} catch (e) {
- setErrorMessage(t('customget:badJSON'));
+ setErrorMessage(t('jsonUpload.badJSON'));
return false;
}
return true;
diff --git a/front/src/applications/customget/components/uploadFileModal.jsx b/front/src/common/uploadFileModal.jsx
similarity index 88%
rename from front/src/applications/customget/components/uploadFileModal.jsx
rename to front/src/common/uploadFileModal.jsx
index 9be94bb4757..1881e5d91bc 100644
--- a/front/src/applications/customget/components/uploadFileModal.jsx
+++ b/front/src/common/uploadFileModal.jsx
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
import { ModalContext } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
function UploadFileModal(props) {
- const { t } = useTranslation(['customget', 'translation']);
+ const { t } = useTranslation(['translation']);
const [selectedFile, setSelectedFile] = useState();
const [isValid, setIsValid] = useState('');
const { closeModal } = useContext(ModalContext);
@@ -15,15 +15,15 @@ function UploadFileModal(props) {
const validateFile = async (fileToValidate) => {
if (fileToValidate.type !== 'application/json') {
- return t('customget:notJSONFormat');
+ return t('jsonUpload.notJSONFormat');
}
if (fileToValidate.size === 0) {
- return t('customget:emptyFile');
+ return t('jsonUpload.emptyFile');
}
try {
JSON.parse(await fileToValidate.text());
} catch (e) {
- return t('customget:badJSON');
+ return t('jsonUpload.badJSON');
}
return true;
};
@@ -56,7 +56,7 @@ function UploadFileModal(props) {
className="btn btn-block btn-sm btn-secondary"
onClick={closeModal}
>
- {t('translation:common:cancel')}
+ {t('common.cancel')}
@@ -65,7 +65,7 @@ function UploadFileModal(props) {
className={`btn btn-block btn-sm btn-primary ${isValid !== true ? 'disabled' : ''}`}
onClick={() => handleSubmit(selectedFile)}
>
- {t('translation:common:download')}
+ {t('common.download')}
diff --git a/front/src/main/app.jsx b/front/src/main/app.jsx
index 97337ec9cde..83f5586bc4b 100644
--- a/front/src/main/app.jsx
+++ b/front/src/main/app.jsx
@@ -6,7 +6,6 @@ import 'i18n';
import { attemptLoginOnLaunch } from 'reducers/user';
import { updateLastInterfaceVersion } from 'reducers/main';
-import HomeCustomGET from 'applications/customget/Home';
import HomeEditor from 'applications/editor/Home';
import HomeMap from 'applications/referenceMap/Home';
import HomeOperationalStudies from 'applications/operationalStudies/Home';
@@ -66,7 +65,6 @@ export default function App() {
} />
} />
} />
- } />
} />
diff --git a/front/src/main/home.jsx b/front/src/main/home.jsx
index 5e9495d5b97..472bb111c35 100644
--- a/front/src/main/home.jsx
+++ b/front/src/main/home.jsx
@@ -6,7 +6,6 @@ import editorImg from 'assets/pictures/home/editor.svg';
import rollingStockEditorImg from 'assets/pictures/home/rollingstockeditor.svg';
import stdcmImg from 'assets/pictures/home/stdcm.svg';
import operationalStudiesImg from 'assets/pictures/home/operationalStudies.svg';
-import customgetImg from 'assets/pictures/home/customget.svg';
import logo from 'assets/logo_osrd_seul_blanc.svg';
import osrdLogo from 'assets/pictures/osrd.png';
import { useSelector } from 'react-redux';
@@ -50,9 +49,6 @@ export default function Home() {
-
-
-
diff --git a/front/tests/pages/home-page-model.ts b/front/tests/pages/home-page-model.ts
index 475e2c53590..ee32967cf06 100644
--- a/front/tests/pages/home-page-model.ts
+++ b/front/tests/pages/home-page-model.ts
@@ -73,7 +73,6 @@ export class PlaywrightHomePage {
this.getTranslations('editor'),
this.getTranslations('rollingStockEditor'),
this.getTranslations('stdcm'),
- this.getTranslations('customget'),
]);
}