@gridsuite/commons-ui 0.68.2 → 0.68.4
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/dialogs/customMuiDialog/CustomMuiDialog.d.ts +0 -1
- package/dist/components/dialogs/customMuiDialog/CustomMuiDialog.js +1 -2
- package/dist/components/filter/FilterForm.js +13 -3
- package/dist/components/filter/HeaderFilterForm.d.ts +2 -1
- package/dist/components/filter/HeaderFilterForm.js +3 -13
- package/dist/components/filter/utils/filterFormUtils.d.ts +1 -1
- package/dist/components/filter/utils/filterFormUtils.js +20 -0
- package/dist/services/explore.js +25 -19
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from "@mui/material";
|
|
3
|
-
import { useWatch } from "react-hook-form";
|
|
3
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
4
|
+
import { useEffect } from "react";
|
|
4
5
|
import { HeaderFilterForm } from "./HeaderFilterForm.js";
|
|
5
6
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
6
7
|
import { CriteriaBasedFilterForm } from "./criteriaBased/CriteriaBasedFilterForm.js";
|
|
@@ -9,7 +10,6 @@ import { ExpertFilterForm } from "./expert/ExpertFilterForm.js";
|
|
|
9
10
|
import { FilterType } from "./constants/FilterConstants.js";
|
|
10
11
|
import { unscrollableDialogStyles } from "../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
11
12
|
import "../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
|
|
12
|
-
import "react";
|
|
13
13
|
import "react-intl";
|
|
14
14
|
import "@mui/icons-material";
|
|
15
15
|
import "../treeViewFinder/TreeViewFinder.js";
|
|
@@ -26,7 +26,16 @@ function FilterForm({
|
|
|
26
26
|
activeDirectory,
|
|
27
27
|
elementExists
|
|
28
28
|
}) {
|
|
29
|
+
const { setValue } = useFormContext();
|
|
29
30
|
const filterType = useWatch({ name: FieldConstants.FILTER_TYPE });
|
|
31
|
+
const handleFilterTypeChange = (_event, value) => {
|
|
32
|
+
setValue(FieldConstants.FILTER_TYPE, value);
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (sourceFilterForExplicitNamingConversion) {
|
|
36
|
+
setValue(FieldConstants.FILTER_TYPE, FilterType.EXPLICIT_NAMING.id);
|
|
37
|
+
}
|
|
38
|
+
}, [sourceFilterForExplicitNamingConversion, setValue]);
|
|
30
39
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
40
|
/* @__PURE__ */ jsx(Box, { sx: unscrollableDialogStyles.unscrollableHeader, children: /* @__PURE__ */ jsx(
|
|
32
41
|
HeaderFilterForm,
|
|
@@ -34,7 +43,8 @@ function FilterForm({
|
|
|
34
43
|
creation,
|
|
35
44
|
activeDirectory,
|
|
36
45
|
elementExists,
|
|
37
|
-
sourceFilterForExplicitNamingConversion
|
|
46
|
+
sourceFilterForExplicitNamingConversion,
|
|
47
|
+
handleFilterTypeChange
|
|
38
48
|
}
|
|
39
49
|
) }),
|
|
40
50
|
filterType === FilterType.CRITERIA_BASED.id && /* @__PURE__ */ jsx(CriteriaBasedFilterForm, {}),
|
|
@@ -9,5 +9,6 @@ export interface FilterFormProps {
|
|
|
9
9
|
id: UUID;
|
|
10
10
|
equipmentType: string;
|
|
11
11
|
};
|
|
12
|
+
handleFilterTypeChange?: (event: React.ChangeEvent<HTMLInputElement>, value: string) => void;
|
|
12
13
|
}
|
|
13
|
-
export declare function HeaderFilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function HeaderFilterForm({ sourceFilterForExplicitNamingConversion, creation, activeDirectory, elementExists, handleFilterTypeChange, }: Readonly<FilterFormProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useFormContext } from "react-hook-form";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
2
|
import { Grid } from "@mui/material";
|
|
5
3
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
6
4
|
import { FilterType } from "./constants/FilterConstants.js";
|
|
@@ -12,17 +10,9 @@ function HeaderFilterForm({
|
|
|
12
10
|
sourceFilterForExplicitNamingConversion,
|
|
13
11
|
creation,
|
|
14
12
|
activeDirectory,
|
|
15
|
-
elementExists
|
|
13
|
+
elementExists,
|
|
14
|
+
handleFilterTypeChange
|
|
16
15
|
}) {
|
|
17
|
-
const { setValue } = useFormContext();
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (sourceFilterForExplicitNamingConversion) {
|
|
20
|
-
setValue(FieldConstants.FILTER_TYPE, FilterType.EXPLICIT_NAMING.id);
|
|
21
|
-
}
|
|
22
|
-
}, [sourceFilterForExplicitNamingConversion, setValue]);
|
|
23
|
-
const handleChange = (_event, value) => {
|
|
24
|
-
setValue(FieldConstants.FILTER_TYPE, value);
|
|
25
|
-
};
|
|
26
16
|
return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [
|
|
27
17
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
|
|
28
18
|
UniqueNameInput,
|
|
@@ -42,7 +32,7 @@ function HeaderFilterForm({
|
|
|
42
32
|
{
|
|
43
33
|
name: FieldConstants.FILTER_TYPE,
|
|
44
34
|
options: Object.values(FilterType),
|
|
45
|
-
formProps: { onChange:
|
|
35
|
+
formProps: { onChange: handleFilterTypeChange }
|
|
46
36
|
}
|
|
47
37
|
) })
|
|
48
38
|
] })
|
|
@@ -13,5 +13,5 @@ export type FormEquipment = {
|
|
|
13
13
|
label: string;
|
|
14
14
|
fields: FormField[];
|
|
15
15
|
};
|
|
16
|
-
export declare const CONTINGENCY_LIST_EQUIPMENTS: Record<EquipmentType.BUSBAR_SECTION | EquipmentType.LINE | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.GENERATOR | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.HVDC_LINE | EquipmentType.DANGLING_LINE, FormEquipment>;
|
|
16
|
+
export declare const CONTINGENCY_LIST_EQUIPMENTS: Record<EquipmentType.BUSBAR_SECTION | EquipmentType.LINE | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.THREE_WINDINGS_TRANSFORMER | EquipmentType.GENERATOR | EquipmentType.BATTERY | EquipmentType.LOAD | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.STATIC_VAR_COMPENSATOR | EquipmentType.HVDC_LINE | EquipmentType.DANGLING_LINE, FormEquipment>;
|
|
17
17
|
export declare const FILTER_EQUIPMENTS: Record<EquipmentType.SUBSTATION | EquipmentType.VOLTAGE_LEVEL | EquipmentType.LINE | EquipmentType.TWO_WINDINGS_TRANSFORMER | EquipmentType.THREE_WINDINGS_TRANSFORMER | EquipmentType.GENERATOR | EquipmentType.BATTERY | EquipmentType.LOAD | EquipmentType.SHUNT_COMPENSATOR | EquipmentType.STATIC_VAR_COMPENSATOR | EquipmentType.HVDC_LINE | EquipmentType.DANGLING_LINE, FormEquipment>;
|
|
@@ -82,16 +82,36 @@ const CONTINGENCY_LIST_EQUIPMENTS = {
|
|
|
82
82
|
label: "TwoWindingsTransformers",
|
|
83
83
|
fields: [countries, nominalVoltage1, nominalVoltage2]
|
|
84
84
|
},
|
|
85
|
+
THREE_WINDINGS_TRANSFORMER: {
|
|
86
|
+
id: "THREE_WINDINGS_TRANSFORMER",
|
|
87
|
+
label: "ThreeWindingsTransformers",
|
|
88
|
+
fields: [countries, nominalVoltage1, nominalVoltage2, nominalVoltage3]
|
|
89
|
+
},
|
|
85
90
|
GENERATOR: {
|
|
86
91
|
id: "GENERATOR",
|
|
87
92
|
label: "Generators",
|
|
88
93
|
fields: [countries, nominalVoltage]
|
|
89
94
|
},
|
|
95
|
+
BATTERY: {
|
|
96
|
+
id: "BATTERY",
|
|
97
|
+
label: "Batteries",
|
|
98
|
+
fields: [countries, nominalVoltage]
|
|
99
|
+
},
|
|
100
|
+
LOAD: {
|
|
101
|
+
id: "LOAD",
|
|
102
|
+
label: "Loads",
|
|
103
|
+
fields: [countries, nominalVoltage]
|
|
104
|
+
},
|
|
90
105
|
SHUNT_COMPENSATOR: {
|
|
91
106
|
id: "SHUNT_COMPENSATOR",
|
|
92
107
|
label: "ShuntCompensators",
|
|
93
108
|
fields: [countries, nominalVoltage]
|
|
94
109
|
},
|
|
110
|
+
STATIC_VAR_COMPENSATOR: {
|
|
111
|
+
id: "STATIC_VAR_COMPENSATOR",
|
|
112
|
+
label: "StaticVarCompensators",
|
|
113
|
+
fields: [countries, nominalVoltage]
|
|
114
|
+
},
|
|
95
115
|
HVDC_LINE: {
|
|
96
116
|
id: "HVDC_LINE",
|
|
97
117
|
label: "HvdcLines",
|
package/dist/services/explore.js
CHANGED
|
@@ -30,26 +30,32 @@ function saveFilter(filter, name, token) {
|
|
|
30
30
|
token
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
function fetchElementsInfos(ids, elementTypes, equipmentTypes) {
|
|
33
|
+
async function fetchElementsInfos(ids, elementTypes, equipmentTypes) {
|
|
34
34
|
console.info("Fetching elements metadata");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
let final = [];
|
|
36
|
+
const chunkSize = 50;
|
|
37
|
+
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
38
|
+
const partitionIds = ids.slice(i, i + chunkSize);
|
|
39
|
+
const idsParams = getRequestParamFromList(
|
|
40
|
+
"ids",
|
|
41
|
+
partitionIds.filter((id) => id)
|
|
42
|
+
// filter falsy elements
|
|
43
|
+
);
|
|
44
|
+
const equipmentTypesParams = getRequestParamFromList("equipmentTypes", equipmentTypes);
|
|
45
|
+
const elementTypesParams = getRequestParamFromList("elementTypes", elementTypes);
|
|
46
|
+
const urlSearchParams = new URLSearchParams([
|
|
47
|
+
...idsParams,
|
|
48
|
+
...equipmentTypesParams,
|
|
49
|
+
...elementTypesParams
|
|
50
|
+
]).toString();
|
|
51
|
+
const url = `${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/metadata?${urlSearchParams}`;
|
|
52
|
+
const result = await backendFetchJson(url, {
|
|
53
|
+
method: "get",
|
|
54
|
+
headers: { "Content-Type": "application/json" }
|
|
55
|
+
});
|
|
56
|
+
final = final.concat(result);
|
|
57
|
+
}
|
|
58
|
+
return final;
|
|
53
59
|
}
|
|
54
60
|
export {
|
|
55
61
|
createFilter,
|