Compare commits

...

2 Commits

Author SHA1 Message Date
Ildar Kamalov
ef92c2e891 Merge branch 'master' into ADG-9565 2025-01-29 13:42:29 +03:00
Ildar Kamalov
a4364ff7ed ADG-9565 format large numbers in the upstream table and query log 2025-01-29 13:39:14 +03:00
3 changed files with 21 additions and 10 deletions

View File

@@ -18,6 +18,12 @@ See also the [v0.107.57 GitHub milestone][ms-v0.107.57].
NOTE: Add new changes BELOW THIS COMMENT. NOTE: Add new changes BELOW THIS COMMENT.
--> -->
### Fixed
- The formatting of large numbers in the upstream table and query log ([#7590]).
[#7590]: https://github.com/AdguardTeam/AdGuardHome/issues/7590
<!-- <!--
NOTE: Add new changes ABOVE THIS COMMENT. NOTE: Add new changes ABOVE THIS COMMENT.
--> -->

View File

@@ -10,6 +10,7 @@ import Card from '../ui/Card';
import DomainCell from './DomainCell'; import DomainCell from './DomainCell';
import { DASHBOARD_TABLES_DEFAULT_PAGE_SIZE, TABLES_MIN_ROWS } from '../../helpers/constants'; import { DASHBOARD_TABLES_DEFAULT_PAGE_SIZE, TABLES_MIN_ROWS } from '../../helpers/constants';
import { formatNumber } from '../../helpers/helpers';
interface TimeCellProps { interface TimeCellProps {
value?: string | number; value?: string | number;
@@ -20,7 +21,7 @@ const TimeCell = ({ value }: TimeCellProps) => {
return ''; return '';
} }
const valueInMilliseconds = round(Number(value) * 1000); const valueInMilliseconds = formatNumber(round(Number(value) * 1000));
return ( return (
<div className="logs__row o-hidden"> <div className="logs__row o-hidden">

View File

@@ -453,7 +453,7 @@ export const getParamsForClientsSearch = (data: any, param: any, additionalParam
}); });
return { return {
clients: Array.from(clients).map(id => ({ id })), clients: Array.from(clients).map((id) => ({ id })),
}; };
}; };
@@ -670,9 +670,16 @@ export const countClientsStatistics = (ids: any, autoClients: any) => {
* @param {function} t translate * @param {function} t translate
* @returns {string} * @returns {string}
*/ */
export const formatElapsedMs = (elapsedMs: any, t: any) => { export const formatElapsedMs = (elapsedMs: string, t: (key: string) => string) => {
const formattedElapsedMs = parseInt(elapsedMs, 10) || parseFloat(elapsedMs).toFixed(2); const parsedElapsedMs = parseInt(elapsedMs, 10);
return `${formattedElapsedMs} ${t('milliseconds_abbreviation')}`;
if (Number.isNaN(parsedElapsedMs)) {
return elapsedMs;
}
const formattedMs = formatNumber(parsedElapsedMs);
return `${formattedMs} ${t('milliseconds_abbreviation')}`;
}; };
/** /**
@@ -754,12 +761,9 @@ type NestedObject = {
order: number; order: number;
}; };
export const getObjectKeysSorted = < export const getObjectKeysSorted = <T extends Record<string, NestedObject>, K extends keyof NestedObject>(
T extends Record<string, NestedObject>,
K extends keyof NestedObject
>(
object: T, object: T,
sortKey: K sortKey: K,
): string[] => { ): string[] => {
return Object.entries(object) return Object.entries(object)
.sort(([, a], [, b]) => (a[sortKey] as number) - (b[sortKey] as number)) .sort(([, a], [, b]) => (a[sortKey] as number) - (b[sortKey] as number))