@gridsuite/commons-ui 0.187.0 → 0.189.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,7 @@ function VoltageLevelCreationForm({
98
98
  /* @__PURE__ */ jsx(
99
99
  Tab,
100
100
  {
101
- label: /* @__PURE__ */ jsx(FormattedMessage, { id: "ConnectivityTab" }),
101
+ label: /* @__PURE__ */ jsx(FormattedMessage, { id: "SubstationTab" }),
102
102
  sx: getTabStyle(tabIndexesWithError, VoltageLevelTab.SUBSTATION_TAB)
103
103
  }
104
104
  ),
@@ -2,6 +2,6 @@ import { UUID } from 'node:crypto';
2
2
  import { ContingencyCount } from './types';
3
3
  export declare function ContingencyTable({ showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, }: Readonly<{
4
4
  showContingencyCount: boolean;
5
- fetchContingencyCount?: (contingencyLists: UUID[] | null) => Promise<ContingencyCount>;
5
+ fetchContingencyCount?: (contingencyLists: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
6
6
  isBuiltCurrentNode?: boolean;
7
7
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,18 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Stack, Alert } from "@mui/material";
2
+ import { Stack, Alert, CircularProgress } from "@mui/material";
3
3
  import { useState, useCallback, useEffect } from "react";
4
4
  import { useIntl, FormattedMessage } from "react-intl";
5
5
  import { useWatch } from "react-hook-form";
6
6
  import "../../../../utils/conversionUtils.js";
7
+ import { snackWithFallback } from "../../../../utils/error.js";
7
8
  import "../../../../utils/types/equipmentType.js";
8
9
  import "@mui/icons-material";
9
10
  import "../../../../utils/yupConfig.js";
11
+ import { DEFAULT_TIMEOUT_MS, IGNORE_SIGNAL } from "../../../../services/utils.js";
10
12
  import "localized-countries";
11
13
  import "localized-countries/data/fr";
12
14
  import "localized-countries/data/en";
13
- import "notistack";
15
+ import { useSnackMessage } from "../../../../hooks/useSnackMessage.js";
14
16
  import { useCreateRowData } from "../../../../hooks/use-create-row-data.js";
15
17
  import { ACTIVATED, ID } from "../parameter-table/constants.js";
16
18
  import { ParameterTable } from "../parameter-table/parameter-table.js";
@@ -25,6 +27,8 @@ function ContingencyTable({
25
27
  const [simulatedContingencyCount, setSimulatedContingencyCount] = useState(null);
26
28
  const [rowData, useFieldArrayOutput] = useCreateRowData(ParamContingencyLists);
27
29
  const contingencyListsInfos = useWatch({ name: CONTINGENCY_LISTS_INFOS });
30
+ const [isLoading, setIsLoading] = useState(false);
31
+ const { snackError } = useSnackMessage();
28
32
  const getColumnsDefinition = useCallback(
29
33
  (columns) => {
30
34
  if (columns) {
@@ -38,27 +42,60 @@ function ContingencyTable({
38
42
  [intl]
39
43
  );
40
44
  useEffect(() => {
41
- if (showContingencyCount) {
42
- const hasNoContingencies = !contingencyListsInfos || (contingencyListsInfos.length ?? 0) === 0 || contingencyListsInfos.every(
43
- (contingencyList) => (contingencyList[CONTINGENCY_LISTS]?.length ?? 0) === 0
44
- );
45
- if (hasNoContingencies) {
46
- setSimulatedContingencyCount(null);
45
+ if (!showContingencyCount || !isBuiltCurrentNode) {
46
+ setIsLoading(false);
47
+ return () => {
48
+ };
49
+ }
50
+ const hasNoContingencies = !contingencyListsInfos || (contingencyListsInfos.length ?? 0) === 0 || contingencyListsInfos.every(
51
+ (contingencyList) => !contingencyList[ACTIVATED] || (contingencyList[CONTINGENCY_LISTS]?.length ?? 0) === 0
52
+ );
53
+ if (hasNoContingencies) {
54
+ setIsLoading(false);
55
+ setSimulatedContingencyCount(null);
56
+ return () => {
57
+ };
58
+ }
59
+ let loadingTimeoutId;
60
+ const controller = new AbortController();
61
+ const abortSignal = AbortSignal.any([controller.signal, AbortSignal.timeout(DEFAULT_TIMEOUT_MS)]);
62
+ setIsLoading(true);
63
+ fetchContingencyCount?.(
64
+ contingencyListsInfos.filter((lists) => lists[ACTIVATED]).flatMap((lists) => lists[CONTINGENCY_LISTS]?.map((contingencyList) => contingencyList[ID])),
65
+ abortSignal
66
+ ).then((contingencyCount) => {
67
+ setSimulatedContingencyCount(contingencyCount);
68
+ loadingTimeoutId = setTimeout(() => {
69
+ setIsLoading(false);
70
+ }, 500);
71
+ }).catch((error) => {
72
+ setSimulatedContingencyCount(null);
73
+ if (abortSignal.aborted && abortSignal.reason?.message === IGNORE_SIGNAL) {
47
74
  return;
48
75
  }
49
- fetchContingencyCount?.(
50
- contingencyListsInfos.filter((lists) => lists[ACTIVATED]).flatMap((lists) => lists[CONTINGENCY_LISTS]?.map((contingencyList) => contingencyList[ID]))
51
- ).then((contingencyCount) => {
52
- setSimulatedContingencyCount(contingencyCount);
53
- }).catch(() => {
54
- setSimulatedContingencyCount(null);
55
- });
56
- }
57
- }, [contingencyListsInfos, fetchContingencyCount, showContingencyCount]);
76
+ setIsLoading(false);
77
+ snackWithFallback(snackError, error, { headerId: "getSecurityAnalysisContingenciesCountError" });
78
+ });
79
+ return () => {
80
+ controller?.abort(new Error(IGNORE_SIGNAL));
81
+ clearTimeout(loadingTimeoutId);
82
+ };
83
+ }, [snackError, contingencyListsInfos, fetchContingencyCount, showContingencyCount, isBuiltCurrentNode]);
58
84
  const renderContingencyCount = () => {
59
85
  if (!isBuiltCurrentNode) {
60
86
  return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "warning", sx: { color: "text.primary" }, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "contingencyCountImpossibleOnUnbuiltNode" }) });
61
87
  }
88
+ if (isLoading) {
89
+ return /* @__PURE__ */ jsx(
90
+ Alert,
91
+ {
92
+ variant: "standard",
93
+ icon: /* @__PURE__ */ jsx(CircularProgress, { size: 22 }),
94
+ severity: "info",
95
+ sx: { color: "text.primary" }
96
+ }
97
+ );
98
+ }
62
99
  if (simulatedContingencyCount?.contingencies === 0 && simulatedContingencyCount.notFoundElements === 0) {
63
100
  return /* @__PURE__ */ jsx(Alert, { variant: "standard", severity: "error", sx: { color: "text.primary" }, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "noContingency" }) });
64
101
  }
@@ -5,7 +5,7 @@ import { ContingencyCount } from '../common/contingency-table/types';
5
5
  export declare function SecurityAnalysisParametersForm({ securityAnalysisMethods, showContingencyCount, fetchContingencyCount, isBuiltCurrentNode, renderTitleFields, renderActions, isDeveloperMode, }: Readonly<{
6
6
  securityAnalysisMethods: UseSecurityAnalysisParametersFormReturn;
7
7
  showContingencyCount: boolean;
8
- fetchContingencyCount?: (contingencyListIds: UUID[] | null) => Promise<ContingencyCount>;
8
+ fetchContingencyCount?: (contingencyListIds: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
9
9
  isBuiltCurrentNode?: boolean;
10
10
  renderTitleFields?: () => ReactNode;
11
11
  renderActions?: () => ReactNode;
@@ -5,7 +5,7 @@ import { ContingencyCount } from '../common/contingency-table/types';
5
5
  export declare function SecurityAnalysisParametersInline({ studyUuid, parametersBackend, fetchContingencyCount, isBuiltCurrentNode, setHaveDirtyFields, isDeveloperMode, }: Readonly<{
6
6
  studyUuid: UUID | null;
7
7
  parametersBackend: UseParametersBackendReturnProps<ComputingType.SECURITY_ANALYSIS>;
8
- fetchContingencyCount: (contingencyListIds: UUID[] | null) => Promise<ContingencyCount>;
8
+ fetchContingencyCount: (contingencyListIds: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
9
9
  isBuiltCurrentNode: boolean;
10
10
  setHaveDirtyFields: (isDirty: boolean) => void;
11
11
  isDeveloperMode: boolean;
package/dist/index.js CHANGED
@@ -245,7 +245,7 @@ import { AnnouncementSeverity, ArrayAction } from "./utils/types/types.js";
245
245
  import { MODIFICATION_TYPES, ModificationType } from "./utils/types/modificationType.js";
246
246
  import { FieldType } from "./utils/types/fieldType.js";
247
247
  import { ParameterType } from "./utils/types/parameters.type.js";
248
- import { SolverTypeInfos } from "./utils/types/dynamic-simulation.type.js";
248
+ import { SolverType } from "./utils/types/dynamic-simulation.type.js";
249
249
  import { DistributionType, SensitivityType } from "./utils/types/sensitivity-analysis.type.js";
250
250
  import { CalculationType, LoadModelsRule } from "./utils/types/dynamic-margin-calculation.type.js";
251
251
  import { OperationType } from "./utils/types/network-modification-types.js";
@@ -783,7 +783,7 @@ export {
783
783
  SilentRenewCallbackHandler,
784
784
  SliderInput,
785
785
  SnackbarProvider,
786
- SolverTypeInfos,
786
+ SolverType,
787
787
  SubmitButton,
788
788
  Substation,
789
789
  SubstationCreationForm,
@@ -143,6 +143,7 @@ export declare const networkModificationsEn: {
143
143
  Side1: string;
144
144
  Side2: string;
145
145
  Or: string;
146
+ SubstationTab: string;
146
147
  ConnectivityTab: string;
147
148
  CharacteristicsTab: string;
148
149
  StructureTab: string;
@@ -150,6 +150,7 @@ const networkModificationsEn = {
150
150
  Side2: "Side 2",
151
151
  Or: "or",
152
152
  // Tabs
153
+ SubstationTab: "Substation",
153
154
  ConnectivityTab: "Connectivity",
154
155
  CharacteristicsTab: "Characteristics",
155
156
  StructureTab: "Structure",
@@ -248,6 +248,7 @@ export declare const parametersEn: {
248
248
  fetchSecurityAnalysisParametersError: string;
249
249
  fetchSecurityAnalysisProvidersError: string;
250
250
  updateSecurityAnalysisParametersError: string;
251
+ getSecurityAnalysisContingenciesCountError: string;
251
252
  fetchSensitivityAnalysisParametersError: string;
252
253
  fetchSensitivityAnalysisProvidersError: string;
253
254
  updateSensitivityAnalysisParametersError: string;
@@ -245,6 +245,7 @@ const parametersEn = {
245
245
  fetchSecurityAnalysisParametersError: "An error occured when fetching the security analysis parameters",
246
246
  fetchSecurityAnalysisProvidersError: "An error occured when fetching security analysis provider list",
247
247
  updateSecurityAnalysisParametersError: "An error occurred while updating the security analysis parameters",
248
+ getSecurityAnalysisContingenciesCountError: "An error occurred while estimating security analysis contingencies count",
248
249
  // SensitivityAnalysis
249
250
  fetchSensitivityAnalysisParametersError: "An error occured when fetching the sensitivity analysis parameters",
250
251
  fetchSensitivityAnalysisProvidersError: "An error occured when fetching sensitivity analysis provider list",
@@ -143,6 +143,7 @@ export declare const networkModificationsFr: {
143
143
  Side1: string;
144
144
  Side2: string;
145
145
  Or: string;
146
+ SubstationTab: string;
146
147
  ConnectivityTab: string;
147
148
  CharacteristicsTab: string;
148
149
  StructureTab: string;
@@ -150,6 +150,7 @@ const networkModificationsFr = {
150
150
  Side2: "Côté 2",
151
151
  Or: "ou",
152
152
  // Tabs
153
+ SubstationTab: "Site",
153
154
  ConnectivityTab: "Connectivité",
154
155
  CharacteristicsTab: "Caractéristiques",
155
156
  StructureTab: "Structure",
@@ -248,6 +248,7 @@ export declare const parametersFr: {
248
248
  fetchSecurityAnalysisParametersError: string;
249
249
  fetchSecurityAnalysisProvidersError: string;
250
250
  updateSecurityAnalysisParametersError: string;
251
+ getSecurityAnalysisContingenciesCountError: string;
251
252
  fetchSensitivityAnalysisParametersError: string;
252
253
  fetchSensitivityAnalysisProvidersError: string;
253
254
  updateSensitivityAnalysisParametersError: string;
@@ -245,6 +245,7 @@ const parametersFr = {
245
245
  fetchSecurityAnalysisParametersError: "Une erreur est survenue lors de la récupération des paramètres de l'analyse de sécurité",
246
246
  fetchSecurityAnalysisProvidersError: "Une erreur est survenue lors de la récupération des fournisseurs d'analyse de sécurité",
247
247
  updateSecurityAnalysisParametersError: "Une erreur est survenue lors de la mise a jour des paramètres de l'analyse de sécurité",
248
+ getSecurityAnalysisContingenciesCountError: "Une erreur est survenue lors de l'estimation du nombre d'aléas de l'analyse de sécurité",
248
249
  // SensitivityAnalysis
249
250
  fetchSensitivityAnalysisParametersError: "Une erreur est survenue lors de la récupération des paramètres de l'analyse de sensibilité",
250
251
  fetchSensitivityAnalysisProvidersError: "Une erreur est survenue lors de la récupération des fournisseurs d'analyse de sensibilité",
@@ -27,7 +27,7 @@ import { AnnouncementSeverity, ArrayAction } from "./types/types.js";
27
27
  import { MODIFICATION_TYPES, ModificationType } from "./types/modificationType.js";
28
28
  import { FieldType } from "./types/fieldType.js";
29
29
  import { ParameterType } from "./types/parameters.type.js";
30
- import { SolverTypeInfos } from "./types/dynamic-simulation.type.js";
30
+ import { SolverType } from "./types/dynamic-simulation.type.js";
31
31
  import { DistributionType, SensitivityType } from "./types/sensitivity-analysis.type.js";
32
32
  import { CalculationType, LoadModelsRule } from "./types/dynamic-margin-calculation.type.js";
33
33
  import { OperationType } from "./types/network-modification-types.js";
@@ -115,7 +115,7 @@ export {
115
115
  SVC,
116
116
  SensitivityType,
117
117
  ShuntCompensator,
118
- SolverTypeInfos,
118
+ SolverType,
119
119
  Substation,
120
120
  SusceptanceAdornment,
121
121
  TYPE_TAG_MAX_SIZE,
@@ -1,12 +1,11 @@
1
1
  import { UUID } from 'node:crypto';
2
- export declare enum SolverTypeInfos {
2
+ export declare enum SolverType {
3
3
  IDA = "IDA",
4
4
  SIM = "SIM"
5
5
  }
6
6
  type CommonSolverInfos = {
7
- id: string;
8
- name: string;
9
- type: SolverTypeInfos;
7
+ id: UUID;
8
+ type: SolverType;
10
9
  fNormTolAlg: number;
11
10
  initialAddTolAlg: number;
12
11
  scStepTolAlg: number;
@@ -32,8 +31,7 @@ type CommonSolverInfos = {
32
31
  minimalAcceptableStep: number;
33
32
  };
34
33
  type IdaSolverInfos = CommonSolverInfos & {
35
- name: 'IDA';
36
- type: SolverTypeInfos.IDA;
34
+ type: SolverType.IDA;
37
35
  order: number;
38
36
  initStep: number;
39
37
  minStep: number;
@@ -42,8 +40,7 @@ type IdaSolverInfos = CommonSolverInfos & {
42
40
  relAccuracy: number;
43
41
  };
44
42
  type SimSolverInfos = CommonSolverInfos & {
45
- name: 'SIM';
46
- type: SolverTypeInfos.SIM;
43
+ type: SolverType.SIM;
47
44
  hMin: number;
48
45
  hMax: number;
49
46
  kReduceStep: number;
@@ -63,8 +60,9 @@ type SimSolverInfos = CommonSolverInfos & {
63
60
  minimumModeChangeTypeForAlgebraicRestoration: string;
64
61
  minimumModeChangeTypeForAlgebraicRestorationInit: string;
65
62
  };
66
- type NetworkInfos = Record<string, number | string | boolean>;
63
+ type NetworkInfos = Record<string, UUID | number | string | boolean>;
67
64
  type CurveInfos = {
65
+ id?: UUID;
68
66
  equipmentType?: string;
69
67
  equipmentId: string;
70
68
  variableId: string;
@@ -95,11 +93,12 @@ export type MappingInfos = {
95
93
  name: string;
96
94
  };
97
95
  export type DynamicSimulationParametersInfos = {
96
+ id?: UUID;
98
97
  provider?: string;
99
98
  startTime?: number;
100
99
  stopTime?: number;
101
100
  mapping?: string;
102
- solverId: string;
101
+ solver: SolverType;
103
102
  solvers?: SolverInfos[];
104
103
  network?: NetworkInfos;
105
104
  curves?: CurveInfos[] | null;
@@ -1,8 +1,8 @@
1
- var SolverTypeInfos = /* @__PURE__ */ ((SolverTypeInfos2) => {
2
- SolverTypeInfos2["IDA"] = "IDA";
3
- SolverTypeInfos2["SIM"] = "SIM";
4
- return SolverTypeInfos2;
5
- })(SolverTypeInfos || {});
1
+ var SolverType = /* @__PURE__ */ ((SolverType2) => {
2
+ SolverType2["IDA"] = "IDA";
3
+ SolverType2["SIM"] = "SIM";
4
+ return SolverType2;
5
+ })(SolverType || {});
6
6
  export {
7
- SolverTypeInfos
7
+ SolverType
8
8
  };
@@ -8,7 +8,7 @@ import { AnnouncementSeverity, ArrayAction } from "./types.js";
8
8
  import { MODIFICATION_TYPES, ModificationType } from "./modificationType.js";
9
9
  import { FieldType } from "./fieldType.js";
10
10
  import { ParameterType } from "./parameters.type.js";
11
- import { SolverTypeInfos } from "./dynamic-simulation.type.js";
11
+ import { SolverType } from "./dynamic-simulation.type.js";
12
12
  import { DistributionType, SensitivityType } from "./sensitivity-analysis.type.js";
13
13
  import { CalculationType, LoadModelsRule } from "./dynamic-margin-calculation.type.js";
14
14
  import { OperationType } from "./network-modification-types.js";
@@ -47,7 +47,7 @@ export {
47
47
  SVC,
48
48
  SensitivityType,
49
49
  ShuntCompensator,
50
- SolverTypeInfos,
50
+ SolverType,
51
51
  Substation,
52
52
  TYPE_TAG_MAX_SIZE,
53
53
  ThreeWindingTransfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.187.0",
3
+ "version": "0.189.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",