@evergis/react 4.0.7 → 4.0.8
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/Dashboard/hooks/useDataSources.d.ts +1 -1
- package/dist/index.js +54 -24
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +54 -24
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -3948,6 +3948,9 @@ const useFetchWithAuth = (url, transform, cleanup) => {
|
|
|
3948
3948
|
})
|
|
3949
3949
|
.then(res => (res.ok ? transformRef.current(res) : null))
|
|
3950
3950
|
.then(setData)
|
|
3951
|
+
.catch(() => {
|
|
3952
|
+
setData(null);
|
|
3953
|
+
})
|
|
3951
3954
|
.finally(() => {
|
|
3952
3955
|
loadingRef.current = false;
|
|
3953
3956
|
});
|
|
@@ -4400,13 +4403,13 @@ const applyQueryFilters = ({ parameters: configParameters, filters: configFilter
|
|
|
4400
4403
|
if (configParameters[key].endsWith(".max")) {
|
|
4401
4404
|
return {
|
|
4402
4405
|
...result,
|
|
4403
|
-
[key]: selectedFilters?.[filterName]?.max ?? defaultValue,
|
|
4406
|
+
[key]: selectedFilters?.[filterName]?.max ?? (Array.isArray(defaultValue) ? defaultValue[1] : defaultValue),
|
|
4404
4407
|
};
|
|
4405
4408
|
}
|
|
4406
4409
|
if (configParameters[key].endsWith(".min")) {
|
|
4407
4410
|
return {
|
|
4408
4411
|
...result,
|
|
4409
|
-
[key]: selectedFilters?.[filterName]?.min ?? defaultValue,
|
|
4412
|
+
[key]: selectedFilters?.[filterName]?.min ?? (Array.isArray(defaultValue) ? defaultValue[0] : defaultValue),
|
|
4410
4413
|
};
|
|
4411
4414
|
}
|
|
4412
4415
|
if (configParameters[key].includes(".")) {
|
|
@@ -10703,12 +10706,13 @@ const useDashboardHeader = () => {
|
|
|
10703
10706
|
};
|
|
10704
10707
|
};
|
|
10705
10708
|
|
|
10709
|
+
/* eslint-disable max-lines */
|
|
10706
10710
|
const useDataSources = ({ type: widgetType, config, attributes, filters, layerParams, eqlParameters, }) => {
|
|
10707
10711
|
const { ewktGeometry, api } = useGlobalContext();
|
|
10708
10712
|
const { dataSources } = useWidgetContext(widgetType);
|
|
10709
10713
|
const { filters: configFilters, dataSources: configDataSources } = config || {};
|
|
10710
10714
|
const prevFilters = useRef({});
|
|
10711
|
-
const getDataSourcePromises = useCallback(async ({ ds, query, parameters, layerName, limit, condition, url, resourceId, fileName, methodName }, newFilters, offset = 0) => {
|
|
10715
|
+
const getDataSourcePromises = useCallback(async ({ ds, query, parameters, layerName, limit, condition, url, resourceId, fileName, methodName, }, newFilters, offset = 0) => {
|
|
10712
10716
|
const selectedFilters = {
|
|
10713
10717
|
...(filters || {}),
|
|
10714
10718
|
...(newFilters || {}),
|
|
@@ -10723,7 +10727,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10723
10727
|
parameters,
|
|
10724
10728
|
...(fileName && { fileName }),
|
|
10725
10729
|
...(methodName && { methodName }),
|
|
10726
|
-
}
|
|
10730
|
+
},
|
|
10727
10731
|
});
|
|
10728
10732
|
if (response.error) {
|
|
10729
10733
|
throw new Error(response.error.message);
|
|
@@ -10738,19 +10742,27 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10738
10742
|
geometry: ewktGeometry,
|
|
10739
10743
|
});
|
|
10740
10744
|
if (url) {
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10745
|
+
try {
|
|
10746
|
+
const response = await fetch(url, {
|
|
10747
|
+
method: "POST",
|
|
10748
|
+
headers: {
|
|
10749
|
+
Accept: "application/json",
|
|
10750
|
+
"Content-Type": "application/json",
|
|
10751
|
+
},
|
|
10752
|
+
body: JSON.stringify(newParams),
|
|
10753
|
+
});
|
|
10754
|
+
if (!response.ok) {
|
|
10755
|
+
throw new Error(`HTTP error: ${response.status}`);
|
|
10756
|
+
}
|
|
10757
|
+
const json = await response.json();
|
|
10758
|
+
return {
|
|
10759
|
+
items: json.result.items,
|
|
10760
|
+
attributeDefinition: json.result.attributeDefinition,
|
|
10761
|
+
};
|
|
10762
|
+
}
|
|
10763
|
+
catch (error) {
|
|
10764
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
10765
|
+
}
|
|
10754
10766
|
}
|
|
10755
10767
|
if (!layerName) {
|
|
10756
10768
|
const getProps = {
|
|
@@ -10786,11 +10798,23 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10786
10798
|
]
|
|
10787
10799
|
: [condition, query].filter(Boolean),
|
|
10788
10800
|
});
|
|
10789
|
-
}, [
|
|
10801
|
+
}, [
|
|
10802
|
+
filters,
|
|
10803
|
+
dataSources,
|
|
10804
|
+
configFilters,
|
|
10805
|
+
ewktGeometry,
|
|
10806
|
+
api.layers,
|
|
10807
|
+
api.remoteTaskManager,
|
|
10808
|
+
api.eql,
|
|
10809
|
+
attributes,
|
|
10810
|
+
layerParams,
|
|
10811
|
+
eqlParameters,
|
|
10812
|
+
]);
|
|
10790
10813
|
const getUpdatingDataSources = useCallback(() => {
|
|
10791
10814
|
const diffFilterNames = filters
|
|
10792
10815
|
? Object.keys(filters).filter(key => Array.isArray(filters[key].value)
|
|
10793
|
-
? filters[key].value.length !==
|
|
10816
|
+
? filters[key].value.length !==
|
|
10817
|
+
prevFilters.current[key]?.value?.length ||
|
|
10794
10818
|
filters[key].value.some((item, index) => item !== prevFilters.current[key]?.value?.[index])
|
|
10795
10819
|
: filters[key].value !== prevFilters.current[key]?.value)
|
|
10796
10820
|
: [];
|
|
@@ -10813,7 +10837,8 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10813
10837
|
newDataSources[index].layerName = currentDataSources[index].layerName;
|
|
10814
10838
|
const items = response.status === "rejected"
|
|
10815
10839
|
? null
|
|
10816
|
-
: response.value?.features ||
|
|
10840
|
+
: response.value?.features ||
|
|
10841
|
+
response.value?.items;
|
|
10817
10842
|
newDataSources[index].features =
|
|
10818
10843
|
response.status === "rejected"
|
|
10819
10844
|
? null
|
|
@@ -10825,13 +10850,18 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10825
10850
|
}))
|
|
10826
10851
|
: items;
|
|
10827
10852
|
newDataSources[index].attributeDefinition =
|
|
10828
|
-
response.status === "rejected" ||
|
|
10853
|
+
response.status === "rejected" ||
|
|
10854
|
+
(!isQueryDataSource && !isPythonDataSource)
|
|
10829
10855
|
? null
|
|
10830
|
-
: response.value
|
|
10856
|
+
: response.value
|
|
10857
|
+
?.attributeDefinition ||
|
|
10831
10858
|
(isPythonDataSource && items?.[0]?.properties
|
|
10832
10859
|
? Object.fromEntries(Object.entries(items[0].properties).map(([key, val]) => [
|
|
10833
10860
|
key,
|
|
10834
|
-
{
|
|
10861
|
+
{
|
|
10862
|
+
type: typeof val === "number" ? "Float" : "String",
|
|
10863
|
+
isDisplayed: true,
|
|
10864
|
+
},
|
|
10835
10865
|
]))
|
|
10836
10866
|
: null);
|
|
10837
10867
|
});
|
|
@@ -10857,7 +10887,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
10857
10887
|
position: bbox.center,
|
|
10858
10888
|
resolution: map.getAdjustedResolution(resolution),
|
|
10859
10889
|
});*/
|
|
10860
|
-
}, []);
|
|
10890
|
+
}, [api.layers]);
|
|
10861
10891
|
return {
|
|
10862
10892
|
getDataSourcePromises,
|
|
10863
10893
|
getUpdatingDataSources,
|