@gridsuite/commons-ui 0.74.0 → 0.76.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/{filter → contingencyList}/criteriaBased/CriteriaBasedForm.d.ts +1 -1
- package/dist/components/{filter/criteriaBased/criteriaBasedFilterUtils.d.ts → contingencyList/criteriaBased/criteriaBasedUtils.d.ts} +0 -39
- package/dist/components/contingencyList/criteriaBased/criteriaBasedUtils.js +36 -0
- package/dist/components/{filter → contingencyList}/criteriaBased/index.d.ts +1 -6
- package/dist/components/contingencyList/criteriaBased/index.js +7 -0
- package/dist/components/filter/FilterCreationDialog.js +1 -10
- package/dist/components/filter/FilterForm.js +0 -2
- package/dist/components/filter/constants/FilterConstants.d.ts +0 -4
- package/dist/components/filter/constants/FilterConstants.js +0 -1
- package/dist/components/filter/index.d.ts +1 -1
- package/dist/components/filter/index.js +3 -24
- package/dist/components/filter/utils/filterApi.d.ts +0 -1
- package/dist/components/filter/utils/filterApi.js +0 -10
- package/dist/components/filter/utils/index.js +1 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +11 -24
- package/dist/components/notifications/NotificationsProvider.d.ts +6 -0
- package/dist/components/notifications/NotificationsProvider.js +54 -0
- package/dist/components/notifications/contexts/NotificationsContext.d.ts +23 -0
- package/dist/components/notifications/contexts/NotificationsContext.js +14 -0
- package/dist/components/notifications/hooks/useListenerManager.d.ts +7 -0
- package/dist/components/notifications/hooks/useListenerManager.js +50 -0
- package/dist/components/notifications/hooks/useNotificationsListener.d.ts +11 -0
- package/dist/components/notifications/hooks/useNotificationsListener.js +33 -0
- package/dist/components/notifications/index.d.ts +4 -0
- package/dist/components/notifications/index.js +10 -0
- package/dist/index.js +11 -24
- package/dist/translations/en/filterEn.d.ts +0 -1
- package/dist/translations/en/filterEn.js +1 -2
- package/dist/translations/en/networkModificationsEn.d.ts +1 -1
- package/dist/translations/en/networkModificationsEn.js +1 -1
- package/dist/translations/fr/filterFr.d.ts +0 -1
- package/dist/translations/fr/filterFr.js +1 -2
- package/dist/utils/mapper/getFileIcon.js +3 -1
- package/dist/utils/types/elementType.d.ts +2 -1
- package/dist/utils/types/elementType.js +1 -0
- package/package.json +2 -1
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.d.ts +0 -19
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.js +0 -103
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.d.ts +0 -49
- package/dist/components/filter/criteriaBased/CriteriaBasedFilterForm.js +0 -33
- package/dist/components/filter/criteriaBased/FilterFreeProperties.d.ts +0 -12
- package/dist/components/filter/criteriaBased/FilterFreeProperties.js +0 -68
- package/dist/components/filter/criteriaBased/FilterProperties.d.ts +0 -15
- package/dist/components/filter/criteriaBased/FilterProperties.js +0 -121
- package/dist/components/filter/criteriaBased/FilterProperty.d.ts +0 -18
- package/dist/components/filter/criteriaBased/FilterProperty.js +0 -65
- package/dist/components/filter/criteriaBased/criteriaBasedFilterUtils.js +0 -158
- package/dist/components/filter/criteriaBased/index.js +0 -27
- /package/dist/components/{filter → contingencyList}/criteriaBased/CriteriaBasedForm.js +0 -0
|
@@ -59,42 +59,3 @@ export declare function getCriteriaBasedFormData(criteriaValues?: Record<string,
|
|
|
59
59
|
readonly nominalVoltage3: any;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
/**
|
|
63
|
-
* Transform
|
|
64
|
-
* from obj.equipmentFilterForm.{
|
|
65
|
-
* freeProperties.{nameB:valuesB},
|
|
66
|
-
* freeProperties1.{nameA:valuesA},
|
|
67
|
-
* freeProperties2.{nameA:valuesC}}
|
|
68
|
-
* to a obj.criteriaBased.freeProperties.[
|
|
69
|
-
* {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
|
|
70
|
-
* {name_property:namesB, prop_values:valuesB}]
|
|
71
|
-
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
72
|
-
*/
|
|
73
|
-
export declare function backToFrontTweak(response: any): {
|
|
74
|
-
readonly criteriaBased: {
|
|
75
|
-
readonly countries: any;
|
|
76
|
-
readonly countries1: any;
|
|
77
|
-
readonly countries2: any;
|
|
78
|
-
readonly nominalVoltage: any;
|
|
79
|
-
readonly nominalVoltage1: any;
|
|
80
|
-
readonly nominalVoltage2: any;
|
|
81
|
-
readonly nominalVoltage3: any;
|
|
82
|
-
};
|
|
83
|
-
readonly equipmentType: any;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Transform
|
|
87
|
-
* from obj.criteriaBased.freeProperties.[
|
|
88
|
-
* {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
|
|
89
|
-
* {name_property:namesB, prop_values:valuesB}]
|
|
90
|
-
* to obj.equipmentFilterForm.{
|
|
91
|
-
* freeProperties.{nameB:valuesB},
|
|
92
|
-
* freeProperties1.{nameA:valuesA},
|
|
93
|
-
* freeProperties2.{nameA:valuesC}}
|
|
94
|
-
* @author Laurent LAUGARN modified by Florent MILLOT
|
|
95
|
-
*/
|
|
96
|
-
export declare function frontToBackTweak(id?: string, filter?: any): {
|
|
97
|
-
id: string | undefined;
|
|
98
|
-
type: string;
|
|
99
|
-
equipmentFilterForm: any;
|
|
100
|
-
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
+
import "../../../utils/yupConfig.js";
|
|
3
|
+
import { getRangeInputSchema, DEFAULT_RANGE_VALUE } from "../../inputs/reactHookForm/numbers/RangeInput.js";
|
|
4
|
+
import * as yup from "yup";
|
|
5
|
+
function getCriteriaBasedSchema(extraFields = {}) {
|
|
6
|
+
return {
|
|
7
|
+
[FieldConstants.CRITERIA_BASED]: yup.object().shape({
|
|
8
|
+
[FieldConstants.COUNTRIES]: yup.array().of(yup.string().required()),
|
|
9
|
+
[FieldConstants.COUNTRIES_1]: yup.array().of(yup.string().required()),
|
|
10
|
+
[FieldConstants.COUNTRIES_2]: yup.array().of(yup.string().required()),
|
|
11
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE),
|
|
12
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_1),
|
|
13
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_2),
|
|
14
|
+
...getRangeInputSchema(FieldConstants.NOMINAL_VOLTAGE_3),
|
|
15
|
+
...extraFields
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function getCriteriaBasedFormData(criteriaValues, extraFields = {}) {
|
|
20
|
+
return {
|
|
21
|
+
[FieldConstants.CRITERIA_BASED]: {
|
|
22
|
+
[FieldConstants.COUNTRIES]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES]) ?? [],
|
|
23
|
+
[FieldConstants.COUNTRIES_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_1]) ?? [],
|
|
24
|
+
[FieldConstants.COUNTRIES_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.COUNTRIES_2]) ?? [],
|
|
25
|
+
[FieldConstants.NOMINAL_VOLTAGE]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE]) ?? DEFAULT_RANGE_VALUE,
|
|
26
|
+
[FieldConstants.NOMINAL_VOLTAGE_1]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_1]) ?? DEFAULT_RANGE_VALUE,
|
|
27
|
+
[FieldConstants.NOMINAL_VOLTAGE_2]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_2]) ?? DEFAULT_RANGE_VALUE,
|
|
28
|
+
[FieldConstants.NOMINAL_VOLTAGE_3]: (criteriaValues == null ? void 0 : criteriaValues[FieldConstants.NOMINAL_VOLTAGE_3]) ?? DEFAULT_RANGE_VALUE,
|
|
29
|
+
...extraFields
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
getCriteriaBasedFormData,
|
|
35
|
+
getCriteriaBasedSchema
|
|
36
|
+
};
|
|
@@ -4,10 +4,5 @@
|
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
|
-
export * from './CriteriaBasedFilterEditionDialog';
|
|
8
|
-
export * from './CriteriaBasedFilterForm';
|
|
9
7
|
export * from './CriteriaBasedForm';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './FilterProperties';
|
|
12
|
-
export * from './FilterProperty';
|
|
13
|
-
export * from './criteriaBasedFilterUtils';
|
|
8
|
+
export * from './criteriaBasedUtils';
|
|
@@ -2,10 +2,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
4
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
5
|
-
import { saveExplicitNamingFilter,
|
|
5
|
+
import { saveExplicitNamingFilter, saveExpertFilter } from "./utils/filterApi.js";
|
|
6
6
|
import { useSnackMessage } from "../../hooks/useSnackMessage.js";
|
|
7
7
|
import { CustomMuiDialog } from "../dialogs/customMuiDialog/CustomMuiDialog.js";
|
|
8
|
-
import { criteriaBasedFilterEmptyFormData, criteriaBasedFilterSchema } from "./criteriaBased/CriteriaBasedFilterForm.js";
|
|
9
8
|
import { getExplicitNamingFilterEmptyFormData, explicitNamingFilterSchema, FILTER_EQUIPMENTS_ATTRIBUTES } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
10
9
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
11
10
|
import "../../utils/yupConfig.js";
|
|
@@ -18,7 +17,6 @@ const emptyFormData = {
|
|
|
18
17
|
[FieldConstants.DESCRIPTION]: "",
|
|
19
18
|
[FieldConstants.FILTER_TYPE]: FilterType.EXPERT.id,
|
|
20
19
|
[FieldConstants.EQUIPMENT_TYPE]: null,
|
|
21
|
-
...criteriaBasedFilterEmptyFormData,
|
|
22
20
|
...getExplicitNamingFilterEmptyFormData(),
|
|
23
21
|
...getExpertFilterEmptyFormData()
|
|
24
22
|
};
|
|
@@ -27,7 +25,6 @@ const formSchema = yup.object().shape({
|
|
|
27
25
|
[FieldConstants.DESCRIPTION]: yup.string().max(500, "descriptionLimitError"),
|
|
28
26
|
[FieldConstants.FILTER_TYPE]: yup.string().required(),
|
|
29
27
|
[FieldConstants.EQUIPMENT_TYPE]: yup.string().required(),
|
|
30
|
-
...criteriaBasedFilterSchema,
|
|
31
28
|
...explicitNamingFilterSchema,
|
|
32
29
|
...expertFilterSchema
|
|
33
30
|
}).required();
|
|
@@ -68,12 +65,6 @@ function FilterCreationDialog({
|
|
|
68
65
|
onClose,
|
|
69
66
|
activeDirectory
|
|
70
67
|
);
|
|
71
|
-
} else if (filterForm[FieldConstants.FILTER_TYPE] === FilterType.CRITERIA_BASED.id) {
|
|
72
|
-
saveCriteriaBasedFilter(filterForm, activeDirectory, onClose, (error) => {
|
|
73
|
-
snackError({
|
|
74
|
-
messageTxt: error
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
68
|
} else if (filterForm[FieldConstants.FILTER_TYPE] === FilterType.EXPERT.id) {
|
|
78
69
|
saveExpertFilter(
|
|
79
70
|
null,
|
|
@@ -4,7 +4,6 @@ import { useFormContext, useWatch } from "react-hook-form";
|
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
import { HeaderFilterForm } from "./HeaderFilterForm.js";
|
|
6
6
|
import { FieldConstants } from "../../utils/constants/fieldConstants.js";
|
|
7
|
-
import { CriteriaBasedFilterForm } from "./criteriaBased/CriteriaBasedFilterForm.js";
|
|
8
7
|
import { ExplicitNamingFilterForm } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
9
8
|
import { ExpertFilterForm } from "./expert/ExpertFilterForm.js";
|
|
10
9
|
import { FilterType } from "./constants/FilterConstants.js";
|
|
@@ -47,7 +46,6 @@ function FilterForm({
|
|
|
47
46
|
handleFilterTypeChange
|
|
48
47
|
}
|
|
49
48
|
) }),
|
|
50
|
-
filterType === FilterType.CRITERIA_BASED.id && /* @__PURE__ */ jsx(CriteriaBasedFilterForm, {}),
|
|
51
49
|
filterType === FilterType.EXPLICIT_NAMING.id && /* @__PURE__ */ jsx(
|
|
52
50
|
ExplicitNamingFilterForm,
|
|
53
51
|
{
|
|
@@ -2,10 +2,6 @@ import { ItemSelectionForCopy } from '../filter.type';
|
|
|
2
2
|
|
|
3
3
|
export declare const DISTRIBUTION_KEY = "distributionKey";
|
|
4
4
|
export declare const FilterType: {
|
|
5
|
-
CRITERIA_BASED: {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
};
|
|
9
5
|
EXPLICIT_NAMING: {
|
|
10
6
|
id: string;
|
|
11
7
|
label: string;
|
|
@@ -8,7 +8,7 @@ export * from './filter.type';
|
|
|
8
8
|
export * from './FilterCreationDialog';
|
|
9
9
|
export * from './FilterForm';
|
|
10
10
|
export * from './constants/FilterConstants';
|
|
11
|
-
export * from '
|
|
11
|
+
export * from '../contingencyList/criteriaBased';
|
|
12
12
|
export * from './expert';
|
|
13
13
|
export * from './explicitNaming';
|
|
14
14
|
export * from './utils';
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { FilterCreationDialog } from "./FilterCreationDialog.js";
|
|
2
2
|
import { FilterForm } from "./FilterForm.js";
|
|
3
3
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./constants/FilterConstants.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { CriteriaBasedForm } from "./criteriaBased/CriteriaBasedForm.js";
|
|
7
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./criteriaBased/FilterFreeProperties.js";
|
|
8
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./criteriaBased/FilterProperties.js";
|
|
9
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./criteriaBased/FilterProperty.js";
|
|
10
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./criteriaBased/criteriaBasedFilterUtils.js";
|
|
4
|
+
import { CriteriaBasedForm } from "../contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
5
|
+
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "../contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
11
6
|
import { ExpertFilterEditionDialog } from "./expert/ExpertFilterEditionDialog.js";
|
|
12
7
|
import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./expert/ExpertFilterForm.js";
|
|
13
8
|
import { CombinatorType, DataType, FieldType, OperatorType } from "./expert/expertFilter.type.js";
|
|
@@ -15,15 +10,13 @@ import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXP
|
|
|
15
10
|
import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./expert/expertFilterUtils.js";
|
|
16
11
|
import { ExplicitNamingFilterEditionDialog } from "./explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
17
12
|
import { ExplicitNamingFilterForm, FILTER_EQUIPMENTS_ATTRIBUTES, explicitNamingFilterSchema, getExplicitNamingFilterEmptyFormData } from "./explicitNaming/ExplicitNamingFilterForm.js";
|
|
18
|
-
import {
|
|
13
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./utils/filterApi.js";
|
|
19
14
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./utils/filterFormUtils.js";
|
|
20
15
|
export {
|
|
21
16
|
COMBINATOR_OPTIONS,
|
|
22
17
|
CONTINGENCY_LIST_EQUIPMENTS,
|
|
23
18
|
CONVERTERS_MODE_OPTIONS,
|
|
24
19
|
CombinatorType,
|
|
25
|
-
CriteriaBasedFilterEditionDialog,
|
|
26
|
-
CriteriaBasedFilterForm,
|
|
27
20
|
CriteriaBasedForm,
|
|
28
21
|
DISTRIBUTION_KEY,
|
|
29
22
|
DataType,
|
|
@@ -41,34 +34,21 @@ export {
|
|
|
41
34
|
FieldType,
|
|
42
35
|
FilterCreationDialog,
|
|
43
36
|
FilterForm,
|
|
44
|
-
FilterFreeProperties,
|
|
45
|
-
FilterProperties,
|
|
46
|
-
FilterProperty,
|
|
47
37
|
FilterType,
|
|
48
|
-
FreePropertiesTypes,
|
|
49
38
|
LOAD_TYPE_OPTIONS,
|
|
50
39
|
NO_ITEM_SELECTION_FOR_COPY,
|
|
51
40
|
OPERATOR_OPTIONS,
|
|
52
41
|
OperatorType,
|
|
53
42
|
PHASE_REGULATION_MODE_OPTIONS,
|
|
54
|
-
PROPERTY_NAME,
|
|
55
|
-
PROPERTY_VALUES,
|
|
56
|
-
PROPERTY_VALUES_1,
|
|
57
|
-
PROPERTY_VALUES_2,
|
|
58
43
|
RATIO_REGULATION_MODE_OPTIONS,
|
|
59
44
|
REGULATION_TYPE_OPTIONS,
|
|
60
45
|
RULES,
|
|
61
46
|
SHUNT_COMPENSATOR_TYPE_OPTIONS,
|
|
62
47
|
SVAR_REGULATION_MODE_OPTIONS,
|
|
63
|
-
backToFrontTweak,
|
|
64
48
|
countRules,
|
|
65
|
-
criteriaBasedFilterEmptyFormData,
|
|
66
|
-
criteriaBasedFilterSchema,
|
|
67
49
|
expertFilterSchema,
|
|
68
50
|
explicitNamingFilterSchema,
|
|
69
51
|
exportExpertRules,
|
|
70
|
-
filterPropertiesYupSchema,
|
|
71
|
-
frontToBackTweak,
|
|
72
52
|
getCriteriaBasedFormData,
|
|
73
53
|
getCriteriaBasedSchema,
|
|
74
54
|
getExpertFilterEmptyFormData,
|
|
@@ -79,7 +59,6 @@ export {
|
|
|
79
59
|
queryValidator,
|
|
80
60
|
recursiveRemove,
|
|
81
61
|
rqbQuerySchemaValidator,
|
|
82
|
-
saveCriteriaBasedFilter,
|
|
83
62
|
saveExpertFilter,
|
|
84
63
|
saveExplicitNamingFilter,
|
|
85
64
|
testQuery
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UUID } from 'crypto';
|
|
2
2
|
|
|
3
3
|
export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value?: string) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
|
|
4
|
-
export declare const saveCriteriaBasedFilter: (filter: any, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
|
5
4
|
export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: any, onClose: () => void, onError: (message: string) => void, token?: string) => void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FieldConstants } from "../../../utils/constants/fieldConstants.js";
|
|
2
|
-
import { frontToBackTweak } from "../criteriaBased/criteriaBasedFilterUtils.js";
|
|
3
2
|
import { Generator, Load } from "../../../utils/types/equipmentTypes.js";
|
|
4
3
|
import { exportExpertRules } from "../expert/expertFilterUtils.js";
|
|
5
4
|
import { DISTRIBUTION_KEY, FilterType } from "../constants/FilterConstants.js";
|
|
@@ -50,14 +49,6 @@ const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType,
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
};
|
|
53
|
-
const saveCriteriaBasedFilter = (filter, activeDirectory, onClose, onError, token) => {
|
|
54
|
-
const filterForBack = frontToBackTweak(void 0, filter);
|
|
55
|
-
createFilter(filterForBack, filter[FieldConstants.NAME], filter[FieldConstants.DESCRIPTION], activeDirectory, token).then(() => {
|
|
56
|
-
onClose();
|
|
57
|
-
}).catch((error) => {
|
|
58
|
-
onError(error.message);
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
52
|
const saveExpertFilter = (id, query, equipmentType, name, description, isFilterCreation, activeDirectory, onClose, onError, token) => {
|
|
62
53
|
if (isFilterCreation) {
|
|
63
54
|
createFilter(
|
|
@@ -93,7 +84,6 @@ const saveExpertFilter = (id, query, equipmentType, name, description, isFilterC
|
|
|
93
84
|
}
|
|
94
85
|
};
|
|
95
86
|
export {
|
|
96
|
-
saveCriteriaBasedFilter,
|
|
97
87
|
saveExpertFilter,
|
|
98
88
|
saveExplicitNamingFilter
|
|
99
89
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./filterApi.js";
|
|
2
2
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./filterFormUtils.js";
|
|
3
3
|
export {
|
|
4
4
|
CONTINGENCY_LIST_EQUIPMENTS,
|
|
5
5
|
FILTER_EQUIPMENTS,
|
|
6
|
-
saveCriteriaBasedFilter,
|
|
7
6
|
saveExpertFilter,
|
|
8
7
|
saveExplicitNamingFilter
|
|
9
8
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -26,13 +26,8 @@ import { TagRenderer } from "./elementSearch/tagRenderer/TagRenderer.js";
|
|
|
26
26
|
import { FilterCreationDialog } from "./filter/FilterCreationDialog.js";
|
|
27
27
|
import { FilterForm } from "./filter/FilterForm.js";
|
|
28
28
|
import { DISTRIBUTION_KEY, FilterType, NO_ITEM_SELECTION_FOR_COPY } from "./filter/constants/FilterConstants.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import { CriteriaBasedForm } from "./filter/criteriaBased/CriteriaBasedForm.js";
|
|
32
|
-
import { FilterFreeProperties, FreePropertiesTypes } from "./filter/criteriaBased/FilterFreeProperties.js";
|
|
33
|
-
import { FilterProperties, filterPropertiesYupSchema } from "./filter/criteriaBased/FilterProperties.js";
|
|
34
|
-
import { FilterProperty, PROPERTY_NAME, PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2 } from "./filter/criteriaBased/FilterProperty.js";
|
|
35
|
-
import { backToFrontTweak, frontToBackTweak, getCriteriaBasedFormData, getCriteriaBasedSchema } from "./filter/criteriaBased/criteriaBasedFilterUtils.js";
|
|
29
|
+
import { CriteriaBasedForm } from "./contingencyList/criteriaBased/CriteriaBasedForm.js";
|
|
30
|
+
import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./contingencyList/criteriaBased/criteriaBasedUtils.js";
|
|
36
31
|
import { ExpertFilterEditionDialog } from "./filter/expert/ExpertFilterEditionDialog.js";
|
|
37
32
|
import { EXPERT_FILTER_QUERY, ExpertFilterForm, expertFilterSchema, getExpertFilterEmptyFormData, rqbQuerySchemaValidator } from "./filter/expert/ExpertFilterForm.js";
|
|
38
33
|
import { CombinatorType, DataType, FieldType, OperatorType } from "./filter/expert/expertFilter.type.js";
|
|
@@ -40,7 +35,7 @@ import { COMBINATOR_OPTIONS, CONVERTERS_MODE_OPTIONS, ENERGY_SOURCE_OPTIONS, EXP
|
|
|
40
35
|
import { countRules, exportExpertRules, getNumberOfSiblings, getOperators, importExpertRules, queryValidator, recursiveRemove, testQuery } from "./filter/expert/expertFilterUtils.js";
|
|
41
36
|
import { ExplicitNamingFilterEditionDialog } from "./filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
|
|
42
37
|
import { ExplicitNamingFilterForm, FILTER_EQUIPMENTS_ATTRIBUTES, explicitNamingFilterSchema, getExplicitNamingFilterEmptyFormData } from "./filter/explicitNaming/ExplicitNamingFilterForm.js";
|
|
43
|
-
import {
|
|
38
|
+
import { saveExpertFilter, saveExplicitNamingFilter } from "./filter/utils/filterApi.js";
|
|
44
39
|
import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./filter/utils/filterFormUtils.js";
|
|
45
40
|
import { FlatParameters, extractDefault } from "./flatParameters/FlatParameters.js";
|
|
46
41
|
import { SelectClearable } from "./inputs/SelectClearable.js";
|
|
@@ -104,6 +99,10 @@ import { TopBar } from "./topBar/TopBar.js";
|
|
|
104
99
|
import { GridLogo, LogoText } from "./topBar/GridLogo.js";
|
|
105
100
|
import { AboutDialog } from "./topBar/AboutDialog.js";
|
|
106
101
|
import { TreeViewFinder, generateTreeViewFinderClass } from "./treeViewFinder/TreeViewFinder.js";
|
|
102
|
+
import { NotificationsProvider } from "./notifications/NotificationsProvider.js";
|
|
103
|
+
import { NotificationsContext } from "./notifications/contexts/NotificationsContext.js";
|
|
104
|
+
import { useNotificationsListener } from "./notifications/hooks/useNotificationsListener.js";
|
|
105
|
+
import { useListenerManager } from "./notifications/hooks/useListenerManager.js";
|
|
107
106
|
export {
|
|
108
107
|
AboutDialog,
|
|
109
108
|
AddButton,
|
|
@@ -126,8 +125,6 @@ export {
|
|
|
126
125
|
CombinatorType,
|
|
127
126
|
CountriesInput,
|
|
128
127
|
CountryValueEditor,
|
|
129
|
-
CriteriaBasedFilterEditionDialog,
|
|
130
|
-
CriteriaBasedFilterForm,
|
|
131
128
|
CriteriaBasedForm,
|
|
132
129
|
CsvUploader,
|
|
133
130
|
CustomAGGrid,
|
|
@@ -170,13 +167,9 @@ export {
|
|
|
170
167
|
FieldType,
|
|
171
168
|
FilterCreationDialog,
|
|
172
169
|
FilterForm,
|
|
173
|
-
FilterFreeProperties,
|
|
174
|
-
FilterProperties,
|
|
175
|
-
FilterProperty,
|
|
176
170
|
FilterType,
|
|
177
171
|
FlatParameters,
|
|
178
172
|
FloatInput,
|
|
179
|
-
FreePropertiesTypes,
|
|
180
173
|
GridLogo,
|
|
181
174
|
GroupValueEditor,
|
|
182
175
|
InputWithPopupConfirmation,
|
|
@@ -194,15 +187,13 @@ export {
|
|
|
194
187
|
MultipleSelectionDialog,
|
|
195
188
|
NAME,
|
|
196
189
|
NO_ITEM_SELECTION_FOR_COPY,
|
|
190
|
+
NotificationsContext,
|
|
191
|
+
NotificationsProvider,
|
|
197
192
|
NumericEditor,
|
|
198
193
|
OPERATOR_OPTIONS,
|
|
199
194
|
OperatorType,
|
|
200
195
|
OverflowableText,
|
|
201
196
|
PHASE_REGULATION_MODE_OPTIONS,
|
|
202
|
-
PROPERTY_NAME,
|
|
203
|
-
PROPERTY_VALUES,
|
|
204
|
-
PROPERTY_VALUES_1,
|
|
205
|
-
PROPERTY_VALUES_2,
|
|
206
197
|
PopupConfirmationDialog,
|
|
207
198
|
PropertyValueEditor,
|
|
208
199
|
RATIO_REGULATION_MODE_OPTIONS,
|
|
@@ -237,19 +228,14 @@ export {
|
|
|
237
228
|
UserManagerMock,
|
|
238
229
|
ValueEditor,
|
|
239
230
|
ValueSelector,
|
|
240
|
-
backToFrontTweak,
|
|
241
231
|
collectibleHelper,
|
|
242
232
|
countRules,
|
|
243
|
-
criteriaBasedFilterEmptyFormData,
|
|
244
|
-
criteriaBasedFilterSchema,
|
|
245
233
|
dispatchUser,
|
|
246
234
|
expertFilterSchema,
|
|
247
235
|
explicitNamingFilterSchema,
|
|
248
236
|
exportExpertRules,
|
|
249
237
|
extractDefault,
|
|
250
|
-
filterPropertiesYupSchema,
|
|
251
238
|
forTesting,
|
|
252
|
-
frontToBackTweak,
|
|
253
239
|
genHelperError,
|
|
254
240
|
genHelperPreviousValue,
|
|
255
241
|
generateMuiVirtualizedTableClass,
|
|
@@ -279,7 +265,6 @@ export {
|
|
|
279
265
|
queryValidator,
|
|
280
266
|
recursiveRemove,
|
|
281
267
|
rqbQuerySchemaValidator,
|
|
282
|
-
saveCriteriaBasedFilter,
|
|
283
268
|
saveExpertFilter,
|
|
284
269
|
saveExplicitNamingFilter,
|
|
285
270
|
styles,
|
|
@@ -289,5 +274,7 @@ export {
|
|
|
289
274
|
useConvertValue,
|
|
290
275
|
useCustomFormContext,
|
|
291
276
|
useElementSearch,
|
|
277
|
+
useListenerManager,
|
|
278
|
+
useNotificationsListener,
|
|
292
279
|
useValid
|
|
293
280
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export type NotificationsProviderProps = {
|
|
4
|
+
urls: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export declare function NotificationsProvider({ urls, children }: PropsWithChildren<NotificationsProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
4
|
+
import { NotificationsContext } from "./contexts/NotificationsContext.js";
|
|
5
|
+
import { useListenerManager } from "./hooks/useListenerManager.js";
|
|
6
|
+
const DELAY_BEFORE_WEBSOCKET_CONNECTED = 12e3;
|
|
7
|
+
function NotificationsProvider({ urls, children }) {
|
|
8
|
+
const {
|
|
9
|
+
broadcast: broadcastMessage,
|
|
10
|
+
addListener: addListenerMessage,
|
|
11
|
+
removeListener: removeListenerMessage
|
|
12
|
+
} = useListenerManager(urls);
|
|
13
|
+
const {
|
|
14
|
+
broadcast: broadcastOnReopen,
|
|
15
|
+
addListener: addListenerOnReopen,
|
|
16
|
+
removeListener: removeListenerOnReopen
|
|
17
|
+
} = useListenerManager(urls);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const connections = Object.keys(urls).filter((u) => urls[u] != null).map((urlKey) => {
|
|
20
|
+
const rws = new ReconnectingWebSocket(() => urls[urlKey], [], {
|
|
21
|
+
// this option set the minimum duration being connected before reset the retry count to 0
|
|
22
|
+
minUptime: DELAY_BEFORE_WEBSOCKET_CONNECTED
|
|
23
|
+
});
|
|
24
|
+
rws.onmessage = broadcastMessage(urlKey);
|
|
25
|
+
rws.onclose = (event) => {
|
|
26
|
+
console.error(`Unexpected ${urlKey} Notification WebSocket closed`, event);
|
|
27
|
+
};
|
|
28
|
+
rws.onerror = (event) => {
|
|
29
|
+
console.error(`Unexpected ${urlKey} Notification WebSocket error`, event);
|
|
30
|
+
};
|
|
31
|
+
rws.onopen = () => {
|
|
32
|
+
console.info(`${urlKey} Notification Websocket connected`);
|
|
33
|
+
broadcastOnReopen(urlKey);
|
|
34
|
+
};
|
|
35
|
+
return rws;
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
connections.forEach((c) => c.close());
|
|
39
|
+
};
|
|
40
|
+
}, [broadcastMessage, broadcastOnReopen, urls]);
|
|
41
|
+
const contextValue = useMemo(
|
|
42
|
+
() => ({
|
|
43
|
+
addListenerEvent: addListenerMessage,
|
|
44
|
+
removeListenerEvent: removeListenerMessage,
|
|
45
|
+
addListenerOnReopen,
|
|
46
|
+
removeListenerOnReopen
|
|
47
|
+
}),
|
|
48
|
+
[addListenerMessage, removeListenerMessage, addListenerOnReopen, removeListenerOnReopen]
|
|
49
|
+
);
|
|
50
|
+
return /* @__PURE__ */ jsx(NotificationsContext.Provider, { value: contextValue, children });
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
NotificationsProvider
|
|
54
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
export type ListenerEventWS = {
|
|
9
|
+
id: string;
|
|
10
|
+
callback: (event: MessageEvent) => void;
|
|
11
|
+
};
|
|
12
|
+
export type ListenerOnReopen = {
|
|
13
|
+
id: string;
|
|
14
|
+
callback: () => void;
|
|
15
|
+
};
|
|
16
|
+
export type NotificationsContextType = {
|
|
17
|
+
addListenerEvent: (urlKey: string, l: ListenerEventWS) => void;
|
|
18
|
+
removeListenerEvent: (urlKey: string, idListener: string) => void;
|
|
19
|
+
addListenerOnReopen: (urlKey: string, l: ListenerOnReopen) => void;
|
|
20
|
+
removeListenerOnReopen: (urlKey: string, idListener: string) => void;
|
|
21
|
+
};
|
|
22
|
+
export type NotificationsContextRecordType = Record<string, NotificationsContextType>;
|
|
23
|
+
export declare const NotificationsContext: import('react').Context<NotificationsContextType>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
const NotificationsContext = createContext({
|
|
3
|
+
addListenerEvent: () => {
|
|
4
|
+
},
|
|
5
|
+
removeListenerEvent: () => {
|
|
6
|
+
},
|
|
7
|
+
addListenerOnReopen: () => {
|
|
8
|
+
},
|
|
9
|
+
removeListenerOnReopen: () => {
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
NotificationsContext
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ListenerEventWS, ListenerOnReopen } from '../contexts/NotificationsContext';
|
|
2
|
+
|
|
3
|
+
export declare const useListenerManager: <TListener extends ListenerEventWS | ListenerOnReopen, TMessage extends MessageEvent<any>>(urls: Record<string, string>) => {
|
|
4
|
+
addListener: (urlKey: string, listener: TListener) => void;
|
|
5
|
+
removeListener: (urlKey: string, id: string) => void;
|
|
6
|
+
broadcast: (urlKey: string) => (event: TMessage) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
2
|
+
const useListenerManager = (urls) => {
|
|
3
|
+
const urlsListenersRef = useRef({});
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
urlsListenersRef.current = Object.keys(urls).reduce((acc, urlKey) => {
|
|
6
|
+
acc[urlKey] = urlsListenersRef.current[urlKey] ?? [];
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
}, [urls]);
|
|
10
|
+
const addListenerEvent = useCallback((urlKey, listener) => {
|
|
11
|
+
const urlsListeners = urlsListenersRef.current;
|
|
12
|
+
if (urlKey in urlsListeners) {
|
|
13
|
+
urlsListeners[urlKey].push(listener);
|
|
14
|
+
} else {
|
|
15
|
+
urlsListeners[urlKey] = [listener];
|
|
16
|
+
}
|
|
17
|
+
urlsListenersRef.current = urlsListeners;
|
|
18
|
+
}, []);
|
|
19
|
+
const removeListenerEvent = useCallback((urlKey, id) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const listeners = (_a = urlsListenersRef.current) == null ? void 0 : _a[urlKey];
|
|
22
|
+
if (listeners) {
|
|
23
|
+
const newListerners = listeners.filter((l) => l.id !== id);
|
|
24
|
+
urlsListenersRef.current = {
|
|
25
|
+
...urlsListenersRef.current,
|
|
26
|
+
[urlKey]: newListerners
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
const broadcast = useCallback(
|
|
31
|
+
(urlKey) => (event) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const listeners = (_a = urlsListenersRef.current) == null ? void 0 : _a[urlKey];
|
|
34
|
+
if (listeners) {
|
|
35
|
+
listeners.forEach(({ callback }) => {
|
|
36
|
+
callback(event);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[]
|
|
41
|
+
);
|
|
42
|
+
return {
|
|
43
|
+
addListener: addListenerEvent,
|
|
44
|
+
removeListener: removeListenerEvent,
|
|
45
|
+
broadcast
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
useListenerManager
|
|
50
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useNotificationsListener: (listenerKey: string, { listenerCallbackMessage, listenerCallbackOnReopen, propsId, }: {
|
|
8
|
+
listenerCallbackMessage?: ((event: MessageEvent<any>) => void) | undefined;
|
|
9
|
+
listenerCallbackOnReopen?: (() => void) | undefined;
|
|
10
|
+
propsId?: string | undefined;
|
|
11
|
+
}) => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useContext, useEffect } from "react";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
import { NotificationsContext } from "../contexts/NotificationsContext.js";
|
|
4
|
+
const useNotificationsListener = (listenerKey, {
|
|
5
|
+
listenerCallbackMessage,
|
|
6
|
+
listenerCallbackOnReopen,
|
|
7
|
+
propsId
|
|
8
|
+
}) => {
|
|
9
|
+
const { addListenerEvent, removeListenerEvent, addListenerOnReopen, removeListenerOnReopen } = useContext(NotificationsContext);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const id = propsId ?? v4();
|
|
12
|
+
if (listenerCallbackMessage) {
|
|
13
|
+
addListenerEvent(listenerKey, {
|
|
14
|
+
id,
|
|
15
|
+
callback: listenerCallbackMessage
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return () => removeListenerEvent(listenerKey, id);
|
|
19
|
+
}, [addListenerEvent, removeListenerEvent, listenerKey, listenerCallbackMessage, propsId]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const id = propsId ?? v4();
|
|
22
|
+
if (listenerCallbackOnReopen) {
|
|
23
|
+
addListenerOnReopen(listenerKey, {
|
|
24
|
+
id,
|
|
25
|
+
callback: listenerCallbackOnReopen
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return () => removeListenerOnReopen(listenerKey, id);
|
|
29
|
+
}, [addListenerOnReopen, removeListenerOnReopen, listenerKey, listenerCallbackOnReopen, propsId]);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
useNotificationsListener
|
|
33
|
+
};
|