@evergis/react 3.1.55 → 3.1.56
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/UploadContainer/styled.d.ts +0 -1
- 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/index.js +102 -83
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +103 -84
- package/dist/react.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6711,96 +6711,34 @@ const ExportPdfContainer = React.memo(({ type, elementConfig }) => {
|
|
|
6711
6711
|
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
6712
|
});
|
|
6713
6713
|
|
|
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
6714
|
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 }) })] }));
|
|
6715
|
+
const { expandedContainers } = useWidgetContext(type);
|
|
6716
|
+
const { id, options } = elementConfig || {};
|
|
6717
|
+
const { expandable, expanded } = options || {};
|
|
6718
|
+
const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
|
|
6719
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && renderElement({ id: "uploader", wrap: false })] }));
|
|
6791
6720
|
});
|
|
6792
6721
|
|
|
6793
|
-
const TaskContainer = React.memo(({ elementConfig }) => {
|
|
6794
|
-
const { t } = useGlobalContext();
|
|
6795
|
-
const {
|
|
6722
|
+
const TaskContainer = React.memo(({ type, elementConfig }) => {
|
|
6723
|
+
const { t, ewktGeometry } = useGlobalContext();
|
|
6724
|
+
const { dataSources, filters: selectedFilters } = useWidgetContext(type);
|
|
6725
|
+
const { currentPage } = useWidgetPage(type);
|
|
6726
|
+
const { runTask, loading } = usePythonTask();
|
|
6796
6727
|
const { options } = elementConfig || {};
|
|
6797
|
-
const { title, relatedResources } = options || {};
|
|
6728
|
+
const { title, relatedResources, center, icon } = options || {};
|
|
6798
6729
|
const onClick = React.useCallback(async () => {
|
|
6799
6730
|
await Promise.all(relatedResources.map(({ resourceId, parameters, script }) => {
|
|
6800
|
-
|
|
6731
|
+
const newParams = applyQueryFilters({
|
|
6732
|
+
parameters,
|
|
6733
|
+
dataSources,
|
|
6734
|
+
selectedFilters,
|
|
6735
|
+
filters: currentPage.filters,
|
|
6736
|
+
geometry: ewktGeometry,
|
|
6737
|
+
});
|
|
6738
|
+
return runTask({ resourceId, parameters: newParams, script });
|
|
6801
6739
|
}));
|
|
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: "Запуск" }) }));
|
|
6740
|
+
}, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters]);
|
|
6741
|
+
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
6742
|
});
|
|
6805
6743
|
|
|
6806
6744
|
const containerComponents = {
|
|
@@ -8184,6 +8122,86 @@ const getDefaultConfig = ({ title, defaultTitle, items, baseMapName, position, r
|
|
|
8184
8122
|
return dashboardConfiguration;
|
|
8185
8123
|
};
|
|
8186
8124
|
|
|
8125
|
+
const UploaderContainer = styled(Container) `
|
|
8126
|
+
${uilibGl.UploaderItemArea} {
|
|
8127
|
+
overflow: visible;
|
|
8128
|
+
padding-top: 1rem;
|
|
8129
|
+
padding-bottom: 1rem;
|
|
8130
|
+
}
|
|
8131
|
+
|
|
8132
|
+
${uilibGl.UploaderTitleWrapper} {
|
|
8133
|
+
top: 0;
|
|
8134
|
+
padding-top: 0;
|
|
8135
|
+
border: 0;
|
|
8136
|
+
}
|
|
8137
|
+
`;
|
|
8138
|
+
|
|
8139
|
+
const UploaderTitle = styled(uilibGl.Flex) `
|
|
8140
|
+
flex-direction: column;
|
|
8141
|
+
align-items: center;
|
|
8142
|
+
width: 11rem;
|
|
8143
|
+
margin: 0 auto;
|
|
8144
|
+
text-align: center;
|
|
8145
|
+
font-size: 0.625rem;
|
|
8146
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8147
|
+
|
|
8148
|
+
span[kind] {
|
|
8149
|
+
width: 1.5rem;
|
|
8150
|
+
height: 1.5rem;
|
|
8151
|
+
margin-bottom: 0.75rem;
|
|
8152
|
+
|
|
8153
|
+
:after {
|
|
8154
|
+
font-size: 1.5rem;
|
|
8155
|
+
color: ${({ theme: { palette } }) => palette.textSecondary};
|
|
8156
|
+
opacity: 0.12;
|
|
8157
|
+
}
|
|
8158
|
+
}
|
|
8159
|
+
`;
|
|
8160
|
+
|
|
8161
|
+
const DEFAULT_FILE_EXTENSIONS = ".txt,.csv,.py";
|
|
8162
|
+
const ElementUploader = React.memo(({ elementConfig, type }) => {
|
|
8163
|
+
const { t, api } = useGlobalContext();
|
|
8164
|
+
const { changeFilters } = useWidgetContext(type);
|
|
8165
|
+
const [files, setFiles] = React.useState([]);
|
|
8166
|
+
const refInput = React.useRef();
|
|
8167
|
+
const { id, style, options } = elementConfig || {};
|
|
8168
|
+
const { fileExtensions = DEFAULT_FILE_EXTENSIONS, multiSelect, parentResourceId, icon, title, filterName } = options || {};
|
|
8169
|
+
const onUpload = React.useCallback(async (input) => {
|
|
8170
|
+
const files = Array.isArray(input) ? input : [input];
|
|
8171
|
+
const response = await Promise.all(files.map(file => {
|
|
8172
|
+
return api.file.upload(file, true, parentResourceId || "", file.name);
|
|
8173
|
+
}));
|
|
8174
|
+
const uploadedFiles = response.map(item => ({
|
|
8175
|
+
name: item.name,
|
|
8176
|
+
id: item.resourceId,
|
|
8177
|
+
done: true,
|
|
8178
|
+
}));
|
|
8179
|
+
setFiles(currentFiles => ([...uploadedFiles, ...currentFiles]));
|
|
8180
|
+
}, [parentResourceId]);
|
|
8181
|
+
const onDelete = React.useCallback(async (id) => {
|
|
8182
|
+
const index = files.findIndex(file => file.id === id);
|
|
8183
|
+
if (index === -1)
|
|
8184
|
+
return;
|
|
8185
|
+
const resourceId = files[index].id;
|
|
8186
|
+
await api.file.deleteResource(resourceId);
|
|
8187
|
+
setFiles(currentFiles => currentFiles.filter(({ id }) => id !== resourceId));
|
|
8188
|
+
}, [files]);
|
|
8189
|
+
const renderTitle = React.useMemo(() => {
|
|
8190
|
+
if (files.length)
|
|
8191
|
+
return null;
|
|
8192
|
+
return (jsxRuntime.jsxs(UploaderTitle, { children: [jsxRuntime.jsx(uilibGl.Icon, { kind: icon || "upload" }), jsxRuntime.jsx("div", { children: title ?? t("uploadTitle", {
|
|
8193
|
+
ns: "dashboard",
|
|
8194
|
+
defaultValue: "Перетащите файл сюда или нажмите, чтобы выбрать",
|
|
8195
|
+
}) })] }));
|
|
8196
|
+
}, [icon, t, title, files.length]);
|
|
8197
|
+
React.useEffect(() => {
|
|
8198
|
+
if (!filterName)
|
|
8199
|
+
return;
|
|
8200
|
+
changeFilters({ [filterName]: { value: files.map(({ id }) => id) } });
|
|
8201
|
+
}, [files]);
|
|
8202
|
+
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 }) }) }));
|
|
8203
|
+
});
|
|
8204
|
+
|
|
8187
8205
|
const elementComponents = {
|
|
8188
8206
|
image: ElementImage,
|
|
8189
8207
|
slideshow: ElementSlideshow,
|
|
@@ -8197,6 +8215,7 @@ const elementComponents = {
|
|
|
8197
8215
|
chart: ElementChart,
|
|
8198
8216
|
legend: ElementLegend,
|
|
8199
8217
|
markdown: ElementMarkdown,
|
|
8218
|
+
uploader: ElementUploader,
|
|
8200
8219
|
};
|
|
8201
8220
|
|
|
8202
8221
|
const getElementValue = ({ getDefaultContainer, ...props }) => {
|