@evergis/react 3.1.58 → 3.1.60

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.
@@ -1,5 +1,5 @@
1
- import { ConfigContainer, ConfigContainerChild, WidgetType } from '../types';
1
+ import { ConfigContainerChild, WidgetType } from '../types';
2
2
  export declare const useWidgetConfig: (type?: WidgetType) => {
3
- config: ConfigContainer;
3
+ config: any;
4
4
  pages: ConfigContainerChild[];
5
5
  };
@@ -12,6 +12,7 @@ export declare const useWidgetContext: (type?: WidgetType) => {
12
12
  attributes: import('../types').ClientFeatureAttribute[];
13
13
  feature: import('../../..').SelectedFeature;
14
14
  closeFeatureCard: VoidFunction;
15
+ containerIds: string[];
15
16
  components: {
16
17
  LayerItem?: import('react').FC<import('../..').LayerItemProps>;
17
18
  ProjectCatalogMenu?: import('react').FC;
@@ -31,6 +31,8 @@ export interface ConfigRelatedResource {
31
31
  resourceId: string;
32
32
  parameters: Record<string, unknown>;
33
33
  script?: string;
34
+ fileName?: string;
35
+ methodName?: string;
34
36
  }
35
37
  export interface BaseMapSettings {
36
38
  opacity?: number;
@@ -4,6 +4,7 @@ import { ConfigContainer, DashboardLayerPayload, DashboardState, LayerItemProps,
4
4
  import { LayerInfo } from '../../types';
5
5
  export type DashboardContextProps = PropsWithChildren<{
6
6
  config?: ConfigContainer;
7
+ containerIds?: string[];
7
8
  projectInfo?: ExtendedProjectInfoDc;
8
9
  updateProject?: (projectInfo: ExtendedProjectInfoDc) => void;
9
10
  pageIndex?: number;
@@ -1,8 +1,10 @@
1
1
  export declare const usePythonTask: () => {
2
- runTask: ({ resourceId, parameters, script, }: {
2
+ runTask: ({ resourceId, parameters, script, fileName, methodName, }: {
3
3
  resourceId: string;
4
4
  parameters: Record<string, unknown>;
5
- script: string;
5
+ script?: string;
6
+ fileName?: string;
7
+ methodName?: string;
6
8
  }) => Promise<void>;
7
9
  stopTask: () => Promise<void>;
8
10
  result: string;
package/dist/index.js CHANGED
@@ -3920,7 +3920,7 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
3920
3920
  };
3921
3921
 
3922
3922
  const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
3923
- const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
3923
+ const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
3924
3924
  const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
3925
3925
  return {
3926
3926
  projectInfo,
@@ -3933,6 +3933,7 @@ const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
3933
3933
  attributes,
3934
3934
  feature,
3935
3935
  closeFeatureCard,
3936
+ containerIds,
3936
3937
  components: dashboardComponents,
3937
3938
  config: type === exports.WidgetType.Dashboard ? dashboardConfig : featureConfig,
3938
3939
  isLoading: type === exports.WidgetType.Dashboard ? projectLoading : featureLoading,
@@ -4840,7 +4841,7 @@ const usePythonTask = () => {
4840
4841
  setTaskId(null);
4841
4842
  setSubscriptionId(null);
4842
4843
  }, []);
4843
- const runTask = React.useCallback(async ({ resourceId, parameters, script, }) => {
4844
+ const runTask = React.useCallback(async ({ resourceId, parameters, script, fileName, methodName, }) => {
4844
4845
  reset();
4845
4846
  const start = Date.now();
4846
4847
  let prototypeId = await api$1.remoteTaskManager.createTaskPrototype({
@@ -4854,6 +4855,8 @@ const usePythonTask = () => {
4854
4855
  resourceId,
4855
4856
  parameters,
4856
4857
  script,
4858
+ fileName,
4859
+ methodName,
4857
4860
  method: "pythonrunner/run",
4858
4861
  },
4859
4862
  },
@@ -6737,7 +6740,7 @@ const TaskContainer = React.memo(({ type, elementConfig }) => {
6737
6740
  const { options } = elementConfig || {};
6738
6741
  const { title, relatedResources, center, icon } = options || {};
6739
6742
  const onClick = React.useCallback(async () => {
6740
- await Promise.all(relatedResources.map(({ resourceId, parameters, script }) => {
6743
+ await Promise.all(relatedResources.map(({ resourceId, parameters, script, fileName, methodName }) => {
6741
6744
  const newParams = applyQueryFilters({
6742
6745
  parameters,
6743
6746
  dataSources,
@@ -6745,7 +6748,7 @@ const TaskContainer = React.memo(({ type, elementConfig }) => {
6745
6748
  filters: currentPage.filters,
6746
6749
  geometry: ewktGeometry,
6747
6750
  });
6748
- return runTask({ resourceId, parameters: newParams, script });
6751
+ return runTask({ resourceId, parameters: newParams, script, fileName, methodName });
6749
6752
  }));
6750
6753
  }, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters]);
6751
6754
  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: "Запуск" })] }) }));
@@ -9393,16 +9396,27 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
9393
9396
  };
9394
9397
 
9395
9398
  const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9396
- const { config: configProp, projectInfo, layerInfo } = useWidgetContext(type);
9399
+ const { config: configProp, containerIds, projectInfo, layerInfo } = useWidgetContext(type);
9397
9400
  const config = React.useMemo(() => {
9398
9401
  if (configProp) {
9399
9402
  return configProp;
9400
9403
  }
9401
- if (type === exports.WidgetType.Dashboard) {
9402
- return (projectInfo?.content?.dashboardConfiguration || {});
9404
+ const currentConfig = type === exports.WidgetType.Dashboard
9405
+ ? (projectInfo?.content?.dashboardConfiguration || {})
9406
+ : (layerInfo?.configuration?.cardConfiguration || {});
9407
+ if (containerIds?.length) {
9408
+ const elements = containerIds.map(id => findAnd.returnFound(currentConfig, { id })).filter(Boolean);
9409
+ if (!elements.length)
9410
+ return currentConfig;
9411
+ const newConfig = JSON.parse(JSON.stringify(currentConfig));
9412
+ const pages = getPagesFromConfig(newConfig);
9413
+ if (!pages?.[0]?.children)
9414
+ return currentConfig;
9415
+ pages[0].children = elements;
9416
+ return newConfig;
9403
9417
  }
9404
- return (layerInfo?.configuration?.cardConfiguration || {});
9405
- }, [configProp, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9418
+ return currentConfig;
9419
+ }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9406
9420
  const pages = React.useMemo(() => (getPagesFromConfig(config) || []), [config]);
9407
9421
  return {
9408
9422
  config,
@@ -10338,9 +10352,9 @@ const ExpandableTitle = React.memo(({ elementConfig, type, renderElement }) => {
10338
10352
  const { id, options, templateName, children } = elementConfig || {};
10339
10353
  const { expandable, fontColor, expanded, layerNames } = options || {};
10340
10354
  const titleElement = children?.find(item => item.id === "title");
10341
- const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
10342
10355
  if (!titleElement)
10343
10356
  return null;
10357
+ const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
10344
10358
  return (jsxRuntime.jsx(TitleContainer, { containerId: id, elementConfig: titleElement, templateName: templateName, layerNames: layerNames, fontColor: fontColor, expandable: expandable, expanded: expanded, type: type, isVisible: isVisible, renderElement: renderElement }));
10345
10359
  });
10346
10360