diff --git a/src/components/parameters-tabs.tsx b/src/components/parameters-tabs.tsx index 10c400f305..9015758abb 100644 --- a/src/components/parameters-tabs.tsx +++ b/src/components/parameters-tabs.tsx @@ -69,6 +69,7 @@ import { } from 'services/study/short-circuit-analysis'; import { useGetPccMinParameters } from './dialogs/parameters/use-get-pcc-min-parameters'; import { useWorkspacePanelActions } from './workspace/hooks/use-workspace-panel-actions'; +import { fetchContingencyCount } from '../services/study'; enum TAB_VALUES { lfParamsTabValue = 'LOAD_FLOW', @@ -295,6 +296,9 @@ const ParametersTabs: FunctionComponent = () => { + fetchContingencyCount(studyUuid, currentNodeUuid, currentRootNetworkUuid, contingencyLists) + } setHaveDirtyFields={setDirtyFields} isDeveloperMode={isDeveloperMode} /> diff --git a/src/components/run-button-container.jsx b/src/components/run-button-container.jsx index eb23b761db..c03ee0ed32 100644 --- a/src/components/run-button-container.jsx +++ b/src/components/run-button-container.jsx @@ -219,16 +219,16 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU [currentNode, snackError] ); - const handleStartSecurityAnalysis = (contingencyListNames) => { + const handleStartSecurityAnalysis = useCallback(() => { startComputationAsync( ComputingType.SECURITY_ANALYSIS, null, - () => startSecurityAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid, contingencyListNames), + () => startSecurityAnalysis(studyUuid, currentNode?.id, currentRootNetworkUuid), () => {}, null, null ); - }; + }, [studyUuid, currentNode?.id, currentRootNetworkUuid, startComputationAsync]); const handleStartDynamicSimulation = (dynamicSimulationConfiguration, debug) => { startComputationAsync( @@ -310,7 +310,8 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU [ComputingType.SECURITY_ANALYSIS]: { messageId: 'SecurityAnalysis', startComputation() { - setShowContingencyListSelector(true); + //setShowContingencyListSelector(true); + handleStartSecurityAnalysis(); }, actionOnRunnable() { actionOnRunnables(ComputingType.SECURITY_ANALYSIS, () => @@ -508,6 +509,7 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU checkForbiddenProvider, studyUuid, handleStartLoadFlow, + handleStartSecurityAnalysis, currentNode?.id, currentRootNetworkUuid, startComputationAsync, diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 3c20ee0732..62d2edc122 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -31,7 +31,7 @@ export const getStudyUrl = (studyUuid: UUID | null) => export const getStudyUrlWithNodeUuidAndRootNetworkUuid = ( studyUuid: string | null | undefined, - nodeUuid: string | undefined, + nodeUuid: string | null | undefined, // ça peut pas être null ? rootNetworkUuid: string | undefined | null ) => `${PREFIX_STUDY_QUERIES}/v1/studies/${safeEncodeURIComponent(studyUuid)}/root-networks/${safeEncodeURIComponent( @@ -200,16 +200,16 @@ export function searchEquipmentsInfos( } export function fetchContingencyCount( - studyUuid: UUID, - currentNodeUuid: UUID, - currentRootNetworkUuid: UUID, - contingencyListNames: string[] + studyUuid: UUID | null, // ça peut pas être null ? + currentNodeUuid: UUID | null, + currentRootNetworkUuid: UUID | null, + contingencyListNames: string[] | null ): Promise { console.info( `Fetching contingency count for ${contingencyListNames} on '${studyUuid}' for root network '${currentRootNetworkUuid}' and node '${currentNodeUuid}'...` ); - const contingencyListNamesParams = getRequestParamFromList(contingencyListNames, 'contingencyListName'); + const contingencyListNamesParams = getRequestParamFromList(contingencyListNames ?? [], 'contingencyListName'); const urlSearchParams = new URLSearchParams(contingencyListNamesParams); const url = diff --git a/src/services/study/security-analysis.ts b/src/services/study/security-analysis.ts index 18b3f4e00f..0060cd7144 100644 --- a/src/services/study/security-analysis.ts +++ b/src/services/study/security-analysis.ts @@ -6,7 +6,6 @@ */ import { getStudyUrl, getStudyUrlWithNodeUuidAndRootNetworkUuid, PREFIX_STUDY_QUERIES } from './index'; -import { getRequestParamFromList } from '../utils'; import type { UUID } from 'node:crypto'; import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, GsLangUser } from '@gridsuite/commons-ui'; import { SecurityAnalysisQueryParams } from '../../components/results/securityanalysis/security-analysis.type'; @@ -14,21 +13,17 @@ import { SecurityAnalysisQueryParams } from '../../components/results/securityan export function startSecurityAnalysis( studyUuid: UUID, currentNodeUuid: UUID, - currentRootNetworkUuid: UUID, - contingencyListUuids: UUID[] + currentRootNetworkUuid: UUID ): Promise { console.info( `Running security analysis on ${studyUuid} on root network ${currentRootNetworkUuid} and node ${currentNodeUuid} ...` ); - // Add params to Url - const contingencyListsQueryParams = getRequestParamFromList(contingencyListUuids, 'contingencyListName'); - const urlSearchParams = new URLSearchParams(contingencyListsQueryParams); const url = `${getStudyUrlWithNodeUuidAndRootNetworkUuid( studyUuid, currentNodeUuid, currentRootNetworkUuid - )}/security-analysis/run?${urlSearchParams}`; + )}/security-analysis/run`; console.debug(url); return backendFetch(url, { method: 'post' });