ydb-embedded-ui 6.29.1 → 6.29.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.d.ts +2 -1
  2. package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.js +2 -2
  3. package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.js.map +1 -1
  4. package/dist/components/FormattedBytes/FormattedBytes.d.ts +3 -2
  5. package/dist/components/FormattedBytes/FormattedBytes.js.map +1 -1
  6. package/dist/components/FormattedBytes/utils.d.ts +3 -2
  7. package/dist/components/FormattedBytes/utils.js.map +1 -1
  8. package/dist/components/PaginatedTable/PaginatedTable.d.ts +2 -2
  9. package/dist/components/PaginatedTable/PaginatedTable.js +10 -15
  10. package/dist/components/PaginatedTable/PaginatedTable.js.map +1 -1
  11. package/dist/components/PaginatedTable/PaginatedTable.scss +5 -1
  12. package/dist/components/PaginatedTable/TableChunk.d.ts +3 -3
  13. package/dist/components/PaginatedTable/TableChunk.js +7 -10
  14. package/dist/components/PaginatedTable/TableChunk.js.map +1 -1
  15. package/dist/components/PaginatedTable/constants.d.ts +1 -1
  16. package/dist/components/PaginatedTable/constants.js +1 -1
  17. package/dist/components/PaginatedTable/useScrollBasedChunks.d.ts +5 -3
  18. package/dist/components/PaginatedTable/useScrollBasedChunks.js +43 -23
  19. package/dist/components/PaginatedTable/useScrollBasedChunks.js.map +1 -1
  20. package/dist/components/PaginatedTable/utils.d.ts +18 -0
  21. package/dist/components/PaginatedTable/utils.js +27 -0
  22. package/dist/components/PaginatedTable/utils.js.map +1 -1
  23. package/dist/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.js +9 -2
  24. package/dist/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.js.map +1 -1
  25. package/dist/containers/Node/Node.js +2 -2
  26. package/dist/containers/Node/Node.js.map +1 -1
  27. package/dist/containers/Nodes/NodesWrapper.d.ts +1 -1
  28. package/dist/containers/Nodes/PaginatedNodes.d.ts +1 -1
  29. package/dist/containers/PDiskPage/PDiskPage.js +3 -2
  30. package/dist/containers/PDiskPage/PDiskPage.js.map +1 -1
  31. package/dist/containers/Storage/PaginatedStorage.d.ts +1 -1
  32. package/dist/containers/Storage/PaginatedStorageGroups.js +2 -2
  33. package/dist/containers/Storage/PaginatedStorageGroups.js.map +1 -1
  34. package/dist/containers/Storage/PaginatedStorageNodes.js +2 -2
  35. package/dist/containers/Storage/PaginatedStorageNodes.js.map +1 -1
  36. package/dist/containers/Storage/StorageGroups/PaginatedStorageGroupsTable.d.ts +1 -1
  37. package/dist/containers/Storage/StorageNodes/PaginatedStorageNodesTable.d.ts +1 -1
  38. package/dist/containers/Storage/StorageWrapper.d.ts +1 -1
  39. package/dist/containers/StorageGroupPage/StorageGroupPage.js +3 -2
  40. package/dist/containers/StorageGroupPage/StorageGroupPage.js.map +1 -1
  41. package/dist/containers/Tablets/TabletsTable.js +3 -3
  42. package/dist/containers/Tablets/TabletsTable.js.map +1 -1
  43. package/dist/containers/VDiskPage/VDiskPage.js +3 -2
  44. package/dist/containers/VDiskPage/VDiskPage.js.map +1 -1
  45. package/dist/services/settings.d.ts +1 -1
  46. package/dist/services/settings.js +1 -1
  47. package/dist/services/settings.js.map +1 -1
  48. package/dist/utils/bytesParsers/formatBytes.d.ts +2 -13
  49. package/dist/utils/bytesParsers/formatBytes.js.map +1 -1
  50. package/dist/utils/bytesParsers/i18n/en.json +4 -0
  51. package/dist/utils/bytesParsers/i18n/index.d.ts +1 -1
  52. package/dist/utils/bytesParsers/i18n/index.js +1 -2
  53. package/dist/utils/bytesParsers/i18n/index.js.map +1 -1
  54. package/dist/utils/dataFormatters/__test__/formatNumbers.test.d.ts +1 -0
  55. package/dist/utils/dataFormatters/__test__/formatNumbers.test.js +37 -0
  56. package/dist/utils/dataFormatters/__test__/formatNumbers.test.js.map +1 -0
  57. package/dist/utils/dataFormatters/__test__/formatStorageValues.test.js +1 -5
  58. package/dist/utils/dataFormatters/__test__/formatStorageValues.test.js.map +1 -1
  59. package/dist/utils/dataFormatters/common.d.ts +13 -0
  60. package/dist/utils/dataFormatters/common.js +25 -0
  61. package/dist/utils/dataFormatters/common.js.map +1 -0
  62. package/dist/utils/dataFormatters/dataFormatters.d.ts +3 -2
  63. package/dist/utils/dataFormatters/dataFormatters.js +9 -41
  64. package/dist/utils/dataFormatters/dataFormatters.js.map +1 -1
  65. package/dist/utils/dataFormatters/formatNumber.d.ts +43 -0
  66. package/dist/utils/dataFormatters/formatNumber.js +82 -0
  67. package/dist/utils/dataFormatters/formatNumber.js.map +1 -0
  68. package/package.json +1 -1
  69. package/dist/utils/bytesParsers/i18n/ru.json +0 -8
@@ -1,15 +1,16 @@
1
1
  import type { TVDiskID, TVSlotId } from '../../types/api/vdisk';
2
2
  import type { BytesSizes } from '../bytesParsers/formatBytes';
3
+ import type { Digits } from './formatNumber';
3
4
  export declare const formatBytes: (bytes?: string | number) => string;
4
5
  export declare const formatBps: (bytes?: string | number) => string;
5
6
  export declare const stringifyVdiskId: (id?: TVDiskID | TVSlotId) => string;
6
7
  export declare const formatUptime: (seconds: number) => string;
7
8
  export declare const formatMsToUptime: (ms?: number) => string | 0 | undefined;
8
- export declare const formatStorageValues: (value?: number, total?: number, size?: BytesSizes, delimiter?: string) => string[];
9
+ export declare function formatStorageValues(value?: number, total?: number, size?: BytesSizes, delimiter?: string, withValueLabel?: boolean): string[];
10
+ export declare function formatNumericValues(value?: number, total?: number, size?: Digits, delimiter?: string, withValueLabel?: boolean): string[];
9
11
  export declare const formatStorageValuesToGb: (value?: number, total?: number) => string[];
10
12
  export declare const formatStorageValuesToTb: (value?: number, total?: number) => string[];
11
13
  export declare const formatNumber: (number?: unknown) => string;
12
- export declare const formatNumberCustom: (number?: number) => string;
13
14
  export declare const formatPercent: (number?: unknown) => string;
14
15
  export declare const formatSecondsToHours: (seconds: number) => string;
15
16
  export declare const roundToPrecision: (value: number | string, precision?: number) => number;
@@ -3,6 +3,8 @@ import { formatBytes as formatBytesCustom, getSizeWithSignificantDigits, } from
3
3
  import { DAY_IN_SECONDS, HOUR_IN_SECONDS } from '../constants';
4
4
  import { configuredNumeral } from '../numeral';
5
5
  import { isNumeric } from '../utils';
6
+ import { formatValues } from './common';
7
+ import { formatNumberWithDigits, getNumberWithSignificantDigits } from './formatNumber';
6
8
  import i18n from './i18n';
7
9
  // Here you can't control displayed size and precision
8
10
  // If you need more custom format, use formatBytesCustom instead
@@ -34,39 +36,12 @@ export const formatUptime = (seconds) => {
34
36
  export const formatMsToUptime = (ms) => {
35
37
  return ms && formatUptime(ms / 1000);
36
38
  };
37
- export const formatStorageValues = (value, total, size, delimiter) => {
38
- let calculatedSize = getSizeWithSignificantDigits(Number(value), 0);
39
- let valueWithSizeLabel = true;
40
- let valuePrecision = 0;
41
- if (isNumeric(total)) {
42
- calculatedSize = getSizeWithSignificantDigits(Number(total), 0);
43
- valueWithSizeLabel = false;
44
- valuePrecision = 1;
45
- }
46
- let formattedValue = formatBytesCustom({
47
- value,
48
- withSizeLabel: valueWithSizeLabel,
49
- size: size || calculatedSize,
50
- precision: valuePrecision,
51
- });
52
- if (value && value > 0) {
53
- while (formattedValue === '0') {
54
- valuePrecision += 1;
55
- formattedValue = formatBytesCustom({
56
- value,
57
- withSizeLabel: valueWithSizeLabel,
58
- size: size || calculatedSize,
59
- precision: valuePrecision,
60
- });
61
- }
62
- }
63
- const formattedTotal = formatBytesCustom({
64
- value: total,
65
- size: size || calculatedSize,
66
- delimiter,
67
- });
68
- return [formattedValue, formattedTotal];
69
- };
39
+ export function formatStorageValues(value, total, size, delimiter, withValueLabel) {
40
+ return formatValues(formatBytesCustom, getSizeWithSignificantDigits, value, total, size, delimiter, withValueLabel);
41
+ }
42
+ export function formatNumericValues(value, total, size, delimiter, withValueLabel) {
43
+ return formatValues(formatNumberWithDigits, getNumberWithSignificantDigits, value, total, size, delimiter, withValueLabel);
44
+ }
70
45
  export const formatStorageValuesToGb = (value, total) => {
71
46
  return formatStorageValues(value, total, 'gb');
72
47
  };
@@ -80,19 +55,12 @@ export const formatNumber = (number) => {
80
55
  // "," in format is delimiter sign, not delimiter itself
81
56
  return configuredNumeral(number).format('0,0.[00000]');
82
57
  };
83
- export const formatNumberCustom = (number) => {
84
- return configuredNumeral(number).format('0.[0]a');
85
- };
86
58
  export const formatPercent = (number) => {
87
59
  if (!isNumeric(number)) {
88
60
  return '';
89
61
  }
90
62
  const configuredNumber = configuredNumeral(number);
91
- const numberValue = configuredNumber.value();
92
- let format = '0.[0]%';
93
- if (numberValue && numberValue < 0.001) {
94
- format = '0.[00]%';
95
- }
63
+ const format = '0%';
96
64
  return configuredNumber.format(format);
97
65
  };
98
66
  export const formatSecondsToHours = (seconds) => {
@@ -1 +1 @@
1
- {"version":3,"file":"dataFormatters.js","sourceRoot":"","sources":["../../../src/utils/dataFormatters/dataFormatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EACH,WAAW,IAAI,iBAAiB,EAChC,4BAA4B,GAC/B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAEnC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,sDAAsD;AACtD,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACnD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,qDAAqD;IACrD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAuB,EAAE,EAAE;IACjD,MAA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,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;AACL,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { FormatValuesArgs } from './common';
2
+ declare const sizes: {
3
+ thousand: {
4
+ value: number;
5
+ label: string;
6
+ };
7
+ million: {
8
+ value: number;
9
+ label: string;
10
+ };
11
+ billion: {
12
+ value: number;
13
+ label: string;
14
+ };
15
+ trillion: {
16
+ value: number;
17
+ label: string;
18
+ };
19
+ };
20
+ export type Digits = keyof typeof sizes;
21
+ /**
22
+ * This function is needed to keep more than 3 digits of the same size.
23
+ *
24
+ * @param significantDigits - number of digits above 3
25
+ * @returns size to format value to get required number of digits
26
+ *
27
+ * By default value converted to the next size when it's above 1000,
28
+ * so we have 900k and 1m. To extend it additional significantDigits could be set
29
+ *
30
+ * significantDigits value added above default 3
31
+ *
32
+ * significantDigits = 1 - 9 000k and 10m
33
+ *
34
+ * significantDigits = 2 - 90 000m and 100b
35
+ *
36
+ * significantDigits = 3 - 900 000b and 1000t
37
+ */
38
+ export declare const getNumberWithSignificantDigits: (value: number, significantDigits: number) => "thousand" | "million" | "billion" | "trillion";
39
+ /**
40
+ * @param significantDigits - number of digits above 3
41
+ */
42
+ export declare const formatNumberWithDigits: ({ value, size, withSizeLabel, significantDigits, delimiter, ...params }: FormatValuesArgs<Digits>) => string;
43
+ export {};
@@ -0,0 +1,82 @@
1
+ import i18n from '../bytesParsers/i18n';
2
+ import { UNBREAKABLE_GAP, isNumeric } from '../utils';
3
+ import { formatNumber, roundToPrecision } from './dataFormatters';
4
+ const sizes = {
5
+ thousand: {
6
+ value: 1000,
7
+ label: i18n('label_thousand'),
8
+ },
9
+ million: {
10
+ value: 1000000,
11
+ label: i18n('label_million'),
12
+ },
13
+ billion: {
14
+ value: 1000000000,
15
+ label: i18n('label_billion'),
16
+ },
17
+ trillion: {
18
+ value: 1000000000000,
19
+ label: i18n('label_trillion'),
20
+ },
21
+ };
22
+ /**
23
+ * This function is needed to keep more than 3 digits of the same size.
24
+ *
25
+ * @param significantDigits - number of digits above 3
26
+ * @returns size to format value to get required number of digits
27
+ *
28
+ * By default value converted to the next size when it's above 1000,
29
+ * so we have 900k and 1m. To extend it additional significantDigits could be set
30
+ *
31
+ * significantDigits value added above default 3
32
+ *
33
+ * significantDigits = 1 - 9 000k and 10m
34
+ *
35
+ * significantDigits = 2 - 90 000m and 100b
36
+ *
37
+ * significantDigits = 3 - 900 000b and 1000t
38
+ */
39
+ export const getNumberWithSignificantDigits = (value, significantDigits) => {
40
+ const multiplier = 10 ** significantDigits;
41
+ const thousandLevel = sizes.thousand.value * multiplier;
42
+ const millionLevel = sizes.million.value * multiplier;
43
+ const billionLevel = sizes.billion.value * multiplier;
44
+ const trillionLevel = sizes.trillion.value * multiplier;
45
+ let size = 'thousand';
46
+ if (value > thousandLevel) {
47
+ size = 'thousand';
48
+ }
49
+ if (value >= millionLevel) {
50
+ size = 'million';
51
+ }
52
+ if (value >= billionLevel) {
53
+ size = 'billion';
54
+ }
55
+ if (value >= trillionLevel) {
56
+ size = 'trillion';
57
+ }
58
+ return size;
59
+ };
60
+ const formatToSize = ({ value, size = 'thousand', precision = 0 }) => {
61
+ const result = roundToPrecision(Number(value) / sizes[size].value, precision);
62
+ return formatNumber(result);
63
+ };
64
+ const addSizeLabel = (result, size, delimiter = UNBREAKABLE_GAP) => {
65
+ return result + delimiter + sizes[size].label;
66
+ };
67
+ /**
68
+ * @param significantDigits - number of digits above 3
69
+ */
70
+ export const formatNumberWithDigits = ({ value, size, withSizeLabel = true, significantDigits = 0, delimiter, ...params }) => {
71
+ if (!isNumeric(value)) {
72
+ return '';
73
+ }
74
+ const numValue = Number(value);
75
+ const sizeToConvert = size !== null && size !== void 0 ? size : getNumberWithSignificantDigits(numValue, significantDigits);
76
+ const result = formatToSize({ value: numValue, size: sizeToConvert, ...params });
77
+ if (withSizeLabel) {
78
+ return addSizeLabel(result, sizeToConvert, delimiter);
79
+ }
80
+ return result;
81
+ };
82
+ //# sourceMappingURL=formatN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AAM,GAAG,YAAY,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,MAAM,EAAC,CAAC,CAAC;IAE/E,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "6.29.1",
3
+ "version": "6.29.3",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,8 +0,0 @@
1
- {
2
- "b": "Б",
3
- "kb": "КБ",
4
- "mb": "МБ",
5
- "gb": "ГБ",
6
- "tb": "ТБ",
7
- "perSecond": "/с"
8
- }