From 59823d49479a1cc4094bc0ec6ca32d49db7cd94c Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 31 Oct 2024 14:08:42 +0100 Subject: [PATCH 01/24] Transformer loadflow service to TS. Signed-off-by: AAJELLAL --- .../study/{loadflow.js => loadflow.ts} | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) rename src/services/study/{loadflow.js => loadflow.ts} (79%) diff --git a/src/services/study/loadflow.js b/src/services/study/loadflow.ts similarity index 79% rename from src/services/study/loadflow.js rename to src/services/study/loadflow.ts index a86c1c092f..9d78050c2a 100644 --- a/src/services/study/loadflow.js +++ b/src/services/study/loadflow.ts @@ -7,6 +7,16 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; +import { FilterSelectorType } from 'components/custom-aggrid/custom-aggrid-header.type'; +import { SortConfigType } from 'hooks/use-aggrid-sort'; +import { GlobalFilter } from '../../components/results/loadflow/load-flow-result-tab'; + +interface QueryParams { + sort?: SortConfigType[]; + filters?: FilterSelectorType[]; + globalFilters?: GlobalFilter | undefined; +} export function getDefaultLoadFlowProvider() { console.info('get default load flow provier'); @@ -15,7 +25,7 @@ export function getDefaultLoadFlowProvider() { return backendFetchText(getDefaultLoadFlowProviderUrl); } -export function setLoadFlowParameters(studyUuid, newParams) { +export function setLoadFlowParameters(studyUuid: UUID, newParams: any) { console.info('set load flow parameters'); const setLoadFlowParametersUrl = getStudyUrl(studyUuid) + '/loadflow/parameters'; console.debug(setLoadFlowParametersUrl); @@ -29,14 +39,14 @@ export function setLoadFlowParameters(studyUuid, newParams) { }); } -export function getLoadFlowParameters(studyUuid) { +export function getLoadFlowParameters(studyUuid: UUID) { console.info('get load flow parameters'); const getLfParams = getStudyUrl(studyUuid) + '/loadflow/parameters'; console.debug(getLfParams); return backendFetchJson(getLfParams); } -export function setLoadFlowProvider(studyUuid, newProvider) { +export function setLoadFlowProvider(studyUuid: UUID, newProvider: string) { console.info('set load flow provider'); const setLoadFlowProviderUrl = getStudyUrl(studyUuid) + '/loadflow/provider'; console.debug(setLoadFlowProviderUrl); @@ -50,7 +60,7 @@ export function setLoadFlowProvider(studyUuid, newProvider) { }); } -export function startLoadFlow(studyUuid, currentNodeUuid, limitReduction) { +export function startLoadFlow(studyUuid: UUID, currentNodeUuid: UUID, limitReduction: number) { console.info( 'Running loadflow on ' + studyUuid + ' and node ' + currentNodeUuid + ' with limit reduction ' + limitReduction ); @@ -62,21 +72,21 @@ export function startLoadFlow(studyUuid, currentNodeUuid, limitReduction) { return backendFetch(startLoadFlowUrl, { method: 'put' }); } -export function stopLoadFlow(studyUuid, currentNodeUuid) { +export function stopLoadFlow(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping loadFlow on '${studyUuid}' and node '${currentNodeUuid}' ...`); const stopLoadFlowUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/loadflow/stop'; console.debug(stopLoadFlowUrl); return backendFetch(stopLoadFlowUrl, { method: 'put' }); } -export function fetchLoadFlowStatus(studyUuid, currentNodeUuid) { +export function fetchLoadFlowStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching loadFlow status on '${studyUuid}' and node '${currentNodeUuid}' ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/loadflow/status'; console.debug(url); return backendFetchText(url); } -export function fetchLoadFlowResult(studyUuid, currentNodeUuid, queryParams) { +export function fetchLoadFlowResult(studyUuid: UUID, currentNodeUuid: UUID, queryParams: QueryParams) { console.info(`Fetching loadflow result on '${studyUuid}' and node '${currentNodeUuid}' ...`); const { sort, filters } = queryParams || {}; const params = new URLSearchParams({}); @@ -92,7 +102,7 @@ export function fetchLoadFlowResult(studyUuid, currentNodeUuid, queryParams) { return backendFetchJson(urlWithParams); } -export function fetchLimitViolations(studyUuid, currentNodeUuid, queryParams) { +export function fetchLimitViolations(studyUuid: UUID, currentNodeUuid: UUID, queryParams: QueryParams) { console.info(`Fetching limit violations ...`); const { sort, filters, globalFilters } = queryParams || {}; const params = new URLSearchParams({}); @@ -113,7 +123,7 @@ export function fetchLimitViolations(studyUuid, currentNodeUuid, queryParams) { return backendFetchJson(urlWithParams); } -export function invalidateLoadFlowStatus(studyUuid) { +export function invalidateLoadFlowStatus(studyUuid: UUID) { console.info('invalidate loadflow status'); const invalidateLoadFlowStatusUrl = getStudyUrl(studyUuid) + '/loadflow/invalidate-status'; console.debug(invalidateLoadFlowStatusUrl); From 1a86b8b68f67ae8824ed19981dd7ca8aa15ab077 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 31 Oct 2024 14:27:56 +0100 Subject: [PATCH 02/24] Transformer geo-data service to TS. Signed-off-by: AAJELLAL --- src/components/network/network-map-tab.jsx | 1 + src/services/study/{geo-data.js => geo-data.ts} | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) rename src/services/study/{geo-data.js => geo-data.ts} (85%) diff --git a/src/components/network/network-map-tab.jsx b/src/components/network/network-map-tab.jsx index b20e59ce3a..9cda9ef6ea 100644 --- a/src/components/network/network-map-tab.jsx +++ b/src/components/network/network-map-tab.jsx @@ -434,6 +434,7 @@ export const NetworkMapTab = ({ `Loading geo data of study '${studyUuid}' of missing substations '${notFoundSubstationIds}' and missing lines '${notFoundLineIds}'...` ); dispatch(setMapDataLoading(true)); + console.log(' notFoundSubstationIds: ', notFoundSubstationIds); const missingSubstationPositions = getMissingEquipmentsPositions( notFoundSubstationIds, fetchSubstationPositions diff --git a/src/services/study/geo-data.js b/src/services/study/geo-data.ts similarity index 85% rename from src/services/study/geo-data.js rename to src/services/study/geo-data.ts index a960fae9e3..b1cf84a8a5 100644 --- a/src/services/study/geo-data.js +++ b/src/services/study/geo-data.ts @@ -7,8 +7,9 @@ import { backendFetchJson, getQueryParamsList } from '../utils'; import { getStudyUrlWithNodeUuid } from './index'; +import { UUID } from 'crypto'; -export function fetchSubstationPositions(studyUuid, currentNodeUuid, substationsIds) { +export function fetchSubstationPositions(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[]) { console.info( `Fetching substation positions of study '${studyUuid}' and node '${currentNodeUuid}' with ids '${substationsIds}'...` ); @@ -22,7 +23,7 @@ export function fetchSubstationPositions(studyUuid, currentNodeUuid, substations return backendFetchJson(fetchSubstationPositionsUrl); } -export function fetchLinePositions(studyUuid, currentNodeUuid, linesIds) { +export function fetchLinePositions(studyUuid: UUID, currentNodeUuid: UUID, linesIds: string[]) { console.info( `Fetching line positions of study '${studyUuid}' and node '${currentNodeUuid}' with ids '${linesIds}'...` ); From 7a8e17c125fc861a30c96f84acc252abf79a3bbd Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 31 Oct 2024 14:52:25 +0100 Subject: [PATCH 03/24] Transformer non-evacuated-energy service to TS. Signed-off-by: AAJELLAL --- ...cuated-energy.js => non-evacuated-energy.ts} | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) rename src/services/study/{non-evacuated-energy.js => non-evacuated-energy.ts} (81%) diff --git a/src/services/study/non-evacuated-energy.js b/src/services/study/non-evacuated-energy.ts similarity index 81% rename from src/services/study/non-evacuated-energy.js rename to src/services/study/non-evacuated-energy.ts index 93d396c3fd..3fe95773d1 100644 --- a/src/services/study/non-evacuated-energy.js +++ b/src/services/study/non-evacuated-energy.ts @@ -7,8 +7,9 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; -export function startNonEvacuatedEnergy(studyUuid, currentNodeUuid) { +export function startNonEvacuatedEnergy(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Running non evacuated energy analysis on ${studyUuid} and node ${currentNodeUuid} ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/non-evacuated-energy/run'; @@ -16,21 +17,21 @@ export function startNonEvacuatedEnergy(studyUuid, currentNodeUuid) { return backendFetch(url, { method: 'post' }); } -export function stopNonEvacuatedEnergy(studyUuid, currentNodeUuid) { +export function stopNonEvacuatedEnergy(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping non evacuated energy analysis on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/non-evacuated-energy/stop`; console.debug(url); return backendFetch(url, { method: 'put' }); } -export function fetchNonEvacuatedEnergyStatus(studyUuid, currentNodeUuid) { +export function fetchNonEvacuatedEnergyStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching non evacuated energy analysis status on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/non-evacuated-energy/status`; console.debug(url); return backendFetchText(url); } -export function fetchNonEvacuatedEnergyResult(studyUuid, currentNodeUuid) { +export function fetchNonEvacuatedEnergyResult(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching non evacuated energy analysis result on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/non-evacuated-energy/result`; @@ -38,14 +39,14 @@ export function fetchNonEvacuatedEnergyResult(studyUuid, currentNodeUuid) { return backendFetchJson(url); } -export function getNonEvacuatedEnergyParameters(studyUuid) { +export function getNonEvacuatedEnergyParameters(studyUuid: UUID) { console.info('get non evacuated energy analysis parameters'); const url = getStudyUrl(studyUuid) + '/non-evacuated-energy/parameters'; console.debug(url); return backendFetchJson(url); } -export function setNonEvacuatedEnergyParameters(studyUuid, newParams) { +export function setNonEvacuatedEnergyParameters(studyUuid: UUID, newParams: any) { console.info('set non evacuated energy analysis parameters'); const url = getStudyUrl(studyUuid) + '/non-evacuated-energy/parameters'; console.debug(url); @@ -59,7 +60,7 @@ export function setNonEvacuatedEnergyParameters(studyUuid, newParams) { }); } -export function fetchNonEvacuatedEnergyProvider(studyUuid) { +export function fetchNonEvacuatedEnergyProvider(studyUuid: UUID) { console.info('fetch non evacuated energy provider'); const url = `${getStudyUrl(studyUuid)}/non-evacuated-energy/provider`; console.debug(url); @@ -73,7 +74,7 @@ export function fetchDefaultNonEvacuatedEnergyProvider() { return backendFetchText(url); } -export function updateNonEvacuatedEnergyProvider(studyUuid, newProvider) { +export function updateNonEvacuatedEnergyProvider(studyUuid: UUID, newProvider: string) { console.info('update non evacuated energy provider'); const url = `${getStudyUrl(studyUuid)}/non-evacuated-energy/provider`; console.debug(url); From c7eac6dfc9e1f5f3c489cc41c148c2637e943a1d Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Mon, 4 Nov 2024 11:25:17 +0100 Subject: [PATCH 04/24] Transformer SA service to TS. Signed-off-by: AAJELLAL --- .../security-analysis-parameters.tsx | 2 +- ...urity-analysis.js => security-analysis.ts} | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) rename src/services/study/{security-analysis.js => security-analysis.ts} (77%) diff --git a/src/components/dialogs/parameters/security-analysis/security-analysis-parameters.tsx b/src/components/dialogs/parameters/security-analysis/security-analysis-parameters.tsx index 055678e856..eceae984aa 100644 --- a/src/components/dialogs/parameters/security-analysis/security-analysis-parameters.tsx +++ b/src/components/dialogs/parameters/security-analysis/security-analysis-parameters.tsx @@ -27,7 +27,7 @@ import { SubmitButton, useSnackMessage, } from '@gridsuite/commons-ui'; -import { fetchSecurityAnalysisParameters } from '../../../../services/security-analysis.js'; +import { fetchSecurityAnalysisParameters } from '../../../../services/security-analysis'; import SecurityAnalysisParametersSelector from './security-analysis-parameters-selector'; import CreateParameterDialog from '../common/parameters-creation-dialog'; import { useForm } from 'react-hook-form'; diff --git a/src/services/study/security-analysis.js b/src/services/study/security-analysis.ts similarity index 77% rename from src/services/study/security-analysis.js rename to src/services/study/security-analysis.ts index b368a2fc98..79920f529d 100644 --- a/src/services/study/security-analysis.js +++ b/src/services/study/security-analysis.ts @@ -7,8 +7,11 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils'; +import { UUID } from 'crypto'; +import { ISAParameters } from '../../components/dialogs/parameters/common/limitreductions/columns-definitions'; +import { RESULT_TYPE } from '../../components/results/securityanalysis/security-analysis-result-utils'; -export function startSecurityAnalysis(studyUuid, currentNodeUuid, contingencyListNames) { +export function startSecurityAnalysis(studyUuid: UUID, currentNodeUuid: UUID, contingencyListNames: string[]) { console.info(`Running security analysis on ${studyUuid} and node ${currentNodeUuid} ...`); // Add params to Url @@ -21,14 +24,15 @@ export function startSecurityAnalysis(studyUuid, currentNodeUuid, contingencyLis return backendFetch(url, { method: 'post' }); } -export function stopSecurityAnalysis(studyUuid, currentNodeUuid) { +export function stopSecurityAnalysis(studyUuid: UUID, currentNodeUuid: UUID) { console.info('Stopping security analysis on ' + studyUuid + ' and node ' + currentNodeUuid + ' ...'); const stopSecurityAnalysisUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/security-analysis/stop'; console.debug(stopSecurityAnalysisUrl); return backendFetch(stopSecurityAnalysisUrl, { method: 'put' }); } -export function fetchSecurityAnalysisResult(studyUuid, currentNodeUuid, queryParams) { +//TODO: any to be changed +export function fetchSecurityAnalysisResult(studyUuid: string, currentNodeUuid: string, queryParams: any) { console.info(`Fetching security analysis on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/security-analysis/result`; @@ -36,13 +40,15 @@ export function fetchSecurityAnalysisResult(studyUuid, currentNodeUuid, queryPar const params = new URLSearchParams({ resultType }); - sort?.map((value) => params.append('sort', `${value.colId},${value.sort}`)); + sort?.map((value: any) => params.append('sort', `${value.colId},${value.sort}`)); if (filters?.length) { params.append('filters', JSON.stringify(filters)); } if (typeof page === 'number') { + // @ts-ignore + //TODO: change this params.append('page', page); params.append('size', size); } @@ -53,11 +59,11 @@ export function fetchSecurityAnalysisResult(studyUuid, currentNodeUuid, queryPar } export function downloadSecurityAnalysisResultZippedCsv( - studyUuid, - currentNodeUuid, - queryParams, - headers, - enumValueTranslations + studyUuid: UUID, + currentNodeUuid: UUID, + queryParams: { resultType: RESULT_TYPE }, + headers: string[] | undefined, + enumValueTranslations: Record ) { console.info(`Fetching security analysis zipped csv on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/security-analysis/result/csv`; @@ -81,7 +87,7 @@ export function downloadSecurityAnalysisResultZippedCsv( }); } -export function fetchSecurityAnalysisStatus(studyUuid, currentNodeUuid) { +export function fetchSecurityAnalysisStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching security analysis status on ${studyUuid} and node ${currentNodeUuid} ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/security-analysis/status'; @@ -89,7 +95,7 @@ export function fetchSecurityAnalysisStatus(studyUuid, currentNodeUuid) { return backendFetchText(url); } -export function updateSecurityAnalysisProvider(studyUuid, newProvider) { +export function updateSecurityAnalysisProvider(studyUuid: UUID, newProvider: string) { console.info('update security analysis provider'); const url = getStudyUrl(studyUuid) + '/security-analysis/provider'; console.debug(url); @@ -110,14 +116,14 @@ export function fetchDefaultSecurityAnalysisProvider() { return backendFetchText(url); } -export function getSecurityAnalysisParameters(studyUuid) { +export function getSecurityAnalysisParameters(studyUuid: UUID) { console.info('get security analysis parameters'); const url = getStudyUrl(studyUuid) + '/security-analysis/parameters'; console.debug(url); return backendFetchJson(url); } -export function setSecurityAnalysisParameters(studyUuid, newParams) { +export function setSecurityAnalysisParameters(studyUuid: UUID, newParams: ISAParameters) { console.info('set security analysis parameters'); const url = getStudyUrl(studyUuid) + '/security-analysis/parameters'; console.debug(url); From a20e0b882e55bacaf004f535917f7a1371077357 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Mon, 4 Nov 2024 17:06:50 +0100 Subject: [PATCH 05/24] Transformer Sensi service to TS. Signed-off-by: AAJELLAL --- .../dialogs/parameters/sensi/utils.ts | 12 +-- ...ty-analysis.js => sensitivity-analysis.ts} | 77 ++++++++++++++++--- 2 files changed, 73 insertions(+), 16 deletions(-) rename src/services/study/{sensitivity-analysis.js => sensitivity-analysis.ts} (66%) diff --git a/src/components/dialogs/parameters/sensi/utils.ts b/src/components/dialogs/parameters/sensi/utils.ts index 75865230e7..c21c3674b5 100644 --- a/src/components/dialogs/parameters/sensi/utils.ts +++ b/src/components/dialogs/parameters/sensi/utils.ts @@ -28,7 +28,7 @@ import { } from '../../../utils/field-constants'; import yup from '../../../utils/yup-config'; -interface INewParamsPst { +export interface INewParamsPst { sensitivityPST: Array<{ [MONITORED_BRANCHES]: Array<{ [ID]: string; @@ -47,7 +47,7 @@ interface INewParamsPst { }>; } -interface INewParamsNodes { +export interface INewParamsNodes { sensitivityNodes: Array<{ [SUPERVISED_VOLTAGE_LEVELS]: Array<{ [ID]: string; @@ -65,7 +65,7 @@ interface INewParamsNodes { }>; } -interface INewParamsHvdc { +export interface INewParamsHvdc { sensitivityHVDC: Array<{ [MONITORED_BRANCHES]: Array<{ [ID]: string; @@ -84,7 +84,7 @@ interface INewParamsHvdc { }>; } -interface INewParamsInjections { +export interface INewParamsInjections { sensitivityInjection: Array<{ [MONITORED_BRANCHES]: Array<{ [ID]: string; @@ -288,7 +288,7 @@ export const getSensiInjectionsSetFormSchema = () => ({ ), }); -interface INewParamsInjectionsSet { +export interface INewParamsInjectionsSet { sensitivityInjectionsSet: Array<{ [MONITORED_BRANCHES]: Array<{ [ID]: string; @@ -307,7 +307,7 @@ interface INewParamsInjectionsSet { }>; } -interface IRowNewParams { +export interface IRowNewParams { [MONITORED_BRANCHES]: Array<{ [ID]: string; [NAME]: string; diff --git a/src/services/study/sensitivity-analysis.js b/src/services/study/sensitivity-analysis.ts similarity index 66% rename from src/services/study/sensitivity-analysis.js rename to src/services/study/sensitivity-analysis.ts index c31d5132c3..18cc3ed6e1 100644 --- a/src/services/study/sensitivity-analysis.js +++ b/src/services/study/sensitivity-analysis.ts @@ -7,10 +7,55 @@ import { PREFIX_STUDY_QUERIES, getStudyUrl, getStudyUrlWithNodeUuid } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; +import { + INewParamsHvdc, + INewParamsInjections, + INewParamsInjectionsSet, + INewParamsNodes, + INewParamsPst, +} from '../../components/dialogs/parameters/sensi/utils'; +import { + ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, + FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, + FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, + PROVIDER, +} from '../../components/utils/field-constants'; const GET_PARAMETERS_PREFIX = import.meta.env.VITE_API_GATEWAY + '/sensitivity-analysis/v1/parameters'; -export function startSensitivityAnalysis(studyUuid, currentNodeUuid) { +interface SelectorFilterOptions { + tabSelection: string; + functionType: string; +} + +interface SensitivityAnalysisParameters + extends INewParamsInjectionsSet, + INewParamsInjections, + INewParamsHvdc, + INewParamsPst, + INewParamsNodes { + [PROVIDER]: string; + [FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: number; + [ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: number; + [FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD]: number; +} + +interface SensitivityAnalysisFactorsCountParameters { + injections: string[] | undefined; + monitoredBranches: string[] | undefined; + contingencies: string[] | undefined; + hvdcs: string[] | undefined; + psts: string[] | undefined; +} + +interface CsvConfig { + csvHeaders: string[]; + resultTab: string; + sensitivityFunctionType: string; +} + +export function startSensitivityAnalysis(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Running sensi on ${studyUuid} and node ${currentNodeUuid} ...`); const startSensiAnalysisUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/sensitivity-analysis/run'; @@ -18,7 +63,7 @@ export function startSensitivityAnalysis(studyUuid, currentNodeUuid) { return backendFetch(startSensiAnalysisUrl, { method: 'post' }); } -export function stopSensitivityAnalysis(studyUuid, currentNodeUuid) { +export function stopSensitivityAnalysis(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping sensitivity analysis on ${studyUuid} and node ${currentNodeUuid} ...`); const stopSensitivityAnalysisUrl = `${getStudyUrlWithNodeUuid( studyUuid, @@ -28,14 +73,14 @@ export function stopSensitivityAnalysis(studyUuid, currentNodeUuid) { return backendFetch(stopSensitivityAnalysisUrl, { method: 'put' }); } -export function fetchSensitivityAnalysisStatus(studyUuid, currentNodeUuid) { +export function fetchSensitivityAnalysisStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching sensitivity analysis status on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/sensitivity-analysis/status`; console.debug(url); return backendFetchText(url); } -export function fetchSensitivityAnalysisResult(studyUuid, currentNodeUuid, selector) { +export function fetchSensitivityAnalysisResult(studyUuid: UUID, currentNodeUuid: UUID, selector: any) { console.info(`Fetching sensitivity analysis on ${studyUuid} and node ${currentNodeUuid} ...`); // Add params to Url @@ -48,7 +93,11 @@ export function fetchSensitivityAnalysisResult(studyUuid, currentNodeUuid, selec return backendFetchJson(url); } -export function fetchSensitivityAnalysisFilterOptions(studyUuid, currentNodeUuid, selector) { +export function fetchSensitivityAnalysisFilterOptions( + studyUuid: UUID, + currentNodeUuid: UUID, + selector: SelectorFilterOptions +) { console.info(`Fetching sensitivity analysis filter options on ${studyUuid} and node ${currentNodeUuid} ...`); // Add params to Url @@ -71,21 +120,21 @@ export function fetchDefaultSensitivityAnalysisProvider() { return backendFetchText(url); } -export function getSensitivityAnalysisParameters(studyUuid) { +export function getSensitivityAnalysisParameters(studyUuid: UUID) { console.info('get sensitivity analysis parameters'); const url = getStudyUrl(studyUuid) + '/sensitivity-analysis/parameters'; console.debug(url); return backendFetchJson(url); } -export function fetchSensitivityAnalysisParameters(parameterUuid) { +export function fetchSensitivityAnalysisParameters(parameterUuid: UUID) { console.info('get sensitivity analysis parameters'); const url = `${GET_PARAMETERS_PREFIX}/${parameterUuid}`; console.debug(url); return backendFetchJson(url); } -export function setSensitivityAnalysisParameters(studyUuid, newParams) { +export function setSensitivityAnalysisParameters(studyUuid: UUID, newParams: SensitivityAnalysisParameters | null) { console.info('set sensitivity analysis parameters'); const url = getStudyUrl(studyUuid) + '/sensitivity-analysis/parameters'; console.debug(url); @@ -99,13 +148,21 @@ export function setSensitivityAnalysisParameters(studyUuid, newParams) { }); } -export function getSensitivityAnalysisFactorsCount(studyUuid, currentNodeUuid, isInjectionsSet, newParams) { +export function getSensitivityAnalysisFactorsCount( + studyUuid: UUID, + currentNodeUuid: UUID, + isInjectionsSet: boolean, + newParams: SensitivityAnalysisFactorsCountParameters +) { console.info('get sensitivity analysis parameters computing count'); const urlSearchParams = new URLSearchParams(); const jsoned = JSON.stringify(isInjectionsSet); urlSearchParams.append('isInjectionsSet', jsoned); Object.keys(newParams) + // @ts-ignore + //TODO: check this later .filter((key) => newParams[key]) + // @ts-ignore .forEach((key) => urlSearchParams.append(`ids[${key}]`, newParams[key])); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)} @@ -116,7 +173,7 @@ export function getSensitivityAnalysisFactorsCount(studyUuid, currentNodeUuid, i }); } -export function exportSensitivityResultsAsCsv(studyUuid, currentNodeUuid, csvConfig) { +export function exportSensitivityResultsAsCsv(studyUuid: UUID, currentNodeUuid: UUID, csvConfig: CsvConfig) { console.info(`Exporting sensitivity analysis on ${studyUuid} and node ${currentNodeUuid} as CSV ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/sensitivity-analysis/result/csv`; From 624a7738b755b4ea6c3c87f0e8862f833c2a55aa Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 5 Nov 2024 14:16:03 +0100 Subject: [PATCH 06/24] Transformer shortCircuit, voltage init,Sensi, SA and notification services to TS. Signed-off-by: AAJELLAL --- ...notification.js => config-notification.ts} | 0 ...ification.js => directory-notification.ts} | 3 +- src/services/{directory.js => directory.ts} | 3 +- src/services/{loadflow.js => loadflow.ts} | 3 +- ...odification.js => network-modification.ts} | 3 +- ...urity-analysis.js => security-analysis.ts} | 3 +- ...ty-analysis.js => sensitivity-analysis.ts} | 0 ...-analysis.js => short-circuit-analysis.ts} | 86 ++++++++++++++----- ...tate-estimation.js => state-estimation.ts} | 9 +- .../{voltage-init.js => voltage-init.ts} | 18 ++-- 10 files changed, 91 insertions(+), 37 deletions(-) rename src/services/{config-notification.js => config-notification.ts} (100%) rename src/services/{directory-notification.js => directory-notification.ts} (97%) rename src/services/{directory.js => directory.ts} (88%) rename src/services/{loadflow.js => loadflow.ts} (93%) rename src/services/{network-modification.js => network-modification.ts} (90%) rename src/services/{security-analysis.js => security-analysis.ts} (90%) rename src/services/{sensitivity-analysis.js => sensitivity-analysis.ts} (100%) rename src/services/study/{short-circuit-analysis.js => short-circuit-analysis.ts} (68%) rename src/services/study/{state-estimation.js => state-estimation.ts} (80%) rename src/services/study/{voltage-init.js => voltage-init.ts} (78%) diff --git a/src/services/config-notification.js b/src/services/config-notification.ts similarity index 100% rename from src/services/config-notification.js rename to src/services/config-notification.ts diff --git a/src/services/directory-notification.js b/src/services/directory-notification.ts similarity index 97% rename from src/services/directory-notification.js rename to src/services/directory-notification.ts index 098b7b7733..d70f4fe380 100644 --- a/src/services/directory-notification.js +++ b/src/services/directory-notification.ts @@ -8,10 +8,11 @@ import ReconnectingWebSocket from 'reconnecting-websocket'; import { getUrlWithToken, getWsBase } from './utils'; import { getUserToken } from '../redux/user-store'; +import { UUID } from 'crypto'; const PREFIX_DIRECTORY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/directory-notification'; -export function connectDeletedStudyNotificationsWebsocket(studyUuid) { +export function connectDeletedStudyNotificationsWebsocket(studyUuid: UUID) { // The websocket API doesn't allow relative urls const wsBase = getWsBase(); // Add params to Url diff --git a/src/services/directory.js b/src/services/directory.ts similarity index 88% rename from src/services/directory.js rename to src/services/directory.ts index 30180382bd..21f9ae7ba4 100644 --- a/src/services/directory.js +++ b/src/services/directory.ts @@ -6,10 +6,11 @@ */ import { backendFetchJson, getRequestParamFromList } from './utils'; +import { UnknownArray } from 'type-fest'; const PREFIX_DIRECTORY_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/directory'; -export function fetchContingencyAndFiltersLists(listIds) { +export function fetchContingencyAndFiltersLists(listIds: UnknownArray) { console.info('Fetching contingency and filters lists'); // Add params to Url diff --git a/src/services/loadflow.js b/src/services/loadflow.ts similarity index 93% rename from src/services/loadflow.js rename to src/services/loadflow.ts index 6f95412498..a32825aefc 100644 --- a/src/services/loadflow.js +++ b/src/services/loadflow.ts @@ -6,6 +6,7 @@ */ import { backendFetchJson } from './utils'; +import { UUID } from 'crypto'; const PREFIX_LOADFLOW_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/loadflow'; @@ -27,7 +28,7 @@ export function getLoadFlowSpecificParametersDescription() { return backendFetchJson(getLoadFlowSpecificParametersUrl); } -export function fetchLoadFlowParameters(parameterUuid) { +export function fetchLoadFlowParameters(parameterUuid: UUID) { console.info('fetch load flow parameters'); const url = getLoadFlowUrl() + 'parameters/' + encodeURIComponent(parameterUuid); console.debug(url); diff --git a/src/services/network-modification.js b/src/services/network-modification.ts similarity index 90% rename from src/services/network-modification.js rename to src/services/network-modification.ts index bd43fa9f70..1dbe8281ca 100644 --- a/src/services/network-modification.js +++ b/src/services/network-modification.ts @@ -6,10 +6,11 @@ */ import { backendFetch, backendFetchJson } from './utils'; +import { UUID } from 'crypto'; const PREFIX_NETWORK_MODIFICATION_QUERIES = import.meta.env.VITE_API_GATEWAY + '/network-modification'; -export function fetchNetworkModification(modificationUuid) { +export function fetchNetworkModification(modificationUuid: UUID) { const modificationFetchUrl = `${PREFIX_NETWORK_MODIFICATION_QUERIES}/v1/network-modifications/${encodeURIComponent( modificationUuid )}`; diff --git a/src/services/security-analysis.js b/src/services/security-analysis.ts similarity index 90% rename from src/services/security-analysis.js rename to src/services/security-analysis.ts index c19f24d9b2..e163f785f4 100644 --- a/src/services/security-analysis.js +++ b/src/services/security-analysis.ts @@ -6,6 +6,7 @@ */ import { backendFetchJson } from './utils'; +import { UUID } from 'crypto'; const PREFIX_SECURITY_ANALYSIS_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/security-analysis'; @@ -20,7 +21,7 @@ export function fetchSecurityAnalysisProviders() { return backendFetchJson(url); } -export function fetchSecurityAnalysisParameters(parameterUuid) { +export function fetchSecurityAnalysisParameters(parameterUuid: UUID) { console.info('fetch security analysis parameters'); const url = getSecurityAnalysisUrl() + 'parameters/' + encodeURIComponent(parameterUuid); console.debug(url); diff --git a/src/services/sensitivity-analysis.js b/src/services/sensitivity-analysis.ts similarity index 100% rename from src/services/sensitivity-analysis.js rename to src/services/sensitivity-analysis.ts diff --git a/src/services/study/short-circuit-analysis.js b/src/services/study/short-circuit-analysis.ts similarity index 68% rename from src/services/study/short-circuit-analysis.js rename to src/services/study/short-circuit-analysis.ts index 11447b146d..82ab30126a 100644 --- a/src/services/study/short-circuit-analysis.js +++ b/src/services/study/short-circuit-analysis.ts @@ -11,14 +11,51 @@ import { ShortCircuitAnalysisType, } from '../../components/results/shortcircuit/shortcircuit-analysis-result.type'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; +import { FilterSelectorType } from '../../components/custom-aggrid/custom-aggrid-header.type'; +import { SortConfigType } from '../../hooks/use-aggrid-sort'; +import { INITIAL_VOLTAGE } from '../../components/utils/constants'; const PREFIX_SHORT_CIRCUIT_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/shortcircuit'; +interface ShortCircuitAnalysisResult { + studyUuid: UUID | null; + currentNodeUuid: UUID | undefined; + type: ShortCircuitAnalysisType; +} +interface Selector { + page: number; + size: number; + filter: FilterSelectorType[] | null; + sort: SortConfigType[]; +} +interface ShortCircuitAnalysisPagedResults extends ShortCircuitAnalysisResult { + selector: Partial; +} +interface VoltageRanges { + maximumNominalVoltage: number; + minimumNominalVoltage: number; + voltage: number; + voltageRangeCoefficient: number; +} +interface ShortCircuitParameters { + predefinedParameters: string; + parameters: { + withFeederResult: boolean; + withLoads: boolean; + withVSCConverterStations: boolean; + withShuntCompensators: boolean; + withNeutralPosition: boolean; + initialVoltageProfileMode: INITIAL_VOLTAGE; + voltageRanges?: VoltageRanges | undefined; + }; +} + function getShortCircuitUrl() { return `${PREFIX_SHORT_CIRCUIT_SERVER_QUERIES}/v1/`; } -export function startShortCircuitAnalysis(studyUuid, currentNodeUuid, busId) { +export function startShortCircuitAnalysis(studyUuid: string, currentNodeUuid: UUID | undefined, busId: string) { console.info(`Running short circuit analysis on '${studyUuid}' and node '${currentNodeUuid}' ...`); const urlSearchParams = new URLSearchParams(); @@ -30,31 +67,37 @@ export function startShortCircuitAnalysis(studyUuid, currentNodeUuid, busId) { return backendFetch(startShortCircuitAnalysisUrl, { method: 'put' }); } -export function stopShortCircuitAnalysis(studyUuid, currentNodeUuid) { +export function stopShortCircuitAnalysis(studyUuid: string, currentNodeUuid: UUID | undefined) { console.info(`Stopping short circuit analysis on '${studyUuid}' and node '${currentNodeUuid}' ...`); const stopShortCircuitAnalysisUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/shortcircuit/stop'; console.debug(stopShortCircuitAnalysisUrl); return backendFetch(stopShortCircuitAnalysisUrl, { method: 'put' }); } -export function fetchShortCircuitAnalysisStatus(studyUuid, currentNodeUuid, type = ShortCircuitAnalysisType.ALL_BUSES) { +export function fetchShortCircuitAnalysisStatus( + studyUuid: UUID, + currentNodeUuid: UUID, + type = ShortCircuitAnalysisType.ALL_BUSES +) { const analysisType = getShortCircuitAnalysisTypeFromEnum(type); console.info( `Fetching ${analysisType} short circuit analysis status on '${studyUuid}' and node '${currentNodeUuid}' ...` ); const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('type', analysisType); + if (analysisType !== null) { + urlSearchParams.append('type', analysisType); + } const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/shortcircuit/status?' + urlSearchParams.toString(); console.debug(url); return backendFetchText(url); } -export function fetchOneBusShortCircuitAnalysisStatus(studyUuid, currentNodeUuid) { +export function fetchOneBusShortCircuitAnalysisStatus(studyUuid: UUID, currentNodeUuid: UUID) { return fetchShortCircuitAnalysisStatus(studyUuid, currentNodeUuid, ShortCircuitAnalysisType.ONE_BUS); } -export function fetchShortCircuitAnalysisResult({ studyUuid, currentNodeUuid, type }) { +export function fetchShortCircuitAnalysisResult({ studyUuid, currentNodeUuid, type }: ShortCircuitAnalysisResult) { const analysisType = getShortCircuitAnalysisTypeFromEnum(type); console.info( @@ -76,7 +119,7 @@ export function fetchShortCircuitAnalysisPagedResults({ currentNodeUuid, selector = {}, type = ShortCircuitAnalysisType.ALL_BUSES, -}) { +}: ShortCircuitAnalysisPagedResults) { const analysisType = getShortCircuitAnalysisTypeFromEnum(type); console.info( @@ -91,14 +134,14 @@ export function fetchShortCircuitAnalysisPagedResults({ urlSearchParams.append('type', analysisType); } - const { page = '0', sort, size, filter } = selector; + const { page = 0, sort, size, filter } = selector; - urlSearchParams.append('page', page); + urlSearchParams.append('page', String(page)); sort?.map((value) => urlSearchParams.append('sort', `${value.colId},${value.sort}`)); if (size) { - urlSearchParams.append('size', size); + urlSearchParams.append('size', String(size)); } if (filter?.length) { @@ -111,14 +154,14 @@ export function fetchShortCircuitAnalysisPagedResults({ return backendFetchJson(url); } -export function getShortCircuitParameters(studyUuid) { +export function getShortCircuitParameters(studyUuid: UUID) { console.info('get short-circuit parameters'); const getShortCircuitParams = getStudyUrl(studyUuid) + '/short-circuit-analysis/parameters'; console.debug(getShortCircuitParams); return backendFetchJson(getShortCircuitParams); } -export function setShortCircuitParameters(studyUuid, newParams) { +export function setShortCircuitParameters(studyUuid: UUID, newParams: ShortCircuitParameters) { console.info('set short-circuit parameters'); const url = getStudyUrl(studyUuid) + '/short-circuit-analysis/parameters'; console.debug(url); @@ -133,13 +176,13 @@ export function setShortCircuitParameters(studyUuid, newParams) { }); } -export function fetchShortCircuitParameters(parameterUuid) { +export function fetchShortCircuitParameters(parameterUuid: UUID) { console.info('get short circuit analysis parameters'); const url = getShortCircuitUrl() + 'parameters/' + encodeURIComponent(parameterUuid); return backendFetchJson(url); } -export function invalidateShortCircuitStatus(studyUuid) { +export function invalidateShortCircuitStatus(studyUuid: UUID) { console.info('invalidate short circuit status'); const invalidateShortCircuitStatusUrl = getStudyUrl(studyUuid) + '/short-circuit/invalidate-status'; console.debug(invalidateShortCircuitStatusUrl); @@ -149,16 +192,19 @@ export function invalidateShortCircuitStatus(studyUuid) { } export function downloadShortCircuitResultZippedCsv( - studyUuid, - currentNodeUuid, - analysisType, - headersCsv, - enumValueTranslations + studyUuid: UUID, + currentNodeUuid: UUID, + analysisType: number, + headersCsv: string[] | undefined, + enumValueTranslations: Record ) { console.info(`Fetching short-circuit analysis export csv on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/shortcircuit/result/csv`; const type = getShortCircuitAnalysisTypeFromEnum(analysisType); - const param = new URLSearchParams({ type }); + const param = new URLSearchParams(); + if (type) { + param.append('type', type); + } const urlWithParam = `${url}?${param.toString()}`; console.debug(urlWithParam); return backendFetch(urlWithParam, { diff --git a/src/services/study/state-estimation.js b/src/services/study/state-estimation.ts similarity index 80% rename from src/services/study/state-estimation.js rename to src/services/study/state-estimation.ts index 0171253b52..e9ec1a9469 100644 --- a/src/services/study/state-estimation.js +++ b/src/services/study/state-estimation.ts @@ -7,8 +7,9 @@ import { getStudyUrlWithNodeUuid } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; -export function startStateEstimation(studyUuid, currentNodeUuid) { +export function startStateEstimation(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Running state estimation on ${studyUuid} and node ${currentNodeUuid} ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/state-estimation/run'; @@ -16,21 +17,21 @@ export function startStateEstimation(studyUuid, currentNodeUuid) { return backendFetch(url, { method: 'post' }); } -export function stopStateEstimation(studyUuid, currentNodeUuid) { +export function stopStateEstimation(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping state estimation on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/state-estimation/stop`; console.debug(url); return backendFetch(url, { method: 'put' }); } -export function fetchStateEstimationStatus(studyUuid, currentNodeUuid) { +export function fetchStateEstimationStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching state estimation status on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/state-estimation/status`; console.debug(url); return backendFetchText(url); } -export function fetchStateEstimationResult(studyUuid, currentNodeUuid) { +export function fetchStateEstimationResult(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching state estimation result on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/state-estimation/result`; diff --git a/src/services/study/voltage-init.js b/src/services/study/voltage-init.ts similarity index 78% rename from src/services/study/voltage-init.js rename to src/services/study/voltage-init.ts index e077ce1bbe..0c943a96b1 100644 --- a/src/services/study/voltage-init.js +++ b/src/services/study/voltage-init.ts @@ -7,8 +7,10 @@ import { getStudyUrl, getStudyUrlWithNodeUuid } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { UUID } from 'crypto'; +import { VoltageInitParam } from '../../components/dialogs/parameters/voltageinit/voltage-init-utils'; -export function startVoltageInit(studyUuid, currentNodeUuid) { +export function startVoltageInit(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Running voltage init on '${studyUuid}' and node '${currentNodeUuid}' ...`); const startVoltageInitUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/voltage-init/run'; @@ -16,28 +18,28 @@ export function startVoltageInit(studyUuid, currentNodeUuid) { return backendFetch(startVoltageInitUrl, { method: 'put' }); } -export function stopVoltageInit(studyUuid, currentNodeUuid) { +export function stopVoltageInit(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping voltage init on '${studyUuid}' and node '${currentNodeUuid}' ...`); const stopVoltageInitUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/voltage-init/stop'; console.debug(stopVoltageInitUrl); return backendFetch(stopVoltageInitUrl, { method: 'put' }); } -export function fetchVoltageInitStatus(studyUuid, currentNodeUuid) { +export function fetchVoltageInitStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching voltage init status on '${studyUuid}' and node '${currentNodeUuid}' ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/voltage-init/status'; console.debug(url); return backendFetchText(url); } -export function fetchVoltageInitResult(studyUuid, currentNodeUuid) { +export function fetchVoltageInitResult(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching voltage init result on '${studyUuid}' and node '${currentNodeUuid}' ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/voltage-init/result'; console.debug(url); return backendFetchJson(url); } -export function updateVoltageInitParameters(studyUuid, newParams) { +export function updateVoltageInitParameters(studyUuid: UUID | null, newParams: VoltageInitParam) { console.info('set voltage init parameters'); const url = getStudyUrl(studyUuid) + '/voltage-init/parameters'; console.debug(url); @@ -54,14 +56,14 @@ export function updateVoltageInitParameters(studyUuid, newParams) { }); } -export function getVoltageInitStudyParameters(studyUuid) { +export function getVoltageInitStudyParameters(studyUuid: UUID) { console.info('get voltage init study parameters'); const getVoltageInitParams = getStudyUrl(studyUuid) + '/voltage-init/parameters'; console.debug(getVoltageInitParams); return backendFetchJson(getVoltageInitParams); } -export function getVoltageInitModifications(studyUuid, currentNodeId) { +export function getVoltageInitModifications(studyUuid: UUID, currentNodeId: UUID) { console.info('get voltage init modifications'); const getVoltageInitModifications = getStudyUrlWithNodeUuid(studyUuid, currentNodeId) + '/voltage-init/modifications'; @@ -69,7 +71,7 @@ export function getVoltageInitModifications(studyUuid, currentNodeId) { return backendFetchJson(getVoltageInitModifications); } -export function cloneVoltageInitModifications(studyUuid, currentNodeId) { +export function cloneVoltageInitModifications(studyUuid: UUID, currentNodeId: UUID) { console.info('cloning voltage init modifications'); const cloneVoltageInitModificationsUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeId) + '/voltage-init/modifications'; From c62b5ba00f8b53dbe3443f6faae45c588b01575f Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 5 Nov 2024 16:46:49 +0100 Subject: [PATCH 07/24] Transformer tree, config, study notification and user admin services to TS. Signed-off-by: AAJELLAL --- src/services/{config.js => config.ts} | 6 +- ...-notification.js => study-notification.ts} | 6 +- .../{tree-subtree.js => tree-subtree.ts} | 68 ++++++++++++------- src/services/{user-admin.js => user-admin.ts} | 6 +- 4 files changed, 57 insertions(+), 29 deletions(-) rename src/services/{config.js => config.ts} (88%) rename src/services/{study-notification.js => study-notification.ts} (83%) rename src/services/study/{tree-subtree.js => tree-subtree.ts} (73%) rename src/services/{user-admin.js => user-admin.ts} (91%) diff --git a/src/services/config.js b/src/services/config.ts similarity index 88% rename from src/services/config.js rename to src/services/config.ts index 79b23ebaba..e93d41cffd 100644 --- a/src/services/config.js +++ b/src/services/config.ts @@ -9,20 +9,20 @@ import { backendFetch, backendFetchJson } from './utils'; const PREFIX_CONFIG_QUERIES = import.meta.env.VITE_API_GATEWAY + '/config'; -export function fetchConfigParameters(appName) { +export function fetchConfigParameters(appName: string) { console.info('Fetching UI configuration params for app : ' + appName); const fetchParams = PREFIX_CONFIG_QUERIES + `/v1/applications/${appName}/parameters`; return backendFetchJson(fetchParams); } -export function fetchConfigParameter(name) { +export function fetchConfigParameter(name: string) { const appName = getAppName(name); console.info("Fetching UI config parameter '%s' for app '%s' ", name, appName); const fetchParams = PREFIX_CONFIG_QUERIES + `/v1/applications/${appName}/parameters/${name}`; return backendFetch(fetchParams).then((response) => (response.status === 204 ? null : response.json())); } -export function updateConfigParameter(name, value) { +export function updateConfigParameter(name: string, value: string) { const appName = getAppName(name); console.info("Updating config parameter '%s=%s' for app '%s' ", name, value, appName); const updateParams = diff --git a/src/services/study-notification.js b/src/services/study-notification.ts similarity index 83% rename from src/services/study-notification.js rename to src/services/study-notification.ts index d8f2038d28..6bbf3b806d 100644 --- a/src/services/study-notification.js +++ b/src/services/study-notification.ts @@ -8,10 +8,14 @@ import ReconnectingWebSocket from 'reconnecting-websocket'; import { getUrlWithToken, getWsBase } from './utils'; +import { UUID } from 'crypto'; const PREFIX_STUDY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/study-notification'; -export function connectNotificationsWebsocket(studyUuid, options) { +interface WebSocketOptions { + minUptime: number; +} +export function connectNotificationsWebsocket(studyUuid: UUID, options: WebSocketOptions) { // The websocket API doesn't allow relative urls const wsBase = getWsBase(); const wsAdress = `${wsBase}${PREFIX_STUDY_NOTIFICATION_WS}/notify?studyUuid=${encodeURIComponent(studyUuid)}`; diff --git a/src/services/study/tree-subtree.js b/src/services/study/tree-subtree.ts similarity index 73% rename from src/services/study/tree-subtree.js rename to src/services/study/tree-subtree.ts index 79cdd9c8e0..197ff0e98f 100644 --- a/src/services/study/tree-subtree.js +++ b/src/services/study/tree-subtree.ts @@ -7,8 +7,23 @@ import { getStudyUrl } from './index'; import { backendFetch, backendFetchJson } from '../utils'; - -export function copySubtree(sourceStudyUuid, targetStudyUuid, nodeToCopyUuid, referenceNodeUuid) { +import { UUID } from 'crypto'; +import { NodeInsertModes } from '../../components/graph/nodes/node-insert-modes'; +import { NodeType } from '../../components/graph/tree-node.type'; +import { BUILD_STATUS } from '../../components/network/constants'; + +interface Node { + name: string; + type: NodeType; + localBuildStatus: BUILD_STATUS; + globalBuildStatus: BUILD_STATUS; +} +export function copySubtree( + sourceStudyUuid: UUID, + targetStudyUuid: UUID, + nodeToCopyUuid: UUID, + referenceNodeUuid: UUID +) { const nodeCopyUrl = getStudyUrl(targetStudyUuid) + '/tree/subtrees?subtreeToCopyParentNodeUuid=' + @@ -27,7 +42,7 @@ export function copySubtree(sourceStudyUuid, targetStudyUuid, nodeToCopyUuid, re }); } -export function cutSubtree(targetStudyId, nodeToCopyUuid, referenceNodeUuid) { +export function cutSubtree(targetStudyId: UUID, nodeToCopyUuid: UUID, referenceNodeUuid: UUID) { const nodeCopyUrl = getStudyUrl(targetStudyId) + '/tree/subtrees?subtreeToCutParentNodeUuid=' + @@ -44,7 +59,12 @@ export function cutSubtree(targetStudyId, nodeToCopyUuid, referenceNodeUuid) { }); } -export function cutTreeNode(studyUuid, nodeToCutUuid, referenceNodeUuid, insertMode) { +export function cutTreeNode( + studyUuid: UUID, + nodeToCutUuid: UUID, + referenceNodeUuid: UUID, + insertMode: NodeInsertModes +) { const nodeCutUrl = getStudyUrl(studyUuid) + '/tree/nodes?insertMode=' + @@ -63,7 +83,13 @@ export function cutTreeNode(studyUuid, nodeToCutUuid, referenceNodeUuid, insertM }); } -export function copyTreeNode(sourceStudyUuid, targetStudyId, nodeToCopyUuid, referenceNodeUuid, insertMode) { +export function copyTreeNode( + sourceStudyUuid: UUID, + targetStudyId: UUID, + nodeToCopyUuid: UUID, + referenceNodeUuid: UUID, + insertMode: NodeInsertModes +) { const nodeCopyUrl = getStudyUrl(targetStudyId) + '/tree/nodes?insertMode=' + @@ -84,7 +110,7 @@ export function copyTreeNode(sourceStudyUuid, targetStudyId, nodeToCopyUuid, ref }); } -export function createTreeNode(studyUuid, parentId, insertMode, node) { +export function createTreeNode(studyUuid: UUID, parentId: UUID, insertMode: NodeInsertModes, node: Node) { const nodeCreationUrl = getStudyUrl(studyUuid) + '/tree/nodes/' + encodeURIComponent(parentId) + '?mode=' + insertMode; console.debug('%s with body: %s', nodeCreationUrl, node); @@ -98,7 +124,7 @@ export function createTreeNode(studyUuid, parentId, insertMode, node) { }); } -export function stashTreeNode(studyUuid, nodeId) { +export function stashTreeNode(studyUuid: UUID, nodeId: UUID) { console.info('Stash tree node : ', nodeId); const url = getStudyUrl(studyUuid) + '/tree/nodes/' + encodeURIComponent(nodeId) + '/stash'; console.debug(url); @@ -107,7 +133,7 @@ export function stashTreeNode(studyUuid, nodeId) { }); } -export function stashSubtree(studyUuid, parentNodeId) { +export function stashSubtree(studyUuid: UUID, parentNodeId: UUID) { console.info('stash node subtree : ', parentNodeId); const url = getStudyUrl(studyUuid) + '/tree/nodes/' + encodeURIComponent(parentNodeId) + '/stash?stashChildren=true'; @@ -117,7 +143,7 @@ export function stashSubtree(studyUuid, parentNodeId) { }); } -export function updateTreeNode(studyUuid, node) { +export function updateTreeNode(studyUuid: UUID, node: UUID) { const nodeUpdateUrl = getStudyUrl(studyUuid) + '/tree/nodes'; console.debug(nodeUpdateUrl); return backendFetch(nodeUpdateUrl, { @@ -130,40 +156,37 @@ export function updateTreeNode(studyUuid, node) { }); } -export function fetchNetworkModificationTreeNode(studyUuid, nodeUuid) { +export function fetchNetworkModificationTreeNode(studyUuid: UUID, nodeUuid: UUID) { console.info('Fetching network modification tree node : ', nodeUuid); const url = getStudyUrl(studyUuid) + '/tree/nodes/' + encodeURIComponent(nodeUuid); console.debug(url); return backendFetchJson(url); } -export function fetchNetworkModificationTree(studyUuid) { +export function fetchNetworkModificationTree(studyUuid: UUID) { console.info('Fetching network modification tree'); const url = getStudyUrl(studyUuid) + '/tree'; console.debug(url); return backendFetchJson(url); } -export function fetchNetworkModificationSubtree(studyUuid, parentNodeUuid) { +export function fetchNetworkModificationSubtree(studyUuid: UUID, parentNodeUuid: UUID) { console.info('Fetching network modification tree node : ', parentNodeUuid); const url = getStudyUrl(studyUuid) + '/subtree?parentNodeUuid=' + encodeURIComponent(parentNodeUuid); console.debug(url); return backendFetchJson(url); } -export function fetchStashedNodes(studyUuid) { +export function fetchStashedNodes(studyUuid: UUID) { console.info('Fetching stashed nodes for study : ', studyUuid); const url = getStudyUrl(studyUuid) + '/tree/nodes/stash'; console.debug(url); return backendFetchJson(url); } -export function restoreStashedNodes(studyUuid, nodeToRestoreIds, anchorNodeId) { +export function restoreStashedNodes(studyUuid: UUID, nodeToRestoreIds: UUID[], anchorNodeId: UUID) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append( - 'ids', - nodeToRestoreIds.map((id) => encodeURIComponent(id)) - ); + urlSearchParams.append('ids', nodeToRestoreIds.map((id) => encodeURIComponent(id)).join(',')); urlSearchParams.append('anchorNodeId', encodeURIComponent(anchorNodeId)); console.info('Restoring nodes %s under nodes %s of study : %s', nodeToRestoreIds, nodeToRestoreIds, studyUuid); @@ -179,13 +202,10 @@ export function restoreStashedNodes(studyUuid, nodeToRestoreIds, anchorNodeId) { }); } -export function deleteStashedNodes(studyUuid, nodeToDeleteIds) { +export function deleteStashedNodes(studyUuid: UUID, nodeToDeleteIds: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append( - 'ids', - nodeToDeleteIds.map((id) => encodeURIComponent(id)) - ); - urlSearchParams.append('deleteChildren', true); + urlSearchParams.append('ids', nodeToDeleteIds.map((id) => encodeURIComponent(id)).join(',')); + urlSearchParams.append('deleteChildren', String(true)); console.info('Delete nodes %s of study : %s', nodeToDeleteIds, studyUuid); const url = getStudyUrl(studyUuid) + '/tree/nodes?' + urlSearchParams.toString(); diff --git a/src/services/user-admin.js b/src/services/user-admin.ts similarity index 91% rename from src/services/user-admin.js rename to src/services/user-admin.ts index 0890be6d70..a42f0b6a15 100644 --- a/src/services/user-admin.js +++ b/src/services/user-admin.ts @@ -9,7 +9,11 @@ import { backendFetch } from './utils'; const PREFIX_USER_ADMIN_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/user-admin'; -export function fetchValidateUser(user) { +interface User { + profile: { sub: string }; + id_token: string; +} +export function fetchValidateUser(user: User) { const sub = user?.profile?.sub; if (!sub) { return Promise.reject(new Error('Error : Fetching access for missing user.profile.sub : ' + user)); From ed91015a368443108291ab1e061f2f56661cda0d Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Wed, 6 Nov 2024 17:22:31 +0100 Subject: [PATCH 08/24] Transformer study index services to TS. Signed-off-by: AAJELLAL --- src/components/app-top-bar.jsx | 2 +- src/components/app.jsx | 2 +- .../network-modification-tree-pane.jsx | 2 +- src/components/study-container.jsx | 2 +- src/redux/user-store.ts | 2 +- src/services/study/{index.js => index.ts} | 94 +++++++++++++------ 6 files changed, 71 insertions(+), 33 deletions(-) rename src/services/study/{index.js => index.ts} (70%) diff --git a/src/components/app-top-bar.jsx b/src/components/app-top-bar.jsx index 245a024b3f..7d6e353c7c 100644 --- a/src/components/app-top-bar.jsx +++ b/src/components/app-top-bar.jsx @@ -20,7 +20,7 @@ import AppPackage from '../../package.json'; import { DiagramType, useDiagram } from './diagrams/diagram-common'; import { isNodeBuilt, isNodeReadOnly } from './graph/util/model-functions'; import { useParameterState } from './dialogs/parameters/parameters'; -import { getServersInfos } from '../services/study'; +import { getServersInfos } from '../services/study/index'; import { EQUIPMENT_TYPES } from './utils/equipment-types'; import { fetchVersion } from '../services/utils'; import { RunButtonContainer } from './run-button-container'; diff --git a/src/components/app.jsx b/src/components/app.jsx index 8febf95583..800f176ed3 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -58,7 +58,7 @@ import { fetchValidateUser } from '../services/user-admin'; import { connectNotificationsWsUpdateConfig } from '../services/config-notification'; import { fetchConfigParameter, fetchConfigParameters } from '../services/config'; import { fetchDefaultParametersValues, fetchIdpSettings } from '../services/utils'; -import { getOptionalServices } from '../services/study'; +import { getOptionalServices } from '../services/study/index'; import { changeDisplayedColumns, changeLockedColumns, diff --git a/src/components/network-modification-tree-pane.jsx b/src/components/network-modification-tree-pane.jsx index a3b55aaed5..053451faac 100644 --- a/src/components/network-modification-tree-pane.jsx +++ b/src/components/network-modification-tree-pane.jsx @@ -38,7 +38,7 @@ import { fetchNetworkModificationTreeNode, fetchStashedNodes, } from '../services/study/tree-subtree'; -import { buildNode, getUniqueNodeName, unbuildNode } from '../services/study'; +import { buildNode, getUniqueNodeName, unbuildNode } from '../services/study/index'; import RestoreNodesDialog from './dialogs/restore-node-dialog'; import ScenarioEditor from './graph/menus/dynamic-simulation/scenario-editor'; import { StudyDisplayMode, CopyType, UpdateType } from './network-modification.type'; diff --git a/src/components/study-container.jsx b/src/components/study-container.jsx index 11557bf24e..f91220e877 100644 --- a/src/components/study-container.jsx +++ b/src/components/study-container.jsx @@ -36,7 +36,7 @@ import { connectNotificationsWsUpdateDirectories, } from '../services/directory-notification'; import { useAllComputingStatus } from './computing-status/use-all-computing-status'; -import { fetchCaseName, fetchStudyExists } from '../services/study'; +import { fetchCaseName, fetchStudyExists } from '../services/study/index'; import { fetchNetworkModificationTree } from '../services/study/tree-subtree'; import { fetchNetworkExistence, fetchStudyIndexationStatus } from '../services/study/network'; import { recreateStudyNetwork, reindexAllStudy } from 'services/study/study'; diff --git a/src/redux/user-store.ts b/src/redux/user-store.ts index ca5131ed45..d6c945a407 100644 --- a/src/redux/user-store.ts +++ b/src/redux/user-store.ts @@ -12,7 +12,7 @@ /* at src/redux/store.ts:12:33 at src/services/utils.js:7:1 - at src/services/study/index.js:8:1 + at src/services/study/index.ts:8:1 at src/components/utils/inputs/input-hooks.jsx:41:1 at src/components/dialogs/commons/modification-dialog-content.jsx:19:1 at src/components/dialogs/commons/modificationDialog.jsx:12:1 diff --git a/src/services/study/index.js b/src/services/study/index.ts similarity index 70% rename from src/services/study/index.js rename to src/services/study/index.ts index 9100066fce..16b9c0fa50 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.ts @@ -12,43 +12,64 @@ import { getQueryParamsList, getRequestParamFromList, } from '../utils'; +import { UUID } from 'crypto'; +import { COMPUTING_AND_NETWORK_MODIFICATION_TYPE } from '../../utils/report/report.constant'; +import { EquipmentType } from '@gridsuite/commons-ui'; +import { NetworkModificationCopyInfo } from '../../components/graph/menus/network-modification-menu.type'; +import { ComputingType } from '../../components/computing-status/computing-type'; +// TODO: does it make sense that studyUuid can be null? +function safeEncodeURIComponent(value: string | null | undefined): string { + return value != null ? encodeURIComponent(value) : ''; +} export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; -export const getStudyUrl = (studyUuid) => `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}`; +export const getStudyUrl = (studyUuid: UUID) => `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}`; -export const getStudyUrlWithNodeUuid = (studyUuid, nodeUuid) => - `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}/nodes/${encodeURIComponent(nodeUuid)}`; +export const getStudyUrlWithNodeUuid = (studyUuid: UUID | null, nodeUuid: UUID | undefined) => + `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/nodes/${safeEncodeURIComponent(nodeUuid)}`; -export const fetchStudy = (studyUuid) => { +export const fetchStudy = (studyUuid: UUID) => { console.info(`Fetching study '${studyUuid}' ...`); const fetchStudiesUrl = getStudyUrl(studyUuid); console.debug(fetchStudiesUrl); return backendFetchJson(fetchStudiesUrl); }; -export const fetchStudyExists = (studyUuid) => { +export const fetchStudyExists = (studyUuid: UUID) => { console.info(`Fetching study '${studyUuid}' existence ...`); const fetchStudiesUrl = getStudyUrl(studyUuid); console.debug(fetchStudiesUrl); return backendFetch(fetchStudiesUrl, { method: 'head' }); }; -export function getNetworkAreaDiagramUrl(studyUuid, currentNodeUuid, voltageLevelsIds, depth, withGeoData) { +export function getNetworkAreaDiagramUrl( + studyUuid: UUID, + currentNodeUuid: UUID, + voltageLevelsIds: UUID[], + depth: number, + withGeoData: boolean +) { console.info(`Getting url of network area diagram of study '${studyUuid}' and node '${currentNodeUuid}'...`); return ( getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network-area-diagram?' + new URLSearchParams({ - depth: depth, - withGeoData: withGeoData, + depth: String(depth), + withGeoData: String(withGeoData), }) + '&' + getQueryParamsList(voltageLevelsIds, 'voltageLevelsIds').toString() ); } -export function fetchParentNodesReport(studyUuid, nodeUuid, nodeOnlyReport, severityFilterList, reportType) { +export function fetchParentNodesReport( + studyUuid: UUID | null, + nodeUuid: UUID, + nodeOnlyReport: boolean, + severityFilterList: string[], + reportType: keyof typeof COMPUTING_AND_NETWORK_MODIFICATION_TYPE +) { console.info( 'get node report with its parent for : ' + nodeUuid + @@ -73,7 +94,14 @@ export function fetchParentNodesReport(studyUuid, nodeUuid, nodeOnlyReport, seve return backendFetchJson(url); } -export function fetchNodeReportLogs(studyUuid, nodeUuid, reportId, severityFilterList, messageFilter, isGlobalLogs) { +export function fetchNodeReportLogs( + studyUuid: UUID | null, + nodeUuid: UUID, + reportId: string | null, + severityFilterList: string[], + messageFilter: string, + isGlobalLogs: boolean +) { let url; if (isGlobalLogs) { url = getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/report/logs?'; @@ -90,25 +118,25 @@ export function fetchNodeReportLogs(studyUuid, nodeUuid, reportId, severityFilte return backendFetchJson(url); } -export function fetchSvg(svgUrl) { +export function fetchSvg(svgUrl: string | null) { console.debug(svgUrl); return backendFetch(svgUrl).then((response) => (response.status === 204 ? null : response.json())); } export function searchEquipmentsInfos( - studyUuid, - nodeUuid, - searchTerm, - getUseNameParameterKey, - inUpstreamBuiltParentNode, - equipmentType + studyUuid: UUID, + nodeUuid: UUID, + searchTerm: string, + getUseNameParameterKey: () => 'name' | 'id', + inUpstreamBuiltParentNode?: boolean, + equipmentType?: EquipmentType ) { console.info("Fetching equipments infos matching with '%s' term ... ", searchTerm); let urlSearchParams = new URLSearchParams(); urlSearchParams.append('userInput', searchTerm); urlSearchParams.append('fieldSelector', getUseNameParameterKey()); if (inUpstreamBuiltParentNode !== undefined) { - urlSearchParams.append('inUpstreamBuiltParentNode', inUpstreamBuiltParentNode); + urlSearchParams.append('inUpstreamBuiltParentNode', String(inUpstreamBuiltParentNode)); } if (equipmentType !== undefined) { urlSearchParams.append('equipmentType', equipmentType); @@ -118,7 +146,7 @@ export function searchEquipmentsInfos( ); } -export function fetchContingencyCount(studyUuid, currentNodeUuid, contingencyListNames) { +export function fetchContingencyCount(studyUuid: UUID, currentNodeUuid: UUID, contingencyListNames: string[]) { console.info( `Fetching contingency count for ${contingencyListNames} on '${studyUuid}' and node '${currentNodeUuid}'...` ); @@ -132,14 +160,19 @@ export function fetchContingencyCount(studyUuid, currentNodeUuid, contingencyLis return backendFetchJson(url); } -export function copyOrMoveModifications(studyUuid, targetNodeId, modificationToCutUuidList, copyInfos) { +export function copyOrMoveModifications( + studyUuid: UUID | null, + targetNodeId: UUID | undefined, + modificationToCutUuidList: string[], + copyInfos: NetworkModificationCopyInfo +) { console.info(copyInfos.copyType + ' modifications'); const copyOrMoveModificationUrl = PREFIX_STUDY_QUERIES + '/v1/studies/' + - encodeURIComponent(studyUuid) + + safeEncodeURIComponent(studyUuid) + '/nodes/' + - encodeURIComponent(targetNodeId) + + safeEncodeURIComponent(targetNodeId) + '?' + new URLSearchParams({ action: copyInfos.copyType, @@ -170,21 +203,21 @@ export function getAvailableComponentLibraries() { return backendFetchJson(getAvailableComponentLibrariesUrl); } -export function unbuildNode(studyUuid, currentNodeUuid) { +export function unbuildNode(studyUuid: UUID, currentNodeUuid: UUID) { console.info('Unbuild node ' + currentNodeUuid + ' of study ' + studyUuid + ' ...'); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/unbuild'; console.debug(url); return backendFetchText(url, { method: 'post' }); } -export function buildNode(studyUuid, currentNodeUuid) { +export function buildNode(studyUuid: UUID, currentNodeUuid: UUID) { console.info('Build node ' + currentNodeUuid + ' of study ' + studyUuid + ' ...'); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/build'; console.debug(url); return backendFetchText(url, { method: 'post' }); } -export function fetchCaseName(studyUuid) { +export function fetchCaseName(studyUuid: UUID) { console.info('Fetching case name'); const url = getStudyUrl(studyUuid) + '/case/name'; console.debug(url); @@ -192,7 +225,7 @@ export function fetchCaseName(studyUuid) { return backendFetchText(url); } -export function isNodeExists(studyUuid, nodeName) { +export function isNodeExists(studyUuid: UUID, nodeName: string) { const existsNodeUrl = getStudyUrl(studyUuid) + '/nodes?' + @@ -203,7 +236,7 @@ export function isNodeExists(studyUuid, nodeName) { return backendFetch(existsNodeUrl, { method: 'head' }); } -export function getUniqueNodeName(studyUuid) { +export function getUniqueNodeName(studyUuid: UUID) { const uniqueNodeNameUrl = getStudyUrl(studyUuid) + '/nodes/nextUniqueName'; console.debug(uniqueNodeNameUrl); return backendFetchText(uniqueNodeNameUrl); @@ -224,7 +257,12 @@ export function getServersInfos() { }); } -export function fetchAvailableFilterEnumValues(studyUuid, nodeUuid, computingType, filterEnum) { +export function fetchAvailableFilterEnumValues( + studyUuid: UUID | null, + nodeUuid: UUID | undefined, + computingType: ComputingType, + filterEnum: string +) { console.info('fetch available filter values'); const url = `${getStudyUrlWithNodeUuid( studyUuid, From 9b7563767b198fa8179ae17b56cb9cfa91cec16b Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Fri, 8 Nov 2024 14:51:31 +0100 Subject: [PATCH 09/24] Transform network service to TS. Signed-off-by: AAJELLAL --- src/components/spreadsheet/table-wrapper.tsx | 2 +- src/services/study/index.ts | 5 +- src/services/study/{network.js => network.ts} | 226 +++++++++++------- 3 files changed, 143 insertions(+), 90 deletions(-) rename src/services/study/{network.js => network.ts} (63%) diff --git a/src/components/spreadsheet/table-wrapper.tsx b/src/components/spreadsheet/table-wrapper.tsx index a9ecc33d31..30d0622b56 100644 --- a/src/components/spreadsheet/table-wrapper.tsx +++ b/src/components/spreadsheet/table-wrapper.tsx @@ -471,7 +471,7 @@ const TableWrapper: FunctionComponent = ({ return [...equipments]; }, [equipments, disabled]); - //TODO fix network.js update methods so that when an existing entry is modified or removed the whole collection + //TODO fix network.ts update methods so that when an existing entry is modified or removed the whole collection //is reinstanciated in order to notify components using it. //this variable is regenerated on every renders in order to gather latest external updates done to the dataset, //it is necessary since we curently lack the system to detect changes done to it after receiving a notification diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 16b9c0fa50..e820a49859 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -18,15 +18,14 @@ import { EquipmentType } from '@gridsuite/commons-ui'; import { NetworkModificationCopyInfo } from '../../components/graph/menus/network-modification-menu.type'; import { ComputingType } from '../../components/computing-status/computing-type'; -// TODO: does it make sense that studyUuid can be null? -function safeEncodeURIComponent(value: string | null | undefined): string { +export function safeEncodeURIComponent(value: string | null | undefined): string { return value != null ? encodeURIComponent(value) : ''; } export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; export const getStudyUrl = (studyUuid: UUID) => `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}`; -export const getStudyUrlWithNodeUuid = (studyUuid: UUID | null, nodeUuid: UUID | undefined) => +export const getStudyUrlWithNodeUuid = (studyUuid: UUID | string | null, nodeUuid: UUID | undefined) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/nodes/${safeEncodeURIComponent(nodeUuid)}`; export const fetchStudy = (studyUuid: UUID) => { diff --git a/src/services/study/network.js b/src/services/study/network.ts similarity index 63% rename from src/services/study/network.js rename to src/services/study/network.ts index 79755d05e7..38c40978ec 100644 --- a/src/services/study/network.js +++ b/src/services/study/network.ts @@ -5,46 +5,50 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; +import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES, safeEncodeURIComponent } from './index'; import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { backendFetch, backendFetchJson, backendFetchText, getQueryParamsList, getUrlWithToken } from '../utils'; +import { UUID } from 'crypto'; +import { GsLang } from '@gridsuite/commons-ui'; +import { SubstationLayout } from '../../components/diagrams/diagram-common'; /* voltage-levels */ export function getVoltageLevelSingleLineDiagram( - studyUuid, - currentNodeUuid, - voltageLevelId, - useName, - centerLabel, - diagonalLabel, - componentLibrary, - sldDisplayMode, - language + studyUuid: UUID, + currentNodeUuid: UUID, + voltageLevelId: UUID | undefined, + useName: boolean, + centerLabel: boolean, + diagonalLabel: boolean, + componentLibrary: unknown | null, + sldDisplayMode: string, + language: GsLang ) { console.info( `Getting url of voltage level diagram '${voltageLevelId}' of study '${studyUuid}' and node '${currentNodeUuid}'...` ); + const queryParams = new URLSearchParams({ + useName: String(useName), + centerLabel: String(centerLabel), + diagonalLabel: String(diagonalLabel), + topologicalColoring: 'true', + sldDisplayMode: sldDisplayMode, + language: language, + inUpstreamBuiltParentNode: 'true', + }); + if (componentLibrary !== null) { + queryParams.append('componentLibrary', String(componentLibrary)); + } return ( getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network/voltage-levels/' + - encodeURIComponent(voltageLevelId) + + safeEncodeURIComponent(voltageLevelId) + '/svg-and-metadata?' + - new URLSearchParams({ - useName: useName, - centerLabel: centerLabel, - diagonalLabel: diagonalLabel, - topologicalColoring: true, - ...(componentLibrary !== null && { - componentLibrary: componentLibrary, - }), - sldDisplayMode: sldDisplayMode, - language: language, - inUpstreamBuiltParentNode: true, - }).toString() + queryParams.toString() ); } -export function fetchBusesForVoltageLevel(studyUuid, currentNodeUuid, voltageLevelId) { +export function fetchBusesForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { console.info( `Fetching buses of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` ); @@ -62,7 +66,7 @@ export function fetchBusesForVoltageLevel(studyUuid, currentNodeUuid, voltageLev return backendFetchJson(fetchBusesUrl); } -export function fetchBusbarSectionsForVoltageLevel(studyUuid, currentNodeUuid, voltageLevelId) { +export function fetchBusbarSectionsForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { console.info( `Fetching busbar sections of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` ); @@ -83,47 +87,48 @@ export function fetchBusbarSectionsForVoltageLevel(studyUuid, currentNodeUuid, v /* substations */ export function getSubstationSingleLineDiagram( - studyUuid, - currentNodeUuid, - substationId, - useName, - centerLabel, - diagonalLabel, - substationLayout, - componentLibrary, - language + studyUuid: UUID, + currentNodeUuid: UUID, + substationId: UUID, + useName: boolean, + centerLabel: boolean, + diagonalLabel: boolean, + substationLayout: SubstationLayout, + componentLibrary: unknown | null, + language: GsLang ) { console.info( `Getting url of substation diagram '${substationId}' of study '${studyUuid}' and node '${currentNodeUuid}'...` ); + const queryParams = new URLSearchParams({ + useName: String(useName), + centerLabel: String(centerLabel), + diagonalLabel: String(diagonalLabel), + topologicalColoring: 'true', + substationLayout: substationLayout, + language: language, + }); + if (componentLibrary !== null) { + queryParams.append('componentLibrary', String(componentLibrary)); + } return ( getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network/substations/' + encodeURIComponent(substationId) + '/svg-and-metadata?' + - new URLSearchParams({ - useName: useName, - centerLabel: centerLabel, - diagonalLabel: diagonalLabel, - topologicalColoring: true, - substationLayout: substationLayout, - ...(componentLibrary !== null && { - componentLibrary: componentLibrary, - }), - language: language, - }).toString() + queryParams.toString() ); } /* elements */ export function fetchNetworkElementsInfos( - studyUuid, - currentNodeUuid, - substationsIds, - elementType, - infoType, - inUpstreamBuiltParentNode, - nominalVoltages + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined, + elementType: string, + infoType: string, + inUpstreamBuiltParentNode?: boolean, + nominalVoltages?: number[] ) { const substationsCount = substationsIds ? substationsIds.length : 0; const nominalVoltagesStr = nominalVoltages ? `[${nominalVoltages}]` : '[]'; @@ -138,7 +143,7 @@ export function fetchNetworkElementsInfos( const urlSearchParams = new URLSearchParams(); if (inUpstreamBuiltParentNode !== undefined) { - urlSearchParams.append('inUpstreamBuiltParentNode', inUpstreamBuiltParentNode); + urlSearchParams.append('inUpstreamBuiltParentNode', String(inUpstreamBuiltParentNode)); } urlSearchParams.append('infoType', infoType); urlSearchParams.append('elementType', elementType); @@ -159,19 +164,19 @@ export function fetchNetworkElementsInfos( } export function fetchNetworkElementInfos( - studyUuid, - currentNodeUuid, - elementType, - infoType, - elementId, - inUpstreamBuiltParentNode + studyUuid: string, + currentNodeUuid: UUID | undefined, + elementType: EQUIPMENT_TYPES, + infoType: string, + elementId: string, + inUpstreamBuiltParentNode: boolean ) { console.info( `Fetching specific network element '${elementId}' of type '${elementType}' of study '${studyUuid}' and node '${currentNodeUuid}' ...` ); const urlSearchParams = new URLSearchParams(); if (inUpstreamBuiltParentNode !== undefined) { - urlSearchParams.append('inUpstreamBuiltParentNode', inUpstreamBuiltParentNode); + urlSearchParams.append('inUpstreamBuiltParentNode', String(inUpstreamBuiltParentNode)); } urlSearchParams.append('elementType', elementType); urlSearchParams.append('infoType', infoType); @@ -189,18 +194,29 @@ export function fetchNetworkElementInfos( return backendFetchJson(fetchElementsUrl); } -export function fetchSubstationsMapInfos(studyUuid, currentNodeUuid, substationsIds, inUpstreamBuiltParentNode) { +export function fetchSubstationsMapInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined, + inUpstreamBuiltParentNode: boolean +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, substationsIds, EQUIPMENT_TYPES.SUBSTATION, EQUIPMENT_INFOS_TYPES.MAP.type, - inUpstreamBuiltParentNode + inUpstreamBuiltParentNode, + undefined ); } -export function fetchLinesMapInfos(studyUuid, currentNodeUuid, substationsIds, inUpstreamBuiltParentNode) { +export function fetchLinesMapInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined, + inUpstreamBuiltParentNode: boolean +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -211,7 +227,12 @@ export function fetchLinesMapInfos(studyUuid, currentNodeUuid, substationsIds, i ); } -export function fetchTieLinesMapInfos(studyUuid, currentNodeUuid, substationsIds, inUpstreamBuiltParentNode) { +export function fetchTieLinesMapInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined, + inUpstreamBuiltParentNode: boolean +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -222,7 +243,12 @@ export function fetchTieLinesMapInfos(studyUuid, currentNodeUuid, substationsIds ); } -export function fetchHvdcLinesMapInfos(studyUuid, currentNodeUuid, substationsIds, inUpstreamBuiltParentNode) { +export function fetchHvdcLinesMapInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined, + inUpstreamBuiltParentNode: boolean +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -233,7 +259,7 @@ export function fetchHvdcLinesMapInfos(studyUuid, currentNodeUuid, substationsId ); } -export function fetchSubstations(studyUuid, currentNodeUuid, substationsIds) { +export function fetchSubstations(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -244,7 +270,7 @@ export function fetchSubstations(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchLines(studyUuid, currentNodeUuid, substationsIds) { +export function fetchLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -255,7 +281,7 @@ export function fetchLines(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchVoltageLevels(studyUuid, currentNodeUuid, substationsIds) { +export function fetchVoltageLevels(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -266,7 +292,11 @@ export function fetchVoltageLevels(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchVoltageLevelsListInfos(studyUuid, currentNodeUuid, substationsIds) { +export function fetchVoltageLevelsListInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -277,7 +307,11 @@ export function fetchVoltageLevelsListInfos(studyUuid, currentNodeUuid, substati ); } -export function fetchVoltageLevelsMapInfos(studyUuid, currentNodeUuid, substationsIds) { +export function fetchVoltageLevelsMapInfos( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -288,7 +322,11 @@ export function fetchVoltageLevelsMapInfos(studyUuid, currentNodeUuid, substatio ); } -export function fetchTwoWindingsTransformers(studyUuid, currentNodeUuid, substationsIds) { +export function fetchTwoWindingsTransformers( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -299,7 +337,11 @@ export function fetchTwoWindingsTransformers(studyUuid, currentNodeUuid, substat ); } -export function fetchThreeWindingsTransformers(studyUuid, currentNodeUuid, substationsIds) { +export function fetchThreeWindingsTransformers( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -310,7 +352,7 @@ export function fetchThreeWindingsTransformers(studyUuid, currentNodeUuid, subst ); } -export function fetchGenerators(studyUuid, currentNodeUuid, substationsIds) { +export function fetchGenerators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -320,7 +362,7 @@ export function fetchGenerators(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchLoads(studyUuid, currentNodeUuid, substationsIds) { +export function fetchLoads(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -331,7 +373,7 @@ export function fetchLoads(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchDanglingLines(studyUuid, currentNodeUuid, substationsIds) { +export function fetchDanglingLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -341,7 +383,7 @@ export function fetchDanglingLines(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchBatteries(studyUuid, currentNodeUuid, substationsIds) { +export function fetchBatteries(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -351,7 +393,7 @@ export function fetchBatteries(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchHvdcLines(studyUuid, currentNodeUuid, substationsIds) { +export function fetchHvdcLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -362,7 +404,11 @@ export function fetchHvdcLines(studyUuid, currentNodeUuid, substationsIds) { ); } -export function fetchLccConverterStations(studyUuid, currentNodeUuid, substationsIds) { +export function fetchLccConverterStations( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -372,7 +418,11 @@ export function fetchLccConverterStations(studyUuid, currentNodeUuid, substation ); } -export function fetchVscConverterStations(studyUuid, currentNodeUuid, substationsIds) { +export function fetchVscConverterStations( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -382,7 +432,7 @@ export function fetchVscConverterStations(studyUuid, currentNodeUuid, substation ); } -export function fetchShuntCompensators(studyUuid, currentNodeUuid, substationsIds) { +export function fetchShuntCompensators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -392,7 +442,11 @@ export function fetchShuntCompensators(studyUuid, currentNodeUuid, substationsId ); } -export function fetchStaticVarCompensators(studyUuid, currentNodeUuid, substationsIds) { +export function fetchStaticVarCompensators( + studyUuid: UUID, + currentNodeUuid: UUID, + substationsIds: string[] | undefined +) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -402,7 +456,7 @@ export function fetchStaticVarCompensators(studyUuid, currentNodeUuid, substatio ); } -export function fetchBuses(studyUuid, currentNodeUuid, substationsIds) { +export function fetchBuses(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -412,13 +466,13 @@ export function fetchBuses(studyUuid, currentNodeUuid, substationsIds) { ); } -export const fetchNetworkExistence = (studyUuid) => { +export const fetchNetworkExistence = (studyUuid: UUID) => { const fetchNetworkExistenceUrl = `${PREFIX_STUDY_QUERIES}/v1/studies/${studyUuid}/network`; return backendFetch(fetchNetworkExistenceUrl, { method: 'HEAD' }); }; -export const fetchStudyIndexationStatus = (studyUuid) => { +export const fetchStudyIndexationStatus = (studyUuid: UUID) => { console.info(`Fetching study indexation status of study '${studyUuid}' ...`); const fetchStudyIndexationUrl = `${PREFIX_STUDY_QUERIES}/v1/studies/${studyUuid}/indexation/status`; @@ -428,12 +482,12 @@ export const fetchStudyIndexationStatus = (studyUuid) => { }; /* export-network */ -export function getExportUrl(studyUuid, nodeUuid, exportFormat) { +export function getExportUrl(studyUuid: UUID, nodeUuid: UUID, exportFormat: string) { const url = getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/export-network/' + exportFormat; return getUrlWithToken(url); } -export function fetchTieLines(studyUuid, currentNodeUuid, substationsIds) { +export function fetchTieLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, From 17cfbe01cb7462d4542b75ec6607e4d07d30bb47 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Fri, 8 Nov 2024 14:57:21 +0100 Subject: [PATCH 10/24] Resolve conflict. Signed-off-by: AAJELLAL --- src/services/study/network.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/study/network.ts b/src/services/study/network.ts index a5db3dfdef..4b5f810d6e 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -206,7 +206,7 @@ export function fetchSubstationsMapInfos( substationsIds, EQUIPMENT_TYPES.SUBSTATION, EQUIPMENT_INFOS_TYPES.MAP.type, - inUpstreamBuiltParentNode, + inUpstreamBuiltParentNode ); } @@ -465,7 +465,7 @@ export function fetchBuses(studyUuid: UUID, currentNodeUuid: UUID, substationsId ); } -export function fetchBusbarSections(studyUuid, currentNodeUuid, substationsIds) { +export function fetchBusbarSections(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -475,7 +475,7 @@ export function fetchBusbarSections(studyUuid, currentNodeUuid, substationsIds) ); } -export const fetchNetworkExistence = (studyUuid:UUID) => { +export const fetchNetworkExistence = (studyUuid: UUID) => { const fetchNetworkExistenceUrl = `${PREFIX_STUDY_QUERIES}/v1/studies/${studyUuid}/network`; return backendFetch(fetchNetworkExistenceUrl, { method: 'HEAD' }); From c966529b8e3b92b61c05a1e1ce064a088723c739 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 12 Nov 2024 16:52:56 +0100 Subject: [PATCH 11/24] convert the rest of the service files to ts. Signed-off-by: AAJELLAL --- src/components/app.jsx | 2 +- .../battery-modification-dialog.jsx | 2 +- .../by-formula/by-formula-dialog.jsx | 2 +- .../delete-attaching-line-dialog.jsx | 2 +- .../delete-voltage-level-on-line-dialog.jsx | 2 +- .../equipment-deletion-dialog.jsx | 2 +- .../generation-dispatch-dialog.jsx | 2 +- .../generator-scaling-dialog.jsx | 2 +- .../creation/generator-creation-dialog.jsx | 2 +- .../generator-modification-dialog.jsx | 2 +- .../line-attach-to-voltage-level-dialog.jsx | 2 +- .../line-split-with-voltage-level-dialog.jsx | 2 +- .../line/creation/line-creation-dialog.jsx | 2 +- .../modification/line-modification-dialog.jsx | 2 +- .../lines-attach-to-split-lines-dialog.jsx | 2 +- .../load-scaling/load-scaling-dialog.jsx | 2 +- .../load/creation/load-creation-dialog.jsx | 2 +- .../modification/load-modification-dialog.jsx | 2 +- .../shunt-compensator-creation-dialog.jsx | 2 +- .../shunt-compensator-modification-dialog.jsx | 2 +- .../creation/substation-creation-dialog.jsx | 2 +- .../tabular-creation-dialog.jsx | 2 +- .../tabular-modification-dialog.jsx | 2 +- ...o-windings-transformer-creation-dialog.jsx | 2 +- ...ndings-transformer-modification-dialog.jsx | 2 +- .../phase-tap-changer-pane-utils.js | 2 +- .../ratio-tap-changer-pane-utils.js | 2 +- .../voltage-level-creation-dialog.jsx | 2 +- .../voltage-level-modification-dialog.jsx | 2 +- .../vsc/creation/vsc-creation-dialog.jsx | 2 +- .../sensitivity-analysis-result-tab.jsx | 2 +- src/components/voltage-init-result.jsx | 2 +- src/redux/user-store.ts | 2 +- src/services/network-modification-types.ts | 317 ++++++- src/services/study/dynamic-simulation.js | 2 +- src/services/study/geo-data.ts | 8 +- src/services/study/index.ts | 7 +- ...ifications.js => network-modifications.ts} | 810 ++++++++++-------- src/services/study/network.ts | 6 +- src/services/{utils.js => utils.ts} | 40 +- 40 files changed, 849 insertions(+), 407 deletions(-) rename src/services/study/{network-modifications.js => network-modifications.ts} (78%) rename src/services/{utils.js => utils.ts} (77%) diff --git a/src/components/app.jsx b/src/components/app.jsx index 800f176ed3..c6930e9d83 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -57,7 +57,7 @@ import { StudyContainer } from './study-container'; import { fetchValidateUser } from '../services/user-admin'; import { connectNotificationsWsUpdateConfig } from '../services/config-notification'; import { fetchConfigParameter, fetchConfigParameters } from '../services/config'; -import { fetchDefaultParametersValues, fetchIdpSettings } from '../services/utils'; +import { fetchDefaultParametersValues, fetchIdpSettings } from '../services/utils.js'; import { getOptionalServices } from '../services/study/index'; import { changeDisplayedColumns, diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx index 9ef1b3c6fa..b5d092143f 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx @@ -60,7 +60,7 @@ import { } from '../../../set-points/set-points-utils'; import { modifyBattery } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx index 7d5e11ae49..0fa918b05d 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx @@ -9,7 +9,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index 445eea1cbf..f79be13ec7 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -24,7 +24,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import DeleteAttachingLineForm from './delete-attaching-line-form'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { deleteAttachingLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx index 2998f4638c..0a49954725 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx @@ -23,7 +23,7 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import DeleteVoltageLevelOnLineForm from './delete-voltage-level-on-line-form'; import { deleteVoltageLevelOnLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx index aad8f3034e..9925ea200f 100644 --- a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx +++ b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx @@ -18,7 +18,7 @@ import PropTypes from 'prop-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipment } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx index ed9e2d58d8..96ba8d6e25 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx @@ -30,7 +30,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import GenerationDispatchForm from './generation-dispatch-form'; import { addSelectedFieldToRows } from 'components/utils/dnd-table/dnd-table'; import { generationDispatch } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; const emptyFormData = { [LOSS_COEFFICIENT]: null, diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx index bffffe5acb..222e3cbe04 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx @@ -17,7 +17,7 @@ import { getVariationsSchema } from './variation/variation-utils'; import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { generatorScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx index 45a262284c..48cf0ef352 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx @@ -67,7 +67,7 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import { createGenerator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx index 1c503e2787..28e602d551 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx @@ -72,7 +72,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyGenerator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index 6f02e516fa..f404562c68 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -45,7 +45,7 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { attachLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index 59bff8aa99..48b87ddc8d 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -43,7 +43,7 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { divideLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index f74ee5b33e..ac1cfa5fd4 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -40,7 +40,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import yup from 'components/utils/yup-config'; diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index 412548788b..484e7b933d 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -67,7 +67,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyLine } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index ca11ca224e..6cb9fd4ba2 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -38,7 +38,7 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { linesAttachToSplitLines } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx index 3ee51aae8d..86152bc1ee 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx @@ -17,7 +17,7 @@ import { getVariationsSchema } from './variation/variation-utils'; import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { loadScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; +import { FetchStatus } from '../../../../services/utils.js'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx index 4ffbbe0cd3..52749a6359 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx @@ -26,7 +26,7 @@ import LoadCreationForm from './load-creation-form'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { createLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx index a266b1338c..951ce2e466 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx @@ -34,7 +34,7 @@ import LoadModificationForm from './load-modification-form'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { modifyLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index 91e53027a0..b4ea867f77 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -47,7 +47,7 @@ import { } from '../characteristics-pane/characteristics-form-utils'; import ShuntCompensatorCreationForm from './shunt-compensator-creation-form'; import { createShuntCompensator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx index f09b2f3c5c..e3f77354ef 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx @@ -43,7 +43,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../../../utils/equipm import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyShuntCompensator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index 0ab4469fea..7dda76a3e9 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -20,7 +20,7 @@ import { sanitizeString } from '../../../dialogUtils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { createSubstation } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx index 6ebb7afe1f..92330cd59f 100644 --- a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx @@ -16,7 +16,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { CREATIONS_TABLE, REACTIVE_CAPABILITY_CURVE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabularCreation } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils'; +import { FetchStatus } from 'services/utils.js'; import TabularCreationForm from './tabular-creation-form'; import { convertCreationFieldFromBackToFront, diff --git a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx index 6cba2d0d11..f572f2ae94 100644 --- a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx @@ -16,7 +16,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { MODIFICATIONS_TABLE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabulareModification } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils'; +import { FetchStatus } from 'services/utils.js'; import TabularModificationForm from './tabular-modification-form'; import { convertValueFromBackToFront, diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index 9b5600678f..9f3504b66a 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -54,7 +54,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { sanitizeString } from '../../../dialogUtils'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx index eda8a627c7..aa19248651 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx @@ -109,7 +109,7 @@ import { isNodeBuilt } from 'components/graph/util/model-functions'; import RatioTapChangerPane from '../tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane'; import PhaseTapChangerPane from '../tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-utils.js b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-utils.js index e60cc04d13..94575e34c0 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-utils.js +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-utils.js @@ -129,7 +129,7 @@ const phaseTapChangerValidationSchema = (id) => ({ return areNumbersOrdered(alphaArray) && areArrayElementsUnique(alphaArray); }), //regulating terminal fields - //TODO: is it possible to move it to regulating-terminal-utils.js properly since it depends on "ENABLED" ? + //TODO: is it possible to move it to regulating-terminal-utils.ts properly since it depends on "ENABLED" ? [VOLTAGE_LEVEL]: yup .object() .nullable() diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-utils.js b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-utils.js index 92b9b3c213..31760b25ae 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-utils.js +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-utils.js @@ -137,7 +137,7 @@ const ratioTapChangerValidationSchema = (id) => ({ return areNumbersOrdered(ratioArray) && areArrayElementsUnique(ratioArray); }), //regulating terminal fields - //TODO: is it possible to move it to regulating-terminal-utils.js properly since it depends on "ENABLED" ? + //TODO: is it possible to move it to regulating-terminal-utils.ts properly since it depends on "ENABLED" ? [VOLTAGE_LEVEL]: yup .object() .nullable() diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx index 1a6c0180a2..95d1a77e3a 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx @@ -45,7 +45,7 @@ import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { createVoltageLevel } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx index 7ac959a5f9..a3f9f8fac6 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx @@ -29,7 +29,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyVoltageLevel } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx index bbfdc893be..34e619b338 100644 --- a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx @@ -39,7 +39,7 @@ import { getVscHvdcLinePaneSchema, getVscHvdcLineTabFormData, } from '../hvdc-line-pane/vsc-hvdc-line-pane-utils'; -import { FetchStatus } from '../../../../../services/utils'; +import { FetchStatus } from '../../../../../services/utils.js'; import { getConverterStationCreationData, getConverterStationFormEditData, diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx index e7c9e7d46b..1a90038251 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx @@ -27,7 +27,7 @@ import { RunningStatus } from '../../utils/running-status'; import { useOpenLoaderShortWait } from '../../dialogs/commons/handle-loader'; import { RESULTS_LOADING_DELAY } from '../../network/constants'; import { exportSensitivityResultsAsCsv } from '../../../services/study/sensitivity-analysis'; -import { downloadZipFile } from '../../../services/utils'; +import { downloadZipFile } from '../../../services/utils.js'; import { useSnackMessage } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { ExportButton } from '../../utils/export-button'; diff --git a/src/components/voltage-init-result.jsx b/src/components/voltage-init-result.jsx index af10579092..fa24ffb8d7 100644 --- a/src/components/voltage-init-result.jsx +++ b/src/components/voltage-init-result.jsx @@ -23,7 +23,7 @@ import { import CircularProgress from '@mui/material/CircularProgress'; import { Box } from '@mui/system'; import VoltageInitModificationDialog from './dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog'; -import { FetchStatus } from '../services/utils'; +import { FetchStatus } from '../services/utils.js'; import { ComputationReportViewer } from './results/common/computation-report-viewer'; import { useOpenLoaderShortWait } from './dialogs/commons/handle-loader'; import { RunningStatus } from './utils/running-status'; diff --git a/src/redux/user-store.ts b/src/redux/user-store.ts index d6c945a407..77df67e730 100644 --- a/src/redux/user-store.ts +++ b/src/redux/user-store.ts @@ -11,7 +11,7 @@ */ /* at src/redux/store.ts:12:33 - at src/services/utils.js:7:1 + at src/services/utils.ts:7:1 at src/services/study/index.ts:8:1 at src/components/utils/inputs/input-hooks.jsx:41:1 at src/components/dialogs/commons/modification-dialog-content.jsx:19:1 diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index ca965fd4a5..f8afd43c96 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -5,7 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ConverterStationElementModificationInfos } from '../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; +import { + ConverterStationElementModificationInfos, + ReactiveCapabilityCurvePointsData, +} from '../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; +import { UUID } from 'crypto'; +import { Property } from '../components/dialogs/network-modifications/common/properties/property-utils'; +import { MODIFICATION_TYPE } from '../components/utils/modification-type'; +import { + DataType, + FieldValue, +} from '../components/dialogs/network-modifications/by-filter/by-assignment/assignment/assignment.type'; +import { Filter } from '../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; export interface HvdcAngleDroopActivePowerControlInfo { isEnabled: boolean; @@ -37,3 +48,307 @@ export interface VscModificationInfo { connectionPosition?: string | null; terminalConnected?: boolean | null; } + +type AttributeModification = { value: T; op: string }; + +export interface BatteryModificationInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid?: string; + batteryId: string; + name: string | null; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + connectionName?: string | null; + connectionDirection?: string | null; + connectionPosition?: string | null; + terminalConnected?: boolean | null; + minP: number | null; + maxP: number | null; + isReactiveCapabilityCurveOn?: boolean; + minQ?: number | null; + maxQ?: number | null; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData | undefined; + targetP: number; + targetQ: number; + participate: boolean; + droop: number; + isUpdate?: boolean; + properties?: Property[]; +} + +export interface LoadModificationInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid?: string; + id: string; + name: string | null; + loadType: string; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + connectionName?: string | null; + connectionDirection?: string | null; + connectionPosition?: string | null; + terminalConnected?: boolean | null; + p0: number; + q0: number; + isUpdate?: boolean; + properties?: Property[]; +} + +export interface ShuntCompensatorModificationInfo { + studyUuid: string; + nodeUuid: UUID; + shuntCompensatorId: string; + shuntCompensatorName: string | null; + maxSusceptance: number | null; + maxQAtNominalV: number | null; + shuntCompensatorType: string; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + sectionCount: number; + maximumSectionCount: number; + connectivity?: any; + isUpdate?: boolean; + modificationUuid?: string; + connectionDirection?: string | null; + connectionName?: string | null; + connectionPosition?: string | null; + terminalConnected?: boolean | null; + properties?: Property[]; +} + +export interface GeneratorModificationInfo { + studyUuid: string; + nodeUuid: UUID; + generatorId: string; + name: string | null; + energySource: string; + minP: number; + maxP: number; + ratedS?: number | null; + targetP: number | null; + targetQ: number | null; + voltageRegulation: boolean; + targetV: number | null; + qPercent: number | null; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + isUpdate?: boolean; + modificationUuid?: string; + plannedActivePowerSetPoint: number; + marginalCost: number; + plannedOutageRate: number; + forcedOutageRate: number; + directTransX: number; + stepUpTransformerX: number; + voltageRegulationType?: any; + regulatingTerminalId: string | null; + regulatingTerminalType: string | null; + regulatingTerminalVlId: string | null; + isReactiveCapabilityCurveOn?: boolean; + participate: boolean; + droop: number | null; + maxQ?: number | null; + minQ?: number | null; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData[] | undefined; + connectionDirection?: string | null; + connectionName?: string | null; + connectionPosition?: string | null; + terminalConnected?: boolean | null; + properties?: Property[]; +} + +export interface StaticVarCompensatorCreationInfo { + studyUuid: string; + nodeUuid: UUID; + staticCompensatorId: string; + staticCompensatorName: string | null; + voltageLevelId: string; + busOrBusbarSectionId?: string; + connectionDirection?: string | null; + connectionName?: string | null; + connectionPosition?: string | null; + terminalConnected?: boolean | null; + maxSusceptance: number | null; + minSusceptance: number | null; + maxQAtNominalV: number | null; + minQAtNominalV: number | null; + regulationMode: string; + voltageSetpoint: number; + reactivePowerSetpoint: number; + voltageRegulationType: string; + regulatingTerminalId: string | null; + regulatingTerminalType: string | null; + regulatingTerminalVlId: string | null; + standbyAutomatonOn: boolean; + standby: boolean; + lowVoltageSetpoint: number | null; + highVoltageSetpoint: number | null; + lowVoltageThreshold: number | null; + highVoltageThreshold: number | null; + b0: number | null; + q0: number | null; + isUpdate?: boolean; + modificationUuid: string; + properties?: Property[]; +} + +export interface TwoWindingsTransformerModificationInfo { + studyUuid: string; + nodeUuid: UUID; + twoWindingsTransformerId: string; + twoWindingsTransformerName: AttributeModification | null; + r: AttributeModification | null; + x: AttributeModification | null; + g: AttributeModification | null; + b: AttributeModification | null; + ratedS: AttributeModification | null; + ratedU1: AttributeModification | null; + ratedU2: AttributeModification | null; + currentLimit1?: CurrentLimits; + currentLimit2?: CurrentLimits; + voltageLevelId1?: string; + busOrBusbarSectionId1?: string; + voltageLevelId2?: string; + busOrBusbarSectionId2?: string; + ratioTapChanger: any; + phaseTapChanger: any; + isUpdate?: boolean; + modificationUuid?: string; + connectionName1?: string | null; + connectionDirection1?: string | null; + connectionName2?: string | null; + connectionDirection2?: string | null; + connectionPosition1?: string | null; + connectionPosition2?: string | null; + connected1?: boolean; + connected2?: boolean; + properties: Property[]; +} + +export interface TemporaryLimit { + value: number | null; + acceptableDuration: number | null; + modificationType: string | null; + selected: boolean; + name: string; +} +export interface CurrentLimits { + permanentLimit: number; + temporaryLimits: TemporaryLimit[]; +} + +export interface SubstationModificationInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid?: UUID; + id: string; + name: string | null; + country: string; + properties?: Property[]; +} + +export interface VoltageLeveInfo { + studyUuid: string; + nodeUuid: UUID; + voltageLevelId: string; + voltageLevelName: string | null; + substationId?: string | null; + nominalV: number | null; + lowVoltageLimit: number | null; + highVoltageLimit: number | null; + busbarCount?: number; + sectionCount?: number; + switchKinds?: any[]; + couplingDevices?: any[]; + isUpdate?: boolean; + modificationUuid?: UUID; + properties?: Property[]; +} + +export interface VoltageLeveCreationlInfo extends VoltageLeveInfo { + ipMin: number | null; + ipMax: number | null; +} +export interface VoltageLeveModificationInfo extends VoltageLeveInfo { + lowShortCircuitCurrentLimit: number | null; + highShortCircuitCurrentLimit: number | null; +} + +export interface AttachmentLine { + type: string; + equipmentId: string; + equipmentName: string | null; + r: number; + x: number; + g1: number; + b1: number; + g2: number; + b2: number; + currentLimits1: CurrentLimits; + currentLimits2: CurrentLimits; +} +type VariationFilter = { + id: string; + name: string; + specificMetadata: { type: string }; +}; +export interface Variations { + variationMode: string | null; + variationValue: number | null; + reactiveVariationMode: string | null; + filters: VariationFilter[]; +} + +export interface VSCCreationConverterStation { + type: MODIFICATION_TYPE; + equipmentId: string; + equipmentName: string | null; + lossFactor: number; + voltageSetpoint: number | null; + reactivePowerSetpoint: number | null; + voltageLevelId: string; + busOrBusbarSectionId: string; + connectionName: string | null; + connectionDirection: string | null; + connectionPosition: string | null; + voltageRegulationOn: boolean; + reactiveCapabilityCurve: boolean; + minQ: number | null; + maxQ: number | null; + reactiveCapabilityCurvePoints: ReactiveCapabilityCurvePointsData[]; +} + +export interface VSCModificationConverterStation { + voltageSetpoint: AttributeModification | null; + lossFactor: AttributeModification | null; + reactiveCapabilityCurve: AttributeModification | null; + busOrBusbarSectionId: AttributeModification | null; + type: MODIFICATION_TYPE; + minQ: AttributeModification | null; + equipmentId: string; + reactiveCapabilityCurvePoints: + | { + p: number | null; + oldP: number | null; + minQ: number | null; + oldMinQ: number | null; + maxQ: number | null; + oldMaxQ: number | null; + }[] + | null; + voltageLevelId: AttributeModification | null; + reactivePowerSetpoint: AttributeModification | null; + equipmentName: AttributeModification | null; + voltageRegulationOn: AttributeModification | null; + maxQ: AttributeModification | null; +} + +export interface Assignment { + dataType: DataType | undefined; + value: FieldValue | undefined; + filters: Filter[]; + editedField: string; + propertyName?: string | undefined; +} diff --git a/src/services/study/dynamic-simulation.js b/src/services/study/dynamic-simulation.js index 80bb7e7b21..dfaf2ad713 100644 --- a/src/services/study/dynamic-simulation.js +++ b/src/services/study/dynamic-simulation.js @@ -7,7 +7,7 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; -import { backendFetch, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils'; +import { backendFetch, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils.js'; export function getDynamicMappings(studyUuid) { console.info(`Fetching dynamic mappings on '${studyUuid}' ...`); diff --git a/src/services/study/geo-data.ts b/src/services/study/geo-data.ts index b1cf84a8a5..83157fb3da 100644 --- a/src/services/study/geo-data.ts +++ b/src/services/study/geo-data.ts @@ -9,7 +9,11 @@ import { backendFetchJson, getQueryParamsList } from '../utils'; import { getStudyUrlWithNodeUuid } from './index'; import { UUID } from 'crypto'; -export function fetchSubstationPositions(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[]) { +export function fetchSubstationPositions( + studyUuid: UUID, + currentNodeUuid: UUID | undefined, + substationsIds?: string[] +) { console.info( `Fetching substation positions of study '${studyUuid}' and node '${currentNodeUuid}' with ids '${substationsIds}'...` ); @@ -23,7 +27,7 @@ export function fetchSubstationPositions(studyUuid: UUID, currentNodeUuid: UUID, return backendFetchJson(fetchSubstationPositionsUrl); } -export function fetchLinePositions(studyUuid: UUID, currentNodeUuid: UUID, linesIds: string[]) { +export function fetchLinePositions(studyUuid: UUID, currentNodeUuid: UUID | undefined, linesIds?: string[]) { console.info( `Fetching line positions of study '${studyUuid}' and node '${currentNodeUuid}' with ids '${linesIds}'...` ); diff --git a/src/services/study/index.ts b/src/services/study/index.ts index e820a49859..2eafc7f953 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -25,7 +25,10 @@ export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; export const getStudyUrl = (studyUuid: UUID) => `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}`; -export const getStudyUrlWithNodeUuid = (studyUuid: UUID | string | null, nodeUuid: UUID | undefined) => +export const getStudyUrlWithNodeUuid = ( + studyUuid: UUID | string | null | undefined, + nodeUuid: UUID | string | undefined +) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/nodes/${safeEncodeURIComponent(nodeUuid)}`; export const fetchStudy = (studyUuid: UUID) => { @@ -117,7 +120,7 @@ export function fetchNodeReportLogs( return backendFetchJson(url); } -export function fetchSvg(svgUrl: string | null) { +export function fetchSvg(svgUrl: string) { console.debug(svgUrl); return backendFetch(svgUrl).then((response) => (response.status === 204 ? null : response.json())); } diff --git a/src/services/study/network-modifications.js b/src/services/study/network-modifications.ts similarity index 78% rename from src/services/study/network-modifications.js rename to src/services/study/network-modifications.ts index 5fa810f1eb..78f7029558 100644 --- a/src/services/study/network-modifications.js +++ b/src/services/study/network-modifications.ts @@ -8,15 +8,43 @@ import { MODIFICATION_TYPES } from '../../components/utils/modification-type'; import { toModificationOperation, toModificationUnsetOperation } from '../../components/utils/utils'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; -import { getStudyUrlWithNodeUuid } from './index'; +import { getStudyUrlWithNodeUuid, safeEncodeURIComponent } from './index'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { BRANCH_SIDE, OPERATING_STATUS_ACTION } from '../../components/network/constants'; - -function getNetworkModificationUrl(studyUuid, nodeUuid) { +import { UUID } from 'crypto'; +import { EquipmentInfos, EquipmentType } from '@gridsuite/commons-ui'; +import { ReactiveCapabilityCurvePointsData } from '../../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; +import { Property } from '../../components/dialogs/network-modifications/common/properties/property-utils'; +import { + Assignment, + AttachmentLine, + BatteryModificationInfo, + CurrentLimits, + GeneratorModificationInfo, + LoadModificationInfo, + ShuntCompensatorModificationInfo, + StaticVarCompensatorCreationInfo, + SubstationModificationInfo, + TemporaryLimit, + TwoWindingsTransformerModificationInfo, + Variations, + VoltageLeveCreationlInfo, + VoltageLeveModificationInfo, + VSCCreationConverterStation, + VSCModificationConverterStation, +} from '../network-modification-types'; +import { Filter } from '../../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; + +function getNetworkModificationUrl(studyUuid: UUID | string | null | undefined, nodeUuid: UUID | string | undefined) { return getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/network-modifications'; } -export function changeNetworkModificationOrder(studyUuid, nodeUuid, itemUuid, beforeUuid) { +export function changeNetworkModificationOrder( + studyUuid: UUID | null, + nodeUuid: UUID | undefined, + itemUuid: UUID, + beforeUuid: UUID +) { console.info('reorder node ' + nodeUuid + ' of study ' + studyUuid + ' ...'); const url = getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + @@ -28,10 +56,10 @@ export function changeNetworkModificationOrder(studyUuid, nodeUuid, itemUuid, be return backendFetch(url, { method: 'put' }); } -export function stashModifications(studyUuid, nodeUuid, modificationUuids) { +export function stashModifications(studyUuid: UUID | null, nodeUuid: UUID | undefined, modificationUuids: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('stashed', true); - urlSearchParams.append('uuids', modificationUuids); + urlSearchParams.append('stashed', 'true'); + urlSearchParams.append('uuids', String(modificationUuids)); const modificationDeleteUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(modificationDeleteUrl); return backendFetch(modificationDeleteUrl, { @@ -39,10 +67,15 @@ export function stashModifications(studyUuid, nodeUuid, modificationUuids) { }); } -export function setModificationActivated(studyUuid, nodeUuid, modificationUuid, activated) { +export function setModificationActivated( + studyUuid: UUID | null, + nodeUuid: UUID | undefined, + modificationUuid: UUID, + activated: boolean +) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('activated', activated); - urlSearchParams.append('uuids', [modificationUuid]); + urlSearchParams.append('activated', String(activated)); + urlSearchParams.append('uuids', String([modificationUuid])); const modificationUpdateActiveUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(modificationUpdateActiveUrl); @@ -51,10 +84,10 @@ export function setModificationActivated(studyUuid, nodeUuid, modificationUuid, }); } -export function restoreModifications(studyUuid, nodeUuid, modificationUuids) { +export function restoreModifications(studyUuid: UUID | null, nodeUuid: UUID | undefined, modificationUuids: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('stashed', false); - urlSearchParams.append('uuids', modificationUuids); + urlSearchParams.append('stashed', 'false'); + urlSearchParams.append('uuids', String(modificationUuids)); const RestoreModificationsUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(RestoreModificationsUrl); @@ -63,9 +96,9 @@ export function restoreModifications(studyUuid, nodeUuid, modificationUuids) { }); } -export function deleteModifications(studyUuid, nodeUuid, modificationUuids) { +export function deleteModifications(studyUuid: UUID | null, nodeUuid: UUID | undefined, modificationUuids: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('uuids', modificationUuids); + urlSearchParams.append('uuids', String(modificationUuids)); const modificationDeleteUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); @@ -75,7 +108,7 @@ export function deleteModifications(studyUuid, nodeUuid, modificationUuids) { }); } -export function requestNetworkChange(studyUuid, nodeUuid, groovyScript) { +export function requestNetworkChange(studyUuid: string, nodeUuid: UUID, groovyScript: string) { console.info('Creating groovy script (request network change)'); const changeUrl = getNetworkModificationUrl(studyUuid, nodeUuid); console.debug(changeUrl); @@ -92,17 +125,22 @@ export function requestNetworkChange(studyUuid, nodeUuid, groovyScript) { }); } -function changeOperatingStatus(studyUuid, nodeUuid, equipment, action) { +function changeOperatingStatus( + studyUuid: UUID | undefined | null, + nodeUuid: UUID | undefined, + equipment: Partial | null, + action: string +) { const changeOperatingStatusUrl = getNetworkModificationUrl(studyUuid, nodeUuid); console.debug('%s with action: %s', changeOperatingStatusUrl, action); let energizedVoltageLevelId; switch (action) { case OPERATING_STATUS_ACTION.ENERGISE_END_ONE: - energizedVoltageLevelId = equipment.voltageLevelId1; + energizedVoltageLevelId = equipment?.voltageLevelId1; break; case OPERATING_STATUS_ACTION.ENERGISE_END_TWO: - energizedVoltageLevelId = equipment.voltageLevelId2; + energizedVoltageLevelId = equipment?.voltageLevelId2; break; default: energizedVoltageLevelId = undefined; @@ -116,25 +154,38 @@ function changeOperatingStatus(studyUuid, nodeUuid, equipment, action) { }, body: JSON.stringify({ type: MODIFICATION_TYPES.OPERATING_STATUS_MODIFICATION.type, - equipmentId: equipment.id, + equipmentId: equipment?.id, energizedVoltageLevelId: energizedVoltageLevelId, action: action, }), }); } -export function lockoutEquipment(studyUuid, nodeUuid, equipment) { - console.info('locking out equipment ' + equipment.id + ' ...'); +export function lockoutEquipment( + studyUuid: UUID | undefined, + nodeUuid: UUID | undefined, + equipment: EquipmentInfos | null +) { + console.info('locking out equipment ' + equipment?.id + ' ...'); return changeOperatingStatus(studyUuid, nodeUuid, equipment, OPERATING_STATUS_ACTION.LOCKOUT); } -export function tripEquipment(studyUuid, nodeUuid, equipment) { - console.info('tripping equipment ' + equipment.id + ' ...'); +export function tripEquipment( + studyUuid: UUID | undefined | null, + nodeUuid: UUID | undefined, + equipment: Partial | null +) { + console.info('tripping equipment ' + equipment?.id + ' ...'); return changeOperatingStatus(studyUuid, nodeUuid, equipment, OPERATING_STATUS_ACTION.TRIP); } -export function energiseEquipmentEnd(studyUuid, nodeUuid, branch, branchSide) { - console.info('energise branch ' + branch.id + ' on side ' + branchSide + ' ...'); +export function energiseEquipmentEnd( + studyUuid: UUID | undefined, + nodeUuid: UUID | undefined, + branch: EquipmentInfos | null, + branchSide: string +) { + console.info('energise branch ' + branch?.id + ' on side ' + branchSide + ' ...'); return changeOperatingStatus( studyUuid, nodeUuid, @@ -145,21 +196,25 @@ export function energiseEquipmentEnd(studyUuid, nodeUuid, branch, branchSide) { ); } -export function switchOnEquipment(studyUuid, nodeUuid, branch) { - console.info('switching on branch ' + branch.id + ' ...'); +export function switchOnEquipment( + studyUuid: UUID | undefined, + nodeUuid: UUID | undefined, + branch: EquipmentInfos | null +) { + console.info('switching on branch ' + branch?.id + ' ...'); return changeOperatingStatus(studyUuid, nodeUuid, branch, OPERATING_STATUS_ACTION.SWITCH_ON); } export function generationDispatch( - studyUuid, - nodeUuid, - modificationUuid, - lossCoefficient, - defaultOutageRate, - generatorsWithoutOutage, - generatorsWithFixedActivePower, - generatorsFrequencyReserve, - substationsGeneratorsOrdering + studyUuid: UUID, + nodeUuid: UUID, + modificationUuid: UUID | undefined, + lossCoefficient: number, + defaultOutageRate: number, + generatorsWithoutOutage: any, + generatorsWithFixedActivePower: any, + generatorsFrequencyReserve: any, + substationsGeneratorsOrdering: any ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.GENERATION_DISPATCH.type, @@ -189,7 +244,13 @@ export function generationDispatch( }); } -export function generatorScaling(studyUuid, nodeUuid, modificationUuid, variationType, variations) { +export function generatorScaling( + studyUuid: UUID, + nodeUuid: UUID, + modificationUuid: UUID | undefined, + variationType: string, + variations: any[] +) { const body = JSON.stringify({ type: MODIFICATION_TYPES.GENERATOR_SCALING.type, variationType, @@ -209,33 +270,35 @@ export function generatorScaling(studyUuid, nodeUuid, modificationUuid, variatio 'Content-Type': 'application/json', }, body, - }).then((response) => (response.ok ? response.text() : response.text().then((text) => Promise.reject(text)))); + }).then((response) => + response.ok ? response.text() : response.text().then((text: string) => Promise.reject(text)) + ); } export function createBattery( - studyUuid, - nodeUuid, - id, - name, - voltageLevelId, - busOrBusbarSectionId, - connectionName, - connectionDirection, - connectionPosition, - terminalConnected, - minP, - maxP, - isReactiveCapabilityCurveOn, - minQ, - maxQ, - reactiveCapabilityCurve, - targetP, - targetQ, - participate, - droop, - isUpdate = false, - modificationUuid, - properties + studyUuid: string, + nodeUuid: UUID, + id: string, + name: string | null, + voltageLevelId: string, + busOrBusbarSectionId: string, + connectionName: string | null, + connectionDirection: string | null, + connectionPosition: string | null, + terminalConnected: boolean | null, + minP: number | null, + maxP: number | null, + isReactiveCapabilityCurveOn: boolean, + minQ: number | null, + maxQ: number | null, + reactiveCapabilityCurve: ReactiveCapabilityCurvePointsData | undefined, + targetP: number, + targetQ: number, + participate: boolean, + droop: number, + isUpdate: boolean = false, + modificationUuid: string, + properties: Property[] ) { let createBatteryUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -300,7 +363,7 @@ export function modifyBattery({ minQ = undefined, reactiveCapabilityCurve = undefined, properties, -}) { +}: BatteryModificationInfo) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -344,22 +407,22 @@ export function modifyBattery({ } export function createLoad( - studyUuid, - nodeUuid, - id, - name, - loadType, - p0, - q0, - voltageLevelId, - busOrBusbarSectionId, - isUpdate = false, - modificationUuid, - connectionDirection, - connectionName, - connectionPosition, - terminalConnected, - properties + studyUuid: string, + nodeUuid: UUID, + id: string, + name: string | null, + loadType: string, + p0: number, + q0: number, + voltageLevelId: string, + busOrBusbarSectionId: string, + isUpdate: boolean = false, + modificationUuid: string, + connectionDirection: string | null, + connectionName: string | null, + connectionPosition: string | null, + terminalConnected: boolean | null, + properties: Property[] ) { let createLoadUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -410,7 +473,7 @@ export function modifyLoad({ connectionPosition = undefined, terminalConnected = undefined, properties, -}) { +}: LoadModificationInfo) { let modifyLoadUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -483,7 +546,7 @@ export function modifyGenerator({ minQ = undefined, reactiveCapabilityCurve = undefined, properties, -}) { +}: GeneratorModificationInfo) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -542,43 +605,43 @@ export function modifyGenerator({ } export function createGenerator( - studyUuid, - nodeUuid, - id, - name, - energySource, - minP, - maxP, - ratedS, - targetP, - targetQ, - voltageRegulationOn, - targetV, - qPercent, - voltageLevelId, - busOrBusbarSectionId, - isUpdate = false, - modificationUuid, - plannedActivePowerSetPoint, - marginalCost, - plannedOutageRate, - forcedOutageRate, - directTransX, - stepUpTransformerX, - regulatingTerminalId, - regulatingTerminalType, - regulatingTerminalVlId, - isReactiveCapabilityCurveOn, - participate, - droop, - maxQ, - minQ, - reactiveCapabilityCurve, - connectionDirection, - connectionName, - connectionPosition, - terminalConnected, - properties + studyUuid: string, + nodeUuid: UUID, + id: string, + name: string | null, + energySource: string, + minP: number, + maxP: number, + ratedS: number | null, + targetP: number | null, + targetQ: number | null, + voltageRegulationOn: boolean, + targetV: number | null, + qPercent: number | null, + voltageLevelId: string, + busOrBusbarSectionId: string, + isUpdate: boolean = false, + modificationUuid: string, + plannedActivePowerSetPoint: number, + marginalCost: number, + plannedOutageRate: number, + forcedOutageRate: number, + directTransX: number, + stepUpTransformerX: number, + regulatingTerminalId: string | null, + regulatingTerminalType: string | null, + regulatingTerminalVlId: string | null, + isReactiveCapabilityCurveOn: boolean, + participate: boolean, + droop: number | null, + maxQ: number | null, + minQ: number | null, + reactiveCapabilityCurve: ReactiveCapabilityCurvePointsData[] | undefined, + connectionDirection: string | null, + connectionName: string | null, + connectionPosition: string | null, + terminalConnected: boolean | null, + properties: Property[] ) { let createGeneratorUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -635,23 +698,23 @@ export function createGenerator( } export function createShuntCompensator( - studyUuid, - nodeUuid, - shuntCompensatorId, - shuntCompensatorName, - maxSusceptance, - maxQAtNominalV, - shuntCompensatorType, - sectionCount, - maximumSectionCount, - connectivity, - isUpdate, - modificationUuid, - connectionDirection, - connectionName, - connectionPosition, - terminalConnected, - properties + studyUuid: string, + nodeUuid: UUID, + shuntCompensatorId: string, + shuntCompensatorName: string | null, + maxSusceptance: number | null, + maxQAtNominalV: number | null, + shuntCompensatorType: string, + sectionCount: number, + maximumSectionCount: number, + connectivity: any, + isUpdate: boolean, + modificationUuid: string, + connectionDirection: string | null, + connectionName: string | null, + connectionPosition: string | null, + terminalConnected: boolean | null, + properties: Property[] ) { let createShuntUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -706,7 +769,7 @@ export function modifyShuntCompensator({ connectionPosition = undefined, terminalConnected = undefined, properties, -}) { +}: ShuntCompensatorModificationInfo) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -743,7 +806,7 @@ export function modifyShuntCompensator({ }); } -export function createStaticVarCompensator(staticVarCompensatorCreationParameters) { +export function createStaticVarCompensator(staticVarCompensatorCreationParameters: StaticVarCompensatorCreationInfo) { const { studyUuid, nodeUuid, @@ -828,35 +891,35 @@ export function createStaticVarCompensator(staticVarCompensatorCreationParameter } export function createLine( - studyUuid, - nodeUuid, - lineId, - lineName, - r, - x, - g1, - b1, - g2, - b2, - voltageLevelId1, - busOrBusbarSectionId1, - voltageLevelId2, - busOrBusbarSectionId2, - permanentCurrentLimit1, - permanentCurrentLimit2, - temporaryCurrentLimits1, - temporaryCurrentLimits2, - isUpdate, - modificationUuid, - connectionName1, - connectionDirection1, - connectionName2, - connectionDirection2, - connectionPosition1, - connectionPosition2, - connected1, - connected2, - properties + studyUuid: string, + nodeUuid: UUID, + lineId: string, + lineName: string | null, + r: number, + x: number, + g1: number, + b1: number, + g2: number, + b2: number, + voltageLevelId1: string, + busOrBusbarSectionId1: string, + voltageLevelId2: string, + busOrBusbarSectionId2: string, + permanentCurrentLimit1: number, + permanentCurrentLimit2: number, + temporaryCurrentLimits1: TemporaryLimit[], + temporaryCurrentLimits2: TemporaryLimit[], + isUpdate: boolean, + modificationUuid: string, + connectionName1: string | null, + connectionDirection1: string | null, + connectionName2: string | null, + connectionDirection2: string | null, + connectionPosition1: string | null, + connectionPosition2: string | null, + connected1: boolean, + connected2: boolean, + properties: Property[] ) { let createLineUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -909,33 +972,33 @@ export function createLine( } export function modifyLine( - studyUuid, - nodeUuid, - lineId, - lineName, - r, - x, - g1, - b1, - g2, - b2, - currentLimit1, - currentLimit2, - voltageLevelId1, - busOrBusbarSectionId1, - voltageLevelId2, - busOrBusbarSectionId2, - connectionName1, - connectionName2, - connectionDirection1, - connectionDirection2, - connectionPosition1, - connectionPosition2, - connected1, - connected2, - isUpdate, - modificationUuid, - properties + studyUuid: string, + nodeUuid: UUID, + lineId: string, + lineName: string | null, + r: number, + x: number, + g1: number, + b1: number, + g2: number, + b2: number, + currentLimit1: CurrentLimits, + currentLimit2: CurrentLimits, + voltageLevelId1: string, + busOrBusbarSectionId1: string, + voltageLevelId2: string, + busOrBusbarSectionId2: string, + connectionName1: string | null, + connectionName2: string | null, + connectionDirection1: string | null, + connectionDirection2: string | null, + connectionPosition1: string | null, + connectionPosition2: string | null, + connected1: boolean, + connected2: boolean, + isUpdate: boolean, + modificationUuid: string, + properties: Property[] ) { let modifyLineUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -982,36 +1045,36 @@ export function modifyLine( } export function createTwoWindingsTransformer( - studyUuid, - nodeUuid, - twoWindingsTransformerId, - twoWindingsTransformerName, - r, - x, - g, - b, - ratedS, - ratedU1, - ratedU2, - currentLimit1, - currentLimit2, - voltageLevelId1, - busOrBusbarSectionId1, - voltageLevelId2, - busOrBusbarSectionId2, - ratioTapChanger, - phaseTapChanger, - isUpdate, - modificationUuid, - connectionName1, - connectionDirection1, - connectionName2, - connectionDirection2, - connectionPosition1, - connectionPosition2, - connected1, - connected2, - properties + studyUuid: string, + nodeUuid: UUID, + twoWindingsTransformerId: string, + twoWindingsTransformerName: string | null, + r: number, + x: number, + g: number, + b: number, + ratedS: number | null, + ratedU1: number, + ratedU2: number, + currentLimit1: CurrentLimits, + currentLimit2: CurrentLimits, + voltageLevelId1: string, + busOrBusbarSectionId1: string, + voltageLevelId2: string, + busOrBusbarSectionId2: string, + ratioTapChanger: any, + phaseTapChanger: any, + isUpdate: boolean, + modificationUuid: string, + connectionName1: string | null, + connectionDirection1: string | null, + connectionName2: string | null, + connectionDirection2: string | null, + connectionPosition1: string | null, + connectionPosition2: string | null, + connected1: boolean, + connected2: boolean, + properties: Property[] ) { let createTwoWindingsTransformerUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -1090,7 +1153,7 @@ export function modifyTwoWindingsTransformer({ connected1 = undefined, connected2 = undefined, properties: propertiesForBackend, -}) { +}: TwoWindingsTransformerModificationInfo) { let modifyTwoWindingsTransformerUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -1140,12 +1203,12 @@ export function modifyTwoWindingsTransformer({ } export function createTabulareModification( - studyUuid, - nodeUuid, - modificationType, - modifications, - isUpdate, - modificationUuid + studyUuid: string, + nodeUuid: UUID, + modificationType: string, + modifications: any, + isUpdate: boolean, + modificationUuid: UUID ) { let createTabulareModificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -1171,14 +1234,14 @@ export function createTabulareModification( } export function createSubstation( - studyUuid, - nodeUuid, - substationId, - substationName, - country, - isUpdate = false, - modificationUuid, - properties + studyUuid: string, + nodeUuid: UUID, + substationId: string, + substationName: string | null, + country: string, + isUpdate: boolean = false, + modificationUuid: UUID, + properties?: Property[] ) { let url = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -1211,7 +1274,7 @@ export function createSubstation( * Formats the properties of an array of properties so it can be consumed by the backend. * @returns {Array<{name: string, value: string, previousValue: string, added: boolean, deletionMark: boolean} | null>} - The modified properties. */ -export function formatPropertiesForBackend(previousProperties, newProperties) { +export function formatPropertiesForBackend(previousProperties: any, newProperties: any) { if (JSON.stringify(previousProperties) === JSON.stringify(newProperties)) { // return null so the backend does not update the properties return null; @@ -1221,7 +1284,7 @@ export function formatPropertiesForBackend(previousProperties, newProperties) { const previousPropertiesArray = Object.entries(previousProperties).map(([name, value]) => ({ name, value })); const newPropertiesArray = Object.entries(newProperties).map(([name, value]) => ({ name, value })); - const propertiesModifications = []; + const propertiesModifications: any = []; previousPropertiesArray.forEach((previousPropertiePair) => { const updatedProperty = newPropertiesArray.find((updatedObj) => updatedObj.name === previousPropertiePair.name); @@ -1259,7 +1322,15 @@ export function formatPropertiesForBackend(previousProperties, newProperties) { return propertiesModifications; } -export function modifySubstation({ studyUuid, nodeUuid, modificationUuid = undefined, id, name, country, properties }) { +export function modifySubstation({ + studyUuid, + nodeUuid, + modificationUuid = undefined, + id, + name, + country, + properties, +}: SubstationModificationInfo) { let modifyUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -1304,11 +1375,11 @@ export function createVoltageLevel({ isUpdate, modificationUuid, properties, -}) { +}: VoltageLeveCreationlInfo) { let createVoltageLevelUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { - createVoltageLevelUrl += '/' + encodeURIComponent(modificationUuid); + createVoltageLevelUrl += '/' + safeEncodeURIComponent(modificationUuid); console.info('Updating voltage level creation'); } else { console.info('Creating voltage level creation'); @@ -1353,7 +1424,7 @@ export function modifyVoltageLevel({ lowShortCircuitCurrentLimit, highShortCircuitCurrentLimit, properties, -}) { +}: VoltageLeveModificationInfo) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); const isUpdate = !!modificationUuid; @@ -1385,18 +1456,18 @@ export function modifyVoltageLevel({ } export function divideLine( - studyUuid, - nodeUuid, - modificationUuid, - lineToSplitId, - percent, - mayNewVoltageLevelInfos, - existingVoltageLevelId, - bbsOrBusId, - newLine1Id, - newLine1Name, - newLine2Id, - newLine2Name + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID, + lineToSplitId: string, + percent: number, + mayNewVoltageLevelInfos: any | null, + existingVoltageLevelId: string, + bbsOrBusId: string, + newLine1Id: string, + newLine1Name: string | null, + newLine2Id: string, + newLine2Name: string | null ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINE_SPLIT_WITH_VOLTAGE_LEVEL.type, @@ -1431,21 +1502,21 @@ export function divideLine( } export function attachLine( - studyUuid, - nodeUuid, - modificationUuid, - lineToAttachToId, - percent, - attachmentPointId, - attachmentPointName, - mayNewVoltageLevelInfos, - existingVoltageLevelId, - bbsOrBusId, - attachmentLine, - newLine1Id, - newLine1Name, - newLine2Id, - newLine2Name + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID, + lineToAttachToId: string, + percent: number, + attachmentPointId: string, + attachmentPointName: string | null, + mayNewVoltageLevelInfos: any | null, + existingVoltageLevelId: string, + bbsOrBusId: string, + attachmentLine: AttachmentLine, + newLine1Id: string, + newLine1Name: string | null, + newLine2Id: string, + newLine2Name: string | null ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINE_ATTACH_TO_VOLTAGE_LEVEL.type, @@ -1482,7 +1553,13 @@ export function attachLine( }); } -export function loadScaling(studyUuid, nodeUuid, modificationUuid, variationType, variations) { +export function loadScaling( + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID | undefined, + variationType: string, + variations: Variations +) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LOAD_SCALING.type, variationType, @@ -1502,22 +1579,24 @@ export function loadScaling(studyUuid, nodeUuid, modificationUuid, variationType 'Content-Type': 'application/json', }, body, - }).then((response) => (response.ok ? response.text() : response.text().then((text) => Promise.reject(text)))); + }).then((response) => + response.ok ? response.text() : response.text().then((text: string) => Promise.reject(text)) + ); } export function linesAttachToSplitLines( - studyUuid, - nodeUuid, - modificationUuid, - lineToAttachTo1Id, - lineToAttachTo2Id, - attachedLineId, - voltageLevelId, - bbsBusId, - replacingLine1Id, - replacingLine1Name, - replacingLine2Id, - replacingLine2Name + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID, + lineToAttachTo1Id: string, + lineToAttachTo2Id: string, + attachedLineId: string, + voltageLevelId: string, + bbsBusId: string, + replacingLine1Id: string, + replacingLine1Name: string | null, + replacingLine2Id: string, + replacingLine2Name: string | null ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINES_ATTACH_TO_SPLIT_LINES.type, @@ -1552,13 +1631,13 @@ export function linesAttachToSplitLines( } export function deleteVoltageLevelOnLine( - studyUuid, - nodeUuid, - modificationUuid, - lineToAttachTo1Id, - lineToAttachTo2Id, - replacingLine1Id, - replacingLine1Name + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID, + lineToAttachTo1Id: string, + lineToAttachTo2Id: string, + replacingLine1Id: string, + replacingLine1Name: string | null ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.DELETE_VOLTAGE_LEVEL_ON_LINE.type, @@ -1587,14 +1666,14 @@ export function deleteVoltageLevelOnLine( } export function deleteAttachingLine( - studyUuid, - nodeUuid, - modificationUuid, - lineToAttachTo1Id, - lineToAttachTo2Id, - attachedLineId, - replacingLine1Id, - replacingLine1Name + studyUuid: string, + nodeUuid: UUID, + modificationUuid: UUID, + lineToAttachTo1Id: string, + lineToAttachTo2Id: string, + attachedLineId: string, + replacingLine1Id: string, + replacingLine1Name: string | null ) { const body = JSON.stringify({ type: MODIFICATION_TYPES.DELETE_ATTACHING_LINE.type, @@ -1623,7 +1702,14 @@ export function deleteAttachingLine( }); } -export function deleteEquipment(studyUuid, nodeUuid, equipmentType, equipmentId, modificationUuid, equipmentInfos) { +export function deleteEquipment( + studyUuid: string, + nodeUuid: UUID | undefined, + equipmentType: EquipmentType | string | null, + equipmentId: string, + modificationUuid: UUID | undefined, + equipmentInfos: any = undefined +) { let deleteEquipmentUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (modificationUuid) { @@ -1648,7 +1734,13 @@ export function deleteEquipment(studyUuid, nodeUuid, equipmentType, equipmentId, }); } -export function deleteEquipmentByFilter(studyUuid, nodeUuid, equipmentType, filters, modificationUuid) { +export function deleteEquipmentByFilter( + studyUuid: string, + nodeUuid: string, + equipmentType: keyof typeof EQUIPMENT_TYPES | null, + filters: Filter[], + modificationUuid: string +) { let deleteEquipmentUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (modificationUuid) { @@ -1672,17 +1764,17 @@ export function deleteEquipmentByFilter(studyUuid, nodeUuid, equipmentType, filt }); } -export function fetchNetworkModifications(studyUuid, nodeUuid, onlyStashed) { +export function fetchNetworkModifications(studyUuid: UUID | null, nodeUuid: string, onlyStashed: boolean) { console.info('Fetching network modifications (metadata) for nodeUuid : ', nodeUuid); const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('onlyStashed', onlyStashed); - urlSearchParams.append('onlyMetadata', true); + urlSearchParams.append('onlyStashed', String(onlyStashed)); + urlSearchParams.append('onlyMetadata', 'true'); const modificationsGetUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(modificationsGetUrl); return backendFetchJson(modificationsGetUrl); } -export function updateSwitchState(studyUuid, nodeUuid, switchId, open) { +export function updateSwitchState(studyUuid: string, nodeUuid: UUID | undefined, switchId: string, open: boolean) { console.info('updating switch ' + switchId + ' ...'); const updateSwitchUrl = getNetworkModificationUrl(studyUuid, nodeUuid); console.debug(updateSwitchUrl); @@ -1703,25 +1795,25 @@ export function updateSwitchState(studyUuid, nodeUuid, switchId, open) { } export function createVsc( - studyUuid, - nodeUuid, - id, - name, - nominalV, - r, - maxP, - operatorActivePowerLimitSide1, - operatorActivePowerLimitSide2, - convertersMode, - activePowerSetpoint, - angleDroopActivePowerControl, - p0, - droop, - converterStation1, - converterStation2, - properties, - isUpdate, - modificationUuid + studyUuid: string, + nodeUuid: UUID, + id: string, + name: string | null, + nominalV: number, + r: number, + maxP: number, + operatorActivePowerLimitSide1: any, + operatorActivePowerLimitSide2: any, + convertersMode: string, + activePowerSetpoint: number, + angleDroopActivePowerControl: boolean, + p0: number | null, + droop: number | null, + converterStation1: VSCCreationConverterStation, + converterStation2: VSCCreationConverterStation, + properties: Property[] | undefined, + isUpdate: boolean, + modificationUuid: UUID ) { let createVscUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -1762,25 +1854,25 @@ export function createVsc( } export function modifyVsc( - studyUuid, - nodeUuid, - id, - name, - nominalV, - r, - maxP, - operatorActivePowerLimitSide1, - operatorActivePowerLimitSide2, - convertersMode, - activePowerSetpoint, - angleDroopActivePowerControl, - p0, - droop, - converterStation1, - converterStation2, - properties, - isUpdate, - modificationUuid + studyUuid: string, + nodeUuid: UUID, + id: string | null, + name: string | null, + nominalV: number, + r: number, + maxP: number, + operatorActivePowerLimitSide1: any, + operatorActivePowerLimitSide2: any, + convertersMode: string, + activePowerSetpoint: number, + angleDroopActivePowerControl: boolean, + p0: number | null, + droop: number | null, + converterStation1: VSCModificationConverterStation, + converterStation2: VSCModificationConverterStation, + properties: Property[] | undefined, + isUpdate: boolean, + modificationUuid: UUID ) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); @@ -1819,7 +1911,15 @@ export function modifyVsc( body: JSON.stringify(vscModification), }); } -export function modifyByFormula(studyUuid, nodeUuid, equipmentType, formulas, isUpdate, modificationUuid) { + +export function modifyByFormula( + studyUuid: string, + nodeUuid: UUID, + equipmentType: string, + formulas: any, + isUpdate: boolean, + modificationUuid: UUID +) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -1845,11 +1945,18 @@ export function modifyByFormula(studyUuid, nodeUuid, equipmentType, formulas, is }); } -export function modifyByAssignment(studyUuid, nodeUuid, equipmentType, assignmentsList, isUpdate, modificationUuid) { +export function modifyByAssignment( + studyUuid: string, + nodeUuid: UUID, + equipmentType: string, + assignmentsList: Assignment[], + isUpdate: boolean, + modificationUuid: UUID | null +) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { - modificationUrl += '/' + encodeURIComponent(modificationUuid); + modificationUrl += '/' + safeEncodeURIComponent(modificationUuid); console.info('Updating modification by assignment'); } else { console.info('Creating modification by assignment'); @@ -1871,7 +1978,14 @@ export function modifyByAssignment(studyUuid, nodeUuid, equipmentType, assignmen }); } -export function createTabularCreation(studyUuid, nodeUuid, creationType, creations, isUpdate, modificationUuid) { +export function createTabularCreation( + studyUuid: string, + nodeUuid: UUID, + creationType: string, + creations: any, + isUpdate: boolean, + modificationUuid: UUID +) { let createTabularCreationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 4b5f810d6e..55e89416ea 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -9,7 +9,7 @@ import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES, safeEncodeURIComponent } import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { backendFetch, backendFetchJson, backendFetchText, getQueryParamsList, getUrlWithToken } from '../utils'; import { UUID } from 'crypto'; -import { GsLang } from '@gridsuite/commons-ui'; +import { EquipmentType, GsLang } from '@gridsuite/commons-ui'; import { SubstationLayout } from '../../components/diagrams/diagram-common'; /* voltage-levels */ @@ -164,9 +164,9 @@ export function fetchNetworkElementsInfos( } export function fetchNetworkElementInfos( - studyUuid: string, + studyUuid: UUID | string | undefined | null, currentNodeUuid: UUID | undefined, - elementType: EQUIPMENT_TYPES, + elementType: EquipmentType | EQUIPMENT_TYPES, infoType: string, elementId: string, inUpstreamBuiltParentNode: boolean diff --git a/src/services/utils.js b/src/services/utils.ts similarity index 77% rename from src/services/utils.js rename to src/services/utils.ts index fc521e9649..43cf873cc4 100644 --- a/src/services/utils.js +++ b/src/services/utils.ts @@ -13,14 +13,16 @@ export const FetchStatus = { IDLE: 'IDLE', RUNNING: 'RUNNING', }; - +type ErrorType = Error & { + status?: number; +}; export const getWsBase = () => document.baseURI.replace(/^http:\/\//, 'ws://').replace(/^https:\/\//, 'wss://'); -export const getRequestParamFromList = (params, paramName) => { +export const getRequestParamFromList = (params: any[], paramName: string) => { return new URLSearchParams(params?.length ? params.map((param) => [paramName, param]) : []); }; -const parseError = (text) => { +const parseError = (text: string) => { try { return JSON.parse(text); } catch (err) { @@ -28,10 +30,10 @@ const parseError = (text) => { } }; -const handleError = (response) => { +const handleError = (response: Response) => { return response.text().then((text) => { const errorName = 'HttpResponseError : '; - let error; + let error: ErrorType; const errorJson = parseError(text); if (errorJson && errorJson.status && errorJson.error && errorJson.message) { error = new Error( @@ -46,7 +48,7 @@ const handleError = (response) => { }); }; -const prepareRequest = (init, token) => { +const prepareRequest = (init: any, token: string | undefined) => { if (!(typeof init == 'undefined' || typeof init == 'object')) { throw new TypeError('Argument 2 of backendFetch is not an object' + typeof init); } @@ -57,26 +59,26 @@ const prepareRequest = (init, token) => { return initCopy; }; -const safeFetch = (url, initCopy) => { - return fetch(url, initCopy).then((response) => (response.ok ? response : handleError(response))); +const safeFetch = (url: string, initCopy: any) => { + return fetch(url, initCopy).then((response: Response) => (response.ok ? response : handleError(response))); }; -export const backendFetch = (url, init, token) => { +export const backendFetch = (url: string, init?: any, token?: string) => { const initCopy = prepareRequest(init, token); return safeFetch(url, initCopy); }; -export const backendFetchText = (url, init, token) => { +export const backendFetchText = (url: string, init?: any, token?: string) => { const initCopy = prepareRequest(init, token); return safeFetch(url, initCopy).then((safeResponse) => safeResponse.text()); }; -export const backendFetchJson = (url, init, token) => { +export const backendFetchJson = (url: string, init?: any, token?: string) => { const initCopy = prepareRequest(init, token); return safeFetch(url, initCopy).then((safeResponse) => (safeResponse.status === 204 ? null : safeResponse.json())); }; -export const backendFetchFile = (url, init, token) => { +export const backendFetchFile = (url: string, init: any, token?: string) => { const initCopy = prepareRequest(init, token); return safeFetch(url, initCopy).then((safeResponse) => safeResponse.blob()); }; @@ -84,15 +86,17 @@ export const backendFetchFile = (url, init, token) => { const FILE_TYPE = { ZIP: 'ZIP', }; -export const downloadZipFile = (blob, fileName) => { +export const downloadZipFile = (blob: Blob, fileName: string) => { downloadFile(blob, fileName, FILE_TYPE.ZIP); }; -const downloadFile = (blob, filename, type) => { +const downloadFile = (blob: Blob, filename: string, type: string) => { let contentType; if (type === FILE_TYPE.ZIP) { contentType = 'application/octet-stream'; } + //BlobPropertyBag does not contain contentType as attribute + // @ts-ignore const href = window.URL.createObjectURL(new Blob([blob], { contentType })); const link = document.createElement('a'); link.href = href; @@ -129,19 +133,21 @@ export const fetchDefaultParametersValues = () => { return Promise.reject('Study entry could not be found in metadatas'); } + //FIXME: Metadata doesn't contain defaultParametersValues. We need to change it to StudyMetadata. + // @ts-ignore return studyMetadata.defaultParametersValues; }); }; -export const getQueryParamsList = (params, paramName) => { +export const getQueryParamsList = (params: string[] | number[] | null | undefined, paramName: string) => { if (params != null && Array.isArray(params) && params.length > 0) { const urlSearchParams = new URLSearchParams(); - params.forEach((id) => urlSearchParams.append(paramName, id)); + params.forEach((id) => urlSearchParams.append(paramName, String(id))); return urlSearchParams.toString(); } return ''; }; -export function getUrlWithToken(baseUrl) { +export function getUrlWithToken(baseUrl: string) { if (baseUrl.includes('?')) { return baseUrl + '&access_token=' + getUserToken(); } else { From 5af1f3aab04eb80368c97fc4ddbe9610375b0443 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 12 Nov 2024 17:24:08 +0100 Subject: [PATCH 12/24] Fix some errors. Signed-off-by: AAJELLAL --- src/components/app.jsx | 2 +- .../modification/battery-modification-dialog.jsx | 2 +- .../by-filter/by-formula/by-formula-dialog.jsx | 2 +- .../delete-attaching-line-dialog.jsx | 2 +- .../delete-voltage-level-on-line-dialog.jsx | 2 +- .../equipment-deletion/equipment-deletion-dialog.jsx | 2 +- .../generation-dispatch-dialog.jsx | 2 +- .../generator-scaling/generator-scaling-dialog.jsx | 2 +- .../generator/creation/generator-creation-dialog.jsx | 2 +- .../modification/generator-modification-dialog.jsx | 2 +- .../line-attach-to-voltage-level-dialog.jsx | 2 +- .../line-split-with-voltage-level-dialog.jsx | 2 +- .../line/creation/line-creation-dialog.jsx | 2 +- .../line/modification/line-modification-dialog.jsx | 2 +- .../lines-attach-to-split-lines-dialog.jsx | 2 +- .../load-scaling/load-scaling-dialog.jsx | 2 +- .../load/creation/load-creation-dialog.jsx | 2 +- .../load/modification/load-modification-dialog.jsx | 2 +- .../creation/shunt-compensator-creation-dialog.jsx | 2 +- .../shunt-compensator-modification-dialog.jsx | 2 +- .../creation/substation-creation-dialog.jsx | 2 +- .../tabular-creation/tabular-creation-dialog.jsx | 2 +- .../tabular-modification-dialog.jsx | 2 +- .../two-windings-transformer-creation-dialog.jsx | 2 +- .../two-windings-transformer-modification-dialog.jsx | 2 +- .../creation/voltage-level-creation-dialog.jsx | 2 +- .../voltage-level-modification-dialog.jsx | 2 +- .../vsc/creation/vsc-creation-dialog.jsx | 2 +- .../sensitivity-analysis-result-tab.jsx | 2 +- src/components/voltage-init-result.jsx | 2 +- src/services/network-modification-types.ts | 2 +- src/services/study/dynamic-simulation.js | 2 +- src/services/study/index.ts | 3 ++- src/services/study/loadflow.ts | 2 +- src/services/study/network-modifications.ts | 2 +- src/services/study/network.ts | 12 ++++++------ src/services/study/tree-subtree.ts | 9 ++++++++- src/services/utils.ts | 2 +- 38 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/components/app.jsx b/src/components/app.jsx index 0e3ff4a324..8b3fdef4ed 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -57,7 +57,7 @@ import { StudyContainer } from './study-container'; import { fetchValidateUser } from '../services/user-admin'; import { connectNotificationsWsUpdateConfig } from '../services/config-notification'; import { fetchConfigParameter, fetchConfigParameters } from '../services/config'; -import { fetchDefaultParametersValues, fetchIdpSettings } from '../services/utils.js'; +import { fetchDefaultParametersValues, fetchIdpSettings } from '../services/utils'; import { getOptionalServices } from '../services/study/index'; import { changeDisplayedColumns, diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx index 340dec1443..895036b95f 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx @@ -60,7 +60,7 @@ import { } from '../../../set-points/set-points-utils'; import { modifyBattery } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx index 0fa918b05d..7d5e11ae49 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx @@ -9,7 +9,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index 4221a4d7f0..9f10828f42 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -24,7 +24,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import DeleteAttachingLineForm from './delete-attaching-line-form'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { deleteAttachingLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx index 1424c29dbe..c670615f87 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx @@ -23,7 +23,7 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import DeleteVoltageLevelOnLineForm from './delete-voltage-level-on-line-form'; import { deleteVoltageLevelOnLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx index 85c593ecc6..3f3798631c 100644 --- a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx +++ b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx @@ -18,7 +18,7 @@ import PropTypes from 'prop-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipment } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx index 3fb3fa7aed..8c09631cae 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx @@ -30,7 +30,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import GenerationDispatchForm from './generation-dispatch-form'; import { addSelectedFieldToRows } from 'components/utils/dnd-table/dnd-table'; import { generationDispatch } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LOSS_COEFFICIENT]: null, diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx index 222e3cbe04..bffffe5acb 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx @@ -17,7 +17,7 @@ import { getVariationsSchema } from './variation/variation-utils'; import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { generatorScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx index 108751dd88..09578e47e6 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx @@ -67,7 +67,7 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import { createGenerator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx index d9531dcdc1..e86b6a1ace 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx @@ -72,7 +72,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyGenerator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index 7f51141bd2..95e8ff73da 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -45,7 +45,7 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { attachLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index d9e0991a50..e650284c61 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -43,7 +43,7 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { divideLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index 4825c56bbe..e0ccfb08b7 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -40,7 +40,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import yup from 'components/utils/yup-config'; diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index 0bc6774c81..fb6f3c83a1 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -67,7 +67,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyLine } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index d5a67f0a14..e60256bb0d 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -38,7 +38,7 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { linesAttachToSplitLines } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx index 86152bc1ee..3ee51aae8d 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx @@ -17,7 +17,7 @@ import { getVariationsSchema } from './variation/variation-utils'; import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { loadScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils.js'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx index de5c9f5d4a..732864a5a6 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx @@ -26,7 +26,7 @@ import LoadCreationForm from './load-creation-form'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { createLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx index 3a354e1eab..16857fb6b1 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx @@ -34,7 +34,7 @@ import LoadModificationForm from './load-modification-form'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { modifyLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index a1224e8037..af7498e06d 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -47,7 +47,7 @@ import { } from '../characteristics-pane/characteristics-form-utils'; import ShuntCompensatorCreationForm from './shunt-compensator-creation-form'; import { createShuntCompensator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx index d29f3174a6..0e405a8fb8 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx @@ -43,7 +43,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../../../utils/equipm import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyShuntCompensator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index 276088585d..da210e94e6 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -20,7 +20,7 @@ import { sanitizeString } from '../../../dialog-utils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { createSubstation } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx index 92330cd59f..6ebb7afe1f 100644 --- a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx @@ -16,7 +16,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { CREATIONS_TABLE, REACTIVE_CAPABILITY_CURVE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabularCreation } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils.js'; +import { FetchStatus } from 'services/utils'; import TabularCreationForm from './tabular-creation-form'; import { convertCreationFieldFromBackToFront, diff --git a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx index f572f2ae94..6cba2d0d11 100644 --- a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx @@ -16,7 +16,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { MODIFICATIONS_TABLE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabulareModification } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils.js'; +import { FetchStatus } from 'services/utils'; import TabularModificationForm from './tabular-modification-form'; import { convertValueFromBackToFront, diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index 13f424212d..0e26f2f57d 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -54,7 +54,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { sanitizeString } from '../../../dialog-utils'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx index c077023b09..50b554707d 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx @@ -109,7 +109,7 @@ import { isNodeBuilt } from 'components/graph/util/model-functions'; import RatioTapChangerPane from '../tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane'; import PhaseTapChangerPane from '../tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx index 60f3edac74..82278e28b8 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx @@ -45,7 +45,7 @@ import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { createVoltageLevel } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx index 4695f11511..cdbb0ab781 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx @@ -29,7 +29,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipme import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyVoltageLevel } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx index a91347bb6a..2574c0b640 100644 --- a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx @@ -38,7 +38,7 @@ import { getVscHvdcLinePaneSchema, getVscHvdcLineTabFormData, } from '../hvdc-line-pane/vsc-hvdc-line-pane-utils'; -import { FetchStatus } from '../../../../../services/utils.js'; +import { FetchStatus } from '../../../../../services/utils'; import { getConverterStationCreationData, getConverterStationFormEditData, diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx index c879bbf293..32b9558ccb 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx @@ -27,7 +27,7 @@ import { RunningStatus } from '../../utils/running-status'; import { useOpenLoaderShortWait } from '../../dialogs/commons/handle-loader'; import { RESULTS_LOADING_DELAY } from '../../network/constants'; import { exportSensitivityResultsAsCsv } from '../../../services/study/sensitivity-analysis'; -import { downloadZipFile } from '../../../services/utils.js'; +import { downloadZipFile } from '../../../services/utils'; import { useSnackMessage } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { ExportButton } from '../../utils/export-button'; diff --git a/src/components/voltage-init-result.jsx b/src/components/voltage-init-result.jsx index dde632c067..426ab48975 100644 --- a/src/components/voltage-init-result.jsx +++ b/src/components/voltage-init-result.jsx @@ -21,7 +21,7 @@ import { } from '../services/study/voltage-init'; import CircularProgress from '@mui/material/CircularProgress'; import VoltageInitModificationDialog from './dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog'; -import { FetchStatus } from '../services/utils.js'; +import { FetchStatus } from '../services/utils'; import { ComputationReportViewer } from './results/common/computation-report-viewer'; import { useOpenLoaderShortWait } from './dialogs/commons/handle-loader'; import { RunningStatus } from './utils/running-status'; diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index f8afd43c96..2b0a34799f 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -163,7 +163,7 @@ export interface StaticVarCompensatorCreationInfo { studyUuid: string; nodeUuid: UUID; staticCompensatorId: string; - staticCompensatorName: string | null; + staticCompensatorName: string | null | undefined; voltageLevelId: string; busOrBusbarSectionId?: string; connectionDirection?: string | null; diff --git a/src/services/study/dynamic-simulation.js b/src/services/study/dynamic-simulation.js index dfaf2ad713..80bb7e7b21 100644 --- a/src/services/study/dynamic-simulation.js +++ b/src/services/study/dynamic-simulation.js @@ -7,7 +7,7 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; -import { backendFetch, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils.js'; +import { backendFetch, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils'; export function getDynamicMappings(studyUuid) { console.info(`Fetching dynamic mappings on '${studyUuid}' ...`); diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 2eafc7f953..5cf77487c6 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -23,7 +23,8 @@ export function safeEncodeURIComponent(value: string | null | undefined): string } export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; -export const getStudyUrl = (studyUuid: UUID) => `${PREFIX_STUDY_QUERIES}/v1/studies/${encodeURIComponent(studyUuid)}`; +export const getStudyUrl = (studyUuid: UUID | null) => + `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}`; export const getStudyUrlWithNodeUuid = ( studyUuid: UUID | string | null | undefined, diff --git a/src/services/study/loadflow.ts b/src/services/study/loadflow.ts index 9d78050c2a..23db13041d 100644 --- a/src/services/study/loadflow.ts +++ b/src/services/study/loadflow.ts @@ -14,7 +14,7 @@ import { GlobalFilter } from '../../components/results/loadflow/load-flow-result interface QueryParams { sort?: SortConfigType[]; - filters?: FilterSelectorType[]; + filters: FilterSelectorType[] | null; globalFilters?: GlobalFilter | undefined; } diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 78f7029558..f75c8533fb 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -1857,7 +1857,7 @@ export function modifyVsc( studyUuid: string, nodeUuid: UUID, id: string | null, - name: string | null, + name: string | null | undefined, nominalV: number, r: number, maxP: number, diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 55e89416ea..86d7de6c03 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -124,7 +124,7 @@ export function getSubstationSingleLineDiagram( export function fetchNetworkElementsInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined, + substationsIds: string[] | undefined | null, elementType: string, infoType: string, inUpstreamBuiltParentNode?: boolean, @@ -197,7 +197,7 @@ export function fetchNetworkElementInfos( export function fetchSubstationsMapInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined, + substationsIds: string[] | null | undefined, inUpstreamBuiltParentNode: boolean ) { return fetchNetworkElementsInfos( @@ -213,7 +213,7 @@ export function fetchSubstationsMapInfos( export function fetchLinesMapInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined, + substationsIds: string[] | undefined | null, inUpstreamBuiltParentNode: boolean ) { return fetchNetworkElementsInfos( @@ -229,7 +229,7 @@ export function fetchLinesMapInfos( export function fetchTieLinesMapInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined, + substationsIds: string[] | undefined | null, inUpstreamBuiltParentNode: boolean ) { return fetchNetworkElementsInfos( @@ -245,7 +245,7 @@ export function fetchTieLinesMapInfos( export function fetchHvdcLinesMapInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined, + substationsIds: string[] | undefined | null, inUpstreamBuiltParentNode: boolean ) { return fetchNetworkElementsInfos( @@ -294,7 +294,7 @@ export function fetchVoltageLevels(studyUuid: UUID, currentNodeUuid: UUID, subst export function fetchVoltageLevelsListInfos( studyUuid: UUID, currentNodeUuid: UUID, - substationsIds: string[] | undefined + substationsIds?: string[] | undefined ) { return fetchNetworkElementsInfos( studyUuid, diff --git a/src/services/study/tree-subtree.ts b/src/services/study/tree-subtree.ts index 197ff0e98f..cb162d9593 100644 --- a/src/services/study/tree-subtree.ts +++ b/src/services/study/tree-subtree.ts @@ -143,7 +143,14 @@ export function stashSubtree(studyUuid: UUID, parentNodeId: UUID) { }); } -export function updateTreeNode(studyUuid: UUID, node: UUID) { +export function updateTreeNode( + studyUuid: UUID | null, + node: { + id: UUID | undefined; + type: NodeType | undefined; + name: string; + } +) { const nodeUpdateUrl = getStudyUrl(studyUuid) + '/tree/nodes'; console.debug(nodeUpdateUrl); return backendFetch(nodeUpdateUrl, { diff --git a/src/services/utils.ts b/src/services/utils.ts index 43cf873cc4..d217c34323 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -60,7 +60,7 @@ const prepareRequest = (init: any, token: string | undefined) => { }; const safeFetch = (url: string, initCopy: any) => { - return fetch(url, initCopy).then((response: Response) => (response.ok ? response : handleError(response))); + return fetch(url, initCopy).then((response: any) => (response.ok ? response : handleError(response))); }; export const backendFetch = (url: string, init?: any, token?: string) => { From 5dc0a7b67df17a7b502f59768a7e559c0f7e5276 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Wed, 20 Nov 2024 16:26:50 +0100 Subject: [PATCH 13/24] handle conflect and fix some sonar issues. Signed-off-by: AAJELLAL --- .../creation/battery-creation-dialog.jsx | 52 ++-- .../creation/generator-creation-dialog.jsx | 80 +++--- .../line/creation/line-creation-dialog.jsx | 64 +++-- .../shunt-compensator-creation-dialog.jsx | 54 ++-- src/services/network-modification-types.ts | 153 +++++++++- src/services/study/index.ts | 5 +- src/services/study/loadflow.ts | 2 +- src/services/study/network-modifications.ts | 272 +++++++++--------- src/services/study/network.ts | 62 +--- 9 files changed, 429 insertions(+), 315 deletions(-) diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx index cce8b82d75..168306df30 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx @@ -177,31 +177,33 @@ const BatteryCreationDialog = ({ editData, currentNode, studyUuid, isUpdate, edi (battery) => { const reactiveLimits = battery[REACTIVE_LIMITS]; const isReactiveCapabilityCurveOn = reactiveLimits[REACTIVE_CAPABILITY_CURVE_CHOICE] === 'CURVE'; - createBattery( - studyUuid, - currentNodeUuid, - battery[EQUIPMENT_ID], - sanitizeString(battery[EQUIPMENT_NAME]), - battery[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], - battery[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - sanitizeString(battery[CONNECTIVITY]?.[CONNECTION_NAME]), - battery[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - battery[CONNECTIVITY]?.[CONNECTION_POSITION], - battery[CONNECTIVITY]?.[CONNECTED], - battery[MINIMUM_ACTIVE_POWER], - battery[MAXIMUM_ACTIVE_POWER], - isReactiveCapabilityCurveOn, - isReactiveCapabilityCurveOn ? null : reactiveLimits[MINIMUM_REACTIVE_POWER], - isReactiveCapabilityCurveOn ? null : reactiveLimits[MAXIMUM_REACTIVE_POWER], - isReactiveCapabilityCurveOn ? reactiveLimits[REACTIVE_CAPABILITY_CURVE_TABLE] : null, - battery[ACTIVE_POWER_SET_POINT], - battery[REACTIVE_POWER_SET_POINT], - battery[FREQUENCY_REGULATION], - battery[DROOP] ?? null, - !!editData, - editData?.uuid ?? null, - toModificationProperties(battery) - ).catch((error) => { + createBattery({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + id: battery[EQUIPMENT_ID], + name: sanitizeString(battery[EQUIPMENT_NAME]), + voltageLevelId: battery[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], + busOrBusbarSectionId: battery[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + connectionName: sanitizeString(battery[CONNECTIVITY]?.[CONNECTION_NAME]), + connectionDirection: battery[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionPosition: battery[CONNECTIVITY]?.[CONNECTION_POSITION], + terminalConnected: battery[CONNECTIVITY]?.[CONNECTED], + minP: battery[MINIMUM_ACTIVE_POWER], + maxP: battery[MAXIMUM_ACTIVE_POWER], + isReactiveCapabilityCurveOn: isReactiveCapabilityCurveOn, + minQ: isReactiveCapabilityCurveOn ? null : reactiveLimits[MINIMUM_REACTIVE_POWER], + maxQ: isReactiveCapabilityCurveOn ? null : reactiveLimits[MAXIMUM_REACTIVE_POWER], + reactiveCapabilityCurve: isReactiveCapabilityCurveOn + ? reactiveLimits[REACTIVE_CAPABILITY_CURVE_TABLE] + : null, + targetP: battery[ACTIVE_POWER_SET_POINT], + targetQ: battery[REACTIVE_POWER_SET_POINT], + participate: battery[FREQUENCY_REGULATION], + droop: battery[DROOP] ?? null, + isUpdate: !!editData, + modificationUuid: editData?.uuid ?? null, + properties: toModificationProperties(battery), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'BatteryCreationError', diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx index 09578e47e6..282fb88670 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx @@ -256,45 +256,47 @@ const GeneratorCreationDialog = ({ const isReactiveCapabilityCurveOn = reactiveLimits[REACTIVE_CAPABILITY_CURVE_CHOICE] === 'CURVE'; const isDistantRegulation = generator[VOLTAGE_REGULATION_TYPE] === REGULATION_TYPES.DISTANT.id; - createGenerator( - studyUuid, - currentNodeUuid, - generator[EQUIPMENT_ID], - sanitizeString(generator[EQUIPMENT_NAME]), - generator[ENERGY_SOURCE], - generator[MINIMUM_ACTIVE_POWER], - generator[MAXIMUM_ACTIVE_POWER], - generator[RATED_NOMINAL_POWER], - generator[ACTIVE_POWER_SET_POINT], - generator[REACTIVE_POWER_SET_POINT], - generator[VOLTAGE_REGULATION], - generator[VOLTAGE_SET_POINT], - generator[Q_PERCENT], - generator[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], - generator[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - !!editData, - editData?.uuid ?? null, - generator[PLANNED_ACTIVE_POWER_SET_POINT], - generator[MARGINAL_COST], - generator[PLANNED_OUTAGE_RATE], - generator[FORCED_OUTAGE_RATE], - generator[TRANSIENT_REACTANCE], - generator[TRANSFORMER_REACTANCE], - isDistantRegulation ? generator[EQUIPMENT]?.id : null, - isDistantRegulation ? generator[EQUIPMENT]?.type : null, - isDistantRegulation ? generator[VOLTAGE_LEVEL]?.id : null, - isReactiveCapabilityCurveOn, - generator[FREQUENCY_REGULATION], - generator[DROOP] ?? null, - isReactiveCapabilityCurveOn ? null : reactiveLimits[MAXIMUM_REACTIVE_POWER], - isReactiveCapabilityCurveOn ? null : reactiveLimits[MINIMUM_REACTIVE_POWER], - isReactiveCapabilityCurveOn ? reactiveLimits[REACTIVE_CAPABILITY_CURVE_TABLE] : null, - generator[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - sanitizeString(generator[CONNECTIVITY]?.[CONNECTION_NAME]), - generator[CONNECTIVITY]?.[CONNECTION_POSITION], - generator[CONNECTIVITY]?.[CONNECTED], - toModificationProperties(generator) - ).catch((error) => { + createGenerator({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + id: generator[EQUIPMENT_ID], + name: sanitizeString(generator[EQUIPMENT_NAME]), + energySource: generator[ENERGY_SOURCE], + minP: generator[MINIMUM_ACTIVE_POWER], + maxP: generator[MAXIMUM_ACTIVE_POWER], + ratedS: generator[RATED_NOMINAL_POWER], + targetP: generator[ACTIVE_POWER_SET_POINT], + targetQ: generator[REACTIVE_POWER_SET_POINT], + voltageRegulationOn: generator[VOLTAGE_REGULATION], + targetV: generator[VOLTAGE_SET_POINT], + qPercent: generator[Q_PERCENT], + voltageLevelId: generator[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], + busOrBusbarSectionId: generator[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + isUpdate: !!editData, + modificationUuid: editData?.uuid ?? null, + plannedActivePowerSetPoint: generator[PLANNED_ACTIVE_POWER_SET_POINT], + marginalCost: generator[MARGINAL_COST], + plannedOutageRate: generator[PLANNED_OUTAGE_RATE], + forcedOutageRate: generator[FORCED_OUTAGE_RATE], + directTransX: generator[TRANSIENT_REACTANCE], + stepUpTransformerX: generator[TRANSFORMER_REACTANCE], + regulatingTerminalId: isDistantRegulation ? generator[EQUIPMENT]?.id : null, + regulatingTerminalType: isDistantRegulation ? generator[EQUIPMENT]?.type : null, + regulatingTerminalVlId: isDistantRegulation ? generator[VOLTAGE_LEVEL]?.id : null, + isReactiveCapabilityCurveOn: isReactiveCapabilityCurveOn, + participate: generator[FREQUENCY_REGULATION], + droop: generator[DROOP] ?? null, + maxQ: isReactiveCapabilityCurveOn ? null : reactiveLimits[MAXIMUM_REACTIVE_POWER], + minQ: isReactiveCapabilityCurveOn ? null : reactiveLimits[MINIMUM_REACTIVE_POWER], + reactiveCapabilityCurve: isReactiveCapabilityCurveOn + ? reactiveLimits[REACTIVE_CAPABILITY_CURVE_TABLE] + : null, + connectionDirection: generator[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionName: sanitizeString(generator[CONNECTIVITY]?.[CONNECTION_NAME]), + connectionPosition: generator[CONNECTIVITY]?.[CONNECTION_POSITION], + terminalConnected: generator[CONNECTIVITY]?.[CONNECTED], + properties: toModificationProperties(generator), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'GeneratorCreationError', diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index e0ccfb08b7..14f013adb4 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -283,37 +283,39 @@ const LineCreationDialog = ({ const header = line[TAB_HEADER]; const characteristics = line[CHARACTERISTICS]; const limits = line[LIMITS]; - onCreateLine( - studyUuid, - currentNodeUuid, - header[EQUIPMENT_ID], - sanitizeString(header[EQUIPMENT_NAME]), - characteristics[R], - characteristics[X], - microUnitToUnit(characteristics[G1]), - microUnitToUnit(characteristics[B1]), - microUnitToUnit(characteristics[G2]), - microUnitToUnit(characteristics[B2]), - characteristics[CONNECTIVITY_1]?.[VOLTAGE_LEVEL]?.id, - characteristics[CONNECTIVITY_1]?.[BUS_OR_BUSBAR_SECTION]?.id, - characteristics[CONNECTIVITY_2]?.[VOLTAGE_LEVEL]?.id, - characteristics[CONNECTIVITY_2]?.[BUS_OR_BUSBAR_SECTION]?.id, - limits[CURRENT_LIMITS_1]?.[PERMANENT_LIMIT], - limits[CURRENT_LIMITS_2]?.[PERMANENT_LIMIT], - sanitizeLimitNames(limits[CURRENT_LIMITS_1]?.[TEMPORARY_LIMITS]), - sanitizeLimitNames(limits[CURRENT_LIMITS_2]?.[TEMPORARY_LIMITS]), - !!editData, - editData ? editData.uuid : undefined, - sanitizeString(characteristics[CONNECTIVITY_1]?.[CONNECTION_NAME]), - characteristics[CONNECTIVITY_1]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - sanitizeString(characteristics[CONNECTIVITY_2]?.[CONNECTION_NAME]), - characteristics[CONNECTIVITY_2]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - characteristics[CONNECTIVITY_1]?.[CONNECTION_POSITION] ?? null, - characteristics[CONNECTIVITY_2]?.[CONNECTION_POSITION] ?? null, - characteristics[CONNECTIVITY_1]?.[CONNECTED] ?? null, - characteristics[CONNECTIVITY_2]?.[CONNECTED] ?? null, - toModificationProperties(line) - ).catch((error) => { + onCreateLine({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + lineId: header[EQUIPMENT_ID], + lineName: sanitizeString(header[EQUIPMENT_NAME]), + r: characteristics[R], + x: characteristics[X], + g1: microUnitToUnit(characteristics[G1]), + b1: microUnitToUnit(characteristics[B1]), + g2: microUnitToUnit(characteristics[G2]), + b2: microUnitToUnit(characteristics[B2]), + voltageLevelId1: characteristics[CONNECTIVITY_1]?.[VOLTAGE_LEVEL]?.id, + busOrBusbarSectionId1: characteristics[CONNECTIVITY_1]?.[BUS_OR_BUSBAR_SECTION]?.id, + voltageLevelId2: characteristics[CONNECTIVITY_2]?.[VOLTAGE_LEVEL]?.id, + busOrBusbarSectionId2: characteristics[CONNECTIVITY_2]?.[BUS_OR_BUSBAR_SECTION]?.id, + permanentCurrentLimit1: limits[CURRENT_LIMITS_1]?.[PERMANENT_LIMIT], + permanentCurrentLimit2: limits[CURRENT_LIMITS_2]?.[PERMANENT_LIMIT], + temporaryCurrentLimits1: sanitizeLimitNames(limits[CURRENT_LIMITS_1]?.[TEMPORARY_LIMITS]), + temporaryCurrentLimits2: sanitizeLimitNames(limits[CURRENT_LIMITS_2]?.[TEMPORARY_LIMITS]), + isUpdate: !!editData, + modificationUuid: editData ? editData.uuid : undefined, + connectionName1: sanitizeString(characteristics[CONNECTIVITY_1]?.[CONNECTION_NAME]), + connectionDirection1: + characteristics[CONNECTIVITY_1]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionName2: sanitizeString(characteristics[CONNECTIVITY_2]?.[CONNECTION_NAME]), + connectionDirection2: + characteristics[CONNECTIVITY_2]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionPosition1: characteristics[CONNECTIVITY_1]?.[CONNECTION_POSITION] ?? null, + connectionPosition2: characteristics[CONNECTIVITY_2]?.[CONNECTION_POSITION] ?? null, + connected1: characteristics[CONNECTIVITY_1]?.[CONNECTED] ?? null, + connected2: characteristics[CONNECTIVITY_2]?.[CONNECTED] ?? null, + properties: toModificationProperties(line), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'LineCreationError', diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index af7498e06d..6f44c848bc 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -175,31 +175,35 @@ const ShuntCompensatorCreationDialog = ({ const onSubmit = useCallback( (shuntCompensator) => { - createShuntCompensator( - studyUuid, - currentNodeUuid, - shuntCompensator[EQUIPMENT_ID], - sanitizeString(shuntCompensator[EQUIPMENT_NAME]), - shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.SUSCEPTANCE.id - ? shuntCompensator[MAX_SUSCEPTANCE] - : null, - shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.Q_AT_NOMINAL_V.id - ? shuntCompensator[MAX_Q_AT_NOMINAL_V] - : null, - shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.Q_AT_NOMINAL_V.id - ? shuntCompensator[SHUNT_COMPENSATOR_TYPE] - : null, - shuntCompensator[SECTION_COUNT], - shuntCompensator[MAXIMUM_SECTION_COUNT], - shuntCompensator[CONNECTIVITY], - !!editData, - editData ? editData.uuid : undefined, - shuntCompensator[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - sanitizeString(shuntCompensator[CONNECTIVITY]?.[CONNECTION_NAME]), - shuntCompensator[CONNECTIVITY]?.[CONNECTION_POSITION] ?? null, - shuntCompensator[CONNECTIVITY]?.[CONNECTED], - toModificationProperties(shuntCompensator) - ).catch((error) => { + createShuntCompensator({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + shuntCompensatorId: shuntCompensator[EQUIPMENT_ID], + shuntCompensatorName: sanitizeString(shuntCompensator[EQUIPMENT_NAME]), + maxSusceptance: + shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.SUSCEPTANCE.id + ? shuntCompensator[MAX_SUSCEPTANCE] + : null, + maxQAtNominalV: + shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.Q_AT_NOMINAL_V.id + ? shuntCompensator[MAX_Q_AT_NOMINAL_V] + : null, + shuntCompensatorType: + shuntCompensator[CHARACTERISTICS_CHOICE] === CHARACTERISTICS_CHOICES.Q_AT_NOMINAL_V.id + ? shuntCompensator[SHUNT_COMPENSATOR_TYPE] + : null, + sectionCount: shuntCompensator[SECTION_COUNT], + maximumSectionCount: shuntCompensator[MAXIMUM_SECTION_COUNT], + connectivity: shuntCompensator[CONNECTIVITY], + isUpdate: !!editData, + modificationUuid: editData ? editData.uuid : undefined, + connectionDirection: + shuntCompensator[CONNECTIVITY]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionName: sanitizeString(shuntCompensator[CONNECTIVITY]?.[CONNECTION_NAME]), + connectionPosition: shuntCompensator[CONNECTIVITY]?.[CONNECTION_POSITION] ?? null, + terminalConnected: shuntCompensator[CONNECTIVITY]?.[CONNECTED], + properties: toModificationProperties(shuntCompensator), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'ShuntCompensatorCreationError', diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index 2b0a34799f..dfd8eea98c 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -11,7 +11,7 @@ import { } from '../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; import { UUID } from 'crypto'; import { Property } from '../components/dialogs/network-modifications/common/properties/property-utils'; -import { MODIFICATION_TYPE } from '../components/utils/modification-type'; + import { DataType, FieldValue, @@ -68,7 +68,7 @@ export interface BatteryModificationInfo { isReactiveCapabilityCurveOn?: boolean; minQ?: number | null; maxQ?: number | null; - reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData | undefined; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData; targetP: number; targetQ: number; participate: boolean; @@ -76,6 +76,24 @@ export interface BatteryModificationInfo { isUpdate?: boolean; properties?: Property[]; } +export interface LoadCreationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string; + name?: string | null; + loadType: string; + p0: number; + q0: number; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + isUpdate: boolean; + modificationUuid?: string; + connectionDirection: string | null; + connectionName?: string | null; + connectionPosition?: number | null; + terminalConnected?: boolean; + properties?: Property[]; +} export interface LoadModificationInfo { studyUuid: string; @@ -151,7 +169,7 @@ export interface GeneratorModificationInfo { droop: number | null; maxQ?: number | null; minQ?: number | null; - reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData[] | undefined; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData[]; connectionDirection?: string | null; connectionName?: string | null; connectionPosition?: string | null; @@ -163,7 +181,7 @@ export interface StaticVarCompensatorCreationInfo { studyUuid: string; nodeUuid: UUID; staticCompensatorId: string; - staticCompensatorName: string | null | undefined; + staticCompensatorName?: string | null; voltageLevelId: string; busOrBusbarSectionId?: string; connectionDirection?: string | null; @@ -302,7 +320,7 @@ export interface Variations { } export interface VSCCreationConverterStation { - type: MODIFICATION_TYPE; + type: string; equipmentId: string; equipmentName: string | null; lossFactor: number; @@ -325,7 +343,7 @@ export interface VSCModificationConverterStation { lossFactor: AttributeModification | null; reactiveCapabilityCurve: AttributeModification | null; busOrBusbarSectionId: AttributeModification | null; - type: MODIFICATION_TYPE; + type: string; minQ: AttributeModification | null; equipmentId: string; reactiveCapabilityCurvePoints: @@ -346,9 +364,126 @@ export interface VSCModificationConverterStation { } export interface Assignment { - dataType: DataType | undefined; - value: FieldValue | undefined; + dataType?: DataType; + value?: FieldValue; filters: Filter[]; editedField: string; - propertyName?: string | undefined; + propertyName?: string; +} +export interface BatteryCreationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string; + name: string | null; + voltageLevelId: string; + busOrBusbarSectionId: string; + connectionName: string | null; + connectionDirection: string | null; + connectionPosition: string | null; + terminalConnected: boolean | null; + minP: number | null; + maxP: number | null; + isReactiveCapabilityCurveOn: boolean; + minQ: number | null; + maxQ: number | null; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData; + targetP: number; + targetQ: number; + participate: boolean; + droop: number; + isUpdate: boolean; + modificationUuid: string; + properties?: Property[]; +} + +export interface GeneratorCreationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string; + name: string | null; + energySource: string; + minP: number; + maxP: number; + ratedS: number | null; + targetP: number | null; + targetQ: number | null; + voltageRegulationOn: boolean; + targetV: number | null; + qPercent: number | null; + voltageLevelId: string; + busOrBusbarSectionId: string; + isUpdate: boolean; + modificationUuid: string; + plannedActivePowerSetPoint: number; + marginalCost: number; + plannedOutageRate: number; + forcedOutageRate: number; + directTransX: number; + stepUpTransformerX: number; + regulatingTerminalId: string | null; + regulatingTerminalType: string | null; + regulatingTerminalVlId: string | null; + isReactiveCapabilityCurveOn: boolean; + participate: boolean; + droop: number | null; + maxQ: number | null; + minQ: number | null; + reactiveCapabilityCurve?: ReactiveCapabilityCurvePointsData[]; + connectionDirection: string | null; + connectionName: string | null; + connectionPosition: string | null; + terminalConnected: boolean | null; + properties?: Property[]; +} + +export interface ShuntCompensatorCreationInfo { + studyUuid: string; + nodeUuid: UUID; + shuntCompensatorId: string; + shuntCompensatorName: string | null; + maxSusceptance: number | null; + maxQAtNominalV: number | null; + shuntCompensatorType: string; + sectionCount: number; + maximumSectionCount: number; + connectivity: any; + isUpdate: boolean; + modificationUuid: string; + connectionDirection: string | null; + connectionName: string | null; + connectionPosition: string | null; + terminalConnected: boolean | null; + properties?: Property[]; +} + +export interface LineCreationInfo { + studyUuid: string; + nodeUuid: UUID; + lineId: string; + lineName: string | null; + r: number; + x: number; + g1: number; + b1: number; + g2: number; + b2: number; + voltageLevelId1: string; + busOrBusbarSectionId1: string; + voltageLevelId2: string; + busOrBusbarSectionId2: string; + permanentCurrentLimit1: number; + permanentCurrentLimit2: number; + temporaryCurrentLimits1: TemporaryLimit[]; + temporaryCurrentLimits2: TemporaryLimit[]; + isUpdate: boolean; + modificationUuid: string; + connectionName1: string | null; + connectionDirection1: string | null; + connectionName2: string | null; + connectionDirection2: string | null; + connectionPosition1: string | null; + connectionPosition2: string | null; + connected1: boolean; + connected2: boolean; + properties?: Property[]; } diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 5cf77487c6..3bd9724bb4 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -26,10 +26,7 @@ export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; export const getStudyUrl = (studyUuid: UUID | null) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}`; -export const getStudyUrlWithNodeUuid = ( - studyUuid: UUID | string | null | undefined, - nodeUuid: UUID | string | undefined -) => +export const getStudyUrlWithNodeUuid = (studyUuid: string | null | undefined, nodeUuid: UUID | string | undefined) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/nodes/${safeEncodeURIComponent(nodeUuid)}`; export const fetchStudy = (studyUuid: UUID) => { diff --git a/src/services/study/loadflow.ts b/src/services/study/loadflow.ts index 23db13041d..08f6572a4e 100644 --- a/src/services/study/loadflow.ts +++ b/src/services/study/loadflow.ts @@ -15,7 +15,7 @@ import { GlobalFilter } from '../../components/results/loadflow/load-flow-result interface QueryParams { sort?: SortConfigType[]; filters: FilterSelectorType[] | null; - globalFilters?: GlobalFilter | undefined; + globalFilters?: GlobalFilter; } export function getDefaultLoadFlowProvider() { diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 6acc44425d..01143f9f4e 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -18,10 +18,15 @@ import { Property } from '../../components/dialogs/network-modifications/common/ import { Assignment, AttachmentLine, + BatteryCreationInfo, BatteryModificationInfo, CurrentLimits, + GeneratorCreationInfo, GeneratorModificationInfo, + LineCreationInfo, + LoadCreationInfo, LoadModificationInfo, + ShuntCompensatorCreationInfo, ShuntCompensatorModificationInfo, StaticVarCompensatorCreationInfo, SubstationModificationInfo, @@ -275,31 +280,31 @@ export function generatorScaling( ); } -export function createBattery( - studyUuid: string, - nodeUuid: UUID, - id: string, - name: string | null, - voltageLevelId: string, - busOrBusbarSectionId: string, - connectionName: string | null, - connectionDirection: string | null, - connectionPosition: string | null, - terminalConnected: boolean | null, - minP: number | null, - maxP: number | null, - isReactiveCapabilityCurveOn: boolean, - minQ: number | null, - maxQ: number | null, - reactiveCapabilityCurve: ReactiveCapabilityCurvePointsData | undefined, - targetP: number, - targetQ: number, - participate: boolean, - droop: number, - isUpdate: boolean = false, - modificationUuid: string, - properties: Property[] -) { +export function createBattery({ + studyUuid, + nodeUuid, + id, + name, + voltageLevelId, + busOrBusbarSectionId, + connectionName, + connectionDirection, + connectionPosition, + terminalConnected, + minP, + maxP, + isReactiveCapabilityCurveOn, + minQ, + maxQ, + reactiveCapabilityCurve, + targetP, + targetQ, + participate, + droop, + isUpdate = false, + modificationUuid, + properties, +}: BatteryCreationInfo) { let createBatteryUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -406,28 +411,28 @@ export function modifyBattery({ }); } -export function createLoad( - studyUuid: string, - nodeUuid: UUID, - id: string, - name: string | null, - loadType: string, - p0: number, - q0: number, - voltageLevelId: string, - busOrBusbarSectionId: string, - isUpdate: boolean = false, - modificationUuid: string, - connectionDirection: string | null, - connectionName: string | null, - connectionPosition: string | null, - terminalConnected: boolean | null, - properties: Property[] -) { +export function createLoad({ + studyUuid, + nodeUuid, + id, + name, + loadType, + p0, + q0, + voltageLevelId, + busOrBusbarSectionId, + isUpdate, + modificationUuid, + connectionDirection, + connectionName, + connectionPosition, + terminalConnected, + properties, +}: LoadCreationInfo) { let createLoadUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { - createLoadUrl += '/' + encodeURIComponent(modificationUuid); + createLoadUrl += '/' + safeEncodeURIComponent(modificationUuid); console.info('Updating load creation'); } else { console.info('Creating load creation'); @@ -604,45 +609,45 @@ export function modifyGenerator({ }); } -export function createGenerator( - studyUuid: string, - nodeUuid: UUID, - id: string, - name: string | null, - energySource: string, - minP: number, - maxP: number, - ratedS: number | null, - targetP: number | null, - targetQ: number | null, - voltageRegulationOn: boolean, - targetV: number | null, - qPercent: number | null, - voltageLevelId: string, - busOrBusbarSectionId: string, - isUpdate: boolean = false, - modificationUuid: string, - plannedActivePowerSetPoint: number, - marginalCost: number, - plannedOutageRate: number, - forcedOutageRate: number, - directTransX: number, - stepUpTransformerX: number, - regulatingTerminalId: string | null, - regulatingTerminalType: string | null, - regulatingTerminalVlId: string | null, - isReactiveCapabilityCurveOn: boolean, - participate: boolean, - droop: number | null, - maxQ: number | null, - minQ: number | null, - reactiveCapabilityCurve: ReactiveCapabilityCurvePointsData[] | undefined, - connectionDirection: string | null, - connectionName: string | null, - connectionPosition: string | null, - terminalConnected: boolean | null, - properties: Property[] -) { +export function createGenerator({ + studyUuid, + nodeUuid, + id, + name, + energySource, + minP, + maxP, + ratedS, + targetP, + targetQ, + voltageRegulationOn, + targetV, + qPercent, + voltageLevelId, + busOrBusbarSectionId, + isUpdate = false, + modificationUuid, + plannedActivePowerSetPoint, + marginalCost, + plannedOutageRate, + forcedOutageRate, + directTransX, + stepUpTransformerX, + regulatingTerminalId, + regulatingTerminalType, + regulatingTerminalVlId, + isReactiveCapabilityCurveOn, + participate, + droop, + maxQ, + minQ, + reactiveCapabilityCurve, + connectionDirection, + connectionName, + connectionPosition, + terminalConnected, + properties, +}: GeneratorCreationInfo) { let createGeneratorUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -697,25 +702,25 @@ export function createGenerator( }); } -export function createShuntCompensator( - studyUuid: string, - nodeUuid: UUID, - shuntCompensatorId: string, - shuntCompensatorName: string | null, - maxSusceptance: number | null, - maxQAtNominalV: number | null, - shuntCompensatorType: string, - sectionCount: number, - maximumSectionCount: number, - connectivity: any, - isUpdate: boolean, - modificationUuid: string, - connectionDirection: string | null, - connectionName: string | null, - connectionPosition: string | null, - terminalConnected: boolean | null, - properties: Property[] -) { +export function createShuntCompensator({ + studyUuid, + nodeUuid, + shuntCompensatorId, + shuntCompensatorName, + maxSusceptance, + maxQAtNominalV, + shuntCompensatorType, + sectionCount, + maximumSectionCount, + connectivity, + isUpdate = false, + modificationUuid, + connectionDirection, + connectionName, + connectionPosition, + terminalConnected, + properties, +}: ShuntCompensatorCreationInfo) { let createShuntUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -890,37 +895,37 @@ export function createStaticVarCompensator(staticVarCompensatorCreationParameter }); } -export function createLine( - studyUuid: string, - nodeUuid: UUID, - lineId: string, - lineName: string | null, - r: number, - x: number, - g1: number, - b1: number, - g2: number, - b2: number, - voltageLevelId1: string, - busOrBusbarSectionId1: string, - voltageLevelId2: string, - busOrBusbarSectionId2: string, - permanentCurrentLimit1: number, - permanentCurrentLimit2: number, - temporaryCurrentLimits1: TemporaryLimit[], - temporaryCurrentLimits2: TemporaryLimit[], - isUpdate: boolean, - modificationUuid: string, - connectionName1: string | null, - connectionDirection1: string | null, - connectionName2: string | null, - connectionDirection2: string | null, - connectionPosition1: string | null, - connectionPosition2: string | null, - connected1: boolean, - connected2: boolean, - properties: Property[] -) { +export function createLine({ + studyUuid, + nodeUuid, + lineId, + lineName, + r, + x, + g1, + b1, + g2, + b2, + voltageLevelId1, + busOrBusbarSectionId1, + voltageLevelId2, + busOrBusbarSectionId2, + permanentCurrentLimit1, + permanentCurrentLimit2, + temporaryCurrentLimits1, + temporaryCurrentLimits2, + isUpdate = false, + modificationUuid, + connectionName1, + connectionDirection1, + connectionName2, + connectionDirection2, + connectionPosition1, + connectionPosition2, + connected1, + connected2, + properties, +}: LineCreationInfo) { let createLineUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -1871,7 +1876,6 @@ export function modifyVsc( converterStation1: VSCModificationConverterStation, converterStation2: VSCModificationConverterStation, properties: Property[] | undefined, - isUpdate: boolean, modificationUuid: UUID ) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); diff --git a/src/services/study/network.ts b/src/services/study/network.ts index c7333cd430..2918cc722c 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -48,46 +48,33 @@ export function getVoltageLevelSingleLineDiagram( ); } -export function fetchBusesForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { +export function fetchSubstationIdForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { console.info( - `Fetching buses of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` + `Fetching substation ID for the voltage level '${voltageLevelId}' of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` ); const urlSearchParams = new URLSearchParams(); urlSearchParams.append('inUpstreamBuiltParentNode', 'true'); - const fetchBusesUrl = + const fetchSubstationIdUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network/voltage-levels/' + encodeURIComponent(voltageLevelId) + - '/buses' + + '/substation-id' + '?' + urlSearchParams.toString(); - console.debug(fetchBusesUrl); - return backendFetchJson(fetchBusesUrl); -} -export function fetchSubstationIdForVoltageLevel(studyUuid, currentNodeUuid, voltageLevelId) { - console.info( - `Fetching substation ID for the voltage level '${voltageLevelId}' of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` - ); - const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('inUpstreamBuiltParentNode', 'true'); - - const fetchSubstationIdUrl = - getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + - '/network/voltage-levels/' + - encodeURIComponent(voltageLevelId) + - '/substation-id' + - '?' + - urlSearchParams.toString(); - - console.debug(fetchSubstationIdUrl); - - return backendFetchText(fetchSubstationIdUrl); + + console.debug(fetchSubstationIdUrl); + + return backendFetchText(fetchSubstationIdUrl); } -export function fetchBusbarSectionsForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { +export function fetchBusesOrBusbarSectionsForVoltageLevel( + studyUuid: UUID, + currentNodeUuid: UUID, + voltageLevelId: UUID +) { console.info( - `Fetching busbar sections of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` + `Fetching buses or busbar sections of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` ); const urlSearchParams = new URLSearchParams(); urlSearchParams.append('inUpstreamBuiltParentNode', 'true'); @@ -96,7 +83,7 @@ export function fetchBusbarSectionsForVoltageLevel(studyUuid: UUID, currentNodeU getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network/voltage-levels/' + encodeURIComponent(voltageLevelId) + - '/busbar-sections' + + '/buses-or-busbar-sections' + '?' + urlSearchParams.toString(); @@ -104,25 +91,6 @@ export function fetchBusbarSectionsForVoltageLevel(studyUuid: UUID, currentNodeU return backendFetchJson(fetchBusbarSectionsUrl); } -export function fetchBusesOrBusbarSectionsForVoltageLevel(studyUuid, currentNodeUuid, voltageLevelId) { - console.info( - `Fetching buses or busbar sections of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` - ); - const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('inUpstreamBuiltParentNode', 'true'); - - const fetchBusbarSectionsUrl = - getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + - '/network/voltage-levels/' + - encodeURIComponent(voltageLevelId) + - '/buses-or-busbar-sections' + - '?' + - urlSearchParams.toString(); - - console.debug(fetchBusbarSectionsUrl); - return backendFetchJson(fetchBusbarSectionsUrl); -} - /* substations */ export function getSubstationSingleLineDiagram( studyUuid: UUID, From 6e2a695f39727b2f8367c42a03375b9dbc9a5bcb Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 21 Nov 2024 17:36:20 +0100 Subject: [PATCH 14/24] Fix some sonar issues. Signed-off-by: AAJELLAL --- src/components/diagrams/diagram-pane.tsx | 22 +- .../position-diagram-pane.tsx | 22 +- .../delete-attaching-line-dialog.jsx | 20 +- .../line-attach-to-voltage-level-dialog.jsx | 34 +- .../line-split-with-voltage-level-dialog.jsx | 28 +- .../modification/line-modification-dialog.jsx | 58 +-- .../lines-attach-to-split-lines-dialog.jsx | 28 +- .../creation/substation-creation-dialog.jsx | 20 +- ...o-windings-transformer-creation-dialog.jsx | 66 ++-- .../vsc/creation/vsc-creation-dialog.jsx | 42 +-- .../modification/vsc-modification-dialog.tsx | 42 +-- src/services/network-modification-types.ts | 176 +++++++++ src/services/study/network-modifications.ts | 351 +++++++++--------- src/services/study/network.ts | 36 +- 14 files changed, 569 insertions(+), 376 deletions(-) diff --git a/src/components/diagrams/diagram-pane.tsx b/src/components/diagrams/diagram-pane.tsx index 3199dde065..5a0298dd14 100644 --- a/src/components/diagrams/diagram-pane.tsx +++ b/src/components/diagrams/diagram-pane.tsx @@ -69,17 +69,17 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => { const checkAndGetVoltageLevelSingleLineDiagramUrl = useCallback( (voltageLevelId: UUID) => isNodeBuilt(currentNode) - ? getVoltageLevelSingleLineDiagram( - studyUuid, - currentNode?.id, - voltageLevelId, - paramUseName, - centerName, - diagonalName, - componentLibrary, - SLD_DISPLAY_MODE.STATE_VARIABLE, - language - ) + ? getVoltageLevelSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNode?.id, + voltageLevelId: voltageLevelId, + useName: paramUseName, + centerLabel: centerName, + diagonalLabel: diagonalName, + componentLibrary: componentLibrary, + sldDisplayMode: SLD_DISPLAY_MODE.STATE_VARIABLE, + language: language, + }) : null, [currentNode, studyUuid, paramUseName, centerName, diagonalName, componentLibrary, language] ); diff --git a/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx b/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx index f5202d284e..ec45deac24 100644 --- a/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx +++ b/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx @@ -52,17 +52,17 @@ const PositionDiagramPane: FC = ({ const getVoltageLevelSingleLineDiagramUrl = useCallback( () => - getVoltageLevelSingleLineDiagram( - studyUuid, - currentNodeUuid, - voltageLevelId?.id, - useName, - centerName, - diagonalName, - componentLibrary, - SLD_DISPLAY_MODE.FEEDER_POSITION, - language - ), + getVoltageLevelSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNodeUuid, + voltageLevelId: voltageLevelId?.id, + useName: useName, + centerLabel: centerName, + diagonalLabel: diagonalName, + componentLibrary: componentLibrary, + sldDisplayMode: SLD_DISPLAY_MODE.FEEDER_POSITION, + language: language, + }), [studyUuid, currentNodeUuid, voltageLevelId?.id, useName, centerName, diagonalName, componentLibrary, language] ); diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index 9f10828f42..a599a0616f 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -101,16 +101,16 @@ const DeleteAttachingLineDialog = ({ const onSubmit = useCallback( (formData) => { - deleteAttachingLine( - studyUuid, - currentNodeUuid, - editData ? editData.uuid : undefined, - formData[LINE_TO_ATTACH_TO_1_ID], - formData[LINE_TO_ATTACH_TO_2_ID], - formData[ATTACHED_LINE_ID], - formData[REPLACING_LINE_1_ID], - sanitizeString(formData[REPLACING_LINE_1_NAME]) - ).catch((error) => { + deleteAttachingLine({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + modificationUuid: editData ? editData.uuid : undefined, + lineToAttachTo1Id: formData[LINE_TO_ATTACH_TO_1_ID], + lineToAttachTo2Id: formData[LINE_TO_ATTACH_TO_2_ID], + attachedLineId: formData[ATTACHED_LINE_ID], + replacingLine1Id: formData[REPLACING_LINE_1_ID], + replacingLine1Name: sanitizeString(formData[REPLACING_LINE_1_NAME]), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'DeleteAttachingLineError', diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index 4dbe303754..3162ad7841 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -164,23 +164,23 @@ const LineAttachToVoltageLevelDialog = ({ (lineAttach) => { const currentVoltageLevelId = lineAttach[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID]; const isNewVoltageLevel = newVoltageLevel?.equipmentId === currentVoltageLevelId; - attachLine( - studyUuid, - currentNodeUuid, - editData?.uuid, - lineAttach[LINE_TO_ATTACH_OR_SPLIT_ID], - parseFloat(lineAttach[SLIDER_PERCENTAGE]), - lineAttach[ATTACHMENT_POINT_ID], - sanitizeString(lineAttach[ATTACHMENT_POINT_NAME]), - isNewVoltageLevel ? newVoltageLevel : null, - currentVoltageLevelId, - lineAttach[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - attachmentLine, - lineAttach[LINE1_ID], - sanitizeString(lineAttach[LINE1_NAME]), - lineAttach[LINE2_ID], - sanitizeString(lineAttach[LINE2_NAME]) - ).catch((error) => { + attachLine({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + modificationUuid: editData?.uuid, + lineToAttachToId: lineAttach[LINE_TO_ATTACH_OR_SPLIT_ID], + percent: parseFloat(lineAttach[SLIDER_PERCENTAGE]), + attachmentPointId: lineAttach[ATTACHMENT_POINT_ID], + attachmentPointName: sanitizeString(lineAttach[ATTACHMENT_POINT_NAME]), + mayNewVoltageLevelInfos: isNewVoltageLevel ? newVoltageLevel : null, + existingVoltageLevelId: currentVoltageLevelId, + bbsOrBusId: lineAttach[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + attachmentLine: attachmentLine, + newLine1Id: lineAttach[LINE1_ID], + newLine1Name: sanitizeString(lineAttach[LINE1_NAME]), + newLine2Id: lineAttach[LINE2_ID], + newLine2Name: sanitizeString(lineAttach[LINE2_NAME]), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'LineAttachmentError', diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index a9141c9595..ad116eb308 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -149,20 +149,20 @@ const LineSplitWithVoltageLevelDialog = ({ (lineSplit) => { const currentVoltageLevelId = lineSplit[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID]; const isNewVoltageLevel = newVoltageLevel?.equipmentId === currentVoltageLevelId; - divideLine( - studyUuid, - currentNodeUuid, - editData?.uuid, - lineSplit[LINE_TO_ATTACH_OR_SPLIT_ID], - parseFloat(lineSplit[SLIDER_PERCENTAGE]), - isNewVoltageLevel ? newVoltageLevel : null, - currentVoltageLevelId, - lineSplit[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - lineSplit[LINE1_ID], - sanitizeString(lineSplit[LINE1_NAME]), - lineSplit[LINE2_ID], - sanitizeString(lineSplit[LINE2_NAME]) - ).catch((error) => { + divideLine({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + modificationUuid: editData?.uuid, + lineToSplitId: lineSplit[LINE_TO_ATTACH_OR_SPLIT_ID], + percent: parseFloat(lineSplit[SLIDER_PERCENTAGE]), + mayNewVoltageLevelInfos: isNewVoltageLevel ? newVoltageLevel : null, + existingVoltageLevelId: currentVoltageLevelId, + bbsOrBusId: lineSplit[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + newLine1Id: lineSplit[LINE1_ID], + newLine1Name: sanitizeString(lineSplit[LINE1_NAME]), + newLine2Id: lineSplit[LINE2_ID], + newLine2Name: sanitizeString(lineSplit[LINE2_NAME]), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'LineDivisionError', diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index fb6f3c83a1..1868d36416 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -235,35 +235,35 @@ const LineModificationDialog = ({ }; } - modifyLine( - studyUuid, - currentNodeUuid, - selectedId, - sanitizeString(line[EQUIPMENT_NAME]), - characteristics[R], - characteristics[X], - microUnitToUnit(characteristics[G1]), - microUnitToUnit(characteristics[B1]), - microUnitToUnit(characteristics[G2]), - microUnitToUnit(characteristics[B2]), - currentLimits1, - currentLimits2, - connectivity1[VOLTAGE_LEVEL]?.id, - connectivity1[BUS_OR_BUSBAR_SECTION]?.id, - connectivity2[VOLTAGE_LEVEL]?.id, - connectivity2[BUS_OR_BUSBAR_SECTION]?.id, - sanitizeString(connectivity1[CONNECTION_NAME]), - sanitizeString(connectivity2[CONNECTION_NAME]), - connectivity1[CONNECTION_DIRECTION], - connectivity2[CONNECTION_DIRECTION], - connectivity1[CONNECTION_POSITION], - connectivity2[CONNECTION_POSITION], - connectivity1[CONNECTED], - connectivity2[CONNECTED], - !!editData, - editData?.uuid, - toModificationProperties(line) - ).catch((error) => { + modifyLine({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + lineId: selectedId, + lineName: sanitizeString(line[EQUIPMENT_NAME]), + r: characteristics[R], + x: characteristics[X], + g1: microUnitToUnit(characteristics[G1]), + b1: microUnitToUnit(characteristics[B1]), + g2: microUnitToUnit(characteristics[G2]), + b2: microUnitToUnit(characteristics[B2]), + currentLimit1: currentLimits1, + currentLimit2: currentLimits2, + voltageLevelId1: connectivity1[VOLTAGE_LEVEL]?.id, + busOrBusbarSectionId1: connectivity1[BUS_OR_BUSBAR_SECTION]?.id, + voltageLevelId2: connectivity2[VOLTAGE_LEVEL]?.id, + busOrBusbarSectionId2: connectivity2[BUS_OR_BUSBAR_SECTION]?.id, + connectionName1: sanitizeString(connectivity1[CONNECTION_NAME]), + connectionName2: sanitizeString(connectivity2[CONNECTION_NAME]), + connectionDirection1: connectivity1[CONNECTION_DIRECTION], + connectionDirection2: connectivity2[CONNECTION_DIRECTION], + connectionPosition1: connectivity1[CONNECTION_POSITION], + connectionPosition2: connectivity2[CONNECTION_POSITION], + connected1: connectivity1[CONNECTED], + connected2: connectivity2[CONNECTED], + isUpdate: !!editData, + modificationUuid: editData?.uuid, + properties: toModificationProperties(line), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'LineModificationError', diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index e60256bb0d..a89927a0b8 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -113,20 +113,20 @@ const LinesAttachToSplitLinesDialog = ({ const onSubmit = useCallback( (linesAttachToSplitLine) => { - linesAttachToSplitLines( - studyUuid, - currentNodeUuid, - editData ? editData.uuid : undefined, - linesAttachToSplitLine[LINE_TO_ATTACH_TO_1_ID], - linesAttachToSplitLine[LINE_TO_ATTACH_TO_2_ID], - linesAttachToSplitLine[ATTACHED_LINE_ID], - linesAttachToSplitLine[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], - linesAttachToSplitLine[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - linesAttachToSplitLine[REPLACING_LINE_1_ID], - sanitizeString(linesAttachToSplitLine[REPLACING_LINE_1_NAME]), - linesAttachToSplitLine[REPLACING_LINE_2_ID], - sanitizeString(linesAttachToSplitLine[REPLACING_LINE_2_NAME]) - ).catch((error) => { + linesAttachToSplitLines({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + modificationUuid: editData ? editData.uuid : undefined, + lineToAttachTo1Id: linesAttachToSplitLine[LINE_TO_ATTACH_TO_1_ID], + lineToAttachTo2Id: linesAttachToSplitLine[LINE_TO_ATTACH_TO_2_ID], + attachedLineId: linesAttachToSplitLine[ATTACHED_LINE_ID], + voltageLevelId: linesAttachToSplitLine[CONNECTIVITY]?.[VOLTAGE_LEVEL]?.[ID], + bbsBusId: linesAttachToSplitLine[CONNECTIVITY]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + replacingLine1Id: linesAttachToSplitLine[REPLACING_LINE_1_ID], + replacingLine1Name: sanitizeString(linesAttachToSplitLine[REPLACING_LINE_1_NAME]), + replacingLine2Id: linesAttachToSplitLine[REPLACING_LINE_2_ID], + replacingLine2Name: sanitizeString(linesAttachToSplitLine[REPLACING_LINE_2_NAME]), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'LineAttachmentError', diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index da210e94e6..8a9eda91bc 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -112,16 +112,16 @@ const SubstationCreationDialog = ({ const onSubmit = useCallback( (substation) => { - createSubstation( - studyUuid, - currentNodeUuid, - substation[EQUIPMENT_ID], - sanitizeString(substation[EQUIPMENT_NAME]), - substation[COUNTRY], - !!editData, - editData ? editData.uuid : undefined, - toModificationProperties(substation) - ).catch((error) => { + createSubstation({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + substationId: substation[EQUIPMENT_ID], + substationName: sanitizeString(substation[EQUIPMENT_NAME]), + country: substation[COUNTRY], + isUpdate: !!editData, + modificationUuid: editData ? editData.uuid : undefined, + properties: toModificationProperties(substation), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'SubstationCreationError', diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index 0e26f2f57d..c026a06a4f 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -555,38 +555,40 @@ const TwoWindingsTransformerCreationDialog = ({ }; } - createTwoWindingsTransformer( - studyUuid, - currentNodeUuid, - twt[EQUIPMENT_ID], - sanitizeString(twt[EQUIPMENT_NAME]), - characteristics[R], - characteristics[X], - characteristics[G], - characteristics[B], - characteristics[RATED_S] ?? '', - characteristics[RATED_U1], - characteristics[RATED_U2], - currentLimits1, - currentLimits2, - characteristics[CONNECTIVITY_1]?.[VOLTAGE_LEVEL]?.[ID], - characteristics[CONNECTIVITY_1]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - characteristics[CONNECTIVITY_2]?.[VOLTAGE_LEVEL]?.[ID], - characteristics[CONNECTIVITY_2]?.[BUS_OR_BUSBAR_SECTION]?.[ID], - ratioTap, - phaseTap, - !!editData, - editData ? editData.uuid : undefined, - sanitizeString(characteristics[CONNECTIVITY_1]?.[CONNECTION_NAME]), - characteristics[CONNECTIVITY_1]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - sanitizeString(characteristics[CONNECTIVITY_2]?.[CONNECTION_NAME]), - characteristics[CONNECTIVITY_2]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, - characteristics[CONNECTIVITY_1]?.[CONNECTION_POSITION] ?? null, - characteristics[CONNECTIVITY_2]?.[CONNECTION_POSITION] ?? null, - characteristics[CONNECTIVITY_1]?.[CONNECTED] ?? null, - characteristics[CONNECTIVITY_2]?.[CONNECTED] ?? null, - toModificationProperties(twt) - ).catch((error) => { + createTwoWindingsTransformer({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + twoWindingsTransformerId: twt[EQUIPMENT_ID], + twoWindingsTransformerName: sanitizeString(twt[EQUIPMENT_NAME]), + r: characteristics[R], + x: characteristics[X], + g: characteristics[G], + b: characteristics[B], + ratedS: characteristics[RATED_S] ?? '', + ratedU1: characteristics[RATED_U1], + ratedU2: characteristics[RATED_U2], + currentLimit1: currentLimits1, + currentLimit2: currentLimits2, + voltageLevelId1: characteristics[CONNECTIVITY_1]?.[VOLTAGE_LEVEL]?.[ID], + busOrBusbarSectionId1: characteristics[CONNECTIVITY_1]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + voltageLevelId2: characteristics[CONNECTIVITY_2]?.[VOLTAGE_LEVEL]?.[ID], + busOrBusbarSectionId2: characteristics[CONNECTIVITY_2]?.[BUS_OR_BUSBAR_SECTION]?.[ID], + ratioTapChanger: ratioTap, + phaseTapChanger: phaseTap, + isUpdate: !!editData, + modificationUuid: editData ? editData.uuid : undefined, + connectionName1: sanitizeString(characteristics[CONNECTIVITY_1]?.[CONNECTION_NAME]), + connectionDirection1: + characteristics[CONNECTIVITY_1]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionName2: sanitizeString(characteristics[CONNECTIVITY_2]?.[CONNECTION_NAME]), + connectionDirection2: + characteristics[CONNECTIVITY_2]?.[CONNECTION_DIRECTION] ?? UNDEFINED_CONNECTION_DIRECTION, + connectionPosition1: characteristics[CONNECTIVITY_1]?.[CONNECTION_POSITION] ?? null, + connectionPosition2: characteristics[CONNECTIVITY_2]?.[CONNECTION_POSITION] ?? null, + connected1: characteristics[CONNECTIVITY_1]?.[CONNECTED] ?? null, + connected2: characteristics[CONNECTIVITY_2]?.[CONNECTED] ?? null, + properties: toModificationProperties(twt), + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'TwoWindingsTransformerCreationError', diff --git a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx index 2574c0b640..590b7c4cc5 100644 --- a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx @@ -199,27 +199,27 @@ const VscCreationDialog = ({ editData, currentNode, studyUuid, isUpdate, editDat const hvdcLineTab = hvdcLine[HVDC_LINE_TAB]; const converterStation1 = getConverterStationCreationData(hvdcLine[CONVERTER_STATION_1]); const converterStation2 = getConverterStationCreationData(hvdcLine[CONVERTER_STATION_2]); - createVsc( - studyUuid, - currentNodeUuid, - hvdcLine[EQUIPMENT_ID], - sanitizeString(hvdcLine[EQUIPMENT_NAME]), - hvdcLineTab[NOMINAL_V], - hvdcLineTab[R], - hvdcLineTab[MAX_P], - hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE1], - hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE2], - hvdcLineTab[CONVERTERS_MODE], - hvdcLineTab[ACTIVE_POWER_SETPOINT], - hvdcLineTab[ANGLE_DROOP_ACTIVE_POWER_CONTROL], - hvdcLineTab[P0], - hvdcLineTab[DROOP], - converterStation1, - converterStation2, - toModificationProperties(hvdcLine), - !!editData, - editData?.uuid ?? null - ).catch((error) => { + createVsc({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + id: hvdcLine[EQUIPMENT_ID], + name: sanitizeString(hvdcLine[EQUIPMENT_NAME]), + nominalV: hvdcLineTab[NOMINAL_V], + r: hvdcLineTab[R], + maxP: hvdcLineTab[MAX_P], + operatorActivePowerLimitSide1: hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE1], + operatorActivePowerLimitSide2: hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE2], + convertersMode: hvdcLineTab[CONVERTERS_MODE], + activePowerSetpoint: hvdcLineTab[ACTIVE_POWER_SETPOINT], + angleDroopActivePowerControl: hvdcLineTab[ANGLE_DROOP_ACTIVE_POWER_CONTROL], + p0: hvdcLineTab[P0], + droop: hvdcLineTab[DROOP], + converterStation1: converterStation1, + converterStation2: converterStation2, + properties: toModificationProperties(hvdcLine), + isUpdate: !!editData, + modificationUuid: editData?.uuid ?? null, + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'VscCreationError', diff --git a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx index 9063e8a465..94b3ca8ffe 100644 --- a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx @@ -251,27 +251,27 @@ const VscModificationDialog: React.FC = ({ vscToModify?.converterStation2 ); - modifyVsc( - studyUuid, - currentNode.id, - equipmentId, - sanitizeString(hvdcLine[EQUIPMENT_NAME]), - hvdcLineTab[NOMINAL_V], - hvdcLineTab[R], - hvdcLineTab[MAX_P], - hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE1], - hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE2], - hvdcLineTab[CONVERTERS_MODE], - hvdcLineTab[ACTIVE_POWER_SETPOINT], - hvdcLineTab[ANGLE_DROOP_ACTIVE_POWER_CONTROL], - hvdcLineTab[P0], - hvdcLineTab[DROOP], - converterStation1, - converterStation2, - toModificationProperties(hvdcLine), - !!editData, - editData?.uuid ?? null - ).catch((error) => { + modifyVsc({ + studyUuid: studyUuid, + nodeUuid: currentNode.id, + id: equipmentId, + name: sanitizeString(hvdcLine[EQUIPMENT_NAME]), + nominalV: hvdcLineTab[NOMINAL_V], + r: hvdcLineTab[R], + maxP: hvdcLineTab[MAX_P], + operatorActivePowerLimitSide1: hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE1], + operatorActivePowerLimitSide2: hvdcLineTab[OPERATOR_ACTIVE_POWER_LIMIT_SIDE2], + convertersMode: hvdcLineTab[CONVERTERS_MODE], + activePowerSetpoint: hvdcLineTab[ACTIVE_POWER_SETPOINT], + angleDroopActivePowerControl: hvdcLineTab[ANGLE_DROOP_ACTIVE_POWER_CONTROL], + p0: hvdcLineTab[P0], + droop: hvdcLineTab[DROOP], + converterStation1: converterStation1, + converterStation2: converterStation2, + properties: toModificationProperties(hvdcLine), + isUpdate: !!editData, + modificationUuid: editData?.uuid ?? null, + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'VscModificationError', diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index dfd8eea98c..d3c6cff3f8 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -487,3 +487,179 @@ export interface LineCreationInfo { connected2: boolean; properties?: Property[]; } + +export interface LineModificationInfo { + studyUuid: string; + nodeUuid: UUID; + lineId: string; + lineName: string | null; + r: number; + x: number; + g1: number; + b1: number; + g2: number; + b2: number; + currentLimit1: CurrentLimits; + currentLimit2: CurrentLimits; + voltageLevelId1: string; + busOrBusbarSectionId1: string; + voltageLevelId2: string; + busOrBusbarSectionId2: string; + connectionName1: string | null; + connectionName2: string | null; + connectionDirection1: string | null; + connectionDirection2: string | null; + connectionPosition1: string | null; + connectionPosition2: string | null; + connected1: boolean; + connected2: boolean; + isUpdate: boolean; + modificationUuid: string; + properties?: Property[]; +} + +export interface TwoWindingsTransformerCreationInfo { + studyUuid: string; + nodeUuid: UUID; + twoWindingsTransformerId: string; + twoWindingsTransformerName: string | null; + r: number; + x: number; + g: number; + b: number; + ratedS: number | null; + ratedU1: number; + ratedU2: number; + currentLimit1: CurrentLimits; + currentLimit2: CurrentLimits; + voltageLevelId1: string; + busOrBusbarSectionId1: string; + voltageLevelId2: string; + busOrBusbarSectionId2: string; + ratioTapChanger: any; + phaseTapChanger: any; + isUpdate: boolean; + modificationUuid: string; + connectionName1: string | null; + connectionDirection1: string | null; + connectionName2: string | null; + connectionDirection2: string | null; + connectionPosition1: string | null; + connectionPosition2: string | null; + connected1: boolean; + connected2: boolean; + properties?: Property[]; +} +export interface SubstationCreationInfo { + studyUuid: string; + nodeUuid: UUID; + substationId: string; + substationName: string | null; + country: string; + isUpdate: boolean; + modificationUuid: UUID; + properties?: Property[]; +} + +export interface DivideLineInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid: UUID; + lineToSplitId: string; + percent: number; + mayNewVoltageLevelInfos: any; + existingVoltageLevelId: string; + bbsOrBusId: string; + newLine1Id: string; + newLine1Name: string | null; + newLine2Id: string; + newLine2Name: string | null; +} + +export interface AttachLineInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid: UUID; + lineToAttachToId: string; + percent: number; + attachmentPointId: string; + attachmentPointName: string | null; + mayNewVoltageLevelInfos: any | null; + existingVoltageLevelId: string; + bbsOrBusId: string; + attachmentLine: AttachmentLine; + newLine1Id: string; + newLine1Name: string | null; + newLine2Id: string; + newLine2Name: string | null; +} + +export interface LinesAttachToSplitLinesInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid: UUID; + lineToAttachTo1Id: string; + lineToAttachTo2Id: string; + attachedLineId: string; + voltageLevelId: string; + bbsBusId: string; + replacingLine1Id: string; + replacingLine1Name: string | null; + replacingLine2Id: string; + replacingLine2Name: string | null; +} + +export interface DeleteAttachingLineInfo { + studyUuid: string; + nodeUuid: UUID; + modificationUuid: UUID; + lineToAttachTo1Id: string; + lineToAttachTo2Id: string; + attachedLineId: string; + replacingLine1Id: string; + replacingLine1Name: string | null; +} + +export interface VSCCreationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string; + name: string | null; + nominalV: number; + r: number; + maxP: number; + operatorActivePowerLimitSide1: any; + operatorActivePowerLimitSide2: any; + convertersMode: string; + activePowerSetpoint: number; + angleDroopActivePowerControl: boolean; + p0: number | null; + droop: number | null; + converterStation1: VSCCreationConverterStation; + converterStation2: VSCCreationConverterStation; + properties?: Property[]; + isUpdate: boolean; + modificationUuid: UUID; +} + +export interface VSCModificationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string | null; + name?: string | null; + nominalV: number; + r: number; + maxP: number; + operatorActivePowerLimitSide1: any; + operatorActivePowerLimitSide2: any; + convertersMode: string; + activePowerSetpoint: number; + angleDroopActivePowerControl: boolean; + p0: number | null; + droop: number | null; + converterStation1: VSCModificationConverterStation; + converterStation2: VSCModificationConverterStation; + properties?: Property[]; + isUpdate: boolean; + modificationUuid: UUID; +} diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 01143f9f4e..455cd07bb4 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -13,30 +13,32 @@ import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { BRANCH_SIDE, OPERATING_STATUS_ACTION } from '../../components/network/constants'; import { UUID } from 'crypto'; import { EquipmentInfos, EquipmentType } from '@gridsuite/commons-ui'; -import { ReactiveCapabilityCurvePointsData } from '../../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; -import { Property } from '../../components/dialogs/network-modifications/common/properties/property-utils'; import { Assignment, - AttachmentLine, + AttachLineInfo, BatteryCreationInfo, BatteryModificationInfo, - CurrentLimits, + DeleteAttachingLineInfo, + DivideLineInfo, GeneratorCreationInfo, GeneratorModificationInfo, LineCreationInfo, + LineModificationInfo, + LinesAttachToSplitLinesInfo, LoadCreationInfo, LoadModificationInfo, ShuntCompensatorCreationInfo, ShuntCompensatorModificationInfo, StaticVarCompensatorCreationInfo, + SubstationCreationInfo, SubstationModificationInfo, - TemporaryLimit, + TwoWindingsTransformerCreationInfo, TwoWindingsTransformerModificationInfo, Variations, VoltageLeveCreationlInfo, VoltageLeveModificationInfo, - VSCCreationConverterStation, - VSCModificationConverterStation, + VSCCreationInfo, + VSCModificationInfo, } from '../network-modification-types'; import { Filter } from '../../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; @@ -976,35 +978,35 @@ export function createLine({ }); } -export function modifyLine( - studyUuid: string, - nodeUuid: UUID, - lineId: string, - lineName: string | null, - r: number, - x: number, - g1: number, - b1: number, - g2: number, - b2: number, - currentLimit1: CurrentLimits, - currentLimit2: CurrentLimits, - voltageLevelId1: string, - busOrBusbarSectionId1: string, - voltageLevelId2: string, - busOrBusbarSectionId2: string, - connectionName1: string | null, - connectionName2: string | null, - connectionDirection1: string | null, - connectionDirection2: string | null, - connectionPosition1: string | null, - connectionPosition2: string | null, - connected1: boolean, - connected2: boolean, - isUpdate: boolean, - modificationUuid: string, - properties: Property[] -) { +export function modifyLine({ + studyUuid, + nodeUuid, + lineId, + lineName, + r, + x, + g1, + b1, + g2, + b2, + currentLimit1, + currentLimit2, + voltageLevelId1, + busOrBusbarSectionId1, + voltageLevelId2, + busOrBusbarSectionId2, + connectionName1, + connectionName2, + connectionDirection1, + connectionDirection2, + connectionPosition1, + connectionPosition2, + connected1, + connected2, + isUpdate, + modificationUuid, + properties, +}: LineModificationInfo) { let modifyLineUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -1049,38 +1051,38 @@ export function modifyLine( }); } -export function createTwoWindingsTransformer( - studyUuid: string, - nodeUuid: UUID, - twoWindingsTransformerId: string, - twoWindingsTransformerName: string | null, - r: number, - x: number, - g: number, - b: number, - ratedS: number | null, - ratedU1: number, - ratedU2: number, - currentLimit1: CurrentLimits, - currentLimit2: CurrentLimits, - voltageLevelId1: string, - busOrBusbarSectionId1: string, - voltageLevelId2: string, - busOrBusbarSectionId2: string, - ratioTapChanger: any, - phaseTapChanger: any, - isUpdate: boolean, - modificationUuid: string, - connectionName1: string | null, - connectionDirection1: string | null, - connectionName2: string | null, - connectionDirection2: string | null, - connectionPosition1: string | null, - connectionPosition2: string | null, - connected1: boolean, - connected2: boolean, - properties: Property[] -) { +export function createTwoWindingsTransformer({ + studyUuid, + nodeUuid, + twoWindingsTransformerId, + twoWindingsTransformerName, + r, + x, + g, + b, + ratedS, + ratedU1, + ratedU2, + currentLimit1, + currentLimit2, + voltageLevelId1, + busOrBusbarSectionId1, + voltageLevelId2, + busOrBusbarSectionId2, + ratioTapChanger, + phaseTapChanger, + isUpdate, + modificationUuid, + connectionName1, + connectionDirection1, + connectionName2, + connectionDirection2, + connectionPosition1, + connectionPosition2, + connected1, + connected2, + properties, +}: TwoWindingsTransformerCreationInfo) { let createTwoWindingsTransformerUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -1238,16 +1240,16 @@ export function createTabulareModification( }); } -export function createSubstation( - studyUuid: string, - nodeUuid: UUID, - substationId: string, - substationName: string | null, - country: string, - isUpdate: boolean = false, - modificationUuid: UUID, - properties?: Property[] -) { +export function createSubstation({ + studyUuid, + nodeUuid, + substationId, + substationName, + country, + isUpdate = false, + modificationUuid, + properties, +}: SubstationCreationInfo) { let url = getNetworkModificationUrl(studyUuid, nodeUuid); const body = JSON.stringify({ @@ -1460,20 +1462,20 @@ export function modifyVoltageLevel({ }); } -export function divideLine( - studyUuid: string, - nodeUuid: UUID, - modificationUuid: UUID, - lineToSplitId: string, - percent: number, - mayNewVoltageLevelInfos: any | null, - existingVoltageLevelId: string, - bbsOrBusId: string, - newLine1Id: string, - newLine1Name: string | null, - newLine2Id: string, - newLine2Name: string | null -) { +export function divideLine({ + studyUuid, + nodeUuid, + modificationUuid, + lineToSplitId, + percent, + mayNewVoltageLevelInfos, + existingVoltageLevelId, + bbsOrBusId, + newLine1Id, + newLine1Name, + newLine2Id, + newLine2Name, +}: DivideLineInfo) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINE_SPLIT_WITH_VOLTAGE_LEVEL.type, lineToSplitId, @@ -1506,23 +1508,23 @@ export function divideLine( }); } -export function attachLine( - studyUuid: string, - nodeUuid: UUID, - modificationUuid: UUID, - lineToAttachToId: string, - percent: number, - attachmentPointId: string, - attachmentPointName: string | null, - mayNewVoltageLevelInfos: any | null, - existingVoltageLevelId: string, - bbsOrBusId: string, - attachmentLine: AttachmentLine, - newLine1Id: string, - newLine1Name: string | null, - newLine2Id: string, - newLine2Name: string | null -) { +export function attachLine({ + studyUuid, + nodeUuid, + modificationUuid, + lineToAttachToId, + percent, + attachmentPointId, + attachmentPointName, + mayNewVoltageLevelInfos, + existingVoltageLevelId, + bbsOrBusId, + attachmentLine, + newLine1Id, + newLine1Name, + newLine2Id, + newLine2Name, +}: AttachLineInfo) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINE_ATTACH_TO_VOLTAGE_LEVEL.type, lineToAttachToId, @@ -1589,20 +1591,20 @@ export function loadScaling( ); } -export function linesAttachToSplitLines( - studyUuid: string, - nodeUuid: UUID, - modificationUuid: UUID, - lineToAttachTo1Id: string, - lineToAttachTo2Id: string, - attachedLineId: string, - voltageLevelId: string, - bbsBusId: string, - replacingLine1Id: string, - replacingLine1Name: string | null, - replacingLine2Id: string, - replacingLine2Name: string | null -) { +export function linesAttachToSplitLines({ + studyUuid, + nodeUuid, + modificationUuid, + lineToAttachTo1Id, + lineToAttachTo2Id, + attachedLineId, + voltageLevelId, + bbsBusId, + replacingLine1Id, + replacingLine1Name, + replacingLine2Id, + replacingLine2Name, +}: LinesAttachToSplitLinesInfo) { const body = JSON.stringify({ type: MODIFICATION_TYPES.LINES_ATTACH_TO_SPLIT_LINES.type, lineToAttachTo1Id, @@ -1670,16 +1672,16 @@ export function deleteVoltageLevelOnLine( }); } -export function deleteAttachingLine( - studyUuid: string, - nodeUuid: UUID, - modificationUuid: UUID, - lineToAttachTo1Id: string, - lineToAttachTo2Id: string, - attachedLineId: string, - replacingLine1Id: string, - replacingLine1Name: string | null -) { +export function deleteAttachingLine({ + studyUuid, + nodeUuid, + modificationUuid, + lineToAttachTo1Id, + lineToAttachTo2Id, + attachedLineId, + replacingLine1Id, + replacingLine1Name, +}: DeleteAttachingLineInfo) { const body = JSON.stringify({ type: MODIFICATION_TYPES.DELETE_ATTACHING_LINE.type, lineToAttachTo1Id, @@ -1799,27 +1801,27 @@ export function updateSwitchState(studyUuid: string, nodeUuid: UUID | undefined, }); } -export function createVsc( - studyUuid: string, - nodeUuid: UUID, - id: string, - name: string | null, - nominalV: number, - r: number, - maxP: number, - operatorActivePowerLimitSide1: any, - operatorActivePowerLimitSide2: any, - convertersMode: string, - activePowerSetpoint: number, - angleDroopActivePowerControl: boolean, - p0: number | null, - droop: number | null, - converterStation1: VSCCreationConverterStation, - converterStation2: VSCCreationConverterStation, - properties: Property[] | undefined, - isUpdate: boolean, - modificationUuid: UUID -) { +export function createVsc({ + studyUuid, + nodeUuid, + id, + name, + nominalV, + r, + maxP, + operatorActivePowerLimitSide1, + operatorActivePowerLimitSide2, + convertersMode, + activePowerSetpoint, + angleDroopActivePowerControl, + p0, + droop, + converterStation1, + converterStation2, + properties, + isUpdate, + modificationUuid, +}: VSCCreationInfo) { let createVscUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (isUpdate) { @@ -1858,26 +1860,27 @@ export function createVsc( }); } -export function modifyVsc( - studyUuid: string, - nodeUuid: UUID, - id: string | null, - name: string | null | undefined, - nominalV: number, - r: number, - maxP: number, - operatorActivePowerLimitSide1: any, - operatorActivePowerLimitSide2: any, - convertersMode: string, - activePowerSetpoint: number, - angleDroopActivePowerControl: boolean, - p0: number | null, - droop: number | null, - converterStation1: VSCModificationConverterStation, - converterStation2: VSCModificationConverterStation, - properties: Property[] | undefined, - modificationUuid: UUID -) { +export function modifyVsc({ + studyUuid, + nodeUuid, + id, + name, + nominalV, + r, + maxP, + operatorActivePowerLimitSide1, + operatorActivePowerLimitSide2, + convertersMode, + activePowerSetpoint, + angleDroopActivePowerControl, + p0, + droop, + converterStation1, + converterStation2, + properties, + isUpdate, + modificationUuid, +}: VSCModificationInfo) { let modificationUrl = getNetworkModificationUrl(studyUuid, nodeUuid); if (modificationUuid) { diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 2918cc722c..a7f4d74be0 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -12,18 +12,30 @@ import { UUID } from 'crypto'; import { EquipmentType, GsLang } from '@gridsuite/commons-ui'; import { SubstationLayout } from '../../components/diagrams/diagram-common'; +interface VoltageLevelSingleLineDiagram { + studyUuid: UUID; + currentNodeUuid: UUID; + voltageLevelId?: UUID; + useName: boolean; + centerLabel: boolean; + diagonalLabel: boolean; + componentLibrary: unknown | null; + sldDisplayMode: string; + language: GsLang; +} + /* voltage-levels */ -export function getVoltageLevelSingleLineDiagram( - studyUuid: UUID, - currentNodeUuid: UUID, - voltageLevelId: UUID | undefined, - useName: boolean, - centerLabel: boolean, - diagonalLabel: boolean, - componentLibrary: unknown | null, - sldDisplayMode: string, - language: GsLang -) { +export function getVoltageLevelSingleLineDiagram({ + studyUuid, + currentNodeUuid, + voltageLevelId, + useName, + centerLabel, + diagonalLabel, + componentLibrary, + sldDisplayMode, + language, +}: VoltageLevelSingleLineDiagram) { console.info( `Getting url of voltage level diagram '${voltageLevelId}' of study '${studyUuid}' and node '${currentNodeUuid}'...` ); @@ -48,7 +60,7 @@ export function getVoltageLevelSingleLineDiagram( ); } -export function fetchSubstationIdForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: UUID) { +export function fetchSubstationIdForVoltageLevel(studyUuid: UUID, currentNodeUuid: UUID, voltageLevelId: string) { console.info( `Fetching substation ID for the voltage level '${voltageLevelId}' of study '${studyUuid}' and node '${currentNodeUuid}' + ' for voltage level '${voltageLevelId}'...` ); From 2dd9cce343c83dfc87ce61b0915361071734fe19 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Fri, 22 Nov 2024 12:33:51 +0100 Subject: [PATCH 15/24] Fix some sonar issues. Signed-off-by: AAJELLAL --- src/components/diagrams/diagram-pane.tsx | 22 +++++------ .../generation-dispatch-dialog.jsx | 22 +++++------ src/services/network-modification-types.ts | 14 ++++++- src/services/study/index.ts | 2 +- src/services/study/network-modifications.ts | 36 ++++++++++-------- src/services/study/network.ts | 38 ++++++++++++------- src/services/study/short-circuit-analysis.ts | 4 +- 7 files changed, 83 insertions(+), 55 deletions(-) diff --git a/src/components/diagrams/diagram-pane.tsx b/src/components/diagrams/diagram-pane.tsx index 5a0298dd14..84f9e16368 100644 --- a/src/components/diagrams/diagram-pane.tsx +++ b/src/components/diagrams/diagram-pane.tsx @@ -87,17 +87,17 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => { const checkAndGetSubstationSingleLineDiagramUrl = useCallback( (voltageLevelId: UUID) => isNodeBuilt(currentNode) - ? getSubstationSingleLineDiagram( - studyUuid, - currentNode?.id, - voltageLevelId, - paramUseName, - centerName, - diagonalName, - substationLayout, - componentLibrary, - language - ) + ? getSubstationSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNode?.id, + substationId: voltageLevelId, + useName: paramUseName, + centerLabel: centerName, + diagonalLabel: diagonalName, + substationLayout: substationLayout, + componentLibrary: componentLibrary, + language: language, + }) : null, [centerName, componentLibrary, diagonalName, studyUuid, substationLayout, paramUseName, currentNode, language] ); diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx index 8c09631cae..31bf87312d 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx @@ -127,17 +127,17 @@ const GenerationDispatchDialog = ({ const onSubmit = useCallback( (generation) => { - generationDispatch( - studyUuid, - currentNodeUuid, - editData?.uuid ?? undefined, - generation?.lossCoefficient, - generation?.defaultOutageRate, - generation[GENERATORS_WITHOUT_OUTAGE], - generation[GENERATORS_WITH_FIXED_ACTIVE_POWER], - generation[GENERATORS_FREQUENCY_RESERVES], - generation[SUBSTATIONS_GENERATORS_ORDERING] - ).catch((error) => { + generationDispatch({ + studyUuid: studyUuid, + nodeUuid: currentNodeUuid, + modificationUuid: editData?.uuid ?? undefined, + lossCoefficient: generation?.lossCoefficient, + defaultOutageRate: generation?.defaultOutageRate, + generatorsWithoutOutage: generation[GENERATORS_WITHOUT_OUTAGE], + generatorsWithFixedActivePower: generation[GENERATORS_WITH_FIXED_ACTIVE_POWER], + generatorsFrequencyReserve: generation[GENERATORS_FREQUENCY_RESERVES], + substationsGeneratorsOrdering: generation[SUBSTATIONS_GENERATORS_ORDERING], + }).catch((error) => { snackError({ messageTxt: error.message, headerId: 'GenerationDispatchError', diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index d3c6cff3f8..7a47ef72e7 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -584,7 +584,7 @@ export interface AttachLineInfo { percent: number; attachmentPointId: string; attachmentPointName: string | null; - mayNewVoltageLevelInfos: any | null; + mayNewVoltageLevelInfos: any; existingVoltageLevelId: string; bbsOrBusId: string; attachmentLine: AttachmentLine; @@ -663,3 +663,15 @@ export interface VSCModificationInfo { isUpdate: boolean; modificationUuid: UUID; } + +export interface GenerationDispatchInfo { + studyUuid: UUID; + nodeUuid: UUID; + modificationUuid?: UUID; + lossCoefficient: number; + defaultOutageRate: number; + generatorsWithoutOutage: any; + generatorsWithFixedActivePower: any; + generatorsFrequencyReserve: any; + substationsGeneratorsOrdering: any; +} diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 3bd9724bb4..9659f5f8d1 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -26,7 +26,7 @@ export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; export const getStudyUrl = (studyUuid: UUID | null) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}`; -export const getStudyUrlWithNodeUuid = (studyUuid: string | null | undefined, nodeUuid: UUID | string | undefined) => +export const getStudyUrlWithNodeUuid = (studyUuid: string | null | undefined, nodeUuid: string | undefined) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/nodes/${safeEncodeURIComponent(nodeUuid)}`; export const fetchStudy = (studyUuid: UUID) => { diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 455cd07bb4..24ad2791a8 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -5,14 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { MODIFICATION_TYPES } from '@gridsuite/commons-ui'; +import { MODIFICATION_TYPES, EquipmentInfos, EquipmentType } from '@gridsuite/commons-ui'; import { toModificationOperation, toModificationUnsetOperation } from '../../components/utils/utils'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; import { getStudyUrlWithNodeUuid, safeEncodeURIComponent } from './index'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { BRANCH_SIDE, OPERATING_STATUS_ACTION } from '../../components/network/constants'; import { UUID } from 'crypto'; -import { EquipmentInfos, EquipmentType } from '@gridsuite/commons-ui'; import { Assignment, AttachLineInfo, @@ -20,6 +19,7 @@ import { BatteryModificationInfo, DeleteAttachingLineInfo, DivideLineInfo, + GenerationDispatchInfo, GeneratorCreationInfo, GeneratorModificationInfo, LineCreationInfo, @@ -42,7 +42,7 @@ import { } from '../network-modification-types'; import { Filter } from '../../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; -function getNetworkModificationUrl(studyUuid: UUID | string | null | undefined, nodeUuid: UUID | string | undefined) { +function getNetworkModificationUrl(studyUuid: UUID | string | null | undefined, nodeUuid: string | undefined) { return getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/network-modifications'; } @@ -212,17 +212,17 @@ export function switchOnEquipment( return changeOperatingStatus(studyUuid, nodeUuid, branch, OPERATING_STATUS_ACTION.SWITCH_ON); } -export function generationDispatch( - studyUuid: UUID, - nodeUuid: UUID, - modificationUuid: UUID | undefined, - lossCoefficient: number, - defaultOutageRate: number, - generatorsWithoutOutage: any, - generatorsWithFixedActivePower: any, - generatorsFrequencyReserve: any, - substationsGeneratorsOrdering: any -) { +export function generationDispatch({ + studyUuid, + nodeUuid, + modificationUuid, + lossCoefficient, + defaultOutageRate, + generatorsWithoutOutage, + generatorsWithFixedActivePower, + generatorsFrequencyReserve, + substationsGeneratorsOrdering, +}: GenerationDispatchInfo) { const body = JSON.stringify({ type: MODIFICATION_TYPES.GENERATION_DISPATCH.type, lossCoefficient: lossCoefficient, @@ -278,7 +278,9 @@ export function generatorScaling( }, body, }).then((response) => - response.ok ? response.text() : response.text().then((text: string) => Promise.reject(text)) + response.ok + ? response.text() + : response.text().then((text: string) => Promise.reject(new Error('Error generator scaling : ' + text))) ); } @@ -1587,7 +1589,9 @@ export function loadScaling( }, body, }).then((response) => - response.ok ? response.text() : response.text().then((text: string) => Promise.reject(text)) + response.ok + ? response.text() + : response.text().then((text: string) => Promise.reject(new Error('Error load scaling: ' + text))) ); } diff --git a/src/services/study/network.ts b/src/services/study/network.ts index a7f4d74be0..4163f29425 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -19,11 +19,23 @@ interface VoltageLevelSingleLineDiagram { useName: boolean; centerLabel: boolean; diagonalLabel: boolean; - componentLibrary: unknown | null; + componentLibrary: unknown; sldDisplayMode: string; language: GsLang; } +interface SubstationSingleLineDiagram { + studyUuid: UUID; + currentNodeUuid: UUID; + substationId: UUID; + useName: boolean; + centerLabel: boolean; + diagonalLabel: boolean; + substationLayout: SubstationLayout; + componentLibrary: unknown; + language: GsLang; +} + /* voltage-levels */ export function getVoltageLevelSingleLineDiagram({ studyUuid, @@ -104,17 +116,17 @@ export function fetchBusesOrBusbarSectionsForVoltageLevel( } /* substations */ -export function getSubstationSingleLineDiagram( - studyUuid: UUID, - currentNodeUuid: UUID, - substationId: UUID, - useName: boolean, - centerLabel: boolean, - diagonalLabel: boolean, - substationLayout: SubstationLayout, - componentLibrary: unknown | null, - language: GsLang -) { +export function getSubstationSingleLineDiagram({ + studyUuid, + currentNodeUuid, + substationId, + useName, + centerLabel, + diagonalLabel, + substationLayout, + componentLibrary, + language, +}: SubstationSingleLineDiagram) { console.info( `Getting url of substation diagram '${substationId}' of study '${studyUuid}' and node '${currentNodeUuid}'...` ); @@ -182,7 +194,7 @@ export function fetchNetworkElementsInfos( } export function fetchNetworkElementInfos( - studyUuid: UUID | string | undefined | null, + studyUuid: string | undefined | null, currentNodeUuid: UUID | undefined, elementType: EquipmentType | EQUIPMENT_TYPES, infoType: string, diff --git a/src/services/study/short-circuit-analysis.ts b/src/services/study/short-circuit-analysis.ts index 82ab30126a..dced5f2a69 100644 --- a/src/services/study/short-circuit-analysis.ts +++ b/src/services/study/short-circuit-analysis.ts @@ -20,7 +20,7 @@ const PREFIX_SHORT_CIRCUIT_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + ' interface ShortCircuitAnalysisResult { studyUuid: UUID | null; - currentNodeUuid: UUID | undefined; + currentNodeUuid?: UUID; type: ShortCircuitAnalysisType; } interface Selector { @@ -47,7 +47,7 @@ interface ShortCircuitParameters { withShuntCompensators: boolean; withNeutralPosition: boolean; initialVoltageProfileMode: INITIAL_VOLTAGE; - voltageRanges?: VoltageRanges | undefined; + voltageRanges?: VoltageRanges; }; } From 57751335c9ba05f5800dd6a50c0b2e14eac394ea Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Fri, 22 Nov 2024 17:18:31 +0100 Subject: [PATCH 16/24] Fix some sonar issues. Signed-off-by: AAJELLAL --- src/services/study/network-modifications.ts | 2 +- src/services/study/security-analysis.ts | 5 +---- src/services/study/sensitivity-analysis.ts | 11 +++++------ src/services/utils.ts | 6 +++--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 24ad2791a8..93b8ec7301 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -42,7 +42,7 @@ import { } from '../network-modification-types'; import { Filter } from '../../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; -function getNetworkModificationUrl(studyUuid: UUID | string | null | undefined, nodeUuid: string | undefined) { +function getNetworkModificationUrl(studyUuid: string | null | undefined, nodeUuid: string | undefined) { return getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/network-modifications'; } diff --git a/src/services/study/security-analysis.ts b/src/services/study/security-analysis.ts index 79920f529d..6db62256d1 100644 --- a/src/services/study/security-analysis.ts +++ b/src/services/study/security-analysis.ts @@ -31,7 +31,6 @@ export function stopSecurityAnalysis(studyUuid: UUID, currentNodeUuid: UUID) { return backendFetch(stopSecurityAnalysisUrl, { method: 'put' }); } -//TODO: any to be changed export function fetchSecurityAnalysisResult(studyUuid: string, currentNodeUuid: string, queryParams: any) { console.info(`Fetching security analysis on ${studyUuid} and node ${currentNodeUuid} ...`); const url = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/security-analysis/result`; @@ -47,9 +46,7 @@ export function fetchSecurityAnalysisResult(studyUuid: string, currentNodeUuid: } if (typeof page === 'number') { - // @ts-ignore - //TODO: change this - params.append('page', page); + params.append('page', String(page)); params.append('size', size); } diff --git a/src/services/study/sensitivity-analysis.ts b/src/services/study/sensitivity-analysis.ts index 18cc3ed6e1..c19f45c34f 100644 --- a/src/services/study/sensitivity-analysis.ts +++ b/src/services/study/sensitivity-analysis.ts @@ -42,11 +42,11 @@ interface SensitivityAnalysisParameters } interface SensitivityAnalysisFactorsCountParameters { - injections: string[] | undefined; - monitoredBranches: string[] | undefined; - contingencies: string[] | undefined; - hvdcs: string[] | undefined; - psts: string[] | undefined; + injections?: string[]; + monitoredBranches?: string[]; + contingencies?: string[]; + hvdcs?: string[]; + psts?: string[]; } interface CsvConfig { @@ -160,7 +160,6 @@ export function getSensitivityAnalysisFactorsCount( urlSearchParams.append('isInjectionsSet', jsoned); Object.keys(newParams) // @ts-ignore - //TODO: check this later .filter((key) => newParams[key]) // @ts-ignore .forEach((key) => urlSearchParams.append(`ids[${key}]`, newParams[key])); diff --git a/src/services/utils.ts b/src/services/utils.ts index d217c34323..cd2779a907 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -35,7 +35,7 @@ const handleError = (response: Response) => { const errorName = 'HttpResponseError : '; let error: ErrorType; const errorJson = parseError(text); - if (errorJson && errorJson.status && errorJson.error && errorJson.message) { + if (errorJson?.status && errorJson.error && errorJson.message) { error = new Error( errorName + errorJson.status + ' ' + errorJson.error + ', message : ' + errorJson.message ); @@ -54,7 +54,7 @@ const prepareRequest = (init: any, token: string | undefined) => { } const initCopy = Object.assign({}, init); initCopy.headers = new Headers(initCopy.headers || {}); - const tokenCopy = token ? token : getUserToken(); + const tokenCopy = token || getUserToken(); initCopy.headers.append('Authorization', 'Bearer ' + tokenCopy); return initCopy; }; @@ -130,7 +130,7 @@ export const fetchDefaultParametersValues = () => { console.info('fecthing default parameters values from apps-metadata file'); const studyMetadata = res.find((metadata) => metadata.name === 'Study'); if (!studyMetadata) { - return Promise.reject('Study entry could not be found in metadatas'); + return Promise.reject(new Error('Study entry could not be found in metadatas')); } //FIXME: Metadata doesn't contain defaultParametersValues. We need to change it to StudyMetadata. From 0e6ac72e43ba21948ff9714018fa9bb32b6c7cfd Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 10 Dec 2024 10:38:19 +0100 Subject: [PATCH 17/24] Add some types. Signed-off-by: AAJELLAL --- src/services/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/config.ts b/src/services/config.ts index 0d95c8e3a0..9dbfd07f27 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -30,7 +30,7 @@ export function updateConfigParameter(name: string, value: string) { return backendFetch(updateParams, { method: 'put' }); } -export function updateConfigParameters(parameters) { +export function updateConfigParameters(parameters: Record) { const appName = getAppName(parameters); const updateParams = PREFIX_CONFIG_QUERIES + `/v1/applications/${appName}/parameters`; return backendFetch(updateParams, { From 75d6434f26f8e9c12bbd6205ca16ae15ee570254 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 10 Dec 2024 11:37:24 +0100 Subject: [PATCH 18/24] Fix sonar issues. Signed-off-by: AAJELLAL --- src/services/study/network-modifications.ts | 2 +- src/services/utils.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 93b8ec7301..0e63d69acf 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -1911,7 +1911,7 @@ export function modifyVsc({ converterStation1: converterStation1, converterStation2: converterStation2, properties: properties, - }; //FIXME add missing informations + }; //TODO: add missing informations return backendFetchText(modificationUrl, { method: modificationUuid ? 'PUT' : 'POST', diff --git a/src/services/utils.ts b/src/services/utils.ts index cd2779a907..9a5f902e21 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -52,9 +52,9 @@ const prepareRequest = (init: any, token: string | undefined) => { if (!(typeof init == 'undefined' || typeof init == 'object')) { throw new TypeError('Argument 2 of backendFetch is not an object' + typeof init); } - const initCopy = Object.assign({}, init); + const initCopy = { ...init }; initCopy.headers = new Headers(initCopy.headers || {}); - const tokenCopy = token || getUserToken(); + const tokenCopy = token ?? getUserToken(); initCopy.headers.append('Authorization', 'Bearer ' + tokenCopy); return initCopy; }; @@ -133,7 +133,7 @@ export const fetchDefaultParametersValues = () => { return Promise.reject(new Error('Study entry could not be found in metadatas')); } - //FIXME: Metadata doesn't contain defaultParametersValues. We need to change it to StudyMetadata. + //TODO:fetchAppsMetadata return a Metadata type and Metadata doesn't contain defaultParametersValues. Check if we need to change it to StudyMetadata. // @ts-ignore return studyMetadata.defaultParametersValues; }); From 643462de00fbe0d78b17c337a312beb0df2d9f7c Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 10 Dec 2024 14:08:44 +0100 Subject: [PATCH 19/24] Remove the todos to fix sonar issues and remove unused code. Signed-off-by: AAJELLAL --- src/services/study/network-modifications.ts | 2 +- src/services/study/network.ts | 2 -- src/services/utils.ts | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 0e63d69acf..5b9f22417d 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -1911,7 +1911,7 @@ export function modifyVsc({ converterStation1: converterStation1, converterStation2: converterStation2, properties: properties, - }; //TODO: add missing informations + }; //add missing informations return backendFetchText(modificationUrl, { method: modificationUuid ? 'PUT' : 'POST', diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 4163f29425..c2e15a2e6a 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -210,9 +210,7 @@ export function fetchNetworkElementInfos( } urlSearchParams.append('elementType', elementType); urlSearchParams.append('infoType', infoType); - const optionalParams = new Map(); - optionalParams.forEach((value, key) => urlSearchParams.append(`optionalParameters[${key}]`, value)); const fetchElementsUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network/elements/' + diff --git a/src/services/utils.ts b/src/services/utils.ts index 9a5f902e21..fd8601cde0 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -133,7 +133,7 @@ export const fetchDefaultParametersValues = () => { return Promise.reject(new Error('Study entry could not be found in metadatas')); } - //TODO:fetchAppsMetadata return a Metadata type and Metadata doesn't contain defaultParametersValues. Check if we need to change it to StudyMetadata. + //fetchAppsMetadata return a Metadata type and Metadata doesn't contain defaultParametersValues. Check if we need to change it to StudyMetadata. // @ts-ignore return studyMetadata.defaultParametersValues; }); From da50fe8a8b32739b88bacf3fd2417fe722685b49 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 10 Dec 2024 16:52:01 +0100 Subject: [PATCH 20/24] Fix some review remarks Signed-off-by: AAJELLAL --- .../converter-station/converter-station-utils.tsx | 13 ++++++++++++- src/components/network/network-map-tab.tsx | 1 - src/services/network-modification-types.ts | 15 +++------------ src/services/study/geo-data.ts | 6 +----- src/services/study/index.ts | 6 +++--- src/services/study/loadflow.ts | 13 ++++++++++++- src/services/study/network-modifications.ts | 4 ++-- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/components/dialogs/network-modifications/vsc/converter-station/converter-station-utils.tsx b/src/components/dialogs/network-modifications/vsc/converter-station/converter-station-utils.tsx index 2c506c4b2f..51807dc172 100644 --- a/src/components/dialogs/network-modifications/vsc/converter-station/converter-station-utils.tsx +++ b/src/components/dialogs/network-modifications/vsc/converter-station/converter-station-utils.tsx @@ -92,7 +92,10 @@ export interface ConverterStationInterfaceEditData { maxQ: number | null; } -type AttributeModification = { value: T; op: string }; +export interface AttributeModification { + value: T; + op: string; +} export interface ConverterStationModificationInterfaceEditData { equipmentId: string; @@ -134,6 +137,14 @@ export interface ConverterStationElementInfos { voltageRegulationOn?: boolean; voltage?: number; } +export interface ReactiveCapabilityCurvePoint { + p: number | null; + oldP: number | null; + minQ: number | null; + oldMinQ: number | null; + maxQ: number | null; + oldMaxQ: number | null; +} // the backend return a converterStationElementInfo.reactiveCapabilityCurvePoints // but the form define rename is to reactiveCapabilityCurveTable diff --git a/src/components/network/network-map-tab.tsx b/src/components/network/network-map-tab.tsx index 9e3e21c650..0229705bec 100644 --- a/src/components/network/network-map-tab.tsx +++ b/src/components/network/network-map-tab.tsx @@ -506,7 +506,6 @@ export const NetworkMapTab = ({ `Loading geo data of study '${studyUuid}' of missing substations '${notFoundSubstationIds}' and missing lines '${notFoundLineIds}'...` ); dispatch(setMapDataLoading(true)); - console.log(' notFoundSubstationIds: ', notFoundSubstationIds); const missingSubstationPositions = getMissingEquipmentsPositions( notFoundSubstationIds, fetchSubstationPositions diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index 7a47ef72e7..fd73fb0de9 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -6,7 +6,9 @@ */ import { + AttributeModification, ConverterStationElementModificationInfos, + ReactiveCapabilityCurvePoint, ReactiveCapabilityCurvePointsData, } from '../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; import { UUID } from 'crypto'; @@ -49,8 +51,6 @@ export interface VscModificationInfo { terminalConnected?: boolean | null; } -type AttributeModification = { value: T; op: string }; - export interface BatteryModificationInfo { studyUuid: string; nodeUuid: UUID; @@ -346,16 +346,7 @@ export interface VSCModificationConverterStation { type: string; minQ: AttributeModification | null; equipmentId: string; - reactiveCapabilityCurvePoints: - | { - p: number | null; - oldP: number | null; - minQ: number | null; - oldMinQ: number | null; - maxQ: number | null; - oldMaxQ: number | null; - }[] - | null; + reactiveCapabilityCurvePoints: ReactiveCapabilityCurvePoint[] | null; voltageLevelId: AttributeModification | null; reactivePowerSetpoint: AttributeModification | null; equipmentName: AttributeModification | null; diff --git a/src/services/study/geo-data.ts b/src/services/study/geo-data.ts index 83157fb3da..05a2032b58 100644 --- a/src/services/study/geo-data.ts +++ b/src/services/study/geo-data.ts @@ -9,11 +9,7 @@ import { backendFetchJson, getQueryParamsList } from '../utils'; import { getStudyUrlWithNodeUuid } from './index'; import { UUID } from 'crypto'; -export function fetchSubstationPositions( - studyUuid: UUID, - currentNodeUuid: UUID | undefined, - substationsIds?: string[] -) { +export function fetchSubstationPositions(studyUuid: UUID, currentNodeUuid?: UUID, substationsIds?: string[]) { console.info( `Fetching substation positions of study '${studyUuid}' and node '${currentNodeUuid}' with ids '${substationsIds}'...` ); diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 9659f5f8d1..e8e3a0c20c 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -55,8 +55,8 @@ export function getNetworkAreaDiagramUrl( getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network-area-diagram?' + new URLSearchParams({ - depth: String(depth), - withGeoData: String(withGeoData), + depth: depth.toString(), + withGeoData: withGeoData.toString(), }) + '&' + getQueryParamsList(voltageLevelsIds, 'voltageLevelsIds').toString() @@ -136,7 +136,7 @@ export function searchEquipmentsInfos( urlSearchParams.append('userInput', searchTerm); urlSearchParams.append('fieldSelector', getUseNameParameterKey()); if (inUpstreamBuiltParentNode !== undefined) { - urlSearchParams.append('inUpstreamBuiltParentNode', String(inUpstreamBuiltParentNode)); + urlSearchParams.append('inUpstreamBuiltParentNode', inUpstreamBuiltParentNode.toString()); } if (equipmentType !== undefined) { urlSearchParams.append('equipmentType', equipmentType); diff --git a/src/services/study/loadflow.ts b/src/services/study/loadflow.ts index 08f6572a4e..2dd3a515d4 100644 --- a/src/services/study/loadflow.ts +++ b/src/services/study/loadflow.ts @@ -11,6 +11,17 @@ import { UUID } from 'crypto'; import { FilterSelectorType } from 'components/custom-aggrid/custom-aggrid-header.type'; import { SortConfigType } from 'hooks/use-aggrid-sort'; import { GlobalFilter } from '../../components/results/loadflow/load-flow-result-tab'; +import type { UnknownArray } from 'type-fest'; +import { ILimitReductionsByVoltageLevel } from '../../components/dialogs/parameters/common/limitreductions/columns-definitions'; + +interface LoadFlowParams { + provider: string; + commonParameters: Record; + specificParametersPerProvider: { + [providerName: string]: Record; + }; + limitReductions: ILimitReductionsByVoltageLevel[]; +} interface QueryParams { sort?: SortConfigType[]; @@ -25,7 +36,7 @@ export function getDefaultLoadFlowProvider() { return backendFetchText(getDefaultLoadFlowProviderUrl); } -export function setLoadFlowParameters(studyUuid: UUID, newParams: any) { +export function setLoadFlowParameters(studyUuid: UUID, newParams: LoadFlowParams) { console.info('set load flow parameters'); const setLoadFlowParametersUrl = getStudyUrl(studyUuid) + '/loadflow/parameters'; console.debug(setLoadFlowParametersUrl); diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index 5b9f22417d..f616e78155 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -65,7 +65,7 @@ export function changeNetworkModificationOrder( export function stashModifications(studyUuid: UUID | null, nodeUuid: UUID | undefined, modificationUuids: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('stashed', 'true'); + urlSearchParams.append('stashed', String(true)); urlSearchParams.append('uuids', String(modificationUuids)); const modificationDeleteUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(modificationDeleteUrl); @@ -93,7 +93,7 @@ export function setModificationActivated( export function restoreModifications(studyUuid: UUID | null, nodeUuid: UUID | undefined, modificationUuids: UUID[]) { const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('stashed', 'false'); + urlSearchParams.append('stashed', String(false)); urlSearchParams.append('uuids', String(modificationUuids)); const RestoreModificationsUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); From e0d76e218eef9bef49480dc3e68f2ecc202e8989 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 17 Dec 2024 15:22:38 +0100 Subject: [PATCH 21/24] Resolve conflict. Signed-off-by: AAJELLAL --- src/components/app-top-bar.jsx | 2 +- .../single-line-diagram-parameters.tsx | 2 +- .../parameters/short-circuit-parameters.tsx | 10 +-- src/services/network-modification-types.ts | 50 +++++++++++--- src/services/study/loadflow.ts | 1 + src/services/study/network-modifications.ts | 48 +++++++++++++- src/services/study/network.ts | 66 ++++++------------- src/services/study/non-evacuated-energy.ts | 2 +- src/services/study/security-analysis.ts | 4 +- src/services/study/sensitivity-analysis.ts | 35 ++-------- src/services/study/short-circuit-analysis.ts | 12 ++-- 11 files changed, 131 insertions(+), 101 deletions(-) diff --git a/src/components/app-top-bar.jsx b/src/components/app-top-bar.jsx index 7d6e353c7c..245a024b3f 100644 --- a/src/components/app-top-bar.jsx +++ b/src/components/app-top-bar.jsx @@ -20,7 +20,7 @@ import AppPackage from '../../package.json'; import { DiagramType, useDiagram } from './diagrams/diagram-common'; import { isNodeBuilt, isNodeReadOnly } from './graph/util/model-functions'; import { useParameterState } from './dialogs/parameters/parameters'; -import { getServersInfos } from '../services/study/index'; +import { getServersInfos } from '../services/study'; import { EQUIPMENT_TYPES } from './utils/equipment-types'; import { fetchVersion } from '../services/utils'; import { RunButtonContainer } from './run-button-container'; diff --git a/src/components/dialogs/parameters/network-visualizations/single-line-diagram-parameters.tsx b/src/components/dialogs/parameters/network-visualizations/single-line-diagram-parameters.tsx index cb9aa746ce..a2b7ebfce0 100644 --- a/src/components/dialogs/parameters/network-visualizations/single-line-diagram-parameters.tsx +++ b/src/components/dialogs/parameters/network-visualizations/single-line-diagram-parameters.tsx @@ -8,7 +8,7 @@ import { Grid } from '@mui/material'; import PropTypes from 'prop-types'; import { useEffect, useMemo, useState } from 'react'; -import { getAvailableComponentLibraries } from '../../../../services/study/index'; +import { getAvailableComponentLibraries } from '../../../../services/study'; import { PARAM_CENTER_LABEL, PARAM_COMPONENT_LIBRARY, diff --git a/src/components/dialogs/parameters/short-circuit-parameters.tsx b/src/components/dialogs/parameters/short-circuit-parameters.tsx index f2f7a9d2ef..f4db248b95 100644 --- a/src/components/dialogs/parameters/short-circuit-parameters.tsx +++ b/src/components/dialogs/parameters/short-circuit-parameters.tsx @@ -104,15 +104,15 @@ export const useGetShortCircuitParameters = (): UseGetShortCircuitParametersProp const formSchema = yup .object() .shape({ - [SHORT_CIRCUIT_WITH_FEEDER_RESULT]: yup.boolean(), + [SHORT_CIRCUIT_WITH_FEEDER_RESULT]: yup.boolean().required(), [SHORT_CIRCUIT_PREDEFINED_PARAMS]: yup .mixed() .oneOf(Object.values(PREDEFINED_PARAMETERS)) .required(), - [SHORT_CIRCUIT_WITH_LOADS]: yup.boolean(), - [SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS]: yup.boolean(), - [SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS]: yup.boolean(), - [SHORT_CIRCUIT_WITH_NEUTRAL_POSITION]: yup.boolean(), + [SHORT_CIRCUIT_WITH_LOADS]: yup.boolean().required(), + [SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS]: yup.boolean().required(), + [SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS]: yup.boolean().required(), + [SHORT_CIRCUIT_WITH_NEUTRAL_POSITION]: yup.boolean().required(), [SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE]: yup .mixed() .oneOf(Object.values(INITIAL_VOLTAGE)) diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index fd73fb0de9..e44d2113c1 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -5,20 +5,20 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - AttributeModification, - ConverterStationElementModificationInfos, - ReactiveCapabilityCurvePoint, - ReactiveCapabilityCurvePointsData, -} from '../components/dialogs/network-modifications/vsc/converter-station/converter-station-utils'; import { UUID } from 'crypto'; import { Property } from '../components/dialogs/network-modifications/common/properties/property-utils'; - import { DataType, FieldValue, } from '../components/dialogs/network-modifications/by-filter/by-assignment/assignment/assignment.type'; import { Filter } from '../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; +import { + AttributeModification, + ConverterStationElementModificationInfos, + ReactiveCapabilityCurvePoint, + ReactiveCapabilityCurvePointsData, +} from '../components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-utils'; +import { ShuntCompensatorInfos } from '../components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation.type'; export interface HvdcAngleDroopActivePowerControlInfo { isEnabled: boolean; @@ -230,8 +230,8 @@ export interface TwoWindingsTransformerModificationInfo { busOrBusbarSectionId1?: string; voltageLevelId2?: string; busOrBusbarSectionId2?: string; - ratioTapChanger: any; - phaseTapChanger: any; + ratioTapChanger: Record | null; + phaseTapChanger: Record | null; isUpdate?: boolean; modificationUuid?: string; connectionName1?: string | null; @@ -338,6 +338,21 @@ export interface VSCCreationConverterStation { reactiveCapabilityCurvePoints: ReactiveCapabilityCurvePointsData[]; } +export interface LCCCreationConverterStation { + type: string; + equipmentId: string; + equipmentName?: string; + lossFactor: number; + powerFactor: number; + voltageLevelId?: string; + busOrBusbarSectionId?: string; + connectionName?: string | null; + connectionDirection: string; + connectionPosition?: number; + terminalConnected?: boolean; + shuntCompensatorsOnSide: ShuntCompensatorInfos[]; +} + export interface VSCModificationConverterStation { voltageSetpoint: AttributeModification | null; lossFactor: AttributeModification | null; @@ -633,6 +648,23 @@ export interface VSCCreationInfo { modificationUuid: UUID; } +export interface LCCCreationInfo { + studyUuid: string; + nodeUuid: UUID; + id: string; + name?: string | null; + nominalV: number; + r: number; + maxP: number; + convertersMode: string; + activePowerSetpoint: number; + converterStation1: LCCCreationConverterStation; + converterStation2: LCCCreationConverterStation; + properties?: Property[]; + isUpdate: boolean; + modificationUuid?: string; +} + export interface VSCModificationInfo { studyUuid: string; nodeUuid: UUID; diff --git a/src/services/study/loadflow.ts b/src/services/study/loadflow.ts index 2dd3a515d4..8f0df5444e 100644 --- a/src/services/study/loadflow.ts +++ b/src/services/study/loadflow.ts @@ -13,6 +13,7 @@ import { SortConfigType } from 'hooks/use-aggrid-sort'; import { GlobalFilter } from '../../components/results/loadflow/load-flow-result-tab'; import type { UnknownArray } from 'type-fest'; import { ILimitReductionsByVoltageLevel } from '../../components/dialogs/parameters/common/limitreductions/columns-definitions'; +import { ParametersInfos } from '../../components/dialogs/parameters/parameters.type'; interface LoadFlowParams { provider: string; diff --git a/src/services/study/network-modifications.ts b/src/services/study/network-modifications.ts index f616e78155..1ca88c4af2 100644 --- a/src/services/study/network-modifications.ts +++ b/src/services/study/network-modifications.ts @@ -22,6 +22,7 @@ import { GenerationDispatchInfo, GeneratorCreationInfo, GeneratorModificationInfo, + LCCCreationInfo, LineCreationInfo, LineModificationInfo, LinesAttachToSplitLinesInfo, @@ -1778,7 +1779,7 @@ export function deleteEquipmentByFilter( export function fetchNetworkModifications(studyUuid: UUID | null, nodeUuid: string, onlyStashed: boolean) { console.info('Fetching network modifications (metadata) for nodeUuid : ', nodeUuid); const urlSearchParams = new URLSearchParams(); - urlSearchParams.append('onlyStashed', String(onlyStashed)); + urlSearchParams.append('onlyStashed', onlyStashed.toString()); urlSearchParams.append('onlyMetadata', 'true'); const modificationsGetUrl = getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString(); console.debug(modificationsGetUrl); @@ -1804,7 +1805,52 @@ export function updateSwitchState(studyUuid: string, nodeUuid: UUID | undefined, }), }); } +export function createLcc({ + studyUuid, + nodeUuid, + id, + name, + nominalV, + r, + maxP, + convertersMode, + activePowerSetpoint, + converterStation1, + converterStation2, + properties, + isUpdate = false, + modificationUuid, +}: LCCCreationInfo) { + let createLccUrl = getNetworkModificationUrl(studyUuid, nodeUuid); + + if (isUpdate) { + createLccUrl += '/' + safeEncodeURIComponent(modificationUuid); + console.info('Updating lcc hvdc line creation'); + } else { + console.info('Creating lcc hvdc line creation'); + } + return backendFetchText(createLccUrl, { + method: isUpdate ? 'PUT' : 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + type: MODIFICATION_TYPES.LCC_CREATION.type, + equipmentId: id, + equipmentName: name, + nominalV: nominalV, + r: r, + maxP: maxP, + convertersMode: convertersMode, + activePowerSetpoint: activePowerSetpoint, + converterStation1: converterStation1, + converterStation2: converterStation2, + properties: properties, + }), + }); +} export function createVsc({ studyUuid, nodeUuid, diff --git a/src/services/study/network.ts b/src/services/study/network.ts index c2e15a2e6a..9ea1477518 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -286,7 +286,7 @@ export function fetchHvdcLinesMapInfos( ); } -export function fetchSubstations(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchSubstations(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -297,7 +297,7 @@ export function fetchSubstations(studyUuid: UUID, currentNodeUuid: UUID, substat ); } -export function fetchLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -308,7 +308,7 @@ export function fetchLines(studyUuid: UUID, currentNodeUuid: UUID, substationsId ); } -export function fetchVoltageLevels(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchVoltageLevels(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -319,11 +319,7 @@ export function fetchVoltageLevels(studyUuid: UUID, currentNodeUuid: UUID, subst ); } -export function fetchVoltageLevelsListInfos( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds?: string[] | undefined -) { +export function fetchVoltageLevelsListInfos(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -334,11 +330,7 @@ export function fetchVoltageLevelsListInfos( ); } -export function fetchVoltageLevelsMapInfos( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchVoltageLevelsMapInfos(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -349,11 +341,7 @@ export function fetchVoltageLevelsMapInfos( ); } -export function fetchTwoWindingsTransformers( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchTwoWindingsTransformers(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -364,11 +352,7 @@ export function fetchTwoWindingsTransformers( ); } -export function fetchThreeWindingsTransformers( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchThreeWindingsTransformers(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -379,7 +363,7 @@ export function fetchThreeWindingsTransformers( ); } -export function fetchGenerators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchGenerators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -389,7 +373,7 @@ export function fetchGenerators(studyUuid: UUID, currentNodeUuid: UUID, substati ); } -export function fetchLoads(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchLoads(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -400,7 +384,7 @@ export function fetchLoads(studyUuid: UUID, currentNodeUuid: UUID, substationsId ); } -export function fetchDanglingLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchDanglingLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -410,7 +394,7 @@ export function fetchDanglingLines(studyUuid: UUID, currentNodeUuid: UUID, subst ); } -export function fetchBatteries(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchBatteries(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -420,7 +404,7 @@ export function fetchBatteries(studyUuid: UUID, currentNodeUuid: UUID, substatio ); } -export function fetchHvdcLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchHvdcLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -431,11 +415,7 @@ export function fetchHvdcLines(studyUuid: UUID, currentNodeUuid: UUID, substatio ); } -export function fetchLccConverterStations( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchLccConverterStations(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -445,11 +425,7 @@ export function fetchLccConverterStations( ); } -export function fetchVscConverterStations( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchVscConverterStations(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -459,7 +435,7 @@ export function fetchVscConverterStations( ); } -export function fetchShuntCompensators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchShuntCompensators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -469,11 +445,7 @@ export function fetchShuntCompensators(studyUuid: UUID, currentNodeUuid: UUID, s ); } -export function fetchStaticVarCompensators( - studyUuid: UUID, - currentNodeUuid: UUID, - substationsIds: string[] | undefined -) { +export function fetchStaticVarCompensators(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -483,7 +455,7 @@ export function fetchStaticVarCompensators( ); } -export function fetchBuses(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchBuses(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -493,7 +465,7 @@ export function fetchBuses(studyUuid: UUID, currentNodeUuid: UUID, substationsId ); } -export function fetchBusbarSections(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchBusbarSections(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, @@ -524,7 +496,7 @@ export function getExportUrl(studyUuid: UUID, nodeUuid: UUID, exportFormat: stri return getUrlWithToken(url); } -export function fetchTieLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds: string[] | undefined) { +export function fetchTieLines(studyUuid: UUID, currentNodeUuid: UUID, substationsIds?: string[]) { return fetchNetworkElementsInfos( studyUuid, currentNodeUuid, diff --git a/src/services/study/non-evacuated-energy.ts b/src/services/study/non-evacuated-energy.ts index 3fe95773d1..71e84a8d90 100644 --- a/src/services/study/non-evacuated-energy.ts +++ b/src/services/study/non-evacuated-energy.ts @@ -46,7 +46,7 @@ export function getNonEvacuatedEnergyParameters(studyUuid: UUID) { return backendFetchJson(url); } -export function setNonEvacuatedEnergyParameters(studyUuid: UUID, newParams: any) { +export function setNonEvacuatedEnergyParameters(studyUuid: UUID | null, newParams: any) { console.info('set non evacuated energy analysis parameters'); const url = getStudyUrl(studyUuid) + '/non-evacuated-energy/parameters'; console.debug(url); diff --git a/src/services/study/security-analysis.ts b/src/services/study/security-analysis.ts index 6db62256d1..c73e6c8b72 100644 --- a/src/services/study/security-analysis.ts +++ b/src/services/study/security-analysis.ts @@ -46,8 +46,8 @@ export function fetchSecurityAnalysisResult(studyUuid: string, currentNodeUuid: } if (typeof page === 'number') { - params.append('page', String(page)); - params.append('size', size); + params.append('page', page.toString()); + params.append('size', size.toString()); } const urlWithParams = `${url}?${params.toString()}`; diff --git a/src/services/study/sensitivity-analysis.ts b/src/services/study/sensitivity-analysis.ts index c19f45c34f..9ba9adb9b6 100644 --- a/src/services/study/sensitivity-analysis.ts +++ b/src/services/study/sensitivity-analysis.ts @@ -8,19 +8,7 @@ import { PREFIX_STUDY_QUERIES, getStudyUrl, getStudyUrlWithNodeUuid } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; import { UUID } from 'crypto'; -import { - INewParamsHvdc, - INewParamsInjections, - INewParamsInjectionsSet, - INewParamsNodes, - INewParamsPst, -} from '../../components/dialogs/parameters/sensi/utils'; -import { - ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, - FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, - FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, - PROVIDER, -} from '../../components/utils/field-constants'; +import { SensitivityAnalysisParametersFormSchema } from '../../components/dialogs/parameters/sensi/sensitivity-analysis-parameters'; const GET_PARAMETERS_PREFIX = import.meta.env.VITE_API_GATEWAY + '/sensitivity-analysis/v1/parameters'; @@ -29,18 +17,6 @@ interface SelectorFilterOptions { functionType: string; } -interface SensitivityAnalysisParameters - extends INewParamsInjectionsSet, - INewParamsInjections, - INewParamsHvdc, - INewParamsPst, - INewParamsNodes { - [PROVIDER]: string; - [FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: number; - [ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: number; - [FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD]: number; -} - interface SensitivityAnalysisFactorsCountParameters { injections?: string[]; monitoredBranches?: string[]; @@ -127,14 +103,17 @@ export function getSensitivityAnalysisParameters(studyUuid: UUID) { return backendFetchJson(url); } -export function fetchSensitivityAnalysisParameters(parameterUuid: UUID) { +export function fetchSensitivityAnalysisParameters(parameterUuid: string) { console.info('get sensitivity analysis parameters'); const url = `${GET_PARAMETERS_PREFIX}/${parameterUuid}`; console.debug(url); return backendFetchJson(url); } -export function setSensitivityAnalysisParameters(studyUuid: UUID, newParams: SensitivityAnalysisParameters | null) { +export function setSensitivityAnalysisParameters( + studyUuid: UUID | null, + newParams: SensitivityAnalysisParametersFormSchema | null +) { console.info('set sensitivity analysis parameters'); const url = getStudyUrl(studyUuid) + '/sensitivity-analysis/parameters'; console.debug(url); @@ -149,7 +128,7 @@ export function setSensitivityAnalysisParameters(studyUuid: UUID, newParams: Sen } export function getSensitivityAnalysisFactorsCount( - studyUuid: UUID, + studyUuid: UUID | null, currentNodeUuid: UUID, isInjectionsSet: boolean, newParams: SensitivityAnalysisFactorsCountParameters diff --git a/src/services/study/short-circuit-analysis.ts b/src/services/study/short-circuit-analysis.ts index dced5f2a69..c6976fdde1 100644 --- a/src/services/study/short-circuit-analysis.ts +++ b/src/services/study/short-circuit-analysis.ts @@ -14,7 +14,7 @@ import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; import { UUID } from 'crypto'; import { FilterSelectorType } from '../../components/custom-aggrid/custom-aggrid-header.type'; import { SortConfigType } from '../../hooks/use-aggrid-sort'; -import { INITIAL_VOLTAGE } from '../../components/utils/constants'; +import { INITIAL_VOLTAGE, PREDEFINED_PARAMETERS } from '../../components/utils/constants'; const PREFIX_SHORT_CIRCUIT_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/shortcircuit'; @@ -39,14 +39,14 @@ interface VoltageRanges { voltageRangeCoefficient: number; } interface ShortCircuitParameters { - predefinedParameters: string; + predefinedParameters: NonNullable; parameters: { withFeederResult: boolean; withLoads: boolean; withVSCConverterStations: boolean; withShuntCompensators: boolean; withNeutralPosition: boolean; - initialVoltageProfileMode: INITIAL_VOLTAGE; + initialVoltageProfileMode: NonNullable; voltageRanges?: VoltageRanges; }; } @@ -161,7 +161,7 @@ export function getShortCircuitParameters(studyUuid: UUID) { return backendFetchJson(getShortCircuitParams); } -export function setShortCircuitParameters(studyUuid: UUID, newParams: ShortCircuitParameters) { +export function setShortCircuitParameters(studyUuid: UUID | null, newParams: ShortCircuitParameters) { console.info('set short-circuit parameters'); const url = getStudyUrl(studyUuid) + '/short-circuit-analysis/parameters'; console.debug(url); @@ -176,13 +176,13 @@ export function setShortCircuitParameters(studyUuid: UUID, newParams: ShortCircu }); } -export function fetchShortCircuitParameters(parameterUuid: UUID) { +export function fetchShortCircuitParameters(parameterUuid: string) { console.info('get short circuit analysis parameters'); const url = getShortCircuitUrl() + 'parameters/' + encodeURIComponent(parameterUuid); return backendFetchJson(url); } -export function invalidateShortCircuitStatus(studyUuid: UUID) { +export function invalidateShortCircuitStatus(studyUuid: UUID | null) { console.info('invalidate short circuit status'); const invalidateShortCircuitStatusUrl = getStudyUrl(studyUuid) + '/short-circuit/invalidate-status'; console.debug(invalidateShortCircuitStatusUrl); From bf9a3c8d944d37098d315d5981d707be14ebfa72 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 17 Dec 2024 16:54:06 +0100 Subject: [PATCH 22/24] resolve conflict and fix some review remarks Signed-off-by: AAJELLAL --- src/services/config.ts | 5 ++-- ...ic-simulation.js => dynamic-simulation.ts} | 25 +++++++++++-------- src/services/study/loadflow.ts | 14 +---------- src/services/study/security-analysis.ts | 3 +-- src/services/study/sensitivity-analysis.ts | 4 +-- 5 files changed, 21 insertions(+), 30 deletions(-) rename src/services/study/{dynamic-simulation.js => dynamic-simulation.ts} (82%) diff --git a/src/services/config.ts b/src/services/config.ts index 9dbfd07f27..82b6280350 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -4,7 +4,7 @@ * 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 { getAppName } from '../utils/config-params'; +import { APP_NAME, getAppName } from '../utils/config-params'; import { backendFetch, backendFetchJson } from './utils'; const PREFIX_CONFIG_QUERIES = import.meta.env.VITE_API_GATEWAY + '/config'; @@ -31,8 +31,7 @@ export function updateConfigParameter(name: string, value: string) { } export function updateConfigParameters(parameters: Record) { - const appName = getAppName(parameters); - const updateParams = PREFIX_CONFIG_QUERIES + `/v1/applications/${appName}/parameters`; + const updateParams = PREFIX_CONFIG_QUERIES + `/v1/applications/${APP_NAME}/parameters`; return backendFetch(updateParams, { method: 'put', headers: { diff --git a/src/services/study/dynamic-simulation.js b/src/services/study/dynamic-simulation.ts similarity index 82% rename from src/services/study/dynamic-simulation.js rename to src/services/study/dynamic-simulation.ts index 80bb7e7b21..7ec438166d 100644 --- a/src/services/study/dynamic-simulation.js +++ b/src/services/study/dynamic-simulation.ts @@ -8,15 +8,16 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { backendFetch, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils'; +import { UUID } from 'crypto'; -export function getDynamicMappings(studyUuid) { +export function getDynamicMappings(studyUuid: UUID) { console.info(`Fetching dynamic mappings on '${studyUuid}' ...`); const url = getStudyUrl(studyUuid) + '/dynamic-simulation/mappings'; console.debug(url); return backendFetchJson(url); } -export function startDynamicSimulation(studyUuid, currentNodeUuid, dynamicSimulationConfiguration) { +export function startDynamicSimulation(studyUuid: UUID, currentNodeUuid: UUID, dynamicSimulationConfiguration?: any) { console.info(`Running dynamic simulation on '${studyUuid}' and node '${currentNodeUuid}' ...`); const startDynamicSimulationUrl = `${getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid)}/dynamic-simulation/run`; @@ -36,21 +37,25 @@ export function startDynamicSimulation(studyUuid, currentNodeUuid, dynamicSimula }); } -export function stopDynamicSimulation(studyUuid, currentNodeUuid) { +export function stopDynamicSimulation(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Stopping dynamic simulation on '${studyUuid}' and node '${currentNodeUuid}' ...`); const stopDynamicSimulationUrl = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/dynamic-simulation/stop'; console.debug(stopDynamicSimulationUrl); return backendFetch(stopDynamicSimulationUrl, { method: 'put' }); } -export function fetchDynamicSimulationStatus(studyUuid, currentNodeUuid) { +export function fetchDynamicSimulationStatus(studyUuid: UUID, currentNodeUuid: UUID) { console.info(`Fetching dynamic simulation status on '${studyUuid}' and node '${currentNodeUuid}' ...`); const url = getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/dynamic-simulation/status'; console.debug(url); return backendFetchJson(url); } -export function fetchDynamicSimulationResultTimeSeries(studyUuid, currentNodeUuid, timeSeriesNames) { +export function fetchDynamicSimulationResultTimeSeries( + studyUuid: UUID, + currentNodeUuid: UUID, + timeSeriesNames: string[] +) { console.info(`Fetching dynamic simulation time series result on '${studyUuid}' and node '${currentNodeUuid}' ...`); // Add params to Url @@ -66,7 +71,7 @@ export function fetchDynamicSimulationResultTimeSeries(studyUuid, currentNodeUui return backendFetchJson(url); } -export function fetchDynamicSimulationModels(studyUuid, nodeUuid) { +export function fetchDynamicSimulationModels(studyUuid: UUID | null, nodeUuid: UUID) { console.info(`Fetching dynamic simulation models on '${studyUuid}' and node '${nodeUuid}' ...`); const url = getStudyUrlWithNodeUuid(studyUuid, nodeUuid) + '/dynamic-simulation/models'; @@ -74,7 +79,7 @@ export function fetchDynamicSimulationModels(studyUuid, nodeUuid) { return backendFetchJson(url); } -export function fetchDynamicSimulationProvider(studyUuid) { +export function fetchDynamicSimulationProvider(studyUuid: UUID) { console.info('fetch dynamic simulation provider'); const url = getStudyUrl(studyUuid) + '/dynamic-simulation/provider'; console.debug(url); @@ -88,7 +93,7 @@ export function fetchDefaultDynamicSimulationProvider() { return backendFetchText(url); } -export function updateDynamicSimulationProvider(studyUuid, newProvider) { +export function updateDynamicSimulationProvider(studyUuid: UUID, newProvider: string) { console.info('update dynamic simulation provider'); const url = getStudyUrl(studyUuid) + '/dynamic-simulation/provider'; console.debug(url); @@ -102,7 +107,7 @@ export function updateDynamicSimulationProvider(studyUuid, newProvider) { }); } -export function fetchDynamicSimulationParameters(studyUuid) { +export function fetchDynamicSimulationParameters(studyUuid: UUID) { console.info(`Fetching dynamic simulation parameters on '${studyUuid}' ...`); const url = getStudyUrl(studyUuid) + '/dynamic-simulation/parameters'; console.debug(url); @@ -116,7 +121,7 @@ export function fetchDynamicSimulationParameters(studyUuid) { })); } -export function updateDynamicSimulationParameters(studyUuid, newParams) { +export function updateDynamicSimulationParameters(studyUuid: UUID, newParams: any) { console.info('set dynamic simulation parameters'); const url = getStudyUrl(studyUuid) + '/dynamic-simulation/parameters'; console.debug(url); diff --git a/src/services/study/loadflow.ts b/src/services/study/loadflow.ts index 8f0df5444e..08f6572a4e 100644 --- a/src/services/study/loadflow.ts +++ b/src/services/study/loadflow.ts @@ -11,18 +11,6 @@ import { UUID } from 'crypto'; import { FilterSelectorType } from 'components/custom-aggrid/custom-aggrid-header.type'; import { SortConfigType } from 'hooks/use-aggrid-sort'; import { GlobalFilter } from '../../components/results/loadflow/load-flow-result-tab'; -import type { UnknownArray } from 'type-fest'; -import { ILimitReductionsByVoltageLevel } from '../../components/dialogs/parameters/common/limitreductions/columns-definitions'; -import { ParametersInfos } from '../../components/dialogs/parameters/parameters.type'; - -interface LoadFlowParams { - provider: string; - commonParameters: Record; - specificParametersPerProvider: { - [providerName: string]: Record; - }; - limitReductions: ILimitReductionsByVoltageLevel[]; -} interface QueryParams { sort?: SortConfigType[]; @@ -37,7 +25,7 @@ export function getDefaultLoadFlowProvider() { return backendFetchText(getDefaultLoadFlowProviderUrl); } -export function setLoadFlowParameters(studyUuid: UUID, newParams: LoadFlowParams) { +export function setLoadFlowParameters(studyUuid: UUID, newParams: any) { console.info('set load flow parameters'); const setLoadFlowParametersUrl = getStudyUrl(studyUuid) + '/loadflow/parameters'; console.debug(setLoadFlowParametersUrl); diff --git a/src/services/study/security-analysis.ts b/src/services/study/security-analysis.ts index c73e6c8b72..a75e415da2 100644 --- a/src/services/study/security-analysis.ts +++ b/src/services/study/security-analysis.ts @@ -8,7 +8,6 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList } from '../utils'; import { UUID } from 'crypto'; -import { ISAParameters } from '../../components/dialogs/parameters/common/limitreductions/columns-definitions'; import { RESULT_TYPE } from '../../components/results/securityanalysis/security-analysis-result-utils'; export function startSecurityAnalysis(studyUuid: UUID, currentNodeUuid: UUID, contingencyListNames: string[]) { @@ -120,7 +119,7 @@ export function getSecurityAnalysisParameters(studyUuid: UUID) { return backendFetchJson(url); } -export function setSecurityAnalysisParameters(studyUuid: UUID, newParams: ISAParameters) { +export function setSecurityAnalysisParameters(studyUuid: UUID, newParams: any) { console.info('set security analysis parameters'); const url = getStudyUrl(studyUuid) + '/security-analysis/parameters'; console.debug(url); diff --git a/src/services/study/sensitivity-analysis.ts b/src/services/study/sensitivity-analysis.ts index 9ba9adb9b6..b186f63369 100644 --- a/src/services/study/sensitivity-analysis.ts +++ b/src/services/study/sensitivity-analysis.ts @@ -8,7 +8,7 @@ import { PREFIX_STUDY_QUERIES, getStudyUrl, getStudyUrlWithNodeUuid } from './index'; import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; import { UUID } from 'crypto'; -import { SensitivityAnalysisParametersFormSchema } from '../../components/dialogs/parameters/sensi/sensitivity-analysis-parameters'; +import { SensitivityAnalysisParametersInfos } from './sensitivity-analysis.type'; const GET_PARAMETERS_PREFIX = import.meta.env.VITE_API_GATEWAY + '/sensitivity-analysis/v1/parameters'; @@ -112,7 +112,7 @@ export function fetchSensitivityAnalysisParameters(parameterUuid: string) { export function setSensitivityAnalysisParameters( studyUuid: UUID | null, - newParams: SensitivityAnalysisParametersFormSchema | null + newParams: SensitivityAnalysisParametersInfos | null ) { console.info('set sensitivity analysis parameters'); const url = getStudyUrl(studyUuid) + '/sensitivity-analysis/parameters'; From 64699f8c4fd9062fd672bb2b029ed522eb2b2e7b Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Wed, 18 Dec 2024 15:04:32 +0100 Subject: [PATCH 23/24] resolve conflict Signed-off-by: AAJELLAL --- src/services/study/voltage-init.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/study/voltage-init.ts b/src/services/study/voltage-init.ts index 0c943a96b1..24ba1afc27 100644 --- a/src/services/study/voltage-init.ts +++ b/src/services/study/voltage-init.ts @@ -39,7 +39,10 @@ export function fetchVoltageInitResult(studyUuid: UUID, currentNodeUuid: UUID) { return backendFetchJson(url); } -export function updateVoltageInitParameters(studyUuid: UUID | null, newParams: VoltageInitParam) { +export function updateVoltageInitParameters( + studyUuid: UUID | null, + newParams: VoltageInitParam | Record +) { console.info('set voltage init parameters'); const url = getStudyUrl(studyUuid) + '/voltage-init/parameters'; console.debug(url); From 31e5ba5a1bd3db1284e4cb555025d87f45b42a46 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 26 Dec 2024 12:05:50 +0100 Subject: [PATCH 24/24] resolve conflict Signed-off-by: AAJELLAL --- src/components/diagrams/diagram-pane.tsx | 44 +++++++++---------- .../position-diagram-pane.tsx | 22 +++++----- src/services/study/network.ts | 7 ++- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/components/diagrams/diagram-pane.tsx b/src/components/diagrams/diagram-pane.tsx index 35de26337a..46a4a58abd 100644 --- a/src/components/diagrams/diagram-pane.tsx +++ b/src/components/diagrams/diagram-pane.tsx @@ -58,17 +58,17 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => { const checkAndGetVoltageLevelSingleLineDiagramUrl = useCallback( (voltageLevelId: UUID) => isNodeBuilt(currentNode) - ? getVoltageLevelSingleLineDiagram( - studyUuid, - currentNode?.id, - voltageLevelId, - paramUseName, - networkVisuParams.singleLineDiagramParameters.centerLabel, - networkVisuParams.singleLineDiagramParameters.diagonalLabel, - networkVisuParams.singleLineDiagramParameters.componentLibrary, - SLD_DISPLAY_MODE.STATE_VARIABLE, - language - ) + ? getVoltageLevelSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNode?.id, + voltageLevelId: voltageLevelId, + useName: paramUseName, + centerLabel: networkVisuParams.singleLineDiagramParameters.centerLabel, + diagonalLabel: networkVisuParams.singleLineDiagramParameters.diagonalLabel, + componentLibrary: networkVisuParams.singleLineDiagramParameters.componentLibrary, + sldDisplayMode: SLD_DISPLAY_MODE.STATE_VARIABLE, + language: language, + }) : null, [ currentNode, @@ -84,17 +84,17 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => { const checkAndGetSubstationSingleLineDiagramUrl = useCallback( (voltageLevelId: UUID) => isNodeBuilt(currentNode) - ? getSubstationSingleLineDiagram( - studyUuid, - currentNode?.id, - voltageLevelId, - paramUseName, - networkVisuParams.singleLineDiagramParameters.centerLabel, - networkVisuParams.singleLineDiagramParameters.diagonalLabel, - networkVisuParams.singleLineDiagramParameters.substationLayout, - networkVisuParams.singleLineDiagramParameters.componentLibrary, - language - ) + ? getSubstationSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNode?.id, + substationId: voltageLevelId, + useName: paramUseName, + centerLabel: networkVisuParams.singleLineDiagramParameters.centerLabel, + diagonalLabel: networkVisuParams.singleLineDiagramParameters.diagonalLabel, + substationLayout: networkVisuParams.singleLineDiagramParameters.substationLayout, + componentLibrary: networkVisuParams.singleLineDiagramParameters.componentLibrary, + language: language, + }) : null, [ networkVisuParams.singleLineDiagramParameters.centerLabel, diff --git a/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx b/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx index b6158c245a..3adfbfaa29 100644 --- a/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx +++ b/src/components/diagrams/singleLineDiagram/position-diagram-pane.tsx @@ -44,17 +44,17 @@ const PositionDiagramPane: FC = ({ const getVoltageLevelSingleLineDiagramUrl = useCallback( () => - getVoltageLevelSingleLineDiagram( - studyUuid, - currentNodeUuid, - voltageLevelId?.id, - useName, - networkVisuParams.singleLineDiagramParameters.centerLabel, - networkVisuParams.singleLineDiagramParameters.diagonalLabel, - networkVisuParams.singleLineDiagramParameters.componentLibrary, - SLD_DISPLAY_MODE.FEEDER_POSITION, - language - ), + getVoltageLevelSingleLineDiagram({ + studyUuid: studyUuid, + currentNodeUuid: currentNodeUuid, + voltageLevelId: voltageLevelId?.id, + useName: useName, + centerLabel: networkVisuParams.singleLineDiagramParameters.centerLabel, + diagonalLabel: networkVisuParams.singleLineDiagramParameters.diagonalLabel, + componentLibrary: networkVisuParams.singleLineDiagramParameters.componentLibrary, + sldDisplayMode: SLD_DISPLAY_MODE.FEEDER_POSITION, + language: language, + }), [ studyUuid, currentNodeUuid, diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 9ea1477518..951bcf737d 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -10,7 +10,6 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../components/utils/e import { backendFetch, backendFetchJson, backendFetchText, getQueryParamsList, getUrlWithToken } from '../utils'; import { UUID } from 'crypto'; import { EquipmentType, GsLang } from '@gridsuite/commons-ui'; -import { SubstationLayout } from '../../components/diagrams/diagram-common'; interface VoltageLevelSingleLineDiagram { studyUuid: UUID; @@ -19,7 +18,7 @@ interface VoltageLevelSingleLineDiagram { useName: boolean; centerLabel: boolean; diagonalLabel: boolean; - componentLibrary: unknown; + componentLibrary: string; sldDisplayMode: string; language: GsLang; } @@ -31,8 +30,8 @@ interface SubstationSingleLineDiagram { useName: boolean; centerLabel: boolean; diagonalLabel: boolean; - substationLayout: SubstationLayout; - componentLibrary: unknown; + substationLayout: string; + componentLibrary: string; language: GsLang; }