@evergis/react 3.1.68 → 3.1.69

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/react.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
- import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, DialogContent, WaitingButton, LinearProgress, H2, ThemeProvider, defaultTheme, Preview, Blank, Popover, Expander, darkTheme, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Dropdown, Checkbox, CircularProgress, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
2
+ import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, DialogContent, CircularProgress, darkTheme, LinearProgress, H2, ThemeProvider, defaultTheme, Preview, Blank, Popover, Expander, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Dropdown, Checkbox, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
3
3
  import { createContext, memo, useRef, useState, useEffect, useCallback, useContext, useMemo, Fragment } from 'react';
4
4
  import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
5
5
  import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
@@ -4888,11 +4888,12 @@ const usePythonTask = () => {
4888
4888
  setStatus(data.status);
4889
4889
  setLog([logRef.current, data.log].filter(Boolean).join("\n\n"));
4890
4890
  setExecutionTime(Date.now() - start);
4891
+ setLoading(false);
4891
4892
  setTaskId([RemoteTaskStatus.Completed, RemoteTaskStatus.Error].includes(data.status)
4892
- ? undefined
4893
+ ? null
4893
4894
  : newTaskId);
4894
4895
  setSubscriptionId([RemoteTaskStatus.Completed, RemoteTaskStatus.Error].includes(data.status)
4895
- ? undefined
4896
+ ? null
4896
4897
  : newSubscriptionId);
4897
4898
  if ([RemoteTaskStatus.Completed, RemoteTaskStatus.Error].includes(data.status)) {
4898
4899
  unsubscribeById(newSubscriptionId);
@@ -6760,38 +6761,26 @@ const UploadContainer = memo(({ type, elementConfig, renderElement }) => {
6760
6761
  return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && renderElement({ id: "uploader", wrap: false })] }));
6761
6762
  });
6762
6763
 
6763
- const StatusBadge = styled(Flex) `
6764
- margin-bottom: 1rem;
6765
- padding: 0.5rem 1rem;
6766
- background-color: ${({ $statusColor }) => $statusColor};
6764
+ const StatusBadge = styled(Chip) `
6765
+ background-color: ${({ bgColor }) => bgColor};
6767
6766
  color: ${({ theme }) => theme.palette.iconContrast};
6768
- border-radius: 0.25rem;
6769
- `;
6770
- styled.div `
6771
- flex: 1;
6772
- padding: 1rem;
6773
- background-color: ${({ theme }) => theme.palette.element};
6774
- color: ${({ theme }) => theme.palette.textPrimary};
6775
- font-family: monospace;
6776
- font-size: 0.875rem;
6777
- overflow: auto;
6778
- white-space: pre-wrap;
6779
- word-break: break-word;
6780
- border-radius: 0.25rem;
6781
- max-height: 31.25rem;
6782
6767
  `;
6783
6768
 
6784
6769
  const TerminalWrapper = styled.div `
6785
6770
  flex: 1;
6786
6771
  overflow: hidden;
6787
6772
  padding: 0;
6788
- margin: 1rem;
6773
+ margin: 0;
6789
6774
  box-sizing: border-box;
6790
6775
  min-height: 0;
6791
6776
 
6792
- & && .xterm-viewport {
6777
+ .xterm-viewport {
6793
6778
  overflow-y: auto;
6794
6779
  }
6780
+
6781
+ .xterm-screen .xterm-rows span {
6782
+ letter-spacing: 0 !important;
6783
+ }
6795
6784
  `;
6796
6785
 
6797
6786
  const LogTerminal = ({ log }) => {
@@ -6808,15 +6797,16 @@ const LogTerminal = ({ log }) => {
6808
6797
  const terminal = new Terminal({
6809
6798
  cursorBlink: false,
6810
6799
  fontSize: 12,
6811
- fontFamily: '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace',
6800
+ fontFamily: '"Nunito Sans", sans-serif',
6801
+ scrollback: 10000,
6802
+ convertEol: true,
6803
+ lineHeight: 1.5,
6804
+ letterSpacing: 0,
6812
6805
  theme: {
6813
- background: theme.palette.devBackgroundDark,
6806
+ background: theme.palette.background,
6814
6807
  foreground: theme.palette.textPrimary,
6815
6808
  cursor: theme.palette.primary,
6816
6809
  },
6817
- scrollback: 10000,
6818
- convertEol: true,
6819
- lineHeight: 1.5,
6820
6810
  });
6821
6811
  // Create fit addon
6822
6812
  const fitAddon = new FitAddon();
@@ -6900,9 +6890,9 @@ const STATUS_TRANSLATION_KEYS = {
6900
6890
  [RemoteTaskStatus.Error]: "taskError",
6901
6891
  [RemoteTaskStatus.Unknown]: "taskUnknown",
6902
6892
  };
6903
- const STATUS_DEFAULT_VALUES = {
6904
- [RemoteTaskStatus.Process]: "Остановить",
6905
- [RemoteTaskStatus.Completed]: "Завершено",
6893
+ const STATUS_TITLES = {
6894
+ [RemoteTaskStatus.Process]: "В процессе",
6895
+ [RemoteTaskStatus.Completed]: "Выполнено",
6906
6896
  [RemoteTaskStatus.Error]: "Ошибка",
6907
6897
  [RemoteTaskStatus.Unknown]: "Неизвестно",
6908
6898
  };
@@ -6912,21 +6902,30 @@ const STATUS_COLORS = {
6912
6902
  [RemoteTaskStatus.Error]: "#f44336",
6913
6903
  [RemoteTaskStatus.Unknown]: "#757575",
6914
6904
  };
6905
+ const STATUS_ICONS = {
6906
+ [RemoteTaskStatus.Process]: "loading_circle",
6907
+ [RemoteTaskStatus.Completed]: "success",
6908
+ [RemoteTaskStatus.Error]: "error",
6909
+ [RemoteTaskStatus.Unknown]: "play",
6910
+ };
6915
6911
 
6916
6912
  const LogDialog = ({ isOpen, onClose, logs, status, statusColors }) => {
6917
6913
  const { t } = useGlobalContext();
6918
- const getStatusText = useCallback((status) => {
6914
+ const getStatusTitle = useCallback((status) => {
6919
6915
  const translationKey = STATUS_TRANSLATION_KEYS[status] || STATUS_TRANSLATION_KEYS[RemoteTaskStatus.Unknown];
6920
- const defaultValue = STATUS_DEFAULT_VALUES[status] || STATUS_DEFAULT_VALUES[RemoteTaskStatus.Unknown];
6916
+ const defaultValue = STATUS_TITLES[status] || STATUS_TITLES[RemoteTaskStatus.Unknown];
6921
6917
  return t(translationKey, { ns: "dashboard", defaultValue });
6922
6918
  }, [t]);
6923
6919
  const getStatusColor = useCallback((status) => {
6924
6920
  return statusColors?.[status] || STATUS_COLORS[status] || STATUS_COLORS[RemoteTaskStatus.Unknown];
6925
6921
  }, [statusColors]);
6926
- return (jsxs(Dialog, { isOpen: isOpen, onCloseRequest: onClose, modal: true, maxWidth: "800px", minWidth: "600px", minHeight: "400px", children: [jsx(DialogTitle, { children: jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsx("span", { children: t("taskLogs", { ns: "dashboard", defaultValue: "Логи выполнения задачи" }) }), jsx(IconButton, { kind: "close", onClick: onClose })] }) }), jsx(DialogContent, { children: jsxs(Flex, { flexDirection: "column", height: "100%", marginBottom: "2rem", children: [jsxs(StatusBadge, { "$statusColor": getStatusColor(status), children: [t("taskStatus", { ns: "dashboard", defaultValue: "Статус" }), ": ", getStatusText(status)] }), jsx(LogTerminal, { log: logs || t("taskLogsEmpty", { ns: "dashboard", defaultValue: "Логи отсутствуют" }) })] }) })] }));
6922
+ return (jsxs(Dialog, { isOpen: isOpen, onCloseRequest: onClose, modal: true, maxWidth: "800px", minWidth: "600px", minHeight: "600px", children: [jsx(DialogTitle, { children: jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsxs(Flex, { alignItems: "center", children: [jsx(FlexSpan, { marginRight: "1rem", children: t("taskLogs", { ns: "dashboard", defaultValue: "Логи выполнения задачи" }) }), jsx(StatusBadge, { text: getStatusTitle(status), bgColor: getStatusColor(status) })] }), jsx(IconButton, { kind: "close", onClick: onClose })] }) }), jsx(DialogContent, { children: jsx(Flex, { flexDirection: "column", height: "100%", marginBottom: "2rem", children: jsx(LogTerminal, { log: logs || t("taskLogsEmpty", { ns: "dashboard", defaultValue: "Логи отсутствуют" }) }) }) })] }));
6927
6923
  };
6928
6924
 
6929
- const StatusWaitingButton = styled(WaitingButton) `
6925
+ const StyledButton = styled(FlatButton) `
6926
+ display: flex;
6927
+ align-items: center;
6928
+
6930
6929
  ${({ status = RemoteTaskStatus.Unknown, statusColors }) => !!statusColors?.[status] && css `
6931
6930
  transition: background-color ${transition.toggle};
6932
6931
  background-color: ${statusColors[status]};
@@ -6937,6 +6936,21 @@ const StatusWaitingButton = styled(WaitingButton) `
6937
6936
  `}
6938
6937
  `;
6939
6938
 
6939
+ const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWaiting, isDisabled, onClick }) => {
6940
+ const { t } = useGlobalContext();
6941
+ const renderTitle = useMemo(() => status === RemoteTaskStatus.Process
6942
+ ? t("", { ns: "dashboard", defaultValue: "Остановить" })
6943
+ : status === RemoteTaskStatus.Unknown ? title : STATUS_TITLES[status], [status, t, title]);
6944
+ const renderIcon = useMemo(() => {
6945
+ const iconComponent = isWaiting ? (jsx(CircularProgress, { diameter: 1, theme: darkTheme }))
6946
+ : status !== RemoteTaskStatus.Unknown
6947
+ ? jsx(Icon, { kind: STATUS_ICONS[status] })
6948
+ : jsx(Icon, { kind: icon });
6949
+ return (jsx(FlexSpan, { marginRight: renderTitle ? "0.5rem" : 0, children: iconComponent }));
6950
+ }, [icon, isWaiting, renderTitle, status]);
6951
+ return (jsxs(StyledButton, { status: status, statusColors: statusColors, disabled: isDisabled, onClick: onClick, children: [renderIcon, renderTitle] }));
6952
+ };
6953
+
6940
6954
  const TaskContainer = memo(({ type, elementConfig, renderElement }) => {
6941
6955
  const { t, ewktGeometry } = useGlobalContext();
6942
6956
  const { dataSources, filters: selectedFilters } = useWidgetContext(type);
@@ -6960,7 +6974,7 @@ const TaskContainer = memo(({ type, elementConfig, renderElement }) => {
6960
6974
  return runTask({ resourceId, parameters: newParams, script, fileName, methodName });
6961
6975
  }));
6962
6976
  }, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters, stopTask, taskId]);
6963
- return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxs(Flex, { justifyContent: center ? "center" : "flex-start", children: [jsxs(StatusWaitingButton, { primary: true, status: status, statusColors: statusColors, isWaiting: loading || !!taskId, disabled: !relatedResources?.length, onClick: onClick, children: [icon && jsx(FlexSpan, { marginRight: "0.5rem", children: jsx(Icon, { kind: icon }) }), title || t("run", { ns: "dashboard", defaultValue: "Запуск" })] }), !!taskId && (jsxs(Fragment$1, { children: [jsx(IconButton, { kind: "info", onClick: openLog }), jsx(LogDialog, { logs: log, status: status, statusColors: statusColors, isOpen: isLogDialogOpen, onClose: closeLog })] }))] })] }));
6977
+ return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxs(Flex, { justifyContent: center ? "center" : "flex-start", children: [jsx(StatusWaitingButton, { title: title || t("run", { ns: "dashboard", defaultValue: "Запуск" }), icon: icon, status: status, statusColors: statusColors, isWaiting: loading || !!taskId, isDisabled: !relatedResources?.length, onClick: onClick }), !!(log || taskId) && (jsxs(Fragment$1, { children: [jsx(IconButton, { kind: "info", onClick: openLog }), jsx(LogDialog, { logs: log, status: status, statusColors: statusColors, isOpen: isLogDialogOpen, onClose: closeLog })] }))] })] }));
6964
6978
  });
6965
6979
 
6966
6980
  const containerComponents = {