@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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export declare const LayersContainerWrapper: import('styled-components').StyledComponent<
|
|
1
|
+
export declare const LayersContainerWrapper: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
|
|
2
|
+
isTitle?: boolean;
|
|
3
|
+
isColumn?: boolean;
|
|
4
|
+
isMain?: boolean;
|
|
5
|
+
noBorders?: boolean;
|
|
6
|
+
} & {
|
|
2
7
|
isPresentationMode?: boolean;
|
|
3
|
-
},
|
|
8
|
+
}, never>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export declare const UploaderContainer: import('styled-components').StyledComponent<
|
|
2
|
-
|
|
1
|
+
export declare const UploaderContainer: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
|
|
2
|
+
isTitle?: boolean;
|
|
3
|
+
isColumn?: boolean;
|
|
4
|
+
isMain?: boolean;
|
|
5
|
+
noBorders?: boolean;
|
|
6
|
+
}, never>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export declare const ElementValueWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
3
|
+
noMargin?: boolean;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const Container: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
|
|
6
|
+
isTitle?: boolean;
|
|
7
|
+
isColumn?: boolean;
|
|
8
|
+
isMain?: boolean;
|
|
9
|
+
noBorders?: boolean;
|
|
10
|
+
}, never>;
|
|
11
|
+
export declare const ContainerWrapper: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
|
|
12
|
+
$zIndex?: CSSProperties["zIndex"];
|
|
13
|
+
$noMargin?: boolean;
|
|
14
|
+
}, never>;
|
|
3
15
|
export declare const DashboardChip: import('styled-components').StyledComponent<any, any, any, any>;
|
|
4
16
|
export declare const DashboardPlaceholderWrap: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
|
|
5
17
|
export declare const DashboardPlaceholder: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
|
package/dist/index.js
CHANGED
|
@@ -4507,75 +4507,6 @@ const DashboardChip$1 = styled(uilibGl.Chip) `
|
|
|
4507
4507
|
${({ $fontColor, $isDefault }) => !!$fontColor && !$isDefault && CustomChipColorMixin}
|
|
4508
4508
|
`;
|
|
4509
4509
|
|
|
4510
|
-
const getAttributeByName = (attributeName, attributes) => {
|
|
4511
|
-
return Array.isArray(attributeName)
|
|
4512
|
-
? null
|
|
4513
|
-
: attributeName
|
|
4514
|
-
? attributes?.find(({ name }) => name === attributeName)
|
|
4515
|
-
: null;
|
|
4516
|
-
};
|
|
4517
|
-
|
|
4518
|
-
const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
|
|
4519
|
-
const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
|
|
4520
|
-
const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
|
|
4521
|
-
const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius } = options || {};
|
|
4522
|
-
const valueOrDefault = value || defaultValue;
|
|
4523
|
-
const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
|
|
4524
|
-
? formatAttributeValue({
|
|
4525
|
-
t,
|
|
4526
|
-
type: attribute.type,
|
|
4527
|
-
value: valueOrDefault,
|
|
4528
|
-
stringFormat: attribute.stringFormat,
|
|
4529
|
-
noUnits,
|
|
4530
|
-
})
|
|
4531
|
-
: valueOrDefault;
|
|
4532
|
-
if (!wrap)
|
|
4533
|
-
return resultValue;
|
|
4534
|
-
return (jsxRuntime.jsxs(React.Fragment, { children: [tagView ? (jsxRuntime.jsx(DashboardChip$1, { text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius, style: style })) : resultValue, withDivider && jsxRuntime.jsx(uilibGl.Divider, {})] }, id));
|
|
4535
|
-
};
|
|
4536
|
-
|
|
4537
|
-
const getAttributeValue = (element, attributes) => {
|
|
4538
|
-
const attribute = getAttributeByName(element?.attributeName, attributes);
|
|
4539
|
-
const { maxLength, separator, expandable, lineBreak } = element.options || {};
|
|
4540
|
-
let value = "";
|
|
4541
|
-
if (attribute?.type === api.AttributeType.Boolean && typeof attribute.value === "boolean") {
|
|
4542
|
-
return jsxRuntime.jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
|
|
4543
|
-
}
|
|
4544
|
-
if (Array.isArray(element?.attributeName)) {
|
|
4545
|
-
const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
|
|
4546
|
-
value = concatAttributes.join(separator || ", ");
|
|
4547
|
-
}
|
|
4548
|
-
else {
|
|
4549
|
-
value = attribute?.value?.toString() || "";
|
|
4550
|
-
}
|
|
4551
|
-
return maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
|
|
4552
|
-
};
|
|
4553
|
-
|
|
4554
|
-
const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
|
|
4555
|
-
|
|
4556
|
-
const getChartFilterName = (relatedDataSources) => {
|
|
4557
|
-
const relatedAttributes = relatedDataSources || [];
|
|
4558
|
-
const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
|
|
4559
|
-
return axes?.[0]?.filterName;
|
|
4560
|
-
};
|
|
4561
|
-
|
|
4562
|
-
function getValueIndex(items, attributes) {
|
|
4563
|
-
return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
|
|
4564
|
-
}
|
|
4565
|
-
const getChartMarkers = (items, markers, dataSources) => {
|
|
4566
|
-
if (typeof markers === "string") {
|
|
4567
|
-
const dataSource = getDataSource(markers, dataSources);
|
|
4568
|
-
return dataSource?.features?.map(({ attributes }) => ({
|
|
4569
|
-
...attributes,
|
|
4570
|
-
value: getValueIndex(items, attributes),
|
|
4571
|
-
})) || [];
|
|
4572
|
-
}
|
|
4573
|
-
return (markers?.map(marker => ({
|
|
4574
|
-
...marker,
|
|
4575
|
-
value: getValueIndex(items, marker),
|
|
4576
|
-
})) || []);
|
|
4577
|
-
};
|
|
4578
|
-
|
|
4579
4510
|
const LayerGroupContainer = styled(uilibGl.Flex) `
|
|
4580
4511
|
display: flex;
|
|
4581
4512
|
justify-content: center;
|
|
@@ -5104,21 +5035,34 @@ const LayerListContainer = styled(uilibGl.Flex) `
|
|
|
5104
5035
|
box-sizing: border-box;
|
|
5105
5036
|
`;
|
|
5106
5037
|
|
|
5038
|
+
const ElementValueWrapper = styled.div `
|
|
5039
|
+
transition: background-color ${uilibGl.transition.toggle};
|
|
5040
|
+
|
|
5041
|
+
${({ noMargin }) => styled.css `
|
|
5042
|
+
&&&& {
|
|
5043
|
+
margin-bottom: 0;
|
|
5044
|
+
}
|
|
5045
|
+
`};
|
|
5046
|
+
`;
|
|
5107
5047
|
const Container = styled(uilibGl.Flex) `
|
|
5108
5048
|
flex-direction: column;
|
|
5109
5049
|
width: 100%;
|
|
5110
|
-
|
|
5050
|
+
|
|
5111
5051
|
${({ isColumn }) => isColumn
|
|
5112
5052
|
? styled.css `
|
|
5113
|
-
|
|
5114
|
-
|
|
5053
|
+
> * {
|
|
5054
|
+
width: 100%;
|
|
5055
|
+
|
|
5056
|
+
:not(:last-child) {
|
|
5057
|
+
margin-bottom: 1.5rem;
|
|
5115
5058
|
}
|
|
5116
|
-
|
|
5059
|
+
}
|
|
5060
|
+
`
|
|
5117
5061
|
: styled.css `
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5062
|
+
flex-direction: row;
|
|
5063
|
+
justify-content: space-between;
|
|
5064
|
+
align-items: center;
|
|
5065
|
+
`}
|
|
5122
5066
|
|
|
5123
5067
|
${({ isTitle }) => isTitle &&
|
|
5124
5068
|
styled.css `
|
|
@@ -5147,10 +5091,6 @@ const ContainerWrapper = styled(uilibGl.Flex) `
|
|
|
5147
5091
|
color: ${({ theme: { palette } }) => palette.textPrimary};
|
|
5148
5092
|
z-index: ${({ $zIndex }) => $zIndex ?? 1};
|
|
5149
5093
|
transition: background-color ${uilibGl.transition.toggle};
|
|
5150
|
-
|
|
5151
|
-
${Container} > :not(:last-child) {
|
|
5152
|
-
margin-bottom: 1.5rem;
|
|
5153
|
-
}
|
|
5154
5094
|
|
|
5155
5095
|
${({ $noMargin }) => $noMargin && styled.css `
|
|
5156
5096
|
&&&& {
|
|
@@ -5192,6 +5132,7 @@ const DashboardPlaceholder = styled(uilibGl.Flex) `
|
|
|
5192
5132
|
styled.css `
|
|
5193
5133
|
width: 6.25rem;
|
|
5194
5134
|
`}
|
|
5135
|
+
|
|
5195
5136
|
&&& > * {
|
|
5196
5137
|
margin-bottom: 0;
|
|
5197
5138
|
}
|
|
@@ -5401,13 +5342,82 @@ const FeatureControls = styled(uilibGl.Flex) `
|
|
|
5401
5342
|
}
|
|
5402
5343
|
`;
|
|
5403
5344
|
|
|
5345
|
+
const getAttributeByName = (attributeName, attributes) => {
|
|
5346
|
+
return Array.isArray(attributeName)
|
|
5347
|
+
? null
|
|
5348
|
+
: attributeName
|
|
5349
|
+
? attributes?.find(({ name }) => name === attributeName)
|
|
5350
|
+
: null;
|
|
5351
|
+
};
|
|
5352
|
+
|
|
5353
|
+
const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
|
|
5354
|
+
const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
|
|
5355
|
+
const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
|
|
5356
|
+
const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius, noMargin } = options || {};
|
|
5357
|
+
const valueOrDefault = value || defaultValue;
|
|
5358
|
+
const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
|
|
5359
|
+
? formatAttributeValue({
|
|
5360
|
+
t,
|
|
5361
|
+
type: attribute.type,
|
|
5362
|
+
value: valueOrDefault,
|
|
5363
|
+
stringFormat: attribute.stringFormat,
|
|
5364
|
+
noUnits,
|
|
5365
|
+
})
|
|
5366
|
+
: valueOrDefault;
|
|
5367
|
+
if (!wrap)
|
|
5368
|
+
return resultValue;
|
|
5369
|
+
return (jsxRuntime.jsxs(React.Fragment, { children: [tagView ? (jsxRuntime.jsx(DashboardChip$1, { "data-id": id, "data-templatename": templateName, style: style, text: resultValue, "$bgColor": bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$radius": radius })) : (jsxRuntime.jsx(ElementValueWrapper, { "data-id": id, "data-templatename": templateName, style: style, noMargin: noMargin, children: resultValue })), withDivider && jsxRuntime.jsx(uilibGl.Divider, {})] }, id));
|
|
5370
|
+
};
|
|
5371
|
+
|
|
5372
|
+
const getAttributeValue = (element, attributes) => {
|
|
5373
|
+
const attribute = getAttributeByName(element?.attributeName, attributes);
|
|
5374
|
+
const { maxLength, separator, expandable, lineBreak } = element.options || {};
|
|
5375
|
+
let value = "";
|
|
5376
|
+
if (attribute?.type === api.AttributeType.Boolean && typeof attribute.value === "boolean") {
|
|
5377
|
+
return jsxRuntime.jsx(DashboardCheckbox, { title: attribute.alias || attribute.name, checked: attribute.value });
|
|
5378
|
+
}
|
|
5379
|
+
if (Array.isArray(element?.attributeName)) {
|
|
5380
|
+
const concatAttributes = element.attributeName.map((attributeName) => attributes?.find(({ name }) => name === attributeName)?.value || "");
|
|
5381
|
+
value = concatAttributes.join(separator || ", ");
|
|
5382
|
+
}
|
|
5383
|
+
else {
|
|
5384
|
+
value = attribute?.value?.toString() || "";
|
|
5385
|
+
}
|
|
5386
|
+
return maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
|
|
5387
|
+
};
|
|
5388
|
+
|
|
5389
|
+
const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
|
|
5390
|
+
|
|
5391
|
+
const getChartFilterName = (relatedDataSources) => {
|
|
5392
|
+
const relatedAttributes = relatedDataSources || [];
|
|
5393
|
+
const axes = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y");
|
|
5394
|
+
return axes?.[0]?.filterName;
|
|
5395
|
+
};
|
|
5396
|
+
|
|
5397
|
+
function getValueIndex(items, attributes) {
|
|
5398
|
+
return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
|
|
5399
|
+
}
|
|
5400
|
+
const getChartMarkers = (items, markers, dataSources) => {
|
|
5401
|
+
if (typeof markers === "string") {
|
|
5402
|
+
const dataSource = getDataSource(markers, dataSources);
|
|
5403
|
+
return dataSource?.features?.map(({ attributes }) => ({
|
|
5404
|
+
...attributes,
|
|
5405
|
+
value: getValueIndex(items, attributes),
|
|
5406
|
+
})) || [];
|
|
5407
|
+
}
|
|
5408
|
+
return (markers?.map(marker => ({
|
|
5409
|
+
...marker,
|
|
5410
|
+
value: getValueIndex(items, marker),
|
|
5411
|
+
})) || []);
|
|
5412
|
+
};
|
|
5413
|
+
|
|
5404
5414
|
const ContainersGroupContainer = React.memo(({ elementConfig, type, renderElement }) => {
|
|
5405
5415
|
const { expandedContainers } = useWidgetContext(type);
|
|
5406
|
-
const { id, children, options
|
|
5416
|
+
const { id, children, options } = elementConfig || {};
|
|
5407
5417
|
const { column, expandable, expanded } = options || {};
|
|
5408
5418
|
const isColumn = column === undefined || column;
|
|
5409
5419
|
const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
|
|
5410
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsx(Container, { id: id, isColumn: isColumn,
|
|
5420
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsx(Container, { id: id, isColumn: isColumn, children: jsxRuntime.jsx(ContainerChildren, { items: children, elementConfig: elementConfig, isColumn: isColumn, isMain: id?.startsWith(CONFIG_PAGE_ID), renderElement: renderElement }) }))] }));
|
|
5411
5421
|
});
|
|
5412
5422
|
|
|
5413
5423
|
const ChartLegendContainer = styled(uilibGl.Flex) `
|
|
@@ -6711,96 +6721,34 @@ const ExportPdfContainer = React.memo(({ type, elementConfig }) => {
|
|
|
6711
6721
|
return (jsxRuntime.jsx(Container, { id: id, style: style, children: jsxRuntime.jsx(uilibGl.IconButton, { kind: icon || "download", primary: true, disabled: loading, onClick: onExport, children: title ?? t("downloadPdf", { ns: "dashboard", defaultValue: "Скачать PDF" }) }) }));
|
|
6712
6722
|
});
|
|
6713
6723
|
|
|
6714
|
-
const UploaderContainer = styled(Container) `
|
|
6715
|
-
${uilibGl.UploaderItemArea} {
|
|
6716
|
-
overflow: visible;
|
|
6717
|
-
padding-top: 1rem;
|
|
6718
|
-
padding-bottom: 1rem;
|
|
6719
|
-
}
|
|
6720
|
-
|
|
6721
|
-
${uilibGl.UploaderTitleWrapper} {
|
|
6722
|
-
top: 0;
|
|
6723
|
-
padding-top: 0;
|
|
6724
|
-
border: 0;
|
|
6725
|
-
}
|
|
6726
|
-
`;
|
|
6727
|
-
const UploaderTitle = styled(uilibGl.Flex) `
|
|
6728
|
-
flex-direction: column;
|
|
6729
|
-
align-items: center;
|
|
6730
|
-
width: 11rem;
|
|
6731
|
-
margin: 0 auto;
|
|
6732
|
-
text-align: center;
|
|
6733
|
-
font-size: 0.625rem;
|
|
6734
|
-
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
6735
|
-
|
|
6736
|
-
span[kind] {
|
|
6737
|
-
width: 1.5rem;
|
|
6738
|
-
height: 1.5rem;
|
|
6739
|
-
margin-bottom: 0.75rem;
|
|
6740
|
-
|
|
6741
|
-
:after {
|
|
6742
|
-
font-size: 1.5rem;
|
|
6743
|
-
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
6744
|
-
opacity: 0.12;
|
|
6745
|
-
}
|
|
6746
|
-
}
|
|
6747
|
-
`;
|
|
6748
|
-
|
|
6749
|
-
const DEFAULT_FILE_EXTENSIONS = ".txt,.csv,.py";
|
|
6750
6724
|
const UploadContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
6751
|
-
const {
|
|
6752
|
-
const {
|
|
6753
|
-
const
|
|
6754
|
-
const
|
|
6755
|
-
|
|
6756
|
-
const { icon, title, filterName, fileExtensions = DEFAULT_FILE_EXTENSIONS, parentResourceId, multiSelect } = options || {};
|
|
6757
|
-
const onUpload = React.useCallback(async (input) => {
|
|
6758
|
-
const files = Array.isArray(input) ? input : [input];
|
|
6759
|
-
const response = await Promise.all(files.map(file => {
|
|
6760
|
-
return api.file.upload(file, true, parentResourceId, file.name);
|
|
6761
|
-
}));
|
|
6762
|
-
const uploadedFiles = response.map(item => ({
|
|
6763
|
-
name: item.name,
|
|
6764
|
-
id: item.resourceId,
|
|
6765
|
-
done: true,
|
|
6766
|
-
}));
|
|
6767
|
-
setFiles(currentFiles => ([...uploadedFiles, ...currentFiles]));
|
|
6768
|
-
}, [parentResourceId]);
|
|
6769
|
-
const onDelete = React.useCallback(async (id) => {
|
|
6770
|
-
const index = files.findIndex(file => file.id === id);
|
|
6771
|
-
if (index === -1)
|
|
6772
|
-
return;
|
|
6773
|
-
const resourceId = files[index].id;
|
|
6774
|
-
await api.file.deleteResource(resourceId);
|
|
6775
|
-
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
6776
|
-
}, [files]);
|
|
6777
|
-
const renderTitle = React.useMemo(() => {
|
|
6778
|
-
if (files.length)
|
|
6779
|
-
return null;
|
|
6780
|
-
return (jsxRuntime.jsxs(UploaderTitle, { children: [jsxRuntime.jsx(uilibGl.Icon, { kind: icon || "upload" }), jsxRuntime.jsx("div", { children: title ?? t("uploadTitle", {
|
|
6781
|
-
ns: "dashboard",
|
|
6782
|
-
defaultValue: "Перетащите файл сюда или нажмите, чтобы выбрать",
|
|
6783
|
-
}) })] }));
|
|
6784
|
-
}, [icon, t, title, files.length]);
|
|
6785
|
-
React.useEffect(() => {
|
|
6786
|
-
if (!filterName)
|
|
6787
|
-
return;
|
|
6788
|
-
changeFilters({ [filterName]: { value: files.map(({ id }) => id) } });
|
|
6789
|
-
}, [files]);
|
|
6790
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxRuntime.jsx(UploaderContainer, { id: id, style: style, children: jsxRuntime.jsx(uilibGl.Uploader, { title: renderTitle, accept: fileExtensions, fileItems: files, currentRef: refInput, isMultiple: multiSelect, onUpload: onUpload, onDelete: onDelete }) })] }));
|
|
6725
|
+
const { expandedContainers } = useWidgetContext(type);
|
|
6726
|
+
const { id, options } = elementConfig || {};
|
|
6727
|
+
const { expandable, expanded } = options || {};
|
|
6728
|
+
const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
|
|
6729
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && renderElement({ id: "uploader", wrap: false })] }));
|
|
6791
6730
|
});
|
|
6792
6731
|
|
|
6793
|
-
const TaskContainer = React.memo(({ elementConfig }) => {
|
|
6794
|
-
const { t } = useGlobalContext();
|
|
6795
|
-
const {
|
|
6732
|
+
const TaskContainer = React.memo(({ type, elementConfig }) => {
|
|
6733
|
+
const { t, ewktGeometry } = useGlobalContext();
|
|
6734
|
+
const { dataSources, filters: selectedFilters } = useWidgetContext(type);
|
|
6735
|
+
const { currentPage } = useWidgetPage(type);
|
|
6736
|
+
const { runTask, loading } = usePythonTask();
|
|
6796
6737
|
const { options } = elementConfig || {};
|
|
6797
|
-
const { title, relatedResources } = options || {};
|
|
6738
|
+
const { title, relatedResources, center, icon } = options || {};
|
|
6798
6739
|
const onClick = React.useCallback(async () => {
|
|
6799
6740
|
await Promise.all(relatedResources.map(({ resourceId, parameters, script }) => {
|
|
6800
|
-
|
|
6741
|
+
const newParams = applyQueryFilters({
|
|
6742
|
+
parameters,
|
|
6743
|
+
dataSources,
|
|
6744
|
+
selectedFilters,
|
|
6745
|
+
filters: currentPage.filters,
|
|
6746
|
+
geometry: ewktGeometry,
|
|
6747
|
+
});
|
|
6748
|
+
return runTask({ resourceId, parameters: newParams, script });
|
|
6801
6749
|
}));
|
|
6802
|
-
}, [relatedResources, runTask]);
|
|
6803
|
-
return (jsxRuntime.jsx(uilibGl.WaitingButton, { primary: true, isWaiting: loading, disabled: !relatedResources?.length, onClick: onClick, children: title || t("run", { ns: "dashboard", defaultValue: "Запуск" }) }));
|
|
6750
|
+
}, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters]);
|
|
6751
|
+
return (jsxRuntime.jsx(uilibGl.Flex, { justifyContent: center ? "center" : "flex-start", children: jsxRuntime.jsxs(uilibGl.WaitingButton, { primary: true, isWaiting: loading, disabled: !relatedResources?.length, onClick: onClick, children: [icon && jsxRuntime.jsx(uilibGl.FlexSpan, { marginRight: "0.5rem", children: jsxRuntime.jsx(uilibGl.Icon, { kind: icon }) }), title || t("run", { ns: "dashboard", defaultValue: "Запуск" })] }) }));
|
|
6804
6752
|
});
|
|
6805
6753
|
|
|
6806
6754
|
const containerComponents = {
|
|
@@ -8184,6 +8132,86 @@ const getDefaultConfig = ({ title, defaultTitle, items, baseMapName, position, r
|
|
|
8184
8132
|
return dashboardConfiguration;
|
|
8185
8133
|
};
|
|
8186
8134
|
|
|
8135
|
+
const UploaderContainer = styled(Container) `
|
|
8136
|
+
${uilibGl.UploaderItemArea} {
|
|
8137
|
+
overflow: visible;
|
|
8138
|
+
padding-top: 1rem;
|
|
8139
|
+
padding-bottom: 1rem;
|
|
8140
|
+
}
|
|
8141
|
+
|
|
8142
|
+
${uilibGl.UploaderTitleWrapper} {
|
|
8143
|
+
top: 0;
|
|
8144
|
+
padding-top: 0;
|
|
8145
|
+
border: 0;
|
|
8146
|
+
}
|
|
8147
|
+
`;
|
|
8148
|
+
|
|
8149
|
+
const UploaderTitle = styled(uilibGl.Flex) `
|
|
8150
|
+
flex-direction: column;
|
|
8151
|
+
align-items: center;
|
|
8152
|
+
width: 11rem;
|
|
8153
|
+
margin: 0 auto;
|
|
8154
|
+
text-align: center;
|
|
8155
|
+
font-size: 0.625rem;
|
|
8156
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8157
|
+
|
|
8158
|
+
span[kind] {
|
|
8159
|
+
width: 1.5rem;
|
|
8160
|
+
height: 1.5rem;
|
|
8161
|
+
margin-bottom: 0.75rem;
|
|
8162
|
+
|
|
8163
|
+
:after {
|
|
8164
|
+
font-size: 1.5rem;
|
|
8165
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8166
|
+
opacity: 0.12;
|
|
8167
|
+
}
|
|
8168
|
+
}
|
|
8169
|
+
`;
|
|
8170
|
+
|
|
8171
|
+
const DEFAULT_FILE_EXTENSIONS = ".txt,.csv,.py";
|
|
8172
|
+
const ElementUploader = React.memo(({ elementConfig, type }) => {
|
|
8173
|
+
const { t, api } = useGlobalContext();
|
|
8174
|
+
const { changeFilters } = useWidgetContext(type);
|
|
8175
|
+
const [files, setFiles] = React.useState([]);
|
|
8176
|
+
const refInput = React.useRef();
|
|
8177
|
+
const { id, style, options } = elementConfig || {};
|
|
8178
|
+
const { fileExtensions = DEFAULT_FILE_EXTENSIONS, multiSelect, parentResourceId, icon, title, filterName } = options || {};
|
|
8179
|
+
const onUpload = React.useCallback(async (input) => {
|
|
8180
|
+
const files = Array.isArray(input) ? input : [input];
|
|
8181
|
+
const response = await Promise.all(files.map(file => {
|
|
8182
|
+
return api.file.upload(file, true, parentResourceId || "", file.name);
|
|
8183
|
+
}));
|
|
8184
|
+
const uploadedFiles = response.map(item => ({
|
|
8185
|
+
name: item.name,
|
|
8186
|
+
id: item.resourceId,
|
|
8187
|
+
done: true,
|
|
8188
|
+
}));
|
|
8189
|
+
setFiles(currentFiles => ([...uploadedFiles, ...currentFiles]));
|
|
8190
|
+
}, [parentResourceId]);
|
|
8191
|
+
const onDelete = React.useCallback(async (id) => {
|
|
8192
|
+
const index = files.findIndex(file => file.id === id);
|
|
8193
|
+
if (index === -1)
|
|
8194
|
+
return;
|
|
8195
|
+
const resourceId = files[index].id;
|
|
8196
|
+
await api.file.deleteResource(resourceId);
|
|
8197
|
+
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
8198
|
+
}, [files]);
|
|
8199
|
+
const renderTitle = React.useMemo(() => {
|
|
8200
|
+
if (files.length)
|
|
8201
|
+
return null;
|
|
8202
|
+
return (jsxRuntime.jsxs(UploaderTitle, { children: [jsxRuntime.jsx(uilibGl.Icon, { kind: icon || "upload" }), jsxRuntime.jsx("div", { children: title ?? t("uploadTitle", {
|
|
8203
|
+
ns: "dashboard",
|
|
8204
|
+
defaultValue: "Перетащите файл сюда или нажмите, чтобы выбрать",
|
|
8205
|
+
}) })] }));
|
|
8206
|
+
}, [icon, t, title, files.length]);
|
|
8207
|
+
React.useEffect(() => {
|
|
8208
|
+
if (!filterName)
|
|
8209
|
+
return;
|
|
8210
|
+
changeFilters({ [filterName]: { value: files.map(({ id }) => id) } });
|
|
8211
|
+
}, [files]);
|
|
8212
|
+
return (jsxRuntime.jsx(UploaderContainer, { id: id, style: style, children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx(uilibGl.Uploader, { currentRef: refInput, title: renderTitle, accept: fileExtensions, width: "100%", fileItems: files, isMultiple: multiSelect, onUpload: onUpload, onDelete: onDelete }) }) }));
|
|
8213
|
+
});
|
|
8214
|
+
|
|
8187
8215
|
const elementComponents = {
|
|
8188
8216
|
image: ElementImage,
|
|
8189
8217
|
slideshow: ElementSlideshow,
|
|
@@ -8197,6 +8225,7 @@ const elementComponents = {
|
|
|
8197
8225
|
chart: ElementChart,
|
|
8198
8226
|
legend: ElementLegend,
|
|
8199
8227
|
markdown: ElementMarkdown,
|
|
8228
|
+
uploader: ElementUploader,
|
|
8200
8229
|
};
|
|
8201
8230
|
|
|
8202
8231
|
const getElementValue = ({ getDefaultContainer, ...props }) => {
|
|
@@ -10808,6 +10837,7 @@ exports.ElementMarkdown = ElementMarkdown;
|
|
|
10808
10837
|
exports.ElementSlideshow = ElementSlideshow;
|
|
10809
10838
|
exports.ElementSvg = ElementSvg;
|
|
10810
10839
|
exports.ElementTooltip = ElementTooltip;
|
|
10840
|
+
exports.ElementValueWrapper = ElementValueWrapper;
|
|
10811
10841
|
exports.ExpandableTitle = ExpandableTitle;
|
|
10812
10842
|
exports.FEATURE_CARD_DEFAULT_COLORS = FEATURE_CARD_DEFAULT_COLORS;
|
|
10813
10843
|
exports.FEATURE_CARD_OTHER_COLOR = FEATURE_CARD_OTHER_COLOR;
|