@evergis/react 4.0.30 → 4.0.31
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/TaskContainer/utils/buildFiltersFromResponse.d.ts +2 -0
- package/dist/components/Dashboard/elements/ElementModal/styled.d.ts +1 -1
- package/dist/components/Dashboard/types.d.ts +1 -0
- package/dist/hooks/task/usePythonTask.d.ts +1 -0
- package/dist/index.js +60 -20
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +60 -20
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ModalIcon: import('styled-components').StyledComponent<
|
|
1
|
+
export declare const ModalIcon: import('styled-components').StyledComponent<import('react').FC<import('@evergis/uilib-gl').IIconButtonProps>, any, {}, never>;
|
package/dist/index.js
CHANGED
|
@@ -5405,6 +5405,7 @@ const usePythonTask = () => {
|
|
|
5405
5405
|
const [taskId, setTaskId] = React.useState(null);
|
|
5406
5406
|
const [subscriptionId, setSubscriptionId] = React.useState(null);
|
|
5407
5407
|
const [isLogDialogOpen, setIsLogDialogOpen] = React.useState(false);
|
|
5408
|
+
const [result, setResult] = React.useState(null);
|
|
5408
5409
|
const logRef = React.useRef(null);
|
|
5409
5410
|
const reset = React.useCallback(() => {
|
|
5410
5411
|
setStatus(api.RemoteTaskStatus.Unknown);
|
|
@@ -5413,6 +5414,7 @@ const usePythonTask = () => {
|
|
|
5413
5414
|
setExecutionTime(null);
|
|
5414
5415
|
setTaskId(null);
|
|
5415
5416
|
setSubscriptionId(null);
|
|
5417
|
+
setResult(null);
|
|
5416
5418
|
}, []);
|
|
5417
5419
|
const runTask = React.useCallback(async ({ resourceId, parameters, script, fileName, methodName, }) => {
|
|
5418
5420
|
reset();
|
|
@@ -5452,7 +5454,7 @@ const usePythonTask = () => {
|
|
|
5452
5454
|
});
|
|
5453
5455
|
setTaskId(newTaskId);
|
|
5454
5456
|
setSubscriptionId(newSubscriptionId);
|
|
5455
|
-
const onNotification = ({ data }) => {
|
|
5457
|
+
const onNotification = async ({ data }) => {
|
|
5456
5458
|
if (data?.taskId === newTaskId) {
|
|
5457
5459
|
setStatus(data.status);
|
|
5458
5460
|
setLog([logRef.current, data.log].filter(Boolean).join("\n"));
|
|
@@ -5468,10 +5470,14 @@ const usePythonTask = () => {
|
|
|
5468
5470
|
unsubscribeById(newSubscriptionId);
|
|
5469
5471
|
connection.off(SERVER_NOTIFICATION_EVENT.PythonProgressNotification, onNotification);
|
|
5470
5472
|
}
|
|
5473
|
+
if (data.status === api.RemoteTaskStatus.Completed) {
|
|
5474
|
+
const subTasks = await api$1.remoteTaskManager.get(newTaskId);
|
|
5475
|
+
setResult(subTasks?.[0]?.results ?? null);
|
|
5476
|
+
}
|
|
5471
5477
|
}
|
|
5472
5478
|
};
|
|
5473
5479
|
connection.on(SERVER_NOTIFICATION_EVENT.PythonProgressNotification, onNotification);
|
|
5474
|
-
}, [api$1, connection,
|
|
5480
|
+
}, [reset, api$1.remoteTaskManager, addSubscription, connection, t, unsubscribeById]);
|
|
5475
5481
|
const stopTask = React.useCallback(async () => {
|
|
5476
5482
|
await api$1.remoteTaskManager.stop(taskId);
|
|
5477
5483
|
reset();
|
|
@@ -5498,6 +5504,7 @@ const usePythonTask = () => {
|
|
|
5498
5504
|
executionTime,
|
|
5499
5505
|
isLogDialogOpen,
|
|
5500
5506
|
closeLog,
|
|
5507
|
+
result,
|
|
5501
5508
|
};
|
|
5502
5509
|
};
|
|
5503
5510
|
|
|
@@ -7468,14 +7475,35 @@ const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWai
|
|
|
7468
7475
|
return (jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: uilibGl.darkTheme, children: jsxRuntime.jsxs(StyledButton, { status: status, statusColors: statusColors, disabled: isDisabled, themeName: themeName, onClick: onClick, children: [renderIcon, renderTitle] }) }));
|
|
7469
7476
|
};
|
|
7470
7477
|
|
|
7478
|
+
const buildFiltersFromResponse = (responseFilters, result) => {
|
|
7479
|
+
if (!responseFilters || !result)
|
|
7480
|
+
return null;
|
|
7481
|
+
const properties = result?.result?.features?.[0]?.properties;
|
|
7482
|
+
if (!properties)
|
|
7483
|
+
return null;
|
|
7484
|
+
const filters = Object.entries(responseFilters).reduce((acc, [filterName, token]) => {
|
|
7485
|
+
const attrName = typeof token === "string" && token.startsWith("%") ? token.slice(1) : token;
|
|
7486
|
+
const value = properties[attrName];
|
|
7487
|
+
if (value === undefined)
|
|
7488
|
+
return acc;
|
|
7489
|
+
return { ...acc, [filterName]: { value: value } };
|
|
7490
|
+
}, {});
|
|
7491
|
+
return Object.keys(filters).length ? filters : null;
|
|
7492
|
+
};
|
|
7493
|
+
|
|
7471
7494
|
const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
7472
7495
|
const { t, ewktGeometry } = useGlobalContext();
|
|
7473
|
-
const { dataSources, filters: selectedFilters, attributes, layerInfo } = useWidgetContext(type);
|
|
7496
|
+
const { dataSources, filters: selectedFilters, attributes, layerInfo, changeFilters, } = useWidgetContext(type);
|
|
7474
7497
|
const { dataSources: projectDataSources } = useWidgetContext(exports.WidgetType.Dashboard);
|
|
7475
7498
|
const { currentPage } = useWidgetPage(type);
|
|
7476
|
-
const { taskId, runTask, stopTask, status, openLog, loading, isLogDialogOpen, closeLog, log } = usePythonTask();
|
|
7499
|
+
const { taskId, runTask, stopTask, status, openLog, loading, isLogDialogOpen, closeLog, log, result, } = usePythonTask();
|
|
7477
7500
|
const { options } = elementConfig || {};
|
|
7478
|
-
const { title, relatedResources, center, icon, statusColors } = options || {};
|
|
7501
|
+
const { title, relatedResources, center, icon, statusColors, responseFilters } = options || {};
|
|
7502
|
+
React.useEffect(() => {
|
|
7503
|
+
const filtersToApply = buildFiltersFromResponse(responseFilters, result);
|
|
7504
|
+
if (filtersToApply)
|
|
7505
|
+
changeFilters(filtersToApply);
|
|
7506
|
+
}, [result, responseFilters, changeFilters]);
|
|
7479
7507
|
const onClick = React.useCallback(async () => {
|
|
7480
7508
|
if (taskId) {
|
|
7481
7509
|
await stopTask();
|
|
@@ -7522,6 +7550,12 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7522
7550
|
const getRenderContainerItem = useRenderContainerItem(type, renderElement);
|
|
7523
7551
|
const { options } = elementConfig || {};
|
|
7524
7552
|
const { controls } = options || {};
|
|
7553
|
+
const filteredAttributes = React.useMemo(() => {
|
|
7554
|
+
const { idAttribute } = layerInfo?.configuration?.attributesConfiguration || {};
|
|
7555
|
+
if (!idAttribute)
|
|
7556
|
+
return attributes;
|
|
7557
|
+
return attributes.filter(({ attributeName }) => attributeName !== idAttribute);
|
|
7558
|
+
}, [attributes, layerInfo?.configuration]);
|
|
7525
7559
|
const renderContainer = React.useCallback((attributeName) => {
|
|
7526
7560
|
const control = controls?.find(({ targetAttributeName }) => targetAttributeName === attributeName);
|
|
7527
7561
|
const itemAttribute = attributes.find(item => item.attributeName === attributeName);
|
|
@@ -7554,7 +7588,7 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7554
7588
|
expandedContainers,
|
|
7555
7589
|
]);
|
|
7556
7590
|
if (!controls?.length) {
|
|
7557
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children:
|
|
7591
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: filteredAttributes.map(({ attributeName }) => renderContainer(attributeName)) }));
|
|
7558
7592
|
}
|
|
7559
7593
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: controls.map(({ targetAttributeName }) => renderContainer(targetAttributeName)) }));
|
|
7560
7594
|
});
|
|
@@ -7585,6 +7619,16 @@ const useEditControl = (type, elementConfig) => {
|
|
|
7585
7619
|
[attributeName]: newValue,
|
|
7586
7620
|
});
|
|
7587
7621
|
}, [changeControls, attributeName]);
|
|
7622
|
+
React.useEffect(() => {
|
|
7623
|
+
if (control?.defaultValue === undefined)
|
|
7624
|
+
return;
|
|
7625
|
+
if (controls[attributeName] !== undefined)
|
|
7626
|
+
return;
|
|
7627
|
+
const hasAttributeValue = attributes.some(({ attributeName: name, value: attrValue }) => name === attributeName && attrValue !== undefined && attrValue !== null);
|
|
7628
|
+
if (hasAttributeValue)
|
|
7629
|
+
return;
|
|
7630
|
+
changeControls({ [attributeName]: control.defaultValue });
|
|
7631
|
+
}, [attributeName, attributes, changeControls, control?.defaultValue, controls]);
|
|
7588
7632
|
return React.useMemo(() => ({ control, value, dataSource, items, onChange }), [control, value, dataSource, items, onChange]);
|
|
7589
7633
|
};
|
|
7590
7634
|
|
|
@@ -7720,7 +7764,7 @@ const DefaultHeaderContainer = styled(uilibGl.Flex) `
|
|
|
7720
7764
|
position: relative;
|
|
7721
7765
|
flex-shrink: 0;
|
|
7722
7766
|
min-height: 8.175rem;
|
|
7723
|
-
margin-bottom: -
|
|
7767
|
+
margin-bottom: -0.75rem;
|
|
7724
7768
|
padding: 1.5rem 1.5rem 0;
|
|
7725
7769
|
border-top-left-radius: 0.5rem;
|
|
7726
7770
|
border-top-right-radius: 0.5rem;
|
|
@@ -9270,19 +9314,15 @@ const ElementUploader = React.memo(({ elementConfig, type }) => {
|
|
|
9270
9314
|
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 }) }) }));
|
|
9271
9315
|
});
|
|
9272
9316
|
|
|
9273
|
-
const ModalIcon = styled(uilibGl.
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
:
|
|
9278
|
-
|
|
9279
|
-
color: ${({ theme: { palette } }) => palette.iconDisabled};
|
|
9280
|
-
transition: color ${uilibGl.transition.hover};
|
|
9281
|
-
}
|
|
9317
|
+
const ModalIcon = styled(uilibGl.IconButton) `
|
|
9318
|
+
:after {
|
|
9319
|
+
font-size: 0.75rem;
|
|
9320
|
+
color: ${({ theme: { palette } }) => palette.iconDisabled};
|
|
9321
|
+
transition: color ${uilibGl.transition.hover};
|
|
9322
|
+
}
|
|
9282
9323
|
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
}
|
|
9324
|
+
:hover:after {
|
|
9325
|
+
color: ${({ theme: { palette } }) => palette.icon};
|
|
9286
9326
|
}
|
|
9287
9327
|
`;
|
|
9288
9328
|
|
|
@@ -9392,7 +9432,7 @@ const ElementModal = React.memo(({ type = exports.WidgetType.Dashboard, elementC
|
|
|
9392
9432
|
return null;
|
|
9393
9433
|
const { options: modalOptions } = modalConfig;
|
|
9394
9434
|
const { title, maxWidth, minWidth, minHeight } = modalOptions || {};
|
|
9395
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalIcon, { kind: icon || "new_window", onClick: handleOpen }), jsxRuntime.jsxs(uilibGl.Dialog, {
|
|
9435
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalIcon, { kind: icon || "new_window", onClick: handleOpen, children: title }), jsxRuntime.jsxs(uilibGl.Dialog, { maxWidth: maxWidth, minWidth: minWidth, minHeight: minHeight, isOpen: isOpen, modal: true, onCloseRequest: handleClose, style: { paddingBottom: "2rem" }, children: [jsxRuntime.jsx(uilibGl.DialogTitle, { children: jsxRuntime.jsxs(uilibGl.Flex, { justifyContent: "space-between", alignItems: "center", children: [!!title && jsxRuntime.jsx("span", { children: title }), jsxRuntime.jsx(uilibGl.IconButton, { kind: "close", onClick: handleClose })] }) }), jsxRuntime.jsx(uilibGl.DialogContent, { children: isLoading ? (jsxRuntime.jsx(DashboardLoading, {})) : (jsxRuntime.jsx(Container, { isColumn: true, noBorders: true, children: jsxRuntime.jsx(ContainerChildren, { type: type, items: modalContent, isMain: true, renderElement: renderElement }) })) })] })] }));
|
|
9396
9436
|
});
|
|
9397
9437
|
|
|
9398
9438
|
const ElementLayerName = React.memo(({ type }) => {
|