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

migrate network modification list display #606

Merged
merged 36 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5829a2b
draft refacto improve filter ihm
Mathieu-Deharbe Sep 11, 2024
e36d844
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Sep 18, 2024
e6a882f
new FilterForm file
Mathieu-Deharbe Sep 18, 2024
4f53a68
corrects errors
Mathieu-Deharbe Sep 18, 2024
7950a93
fixed window height
Mathieu-Deharbe Sep 19, 2024
e262283
draft scrolling update
Mathieu-Deharbe Sep 24, 2024
41113ef
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Sep 24, 2024
1591f18
much better scrolling
Mathieu-Deharbe Sep 24, 2024
3139240
read only prop
Mathieu-Deharbe Sep 24, 2024
706cb2b
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Sep 26, 2024
dedbbd0
95vh
Mathieu-Deharbe Oct 1, 2024
d665e3e
Merge remote-tracking branch 'origin/improve-filter-ihm' into improve…
Mathieu-Deharbe Oct 1, 2024
713bbce
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Oct 1, 2024
51d29a1
unscrollableFullHeight props parameter
Mathieu-Deharbe Oct 1, 2024
51a45a2
padding
Mathieu-Deharbe Oct 1, 2024
5e3374f
draft scroll for exmplicit naming filters
Mathieu-Deharbe Oct 1, 2024
355ae33
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Oct 1, 2024
8e6a88b
expert filters scroll
Mathieu-Deharbe Oct 1, 2024
405efb0
Merge remote-tracking branch 'origin/improve-filter-ihm' into improve…
Mathieu-Deharbe Oct 1, 2024
e8e8f8c
reset CriteriaForm to make it usable with aleas
Mathieu-Deharbe Oct 2, 2024
1b3d7d2
min height
Mathieu-Deharbe Oct 2, 2024
3353523
Merge branch 'main' into improve-filter-ihm
Mathieu-Deharbe Oct 4, 2024
83985bc
migrate network modification list display
Mathieu-Deharbe Oct 9, 2024
bde26d6
commit test
Mathieu-Deharbe Oct 9, 2024
073c29b
Resolve merge conflicts
Mathieu-Deharbe Oct 21, 2024
09e7049
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 22, 2024
e321394
omissions
Mathieu-Deharbe Oct 22, 2024
a80b173
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 24, 2024
afc9bba
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 24, 2024
ba61ef9
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 24, 2024
1da47a3
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 24, 2024
736cc06
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 30, 2024
d62d534
rename localization files
Mathieu-Deharbe Oct 30, 2024
6407b9e
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Oct 31, 2024
48aac4d
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Nov 6, 2024
e0ed6ed
Merge branch 'main' into migrate-network-modification-list-display
Mathieu-Deharbe Nov 12, 2024
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
4 changes: 4 additions & 0 deletions demo/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ import {
useSnackMessage,
commonButtonEn,
commonButtonFr,
networkModificationsEn,
networkModificationsFr,
} from '../../src';

const messages = {
Expand All @@ -127,6 +129,7 @@ const messages = {
...flatParametersEn,
...multipleSelectionDialogEn,
...commonButtonEn,
...networkModificationsEn,
...inputsEn,
...translations.en,
},
Expand All @@ -146,6 +149,7 @@ const messages = {
...cardErrorBoundaryFr,
...flatParametersFr,
...commonButtonFr,
...networkModificationsFr,
...multipleSelectionDialogFr,
...inputsFr,
...translations.fr,
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export * from './customStates';
export * from './useModificationLabelComputer';
export * from './useConfidentialityWarning';
export * from './useDebounce';
export * from './useIntlRef';
Expand Down
106 changes: 106 additions & 0 deletions src/hooks/useModificationLabelComputer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { useIntl } from 'react-intl';
import { useCallback } from 'react';
import { UUID } from 'crypto';
import { MODIFICATION_TYPES } from '../utils/types/modificationType';
import { EQUIPMENT_TYPE } from '../utils/types/equipmentType';

export interface NetworkModificationMetadata {
uuid: UUID;
type: string;
date: Date;
stashed: boolean;
activated: boolean;
messageType: string;
messageValues: string;
}

interface ModificationValues {
equipmentId: string;
action: string;
energizedVoltageLevelId: string;
equipmentAttributeName: string;
equipmentAttributeValue: string;
}

const getOperatingStatusModificationValues = (modification: ModificationValues, withFormat: boolean) => {
return {
action: modification.action,
energizedEnd: modification.energizedVoltageLevelId,
computedLabel: withFormat ? <strong>{modification.equipmentId}</strong> : modification.equipmentId,
};
};
const getEquipmentAttributeModificationValues = (modification: ModificationValues, withFormat: boolean) => {
return {
equipmentAttributeName: modification.equipmentAttributeName,
equipmentAttributeValue: modification.equipmentAttributeValue,
computedLabel: withFormat ? <strong>{modification.equipmentId}</strong> : modification.equipmentId,
};
};

export const useModificationLabelComputer = () => {
const intl = useIntl();

const getLabel = useCallback(
(modif: NetworkModificationMetadata) => {
const modificationMetadata = JSON.parse(modif.messageValues);

switch (modif.messageType) {
case MODIFICATION_TYPES.LINE_SPLIT_WITH_VOLTAGE_LEVEL.type:
return modificationMetadata.lineToSplitId;
case MODIFICATION_TYPES.LINE_ATTACH_TO_VOLTAGE_LEVEL.type:
return modificationMetadata.lineToAttachToId;
case MODIFICATION_TYPES.LINES_ATTACH_TO_SPLIT_LINES.type:
return modificationMetadata.attachedLineId;
case MODIFICATION_TYPES.DELETE_VOLTAGE_LEVEL_ON_LINE.type:
return `${modificationMetadata.lineToAttachTo1Id}/${modificationMetadata.lineToAttachTo2Id}`;
case MODIFICATION_TYPES.DELETE_ATTACHING_LINE.type:
return `${modificationMetadata.attachedLineId}/${modificationMetadata.lineToAttachTo1Id}/${modificationMetadata.lineToAttachTo2Id}`;
case MODIFICATION_TYPES.TABULAR_MODIFICATION.type:
return intl.formatMessage({
id: `network_modifications.tabular.${modificationMetadata.tabularModificationType}`,
});
case MODIFICATION_TYPES.BY_FILTER_DELETION.type:
return intl.formatMessage({
id:
modificationMetadata.equipmentType === EQUIPMENT_TYPE.HVDC_LINE
? 'Hvdc'
: modificationMetadata.equipmentType,
});
case MODIFICATION_TYPES.TABULAR_CREATION.type:
return intl.formatMessage({
id: `network_modifications.tabular.${modificationMetadata.tabularCreationType}`,
});
default:
return modificationMetadata.equipmentId || '';
}
},
[intl]
);

const computeLabel = useCallback(
(modif: NetworkModificationMetadata, withFormat = true) => {
const modificationValues = JSON.parse(modif.messageValues);

switch (modif.messageType) {
case MODIFICATION_TYPES.OPERATING_STATUS_MODIFICATION.type:
return getOperatingStatusModificationValues(modificationValues, withFormat);
case MODIFICATION_TYPES.EQUIPMENT_ATTRIBUTE_MODIFICATION.type:
return getEquipmentAttributeModificationValues(modificationValues, withFormat);
default:
return {
computedLabel: withFormat ? <strong>{getLabel(modif)}</strong> : getLabel(modif),
};
}
},
[getLabel]
);

return { computeLabel };
};
1 change: 1 addition & 0 deletions src/translations/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export * from './reportViewerEn';
export * from './tableEn';
export * from './topBarEn';
export * from './treeviewFinderEn';
export * from './networkModificationsEn';
export * from './external/exportParamsEn';
export * from './external/importParamsEn';
64 changes: 64 additions & 0 deletions src/translations/en/networkModificationsEn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

export const networkModificationsEn = {
'network_modifications.modificationsCount':
'{hide, select, false {{count, plural, =0 {no modification} =1 {{count} modification} other {{count} modifications}}} other {...}}',
'network_modifications.EQUIPMENT_DELETION': 'Deletion of {computedLabel}',
'network_modifications.BY_FILTER_DELETION': 'By filter deletion ({computedLabel})',
'network_modifications.SUBSTATION_CREATION': 'Creating substation {computedLabel}',
'network_modifications.SUBSTATION_MODIFICATION': 'Modifying substation {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_CREATION': 'Creating voltage level {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_MODIFICATION': 'Modifying voltage level {computedLabel}',
'network_modifications.LINE_SPLIT_WITH_VOLTAGE_LEVEL': 'Splitting a line {computedLabel}',
'network_modifications.LINE_ATTACH_TO_VOLTAGE_LEVEL': 'Attaching line {computedLabel}',
'network_modifications.LINES_ATTACH_TO_SPLIT_LINES': 'Attaching lines to splitting lines {computedLabel}',
'network_modifications.LOAD_SCALING': 'Load scaling {computedLabel}',
'network_modifications.DELETE_VOLTAGE_LEVEL_ON_LINE': 'Deleting a voltage level on a line {computedLabel}',
'network_modifications.DELETE_ATTACHING_LINE': 'Deleting attaching line {computedLabel}',
'network_modifications.LOAD_CREATION': 'Creating load {computedLabel}',
'network_modifications.LOAD_MODIFICATION': 'Modifying load {computedLabel}',
'network_modifications.BATTERY_CREATION': 'Creating battery {computedLabel}',
'network_modifications.BATTERY_MODIFICATION': 'Modifying battery {computedLabel}',
'network_modifications.GENERATOR_CREATION': 'Creating generator {computedLabel}',
'network_modifications.GENERATOR_MODIFICATION': 'Modifying generator {computedLabel}',
'network_modifications.LINE_CREATION': 'Creating line {computedLabel}',
'network_modifications.LINE_MODIFICATION': 'Modifying line {computedLabel}',
'network_modifications.TWO_WINDINGS_TRANSFORMER_CREATION': 'Creating 2 windings transformer {computedLabel}',
'network_modifications.TWO_WINDINGS_TRANSFORMER_MODIFICATION': 'Modifying 2 windings transformer {computedLabel}',
'network_modifications.OPERATING_STATUS_MODIFICATION':
'{action, select, TRIP {Trip {computedLabel}} LOCKOUT {Lock out {computedLabel}} ENERGISE_END_ONE {Energise {computedLabel} on {energizedEnd}} ENERGISE_END_TWO {Energise {computedLabel} on {energizedEnd}} SWITCH_ON {Switch on {computedLabel}} other {Equipment operating status modification {computedLabel}}}',
'network_modifications.SHUNT_COMPENSATOR_CREATION': 'Creating shunt compensator {computedLabel}',
'network_modifications.SHUNT_COMPENSATOR_MODIFICATION': 'Modifying shunt compensator {computedLabel}',
'network_modifications.GENERATOR_SCALING': 'Generator scaling {computedLabel}',
'network_modifications.VSC_CREATION': 'Creating HVDC (VSC) {computedLabel}',
'network_modifications.VSC_MODIFICATION': 'Modifing HVDC (VSC) {computedLabel}',
'network_modifications.GROOVY_SCRIPT': 'Modification by script',
'network_modifications.EQUIPMENT_ATTRIBUTE_MODIFICATION':
'{equipmentAttributeName, select, open {{equipmentAttributeValue, select, true {Open {computedLabel}} other {Close {computedLabel}}}} other {Equipment modification {computedLabel}}}',
'network_modifications.creatingModification': 'Creating modification ...',
'network_modifications.deletingModification': 'Deleting modification ...',
'network_modifications.updatingModification': 'Updating modification ...',
'network_modifications.stashingModification': 'Stashing modification ...',
'network_modifications.restoringModification': 'Restoring modification ...',
'network_modifications.modifications': 'Updating modification list ...',
'network_modifications.GENERATION_DISPATCH': 'Generation dispatch {computedLabel}',
'network_modifications.VOLTAGE_INIT_MODIFICATION': 'Voltage profile initialization {computedLabel}',
'network_modifications.TABULAR_MODIFICATION': 'Tabular modification - {computedLabel}',
'network_modifications.tabular.GENERATOR_MODIFICATION': 'generator modifications',
'network_modifications.tabular.LOAD_MODIFICATION': 'load modifications',
'network_modifications.BY_FORMULA_MODIFICATION': 'Modification by formula {computedLabel}',
'network_modifications.MODIFICATION_BY_ASSIGNMENT': 'Modification by filter {computedLabel}',
'network_modifications.tabular.LINE_MODIFICATION': 'line modifications',
'network_modifications.tabular.BATTERY_MODIFICATION': 'battery modifications',
'network_modifications.tabular.VOLTAGE_LEVEL_MODIFICATION': 'voltage level modifications',
'network_modifications.tabular.TWO_WINDINGS_TRANSFORMER_MODIFICATION': 'two windings transformer modifications',
'network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION': 'linear shunt compensator modifications',
'network_modifications.tabular.SUBSTATION_MODIFICATION': 'substation modifications',
'network_modifications.TABULAR_CREATION': 'Tabular creation - {computedLabel}',
'network_modifications.tabular.GENERATOR_CREATION': 'generator creations',
};
1 change: 1 addition & 0 deletions src/translations/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export * from './reportViewerFr';
export * from './tableFr';
export * from './topBarFr';
export * from './treeviewFinderFr';
export * from './networkModificationsFr';
export * from './external/exportParamsFr';
export * from './external/importParamsFr';
67 changes: 67 additions & 0 deletions src/translations/fr/networkModificationsFr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

export const networkModificationsFr = {
'network_modifications.modificationsCount':
'{hide, select, false {{count, plural, =0 {aucune modification} =1 {# modification} other {# modifications}}} other {...}}',
'network_modifications.EQUIPMENT_DELETION': 'Suppression de {computedLabel}',
'network_modifications.BY_FILTER_DELETION': 'Suppression par filtre ({computedLabel})',
'network_modifications.SUBSTATION_CREATION': 'Création du site {computedLabel}',
'network_modifications.SUBSTATION_MODIFICATION': 'Modification du site {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_CREATION': 'Création du poste {computedLabel}',
'network_modifications.VOLTAGE_LEVEL_MODIFICATION': 'Modification du poste {computedLabel}',
'network_modifications.LINE_SPLIT_WITH_VOLTAGE_LEVEL': "Création d'une coupure {computedLabel}",
'network_modifications.LINE_ATTACH_TO_VOLTAGE_LEVEL': "Création d'un piquage {computedLabel}",
'network_modifications.LINES_ATTACH_TO_SPLIT_LINES': 'Passage de piquage en coupure {computedLabel}',
'network_modifications.LOAD_SCALING': 'Variation plan de consommation {computedLabel}',
'network_modifications.DELETE_VOLTAGE_LEVEL_ON_LINE': "Suppression d'une coupure {computedLabel}",
'network_modifications.DELETE_ATTACHING_LINE': "Suppression d'un piquage {computedLabel}",
'network_modifications.LOAD_CREATION': 'Création de la charge {computedLabel}',
'network_modifications.LOAD_MODIFICATION': 'Modification de la charge {computedLabel}',
'network_modifications.BATTERY_CREATION': 'Création de batterie {computedLabel}',
'network_modifications.BATTERY_MODIFICATION': 'Modification de batterie {computedLabel}',
'network_modifications.GENERATOR_CREATION': 'Création du générateur {computedLabel}',
'network_modifications.GENERATOR_MODIFICATION': 'Modification du générateur {computedLabel}',
'network_modifications.LINE_CREATION': 'Création de la ligne {computedLabel}',
'network_modifications.LINE_MODIFICATION': 'Modification de la ligne {computedLabel}',
'network_modifications.TWO_WINDINGS_TRANSFORMER_CREATION':
'Création du transformateur à 2 enroulements {computedLabel}',
'network_modifications.TWO_WINDINGS_TRANSFORMER_MODIFICATION':
'Modification du transformateur à 2 enroulements {computedLabel}',
'network_modifications.OPERATING_STATUS_MODIFICATION':
"{action, select, TRIP {Déclenchement de {computedLabel}} LOCKOUT {Consignation de {computedLabel}} ENERGISE_END_ONE {Mise sous tension à vide de {computedLabel} depuis {energizedEnd}} ENERGISE_END_TWO {Mise sous tension à vide de {computedLabel} depuis {energizedEnd}} SWITCH_ON {Mise en service de {computedLabel}} other {Modification du statut opérationnel de l'équipement {computedLabel}}}",
'network_modifications.SHUNT_COMPENSATOR_CREATION': "Création d'un moyen de compensation {computedLabel}",
'network_modifications.SHUNT_COMPENSATOR_MODIFICATION': "Modification d'un moyen de compensation {computedLabel}",
'network_modifications.GENERATOR_SCALING': 'Variation plan de production {computedLabel}',
'network_modifications.VSC_CREATION': 'Création de la HVDC (VSC) {computedLabel}',
'network_modifications.VSC_MODIFICATION': 'Modification de la HVDC (VSC) {computedLabel}',
'network_modifications.GROOVY_SCRIPT': 'Modification par script',
'network_modifications.EQUIPMENT_ATTRIBUTE_MODIFICATION':
"{equipmentAttributeName, select, open {{equipmentAttributeValue, select, true {Ouverture de {computedLabel}} other {Fermeture de {computedLabel}}}} other {Modification de l'equipement {computedLabel}}}",
'network_modifications.creatingModification': 'Création de la modification en cours ...',
'network_modifications.deletingModification': 'Suppression de la modification en cours ...',
'network_modifications.updatingModification': 'Mise à jour de la modification en cours ...',
'network_modifications.stashingModification': 'Mise en corbeille de la modification en cours ...',
'network_modifications.restoringModification': 'Restauration de la modification en cours ...',
'network_modifications.modifications': 'Mise à jour de la liste des modifications en cours ...',
'network_modifications.GENERATION_DISPATCH': 'Démarrage de groupes {computedLabel}',
'network_modifications.VOLTAGE_INIT_MODIFICATION': 'Initialisation du plan de tension {computedLabel}',
'network_modifications.TABULAR_MODIFICATION': 'Modification tabulaire - {computedLabel}',
'network_modifications.tabular.GENERATOR_MODIFICATION': 'modifications de générateurs',
'network_modifications.tabular.LOAD_MODIFICATION': 'modifications de consommations',
'network_modifications.BY_FORMULA_MODIFICATION': 'Modification par formule {computedLabel}',
'network_modifications.MODIFICATION_BY_ASSIGNMENT': 'Modification par filtre {computedLabel}',
'network_modifications.tabular.LINE_MODIFICATION': 'modifications de lignes',
'network_modifications.tabular.BATTERY_MODIFICATION': 'modifications de batteries',
'network_modifications.tabular.VOLTAGE_LEVEL_MODIFICATION': 'modifications de postes',
'network_modifications.tabular.TWO_WINDINGS_TRANSFORMER_MODIFICATION':
'modifications de transformateurs à 2 enroulements',
'network_modifications.tabular.SHUNT_COMPENSATOR_MODIFICATION': 'modifications de MCS linéaires',
'network_modifications.tabular.SUBSTATION_MODIFICATION': 'modifications de sites',
'network_modifications.TABULAR_CREATION': 'Création tabulaire - {computedLabel}',
'network_modifications.tabular.GENERATOR_CREATION': 'créations de générateurs',
};
1 change: 1 addition & 0 deletions src/utils/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './equipmentType';
export * from './equipmentTypes';
export * from './metadata';
export * from './types';
export * from './modificationType';
Loading
Loading