Skip to content

Commit

Permalink
Pull request 2324: 7505-format-values
Browse files Browse the repository at this point in the history
Closes #7329.
Updates #7505.

* commit '5c15d1bb16044bbaff1ff29e8bbe3ce2ff3bc982':
  all: upd chlog
  Format values in General Statistics
  • Loading branch information
ainar-g committed Dec 17, 2024
2 parents fe07786 + 5c15d1b commit 21945c6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ NOTE: Add new changes BELOW THIS COMMENT.

- The `GET /clients/find` HTTP API is deprecated. Use the new `POST /clients/search` API.

### Fixed

- The formatting of large numbers on the dashboard ([#7329]).

[#7329]: https://github.com/AdguardTeam/AdGuardHome/issues/7329

<!--
NOTE: Add new changes ABOVE THIS COMMENT.
-->
Expand Down
14 changes: 7 additions & 7 deletions client/src/components/Dashboard/Counters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface RowProps {

const Row = ({ label, count, response_status, tooltipTitle, translationComponents }: RowProps) => {
const content = response_status ? (
<LogsSearchLink response_status={response_status}>{formatNumber(count)}</LogsSearchLink>
<LogsSearchLink response_status={response_status}>{count}</LogsSearchLink>
) : (
count
);
Expand Down Expand Up @@ -77,16 +77,16 @@ const Counters = ({ refreshButton, subtitle }: CountersProps) => {
? t('number_of_dns_query_hours', { count: msToHours(interval) })
: t('number_of_dns_query_days', { count: msToDays(interval) });

const rows = [
const rows: RowProps[] = [
{
label: 'dns_query',
count: numDnsQueries.toString(),
count: formatNumber(numDnsQueries),
tooltipTitle: dnsQueryTooltip,
response_status: RESPONSE_FILTER.ALL.QUERY,
},
{
label: 'blocked_by',
count: numBlockedFiltering.toString(),
count: formatNumber(numBlockedFiltering),
tooltipTitle: 'number_of_dns_query_blocked_24_hours',
response_status: RESPONSE_FILTER.BLOCKED.QUERY,

Expand All @@ -98,19 +98,19 @@ const Counters = ({ refreshButton, subtitle }: CountersProps) => {
},
{
label: 'stats_malware_phishing',
count: numReplacedSafebrowsing.toString(),
count: formatNumber(numReplacedSafebrowsing),
tooltipTitle: 'number_of_dns_query_blocked_24_hours_by_sec',
response_status: RESPONSE_FILTER.BLOCKED_THREATS.QUERY,
},
{
label: 'stats_adult',
count: numReplacedParental.toString(),
count: formatNumber(numReplacedParental),
tooltipTitle: 'number_of_dns_query_blocked_24_hours_adult',
response_status: RESPONSE_FILTER.BLOCKED_ADULT_WEBSITES.QUERY,
},
{
label: 'enforced_save_search',
count: numReplacedSafesearch.toString(),
count: formatNumber(numReplacedSafesearch),
tooltipTitle: 'number_of_dns_query_to_safe_search',
response_status: RESPONSE_FILTER.SAFE_SEARCH.QUERY,
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export const getObjDiff = (initialValues: any, values: any) =>
* @param num {number} to format
* @returns {string} Returns a string with a language-sensitive representation of this number
*/
export const formatNumber = (num: any) => {
export const formatNumber = (num: number): string => {
const currentLanguage = i18n.languages[0] || DEFAULT_LANGUAGE;
return num.toLocaleString(currentLanguage);
};
Expand Down
6 changes: 6 additions & 0 deletions scripts/make/go-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ run_linter ineffassign ./...
run_linter unparam ./...

find . \
'(' \
-name 'node_modules' \
-type 'd' \
-prune \
')' \
-o \
-type 'f' \
'(' \
-name 'Makefile' \
Expand Down

0 comments on commit 21945c6

Please sign in to comment.