Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/parameters-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
} 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',
Expand Down Expand Up @@ -295,6 +296,9 @@
<SecurityAnalysisParametersInline
studyUuid={studyUuid}
parametersBackend={securityAnalysisParametersBackend}
fetchContingencyCount={(contingencyLists: string[] | null) =>

Check failure on line 299 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Type '{ studyUuid: `${string}-${string}-${string}-${string}-${string}` | null; parametersBackend: UseParametersBackendReturnProps<ComputingType.SECURITY_ANALYSIS>; fetchContingencyCount: (contingencyLists: string[] | null) => Promise<...>; setHaveDirtyFields: (isDirty: boolean) => void; isDeveloperMode: boolean; }' is not assignable to type 'IntrinsicAttributes & Readonly<{ studyUuid: `${string}-${string}-${string}-${string}-${string}` | null; parametersBackend: UseParametersBackendReturnProps<ComputingType.SECURITY_ANALYSIS>; setHaveDirtyFields: (isDirty: boolean) => void; isDeveloperMode: boolean; }>'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fetchContingencyCount={(contingencyLists: string[] | null) =>
fetchContingencyCount={(contingencyListIds: UUID[] | null) =>

fetchContingencyCount(studyUuid, currentNodeUuid, currentRootNetworkUuid, contingencyLists)
}
setHaveDirtyFields={setDirtyFields}
isDeveloperMode={isDeveloperMode}
/>
Expand Down
10 changes: 6 additions & 4 deletions src/components/run-button-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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, () =>
Expand Down Expand Up @@ -508,6 +509,7 @@ export function RunButtonContainer({ studyUuid, currentNode, currentRootNetworkU
checkForbiddenProvider,
studyUuid,
handleStartLoadFlow,
handleStartSecurityAnalysis,
currentNode?.id,
currentRootNetworkUuid,
startComputationAsync,
Expand Down
12 changes: 6 additions & 6 deletions src/services/study/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Copy link
Contributor

@thangqp thangqp Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
contingencyListNames: string[] | null
contingencyListIds: UUID[] | null

clean notion contingencyListNames i think it is historically.. and change type to UUID

): Promise<number> {
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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const contingencyListNamesParams = getRequestParamFromList(contingencyListNames ?? [], 'contingencyListName');
const contingencyListIdsParams = getRequestParamFromList(contingencyListIds ?? [], 'contingencyListIds');

To rectify also in the backend of study-server

const urlSearchParams = new URLSearchParams(contingencyListNamesParams);

const url =
Expand Down
9 changes: 2 additions & 7 deletions src/services/study/security-analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@
*/

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';

export function startSecurityAnalysis(
studyUuid: UUID,
currentNodeUuid: UUID,
currentRootNetworkUuid: UUID,
contingencyListUuids: UUID[]
currentRootNetworkUuid: UUID
): Promise<Response> {
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' });
Expand Down
Loading