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

Update Limit Reductions Table Form to display duration bounds in minutes and adjust translations accordingly #2451

Merged
merged 17 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -12,6 +12,7 @@ import {
PARAM_SA_LOW_VOLTAGE_PROPORTIONAL_THRESHOLD,
} from 'utils/config-params';
import yup from '../../../../utils/yup-config';
import { NumberSchema } from 'yup';

export const LIMIT_REDUCTIONS_FORM = 'limitReductionsForm';
export const VOLTAGE_LEVELS_FORM = 'voltageLevelsForm';
Expand Down Expand Up @@ -64,20 +65,39 @@ export const TAB_INFO = [
export interface IColumnsDef {
label: string;
dataKey: string;
tooltip: string;
width?: string;
}

export const COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS = [
export const COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS: IColumnsDef[] = [
{
label: 'VoltageLevels',
label: 'voltageRange',
dataKey: VOLTAGE_LEVELS_FORM,
tooltip: 'voltageRange',
},
{
label: 'IST',
dataKey: IST_FORM,
tooltip: 'Permanent',
},
];

//TODO: a cleaner solution can be done by using yup.array()
// Instead of creating a schema for each limit duration individually,
// we can use yup.array() to define an array of limit durations directly.
const getLimitDurationsFormSchema = (nbLimits: number) => {
let limitDurationsFormSchema: Record<string, NumberSchema> = {};
for (let i = 0; i < nbLimits; i++) {
limitDurationsFormSchema[LIMIT_DURATION_FORM + i] = yup
.number()
.min(0, 'RealPercentage')
.max(1, 'RealPercentage')
.nullable()
.required();
}
return limitDurationsFormSchema;
};

export const getLimitReductionsFormSchema = (nbTemporaryLimits: number) => {
return yup
.object()
Expand All @@ -86,11 +106,7 @@ export const getLimitReductionsFormSchema = (nbTemporaryLimits: number) => {
yup.object().shape({
[VOLTAGE_LEVELS_FORM]: yup.string(),
[IST_FORM]: yup.number().min(0, 'RealPercentage').max(1, 'RealPercentage').nullable().required(),
[LIMIT_DURATION_FORM]: yup
.array()
.length(nbTemporaryLimits)
.of(yup.number().min(0, 'RealPercentage').max(1, 'RealPercentage').nullable().required())
.required(),
...getLimitDurationsFormSchema(nbTemporaryLimits),
})
),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,47 @@ const LimitReductionsTableForm: FunctionComponent<{

const getLabelColumn = useCallback(
(limit: ITemporaryLimitReduction) => {
const lowBound = Math.trunc(limit.limitDuration.lowBound / 60);
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
const highBound = Math.trunc(limit.limitDuration.highBound / 60);
if (lowBound === 0) {
return intl.formatMessage({ id: 'LimitDurationAfterIST' }, { value: highBound });
}
return intl.formatMessage(
{ id: 'LimitDuration' },
{
sign: limit.limitDuration.lowClosed ? '>=' : '>',
value: Math.trunc(limit.limitDuration.lowBound / 60),
lowBound: `IT ${lowBound}`,
highBound: `IT ${highBound}`,
}
);
},
[intl]
);

const getToolTipColumn = useCallback((limit: ITemporaryLimitReduction) => {
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
const lowBound = Math.trunc(limit.limitDuration.lowBound / 60);
const highBound = Math.trunc(limit.limitDuration.highBound / 60);
return `[${lowBound} min, ${highBound} min[`;
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
}, []);

const columnsDefinition = useMemo(() => {
let columnsDefinition = COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS.map((column) => ({
...column,
label: intl.formatMessage({ id: column.label }),
tooltip: intl.formatMessage({ id: column.tooltip }),
}));

if (limits !== null && limits.length > 0) {
limits[0].temporaryLimitReductions.forEach((tlimit, index) => {
columnsDefinition.push({
label: getLabelColumn(tlimit),
dataKey: LIMIT_DURATION_FORM + index,
tooltip: getToolTipColumn(tlimit),
});
});
}

return columnsDefinition;
}, [intl, limits, getLabelColumn]);
}, [intl, limits, getLabelColumn, getToolTipColumn]);

return <LimitReductionsTable columnsDefinition={columnsDefinition} tableHeight={600} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const LimitReductionsTable: FunctionComponent<LimitReductionsTableProps> = ({ co
sx={{
textAlign: 'center',
}}
title={column.tooltip}
>
<Box>{column.label}</Box>
</TableCell>
Expand Down
3 changes: 2 additions & 1 deletion src/components/dialogs/parameters/load-flow-parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import ParameterLineSlider from './widget/parameter-line-slider';
import {
ILimitReductionsByVoltageLevel,
IST_FORM,
LIMIT_DURATION_FORM,
LIMIT_REDUCTIONS_FORM,
TAB_INFO,
TAB_VALUES,
getLimitReductionsFormSchema,
LIMIT_DURATION_FORM,
} from './common/limitreductions/columns-definitions';
import LimitReductionsTableForm from './common/limitreductions/limit-reductions-table-form';
import { useForm } from 'react-hook-form';
Expand Down Expand Up @@ -627,6 +627,7 @@ export const LoadFlowParameters: FunctionComponent<LoadFlowParametersProps> = ({
vlLimits.temporaryLimitReductions.forEach((temporaryLimit, index) => {
vlLNewLimits.temporaryLimitReductions[index] = {
...temporaryLimit,
// @ts-expect-error
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
reduction: formLimits[indexVl][LIMIT_DURATION_FORM][index],
};
});
Expand Down
5 changes: 4 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"LimitReductions" : "Limit reductions",
jamal-khey marked this conversation as resolved.
Show resolved Hide resolved
"IST" : "IST",
"LimitDuration" : "Limit duration {sign} {value}min",
"LimitDuration" : "Between {highBound} and {lowBound}",
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
"LimitDurationAfterIST": "After IT{value}",
"voltageRange": "Voltage range",

"button.delete": "Delete",
"filter": "Filter",
Expand Down Expand Up @@ -413,6 +415,7 @@
"CalculatedValue": "Calculated value (A or kV)",
"OverloadedEquipment": "Equipment",
"PermanentLimitName": "IST",
"Permanent": "Permanent",
"LimitAcceptableDuration": "Duration",
"Overload": "Overload",
"ErrFetchViolationsMsg": "An error occurred while getting constraint violations",
Expand Down
17 changes: 10 additions & 7 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"General": "General",

"LimitReductions" : "Abattements de limites",
"LimitReductions" : "Abattements",
jamal-khey marked this conversation as resolved.
Show resolved Hide resolved
"IST" : "IST",
"LimitDuration" : "Surcharge {sign} {value}min",
"LimitDuration" : "Entre {highBound} et {lowBound}",
"LimitDurationAfterIST": "Au-delà de IT{value}",
"voltageRange": "Niveau de tension",

"button.delete": "Supprimer",
"filter": "Filtre",
Expand Down Expand Up @@ -411,9 +413,10 @@
"LimitName": "Nom du seuil",
"Limit_name": "Seuil",
"LimitNameCurrentViolation": "Nom du seuil",
"CalculatedValue": "Valeur calculée (A ou kV)",
"CalculatedValue": "Valeur calculée (A ou kV)",
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
"OverloadedEquipment": "Ouvrage",
"PermanentLimitName": "IST",
"Permanent":"Permanent",
"LimitAcceptableDuration": "Durée",
"Overload": "Surcharge",

Expand Down Expand Up @@ -1161,7 +1164,7 @@
"GeneratorFilter": "FILTRE GROUPE",
"FrequencyReserve": "RESERVE FREQUENCE (%)",
"frequencyReserve": "Réserve fréquence",
"GeneratorsFiltersFrequencyReserveToolTip": "Les saisies sont appliquées dans lordre de la liste (en remplaçant éventuellement des saisies au fur et à mesure si un groupe est inclus dans plusieurs filtres)",
"GeneratorsFiltersFrequencyReserveToolTip": "Les saisies sont appliquées dans l'ordre de la liste (en remplaçant éventuellement des saisies au fur et à mesure si un groupe est inclus dans plusieurs filtres)",
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
"GeneratorsOrdering": "Hiérarchie des sites",
"ReplacingLine": "Liaison de remplacement",
"ConnectionPosition": "Position départ",
Expand Down Expand Up @@ -1237,9 +1240,9 @@
"muiTablePaginationFirst": "Aller à la première page",
"muiTablePaginationLast": "Aller à la dernière page",
"flowSensitivityValue": "Valeur du seuil de sensibilité",
"flowFlowSensitivityValueThreshold": "ΔMW ou ΔA / MW",
"angleFlowSensitivityValueThreshold": "ΔMW ou ΔA / Δ°",
"flowVoltageSensitivityValueThreshold": "ΔkV / kV",
"flowFlowSensitivityValueThreshold": "ΔMW ou ΔA / MW",
SlimaneAmar marked this conversation as resolved.
Show resolved Hide resolved
"angleFlowSensitivityValueThreshold": "ΔMW ou ΔA / Δ°",
"flowVoltageSensitivityValueThreshold": "ΔkV / kV",
"previewModifications": "Visualiser modifications",
"errPreviewVoltageInitModificationMsg": "Une erreur est survenue lors de la récupération des modifications issues de l'initialisation du plan de tension",
"errCloneVoltageInitModificationMsg": "Une erreur est survenue lors de l'application des modifications issues de l'initialisation du plan de tension",
Expand Down
Loading