diff --git a/src/components/ui/reactHookForm/constants.ts b/src/components/ui/reactHookForm/constants.ts index f54f3cac7..43bea3d6b 100644 --- a/src/components/ui/reactHookForm/constants.ts +++ b/src/components/ui/reactHookForm/constants.ts @@ -7,3 +7,6 @@ export const NAME = 'name'; export const DESCRIPTION = 'description'; +export const DIRECTORY_ITEM = 'directoryItem'; +export const DIRECTORY_ITEM_ID = 'directoryItemId'; +export const DIRECTORY_ITEM_FULL_PATH = 'directoryItemFullPath'; diff --git a/src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx b/src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx new file mode 100644 index 000000000..3663f3446 --- /dev/null +++ b/src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2026, 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 { Box, Button, FormHelperText, Grid2 as Grid, Stack, Tooltip, Typography } from '@mui/material'; +import { FormattedMessage, useIntl } from 'react-intl'; +import { useCallback, useMemo, useState } from 'react'; +import { useController } from 'react-hook-form'; +import { UUID } from 'node:crypto'; +import { FolderOutlined } from '@mui/icons-material'; +import { DIRECTORY_ITEM_FULL_PATH, DIRECTORY_ITEM_ID } from '../constants'; +import { DirectoryItemSchema, getAbsenceLabelKeyFromType } from './directory-item-utils'; +import { DirectoryItemSelector, DirectoryItemSelectorProps } from '../../directoryItemSelector'; +import { TreeViewFinderNodeProps } from '../../treeViewFinder'; + +export interface DirectoryItemSelectorInputProps extends Omit { + name: string; +} + +export function DirectoryItemInput({ name, types, ...props }: Readonly) { + const [isOpen, setIsOpen] = useState(false); + + const { + field: { onChange, value }, + fieldState: { error }, + } = useController({ name }); + + const nodeInfos: DirectoryItemSchema | undefined | null = value; + const intl = useIntl(); + + const breadcrumb = useMemo(() => { + return nodeInfos?.[DIRECTORY_ITEM_FULL_PATH] ? nodeInfos[DIRECTORY_ITEM_FULL_PATH] : undefined; + }, [nodeInfos]); + + const onNodeChanged = useCallback( + (nodes: TreeViewFinderNodeProps[]) => { + if (nodes.length > 0) { + const fullPath = nodes[0]?.name; + const nodeId: UUID | null = nodes[0]?.id; + if (nodeId) { + const newNodeInfos = { + [DIRECTORY_ITEM_ID]: nodeId, + [DIRECTORY_ITEM_FULL_PATH]: fullPath, + }; + onChange(newNodeInfos); + } + } + setIsOpen(false); + }, + [onChange] + ); + + return ( + + + + + + + + + + {breadcrumb || } + + + + + {error?.message && ( + {intl.formatMessage({ id: error?.message })} + )} + + + + + + + + ); +} diff --git a/src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts b/src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts new file mode 100644 index 000000000..648065f3a --- /dev/null +++ b/src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2026, 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 * as yup from 'yup'; +import { DIRECTORY_ITEM_FULL_PATH, DIRECTORY_ITEM_ID } from '../constants'; +import { ElementType } from '../../../../utils'; + +export function getAbsenceLabelKeyFromType(elementType: string) { + switch (elementType) { + case ElementType.DIRECTORY: + return 'NoFolder'; + case ElementType.CASE: + return 'NoCase'; + case ElementType.STUDY: + return 'NoStudy'; + default: + return 'NoItem'; + } +} + +export const directoryItemSchema = yup.object().shape({ + [DIRECTORY_ITEM_ID]: yup.string().required(), + [DIRECTORY_ITEM_FULL_PATH]: yup.string().required(), +}); + +export type DirectoryItemSchema = yup.InferType; diff --git a/src/components/ui/reactHookForm/directory-item-input/index.ts b/src/components/ui/reactHookForm/directory-item-input/index.ts new file mode 100644 index 000000000..16a34d4ea --- /dev/null +++ b/src/components/ui/reactHookForm/directory-item-input/index.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2026, 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 * from './directory-item-utils'; +export * from './directory-item-input'; diff --git a/src/components/ui/reactHookForm/index.ts b/src/components/ui/reactHookForm/index.ts index 8a1f87a03..62e977cad 100644 --- a/src/components/ui/reactHookForm/index.ts +++ b/src/components/ui/reactHookForm/index.ts @@ -24,3 +24,4 @@ export * from './constants'; export * from './expandableInput'; export * from './CountrySelectionInput'; export * from './CheckboxNullableInput'; +export * from './directory-item-input'; diff --git a/src/features/parameters/common/widget/parameter-line-directory-items-input.tsx b/src/features/parameters/common/widget/parameter-line-directory-items-input.tsx index 9682bbbb3..d0259fb04 100644 --- a/src/features/parameters/common/widget/parameter-line-directory-items-input.tsx +++ b/src/features/parameters/common/widget/parameter-line-directory-items-input.tsx @@ -15,7 +15,7 @@ type DirectoryItemsInputLineProps = { name: string; equipmentTypes?: string[]; elementType: string; - hideErrorMessage: boolean; + hideErrorMessage?: boolean; allowMultiSelect?: boolean; }; diff --git a/src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx b/src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx index 3f0322b59..9330fee9c 100644 --- a/src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx +++ b/src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx @@ -6,10 +6,10 @@ */ import React, { forwardRef, Ref, useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react'; -import { alpha, Checkbox, styled, SxProps, Theme, useTheme } from '@mui/material'; +import { alpha, Checkbox, styled, SxProps, Theme } from '@mui/material'; import { SimpleTreeView, TreeItem, treeItemClasses } from '@mui/x-tree-view'; -const BorderedTreeItem = styled(TreeItem)(({ theme, root }: { theme: Theme; root: boolean }) => { +const BorderedTreeItem = styled(TreeItem)<{ root: boolean }>(({ theme, root }: { theme: Theme; root: boolean }) => { const border = `1px dashed ${alpha(theme.palette.text.primary, 0.4)}`; return { position: 'relative', @@ -65,8 +65,6 @@ function CheckboxTreeview( { data: items, checkAll, onSelectionChanged, getLabel, sx }: Readonly>, ref: Ref> ) { - const theme = useTheme(); - const initialItemStates = useMemo>( () => Object.fromEntries(items.map((elem) => [elem.id, checkAll ? CheckState.CHECKED : CheckState.UNCHECKED])), [items, checkAll] @@ -202,7 +200,6 @@ function CheckboxTreeview( return itemsToRender.map((elem) => ( ( )); }, - [itemsByParent, theme, handleExpand, itemStates, getLabel, handleItemSelect] + [itemsByParent, handleExpand, itemStates, getLabel, handleItemSelect] ); return {renderTree(null)}; diff --git a/src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx b/src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx index ad4d947b8..f64d62e5a 100644 --- a/src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx +++ b/src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx @@ -21,7 +21,7 @@ import { ExpertFilter, IdentifiableAttributes } from '../../../../components/com import { Curve as CurveType } from './common/curve.type'; import { type MuiStyles } from '../../../../utils/styles'; import { CustomAGGrid } from '../../../../components/composite/customAGGrid'; -import { isEmpty } from '../../../../utils/functions'; +import { IdName } from '../../../../utils'; const styles = { grid: { @@ -156,8 +156,8 @@ function CurveParameters({ // config fetchers based on the mapping and studyUuid const modelsFetcher = useCallback(() => { - const mapping = getValues(mappingPath); - return isEmpty(mapping) ? undefined : fetchDynamicSimulationModels(mapping); + const mapping = (getValues(mappingPath) as IdName[] | undefined)?.[0]; /* array of one element */ + return mapping?.id ? fetchDynamicSimulationModels(mapping) : undefined; }, [getValues, mappingPath]); return ( diff --git a/src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx b/src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx index 1d1757bbd..be6d754ec 100644 --- a/src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx +++ b/src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx @@ -9,7 +9,13 @@ import { FormattedMessage, useIntl } from 'react-intl'; import { useCallback, useEffect, useState } from 'react'; import { FieldErrors, FieldValues } from 'react-hook-form'; import { Grid } from '@mui/material'; -import { ElementType, mergeSx, snackWithFallback, VoltageLevelInfos } from '../../../utils'; +import { + ElementType, + mapDynamicSimulationParameters, + mergeSx, + snackWithFallback, + VoltageLevelInfos, +} from '../../../utils'; import { UseParametersBackendReturnProps } from '../../../utils/types/parameters.type'; import { ComputingType, CreateParameterDialog, LabelledButton } from '../common'; @@ -21,7 +27,7 @@ import { DirectoryItemSelector } from '../../../components/ui/directoryItemSelec import { PopupConfirmationDialog } from '../../../components/ui/dialogs'; import { toFormValues, - toParamsInfos, + toParamsEnriched, useDynamicSimulationParametersForm, } from './use-dynamic-simulation-parameters-form'; import { DynamicSimulationForm } from './dynamic-simulation-parameters-form'; @@ -83,7 +89,7 @@ export function DynamicSimulationInline({ const onSubmit = useCallback( (formData: FieldValues) => { // update params after convert form representation to dto representation - updateParameters(toParamsInfos(formData, getDefaultParams())); + updateParameters(toParamsEnriched(formData, getDefaultParams())); }, [updateParameters, getDefaultParams] ); @@ -142,7 +148,9 @@ export function DynamicSimulationInline({ open={openCreateParameterDialog} onClose={() => setOpenCreateParameterDialog(false)} parameterValues={getValues} - parameterFormatter={(formData) => toParamsInfos(formData, getDefaultParams())} + parameterFormatter={(formData) => + mapDynamicSimulationParameters(toParamsEnriched(formData, getDefaultParams())) + } parameterType={ElementType.DYNAMIC_SIMULATION_PARAMETERS} /> )} diff --git a/src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts b/src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts index fd55695a5..eef0d014d 100644 --- a/src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts +++ b/src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts @@ -6,11 +6,24 @@ */ import * as yup from 'yup'; import { MAPPING } from './mapping-parameters-constants'; +import { ID, NAME } from '../../common/parameter-table-field'; +import { YUP_REQUIRED } from '../../../../utils'; export const mappingFormSchema = yup.object().shape({ - [MAPPING]: yup.string().required(), + [MAPPING]: yup + .array() + .of( + yup + .object() + .shape({ + [ID]: yup.string().required(), + [NAME]: yup.string().required(), + }) + .required() + ) + .min(1, YUP_REQUIRED), }); export const mappingEmptyFormData = { - [MAPPING]: '', + [MAPPING]: [], }; diff --git a/src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx b/src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx index a2e18d181..7d1916a8b 100644 --- a/src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx +++ b/src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx @@ -5,60 +5,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Grid } from '@mui/material'; -import { useEffect, useMemo, useState } from 'react'; -import { ParameterType, SpecificParameterInfos } from '../../../../utils/types/parameters.type'; -import { MappingInfos } from '../../../../utils/types/dynamic-simulation.type'; -import ParameterField from '../../common/parameter-field'; import { MAPPING } from './mapping-parameters-constants'; -import { getDynamicMappings } from '../../../../services'; -import { snackWithFallback } from '../../../../utils'; -import { useSnackMessage } from '../../../../hooks'; +import { ElementType } from '../../../../utils'; +import { ParameterLineDirectoryItemsInput } from '../../common'; interface MappingParametersProps { path: string; } export function MappingParameters({ path }: Readonly) { - const { snackError } = useSnackMessage(); - const [mappings, setMappings] = useState([]); - - useEffect(() => { - getDynamicMappings() - .then((_mappings) => { - setMappings(_mappings); - }) - .catch((error: Error) => { - snackWithFallback(snackError, error, { - headerId: `DynamicSimulationMappingsError`, - }); - }); - }, [setMappings, snackError]); - - const mappingOptions = useMemo(() => { - return mappings?.map((elem) => elem.name) ?? []; - }, [mappings]); - - const params: SpecificParameterInfos[] = useMemo( - () => [ - { - name: MAPPING, - type: ParameterType.STRING, - label: 'DynamicSimulationMapping', - possibleValues: mappingOptions, - sx: { width: '100%' }, - }, - ], - [mappingOptions] - ); - return ( - {params.map((param: SpecificParameterInfos) => { - const { name, type, ...otherParams } = param; - return ( - - ); - })} + ); } diff --git a/src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts b/src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts index efe411050..3f470d286 100644 --- a/src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts +++ b/src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts @@ -7,7 +7,11 @@ import { FieldValues } from 'react-hook-form'; import * as yup from 'yup'; import { UseComputationParametersFormReturn } from '../common/utils'; -import { DynamicSimulationParametersInfos, SolverInfos } from '../../../utils/types/dynamic-simulation.type'; +import { + DynamicSimulationParametersEnriched, + DynamicSimulationParametersInfos, + SolverInfos, +} from '../../../utils/types/dynamic-simulation.type'; import { TabValues } from './dynamic-simulation.type'; import { PROVIDER } from '../common/constants'; import { timeDelayEmptyFormData, timeDelayFormSchema } from './time-delay/time-delay-parameters-utils'; @@ -40,7 +44,7 @@ const emptyFormData = { [TabValues.TAB_CURVE]: curveEmptyFormData, }; -export const toFormValues = (_params: DynamicSimulationParametersInfos): FieldValues => ({ +export const toFormValues = (_params: DynamicSimulationParametersEnriched): FieldValues => ({ [ID]: _params.id, // not show in form [PROVIDER]: _params.provider, [TabValues.TAB_TIME_DELAY]: { @@ -52,7 +56,9 @@ export const toFormValues = (_params: DynamicSimulationParametersInfos): FieldVa [Solver.SOLVERS]: _params.solvers, }, [TabValues.TAB_MAPPING]: { - [MAPPING]: _params.mapping, + [MAPPING]: _params.mapping + ? [_params.mapping] + : [] /* array of one element to be compatible with model rhf of DirectoryItemsInput */, }, [TabValues.TAB_NETWORK]: { ..._params.network, @@ -62,10 +68,10 @@ export const toFormValues = (_params: DynamicSimulationParametersInfos): FieldVa }, }); -export const toParamsInfos = ( +export const toParamsEnriched = ( _formData: FieldValues, - defaultParams: DynamicSimulationParametersInfos | null -): DynamicSimulationParametersInfos => ({ + defaultParams: DynamicSimulationParametersEnriched | null +): DynamicSimulationParametersEnriched => ({ provider: _formData[PROVIDER], startTime: _formData[TabValues.TAB_TIME_DELAY][TimeDelay.START_TIME], stopTime: _formData[TabValues.TAB_TIME_DELAY][TimeDelay.STOP_TIME], @@ -81,7 +87,7 @@ export const toParamsInfos = ( ], [] as SolverInfos[] ), - mapping: _formData[TabValues.TAB_MAPPING][MAPPING], + mapping: _formData[TabValues.TAB_MAPPING][MAPPING]?.[0] /* array of one element */, network: _formData[TabValues.TAB_NETWORK], curves: _formData[TabValues.TAB_CURVE][Curve.CURVES], }); diff --git a/src/services/dynamic-mapping.ts b/src/services/dynamic-mapping.ts index a151dc9da..7b97283a3 100644 --- a/src/services/dynamic-mapping.ts +++ b/src/services/dynamic-mapping.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { backendFetchJson } from './utils'; -import { DynamicSimulationModelInfos, MappingInfos } from '../utils'; +import { DynamicSimulationModelInfos, IdName } from '../utils'; const PREFIX_DYNAMIC_MAPPING_SERVER_QUERIES = `${import.meta.env.VITE_API_GATEWAY}/dynamic-mapping`; @@ -13,17 +13,10 @@ function getDynamicMappingUrl() { return `${PREFIX_DYNAMIC_MAPPING_SERVER_QUERIES}/`; } -export function getDynamicMappings(): Promise { - console.info(`Fetching dynamic mappings ...`); - const url = `${getDynamicMappingUrl()}mappings/`; - console.debug(url); - return backendFetchJson(url); -} - -export function fetchDynamicSimulationModels(mapping: string): Promise { - console.info(`Fetching dynamic simulation models on mapping '${mapping}' ...`); +export function fetchDynamicSimulationModels(mapping: IdName): Promise { + console.info(`Fetching dynamic simulation models on mapping '${mapping.name}' ...`); - const url = `${getDynamicMappingUrl()}mappings/${mapping}/models`; + const url = `${getDynamicMappingUrl()}mappings/${mapping.id}/models`; console.debug(url); return backendFetchJson(url); } diff --git a/src/translations/en/businessErrorsEn.ts b/src/translations/en/businessErrorsEn.ts index 5e6c9d7a6..29cdd15b1 100644 --- a/src/translations/en/businessErrorsEn.ts +++ b/src/translations/en/businessErrorsEn.ts @@ -66,7 +66,7 @@ export const businessErrorsEn = { 'securityAnalysis.contingencyListConfigEmpty': 'The configuration does not contain any contingency.', 'securityAnalysis.missingContingencyList': 'The configuration contains one or more contingency lists that have been deleted.', - 'dynamicMapping.mappingNameNotProvided': 'Mapping name not provided', + 'dynamicMapping.mappingNotProvided': 'Mapping not provided', 'dynamicSecurityAnalysis.providerNotFound': 'Dynamic security analysis provider not found.', 'dynamicSecurityAnalysis.contingenciesNotFound': 'No contingencies provided.', 'dynamicSecurityAnalysis.contingencyListEmpty': 'Contingency list parameter must not be null or empty.', diff --git a/src/translations/fr/businessErrorsFr.ts b/src/translations/fr/businessErrorsFr.ts index e80313686..2842dc42d 100644 --- a/src/translations/fr/businessErrorsFr.ts +++ b/src/translations/fr/businessErrorsFr.ts @@ -67,7 +67,7 @@ export const businessErrorsFr = { 'securityAnalysis.contingencyListConfigEmpty': 'La configuration ne contient aucun aléas.', 'securityAnalysis.missingContingencyList': "La configuration contient une ou des listes d'aléas qui ont été supprimées.", - 'dynamicMapping.mappingNameNotProvided': 'Nom du mapping non fourni', + 'dynamicMapping.mappingNotProvided': 'Mapping non fourni', 'dynamicSecurityAnalysis.providerNotFound': "Simulateur d'analyse de sécurité dynamique non trouvé.", 'dynamicSecurityAnalysis.contingenciesNotFound': 'Aucun aléa fourni.', 'dynamicSecurityAnalysis.contingencyListEmpty': "La liste d'aléas fournie ne doit pas être nulle ou vide.", diff --git a/src/utils/mapper/getFileIcon.tsx b/src/utils/mapper/getFileIcon.tsx index 445a3e381..86c9a267d 100644 --- a/src/utils/mapper/getFileIcon.tsx +++ b/src/utils/mapper/getFileIcon.tsx @@ -6,16 +6,17 @@ */ import { Article as ArticleIcon, + AutoGraphRounded as AutoGraphRoundedIcon, Calculate as CalculateIcon, + Dashboard as DashboardIcon, Hub as HubIcon, + MiscellaneousServicesRounded as MiscellaneousServicesRoundedIcon, NoteAlt as NoteAltIcon, OfflineBolt as OfflineBoltIcon, Photo as PhotoIcon, PhotoLibrary as PhotoLibraryIcon, Settings as SettingsIcon, TableView as TableViewIcon, - Dashboard as DashboardIcon, - MiscellaneousServicesRounded as MiscellaneousServicesRoundedIcon, } from '@mui/icons-material'; import { ElementType } from '../types/elementType'; import type { SxStyle } from '../styles'; @@ -50,6 +51,8 @@ export function getFileIcon(type: ElementType, style: SxStyle) { return ; case ElementType.PROCESS_CONFIG: return ; + case ElementType.DYNAMIC_MAPPING: + return ; case ElementType.DIRECTORY: // to easily use in TreeView we do not give icons for directories return undefined; diff --git a/src/utils/types/dynamic-margin-calculation.type.ts b/src/utils/types/dynamic-margin-calculation.type.ts index 1786554dd..e3d99f15e 100644 --- a/src/utils/types/dynamic-margin-calculation.type.ts +++ b/src/utils/types/dynamic-margin-calculation.type.ts @@ -6,6 +6,7 @@ */ import type { UUID } from 'node:crypto'; +import { IdName } from './types'; export enum CalculationType { GLOBAL_MARGIN = 'GLOBAL_MARGIN', @@ -17,11 +18,9 @@ export enum LoadModelsRule { TARGETED_LOADS = 'TARGETED_LOADS', } -export type IdNameInfos = { id: UUID; name?: string }; - export type LoadsVariationInfos = { id?: UUID; // persisted id of the info to be modified - loadFilters?: IdNameInfos[]; + loadFilters?: IdName[]; variation: number; active: boolean; }; diff --git a/src/utils/types/dynamic-simulation.type.ts b/src/utils/types/dynamic-simulation.type.ts index db3b9ddb0..f8ea2ab10 100644 --- a/src/utils/types/dynamic-simulation.type.ts +++ b/src/utils/types/dynamic-simulation.type.ts @@ -6,6 +6,7 @@ */ import type { UUID } from 'node:crypto'; import { EquipmentType } from './equipmentType'; +import { IdName } from './types'; export enum SolverType { IDA = 'IDA', @@ -83,22 +84,33 @@ type CurveInfos = { export type SolverInfos = IdaSolverInfos | SimSolverInfos; -export type MappingInfos = { - name: string; -}; - export type DynamicSimulationParametersInfos = { id?: UUID; provider?: string; startTime?: number; stopTime?: number; - mapping?: string; + mappingId?: UUID; solver: SolverType; solvers?: SolverInfos[]; network?: NetworkInfos; curves?: CurveInfos[] | null; }; +export type DynamicSimulationParametersEnriched = Omit & { + mapping?: IdName; +}; + +export function mapDynamicSimulationParameters( + parameters: DynamicSimulationParametersEnriched +): DynamicSimulationParametersInfos { + const { mapping, ...rest } = parameters; + const newParameters = { + ...rest, + mappingId: parameters.mapping?.id, + }; + return newParameters; +} + // --- Types related to model/variables --- // export type ModelVariableDefinitionInfos = { diff --git a/src/utils/types/elementType.ts b/src/utils/types/elementType.ts index c66ee9bd1..0afd4374e 100644 --- a/src/utils/types/elementType.ts +++ b/src/utils/types/elementType.ts @@ -15,7 +15,6 @@ export enum ElementType { FILTER = 'FILTER', MODIFICATION = 'MODIFICATION', CONTINGENCY_LIST = 'CONTINGENCY_LIST', - DYNAMIC_SIMULATION_MAPPING = 'DYNAMIC_SIMULATION_MAPPING', VOLTAGE_INIT_PARAMETERS = 'VOLTAGE_INIT_PARAMETERS', SECURITY_ANALYSIS_PARAMETERS = 'SECURITY_ANALYSIS_PARAMETERS', PCC_MIN_PARAMETERS = 'PCC_MIN_PARAMETERS', @@ -31,4 +30,5 @@ export enum ElementType { DIAGRAM_CONFIG = 'DIAGRAM_CONFIG', WORKSPACE = 'WORKSPACE', PROCESS_CONFIG = 'PROCESS_CONFIG', + DYNAMIC_MAPPING = 'DYNAMIC_MAPPING', } diff --git a/src/utils/types/parameters.type.ts b/src/utils/types/parameters.type.ts index cafe6d971..6886dbc61 100644 --- a/src/utils/types/parameters.type.ts +++ b/src/utils/types/parameters.type.ts @@ -10,7 +10,7 @@ import { ComputingType } from '../../features/parameters/common/computing-type'; import { LoadFlowParametersInfos } from './loadflow.type'; import { DynamicSecurityAnalysisParametersFetchReturn } from './dynamic-security-analysis.type'; import type { ILimitReductionsByVoltageLevel } from '../../features/parameters/common/limitreductions/columns-definitions'; -import { DynamicSimulationParametersInfos } from './dynamic-simulation.type'; +import { DynamicSimulationParametersEnriched } from './dynamic-simulation.type'; import { SensitivityAnalysisParametersInfosEnriched } from './sensitivity-analysis.type'; import { type ShortCircuitParametersInfos } from '../../features/parameters/short-circuit/short-circuit-parameters.type'; import { SAParametersEnriched } from './security-analysis.type'; @@ -47,7 +47,7 @@ export type ParametersInfos = T extends ComputingType.S : T extends ComputingType.LOAD_FLOW ? LoadFlowParametersInfos : T extends ComputingType.DYNAMIC_SIMULATION - ? DynamicSimulationParametersInfos + ? DynamicSimulationParametersEnriched : T extends ComputingType.DYNAMIC_SECURITY_ANALYSIS ? DynamicSecurityAnalysisParametersFetchReturn : T extends ComputingType.DYNAMIC_MARGIN_CALCULATION