Skip to content

Commit 6faaa0e

Browse files
clementleclercRTEBOUTIER CharlyEstherDarkishSOUISSI Maissa (Externe)souissimai
authored
Limit nad in grid (#3029)
* NAD depth refactor (WIP) Signed-off-by: BOUTIER Charly <[email protected]> * add men when click on voltage level on nad Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> * add voltage level to expand , when clicking on vl nad Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> * NAD depth refactor (WIP) Signed-off-by: BOUTIER Charly <[email protected]> * hide voltageLevel Signed-off-by: Leclerc Clement <[email protected]> * hide voltageLevel Signed-off-by: Leclerc Clement <[email protected]> * hide voltageLevel fix Signed-off-by: Leclerc Clement <[email protected]> * rename voltagelevel context menu Signed-off-by: Leclerc Clement <[email protected]> * rename node context menu Signed-off-by: Leclerc Clement <[email protected]> * New button to augment depth in NAD Signed-off-by: BOUTIER Charly <[email protected]> * NAD_FROM_ELEMENT removal. Still needs to fix the diagram's titles. Signed-off-by: BOUTIER Charly <[email protected]> * TS Fixes Signed-off-by: BOUTIER Charly <[email protected]> * TS Fixes Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * Clean front data when receiving SVG Signed-off-by: BOUTIER Charly <[email protected]> * Update front data when receiving NAD SVG Signed-off-by: BOUTIER Charly <[email protected]> * add positions Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * type fix Signed-off-by: Leclerc Clement <[email protected]> * Fix diagram names Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * Code cleaning Signed-off-by: BOUTIER Charly <[email protected]> * Fix positions Signed-off-by: BOUTIER Charly <[email protected]> * TS Signed-off-by: BOUTIER Charly <[email protected]> * Store positions in session storage Signed-off-by: BOUTIER Charly <[email protected]> * update createDiagram Method Signed-off-by: Leclerc Clement <[email protected]> * create styles Signed-off-by: Leclerc Clement <[email protected]> * replace style with sx Signed-off-by: Leclerc Clement <[email protected]> * add nad loading state checks Signed-off-by: Leclerc Clement <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * PR Review Signed-off-by: BOUTIER Charly <[email protected]> * change snackbar message Signed-off-by: Leclerc Clement <[email protected]> * merge main Signed-off-by: Leclerc Clement <[email protected]> * review fix Signed-off-by: Leclerc Clement <[email protected]> * review fix Signed-off-by: Leclerc Clement <[email protected]> --------- Signed-off-by: BOUTIER Charly <[email protected]> Signed-off-by: SOUISSI Maissa (Externe) <[email protected]> Signed-off-by: Leclerc Clement <[email protected]> Co-authored-by: BOUTIER Charly <[email protected]> Co-authored-by: Charly B <[email protected]> Co-authored-by: SOUISSI Maissa (Externe) <[email protected]> Co-authored-by: souissimai <[email protected]>
1 parent 451c3e4 commit 6faaa0e

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/components/diagrams/diagram-common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const MAX_WIDTH_SUBSTATION = 1200;
2121
export const MAX_HEIGHT_SUBSTATION = 700;
2222
export const MAX_WIDTH_NETWORK_AREA_DIAGRAM = 1200;
2323
export const MAX_HEIGHT_NETWORK_AREA_DIAGRAM = 650;
24+
export const MAX_NUMBER_OF_NAD_DIAGRAMS = 3;
2425

2526
// Array of zoom levels used to determine level-of-detail rendering by applying in the network-viewer the
2627
// corresponding css class 'nad-zoom-{level}' to the NAD's SVG.

src/components/diagrams/hooks/use-diagram-model.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { useIntl } from 'react-intl';
2929
import { useDiagramTitle } from './use-diagram-title';
3030
import { useSnackMessage } from '@gridsuite/commons-ui';
3131
import { NodeType } from 'components/graph/tree-node.type';
32-
import { DiagramAdditionalMetadata } from '../diagram-common';
32+
import { DiagramAdditionalMetadata, MAX_NUMBER_OF_NAD_DIAGRAMS } from '../diagram-common';
3333
import { mergePositions } from '../diagram-utils';
3434
import { DiagramMetadata } from '@powsybl/network-viewer';
3535

@@ -41,7 +41,7 @@ type UseDiagramModelProps = {
4141

4242
export const useDiagramModel = ({ diagramTypes, onAddDiagram, onDiagramAlreadyExists }: UseDiagramModelProps) => {
4343
const intl = useIntl();
44-
const { snackError } = useSnackMessage();
44+
const { snackInfo } = useSnackMessage();
4545
// context
4646
const studyUuid = useSelector((state: AppState) => state.studyUuid);
4747
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
@@ -308,7 +308,7 @@ export const useDiagramModel = ({ diagramTypes, onAddDiagram, onDiagramAlreadyEx
308308
diagram.type === DiagramType.SUBSTATION ? 'SubstationNotFound' : 'VoltageLevelNotFound';
309309
} else {
310310
errorMessage = 'svgLoadingFail';
311-
snackError({
311+
snackInfo({
312312
headerId: errorMessage,
313313
});
314314
}
@@ -325,7 +325,7 @@ export const useDiagramModel = ({ diagramTypes, onAddDiagram, onDiagramAlreadyEx
325325
});
326326
});
327327
},
328-
[getDiagramTitle, getUrl, intl, snackError, networkVisuParams.networkAreaDiagramParameters.initNadWithGeoData]
328+
[getDiagramTitle, getUrl, intl, snackInfo, networkVisuParams.networkAreaDiagramParameters.initNadWithGeoData]
329329
);
330330

331331
const findSimilarDiagram = useCallback(
@@ -356,8 +356,22 @@ export const useDiagramModel = ({ diagramTypes, onAddDiagram, onDiagramAlreadyEx
356356
[diagrams]
357357
);
358358

359+
const countOpenedNadDiagrams = (diagrams: Record<UUID, Diagram>) => {
360+
return Object.values(diagrams).filter((diagram) => diagram?.type === DiagramType.NETWORK_AREA_DIAGRAM).length;
361+
};
362+
359363
const createDiagram = useCallback(
360364
(diagramParams: DiagramParams) => {
365+
if (
366+
diagramParams.type === DiagramType.NETWORK_AREA_DIAGRAM &&
367+
countOpenedNadDiagrams(diagrams) >= MAX_NUMBER_OF_NAD_DIAGRAMS
368+
) {
369+
snackInfo({
370+
messageTxt: intl.formatMessage({ id: 'MaxNumberOfNadDiagramsReached' }),
371+
});
372+
return;
373+
}
374+
361375
if (filterDiagramParams([diagramParams]).length === 0) {
362376
// this hook instance don't manage this type of diagram
363377
return;
@@ -380,6 +394,9 @@ export const useDiagramModel = ({ diagramTypes, onAddDiagram, onDiagramAlreadyEx
380394
filterDiagramParams,
381395
findSimilarDiagram,
382396
onDiagramAlreadyExists,
397+
diagrams,
398+
intl,
399+
snackInfo,
383400
]
384401
);
385402

src/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,5 +1483,6 @@
14831483
"selectedOperationalLimitsGroup1": "Active limit set on side 1",
14841484
"selectedOperationalLimitsGroup2": "Active limit set on side 2",
14851485
"OpenMapCard": "Add the map",
1486-
"AddNewCard": "Add a new image"
1486+
"AddNewCard": "Add a new image",
1487+
"MaxNumberOfNadDiagramsReached": "You need to close at least one network area diagram to open a new one"
14871488
}

src/translations/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,5 +1478,6 @@
14781478
"selectedOperationalLimitsGroup1": "Jeu de limites actif côté 1",
14791479
"selectedOperationalLimitsGroup2": "Jeu de limites actif côté 2",
14801480
"OpenMapCard": "Ajouter la carte géographique",
1481-
"AddNewCard": "Ajouter une nouvelle image"
1481+
"AddNewCard": "Ajouter une nouvelle image",
1482+
"MaxNumberOfNadDiagramsReached": "Vous devez fermer au moins une image nodale existante pour en ouvrir une nouvelle"
14821483
}

0 commit comments

Comments
 (0)