ydb-embedded-ui 4.17.0 → 4.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/components/FullNodeViewer/FullNodeViewer.scss +1 -1
  3. package/dist/components/FullNodeViewer/FullNodeViewer.tsx +15 -6
  4. package/dist/components/InfoViewer/formatters/common.ts +1 -1
  5. package/dist/components/InfoViewer/formatters/pqGroup.ts +1 -1
  6. package/dist/components/InfoViewer/formatters/table.ts +6 -1
  7. package/dist/components/ProgressViewer/ProgressViewer.tsx +105 -0
  8. package/dist/components/TooltipsContent/TabletTooltipContent/TabletTooltipContent.tsx +1 -1
  9. package/dist/containers/AsideNavigation/AsideNavigation.tsx +3 -1
  10. package/dist/containers/Authentication/Authentication.tsx +14 -4
  11. package/dist/containers/Cluster/ClusterInfo/ClusterInfo.tsx +2 -2
  12. package/dist/containers/Heatmap/Heatmap.tsx +1 -1
  13. package/dist/containers/Heatmap/Histogram/Histogram.js +1 -1
  14. package/dist/containers/Node/NodeStructure/Pdisk.tsx +2 -2
  15. package/dist/containers/Node/NodeStructure/Vdisk.tsx +5 -2
  16. package/dist/containers/Nodes/getNodesColumns.tsx +3 -2
  17. package/dist/containers/Storage/PDisk/PDisk.tsx +1 -1
  18. package/dist/containers/Storage/PDiskPopup/PDiskPopup.tsx +2 -2
  19. package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +3 -232
  20. package/dist/containers/Storage/StorageGroups/getStorageGroupsColumns.tsx +278 -0
  21. package/dist/containers/Storage/VDisk/VDisk.tsx +1 -1
  22. package/dist/containers/Storage/VDiskPopup/VDiskPopup.tsx +1 -1
  23. package/dist/containers/Tablet/TabletInfo/TabletInfo.tsx +1 -1
  24. package/dist/containers/Tablet/TabletTable/TabletTable.tsx +1 -1
  25. package/dist/containers/Tenant/Diagnostics/Consumers/TopicStats/ConsumersTopicStats.tsx +1 -1
  26. package/dist/containers/Tenant/Diagnostics/Consumers/columns/columns.tsx +1 -1
  27. package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.tsx +3 -3
  28. package/dist/containers/Tenant/Diagnostics/Overview/TableInfo/prepareTableInfo.ts +1 -1
  29. package/dist/containers/Tenant/Diagnostics/Overview/TopicStats/TopicStats.tsx +1 -1
  30. package/dist/containers/Tenant/Diagnostics/Partitions/columns/columns.tsx +1 -1
  31. package/dist/containers/Tenant/Diagnostics/TenantOverview/MetricsCards/MetricsCards.tsx +2 -3
  32. package/dist/containers/Tenant/Diagnostics/TenantOverview/OldTenantOverview.tsx +1 -1
  33. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx +22 -6
  34. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.scss +41 -0
  35. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx +68 -0
  36. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopGroups.tsx +76 -0
  37. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx +105 -0
  38. package/dist/containers/Tenant/Diagnostics/TenantOverview/i18n/en.json +2 -0
  39. package/dist/containers/Tenant/Diagnostics/TenantOverview/i18n/ru.json +2 -0
  40. package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.tsx +1 -1
  41. package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.tsx +1 -1
  42. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +1 -1
  43. package/dist/containers/Tenants/Tenants.tsx +5 -1
  44. package/dist/containers/UserSettings/i18n/en.json +1 -1
  45. package/dist/containers/UserSettings/i18n/ru.json +1 -1
  46. package/dist/containers/UserSettings/settings.ts +2 -2
  47. package/dist/containers/Versions/NodesTable/NodesTable.tsx +3 -2
  48. package/dist/services/api.ts +1 -1
  49. package/dist/store/reducers/clusterNodes/clusterNodes.tsx +1 -1
  50. package/dist/store/reducers/index.ts +4 -0
  51. package/dist/store/reducers/node/selectors.ts +1 -1
  52. package/dist/store/reducers/nodes/selectors.ts +1 -1
  53. package/dist/store/reducers/nodes/types.ts +1 -1
  54. package/dist/store/reducers/nodes/utils.ts +1 -1
  55. package/dist/store/reducers/settings/settings.ts +4 -4
  56. package/dist/store/reducers/storage/types.ts +1 -1
  57. package/dist/store/reducers/storage/utils.ts +21 -12
  58. package/dist/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts +93 -0
  59. package/dist/store/reducers/tenantOverview/executeTopTables/types.ts +14 -0
  60. package/dist/store/reducers/tenantOverview/topStorageGroups/topStorageGroups.ts +98 -0
  61. package/dist/store/reducers/tenantOverview/topStorageGroups/types.ts +29 -0
  62. package/dist/store/reducers/tenantOverview/topStorageGroups/utils.ts +20 -0
  63. package/dist/store/reducers/tenants/utils.ts +30 -20
  64. package/dist/styles/constants.scss +4 -0
  65. package/dist/types/additionalProps.ts +1 -1
  66. package/dist/types/api/storage.ts +1 -1
  67. package/dist/types/api/tenant.ts +21 -8
  68. package/dist/types/api/vdisk.ts +1 -1
  69. package/dist/utils/bytesParsers/__test__/formatBytes.test.ts +10 -1
  70. package/dist/utils/bytesParsers/formatBytes.ts +3 -3
  71. package/dist/utils/constants.ts +10 -1
  72. package/dist/utils/dataFormatters/__test__/roundToSignificant.test.ts +22 -0
  73. package/dist/utils/dataFormatters/dataFormatters.ts +150 -0
  74. package/dist/utils/dataFormatters/i18n/en.json +3 -0
  75. package/dist/utils/dataFormatters/i18n/ru.json +3 -0
  76. package/dist/utils/index.js +0 -102
  77. package/package.json +1 -1
  78. package/dist/components/ProgressViewer/ProgressViewer.js +0 -92
  79. package/dist/utils/formatCPU/formatCPU.ts +0 -20
  80. package/dist/utils/formatCPU/i18n/en.json +0 -3
  81. package/dist/utils/formatCPU/i18n/ru.json +0 -3
  82. /package/dist/utils/{formatCPU → dataFormatters}/i18n/index.ts +0 -0
@@ -0,0 +1,150 @@
1
+ import {dateTimeParse} from '@gravity-ui/date-utils';
2
+
3
+ import type {TVDiskID, TVSlotId} from '../../types/api/vdisk';
4
+ import {DAY_IN_SECONDS, GIGABYTE} from '../constants';
5
+ import {configuredNumeral} from '../numeral';
6
+ import {isNumeric} from '../utils';
7
+ import {
8
+ type BytesSizes,
9
+ formatBytes as formatBytesCustom,
10
+ getSizeWithSignificantDigits,
11
+ } from '../bytesParsers/formatBytes';
12
+
13
+ import i18n from './i18n';
14
+
15
+ // Here you can't control displayed size and precision
16
+ // If you need more custom format, use formatBytesCustom instead
17
+ export const formatBytes = (bytes?: string | number) => {
18
+ if (!isNumeric(bytes)) {
19
+ return '';
20
+ }
21
+
22
+ // by agreement, display byte values in decimal scale
23
+ return configuredNumeral(bytes).format('0 b');
24
+ };
25
+
26
+ export const formatBps = (bytes?: string | number) => {
27
+ const formattedBytes = formatBytes(bytes);
28
+
29
+ if (!formattedBytes) {
30
+ return '';
31
+ }
32
+
33
+ return formattedBytes + '/s';
34
+ };
35
+
36
+ export const formatBytesToGigabyte = (bytes: number | string) => {
37
+ return `${Math.floor(Number(bytes) / GIGABYTE)} GB`;
38
+ };
39
+
40
+ export const stringifyVdiskId = (id?: TVDiskID | TVSlotId) => {
41
+ return id ? Object.values(id).join('-') : '';
42
+ };
43
+
44
+ export const getPDiskId = (info: {NodeId?: number; PDiskId?: number}) => {
45
+ return info.NodeId && info.PDiskId ? `${info.NodeId}-${info.PDiskId}` : undefined;
46
+ };
47
+
48
+ export const formatUptime = (seconds: number) => {
49
+ const days = Math.floor(seconds / DAY_IN_SECONDS);
50
+ const remain = seconds % DAY_IN_SECONDS;
51
+
52
+ const uptime = [days && `${days}d`, configuredNumeral(remain).format('00:00:00')]
53
+ .filter(Boolean)
54
+ .join(' ');
55
+
56
+ return uptime;
57
+ };
58
+
59
+ export const formatMsToUptime = (ms?: number) => {
60
+ return ms && formatUptime(ms / 1000);
61
+ };
62
+
63
+ export const formatStorageValues = (value?: number, total?: number, size?: BytesSizes) => {
64
+ let calculatedSize = getSizeWithSignificantDigits(Number(value), 0);
65
+ let valueWithSizeLabel = true;
66
+ let valuePrecision = 0;
67
+
68
+ if (isNumeric(total)) {
69
+ calculatedSize = getSizeWithSignificantDigits(Number(total), 0);
70
+ valueWithSizeLabel = false;
71
+ valuePrecision = 1;
72
+ }
73
+
74
+ const formattedValue = formatBytesCustom({
75
+ value,
76
+ withSizeLabel: valueWithSizeLabel,
77
+ size: size || calculatedSize,
78
+ precision: valuePrecision,
79
+ });
80
+ const formattedTotal = formatBytesCustom({value: total, size: size || calculatedSize});
81
+
82
+ return [formattedValue, formattedTotal];
83
+ };
84
+
85
+ export const formatStorageValuesToGb = (value?: number, total?: number) => {
86
+ return formatStorageValues(value, total, 'gb');
87
+ };
88
+
89
+ export const formatNumber = (number?: unknown) => {
90
+ if (!isNumeric(number)) {
91
+ return '';
92
+ }
93
+
94
+ return configuredNumeral(number).format('0,0.[00000]');
95
+ };
96
+
97
+ export const roundToPrecision = (value: number | string, precision = 0) => {
98
+ let [digits] = String(value).split('.');
99
+ if (Number(value) < 1) {
100
+ digits = '';
101
+ }
102
+ if (digits.length >= precision) {
103
+ return Math.round(Number(value));
104
+ }
105
+ return Number(Number(value).toFixed(precision - digits.length));
106
+ };
107
+
108
+ const normalizeCPU = (value: number | string) => {
109
+ const rawCores = Number(value) / 1000000;
110
+
111
+ return roundToPrecision(rawCores, 3);
112
+ };
113
+
114
+ export const formatCPU = (value?: number | string) => {
115
+ if (value === undefined) {
116
+ return undefined;
117
+ }
118
+
119
+ return configuredNumeral(normalizeCPU(value)).format('0.[000]');
120
+ };
121
+
122
+ export const formatCPUWithLabel = (value?: number) => {
123
+ if (value === undefined) {
124
+ return undefined;
125
+ }
126
+ const cores = normalizeCPU(value);
127
+ const localizedCores = configuredNumeral(cores).format('0.[000]');
128
+
129
+ return `${localizedCores} ${i18n('format-cpu.cores', {count: cores})}`;
130
+ };
131
+
132
+ export const formatDateTime = (value?: number | string) => {
133
+ if (!isNumeric(value)) {
134
+ return '';
135
+ }
136
+
137
+ const formattedData = dateTimeParse(Number(value))?.format('YYYY-MM-DD HH:mm');
138
+
139
+ return Number(value) > 0 && formattedData ? formattedData : 'N/A';
140
+ };
141
+
142
+ export const calcUptimeInSeconds = (milliseconds: number | string) => {
143
+ const currentDate = new Date();
144
+ const diff = currentDate.getTime() - Number(milliseconds);
145
+ return diff <= 0 ? 0 : diff / 1000;
146
+ };
147
+
148
+ export const calcUptime = (milliseconds?: number | string) => {
149
+ return formatUptime(calcUptimeInSeconds(Number(milliseconds)));
150
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "format-cpu.cores": ["core", "cores", "cores", "cores"]
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "format-cpu.cores": ["ядро", "ядра", "ядер", "ядер"]
3
+ }
@@ -1,105 +1,3 @@
1
- import {dateTimeParse} from '@gravity-ui/date-utils';
2
-
3
- import {MEGABYTE, TERABYTE, GIGABYTE, DAY_IN_SECONDS} from './constants';
4
- import {isNumeric} from './utils';
5
- import {configuredNumeral} from './numeral';
6
-
7
- // Here you can't control displayed size and precision
8
- // If you need more custom format, use formatBytesCustom instead
9
- export const formatBytes = (bytes) => {
10
- if (!isNumeric(bytes)) {
11
- return '';
12
- }
13
-
14
- // by agreement, display byte values in decimal scale
15
- return configuredNumeral(bytes).format('0 b');
16
- };
17
-
18
- export const formatBps = (bytes) => {
19
- const formattedBytes = formatBytes(bytes);
20
-
21
- if (!formattedBytes) {
22
- return '';
23
- }
24
-
25
- return formattedBytes + '/s';
26
- };
27
-
28
- export const formatBytesToGigabyte = (bytes) => {
29
- return `${Math.floor(bytes / GIGABYTE)} GB`;
30
- };
31
-
32
- export const stringifyVdiskId = (id) => {
33
- return Object.values(id).join('-');
34
- };
35
- export const getPDiskId = (info) => {
36
- return `${info.NodeId}-${info.PDiskId}`;
37
- };
38
-
39
- export const formatUptime = (seconds) => {
40
- const days = Math.floor(seconds / DAY_IN_SECONDS);
41
- const remain = seconds % DAY_IN_SECONDS;
42
-
43
- const uptime = [days && `${days}d`, configuredNumeral(remain).format('00:00:00')]
44
- .filter(Boolean)
45
- .join(' ');
46
-
47
- return uptime;
48
- };
49
-
50
- export const formatMsToUptime = (ms) => {
51
- return formatUptime(ms / 1000);
52
- };
53
-
54
- export const formatIOPS = (value, capacity) => {
55
- return [Math.floor(value), Math.floor(capacity) + ' IOPS'];
56
- };
57
-
58
- export const formatStorageValues = (value, total) => {
59
- return [Math.floor(value / TERABYTE), `${Math.floor(total / TERABYTE)} TB`];
60
- };
61
- export const formatStorageValuesToGb = (value, total) => {
62
- return [Math.floor(value / 1000000000), `${Math.floor(total / 1000000000)} GB`];
63
- };
64
-
65
- export const formatThroughput = (value, total) => {
66
- return [(value / MEGABYTE).toFixed(2), (total / MEGABYTE).toFixed(1) + ' MB/s'];
67
- };
68
-
69
- export const formatNumber = (number) => {
70
- if (!isNumeric(number)) {
71
- return '';
72
- }
73
-
74
- return configuredNumeral(number).format();
75
- };
76
-
77
- export const formatCPU = (value) => {
78
- if (!isNumeric(value)) {
79
- return '';
80
- }
81
-
82
- return configuredNumeral(value / 1000000).format('0.00');
83
- };
84
-
85
- export const formatDateTime = (value) => {
86
- if (!isNumeric(value)) {
87
- return '';
88
- }
89
-
90
- return value > 0 ? dateTimeParse(Number(value)).format('YYYY-MM-DD HH:mm') : 'N/A';
91
- };
92
-
93
- export const calcUptimeInSeconds = (milliseconds) => {
94
- const currentDate = new Date();
95
- const diff = currentDate - Number(milliseconds);
96
- return diff <= 0 ? 0 : diff / 1000;
97
- };
98
-
99
- export const calcUptime = (milliseconds) => {
100
- return formatUptime(calcUptimeInSeconds(milliseconds));
101
- };
102
-
103
1
  // determine how many nodes have status Connected "true"
104
2
  export const getConnectedNodesCount = (nodeStateInfo) => {
105
3
  return nodeStateInfo?.reduce((acc, item) => (item.Connected ? acc + 1 : acc), 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "4.17.0",
3
+ "version": "4.19.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,92 +0,0 @@
1
- import React from 'react';
2
- import cn from 'bem-cn-lite';
3
- import './ProgressViewer.scss';
4
- import PropTypes from 'prop-types';
5
- const b = cn('progress-viewer');
6
- /*
7
-
8
- Описание props:
9
- 1) value - величина прогресса
10
- 2) capacity - предельно возможный прогресс
11
- 3) formatValues - функция форматирования value и capacity
12
- 4) percents - отображать ли заполненость в виде процентов
13
- 5) className - кастомный класс
14
- 6) colorizeProgress - менять ли цвет полосы прогресса в зависимости от его величины
15
- 7) inverseColorize - инвертировать ли цвета при разукрашивании прогресса
16
- */
17
- export class ProgressViewer extends React.Component {
18
- static propTypes = {
19
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
20
- capacity: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
21
- formatValues: PropTypes.func,
22
- percents: PropTypes.bool,
23
- className: PropTypes.string,
24
- size: PropTypes.oneOf(['xs', 's', 'ns', 'm', 'n', 'l', 'head']),
25
- colorizeProgress: PropTypes.bool,
26
- inverseColorize: PropTypes.bool,
27
- };
28
-
29
- static defaultProps = {
30
- size: 'xs',
31
- colorizeProgress: false,
32
- capacity: 100,
33
- inverseColorize: false,
34
- };
35
-
36
- render() {
37
- const {
38
- value,
39
- capacity,
40
- formatValues,
41
- percents,
42
- size,
43
- className,
44
- colorizeProgress,
45
- inverseColorize,
46
- } = this.props;
47
-
48
- let fillWidth = Math.round((parseFloat(value) / parseFloat(capacity)) * 100);
49
- fillWidth = fillWidth > 100 ? 100 : fillWidth;
50
-
51
- let valueText = Math.round(value),
52
- capacityText = capacity,
53
- divider = '/';
54
- if (formatValues) {
55
- [valueText, capacityText] = formatValues(value, capacity);
56
- } else if (percents) {
57
- valueText = fillWidth + '%';
58
- capacityText = '';
59
- divider = '';
60
- }
61
-
62
- let bg = inverseColorize ? 'scarlet' : 'apple';
63
- if (colorizeProgress) {
64
- if (fillWidth > 60 && fillWidth <= 80) {
65
- bg = 'saffron';
66
- } else if (fillWidth > 80) {
67
- bg = inverseColorize ? 'apple' : 'scarlet';
68
- }
69
- }
70
-
71
- const lineStyle = {
72
- width: fillWidth + '%',
73
- };
74
-
75
- const text = fillWidth > 60 ? 'contrast0' : 'contrast70';
76
-
77
- if (!isNaN(fillWidth)) {
78
- return (
79
- <div className={b({size}, className)}>
80
- <div className={b('line', {bg})} style={lineStyle}></div>
81
- <span className={b('text', {text})}>
82
- {`${valueText} ${divider} ${capacityText}`}
83
- </span>
84
- </div>
85
- );
86
- }
87
-
88
- return <div className={`${b({size})} ${className} error`}>no data</div>;
89
- }
90
- }
91
-
92
- export default ProgressViewer;
@@ -1,20 +0,0 @@
1
- import {configuredNumeral} from '../numeral';
2
- import i18n from './i18n';
3
-
4
- export const formatCPU = (value?: number) => {
5
- if (value === undefined) {
6
- return undefined;
7
- }
8
-
9
- const rawCores = value / 1000000;
10
- let cores = rawCores.toPrecision(3);
11
- if (rawCores >= 1000) {
12
- cores = rawCores.toFixed();
13
- }
14
- if (rawCores < 0.001) {
15
- cores = '0';
16
- }
17
- const localizedCores = configuredNumeral(Number(cores)).format('0.[000]');
18
-
19
- return `${localizedCores} ${i18n('cores', {count: cores})}`;
20
- };
@@ -1,3 +0,0 @@
1
- {
2
- "cores": ["core", "cores", "cores", "cores"]
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "cores": ["ядро", "ядра", "ядер", "ядер"]
3
- }