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