@gridsuite/commons-ui 0.111.0 → 0.113.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.
- package/dist/components/csvDownloader/csv-export.d.ts +1 -1
- package/dist/components/csvDownloader/csv-export.js +2 -3
- package/dist/components/csvDownloader/csv-export.type.d.ts +0 -3
- package/dist/components/dnd-table/dnd-table.js +2 -2
- package/dist/components/index.js +27 -6
- package/dist/components/inputs/reactHookForm/provider/CustomFormProvider.js +0 -4
- package/dist/components/inputs/reactHookForm/text/DescriptionField.js +0 -3
- package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +1 -0
- package/dist/components/parameters/common/index.js +0 -2
- package/dist/components/parameters/common/limitreductions/columns-definitions.d.ts +7 -2
- package/dist/components/parameters/common/limitreductions/columns-definitions.js +16 -3
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.d.ts +3 -3
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +4 -1
- package/dist/components/parameters/common/limitreductions/limit-reduction-table-row.d.ts +2 -2
- package/dist/components/parameters/common/name-element-editor/name-element-editor-form.js +5 -28
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.d.ts +2 -2
- package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +2 -2
- package/dist/components/parameters/common/parameters-edition-dialog-props.d.ts +0 -4
- package/dist/components/parameters/common/parameters-edition-dialog-props.js +1 -14
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.d.ts +2 -2
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-row.d.ts +2 -2
- package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table.d.ts +2 -2
- package/dist/components/parameters/index.d.ts +1 -1
- package/dist/components/parameters/index.js +27 -6
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +1 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +1 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +1 -1
- package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +0 -2
- package/dist/components/parameters/network-visualizations/map-parameters.js +1 -1
- package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +1 -1
- package/dist/components/parameters/parameters-style.d.ts +0 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +8 -2
- package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +2 -1
- package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +1 -1
- package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +1 -1
- package/dist/components/parameters/sensi/columns-definitions.d.ts +222 -0
- package/dist/components/parameters/sensi/columns-definitions.js +305 -0
- package/dist/components/parameters/sensi/constants.d.ts +29 -0
- package/dist/components/parameters/sensi/constants.js +48 -0
- package/dist/components/parameters/sensi/index.d.ts +10 -0
- package/dist/components/parameters/sensi/index.js +29 -0
- package/dist/components/parameters/sensi/sensitivity-Flow-parameters.d.ts +7 -0
- package/dist/components/parameters/sensi/sensitivity-Flow-parameters.js +72 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.d.ts +2 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +113 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.d.ts +8 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +129 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.d.ts +13 -0
- package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +185 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.d.ts +16 -0
- package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +274 -0
- package/dist/components/parameters/sensi/sensitivity-table.d.ts +15 -0
- package/dist/components/parameters/sensi/sensitivity-table.js +134 -0
- package/dist/components/parameters/sensi/table-cell.d.ts +8 -0
- package/dist/components/parameters/sensi/table-cell.js +86 -0
- package/dist/components/parameters/sensi/table-row.d.ts +11 -0
- package/dist/components/parameters/sensi/table-row.js +42 -0
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +49 -0
- package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +413 -0
- package/dist/components/parameters/sensi/utils.d.ts +419 -0
- package/dist/components/parameters/sensi/utils.js +357 -0
- package/dist/components/parameters/voltage-init/general-parameters.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/use-create-row-data-sensi.d.ts +4 -0
- package/dist/hooks/use-create-row-data-sensi.js +20 -0
- package/dist/index.js +29 -6
- package/dist/services/sensitivity-analysis.d.ts +12 -0
- package/dist/services/sensitivity-analysis.js +87 -0
- package/dist/translations/en/parameters.d.ts +64 -0
- package/dist/translations/en/parameters.js +70 -1
- package/dist/translations/fr/parameters.d.ts +64 -0
- package/dist/translations/fr/parameters.js +70 -1
- package/package.json +1 -1
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { useForm } from "react-hook-form";
|
|
2
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
3
|
+
import { useState, useMemo, useCallback, useEffect } from "react";
|
|
4
|
+
import { PROVIDER } from "../common/constant.js";
|
|
5
|
+
import "react/jsx-runtime";
|
|
6
|
+
import "@mui/material";
|
|
7
|
+
import "react-intl";
|
|
8
|
+
import "../../../utils/types/equipmentType.js";
|
|
9
|
+
import { updateParameter } from "../../../services/explore.js";
|
|
10
|
+
import "localized-countries";
|
|
11
|
+
import "localized-countries/data/fr";
|
|
12
|
+
import "localized-countries/data/en";
|
|
13
|
+
import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
|
|
14
|
+
import { PARAMETER_SENSI_NODES, PARAMETER_SENSI_PST, PARAMETER_SENSI_HVDC, PARAMETER_SENSI_INJECTION, PARAMETER_SENSI_INJECTIONS_SET, FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, ACTIVATED, MONITORED_BRANCHES, INJECTIONS, PSTS, HVDC_LINES, COUNT, SENSI_INJECTIONS_SET, CONTINGENCIES, CONTAINER_NAME, CONTAINER_ID, EQUIPMENTS_IN_VOLTAGE_REGULATION, SUPERVISED_VOLTAGE_LEVELS, SENSITIVITY_TYPE, DISTRIBUTION_TYPE } from "./constants.js";
|
|
15
|
+
import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
|
|
16
|
+
import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
17
|
+
import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
|
|
18
|
+
import "@mui/icons-material";
|
|
19
|
+
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
20
|
+
import { ElementType } from "../../../utils/types/elementType.js";
|
|
21
|
+
import "../../treeViewFinder/TreeViewFinder.js";
|
|
22
|
+
import "yup";
|
|
23
|
+
import "../../overflowableText/OverflowableText.js";
|
|
24
|
+
import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
|
|
25
|
+
import "../../customAGGrid/customAggrid.js";
|
|
26
|
+
import "ag-grid-community";
|
|
27
|
+
import "react-papaparse";
|
|
28
|
+
import "react-csv-downloader";
|
|
29
|
+
import "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
30
|
+
import "../../../utils/conversionUtils.js";
|
|
31
|
+
import "../../../utils/yupConfig.js";
|
|
32
|
+
import "@react-querybuilder/material";
|
|
33
|
+
import "../../filter/expert/expertFilterConstants.js";
|
|
34
|
+
import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
35
|
+
import "uuid";
|
|
36
|
+
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
37
|
+
import "react-querybuilder";
|
|
38
|
+
import "../common/widget/parameter-line-slider.js";
|
|
39
|
+
import "../common/limitreductions/columns-definitions.js";
|
|
40
|
+
import { getFormSchema, getSensiNodesformatNewParams, getSensiPstformatNewParams, getSensiHvdcformatNewParams, getSensiInjectionsformatNewParams, getSensiInjectionsSetformatNewParams, getGenericRowNewParams } from "./utils.js";
|
|
41
|
+
import { getSensitivityAnalysisFactorsCount, setSensitivityAnalysisParameters } from "../../../services/sensitivity-analysis.js";
|
|
42
|
+
import "../../filter/HeaderFilterForm.js";
|
|
43
|
+
import { getNameElementEditorEmptyFormData } from "../common/name-element-editor/name-element-editor-utils.js";
|
|
44
|
+
const numberMax = 5e5;
|
|
45
|
+
const useSensitivityAnalysisParametersForm = ({
|
|
46
|
+
studyUuid,
|
|
47
|
+
currentNodeUuid,
|
|
48
|
+
currentRootNetworkUuid,
|
|
49
|
+
parametersBackend,
|
|
50
|
+
parametersUuid,
|
|
51
|
+
name,
|
|
52
|
+
description
|
|
53
|
+
}) => {
|
|
54
|
+
const [providers, , , , , params, , updateParameters] = parametersBackend;
|
|
55
|
+
const [sensitivityAnalysisParams, setSensitivityAnalysisParams] = useState(params);
|
|
56
|
+
const [analysisComputeComplexity, setAnalysisComputeComplexity] = useState(0);
|
|
57
|
+
const [launchLoader, setLaunchLoader] = useState(false);
|
|
58
|
+
const [isSubmitAction, setIsSubmitAction] = useState(false);
|
|
59
|
+
const { snackError } = useSnackMessage();
|
|
60
|
+
const emptyFormData = useMemo(() => {
|
|
61
|
+
return {
|
|
62
|
+
...getNameElementEditorEmptyFormData(name, description),
|
|
63
|
+
[PROVIDER]: "",
|
|
64
|
+
[FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: 0,
|
|
65
|
+
[ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: 0,
|
|
66
|
+
[FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD]: 0,
|
|
67
|
+
[PARAMETER_SENSI_INJECTIONS_SET]: [],
|
|
68
|
+
[PARAMETER_SENSI_INJECTION]: [],
|
|
69
|
+
[PARAMETER_SENSI_HVDC]: [],
|
|
70
|
+
[PARAMETER_SENSI_PST]: [],
|
|
71
|
+
[PARAMETER_SENSI_NODES]: []
|
|
72
|
+
};
|
|
73
|
+
}, [description, name]);
|
|
74
|
+
const isStudyLinked = useMemo(() => {
|
|
75
|
+
return studyUuid !== null && currentNodeUuid !== null && currentRootNetworkUuid !== null;
|
|
76
|
+
}, [currentNodeUuid, currentRootNetworkUuid, studyUuid]);
|
|
77
|
+
const formSchema = useMemo(() => {
|
|
78
|
+
return getFormSchema(name);
|
|
79
|
+
}, [name]);
|
|
80
|
+
const formMethods = useForm({
|
|
81
|
+
defaultValues: emptyFormData,
|
|
82
|
+
resolver: yupResolver(formSchema)
|
|
83
|
+
});
|
|
84
|
+
const { reset, getValues, setValue } = formMethods;
|
|
85
|
+
const formattedProviders = Object.keys(providers).map((key) => ({
|
|
86
|
+
id: key,
|
|
87
|
+
label: providers[key]
|
|
88
|
+
}));
|
|
89
|
+
const formatNewParams = useCallback((newParams) => {
|
|
90
|
+
return {
|
|
91
|
+
[PROVIDER]: newParams[PROVIDER],
|
|
92
|
+
[FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: newParams[FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD],
|
|
93
|
+
[ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: newParams[ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD],
|
|
94
|
+
[FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD]: newParams[FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD],
|
|
95
|
+
...getSensiInjectionsSetformatNewParams(newParams),
|
|
96
|
+
...getSensiInjectionsformatNewParams(newParams),
|
|
97
|
+
...getSensiHvdcformatNewParams(newParams),
|
|
98
|
+
...getSensiPstformatNewParams(newParams),
|
|
99
|
+
...getSensiNodesformatNewParams(newParams)
|
|
100
|
+
};
|
|
101
|
+
}, []);
|
|
102
|
+
const formatFilteredParams = useCallback((row) => {
|
|
103
|
+
return getGenericRowNewParams(row);
|
|
104
|
+
}, []);
|
|
105
|
+
const getResultCount = useCallback(() => {
|
|
106
|
+
const values = getValues();
|
|
107
|
+
let totalResultCount = 0;
|
|
108
|
+
const tabsToCheck = [
|
|
109
|
+
"sensitivityInjectionsSet",
|
|
110
|
+
"sensitivityInjection",
|
|
111
|
+
"sensitivityHVDC",
|
|
112
|
+
"sensitivityPST"
|
|
113
|
+
];
|
|
114
|
+
tabsToCheck.forEach((tab) => {
|
|
115
|
+
const tabToCheck = values[tab];
|
|
116
|
+
if (tabToCheck) {
|
|
117
|
+
const count = tabToCheck.filter((entry) => entry[ACTIVATED]).filter((entry) => entry[MONITORED_BRANCHES].length > 0).filter(
|
|
118
|
+
(entry) => {
|
|
119
|
+
var _a, _b, _c;
|
|
120
|
+
return ((_a = entry[INJECTIONS]) == null ? void 0 : _a.length) > 0 || ((_b = entry[PSTS]) == null ? void 0 : _b.length) > 0 || ((_c = entry[HVDC_LINES]) == null ? void 0 : _c.length) > 0;
|
|
121
|
+
}
|
|
122
|
+
).map((entry) => entry[COUNT]).reduce((a, b) => a + b, 0);
|
|
123
|
+
totalResultCount += count;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
setAnalysisComputeComplexity(totalResultCount);
|
|
127
|
+
const timeoutId = setTimeout(() => {
|
|
128
|
+
setLaunchLoader(false);
|
|
129
|
+
}, 500);
|
|
130
|
+
return () => clearTimeout(timeoutId);
|
|
131
|
+
}, [getValues]);
|
|
132
|
+
const onFormChanged = useCallback(
|
|
133
|
+
(formChanged) => {
|
|
134
|
+
if (formChanged) {
|
|
135
|
+
setLaunchLoader(true);
|
|
136
|
+
getResultCount();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
[getResultCount]
|
|
140
|
+
);
|
|
141
|
+
const onChangeParams = useCallback(
|
|
142
|
+
(row, arrayFormName, index) => {
|
|
143
|
+
if (!currentNodeUuid || !currentRootNetworkUuid) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setLaunchLoader(true);
|
|
147
|
+
getSensitivityAnalysisFactorsCount(
|
|
148
|
+
studyUuid,
|
|
149
|
+
currentNodeUuid,
|
|
150
|
+
currentRootNetworkUuid,
|
|
151
|
+
arrayFormName === SENSI_INJECTIONS_SET,
|
|
152
|
+
formatFilteredParams(row)
|
|
153
|
+
).then((response) => {
|
|
154
|
+
response.text().then((value) => {
|
|
155
|
+
setValue(
|
|
156
|
+
`${arrayFormName}.${index}.${COUNT}`,
|
|
157
|
+
!Number.isNaN(Number(value)) ? parseInt(value, 10) : 0
|
|
158
|
+
);
|
|
159
|
+
getResultCount();
|
|
160
|
+
});
|
|
161
|
+
}).catch((error) => {
|
|
162
|
+
setLaunchLoader(false);
|
|
163
|
+
snackError({
|
|
164
|
+
messageTxt: error.message,
|
|
165
|
+
headerId: "getSensitivityAnalysisFactorsCountError"
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
[snackError, studyUuid, currentRootNetworkUuid, formatFilteredParams, setValue, getResultCount, currentNodeUuid]
|
|
170
|
+
);
|
|
171
|
+
const fromSensitivityAnalysisParamsDataToFormValues = useCallback(
|
|
172
|
+
(parameters) => {
|
|
173
|
+
var _a, _b, _c, _d, _e;
|
|
174
|
+
const values = {
|
|
175
|
+
[PROVIDER]: parameters[PROVIDER],
|
|
176
|
+
[FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: parameters.flowFlowSensitivityValueThreshold,
|
|
177
|
+
[ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: parameters.angleFlowSensitivityValueThreshold,
|
|
178
|
+
[FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD]: parameters.flowVoltageSensitivityValueThreshold,
|
|
179
|
+
[PARAMETER_SENSI_INJECTIONS_SET]: ((_a = parameters.sensitivityInjectionsSet) == null ? void 0 : _a.map((sensiInjectionsSet) => {
|
|
180
|
+
var _a2, _b2, _c2;
|
|
181
|
+
return {
|
|
182
|
+
[MONITORED_BRANCHES]: ((_a2 = sensiInjectionsSet[MONITORED_BRANCHES]) == null ? void 0 : _a2.map((sensiInjection) => {
|
|
183
|
+
return {
|
|
184
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
185
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
186
|
+
};
|
|
187
|
+
})) ?? [],
|
|
188
|
+
[INJECTIONS]: ((_b2 = sensiInjectionsSet[INJECTIONS]) == null ? void 0 : _b2.map((sensiInjection) => {
|
|
189
|
+
return {
|
|
190
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
191
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
192
|
+
};
|
|
193
|
+
})) ?? [],
|
|
194
|
+
[DISTRIBUTION_TYPE]: sensiInjectionsSet[DISTRIBUTION_TYPE],
|
|
195
|
+
[CONTINGENCIES]: ((_c2 = sensiInjectionsSet[CONTINGENCIES]) == null ? void 0 : _c2.map((sensiInjection) => {
|
|
196
|
+
return {
|
|
197
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
198
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
199
|
+
};
|
|
200
|
+
})) ?? [],
|
|
201
|
+
[ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
|
|
202
|
+
[COUNT]: 0
|
|
203
|
+
};
|
|
204
|
+
})) ?? [],
|
|
205
|
+
[PARAMETER_SENSI_INJECTION]: ((_b = parameters.sensitivityInjection) == null ? void 0 : _b.map((sensiInjections) => {
|
|
206
|
+
var _a2, _b2, _c2;
|
|
207
|
+
return {
|
|
208
|
+
[MONITORED_BRANCHES]: ((_a2 = sensiInjections[MONITORED_BRANCHES]) == null ? void 0 : _a2.map((sensiInjection) => {
|
|
209
|
+
return {
|
|
210
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
211
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
212
|
+
};
|
|
213
|
+
})) ?? [],
|
|
214
|
+
[INJECTIONS]: ((_b2 = sensiInjections[INJECTIONS]) == null ? void 0 : _b2.map((sensiInjection) => {
|
|
215
|
+
return {
|
|
216
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
217
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
218
|
+
};
|
|
219
|
+
})) ?? [],
|
|
220
|
+
[CONTINGENCIES]: ((_c2 = sensiInjections[CONTINGENCIES]) == null ? void 0 : _c2.map((sensiInjection) => {
|
|
221
|
+
return {
|
|
222
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
223
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
224
|
+
};
|
|
225
|
+
})) ?? [],
|
|
226
|
+
[ACTIVATED]: sensiInjections[ACTIVATED] ?? false,
|
|
227
|
+
[COUNT]: 0
|
|
228
|
+
};
|
|
229
|
+
})) ?? [],
|
|
230
|
+
[PARAMETER_SENSI_HVDC]: ((_c = parameters.sensitivityHVDC) == null ? void 0 : _c.map((sensiInjectionsSet) => {
|
|
231
|
+
var _a2, _b2, _c2;
|
|
232
|
+
return {
|
|
233
|
+
[MONITORED_BRANCHES]: ((_a2 = sensiInjectionsSet[MONITORED_BRANCHES]) == null ? void 0 : _a2.map((sensiInjection) => {
|
|
234
|
+
return {
|
|
235
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
236
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
237
|
+
};
|
|
238
|
+
})) ?? [],
|
|
239
|
+
[HVDC_LINES]: ((_b2 = sensiInjectionsSet[HVDC_LINES]) == null ? void 0 : _b2.map((sensiInjection) => {
|
|
240
|
+
return {
|
|
241
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
242
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
243
|
+
};
|
|
244
|
+
})) ?? [],
|
|
245
|
+
[SENSITIVITY_TYPE]: sensiInjectionsSet[SENSITIVITY_TYPE],
|
|
246
|
+
[CONTINGENCIES]: ((_c2 = sensiInjectionsSet[CONTINGENCIES]) == null ? void 0 : _c2.map((sensiInjection) => {
|
|
247
|
+
return {
|
|
248
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
249
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
250
|
+
};
|
|
251
|
+
})) ?? [],
|
|
252
|
+
[ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
|
|
253
|
+
[COUNT]: 0
|
|
254
|
+
};
|
|
255
|
+
})) ?? [],
|
|
256
|
+
[PARAMETER_SENSI_PST]: ((_d = parameters.sensitivityPST) == null ? void 0 : _d.map((sensiInjectionsSet) => {
|
|
257
|
+
var _a2, _b2, _c2;
|
|
258
|
+
return {
|
|
259
|
+
[MONITORED_BRANCHES]: ((_a2 = sensiInjectionsSet[MONITORED_BRANCHES]) == null ? void 0 : _a2.map((sensiInjection) => {
|
|
260
|
+
return {
|
|
261
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
262
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
263
|
+
};
|
|
264
|
+
})) ?? [],
|
|
265
|
+
[PSTS]: ((_b2 = sensiInjectionsSet[PSTS]) == null ? void 0 : _b2.map((sensiInjection) => {
|
|
266
|
+
return {
|
|
267
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
268
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
269
|
+
};
|
|
270
|
+
})) ?? [],
|
|
271
|
+
[SENSITIVITY_TYPE]: sensiInjectionsSet[SENSITIVITY_TYPE],
|
|
272
|
+
[CONTINGENCIES]: ((_c2 = sensiInjectionsSet[CONTINGENCIES]) == null ? void 0 : _c2.map((sensiInjection) => {
|
|
273
|
+
return {
|
|
274
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
275
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
276
|
+
};
|
|
277
|
+
})) ?? [],
|
|
278
|
+
[ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
|
|
279
|
+
[COUNT]: 0
|
|
280
|
+
};
|
|
281
|
+
})) ?? [],
|
|
282
|
+
[PARAMETER_SENSI_NODES]: ((_e = parameters.sensitivityNodes) == null ? void 0 : _e.map((sensiInjectionsSet) => {
|
|
283
|
+
var _a2, _b2, _c2;
|
|
284
|
+
return {
|
|
285
|
+
[SUPERVISED_VOLTAGE_LEVELS]: ((_a2 = sensiInjectionsSet[SUPERVISED_VOLTAGE_LEVELS]) == null ? void 0 : _a2.map((sensiInjection) => {
|
|
286
|
+
return {
|
|
287
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
288
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
289
|
+
};
|
|
290
|
+
})) ?? [],
|
|
291
|
+
[EQUIPMENTS_IN_VOLTAGE_REGULATION]: ((_b2 = sensiInjectionsSet[EQUIPMENTS_IN_VOLTAGE_REGULATION]) == null ? void 0 : _b2.map((sensiInjection) => {
|
|
292
|
+
return {
|
|
293
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
294
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
295
|
+
};
|
|
296
|
+
})) ?? [],
|
|
297
|
+
[CONTINGENCIES]: ((_c2 = sensiInjectionsSet[CONTINGENCIES]) == null ? void 0 : _c2.map((sensiInjection) => {
|
|
298
|
+
return {
|
|
299
|
+
[FieldConstants.ID]: sensiInjection[CONTAINER_ID],
|
|
300
|
+
[FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
|
|
301
|
+
};
|
|
302
|
+
})) ?? [],
|
|
303
|
+
[ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
|
|
304
|
+
[COUNT]: 0
|
|
305
|
+
};
|
|
306
|
+
})) ?? []
|
|
307
|
+
};
|
|
308
|
+
return values;
|
|
309
|
+
},
|
|
310
|
+
[]
|
|
311
|
+
);
|
|
312
|
+
const initRowsCount = useCallback(() => {
|
|
313
|
+
const handleEntries = (entries, parameter) => {
|
|
314
|
+
if (!entries) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const entriesWithIndices = entries.map((entry, index) => ({
|
|
318
|
+
entry,
|
|
319
|
+
index
|
|
320
|
+
}));
|
|
321
|
+
const filteredInitEntries = entries.filter(
|
|
322
|
+
(entry) => {
|
|
323
|
+
var _a, _b, _c;
|
|
324
|
+
return entry[ACTIVATED] && entry[MONITORED_BRANCHES].length > 0 && (((_a = entry[INJECTIONS]) == null ? void 0 : _a.length) > 0 || ((_b = entry[PSTS]) == null ? void 0 : _b.length) > 0 || ((_c = entry[HVDC_LINES]) == null ? void 0 : _c.length) > 0);
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
filteredInitEntries.forEach((entry) => {
|
|
328
|
+
const originalIndex = entriesWithIndices.findIndex((obj) => obj.entry === entry);
|
|
329
|
+
onChangeParams(entry, parameter, originalIndex);
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
const values = getValues();
|
|
333
|
+
handleEntries(values[PARAMETER_SENSI_INJECTIONS_SET], PARAMETER_SENSI_INJECTIONS_SET);
|
|
334
|
+
handleEntries(values[PARAMETER_SENSI_INJECTION], PARAMETER_SENSI_INJECTION);
|
|
335
|
+
handleEntries(values[PARAMETER_SENSI_HVDC], PARAMETER_SENSI_HVDC);
|
|
336
|
+
handleEntries(values[PARAMETER_SENSI_PST], PARAMETER_SENSI_PST);
|
|
337
|
+
}, [onChangeParams, getValues]);
|
|
338
|
+
const onSaveInline = useCallback(
|
|
339
|
+
(newParams) => {
|
|
340
|
+
setIsSubmitAction(true);
|
|
341
|
+
setSensitivityAnalysisParameters(studyUuid, formatNewParams(newParams)).then(() => {
|
|
342
|
+
const formattedParams = formatNewParams(newParams);
|
|
343
|
+
setSensitivityAnalysisParams(formattedParams);
|
|
344
|
+
updateParameters(formattedParams);
|
|
345
|
+
initRowsCount();
|
|
346
|
+
}).catch((error) => {
|
|
347
|
+
snackError({
|
|
348
|
+
messageTxt: error.message,
|
|
349
|
+
headerId: "updateSensitivityAnalysisParametersError"
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
[setSensitivityAnalysisParams, snackError, studyUuid, formatNewParams, initRowsCount, updateParameters]
|
|
354
|
+
);
|
|
355
|
+
const onSaveDialog = useCallback(
|
|
356
|
+
(formData) => {
|
|
357
|
+
if (parametersUuid) {
|
|
358
|
+
updateParameter(
|
|
359
|
+
parametersUuid,
|
|
360
|
+
formatNewParams(formData),
|
|
361
|
+
formData[FieldConstants.NAME],
|
|
362
|
+
ElementType.SENSITIVITY_PARAMETERS,
|
|
363
|
+
formData[FieldConstants.DESCRIPTION] ?? ""
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
[parametersUuid, formatNewParams]
|
|
368
|
+
);
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
if (sensitivityAnalysisParams) {
|
|
371
|
+
reset(fromSensitivityAnalysisParamsDataToFormValues(sensitivityAnalysisParams));
|
|
372
|
+
if (!isSubmitAction) {
|
|
373
|
+
initRowsCount();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}, [
|
|
377
|
+
fromSensitivityAnalysisParamsDataToFormValues,
|
|
378
|
+
sensitivityAnalysisParams,
|
|
379
|
+
initRowsCount,
|
|
380
|
+
isSubmitAction,
|
|
381
|
+
reset
|
|
382
|
+
]);
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
if (params) {
|
|
385
|
+
reset(fromSensitivityAnalysisParamsDataToFormValues(params));
|
|
386
|
+
}
|
|
387
|
+
}, [params, reset, fromSensitivityAnalysisParamsDataToFormValues]);
|
|
388
|
+
const isMaxReached = useMemo(() => analysisComputeComplexity > numberMax, [analysisComputeComplexity]);
|
|
389
|
+
const paramsLoaded = useMemo(() => !!params, [params]);
|
|
390
|
+
return {
|
|
391
|
+
formMethods,
|
|
392
|
+
formSchema,
|
|
393
|
+
formattedProviders,
|
|
394
|
+
fromSensitivityAnalysisParamsDataToFormValues,
|
|
395
|
+
formatNewParams,
|
|
396
|
+
params,
|
|
397
|
+
paramsLoaded,
|
|
398
|
+
isStudyLinked,
|
|
399
|
+
onSaveInline,
|
|
400
|
+
onSaveDialog,
|
|
401
|
+
isMaxReached,
|
|
402
|
+
launchLoader,
|
|
403
|
+
initRowsCount,
|
|
404
|
+
onFormChanged,
|
|
405
|
+
onChangeParams,
|
|
406
|
+
emptyFormData,
|
|
407
|
+
analysisComputeComplexity,
|
|
408
|
+
setAnalysisComputeComplexity
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
export {
|
|
412
|
+
useSensitivityAnalysisParametersForm
|
|
413
|
+
};
|