@evergis/react 3.1.55 → 3.1.57
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/containers/LayersContainer/styled.d.ts +7 -2
- package/dist/components/Dashboard/containers/UploadContainer/styled.d.ts +6 -2
- package/dist/components/Dashboard/elements/ElementUploader/index.d.ts +3 -0
- package/dist/components/Dashboard/{containers/TaskContainer → elements/ElementUploader}/styled.d.ts +0 -1
- package/dist/components/Dashboard/elements/registry.d.ts +1 -0
- package/dist/components/Dashboard/styled.d.ts +14 -2
- package/dist/index.js +196 -166
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +197 -168
- package/dist/react.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/react.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
|
-
import { IconButton, Flex, transition, Chip,
|
|
2
|
+
import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, WaitingButton, LinearProgress, H2, ThemeProvider, defaultTheme, Preview, Blank, Popover, Expander, darkTheme, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Dropdown, Checkbox, CircularProgress, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
|
|
3
3
|
import { createContext, memo, useRef, useState, useEffect, useCallback, useContext, useMemo, Fragment } from 'react';
|
|
4
4
|
import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
|
|
5
5
|
import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
|
|
@@ -4505,75 +4505,6 @@ const DashboardChip$1 = styled(Chip) `
|
|
|
4505
4505
|
${({ $fontColor, $isDefault }) => !!$fontColor && !$isDefault && CustomChipColorMixin}
|
|
4506
4506
|
`;
|
|
4507
4507
|
|
|
4508
|
-
const getAttributeByName = (attributeName, attributes) => {
|
|
4509
|
-
return Array.isArray(attributeName)
|
|
4510
|
-
? null
|
|
4511
|
-
: attributeName
|
|
4512
|
-
? attributes?.find(({ name }) => name === attributeName)
|
|
4513
|
-
: null;
|
|
4514
|
-
};
|
|
4515
|
-
|
|
4516
|
-
const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
|
|
4517
|
-
const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
|
|
4518
|
-
const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
|
|
4519
|
-
const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius } = options || {};
|
|
4520
|
-
const valueOrDefault = value || defaultValue;
|
|
4521
|
-
const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
|
|
4522
|
-
? formatAttributeValue({
|
|
4523
|
-
t,
|
|
4524
|
-
type: attribute.type,
|
|
4525
|
-
value: valueOrDefault,
|
|
4526
|
-
stringFormat: attribute.stringFormat,
|
|
4527
|
-
noUnits,
|
|
4528
|
-
})
|
|
4529
|
-
: valueOrDefault;
|
|
4530
|
-
if (!wrap)
|
|
4531
|
-
return resultValue;
|
|
4532
|
-
return (jsxs(Fragment, { children: [tagView ? (jsx(DashboardChip$1, { text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius, style: style })) : resultValue, withDivider && jsx(Divider, {})] }, id));
|
|
4533
|
-
};
|
|
4534
|
-
|
|
4535
|
-
const getAttributeValue = (element, attributes) => {
|
|
4536
|
-
const attribute = getAttributeByName(element?.attributeName, attributes);
|
|
4537
|
-
const { maxLength, separator, expandable, lineBreak } = element.options || {};
|
|
4538
|
-
let value = "";
|
|
4539
|
-
if (attribute?.type === AttributeType.Boolean && typeof attribute.value === "boolean") {
|
|
4540
|
-
return jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
|
|
4541
|
-
}
|
|
4542
|
-
if (Array.isArray(element?.attributeName)) {
|
|
4543
|
-
const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
|
|
4544
|
-
value = concatAttributes.join(separator || ", ");
|
|
4545
|
-
}
|
|
4546
|
-
else {
|
|
4547
|
-
value = attribute?.value?.toString() || "";
|
|
4548
|
-
}
|
|
4549
|
-
return maxLength && maxLength < value.length ? (jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
|
|
4550
|
-
};
|
|
4551
|
-
|
|
4552
|
-
const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
|
|
4553
|
-
|
|
4554
|
-
const getChartFilterName = (relatedDataSources) => {
|
|
4555
|
-
const relatedAttributes = relatedDataSources || [];
|
|
4556
|
-
const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
|
|
4557
|
-
return axes?.[0]?.filterName;
|
|
4558
|
-
};
|
|
4559
|
-
|
|
4560
|
-
function getValueIndex(items, attributes) {
|
|
4561
|
-
return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
|
|
4562
|
-
}
|
|
4563
|
-
const getChartMarkers = (items, markers, dataSources) => {
|
|
4564
|
-
if (typeof markers === "string") {
|
|
4565
|
-
const dataSource = getDataSource(markers, dataSources);
|
|
4566
|
-
return dataSource?.features?.map(({ attributes }) => ({
|
|
4567
|
-
...attributes,
|
|
4568
|
-
value: getValueIndex(items, attributes),
|
|
4569
|
-
})) || [];
|
|
4570
|
-
}
|
|
4571
|
-
return (markers?.map(marker => ({
|
|
4572
|
-
...marker,
|
|
4573
|
-
value: getValueIndex(items, marker),
|
|
4574
|
-
})) || []);
|
|
4575
|
-
};
|
|
4576
|
-
|
|
4577
4508
|
const LayerGroupContainer = styled(Flex) `
|
|
4578
4509
|
display: flex;
|
|
4579
4510
|
justify-content: center;
|
|
@@ -5102,21 +5033,34 @@ const LayerListContainer = styled(Flex) `
|
|
|
5102
5033
|
box-sizing: border-box;
|
|
5103
5034
|
`;
|
|
5104
5035
|
|
|
5036
|
+
const ElementValueWrapper = styled.div `
|
|
5037
|
+
transition: background-color ${transition.toggle};
|
|
5038
|
+
|
|
5039
|
+
${({ noMargin }) => css `
|
|
5040
|
+
&&&& {
|
|
5041
|
+
margin-bottom: 0;
|
|
5042
|
+
}
|
|
5043
|
+
`};
|
|
5044
|
+
`;
|
|
5105
5045
|
const Container = styled(Flex) `
|
|
5106
5046
|
flex-direction: column;
|
|
5107
5047
|
width: 100%;
|
|
5108
|
-
|
|
5048
|
+
|
|
5109
5049
|
${({ isColumn }) => isColumn
|
|
5110
5050
|
? css `
|
|
5111
|
-
|
|
5112
|
-
|
|
5051
|
+
> * {
|
|
5052
|
+
width: 100%;
|
|
5053
|
+
|
|
5054
|
+
:not(:last-child) {
|
|
5055
|
+
margin-bottom: 1.5rem;
|
|
5113
5056
|
}
|
|
5114
|
-
|
|
5057
|
+
}
|
|
5058
|
+
`
|
|
5115
5059
|
: css `
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5060
|
+
flex-direction: row;
|
|
5061
|
+
justify-content: space-between;
|
|
5062
|
+
align-items: center;
|
|
5063
|
+
`}
|
|
5120
5064
|
|
|
5121
5065
|
${({ isTitle }) => isTitle &&
|
|
5122
5066
|
css `
|
|
@@ -5145,10 +5089,6 @@ const ContainerWrapper = styled(Flex) `
|
|
|
5145
5089
|
color: ${({ theme: { palette } }) => palette.textPrimary};
|
|
5146
5090
|
z-index: ${({ $zIndex }) => $zIndex ?? 1};
|
|
5147
5091
|
transition: background-color ${transition.toggle};
|
|
5148
|
-
|
|
5149
|
-
${Container} > :not(:last-child) {
|
|
5150
|
-
margin-bottom: 1.5rem;
|
|
5151
|
-
}
|
|
5152
5092
|
|
|
5153
5093
|
${({ $noMargin }) => $noMargin && css `
|
|
5154
5094
|
&&&& {
|
|
@@ -5190,6 +5130,7 @@ const DashboardPlaceholder = styled(Flex) `
|
|
|
5190
5130
|
css `
|
|
5191
5131
|
width: 6.25rem;
|
|
5192
5132
|
`}
|
|
5133
|
+
|
|
5193
5134
|
&&& > * {
|
|
5194
5135
|
margin-bottom: 0;
|
|
5195
5136
|
}
|
|
@@ -5399,13 +5340,82 @@ const FeatureControls = styled(Flex) `
|
|
|
5399
5340
|
}
|
|
5400
5341
|
`;
|
|
5401
5342
|
|
|
5343
|
+
const getAttributeByName = (attributeName, attributes) => {
|
|
5344
|
+
return Array.isArray(attributeName)
|
|
5345
|
+
? null
|
|
5346
|
+
: attributeName
|
|
5347
|
+
? attributes?.find(({ name }) => name === attributeName)
|
|
5348
|
+
: null;
|
|
5349
|
+
};
|
|
5350
|
+
|
|
5351
|
+
const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
|
|
5352
|
+
const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
|
|
5353
|
+
const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
|
|
5354
|
+
const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius, noMargin } = options || {};
|
|
5355
|
+
const valueOrDefault = value || defaultValue;
|
|
5356
|
+
const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
|
|
5357
|
+
? formatAttributeValue({
|
|
5358
|
+
t,
|
|
5359
|
+
type: attribute.type,
|
|
5360
|
+
value: valueOrDefault,
|
|
5361
|
+
stringFormat: attribute.stringFormat,
|
|
5362
|
+
noUnits,
|
|
5363
|
+
})
|
|
5364
|
+
: valueOrDefault;
|
|
5365
|
+
if (!wrap)
|
|
5366
|
+
return resultValue;
|
|
5367
|
+
return (jsxs(Fragment, { children: [tagView ? (jsx(DashboardChip$1, { "data-id": id, "data-templatename": templateName, style: style, text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius })) : (jsx(ElementValueWrapper, { "data-id": id, "data-templatename": templateName, style: style, noMargin: noMargin, children: resultValue })), withDivider && jsx(Divider, {})] }, id));
|
|
5368
|
+
};
|
|
5369
|
+
|
|
5370
|
+
const getAttributeValue = (element, attributes) => {
|
|
5371
|
+
const attribute = getAttributeByName(element?.attributeName, attributes);
|
|
5372
|
+
const { maxLength, separator, expandable, lineBreak } = element.options || {};
|
|
5373
|
+
let value = "";
|
|
5374
|
+
if (attribute?.type === AttributeType.Boolean && typeof attribute.value === "boolean") {
|
|
5375
|
+
return jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
|
|
5376
|
+
}
|
|
5377
|
+
if (Array.isArray(element?.attributeName)) {
|
|
5378
|
+
const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
|
|
5379
|
+
value = concatAttributes.join(separator || ", ");
|
|
5380
|
+
}
|
|
5381
|
+
else {
|
|
5382
|
+
value = attribute?.value?.toString() || "";
|
|
5383
|
+
}
|
|
5384
|
+
return maxLength && maxLength < value.length ? (jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
|
|
5385
|
+
};
|
|
5386
|
+
|
|
5387
|
+
const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
|
|
5388
|
+
|
|
5389
|
+
const getChartFilterName = (relatedDataSources) => {
|
|
5390
|
+
const relatedAttributes = relatedDataSources || [];
|
|
5391
|
+
const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
|
|
5392
|
+
return axes?.[0]?.filterName;
|
|
5393
|
+
};
|
|
5394
|
+
|
|
5395
|
+
function getValueIndex(items, attributes) {
|
|
5396
|
+
return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
|
|
5397
|
+
}
|
|
5398
|
+
const getChartMarkers = (items, markers, dataSources) => {
|
|
5399
|
+
if (typeof markers === "string") {
|
|
5400
|
+
const dataSource = getDataSource(markers, dataSources);
|
|
5401
|
+
return dataSource?.features?.map(({ attributes }) => ({
|
|
5402
|
+
...attributes,
|
|
5403
|
+
value: getValueIndex(items, attributes),
|
|
5404
|
+
})) || [];
|
|
5405
|
+
}
|
|
5406
|
+
return (markers?.map(marker => ({
|
|
5407
|
+
...marker,
|
|
5408
|
+
value: getValueIndex(items, marker),
|
|
5409
|
+
})) || []);
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5402
5412
|
const ContainersGroupContainer = memo(({ elementConfig, type, renderElement }) => {
|
|
5403
5413
|
const { expandedContainers } = useWidgetContext(type);
|
|
5404
|
-
const { id, children, options
|
|
5414
|
+
const { id, children, options } = elementConfig || {};
|
|
5405
5415
|
const { column, expandable, expanded } = options || {};
|
|
5406
5416
|
const isColumn = column === undefined || column;
|
|
5407
5417
|
const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
|
|
5408
|
-
return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsx(Container, { id: id, isColumn: isColumn,
|
|
5418
|
+
return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsx(Container, { id: id, isColumn: isColumn, children: jsx(ContainerChildren, { items: children, elementConfig: elementConfig, isColumn: isColumn, isMain: id?.startsWith(CONFIG_PAGE_ID), renderElement: renderElement }) }))] }));
|
|
5409
5419
|
});
|
|
5410
5420
|
|
|
5411
5421
|
const ChartLegendContainer = styled(Flex) `
|
|
@@ -6709,96 +6719,34 @@ const ExportPdfContainer = memo(({ type, elementConfig }) => {
|
|
|
6709
6719
|
return (jsx(Container, { id: id, style: style, children: jsx(IconButton, { kind: icon || "download", primary: true, disabled: loading, onClick: onExport, children: title ?? t("downloadPdf", { ns: "dashboard", defaultValue: "Скачать PDF" }) }) }));
|
|
6710
6720
|
});
|
|
6711
6721
|
|
|
6712
|
-
const UploaderContainer = styled(Container) `
|
|
6713
|
-
${UploaderItemArea} {
|
|
6714
|
-
overflow: visible;
|
|
6715
|
-
padding-top: 1rem;
|
|
6716
|
-
padding-bottom: 1rem;
|
|
6717
|
-
}
|
|
6718
|
-
|
|
6719
|
-
${UploaderTitleWrapper} {
|
|
6720
|
-
top: 0;
|
|
6721
|
-
padding-top: 0;
|
|
6722
|
-
border: 0;
|
|
6723
|
-
}
|
|
6724
|
-
`;
|
|
6725
|
-
const UploaderTitle = styled(Flex) `
|
|
6726
|
-
flex-direction: column;
|
|
6727
|
-
align-items: center;
|
|
6728
|
-
width: 11rem;
|
|
6729
|
-
margin: 0 auto;
|
|
6730
|
-
text-align: center;
|
|
6731
|
-
font-size: 0.625rem;
|
|
6732
|
-
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
6733
|
-
|
|
6734
|
-
span[kind] {
|
|
6735
|
-
width: 1.5rem;
|
|
6736
|
-
height: 1.5rem;
|
|
6737
|
-
margin-bottom: 0.75rem;
|
|
6738
|
-
|
|
6739
|
-
:after {
|
|
6740
|
-
font-size: 1.5rem;
|
|
6741
|
-
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
6742
|
-
opacity: 0.12;
|
|
6743
|
-
}
|
|
6744
|
-
}
|
|
6745
|
-
`;
|
|
6746
|
-
|
|
6747
|
-
const DEFAULT_FILE_EXTENSIONS = ".txt,.csv,.py";
|
|
6748
6722
|
const UploadContainer = memo(({ type, elementConfig, renderElement }) => {
|
|
6749
|
-
const {
|
|
6750
|
-
const {
|
|
6751
|
-
const
|
|
6752
|
-
const
|
|
6753
|
-
|
|
6754
|
-
const { icon, title, filterName, fileExtensions = DEFAULT_FILE_EXTENSIONS, parentResourceId, multiSelect } = options || {};
|
|
6755
|
-
const onUpload = useCallback(async (input) => {
|
|
6756
|
-
const files = Array.isArray(input) ? input : [input];
|
|
6757
|
-
const response = await Promise.all(files.map(file => {
|
|
6758
|
-
return api.file.upload(file, true, parentResourceId, file.name);
|
|
6759
|
-
}));
|
|
6760
|
-
const uploadedFiles = response.map(item => ({
|
|
6761
|
-
name: item.name,
|
|
6762
|
-
id: item.resourceId,
|
|
6763
|
-
done: true,
|
|
6764
|
-
}));
|
|
6765
|
-
setFiles(currentFiles => ([...uploadedFiles, ...currentFiles]));
|
|
6766
|
-
}, [parentResourceId]);
|
|
6767
|
-
const onDelete = useCallback(async (id) => {
|
|
6768
|
-
const index = files.findIndex(file => file.id === id);
|
|
6769
|
-
if (index === -1)
|
|
6770
|
-
return;
|
|
6771
|
-
const resourceId = files[index].id;
|
|
6772
|
-
await api.file.deleteResource(resourceId);
|
|
6773
|
-
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
6774
|
-
}, [files]);
|
|
6775
|
-
const renderTitle = useMemo(() => {
|
|
6776
|
-
if (files.length)
|
|
6777
|
-
return null;
|
|
6778
|
-
return (jsxs(UploaderTitle, { children: [jsx(Icon, { kind: icon || "upload" }), jsx("div", { children: title ?? t("uploadTitle", {
|
|
6779
|
-
ns: "dashboard",
|
|
6780
|
-
defaultValue: "Перетащите файл сюда или нажмите, чтобы выбрать",
|
|
6781
|
-
}) })] }));
|
|
6782
|
-
}, [icon, t, title, files.length]);
|
|
6783
|
-
useEffect(() => {
|
|
6784
|
-
if (!filterName)
|
|
6785
|
-
return;
|
|
6786
|
-
changeFilters({ [filterName]: { value: files.map(({ id }) => id) } });
|
|
6787
|
-
}, [files]);
|
|
6788
|
-
return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsx(UploaderContainer, { id: id, style: style, children: jsx(Uploader, { title: renderTitle, accept: fileExtensions, fileItems: files, currentRef: refInput, isMultiple: multiSelect, onUpload: onUpload, onDelete: onDelete }) })] }));
|
|
6723
|
+
const { expandedContainers } = useWidgetContext(type);
|
|
6724
|
+
const { id, options } = elementConfig || {};
|
|
6725
|
+
const { expandable, expanded } = options || {};
|
|
6726
|
+
const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
|
|
6727
|
+
return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && renderElement({ id: "uploader", wrap: false })] }));
|
|
6789
6728
|
});
|
|
6790
6729
|
|
|
6791
|
-
const TaskContainer = memo(({ elementConfig }) => {
|
|
6792
|
-
const { t } = useGlobalContext();
|
|
6793
|
-
const {
|
|
6730
|
+
const TaskContainer = memo(({ type, elementConfig }) => {
|
|
6731
|
+
const { t, ewktGeometry } = useGlobalContext();
|
|
6732
|
+
const { dataSources, filters: selectedFilters } = useWidgetContext(type);
|
|
6733
|
+
const { currentPage } = useWidgetPage(type);
|
|
6734
|
+
const { runTask, loading } = usePythonTask();
|
|
6794
6735
|
const { options } = elementConfig || {};
|
|
6795
|
-
const { title, relatedResources } = options || {};
|
|
6736
|
+
const { title, relatedResources, center, icon } = options || {};
|
|
6796
6737
|
const onClick = useCallback(async () => {
|
|
6797
6738
|
await Promise.all(relatedResources.map(({ resourceId, parameters, script }) => {
|
|
6798
|
-
|
|
6739
|
+
const newParams = applyQueryFilters({
|
|
6740
|
+
parameters,
|
|
6741
|
+
dataSources,
|
|
6742
|
+
selectedFilters,
|
|
6743
|
+
filters: currentPage.filters,
|
|
6744
|
+
geometry: ewktGeometry,
|
|
6745
|
+
});
|
|
6746
|
+
return runTask({ resourceId, parameters: newParams, script });
|
|
6799
6747
|
}));
|
|
6800
|
-
}, [relatedResources, runTask]);
|
|
6801
|
-
return (jsx(WaitingButton, { primary: true, isWaiting: loading, disabled: !relatedResources?.length, onClick: onClick, children: title || t("run", { ns: "dashboard", defaultValue: "Запуск" }) }));
|
|
6748
|
+
}, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters]);
|
|
6749
|
+
return (jsx(Flex, { justifyContent: center ? "center" : "flex-start", children: jsxs(WaitingButton, { primary: true, isWaiting: loading, disabled: !relatedResources?.length, onClick: onClick, children: [icon && jsx(FlexSpan, { marginRight: "0.5rem", children: jsx(Icon, { kind: icon }) }), title || t("run", { ns: "dashboard", defaultValue: "Запуск" })] }) }));
|
|
6802
6750
|
});
|
|
6803
6751
|
|
|
6804
6752
|
const containerComponents = {
|
|
@@ -8182,6 +8130,86 @@ const getDefaultConfig = ({ title, defaultTitle, items, baseMapName, position, r
|
|
|
8182
8130
|
return dashboardConfiguration;
|
|
8183
8131
|
};
|
|
8184
8132
|
|
|
8133
|
+
const UploaderContainer = styled(Container) `
|
|
8134
|
+
${UploaderItemArea} {
|
|
8135
|
+
overflow: visible;
|
|
8136
|
+
padding-top: 1rem;
|
|
8137
|
+
padding-bottom: 1rem;
|
|
8138
|
+
}
|
|
8139
|
+
|
|
8140
|
+
${UploaderTitleWrapper} {
|
|
8141
|
+
top: 0;
|
|
8142
|
+
padding-top: 0;
|
|
8143
|
+
border: 0;
|
|
8144
|
+
}
|
|
8145
|
+
`;
|
|
8146
|
+
|
|
8147
|
+
const UploaderTitle = styled(Flex) `
|
|
8148
|
+
flex-direction: column;
|
|
8149
|
+
align-items: center;
|
|
8150
|
+
width: 11rem;
|
|
8151
|
+
margin: 0 auto;
|
|
8152
|
+
text-align: center;
|
|
8153
|
+
font-size: 0.625rem;
|
|
8154
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8155
|
+
|
|
8156
|
+
span[kind] {
|
|
8157
|
+
width: 1.5rem;
|
|
8158
|
+
height: 1.5rem;
|
|
8159
|
+
margin-bottom: 0.75rem;
|
|
8160
|
+
|
|
8161
|
+
:after {
|
|
8162
|
+
font-size: 1.5rem;
|
|
8163
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8164
|
+
opacity: 0.12;
|
|
8165
|
+
}
|
|
8166
|
+
}
|
|
8167
|
+
`;
|
|
8168
|
+
|
|
8169
|
+
const DEFAULT_FILE_EXTENSIONS = ".txt,.csv,.py";
|
|
8170
|
+
const ElementUploader = memo(({ elementConfig, type }) => {
|
|
8171
|
+
const { t, api } = useGlobalContext();
|
|
8172
|
+
const { changeFilters } = useWidgetContext(type);
|
|
8173
|
+
const [files, setFiles] = useState([]);
|
|
8174
|
+
const refInput = useRef();
|
|
8175
|
+
const { id, style, options } = elementConfig || {};
|
|
8176
|
+
const { fileExtensions = DEFAULT_FILE_EXTENSIONS, multiSelect, parentResourceId, icon, title, filterName } = options || {};
|
|
8177
|
+
const onUpload = useCallback(async (input) => {
|
|
8178
|
+
const files = Array.isArray(input) ? input : [input];
|
|
8179
|
+
const response = await Promise.all(files.map(file => {
|
|
8180
|
+
return api.file.upload(file, true, parentResourceId || "", file.name);
|
|
8181
|
+
}));
|
|
8182
|
+
const uploadedFiles = response.map(item => ({
|
|
8183
|
+
name: item.name,
|
|
8184
|
+
id: item.resourceId,
|
|
8185
|
+
done: true,
|
|
8186
|
+
}));
|
|
8187
|
+
setFiles(currentFiles => ([...uploadedFiles, ...currentFiles]));
|
|
8188
|
+
}, [parentResourceId]);
|
|
8189
|
+
const onDelete = useCallback(async (id) => {
|
|
8190
|
+
const index = files.findIndex(file => file.id === id);
|
|
8191
|
+
if (index === -1)
|
|
8192
|
+
return;
|
|
8193
|
+
const resourceId = files[index].id;
|
|
8194
|
+
await api.file.deleteResource(resourceId);
|
|
8195
|
+
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
8196
|
+
}, [files]);
|
|
8197
|
+
const renderTitle = useMemo(() => {
|
|
8198
|
+
if (files.length)
|
|
8199
|
+
return null;
|
|
8200
|
+
return (jsxs(UploaderTitle, { children: [jsx(Icon, { kind: icon || "upload" }), jsx("div", { children: title ?? t("uploadTitle", {
|
|
8201
|
+
ns: "dashboard",
|
|
8202
|
+
defaultValue: "Перетащите файл сюда или нажмите, чтобы выбрать",
|
|
8203
|
+
}) })] }));
|
|
8204
|
+
}, [icon, t, title, files.length]);
|
|
8205
|
+
useEffect(() => {
|
|
8206
|
+
if (!filterName)
|
|
8207
|
+
return;
|
|
8208
|
+
changeFilters({ [filterName]: { value: files.map(({ id }) => id) } });
|
|
8209
|
+
}, [files]);
|
|
8210
|
+
return (jsx(UploaderContainer, { id: id, style: style, children: jsx("div", { children: jsx(Uploader, { currentRef: refInput, title: renderTitle, accept: fileExtensions, width: "100%", fileItems: files, isMultiple: multiSelect, onUpload: onUpload, onDelete: onDelete }) }) }));
|
|
8211
|
+
});
|
|
8212
|
+
|
|
8185
8213
|
const elementComponents = {
|
|
8186
8214
|
image: ElementImage,
|
|
8187
8215
|
slideshow: ElementSlideshow,
|
|
@@ -8195,6 +8223,7 @@ const elementComponents = {
|
|
|
8195
8223
|
chart: ElementChart,
|
|
8196
8224
|
legend: ElementLegend,
|
|
8197
8225
|
markdown: ElementMarkdown,
|
|
8226
|
+
uploader: ElementUploader,
|
|
8198
8227
|
};
|
|
8199
8228
|
|
|
8200
8229
|
const getElementValue = ({ getDefaultContainer, ...props }) => {
|
|
@@ -10739,5 +10768,5 @@ const Map$1 = ({ zIndex, lowerSiblings, upperSiblings, onError, children, ...res
|
|
|
10739
10768
|
}, children: children }), upperSiblings] }));
|
|
10740
10769
|
};
|
|
10741
10770
|
|
|
10742
|
-
export { AddFeatureButton, AddFeatureContainer, AttributeGalleryContainer, AttributeLabel, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, Container, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementMarkdown, ElementSlideshow, ElementSvg, ElementTooltip, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, SERVER_NOTIFICATION_EVENT, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, UploadContainer, WidgetType, addDataSource, addDataSources, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartAxes, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getRootElementId, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useExportPdf, useGetConfigLayer, useGlobalContext, useHeaderRender, useLayerParams, useMapContext, useMapDraw, useProjectDashboardInit, usePythonTask, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
|
|
10771
|
+
export { AddFeatureButton, AddFeatureContainer, AttributeGalleryContainer, AttributeLabel, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, Container, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementMarkdown, ElementSlideshow, ElementSvg, ElementTooltip, ElementValueWrapper, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, SERVER_NOTIFICATION_EVENT, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, UploadContainer, WidgetType, addDataSource, addDataSources, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartAxes, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getRootElementId, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useExportPdf, useGetConfigLayer, useGlobalContext, useHeaderRender, useLayerParams, useMapContext, useMapDraw, useProjectDashboardInit, usePythonTask, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
|
|
10743
10772
|
//# sourceMappingURL=react.esm.js.map
|