ydb-embedded-ui 4.9.0 → 4.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/BasicNodeViewer/BasicNodeViewer.tsx +7 -4
  3. package/dist/components/EntityStatus/EntityStatus.js +3 -1
  4. package/dist/components/FormattedBytes/FormattedBytes.tsx +10 -0
  5. package/dist/components/FormattedBytes/utils.tsx +13 -0
  6. package/dist/components/FullNodeViewer/FullNodeViewer.tsx +73 -0
  7. package/dist/components/InfoViewer/formatters/schema.ts +3 -1
  8. package/dist/components/InfoViewer/formatters/table.ts +6 -5
  9. package/dist/components/ProblemFilter/ProblemFilter.tsx +2 -2
  10. package/dist/components/SpeedMultiMeter/SpeedMultiMeter.tsx +4 -4
  11. package/dist/components/TableWithControlsLayout/TableWithControlsLayout.scss +32 -0
  12. package/dist/components/TableWithControlsLayout/TableWithControlsLayout.tsx +43 -0
  13. package/dist/components/TruncatedQuery/{TruncatedQuery.js → TruncatedQuery.tsx} +10 -8
  14. package/dist/containers/AsideNavigation/AsideNavigation.tsx +8 -8
  15. package/dist/containers/Cluster/Cluster.scss +4 -5
  16. package/dist/containers/Cluster/Cluster.tsx +13 -28
  17. package/dist/containers/Cluster/ClusterInfo/ClusterInfo.scss +4 -0
  18. package/dist/containers/Cluster/ClusterInfo/ClusterInfo.tsx +7 -0
  19. package/dist/containers/Cluster/ClusterInfoSkeleton/ClusterInfoSkeleton.tsx +1 -1
  20. package/dist/containers/Cluster/utils.tsx +0 -11
  21. package/dist/containers/Header/Header.scss +1 -5
  22. package/dist/containers/Node/Node.tsx +3 -3
  23. package/dist/containers/Nodes/Nodes.scss +1 -24
  24. package/dist/containers/Nodes/Nodes.tsx +30 -40
  25. package/dist/containers/Storage/PDisk/PDisk.tsx +2 -7
  26. package/dist/containers/Storage/Storage.scss +1 -14
  27. package/dist/containers/Storage/Storage.tsx +237 -0
  28. package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +45 -40
  29. package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +12 -16
  30. package/dist/containers/Storage/StorageTypeFilter/StorageTypeFilter.tsx +3 -1
  31. package/dist/containers/Storage/{StorageVisibleEntityFilter/StorageVisibleEntityFilter.tsx → StorageVisibleEntitiesFilter/StorageVisibleEntitiesFilter.tsx} +4 -2
  32. package/dist/containers/Storage/UsageFilter/UsageFilter.scss +1 -0
  33. package/dist/containers/Storage/UsageFilter/UsageFilter.tsx +17 -17
  34. package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +6 -2
  35. package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +3 -3
  36. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +7 -4
  37. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss +0 -15
  38. package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.tsx +10 -3
  39. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.scss +3 -12
  40. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +2 -7
  41. package/dist/containers/Tenant/{Preview → Query/Preview}/Preview.scss +1 -1
  42. package/dist/containers/Tenant/Query/Preview/Preview.tsx +121 -0
  43. package/dist/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx +1 -1
  44. package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.js +6 -8
  45. package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.tsx +1 -1
  46. package/dist/containers/Tenant/Query/i18n/en.json +9 -2
  47. package/dist/containers/Tenant/Query/i18n/ru.json +9 -2
  48. package/dist/containers/Tenants/Tenants.scss +1 -13
  49. package/dist/containers/Tenants/Tenants.tsx +262 -0
  50. package/dist/services/api.ts +8 -3
  51. package/dist/store/reducers/nodes/nodes.ts +4 -112
  52. package/dist/store/reducers/nodes/selectors.ts +74 -0
  53. package/dist/store/reducers/nodes/utils.ts +46 -0
  54. package/dist/store/reducers/partitions/types.ts +3 -3
  55. package/dist/store/reducers/settings/settings.ts +4 -2
  56. package/dist/store/reducers/settings/types.ts +3 -1
  57. package/dist/store/reducers/storage/selectors.ts +279 -0
  58. package/dist/store/reducers/storage/storage.ts +191 -0
  59. package/dist/store/reducers/storage/types.ts +80 -0
  60. package/dist/store/reducers/tenants/selectors.ts +46 -0
  61. package/dist/store/reducers/tenants/tenants.ts +21 -14
  62. package/dist/store/reducers/tenants/types.ts +20 -5
  63. package/dist/store/reducers/tenants/utils.ts +68 -0
  64. package/dist/types/additionalProps.ts +8 -0
  65. package/dist/types/api/compute.ts +27 -2
  66. package/dist/types/api/nodes.ts +12 -1
  67. package/dist/types/api/schema/cdcStream.ts +32 -0
  68. package/dist/types/api/schema/columnEntity.ts +138 -0
  69. package/dist/types/api/schema/externalDataSource.ts +24 -0
  70. package/dist/types/api/schema/externalTable.ts +14 -0
  71. package/dist/types/api/schema/index.ts +10 -0
  72. package/dist/types/api/schema/persQueueGroup.ts +191 -0
  73. package/dist/types/api/schema/schema.ts +299 -0
  74. package/dist/types/api/schema/shared.ts +42 -0
  75. package/dist/types/api/schema/table.ts +616 -0
  76. package/dist/types/api/schema/tableIndex.ts +33 -0
  77. package/dist/types/api/storage.ts +1 -1
  78. package/dist/types/store/topic.ts +3 -3
  79. package/dist/utils/bytesParsers/__test__/formatBytes.test.ts +38 -0
  80. package/dist/utils/bytesParsers/convertBytesObjectToSpeed.ts +2 -2
  81. package/dist/utils/bytesParsers/formatBytes.ts +132 -0
  82. package/dist/utils/bytesParsers/i18n/en.json +1 -0
  83. package/dist/utils/bytesParsers/i18n/ru.json +1 -0
  84. package/dist/utils/bytesParsers/index.ts +1 -1
  85. package/dist/utils/index.js +5 -10
  86. package/dist/utils/numeral.ts +8 -0
  87. package/package.json +1 -1
  88. package/dist/assets/icons/versions.svg +0 -3
  89. package/dist/components/FullNodeViewer/FullNodeViewer.js +0 -89
  90. package/dist/containers/Node/NodeOverview/NodeOverview.scss +0 -0
  91. package/dist/containers/Node/NodeOverview/NodeOverview.tsx +0 -21
  92. package/dist/containers/Storage/Storage.js +0 -350
  93. package/dist/containers/Tenant/Preview/Preview.js +0 -168
  94. package/dist/containers/Tenants/Tenants.js +0 -363
  95. package/dist/store/reducers/storage/storage.js +0 -404
  96. package/dist/types/api/schema.ts +0 -1326
  97. package/dist/utils/bytesParsers/formatBytesCustom.ts +0 -57
@@ -2,7 +2,7 @@ import type {MultipleWindowsStat} from '../../types/api/consumer';
2
2
 
3
3
  import {DAY_IN_SECONDS, HOUR_IN_SECONDS, MINUTE_IN_SECONDS} from '../constants';
4
4
 
5
- export interface IProcessSpeedStats {
5
+ export interface ProcessSpeedStats {
6
6
  perMinute: number;
7
7
  perHour: number;
8
8
  perDay: number;
@@ -14,7 +14,7 @@ export interface IProcessSpeedStats {
14
14
  */
15
15
  export const convertBytesObjectToSpeed = (
16
16
  data: MultipleWindowsStat | undefined,
17
- ): IProcessSpeedStats => {
17
+ ): ProcessSpeedStats => {
18
18
  return {
19
19
  perMinute:
20
20
  data && data.per_minute ? Math.round(Number(data.per_minute) / MINUTE_IN_SECONDS) : 0,
@@ -0,0 +1,132 @@
1
+ import {formatNumber} from '..';
2
+ import {GIGABYTE, KILOBYTE, MEGABYTE, TERABYTE} from '../constants';
3
+ import {isNumeric} from '../utils';
4
+
5
+ import i18n from './i18n';
6
+
7
+ const sizes = {
8
+ b: {
9
+ value: 1,
10
+ label: i18n('b'),
11
+ },
12
+ kb: {
13
+ value: KILOBYTE,
14
+ label: i18n('kb'),
15
+ },
16
+ mb: {
17
+ value: MEGABYTE,
18
+ label: i18n('mb'),
19
+ },
20
+ gb: {
21
+ value: GIGABYTE,
22
+ label: i18n('gb'),
23
+ },
24
+ tb: {
25
+ value: TERABYTE,
26
+ label: i18n('tb'),
27
+ },
28
+ };
29
+
30
+ export type BytesSizes = keyof typeof sizes;
31
+
32
+ /**
33
+ * This function is needed to keep more than 3 digits of the same size.
34
+ *
35
+ * @param significantDigits - number of digits above 3
36
+ * @returns size to format value to get required number of digits
37
+ *
38
+ * By default value converted to the next size when it's above 1000,
39
+ * so we have 900mb and 1gb. To extend it additional significantDigits could be set
40
+ *
41
+ * significantDigits value added above default 3
42
+ *
43
+ * significantDigits = 1 - 9 000 mb and 10 gb
44
+ *
45
+ * significantDigits = 2 - 90 000 mb and 100 gb
46
+ *
47
+ * significantDigits = 3 - 900 000 mb and 1000 gb
48
+ */
49
+ const getSizeWithSignificantDigits = (value: number, significantDigits: number) => {
50
+ const multiplier = 10 ** significantDigits;
51
+
52
+ const tbLevel = sizes.tb.value * multiplier;
53
+ const gbLevel = sizes.gb.value * multiplier;
54
+ const mbLevel = sizes.mb.value * multiplier;
55
+ const kbLevel = sizes.kb.value * multiplier;
56
+
57
+ let size: BytesSizes = 'b';
58
+
59
+ if (value >= kbLevel) {
60
+ size = 'kb';
61
+ }
62
+ if (value >= mbLevel) {
63
+ size = 'mb';
64
+ }
65
+ if (value >= gbLevel) {
66
+ size = 'gb';
67
+ }
68
+ if (value >= tbLevel) {
69
+ size = 'tb';
70
+ }
71
+
72
+ return size;
73
+ };
74
+
75
+ interface FormatToSizeArgs {
76
+ value: number;
77
+ size?: BytesSizes;
78
+ precision?: number;
79
+ }
80
+
81
+ const formatToSize = ({value, size = 'mb', precision = 0}: FormatToSizeArgs) => {
82
+ const result = (Number(value) / sizes[size].value).toFixed(precision);
83
+
84
+ return formatNumber(result);
85
+ };
86
+
87
+ const addSizeLabel = (result: string, size: BytesSizes) => {
88
+ return result + ` ${sizes[size].label}`;
89
+ };
90
+
91
+ const addSpeedLabel = (result: string, size: BytesSizes) => {
92
+ return addSizeLabel(result, size) + i18n('perSecond');
93
+ };
94
+
95
+ export type FormatBytesArgs = Omit<FormatToSizeArgs, 'value'> & {
96
+ value: number | string | undefined | null;
97
+ withSpeedLabel?: boolean;
98
+ withSizeLabel?: boolean;
99
+ significantDigits?: number;
100
+ };
101
+
102
+ /**
103
+ * @param significantDigits - number of digits above 3
104
+ */
105
+ export const formatBytes = ({
106
+ value,
107
+ size,
108
+ withSpeedLabel = false,
109
+ withSizeLabel = true,
110
+ significantDigits = 0,
111
+ ...params
112
+ }: FormatBytesArgs) => {
113
+ if (!isNumeric(value)) {
114
+ return '';
115
+ }
116
+
117
+ const numValue = Number(value);
118
+
119
+ const sizeToConvert = size ?? getSizeWithSignificantDigits(numValue, significantDigits);
120
+
121
+ const result = formatToSize({value: numValue, size: sizeToConvert, ...params});
122
+
123
+ if (withSpeedLabel) {
124
+ return addSpeedLabel(result, sizeToConvert);
125
+ }
126
+
127
+ if (withSizeLabel) {
128
+ return addSizeLabel(result, sizeToConvert);
129
+ }
130
+
131
+ return result;
132
+ };
@@ -3,5 +3,6 @@
3
3
  "kb": "KB",
4
4
  "mb": "MB",
5
5
  "gb": "GB",
6
+ "tb": "TB",
6
7
  "perSecond": "/s"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "kb": "КБ",
4
4
  "mb": "МБ",
5
5
  "gb": "ГБ",
6
+ "tb": "ТБ",
6
7
  "perSecond": "/с"
7
8
  }
@@ -1,2 +1,2 @@
1
- export * from './formatBytesCustom';
1
+ export * from './formatBytes';
2
2
  export * from './convertBytesObjectToSpeed';
@@ -1,13 +1,8 @@
1
- import numeral from 'numeral';
2
- import locales from 'numeral/locales'; // eslint-disable-line no-unused-vars
3
-
4
1
  import {dateTimeParse} from '@gravity-ui/date-utils';
5
2
 
6
- import {i18n} from './i18n';
7
3
  import {MEGABYTE, TERABYTE, GIGABYTE, DAY_IN_SECONDS} from './constants';
8
4
  import {isNumeric} from './utils';
9
-
10
- numeral.locale(i18n.lang);
5
+ import {configuredNumeral} from './numeral';
11
6
 
12
7
  // Here you can't control displayed size and precision
13
8
  // If you need more custom format, use formatBytesCustom instead
@@ -17,7 +12,7 @@ export const formatBytes = (bytes) => {
17
12
  }
18
13
 
19
14
  // by agreement, display byte values in decimal scale
20
- return numeral(bytes).format('0 b');
15
+ return configuredNumeral(bytes).format('0 b');
21
16
  };
22
17
 
23
18
  export const formatBps = (bytes) => {
@@ -45,7 +40,7 @@ export const formatUptime = (seconds) => {
45
40
  const days = Math.floor(seconds / DAY_IN_SECONDS);
46
41
  const remain = seconds % DAY_IN_SECONDS;
47
42
 
48
- const uptime = [days && `${days}d`, numeral(remain).format('00:00:00')]
43
+ const uptime = [days && `${days}d`, configuredNumeral(remain).format('00:00:00')]
49
44
  .filter(Boolean)
50
45
  .join(' ');
51
46
 
@@ -76,7 +71,7 @@ export const formatNumber = (number) => {
76
71
  return '';
77
72
  }
78
73
 
79
- return numeral(number).format();
74
+ return configuredNumeral(number).format();
80
75
  };
81
76
 
82
77
  export const formatCPU = (value) => {
@@ -84,7 +79,7 @@ export const formatCPU = (value) => {
84
79
  return '';
85
80
  }
86
81
 
87
- return numeral(value / 1000000).format('0.00');
82
+ return configuredNumeral(value / 1000000).format('0.00');
88
83
  };
89
84
 
90
85
  export const formatDateTime = (value) => {
@@ -0,0 +1,8 @@
1
+ import numeral from 'numeral';
2
+ import 'numeral/locales'; // Without this numeral will throw an error when using not 'en' locale
3
+
4
+ import {i18n} from './i18n';
5
+
6
+ numeral.locale(i18n.lang);
7
+
8
+ export const configuredNumeral = numeral;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "4.9.0",
3
+ "version": "4.10.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,3 +0,0 @@
1
- <svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M8.625 13.0156C8.625 13.2695 8.47266 13.498 8.24414 13.5742C8.04102 13.6758 7.76172 13.6504 7.58398 13.4727L5.55273 11.6445C5.42578 11.543 5.375 11.3652 5.375 11.1875C5.375 11.0352 5.42578 10.8574 5.55273 10.7559L7.58398 8.92773C7.76172 8.75 8.04102 8.72461 8.24414 8.82617C8.47266 8.90234 8.625 9.13086 8.625 9.35938V10.5781H9.03125C10.0215 10.5781 10.8594 9.76562 10.8594 8.75V4.61133C10.0215 4.35742 9.4375 3.57031 9.4375 2.65625C9.4375 1.53906 10.3262 0.625 11.4688 0.625C12.5859 0.625 13.5 1.53906 13.5 2.65625C13.5 3.57031 12.8906 4.35742 12.0781 4.61133V8.75C12.0781 10.4512 10.707 11.7969 9.03125 11.7969H8.625V13.0156ZM12.2812 2.65625C12.2812 2.22461 11.9004 1.84375 11.4688 1.84375C11.0117 1.84375 10.6562 2.22461 10.6562 2.65625C10.6562 3.11328 11.0117 3.46875 11.4688 3.46875C11.9004 3.46875 12.2812 3.11328 12.2812 2.65625ZM5.375 1.23438C5.375 1.00586 5.50195 0.777344 5.73047 0.701172C5.93359 0.599609 6.21289 0.625 6.39062 0.802734L8.42188 2.63086C8.54883 2.73242 8.625 2.91016 8.625 3.0625C8.625 3.24023 8.54883 3.41797 8.42188 3.51953L6.39062 5.34766C6.21289 5.52539 5.93359 5.55078 5.73047 5.44922C5.50195 5.37305 5.375 5.14453 5.375 4.89062V3.67188H4.96875C3.95312 3.67188 3.14062 4.50977 3.14062 5.5V9.66406C3.95312 9.91797 4.5625 10.7051 4.5625 11.5938C4.5625 12.7363 3.64844 13.625 2.53125 13.625C1.38867 13.625 0.5 12.7363 0.5 11.5938C0.5 10.7051 1.08398 9.91797 1.92188 9.66406V5.5C1.92188 3.82422 3.26758 2.45312 4.96875 2.45312H5.375V1.23438ZM1.71875 11.5938C1.71875 12.0508 2.07422 12.4062 2.53125 12.4062C2.96289 12.4062 3.34375 12.0508 3.34375 11.5938C3.34375 11.1621 2.96289 10.7812 2.53125 10.7812C2.07422 10.7812 1.71875 11.1621 1.71875 11.5938Z"/>
3
- </svg>
@@ -1,89 +0,0 @@
1
- import React from 'react';
2
- import cn from 'bem-cn-lite';
3
- import PropTypes from 'prop-types';
4
-
5
- import InfoViewer from '../InfoViewer/InfoViewer';
6
- import ProgressViewer from '../ProgressViewer/ProgressViewer';
7
- import {PoolUsage} from '../PoolUsage/PoolUsage';
8
-
9
- import {LOAD_AVERAGE_TIME_INTERVALS} from '../../utils/constants';
10
- import {calcUptime} from '../../utils';
11
-
12
- import './FullNodeViewer.scss';
13
-
14
- const b = cn('full-node-viewer');
15
-
16
- class FullNodeViewer extends React.Component {
17
- static propTypes = {
18
- className: PropTypes.string,
19
- node: PropTypes.object.isRequired,
20
- backend: PropTypes.string,
21
- singleClusterMode: PropTypes.bool,
22
- };
23
-
24
- static defaultProps = {
25
- className: '',
26
- };
27
-
28
- render() {
29
- const {node, className} = this.props;
30
-
31
- const endpointsInfo = node.Endpoints?.map(({Name, Address}) => ({
32
- label: Name,
33
- value: Address,
34
- }));
35
-
36
- const commonInfo = [
37
- {label: 'Version', value: node.Version},
38
- {label: 'Uptime', value: calcUptime(node.StartTime)},
39
- {label: 'DC', value: node.DataCenterDescription},
40
- {label: 'Rack', value: node.Rack},
41
- ];
42
-
43
- const averageInfo = node.LoadAverage.map((load, loadIndex) => ({
44
- label: LOAD_AVERAGE_TIME_INTERVALS[`${loadIndex}`],
45
- value: <ProgressViewer value={load} percents={true} colorizeProgress={true} />,
46
- }));
47
-
48
- return (
49
- <div className={`${b()} ${className}`}>
50
- {node ? (
51
- <div className={b('common-info')}>
52
- <div>
53
- <div className={b('section-title')}>Pools</div>
54
- <div className={b('section', {pools: true})}>
55
- {node.PoolStats.map((pool, poolIndex) => (
56
- <PoolUsage key={poolIndex} data={pool} />
57
- ))}
58
- </div>
59
- </div>
60
-
61
- {endpointsInfo && endpointsInfo.length && (
62
- <InfoViewer
63
- title="Endpoints"
64
- className={b('section')}
65
- info={endpointsInfo}
66
- />
67
- )}
68
-
69
- <InfoViewer
70
- title="Common info"
71
- className={b('section')}
72
- info={commonInfo}
73
- />
74
-
75
- <InfoViewer
76
- title="Load average"
77
- className={b('section', {average: true})}
78
- info={averageInfo}
79
- />
80
- </div>
81
- ) : (
82
- <div className="error">no data</div>
83
- )}
84
- </div>
85
- );
86
- }
87
- }
88
-
89
- export default FullNodeViewer;
@@ -1,21 +0,0 @@
1
-
2
- //@ts-ignore
3
- import FullNodeViewer from '../../../components/FullNodeViewer/FullNodeViewer';
4
- import {backend} from '../../../store';
5
-
6
- interface NodeOverviewProps {
7
- node: any;
8
- className?: string;
9
- }
10
-
11
- function NodeOverview({node, className}: NodeOverviewProps) {
12
- return (
13
- <FullNodeViewer
14
- node={node}
15
- backend={backend}
16
- className={className}
17
- />
18
- );
19
- }
20
-
21
- export default NodeOverview;