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

workschedules #9012

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
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 @@ -3,6 +3,7 @@ import { useMemo, useState } from 'react';
import { Button } from '@osrd-project/ui-core';
import { PDFDownloadLink } from '@react-pdf/renderer';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import SimulationReportSheet from 'applications/stdcm/components/SimulationReportSheet';
import { STDCM_TRAIN_ID } from 'applications/stdcm/consts';
Expand All @@ -12,10 +13,13 @@ import {
getOperationalPointsWithTimes,
} from 'applications/stdcm/utils/formatSimulationReportSheet';
import type { StdcmSimulation } from 'applications/stdcmV2/types';
import { osrdEditoastApi, type TrackRange } from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors } from 'common/osrdContext';
import i18n from 'i18n';
import ManchetteWithSpaceTimeChartWrapper from 'modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart';
import SpeedSpaceChartContainer from 'modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartContainer';
import { Map } from 'modules/trainschedule/components/ManageTrainSchedule';
import type { StdcmConfSelectors } from 'reducers/osrdconf/stdcmConf/selectors';

import StcdmResultsTable from './StdcmResultsTable';
import StdcmSimulationNavigator from './StdcmSimulationNavigator';
Expand All @@ -30,6 +34,7 @@ type StcdmResultsV2Props = {
selectedSimulationIndex: number;
showStatusBanner: boolean;
simulationsList: StdcmSimulation[];
pathTrackRanges?: TrackRange[];
};

const SPEED_SPACE_CHART_HEIGHT = 521.5;
Expand All @@ -45,7 +50,19 @@ const StcdmResults = ({
selectedSimulationIndex,
showStatusBanner,
simulationsList,
pathTrackRanges,
}: StcdmResultsV2Props) => {
const { getWorkScheduleGroupId } = useOsrdConfSelectors() as StdcmConfSelectors;
const workScheduleGroupId = useSelector(getWorkScheduleGroupId);
const { data: workSchedules } = osrdEditoastApi.endpoints.postWorkSchedulesProjectPath.useQuery(
{
body: {
path_track_ranges: pathTrackRanges!,
work_schedule_group_id: workScheduleGroupId!,
},
},
{ skip: !pathTrackRanges || !workScheduleGroupId }
);
const { t } = useTranslation('stdcm', { keyPrefix: 'simulation.results' });
const tWithoutPrefix = i18n.getFixedT(null, 'stdcm');

Expand Down Expand Up @@ -154,6 +171,7 @@ const StcdmResults = ({
}
projectPathTrainResult={spaceTimeData}
selectedTrainScheduleId={STDCM_TRAIN_ID}
workSchedules={workSchedules}
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions front/src/applications/stdcmV2/views/StdcmViewV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const StdcmViewV2 = () => {
selectedSimulationIndex={selectedSimulationIndex}
showStatusBanner={showStatusBanner}
simulationsList={simulationsList}
pathTrackRanges={stdcmV2Results?.stdcmResponse.path.track_section_ranges}
/>
)}
</div>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ const ScenarioExplorer = ({
updateStdcmEnvironment({
infraID: scenario.infra_id,
timetableID: scenario.timetable_id,
electricalProfileSetId: undefined,
workScheduleGroupId: undefined,
electricalProfileSetId: scenario.electrical_profile_set_id,
searchDatetimeWindow: scenarioDateTimeWindow,
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import { useRef, useState } from 'react';
import { KebabHorizontal } from '@osrd-project/ui-icons';
import { Manchette } from '@osrd-project/ui-manchette';
import { useManchettesWithSpaceTimeChart } from '@osrd-project/ui-manchette-with-spacetimechart';
import { ConflictLayer, PathLayer, SpaceTimeChart } from '@osrd-project/ui-spacetimechart';
import {
ConflictLayer,
PathLayer,
SpaceTimeChart,
WorkScheduleLayer,
} from '@osrd-project/ui-spacetimechart';
import type { Conflict } from '@osrd-project/ui-spacetimechart';

import type { OperationalPoint, TrainSpaceTimeData } from 'applications/operationalStudies/types';
import upward from 'assets/pictures/workSchedules/ScheduledMaintenanceUp.svg';
import type { PostWorkSchedulesProjectPathApiResponse } from 'common/api/osrdEditoastApi';
import type { WaypointsPanelData } from 'modules/simulationResult/types';

import SettingsPanel from './SettingsPanel';
Expand All @@ -19,6 +26,7 @@ type ManchetteWithSpaceTimeChartProps = {
selectedTrainScheduleId?: number;
waypointsPanelData?: WaypointsPanelData;
conflicts?: Conflict[];
workSchedules?: PostWorkSchedulesProjectPathApiResponse;
};
const DEFAULT_HEIGHT = 561;

Expand All @@ -28,6 +36,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
selectedTrainScheduleId,
waypointsPanelData,
conflicts = [],
workSchedules,
}: ManchetteWithSpaceTimeChartProps) => {
const [heightOfManchetteWithSpaceTimeChart] = useState(DEFAULT_HEIGHT);
const manchetteWithSpaceTimeChartRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -97,6 +106,17 @@ const ManchetteWithSpaceTimeChartWrapper = ({
{spaceTimeChartProps.paths.map((path) => (
<PathLayer key={path.id} path={path} color={path.color} />
))}
{workSchedules && (
<WorkScheduleLayer
workSchedules={workSchedules.map((ws) => ({
type: ws.type,
timeStart: new Date(ws.start_date_time),
timeEnd: new Date(ws.end_date_time),
spaceRanges: ws.path_position_ranges.map(({ start, end }) => [start, end]),
}))}
imageUrl={upward}
/>
)}
{settings.showConflicts && <ConflictLayer conflicts={conflicts} />}
</SpaceTimeChart>
</div>
Expand Down
1 change: 1 addition & 0 deletions front/src/reducers/osrdconf/osrdConfCommon/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const buildCommonConfSelectors = <ConfState extends OsrdConfState>(
getScenarioID: makeOsrdConfSelector('scenarioID'),
getTimetableID: makeOsrdConfSelector('timetableID'),
getElectricalProfileSetId: makeOsrdConfSelector('electricalProfileSetId'),
getWorkScheduleGroupId: makeOsrdConfSelector('workScheduleGroupId'),
getSearchDatetimeWindow: makeOsrdConfSelector('searchDatetimeWindow'),
getRollingStockID: makeOsrdConfSelector('rollingStockID'),
getSpeedLimitByTag: makeOsrdConfSelector('speedLimitByTag'),
Expand Down
4 changes: 3 additions & 1 deletion front/src/reducers/osrdconf/stdcmConf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ export const stdcmConfSlice = createSlice({
state.infraID = action.payload.infraID;
state.timetableID = action.payload.timetableID;
state.electricalProfileSetId = action.payload.electricalProfileSetId;
state.workScheduleGroupId = action.payload.workScheduleGroupId;
state.searchDatetimeWindow = action.payload.searchDatetimeWindow;
if (action.payload.workScheduleGroupId) {
state.workScheduleGroupId = action.payload.workScheduleGroupId;
}
},
updateOriginArrival(
state: Draft<OsrdStdcmConfState>,
Expand Down
Loading