ydb-embedded-ui 6.29.0 → 6.29.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.d.ts +2 -1
- package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.js +2 -2
- package/dist/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.js.map +1 -1
- package/dist/components/EntityStatus/EntityStatus.js +1 -1
- package/dist/components/EntityStatus/EntityStatus.js.map +1 -1
- package/dist/components/EntityStatus/EntityStatus.scss +3 -1
- package/dist/components/FormattedBytes/FormattedBytes.d.ts +3 -2
- package/dist/components/FormattedBytes/FormattedBytes.js.map +1 -1
- package/dist/components/FormattedBytes/utils.d.ts +3 -2
- package/dist/components/FormattedBytes/utils.js.map +1 -1
- package/dist/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.js +9 -2
- package/dist/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.js.map +1 -1
- package/dist/containers/Tablets/TabletsTable.js +3 -3
- package/dist/containers/Tablets/TabletsTable.js.map +1 -1
- package/dist/containers/Tenant/Schema/SchemaViewer/prepareData.js +4 -4
- package/dist/containers/Tenant/Schema/SchemaViewer/prepareData.js.map +1 -1
- package/dist/utils/bytesParsers/formatBytes.d.ts +2 -13
- package/dist/utils/bytesParsers/formatBytes.js.map +1 -1
- package/dist/utils/bytesParsers/i18n/en.json +4 -0
- package/dist/utils/bytesParsers/i18n/index.d.ts +1 -1
- package/dist/utils/bytesParsers/i18n/index.js +1 -2
- package/dist/utils/bytesParsers/i18n/index.js.map +1 -1
- package/dist/utils/dataFormatters/__test__/formatNumbers.test.d.ts +1 -0
- package/dist/utils/dataFormatters/__test__/formatNumbers.test.js +37 -0
- package/dist/utils/dataFormatters/__test__/formatNumbers.test.js.map +1 -0
- package/dist/utils/dataFormatters/__test__/formatStorageValues.test.js +1 -5
- package/dist/utils/dataFormatters/__test__/formatStorageValues.test.js.map +1 -1
- package/dist/utils/dataFormatters/common.d.ts +13 -0
- package/dist/utils/dataFormatters/common.js +25 -0
- package/dist/utils/dataFormatters/common.js.map +1 -0
- package/dist/utils/dataFormatters/dataFormatters.d.ts +3 -2
- package/dist/utils/dataFormatters/dataFormatters.js +9 -41
- package/dist/utils/dataFormatters/dataFormatters.js.map +1 -1
- package/dist/utils/dataFormatters/formatNumber.d.ts +43 -0
- package/dist/utils/dataFormatters/formatNumber.js +82 -0
- package/dist/utils/dataFormatters/formatNumber.js.map +1 -0
- package/package.json +1 -1
- package/dist/utils/bytesParsers/i18n/ru.json +0 -8
@@ -9,11 +9,12 @@ interface ButtonWithConfirmDialogProps<T, K> {
|
|
9
9
|
retryButtonText?: string;
|
10
10
|
buttonDisabled?: ButtonProps['disabled'];
|
11
11
|
buttonView?: ButtonProps['view'];
|
12
|
+
buttonTitle?: ButtonProps['title'];
|
12
13
|
buttonClassName?: ButtonProps['className'];
|
13
14
|
withPopover?: boolean;
|
14
15
|
popoverContent?: PopoverProps['content'];
|
15
16
|
popoverPlacement?: PopoverProps['placement'];
|
16
17
|
popoverDisabled?: PopoverProps['disabled'];
|
17
18
|
}
|
18
|
-
export declare function ButtonWithConfirmDialog<T, K>({ children, onConfirmAction, onConfirmActionSuccess, dialogHeader, dialogText, retryButtonText, buttonDisabled, buttonView, buttonClassName, withPopover, popoverContent, popoverPlacement, popoverDisabled, }: ButtonWithConfirmDialogProps<T, K>): import("react/jsx-runtime").JSX.Element;
|
19
|
+
export declare function ButtonWithConfirmDialog<T, K>({ children, onConfirmAction, onConfirmActionSuccess, dialogHeader, dialogText, retryButtonText, buttonDisabled, buttonView, buttonTitle, buttonClassName, withPopover, popoverContent, popoverPlacement, popoverDisabled, }: ButtonWithConfirmDialogProps<T, K>): import("react/jsx-runtime").JSX.Element;
|
19
20
|
export {};
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
3
3
|
import { Button, Popover } from '@gravity-ui/uikit';
|
4
4
|
import { CriticalActionDialog } from '../CriticalActionDialog/CriticalActionDialog';
|
5
5
|
import { isErrorWithRetry } from '../CriticalActionDialog/utils';
|
6
|
-
export function ButtonWithConfirmDialog({ children, onConfirmAction, onConfirmActionSuccess, dialogHeader, dialogText, retryButtonText, buttonDisabled = false, buttonView = 'action', buttonClassName, withPopover = false, popoverContent, popoverPlacement = 'right', popoverDisabled = true, }) {
|
6
|
+
export function ButtonWithConfirmDialog({ children, onConfirmAction, onConfirmActionSuccess, dialogHeader, dialogText, retryButtonText, buttonDisabled = false, buttonView = 'action', buttonTitle, buttonClassName, withPopover = false, popoverContent, popoverPlacement = 'right', popoverDisabled = true, }) {
|
7
7
|
const [isConfirmDialogVisible, setIsConfirmDialogVisible] = React.useState(false);
|
8
8
|
const [buttonLoading, setButtonLoading] = React.useState(false);
|
9
9
|
const [withRetry, setWithRetry] = React.useState(false);
|
@@ -25,7 +25,7 @@ export function ButtonWithConfirmDialog({ children, onConfirmAction, onConfirmAc
|
|
25
25
|
setButtonLoading(false);
|
26
26
|
};
|
27
27
|
const renderButton = () => {
|
28
|
-
return (_jsx(Button, { onClick: () => setIsConfirmDialogVisible(true), view: buttonView, disabled: buttonDisabled, loading: !buttonDisabled && buttonLoading, className: buttonClassName, children: children }));
|
28
|
+
return (_jsx(Button, { onClick: () => setIsConfirmDialogVisible(true), view: buttonView, disabled: buttonDisabled, loading: !buttonDisabled && buttonLoading, className: buttonClassName, title: buttonTitle, children: children }));
|
29
29
|
};
|
30
30
|
const renderContent = () => {
|
31
31
|
if (withPopover) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ButtonWithConfirmDialog.js","sourceRoot":"","sources":["../../../src/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;
|
1
|
+
{"version":3,"file":"ButtonWithConfirmDialog.js","sourceRoot":"","sources":["../../../src/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAmB/D,MAAM,UAAU,uBAAuB,CAAO,EAC1C,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,cAAc,GAAG,KAAK,EACtB,UAAU,GAAG,QAAQ,EACrB,WAAW,EACX,eAAe,EACf,WAAW,GAAG,KAAK,EACnB,cAAc,EACd,gBAAgB,GAAG,OAAO,EAC1B,eAAe,GAAG,IAAI,GACW;IACjC,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,MAAM,mBAAmB,GAAG,KAAK,EAAE,OAAiB,EAAE,EAAE;QACpD,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,MAAM,0BAA0B,GAAG,KAAK,IAAI,EAAE;QAC1C,YAAY,CAAC,KAAK,CAAC,CAAC;QAEpB,IAAI,CAAC;YACD,MAAM,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,EAAI,CAAA,CAAC;QACrC,CAAC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
|
@@ -25,7 +25,7 @@ export function EntityStatus({ status = EFlag.Grey, name = '', label, path, icon
|
|
25
25
|
}
|
26
26
|
return name && _jsx("span", { className: b('name'), children: name });
|
27
27
|
};
|
28
|
-
return (_jsxs("div", { className: b(null, className), title: name, children: [iconPath ? renderStatusLink(iconPath) : renderIcon(), label && (_jsx("span", { title: label, className: b('label', { size, state: status.toLowerCase() }), children: label })), (path || name) && (_jsxs("div", { className: b('wrapper'), children: [_jsx("span", { className: b('link', { 'with-left-trim': withLeftTrim }), children: renderLink() }), hasClipboardButton && (_jsx("div", { className: b('controls-wrapper', {
|
28
|
+
return (_jsxs("div", { className: b(null, className), title: name, children: [iconPath ? renderStatusLink(iconPath) : renderIcon(), label && (_jsx("span", { title: label, className: b('label', { size, state: status.toLowerCase() }), children: label })), (path || name) && (_jsxs("div", { className: b('wrapper', { 'with-button': hasClipboardButton }), children: [_jsx("span", { className: b('link', { 'with-left-trim': withLeftTrim }), children: renderLink() }), hasClipboardButton && (_jsx("div", { className: b('controls-wrapper', {
|
29
29
|
visible: clipboardButtonAlwaysVisible,
|
30
30
|
}), children: _jsx(ClipboardButton, { text: name, size: "xs", view: "normal", className: b('clipboard-button', {
|
31
31
|
visible: clipboardButtonAlwaysVisible,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EntityStatus.js","sourceRoot":"","sources":["../../../src/components/EntityStatus/EntityStatus.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAE,IAAI,IAAI,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAC,EAAE,EAAC,MAAM,gBAAgB,CAAC;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAGpD,OAAO,qBAAqB,CAAC;AAE7B,MAAM,CAAC,GAAG,EAAE,CAAC,eA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W,EAAE,EAAC,CAAC,YACzE,KAAK,GACH,CACV,EACA,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CACf,eAAK,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAC,aAAa,EAAE,kBAAkB,EAAC,CAAC,aAC7D,eAAM,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAC,gBAAgB,EAAE,YAAY,EAAC,CAAC,YACvD,UAAU,EAAE,GACV,EACN,kBAAkB,IAAI,CACnB,cACI,SAAS,EAAE,CAAC,CAAC,kBAAkB,EAAE;4BAC7B,OAAO,EAAE,4BAA4B;yBACxC,CAAC,YAEF,KAAC,eAAe,IACZ,IAAI,EAAE,IAAI,EACV,IAAI,EAAC,IAAI,EACT,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,CAAC,CAAC,kBAAkB,EAAE;gCAC7B,OAAO,EAAE,4BAA4B;6BACxC,CAAC,GACJ,GACA,CACT,IACC,CACT,IACC,CACT,CAAC;AACN,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
type
|
1
|
+
import type { BytesSizes } from '../../utils/bytesParsers';
|
2
|
+
import type { FormatValuesArgs } from '../../utils/dataFormatters/common';
|
3
|
+
type FormattedBytesProps = FormatValuesArgs<BytesSizes>;
|
3
4
|
export declare const FormattedBytes: ({ value, withSpeedLabel, ...params }: FormattedBytesProps) => import("react/jsx-runtime").JSX.Element;
|
4
5
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FormattedBytes.js","sourceRoot":"","sources":["../../../src/components/FormattedBytes/FormattedBytes.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"FormattedBytes.js","sourceRoot":"","sources":["../../../src/components/FormattedBytes/FormattedBytes.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAKrD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAC,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,EAAsB,EAAE,EAAE;IACtF,MAAM,SAAS,GAAG,WAAW,CAAC,EAAC,KAAK,EAAE,cAAc,EAAE,GAAG,MAAM,EAAC,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,WAAW,CAAC,EAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC;IAE9D,OAAO,eAAM,KAAK,EAAE,KAAK,YAAG,SAAS,GAAQ,CAAC;AAClD,CAAC,CAAC"}
|
@@ -1,2 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { BytesSizes } from '../../utils/bytesParsers';
|
2
|
+
import type { FormatValuesArgs } from '../../utils/dataFormatters/common';
|
3
|
+
export declare const toFormattedSize: (value: number | string | undefined, params?: Omit<FormatValuesArgs<BytesSizes>, "value">) => import("react/jsx-runtime").JSX.Element | null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/FormattedBytes/utils.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/FormattedBytes/utils.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,KAAkC,EAClC,MAAoD,EACtD,EAAE;IACA,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,KAAM,MAAM,GAAI,CAAC;AAC9E,CAAC,CAAC"}
|
@@ -1,11 +1,18 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { DoughnutMetrics } from '../../../../components/DoughnutMetrics/DoughnutMetrics';
|
3
|
-
import {
|
3
|
+
import { formatNumber, formatNumericValues } from '../../../../utils/dataFormatters/dataFormatters';
|
4
4
|
import i18n from '../../i18n';
|
5
5
|
import { useDiagramValues } from '../utils';
|
6
6
|
import { ClusterMetricsCardDoughnut } from './ClusterMetricsCard';
|
7
7
|
function formatCoresLegend({ value, capacity }) {
|
8
|
-
|
8
|
+
let formatted = [];
|
9
|
+
if (capacity < 10000) {
|
10
|
+
formatted = [formatNumber(Math.round(value)), formatNumber(Math.round(capacity))];
|
11
|
+
}
|
12
|
+
else {
|
13
|
+
formatted = formatNumericValues(value, capacity, undefined, '', true);
|
14
|
+
}
|
15
|
+
return `${formatted[0]} / ${formatted[1]}\n${i18n('context_cores')}`;
|
9
16
|
}
|
10
17
|
export function ClusterMetricsCores({ value, capacity, ...rest }) {
|
11
18
|
const { status, percents, legend, fill } = useDiagramValues({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ClusterMetricsCores.js","sourceRoot":"","sources":["../../../../../src/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,wDAAwD,CAAC;AACvF,OAAO,EAAC,
|
1
|
+
{"version":3,"file":"ClusterMetricsCores.js","sourceRoot":"","sources":["../../../../../src/containers/Cluster/ClusterDashboard/components/ClusterMetricsCores.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,wDAAwD,CAAC;AACvF,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAC,MAAM,iDAAiD,CAAC;AAClG,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAC,0BAA0B,EAAC,MAAM,sBAAsB,CAAC;AAIhE,SAAS,iBAAiB,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAoC;IAC3E,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAM,EAAE,CAAC;QACpB,SAAS,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;SAAM,CAAC;QACJ,SAAS,GAAG,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAA2B;IACpF,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,GAAG,gBAAgB,CAAC;QACtD,KAAK;QACL,QAAQ;QACR,eAAe,EAAE,iBAAiB;QAClC,GAAG,IAAI;KACV,CAAC,CAAC;IACH,OAAO,CACH,MAAC,0BAA0B,IAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,aACjF,KAAC,eAAe,CAAC,MAAM,cAAE,MAAM,GAA0B,EACzD,KAAC,eAAe,CAAC,KAAK,cAAE,QAAQ,GAAyB,IAChC,CAChC,CAAC;AACN,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import {
|
2
|
+
import { ArrowRotateLeft } from '@gravity-ui/icons';
|
3
3
|
import { Icon, Text } from '@gravity-ui/uikit';
|
4
4
|
import { ButtonWithConfirmDialog } from '../../components/ButtonWithConfirmDialog/ButtonWithConfirmDialog';
|
5
5
|
import { EntityStatus } from '../../components/EntityStatus/EntityStatus';
|
@@ -112,9 +112,9 @@ function TabletActions(tablet) {
|
|
112
112
|
if (!id) {
|
113
113
|
return null;
|
114
114
|
}
|
115
|
-
return (_jsx(ButtonWithConfirmDialog, { buttonView: "outlined", dialogHeader: i18n('dialog.kill-header'), dialogText: i18n('dialog.kill-text'), onConfirmAction: () => {
|
115
|
+
return (_jsx(ButtonWithConfirmDialog, { buttonView: "outlined", buttonTitle: i18n('dialog.kill-header'), dialogHeader: i18n('dialog.kill-header'), dialogText: i18n('dialog.kill-text'), onConfirmAction: () => {
|
116
116
|
return killTablet({ id }).unwrap();
|
117
|
-
}, buttonDisabled: isDisabledRestart || !isUserAllowedToMakeChanges, withPopover: true, popoverContent: i18n('controls.kill-not-allowed'), popoverDisabled: isUserAllowedToMakeChanges, children: _jsx(Icon, { data:
|
117
|
+
}, buttonDisabled: isDisabledRestart || !isUserAllowedToMakeChanges, withPopover: true, popoverContent: i18n('controls.kill-not-allowed'), popoverDisabled: isUserAllowedToMakeChanges, children: _jsx(Icon, { data: ArrowRotateLeft }) }));
|
118
118
|
}
|
119
119
|
export function TabletsTable({ database, tablets, className, loading }) {
|
120
120
|
if (loading) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabletsTable.js","sourceRoot":"","sources":["../../../src/containers/Tablets/TabletsTable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
1
|
+
{"version":3,"file":"TabletsTable.js","sourceRoot":"","sources":["../../../src/containers/Tablets/TabletsTable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAC,uBAAuB,EAAC,MAAM,kEAAkE,CAAC;AACzG,OAAO,EAAC,YAAY,EAAC,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,mBA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,oBAAoB,CAAC,EACvC,YAAY,EAAE,IAAI,CAAC,oBAAoB,CAAC,EACxC,UAAU,EAAE,IAAI,CAAC,kBAAkB,CAAC,EACpC,eAAe,EAAE,GAAG,EAAE;YAClB,OAAO,UAAU,CAAC,EAAC,EAAE,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC,EACD,cAAc,EAAE,iBAAiB,IAAI,CAAC,0BAA0B,EAChE,WAAW,QACX,cAAc,EAAE,IAAI,CAAC,2BAA2B,CAAC,EACjD,eAAe,EAAE,0BAA0B,YAE3C,KAAC,IAAI,IAAC,IAAI,EAAE,eAAe,GAAI,GACT,CAC7B,CAAC;AACN,CAAC;AAWD,MAAM,UAAU,YAAY,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAoB;IACnF,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,KAAC,aAAa,KAAG,CAAC;IAC7B,CAAC;IACD,OAAO,CACH,KAAC,mBAAmB,IAChB,gBAAgB,EAAE,SAAS,EAC3B,OAAO,EAAE,UAAU,CAAC,EAAC,QAAQ,EAAC,CAAC,EAC/B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,sBAAsB,EAChC,gBAAgB,EAAE,IAAI,CAAC,eAAe,CAAC,GACzC,CACL,CAAC;AACN,CAAC"}
|
@@ -23,11 +23,11 @@ export function prepareFamilies(data) {
|
|
23
23
|
}
|
24
24
|
function prepareRowTableSchema(data = {}) {
|
25
25
|
const families = prepareFamilies(data);
|
26
|
-
const { Columns,
|
26
|
+
const { Columns, KeyColumnNames } = data;
|
27
27
|
const preparedColumns = Columns === null || Columns === void 0 ? void 0 : Columns.map((column) => {
|
28
28
|
var _a, _b, _c;
|
29
29
|
const { Id, Name, NotNull, Type, Family, DefaultFromSequence, DefaultFromLiteral } = column;
|
30
|
-
const keyColumnIndex = (_a =
|
30
|
+
const keyColumnIndex = (_a = KeyColumnNames === null || KeyColumnNames === void 0 ? void 0 : KeyColumnNames.findIndex((keyColumnName) => keyColumnName === Name)) !== null && _a !== void 0 ? _a : -1;
|
31
31
|
const familyName = Family ? families[Family].Name : undefined;
|
32
32
|
const prefferedPoolKind = Family
|
33
33
|
? (_c = (_b = families[Family].StorageConfig) === null || _b === void 0 ? void 0 : _b.Data) === null || _c === void 0 ? void 0 : _c.PreferredPoolKind
|
@@ -65,13 +65,13 @@ function prepareExternalTableSchema(data = {}) {
|
|
65
65
|
}
|
66
66
|
function prepareColumnTableSchema(data = {}) {
|
67
67
|
const { Schema = {}, Sharding = {} } = data;
|
68
|
-
const { Columns,
|
68
|
+
const { Columns, KeyColumnNames } = Schema;
|
69
69
|
const { HashSharding = {} } = Sharding;
|
70
70
|
const { Columns: HashColumns = [] } = HashSharding;
|
71
71
|
const preparedColumns = Columns === null || Columns === void 0 ? void 0 : Columns.map((column) => {
|
72
72
|
var _a;
|
73
73
|
const { Id, Name, Type, NotNull } = column;
|
74
|
-
const keyColumnIndex = (_a =
|
74
|
+
const keyColumnIndex = (_a = KeyColumnNames === null || KeyColumnNames === void 0 ? void 0 : KeyColumnNames.findIndex((keyColumnName) => keyColumnName === Name)) !== null && _a !== void 0 ? _a : -1;
|
75
75
|
const isPartitioningKeyColumn = Boolean(HashColumns === null || HashColumns === void 0 ? void 0 : HashColumns.find((hashColumnName) => hashColumnName === Name));
|
76
76
|
return {
|
77
77
|
id: Id,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prepareData.js","sourceRoot":"","sources":["../../../../../src/containers/Tenant/Schema/SchemaViewer/prepareData.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAI3F,SAAS,iBAAiB,CAAC,KAAoB;IAC3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,KAAK,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAwB;;IACpD,OAAO,CACH,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,0CAAE,cAAc,0CAAE,MAAM,CACzC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACZ,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;YACZ,OAAO;gBACH,GAAG,GAAG;gBACN,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM;aACtB,CAAC;QACN,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC,EACD,EAAE,CACL,mCAAI,EAAE,CACV,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA0B,EAAE;IACvD,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,EAAC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"prepareData.js","sourceRoot":"","sources":["../../../../../src/containers/Tenant/Schema/SchemaViewer/prepareData.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAI3F,SAAS,iBAAiB,CAAC,KAAoB;IAC3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,KAAK,KAAK,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAC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AAC,IAAI,CAAC;QAEjF,OAAO;YACH,IAAI;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SACpB,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { FormatValuesArgs } from '../dataFormatters/common';
|
1
2
|
declare const sizes: {
|
2
3
|
b: {
|
3
4
|
value: number;
|
@@ -39,20 +40,8 @@ export type BytesSizes = keyof typeof sizes;
|
|
39
40
|
* significantDigits = 3 - 900 000 mb and 1000 gb
|
40
41
|
*/
|
41
42
|
export declare const getSizeWithSignificantDigits: (value: number, significantDigits: number) => "b" | "kb" | "mb" | "gb" | "tb";
|
42
|
-
interface FormatToSizeArgs {
|
43
|
-
value: number;
|
44
|
-
size?: BytesSizes;
|
45
|
-
precision?: number;
|
46
|
-
}
|
47
|
-
export type FormatBytesArgs = Omit<FormatToSizeArgs, 'value'> & {
|
48
|
-
value: number | string | undefined | null;
|
49
|
-
withSpeedLabel?: boolean;
|
50
|
-
withSizeLabel?: boolean;
|
51
|
-
significantDigits?: number;
|
52
|
-
delimiter?: string;
|
53
|
-
};
|
54
43
|
/**
|
55
44
|
* @param significantDigits - number of digits above 3
|
56
45
|
*/
|
57
|
-
export declare const formatBytes: ({ value, size, withSpeedLabel, withSizeLabel, significantDigits, delimiter, ...params }:
|
46
|
+
export declare const formatBytes: ({ value, size, withSpeedLabel, withSizeLabel, significantDigits, delimiter, ...params }: FormatValuesArgs<BytesSizes>) => string;
|
58
47
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatBytes.js","sourceRoot":"","sources":["../../../src/utils/bytesParsers/formatBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"formatBytes.js","sourceRoot":"","sources":["../../../src/utils/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,EAAE;IAC/B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,aAAa,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,4BAA4B,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAExF,MAAM,MAAM,GAAG,YAAY,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,MAAM,EAAC,CAAC,CAAC;IAE/E,IAAI,cAAc,EAAE,CAAC;QACjB,OAAO,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAChB,OAAO,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: (key: "b" | "kb" | "mb" | "gb" | "tb" | "perSecond", params?: import("@gravity-ui/i18n").Params) => string;
|
1
|
+
declare const _default: (key: "b" | "kb" | "mb" | "gb" | "tb" | "label_thousand" | "label_million" | "label_billion" | "label_trillion" | "perSecond", params?: import("@gravity-ui/i18n").Params) => string;
|
2
2
|
export default _default;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { registerKeysets } from '../../i18n';
|
2
2
|
import en from './en.json';
|
3
|
-
import ru from './ru.json';
|
4
3
|
const COMPONENT = 'ydb-bytes-parsers';
|
5
|
-
export default registerKeysets(COMPONENT, {
|
4
|
+
export default registerKeysets(COMPONENT, { en });
|
6
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/bytesParsers/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/bytesParsers/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAEtC,eAAe,eAAe,CAAC,SAAS,EAAE,EAAC,EAAE,EAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { UNBREAKABLE_GAP } from '../../utils';
|
2
|
+
import { formatNumericValues } from '../dataFormatters';
|
3
|
+
describe('formatNumericValues', () => {
|
4
|
+
it('should return ["", ""] when both value and total are undefined', () => {
|
5
|
+
const result = formatNumericValues();
|
6
|
+
expect(result).toEqual(['', '']);
|
7
|
+
});
|
8
|
+
it('should format value correctly when total is undefined', () => {
|
9
|
+
const result = formatNumericValues(1000);
|
10
|
+
expect(result).toEqual([`1${UNBREAKABLE_GAP}k`, '']);
|
11
|
+
});
|
12
|
+
it('should format total correctly when value is undefined', () => {
|
13
|
+
const result = formatNumericValues(undefined, 1000000);
|
14
|
+
expect(result).toEqual(['', `1${UNBREAKABLE_GAP}m`]);
|
15
|
+
});
|
16
|
+
it('should format both value and total correctly', () => {
|
17
|
+
const result = formatNumericValues(1024, 2048);
|
18
|
+
expect(result).toEqual(['1', `2${UNBREAKABLE_GAP}k`]);
|
19
|
+
});
|
20
|
+
it('should format value with label if set', () => {
|
21
|
+
const result = formatNumericValues(1024, 2048, undefined, undefined, true);
|
22
|
+
expect(result).toEqual([`1${UNBREAKABLE_GAP}k`, `2${UNBREAKABLE_GAP}k`]);
|
23
|
+
});
|
24
|
+
it('should return ["0", formattedTotal] when value is 0', () => {
|
25
|
+
const result = formatNumericValues(0, 2048);
|
26
|
+
expect(result).toEqual(['0', `2${UNBREAKABLE_GAP}k`]);
|
27
|
+
});
|
28
|
+
it('should use provided size and delimiter', () => {
|
29
|
+
const result = formatNumericValues(5120, 10240, 'billion', '/');
|
30
|
+
expect(result).toEqual(['0', '0/b']);
|
31
|
+
});
|
32
|
+
it('should handle non-numeric total gracefully', () => {
|
33
|
+
const result = formatNumericValues(2048, 'Not a number');
|
34
|
+
expect(result).toEqual([`2${UNBREAKABLE_GAP}k`, '']);
|
35
|
+
});
|
36
|
+
});
|
37
|
+
//# sourceMappingURL=formatNumbers.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formatNumbers.test.js","sourceRoot":"","sources":["../../../../src/utils/dataFormatters/__test__/formatNumbers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,eAAe,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,EAAE,OAAS,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EA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AM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,eAAe,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -17,17 +17,13 @@ describe('formatStorageValues', () => {
|
|
17
17
|
const result = formatStorageValues(1024, 2048);
|
18
18
|
expect(result).toEqual(['1', `2${UNBREAKABLE_GAP}KB`]);
|
19
19
|
});
|
20
|
-
it('should handle small value compared to total and increase precision', () => {
|
21
|
-
const result = formatStorageValues(1, 1024);
|
22
|
-
expect(result).toEqual(['0.001', `1${UNBREAKABLE_GAP}KB`]);
|
23
|
-
});
|
24
20
|
it('should return ["0", formattedTotal] when value is 0', () => {
|
25
21
|
const result = formatStorageValues(0, 2048);
|
26
22
|
expect(result).toEqual(['0', `2${UNBREAKABLE_GAP}KB`]);
|
27
23
|
});
|
28
24
|
it('should use provided size and delimiter', () => {
|
29
25
|
const result = formatStorageValues(5120, 10240, 'mb', '/');
|
30
|
-
expect(result).toEqual(['0
|
26
|
+
expect(result).toEqual(['0', '0/MB']);
|
31
27
|
});
|
32
28
|
it('should handle non-numeric total gracefully', () => {
|
33
29
|
const result = formatStorageValues(2048, 'Not a number');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatStorageValues.test.js","sourceRoot":"","sources":["../../../../src/utils/dataFormatters/__test__/formatStorageValues.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,eAAe,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACpD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,IAAI,eAAe,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,eAAe,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,
|
1
|
+
{"version":3,"file":"formatStorageValues.test.js","sourceRoot":"","sources":["../../../../src/utils/dataFormatters/__test__/formatStorageValues.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EA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,GAAG,mBAAmB,CAAC,IAAI,EAAE,cAAqB,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,eAAe,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export interface FormatToSizeArgs<T> {
|
2
|
+
value: number;
|
3
|
+
size?: T;
|
4
|
+
precision?: number;
|
5
|
+
}
|
6
|
+
export type FormatValuesArgs<T> = Omit<FormatToSizeArgs<T>, 'value'> & {
|
7
|
+
value: number | string | undefined | null;
|
8
|
+
withSpeedLabel?: boolean;
|
9
|
+
withSizeLabel?: boolean;
|
10
|
+
significantDigits?: number;
|
11
|
+
delimiter?: string;
|
12
|
+
};
|
13
|
+
export declare function formatValues<T>(formatter: (args: FormatValuesArgs<T>) => string, sizeGetter: (value: number, significantDigits: number) => T, value?: number, total?: number, size?: T, delimiter?: string, withValueLabel?: boolean): string[];
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { isNumeric } from '../utils';
|
2
|
+
export function formatValues(formatter, sizeGetter, value, total, size, delimiter, withValueLabel = false) {
|
3
|
+
let calculatedSize = sizeGetter(Number(value), 0);
|
4
|
+
let valueWithSizeLabel = true;
|
5
|
+
let valuePrecision = 0;
|
6
|
+
if (isNumeric(total)) {
|
7
|
+
calculatedSize = sizeGetter(Number(total), 0);
|
8
|
+
valueWithSizeLabel = withValueLabel;
|
9
|
+
valuePrecision = 1;
|
10
|
+
}
|
11
|
+
const formattedValue = formatter({
|
12
|
+
value,
|
13
|
+
withSizeLabel: valueWithSizeLabel,
|
14
|
+
size: size || calculatedSize,
|
15
|
+
precision: valuePrecision,
|
16
|
+
delimiter,
|
17
|
+
});
|
18
|
+
const formattedTotal = formatter({
|
19
|
+
value: total,
|
20
|
+
size: size || calculatedSize,
|
21
|
+
delimiter,
|
22
|
+
});
|
23
|
+
return [formattedValue, formattedTotal];
|
24
|
+
}
|
25
|
+
//# sourceMappingURL=common.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/dataFormatters/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAgBnC,MAAM,UAAU,YAAY,CACxB,SAAgD,EAChD,UAA2D,EAC3D,KAAc,EACd,KAAc,EACd,IAAQ,EACR,SAAkB,EAClB,cAAc,GAAG,KAAK;IAEtB,IAAI,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAClD,IAAI,kBAAkB,GAAG,IAAI,CAAC;IAC9B,IAAI,cAAc,GAAG,CAAC,CAAC;IAEvB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9C,kBAAkB,GAAG,cAAc,CAAC;QACpC,cAAc,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,cAAc,GAAG,SAAS,CAAC;QAC7B,KAAK;QACL,aAAa,EAAE,kBAAkB;QACjC,IAAI,EAAE,IAAI,IAAI,cAAc;QAC5B,SAAS,EAAE,cAAc;QACzB,SAAS;KACZ,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,SAAS,CAAC;QAC7B,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI,IAAI,cAAc;QAC5B,SAAS;KACZ,CAAC,CAAC;IAEH,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC"}
|
@@ -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
|
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
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
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,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,cAAc,GAAG,IAAI,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAwB,EAAE,EAAE;IACzD,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAA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,CAAC,CAAC;IAC1D,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,YAA8B,EAAE,EAAE;IACzD,OAAO,YAAY,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACJ,OAAO,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=formatNumber.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formatNumber.js","sourceRoot":"","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