@evergis/react 4.0.29 → 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 +65 -21
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +65 -21
- 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
|
@@ -4443,6 +4443,10 @@ const applyQueryFilters = ({ parameters: configParameters, filters: configFilter
|
|
|
4443
4443
|
return result;
|
|
4444
4444
|
}
|
|
4445
4445
|
if (typeof configParameters[key] === "string" && configParameters[key].includes("{") && attributes?.length) {
|
|
4446
|
+
const exactAttr = attributes.find(({ attributeName }) => configParameters[key] === `{${attributeName}}`);
|
|
4447
|
+
if (exactAttr) {
|
|
4448
|
+
return { ...result, [key]: exactAttr.value ?? "" };
|
|
4449
|
+
}
|
|
4446
4450
|
let interpolated = configParameters[key];
|
|
4447
4451
|
attributes.forEach(({ attributeName, value: attrValue }) => {
|
|
4448
4452
|
interpolated = interpolated.replace(new RegExp(`\\{${attributeName}\\}`, "g"), attrValue?.toString() ?? "");
|
|
@@ -5401,6 +5405,7 @@ const usePythonTask = () => {
|
|
|
5401
5405
|
const [taskId, setTaskId] = React.useState(null);
|
|
5402
5406
|
const [subscriptionId, setSubscriptionId] = React.useState(null);
|
|
5403
5407
|
const [isLogDialogOpen, setIsLogDialogOpen] = React.useState(false);
|
|
5408
|
+
const [result, setResult] = React.useState(null);
|
|
5404
5409
|
const logRef = React.useRef(null);
|
|
5405
5410
|
const reset = React.useCallback(() => {
|
|
5406
5411
|
setStatus(api.RemoteTaskStatus.Unknown);
|
|
@@ -5409,6 +5414,7 @@ const usePythonTask = () => {
|
|
|
5409
5414
|
setExecutionTime(null);
|
|
5410
5415
|
setTaskId(null);
|
|
5411
5416
|
setSubscriptionId(null);
|
|
5417
|
+
setResult(null);
|
|
5412
5418
|
}, []);
|
|
5413
5419
|
const runTask = React.useCallback(async ({ resourceId, parameters, script, fileName, methodName, }) => {
|
|
5414
5420
|
reset();
|
|
@@ -5448,7 +5454,7 @@ const usePythonTask = () => {
|
|
|
5448
5454
|
});
|
|
5449
5455
|
setTaskId(newTaskId);
|
|
5450
5456
|
setSubscriptionId(newSubscriptionId);
|
|
5451
|
-
const onNotification = ({ data }) => {
|
|
5457
|
+
const onNotification = async ({ data }) => {
|
|
5452
5458
|
if (data?.taskId === newTaskId) {
|
|
5453
5459
|
setStatus(data.status);
|
|
5454
5460
|
setLog([logRef.current, data.log].filter(Boolean).join("\n"));
|
|
@@ -5464,10 +5470,14 @@ const usePythonTask = () => {
|
|
|
5464
5470
|
unsubscribeById(newSubscriptionId);
|
|
5465
5471
|
connection.off(SERVER_NOTIFICATION_EVENT.PythonProgressNotification, onNotification);
|
|
5466
5472
|
}
|
|
5473
|
+
if (data.status === api.RemoteTaskStatus.Completed) {
|
|
5474
|
+
const subTasks = await api$1.remoteTaskManager.get(newTaskId);
|
|
5475
|
+
setResult(subTasks?.[0]?.results ?? null);
|
|
5476
|
+
}
|
|
5467
5477
|
}
|
|
5468
5478
|
};
|
|
5469
5479
|
connection.on(SERVER_NOTIFICATION_EVENT.PythonProgressNotification, onNotification);
|
|
5470
|
-
}, [api$1, connection,
|
|
5480
|
+
}, [reset, api$1.remoteTaskManager, addSubscription, connection, t, unsubscribeById]);
|
|
5471
5481
|
const stopTask = React.useCallback(async () => {
|
|
5472
5482
|
await api$1.remoteTaskManager.stop(taskId);
|
|
5473
5483
|
reset();
|
|
@@ -5494,6 +5504,7 @@ const usePythonTask = () => {
|
|
|
5494
5504
|
executionTime,
|
|
5495
5505
|
isLogDialogOpen,
|
|
5496
5506
|
closeLog,
|
|
5507
|
+
result,
|
|
5497
5508
|
};
|
|
5498
5509
|
};
|
|
5499
5510
|
|
|
@@ -7464,14 +7475,35 @@ const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWai
|
|
|
7464
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] }) }));
|
|
7465
7476
|
};
|
|
7466
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
|
+
|
|
7467
7494
|
const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
7468
7495
|
const { t, ewktGeometry } = useGlobalContext();
|
|
7469
|
-
const { dataSources, filters: selectedFilters, attributes, layerInfo } = useWidgetContext(type);
|
|
7496
|
+
const { dataSources, filters: selectedFilters, attributes, layerInfo, changeFilters, } = useWidgetContext(type);
|
|
7470
7497
|
const { dataSources: projectDataSources } = useWidgetContext(exports.WidgetType.Dashboard);
|
|
7471
7498
|
const { currentPage } = useWidgetPage(type);
|
|
7472
|
-
const { taskId, runTask, stopTask, status, openLog, loading, isLogDialogOpen, closeLog, log } = usePythonTask();
|
|
7499
|
+
const { taskId, runTask, stopTask, status, openLog, loading, isLogDialogOpen, closeLog, log, result, } = usePythonTask();
|
|
7473
7500
|
const { options } = elementConfig || {};
|
|
7474
|
-
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]);
|
|
7475
7507
|
const onClick = React.useCallback(async () => {
|
|
7476
7508
|
if (taskId) {
|
|
7477
7509
|
await stopTask();
|
|
@@ -7518,6 +7550,12 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7518
7550
|
const getRenderContainerItem = useRenderContainerItem(type, renderElement);
|
|
7519
7551
|
const { options } = elementConfig || {};
|
|
7520
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]);
|
|
7521
7559
|
const renderContainer = React.useCallback((attributeName) => {
|
|
7522
7560
|
const control = controls?.find(({ targetAttributeName }) => targetAttributeName === attributeName);
|
|
7523
7561
|
const itemAttribute = attributes.find(item => item.attributeName === attributeName);
|
|
@@ -7550,7 +7588,7 @@ const EditGroupContainer = React.memo(({ type, elementConfig, renderElement }) =
|
|
|
7550
7588
|
expandedContainers,
|
|
7551
7589
|
]);
|
|
7552
7590
|
if (!controls?.length) {
|
|
7553
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children:
|
|
7591
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: filteredAttributes.map(({ attributeName }) => renderContainer(attributeName)) }));
|
|
7554
7592
|
}
|
|
7555
7593
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: controls.map(({ targetAttributeName }) => renderContainer(targetAttributeName)) }));
|
|
7556
7594
|
});
|
|
@@ -7581,6 +7619,16 @@ const useEditControl = (type, elementConfig) => {
|
|
|
7581
7619
|
[attributeName]: newValue,
|
|
7582
7620
|
});
|
|
7583
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]);
|
|
7584
7632
|
return React.useMemo(() => ({ control, value, dataSource, items, onChange }), [control, value, dataSource, items, onChange]);
|
|
7585
7633
|
};
|
|
7586
7634
|
|
|
@@ -7716,7 +7764,7 @@ const DefaultHeaderContainer = styled(uilibGl.Flex) `
|
|
|
7716
7764
|
position: relative;
|
|
7717
7765
|
flex-shrink: 0;
|
|
7718
7766
|
min-height: 8.175rem;
|
|
7719
|
-
margin-bottom: -
|
|
7767
|
+
margin-bottom: -0.75rem;
|
|
7720
7768
|
padding: 1.5rem 1.5rem 0;
|
|
7721
7769
|
border-top-left-radius: 0.5rem;
|
|
7722
7770
|
border-top-right-radius: 0.5rem;
|
|
@@ -9266,19 +9314,15 @@ const ElementUploader = React.memo(({ elementConfig, type }) => {
|
|
|
9266
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 }) }) }));
|
|
9267
9315
|
});
|
|
9268
9316
|
|
|
9269
|
-
const ModalIcon = styled(uilibGl.
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
:
|
|
9274
|
-
|
|
9275
|
-
color: ${({ theme: { palette } }) => palette.iconDisabled};
|
|
9276
|
-
transition: color ${uilibGl.transition.hover};
|
|
9277
|
-
}
|
|
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
|
+
}
|
|
9278
9323
|
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
}
|
|
9324
|
+
:hover:after {
|
|
9325
|
+
color: ${({ theme: { palette } }) => palette.icon};
|
|
9282
9326
|
}
|
|
9283
9327
|
`;
|
|
9284
9328
|
|
|
@@ -9388,7 +9432,7 @@ const ElementModal = React.memo(({ type = exports.WidgetType.Dashboard, elementC
|
|
|
9388
9432
|
return null;
|
|
9389
9433
|
const { options: modalOptions } = modalConfig;
|
|
9390
9434
|
const { title, maxWidth, minWidth, minHeight } = modalOptions || {};
|
|
9391
|
-
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 }) })) })] })] }));
|
|
9392
9436
|
});
|
|
9393
9437
|
|
|
9394
9438
|
const ElementLayerName = React.memo(({ type }) => {
|
|
@@ -9476,7 +9520,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
|
|
|
9476
9520
|
const isIdAttribute = attributeName === idAttribute;
|
|
9477
9521
|
const additionalProps = isIdAttribute
|
|
9478
9522
|
? {
|
|
9479
|
-
value: idValue,
|
|
9523
|
+
value: currentAttributes?.[attributeName] ?? idValue,
|
|
9480
9524
|
readOnly: true,
|
|
9481
9525
|
}
|
|
9482
9526
|
: {
|