Skip to content

Commit 87e7484

Browse files
committed
front: refacto move macro consts to consts.ts
Signed-off-by: Louis Greiner <[email protected]>
1 parent a293855 commit 87e7484

File tree

3 files changed

+123
-107
lines changed

3 files changed

+123
-107
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import type {
2+
LabelGroupDto,
3+
NetzgrafikDto,
4+
TimeLockDto,
5+
TrainrunCategory,
6+
TrainrunFrequency,
7+
TrainrunTimeCategory,
8+
} from '../NGE/types';
9+
10+
export const TRAINRUN_CATEGORY_HALTEZEITEN = {
11+
HaltezeitIPV: { haltezeit: 0, no_halt: false },
12+
HaltezeitA: { haltezeit: 0, no_halt: false },
13+
HaltezeitB: { haltezeit: 0, no_halt: false },
14+
HaltezeitC: { haltezeit: 0, no_halt: false },
15+
HaltezeitD: { haltezeit: 0, no_halt: false },
16+
HaltezeitUncategorized: { haltezeit: 0, no_halt: false },
17+
};
18+
19+
export const TRAINRUN_LABEL_GROUP: LabelGroupDto = {
20+
id: 1,
21+
name: 'Default',
22+
labelRef: 'Trainrun',
23+
};
24+
export const NODE_LABEL_GROUP: LabelGroupDto = {
25+
id: 2,
26+
name: 'Node',
27+
labelRef: 'Node',
28+
};
29+
30+
export const DEFAULT_TRAINRUN_CATEGORY: TrainrunCategory = {
31+
id: 1, // In NGE, Trainrun.DEFAULT_TRAINRUN_CATEGORY
32+
order: 0,
33+
name: 'Default',
34+
shortName: '', // TODO: find a better way to hide this in the graph
35+
fachCategory: 'HaltezeitUncategorized',
36+
colorRef: 'EC',
37+
minimalTurnaroundTime: 0,
38+
nodeHeadwayStop: 0,
39+
nodeHeadwayNonStop: 0,
40+
sectionHeadway: 0,
41+
};
42+
43+
export const DEFAULT_TRAINRUN_FREQUENCIES: TrainrunFrequency[] = [
44+
{
45+
id: 2,
46+
order: 0,
47+
frequency: 30,
48+
offset: 0,
49+
name: 'Half-hourly',
50+
shortName: '30',
51+
linePatternRef: '30',
52+
},
53+
{
54+
id: 3, // default NGE frequency takes id 3
55+
order: 1,
56+
frequency: 60,
57+
offset: 0,
58+
name: 'Hourly',
59+
/** Short name, needs to be unique */
60+
shortName: '60',
61+
linePatternRef: '60',
62+
},
63+
{
64+
id: 4,
65+
order: 2,
66+
frequency: 120,
67+
offset: 0,
68+
name: 'Two-hourly',
69+
shortName: '120',
70+
linePatternRef: '120',
71+
},
72+
];
73+
74+
export const DEFAULT_TRAINRUN_FREQUENCY: TrainrunFrequency = DEFAULT_TRAINRUN_FREQUENCIES[1];
75+
76+
export const DEFAULT_TRAINRUN_TIME_CATEGORY: TrainrunTimeCategory = {
77+
id: 0, // In NGE, Trainrun.DEFAULT_TRAINRUN_TIME_CATEGORY
78+
order: 0,
79+
name: 'Default',
80+
shortName: '7/24',
81+
dayTimeInterval: [],
82+
weekday: [1, 2, 3, 4, 5, 6, 7],
83+
linePatternRef: '7/24',
84+
};
85+
86+
export const DEFAULT_DTO: NetzgrafikDto = {
87+
resources: [],
88+
nodes: [],
89+
trainruns: [],
90+
trainrunSections: [],
91+
metadata: {
92+
netzgrafikColors: [],
93+
trainrunCategories: [DEFAULT_TRAINRUN_CATEGORY],
94+
trainrunFrequencies: [...DEFAULT_TRAINRUN_FREQUENCIES],
95+
trainrunTimeCategories: [DEFAULT_TRAINRUN_TIME_CATEGORY],
96+
},
97+
freeFloatingTexts: [],
98+
labels: [],
99+
labelGroups: [],
100+
filterData: {
101+
filterSettings: [],
102+
},
103+
};
104+
105+
export const DEFAULT_TIME_LOCK: TimeLockDto = {
106+
time: null,
107+
consecutiveTime: null,
108+
lock: false,
109+
warning: null,
110+
timeFormatter: null,
111+
};

front/src/applications/operationalStudies/components/MacroEditor/ngeToOsrd.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import type { AppDispatch } from 'store';
1010
import { formatToIsoDate } from 'utils/date';
1111
import { Duration } from 'utils/duration';
1212

13+
import { DEFAULT_TRAINRUN_FREQUENCIES, DEFAULT_TRAINRUN_FREQUENCY } from './consts';
1314
import type MacroEditorState from './MacroEditorState';
1415
import type { NodeIndexed } from './MacroEditorState';
15-
import { DEFAULT_TRAINRUN_FREQUENCIES, DEFAULT_TRAINRUN_FREQUENCY } from './osrdToNge';
1616
import { createMacroNode, deleteMacroNodeByNgeId, updateMacroNode } from './utils';
1717
import type {
1818
NetzgrafikDto,

front/src/applications/operationalStudies/components/MacroEditor/osrdToNge.ts

+11-106
Original file line numberDiff line numberDiff line change
@@ -6,124 +6,29 @@ import buildOpSearchQuery from 'modules/operationalPoint/helpers/buildOpSearchQu
66
import type { AppDispatch } from 'store';
77
import { Duration, addDurationToDate } from 'utils/duration';
88

9+
import {
10+
TRAINRUN_CATEGORY_HALTEZEITEN,
11+
NODE_LABEL_GROUP,
12+
DEFAULT_TRAINRUN_FREQUENCIES,
13+
DEFAULT_TRAINRUN_CATEGORY,
14+
DEFAULT_TRAINRUN_FREQUENCY,
15+
DEFAULT_TRAINRUN_TIME_CATEGORY,
16+
TRAINRUN_LABEL_GROUP,
17+
DEFAULT_TIME_LOCK,
18+
DEFAULT_DTO,
19+
} from './consts';
920
import MacroEditorState, { type NodeIndexed } from './MacroEditorState';
1021
import { deleteMacroNodeByDbId, getSavedMacroNodes } from './utils';
1122
import {
1223
type PortDto,
1324
type TimeLockDto,
1425
type TrainrunSectionDto,
15-
type TrainrunCategory,
16-
type TrainrunTimeCategory,
1726
type TrainrunFrequency,
1827
type NetzgrafikDto,
19-
type LabelGroupDto,
2028
PortAlignment,
2129
type LabelDto,
2230
} from '../NGE/types';
2331

24-
const TRAINRUN_CATEGORY_HALTEZEITEN = {
25-
HaltezeitIPV: { haltezeit: 0, no_halt: false },
26-
HaltezeitA: { haltezeit: 0, no_halt: false },
27-
HaltezeitB: { haltezeit: 0, no_halt: false },
28-
HaltezeitC: { haltezeit: 0, no_halt: false },
29-
HaltezeitD: { haltezeit: 0, no_halt: false },
30-
HaltezeitUncategorized: { haltezeit: 0, no_halt: false },
31-
};
32-
33-
const TRAINRUN_LABEL_GROUP: LabelGroupDto = {
34-
id: 1,
35-
name: 'Default',
36-
labelRef: 'Trainrun',
37-
};
38-
const NODE_LABEL_GROUP: LabelGroupDto = {
39-
id: 2,
40-
name: 'Node',
41-
labelRef: 'Node',
42-
};
43-
44-
const DEFAULT_TRAINRUN_CATEGORY: TrainrunCategory = {
45-
id: 1, // In NGE, Trainrun.DEFAULT_TRAINRUN_CATEGORY
46-
order: 0,
47-
name: 'Default',
48-
shortName: '', // TODO: find a better way to hide this in the graph
49-
fachCategory: 'HaltezeitUncategorized',
50-
colorRef: 'EC',
51-
minimalTurnaroundTime: 0,
52-
nodeHeadwayStop: 0,
53-
nodeHeadwayNonStop: 0,
54-
sectionHeadway: 0,
55-
};
56-
57-
export const DEFAULT_TRAINRUN_FREQUENCIES: TrainrunFrequency[] = [
58-
{
59-
id: 2,
60-
order: 0,
61-
frequency: 30,
62-
offset: 0,
63-
name: 'Half-hourly',
64-
shortName: '30',
65-
linePatternRef: '30',
66-
},
67-
{
68-
id: 3, // default NGE frequency takes id 3
69-
order: 1,
70-
frequency: 60,
71-
offset: 0,
72-
name: 'Hourly',
73-
/** Short name, needs to be unique */
74-
shortName: '60',
75-
linePatternRef: '60',
76-
},
77-
{
78-
id: 4,
79-
order: 2,
80-
frequency: 120,
81-
offset: 0,
82-
name: 'Two-hourly',
83-
shortName: '120',
84-
linePatternRef: '120',
85-
},
86-
];
87-
88-
export const DEFAULT_TRAINRUN_FREQUENCY: TrainrunFrequency = DEFAULT_TRAINRUN_FREQUENCIES[1];
89-
90-
const DEFAULT_TRAINRUN_TIME_CATEGORY: TrainrunTimeCategory = {
91-
id: 0, // In NGE, Trainrun.DEFAULT_TRAINRUN_TIME_CATEGORY
92-
order: 0,
93-
name: 'Default',
94-
shortName: '7/24',
95-
dayTimeInterval: [],
96-
weekday: [1, 2, 3, 4, 5, 6, 7],
97-
linePatternRef: '7/24',
98-
};
99-
100-
const DEFAULT_DTO: NetzgrafikDto = {
101-
resources: [],
102-
nodes: [],
103-
trainruns: [],
104-
trainrunSections: [],
105-
metadata: {
106-
netzgrafikColors: [],
107-
trainrunCategories: [DEFAULT_TRAINRUN_CATEGORY],
108-
trainrunFrequencies: [...DEFAULT_TRAINRUN_FREQUENCIES],
109-
trainrunTimeCategories: [DEFAULT_TRAINRUN_TIME_CATEGORY],
110-
},
111-
freeFloatingTexts: [],
112-
labels: [],
113-
labelGroups: [],
114-
filterData: {
115-
filterSettings: [],
116-
},
117-
};
118-
119-
const DEFAULT_TIME_LOCK: TimeLockDto = {
120-
time: null,
121-
consecutiveTime: null,
122-
lock: false,
123-
warning: null,
124-
timeFormatter: null,
125-
};
126-
12732
/**
12833
* Execute the search payload and collect all result pages.
12934
*/

0 commit comments

Comments
 (0)