-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate network modification list display (#606)
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
- Loading branch information
1 parent
5999ccd
commit 06603ba
Showing
9 changed files
with
417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.