@evergis/react 4.0.112 → 4.0.114
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/constants.d.ts +1 -0
- package/dist/components/Dashboard/types.d.ts +4 -3
- package/dist/components/Dashboard/utils/fetchQueryDescription.d.ts +8 -0
- package/dist/components/Dashboard/utils/index.d.ts +1 -1
- package/dist/index.js +50 -26
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +49 -27
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/format.d.ts +9 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +2 -2
- /package/dist/{components/Dashboard/utils → utils}/roundTotalSum.d.ts +0 -0
|
@@ -23,6 +23,7 @@ export declare enum ProviderPrefix {
|
|
|
23
23
|
export declare const FILTERED_VALUE_OPACITY = 28;
|
|
24
24
|
export declare const DEFAULT_ATTRIBUTE_NAME = "name";
|
|
25
25
|
export declare const DEFAULT_DATA_SOURCE_LIMIT = 100;
|
|
26
|
+
export declare const QUERY_DESCRIPTION_CACHE_TTL = 60000;
|
|
26
27
|
export declare const LEFT_PANEL_HEADER_HEIGHT = "9.1875rem";
|
|
27
28
|
export declare const DEFAULT_BASE_MAP = "Mapbox_Light";
|
|
28
29
|
export declare const DEFAULT_LNG = 37.618423;
|
|
@@ -4,8 +4,9 @@ import { i18n } from 'i18next';
|
|
|
4
4
|
import { PieChartData, BarChartMarker } from '@evergis/charts';
|
|
5
5
|
import { IconTypesKeys, IOption } from '@evergis/uilib-gl';
|
|
6
6
|
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification } from 'maplibre-gl';
|
|
7
|
-
import {
|
|
7
|
+
import { AttributeType, EqlRequestDc, FeatureDc, OgcGeometryType, PagedFeaturesListDc, PositionDc, QueryLayerServiceInfoDc, RemoteTaskStatus, StringSubType, AttributesConfigurationDc } from '@evergis/api';
|
|
8
8
|
import { FeatureAttributeValue, EditGeometryType, ThemeName } from '../../types';
|
|
9
|
+
import { AttributeFormatConfiguration } from '../../utils/format';
|
|
9
10
|
import { InnerContainerProps } from './containers/DataSourceInnerContainer/types';
|
|
10
11
|
export * from './componentTypes';
|
|
11
12
|
export * from './branded';
|
|
@@ -388,7 +389,7 @@ export interface ConfigDataSourceAttribute {
|
|
|
388
389
|
alias?: string;
|
|
389
390
|
type?: AttributeType;
|
|
390
391
|
description?: string;
|
|
391
|
-
stringFormat?:
|
|
392
|
+
stringFormat?: AttributeFormatConfiguration;
|
|
392
393
|
}
|
|
393
394
|
export interface ConfigDataSource {
|
|
394
395
|
name: string;
|
|
@@ -669,6 +670,6 @@ export type ClientFeatureAttribute = {
|
|
|
669
670
|
type: AttributeType;
|
|
670
671
|
readOnly?: boolean;
|
|
671
672
|
subType?: StringSubType;
|
|
672
|
-
stringFormat?:
|
|
673
|
+
stringFormat?: AttributeFormatConfiguration;
|
|
673
674
|
clientData?: unknown;
|
|
674
675
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Api } from '@evergis/api';
|
|
2
|
+
type QueryDescriptionRequest = {
|
|
3
|
+
ds?: string;
|
|
4
|
+
query?: string;
|
|
5
|
+
parameters?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare const fetchQueryDescription: (api: Api, { ds, query, parameters }: QueryDescriptionRequest) => Promise<(import('@evergis/api').AttributeConfigurationDc | import('@evergis/api').CalculatedAttributeConfigurationDc | import('@evergis/api').GeometryAttributeConfigurationDc | import('@evergis/api').StringAttributeConfigurationDc)[]>;
|
|
8
|
+
export {};
|
|
@@ -10,6 +10,7 @@ export * from './createNewPageId';
|
|
|
10
10
|
export * from './eqlParametersToPayload';
|
|
11
11
|
export * from './formatChartRelatedValue';
|
|
12
12
|
export * from './formatConditionValue';
|
|
13
|
+
export * from './fetchQueryDescription';
|
|
13
14
|
export * from './formatDataSourceCondition';
|
|
14
15
|
export * from './formatElementValue';
|
|
15
16
|
export * from './getAttributeByName';
|
|
@@ -65,7 +66,6 @@ export * from './mergeAttributeConfigurations';
|
|
|
65
66
|
export * from './pieChartTooltipFromAttributes';
|
|
66
67
|
export * from './pieChartTooltipFromRelatedFeatures';
|
|
67
68
|
export * from './removeDataSource';
|
|
68
|
-
export * from './roundTotalSum';
|
|
69
69
|
export * from './updateDataSource';
|
|
70
70
|
export * from './sliceShownOtherItems';
|
|
71
71
|
export * from './toCssSize';
|
package/dist/index.js
CHANGED
|
@@ -3502,6 +3502,7 @@ exports.ProviderPrefix = void 0;
|
|
|
3502
3502
|
const FILTERED_VALUE_OPACITY = 28;
|
|
3503
3503
|
const DEFAULT_ATTRIBUTE_NAME = "name";
|
|
3504
3504
|
const DEFAULT_DATA_SOURCE_LIMIT = 100;
|
|
3505
|
+
const QUERY_DESCRIPTION_CACHE_TTL = 60000;
|
|
3505
3506
|
const LEFT_PANEL_HEADER_HEIGHT = "9.1875rem";
|
|
3506
3507
|
const DEFAULT_BASE_MAP = "Mapbox_Light";
|
|
3507
3508
|
const DEFAULT_LNG = 37.618423;
|
|
@@ -3805,6 +3806,22 @@ const debounce = (callback, delay) => {
|
|
|
3805
3806
|
};
|
|
3806
3807
|
};
|
|
3807
3808
|
|
|
3809
|
+
const MILLION = 1000000;
|
|
3810
|
+
const TEN_THOUSANDS = 10000;
|
|
3811
|
+
const THOUSAND = 1000;
|
|
3812
|
+
const FRACTION_DIGITS = 1;
|
|
3813
|
+
const roundTotalSum = (value) => {
|
|
3814
|
+
if (!value)
|
|
3815
|
+
return "";
|
|
3816
|
+
if (value >= MILLION) {
|
|
3817
|
+
return `${(value / MILLION).toFixed(FRACTION_DIGITS)}M`;
|
|
3818
|
+
}
|
|
3819
|
+
if (value >= TEN_THOUSANDS) {
|
|
3820
|
+
return `${(value / THOUSAND).toFixed(FRACTION_DIGITS)}K`;
|
|
3821
|
+
}
|
|
3822
|
+
return value;
|
|
3823
|
+
};
|
|
3824
|
+
|
|
3808
3825
|
const TIME_ZONE_FORMAT = ' "GMT"z'; // eslint-disable-line
|
|
3809
3826
|
exports.ScalingFactor = void 0;
|
|
3810
3827
|
(function (ScalingFactor) {
|
|
@@ -3933,8 +3950,9 @@ const formatDateValue = (stringFormat, dateValue) => {
|
|
|
3933
3950
|
const timeFormat = (timeOptionValue && dateFns.format(value, showTimeZone ? `${timeOptionValue} zz` : timeOptionValue)) || "";
|
|
3934
3951
|
return dateFormat ? `${dateFormat} ${timeFormat}` : "";
|
|
3935
3952
|
};
|
|
3953
|
+
const appendUnitsLabel = (value, unitsLabel, noUnits) => (unitsLabel && !noUnits ? `${value} ${unitsLabel}` : value)?.toString() || "";
|
|
3936
3954
|
const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
3937
|
-
const { scalingFactor, rounding, splitDigitGroup, unitsLabel } = stringFormat || {};
|
|
3955
|
+
const { scalingFactor, rounding, splitDigitGroup, roundDigitGroup, unitsLabel } = stringFormat || {};
|
|
3938
3956
|
const isIntValue = [api.AttributeType.Int32, api.AttributeType.Int64].includes(type);
|
|
3939
3957
|
const isDefaultScaling = stringFormat && stringFormat.scalingFactor === +numberOptions[0].value;
|
|
3940
3958
|
let currentValue = value;
|
|
@@ -3944,6 +3962,10 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
|
3944
3962
|
if (scalingFactor) {
|
|
3945
3963
|
currentValue *= scalingFactor;
|
|
3946
3964
|
}
|
|
3965
|
+
const compactValue = roundDigitGroup ? roundTotalSum(Number(currentValue)) : null;
|
|
3966
|
+
if (typeof compactValue === "string" && compactValue) {
|
|
3967
|
+
return appendUnitsLabel(compactValue, unitsLabel, noUnits);
|
|
3968
|
+
}
|
|
3947
3969
|
if ((rounding || rounding === 0) && (!isIntValue || (isIntValue && !isDefaultScaling))) {
|
|
3948
3970
|
currentValue = currentValue && Number(currentValue).toFixed(rounding);
|
|
3949
3971
|
}
|
|
@@ -3953,10 +3975,7 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
|
|
|
3953
3975
|
if (currentValue) {
|
|
3954
3976
|
currentValue = currentValue.toString().replace(".", ",");
|
|
3955
3977
|
}
|
|
3956
|
-
|
|
3957
|
-
currentValue = `${currentValue} ${unitsLabel}`;
|
|
3958
|
-
}
|
|
3959
|
-
return currentValue?.toString() || "";
|
|
3978
|
+
return appendUnitsLabel(currentValue, unitsLabel, noUnits);
|
|
3960
3979
|
};
|
|
3961
3980
|
const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
|
|
3962
3981
|
const isNilValue = lodash.isNil(value);
|
|
@@ -4330,6 +4349,25 @@ const formatChartRelatedValue = (t, value, layerInfo, relatedAttributes) => {
|
|
|
4330
4349
|
: value;
|
|
4331
4350
|
};
|
|
4332
4351
|
|
|
4352
|
+
const descriptionCache = new Map();
|
|
4353
|
+
const fetchQueryDescription = (api, { ds, query, parameters }) => {
|
|
4354
|
+
const key = JSON.stringify([ds ?? null, query ?? null]);
|
|
4355
|
+
const cached = descriptionCache.get(key);
|
|
4356
|
+
if (cached && Date.now() - cached.requestedAt < QUERY_DESCRIPTION_CACHE_TTL) {
|
|
4357
|
+
return cached.request;
|
|
4358
|
+
}
|
|
4359
|
+
const request = api.eql
|
|
4360
|
+
.getQueryDescription({ ds, query, parameters })
|
|
4361
|
+
.then(description => description)
|
|
4362
|
+
.catch(error => {
|
|
4363
|
+
if (descriptionCache.get(key)?.request === request)
|
|
4364
|
+
descriptionCache.delete(key);
|
|
4365
|
+
throw error;
|
|
4366
|
+
});
|
|
4367
|
+
descriptionCache.set(key, { requestedAt: Date.now(), request });
|
|
4368
|
+
return request;
|
|
4369
|
+
};
|
|
4370
|
+
|
|
4333
4371
|
const applyFiltersToCondition = ({ condition, name, defaultValue, filters, isSingle, isSetParams, }) => {
|
|
4334
4372
|
const rawValue = filters[name] !== undefined ? filters[name].value : defaultValue;
|
|
4335
4373
|
if (isTreeFilterValue(rawValue)) {
|
|
@@ -7093,8 +7131,10 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
7093
7131
|
};
|
|
7094
7132
|
const newSignature = JSON.stringify(["eql", ds, query, newParams, offset, limit]);
|
|
7095
7133
|
return dedupe(newSignature, async () => {
|
|
7096
|
-
const queryResponse = await
|
|
7097
|
-
|
|
7134
|
+
const [queryResponse, descriptionResponse] = await Promise.all([
|
|
7135
|
+
api.eql.getPagedQueryResult({ saveInHistory: false }, getProps),
|
|
7136
|
+
fetchQueryDescription(api, { ds, query, parameters: newParams }),
|
|
7137
|
+
]);
|
|
7098
7138
|
return {
|
|
7099
7139
|
items: queryResponse.features,
|
|
7100
7140
|
attributes: descriptionResponse,
|
|
@@ -7128,9 +7168,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
7128
7168
|
dataSources,
|
|
7129
7169
|
configFilters,
|
|
7130
7170
|
ewktGeometry,
|
|
7131
|
-
api
|
|
7132
|
-
api.remoteTaskManager,
|
|
7133
|
-
api.eql,
|
|
7171
|
+
api,
|
|
7134
7172
|
attributes,
|
|
7135
7173
|
layerParams,
|
|
7136
7174
|
layerInfo,
|
|
@@ -14157,22 +14195,6 @@ const removeDataSource = (dashboardConfiguration, name, pageIndex) => {
|
|
|
14157
14195
|
return newConfig;
|
|
14158
14196
|
};
|
|
14159
14197
|
|
|
14160
|
-
const BILLION = 1000000;
|
|
14161
|
-
const TEN_THOUSANDS = 10000;
|
|
14162
|
-
const THOUSAND = 1000;
|
|
14163
|
-
const FRACTION_DIGITS = 1;
|
|
14164
|
-
const roundTotalSum = (value) => {
|
|
14165
|
-
if (!value)
|
|
14166
|
-
return "";
|
|
14167
|
-
if (value >= BILLION) {
|
|
14168
|
-
return `${(value / BILLION).toFixed(FRACTION_DIGITS)}M`;
|
|
14169
|
-
}
|
|
14170
|
-
if (value >= TEN_THOUSANDS) {
|
|
14171
|
-
return `${(value / THOUSAND).toFixed(FRACTION_DIGITS)}K`;
|
|
14172
|
-
}
|
|
14173
|
-
return value;
|
|
14174
|
-
};
|
|
14175
|
-
|
|
14176
14198
|
const updateDataSource = (dashboardConfiguration, name, pageIndex, data) => {
|
|
14177
14199
|
const newConfig = JSON.parse(JSON.stringify(dashboardConfiguration));
|
|
14178
14200
|
if (newConfig.dataSources?.length) {
|
|
@@ -15337,6 +15359,7 @@ exports.PresentationPanelContainer = PresentationPanelContainer;
|
|
|
15337
15359
|
exports.PresentationPanelWrapper = PresentationPanelWrapper;
|
|
15338
15360
|
exports.PresentationWrapper = PresentationWrapper;
|
|
15339
15361
|
exports.ProgressContainer = ProgressContainer;
|
|
15362
|
+
exports.QUERY_DESCRIPTION_CACHE_TTL = QUERY_DESCRIPTION_CACHE_TTL;
|
|
15340
15363
|
exports.RoundedBackgroundContainer = RoundedBackgroundContainer;
|
|
15341
15364
|
exports.SAVE_HOOK_RESULT_DURATION = SAVE_HOOK_RESULT_DURATION;
|
|
15342
15365
|
exports.SERVER_NOTIFICATION_EVENT = SERVER_NOTIFICATION_EVENT;
|
|
@@ -15390,6 +15413,7 @@ exports.decimalOpacityToHex = decimalOpacityToHex;
|
|
|
15390
15413
|
exports.enrichStyleItemsWithIds = enrichStyleItemsWithIds;
|
|
15391
15414
|
exports.enrichStyleModelsWithIds = enrichStyleModelsWithIds;
|
|
15392
15415
|
exports.eqlParametersToPayload = eqlParametersToPayload;
|
|
15416
|
+
exports.fetchQueryDescription = fetchQueryDescription;
|
|
15393
15417
|
exports.findAttributeInExpression = findAttributeInExpression;
|
|
15394
15418
|
exports.formatArea = formatArea;
|
|
15395
15419
|
exports.formatAttributeValue = formatAttributeValue;
|