mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-09-11 10:45:42 +03:00
6296 fix charts and custom retention labels
Updates #6296 Squashed commit of the following: commit e6a36f107b7bdd17fe4141b035fe5c1f6edd5c6c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Oct 13 17:42:41 2023 +0300 changelog commit 96f11f2090d2aff600f6dcd6ca601e25cd857530 Author: Ildar Kamalov <ik@adguard.com> Date: Fri Oct 13 16:01:27 2023 +0300 changelog commit 136fb14f61dcb2bdec3bc9b8943a05544752a606 Author: Ildar Kamalov <ik@adguard.com> Date: Fri Oct 13 15:20:14 2023 +0300 ADG-7598 fix charts and custom retention labels
This commit is contained in:
parent
506d71310c
commit
733d6c1fca
@ -25,9 +25,11 @@ NOTE: Add new changes BELOW THIS COMMENT.
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- The time shown in the statistics is one hour less than the current time ([#6296]).
|
||||||
- Issues with QUIC and HTTP/3 upstreams on FreeBSD ([#6301]).
|
- Issues with QUIC and HTTP/3 upstreams on FreeBSD ([#6301]).
|
||||||
- Panic on clearing query log ([#6304]).
|
- Panic on clearing query log ([#6304]).
|
||||||
|
|
||||||
|
[#6296]: https://github.com/AdguardTeam/AdGuardHome/issues/6296
|
||||||
[#6301]: https://github.com/AdguardTeam/AdGuardHome/issues/6301
|
[#6301]: https://github.com/AdguardTeam/AdGuardHome/issues/6301
|
||||||
[#6304]: https://github.com/AdguardTeam/AdGuardHome/issues/6304
|
[#6304]: https://github.com/AdguardTeam/AdGuardHome/issues/6304
|
||||||
|
|
||||||
|
@ -119,7 +119,8 @@
|
|||||||
"stats_malware_phishing": "Blocked malware/phishing",
|
"stats_malware_phishing": "Blocked malware/phishing",
|
||||||
"stats_adult": "Blocked adult websites",
|
"stats_adult": "Blocked adult websites",
|
||||||
"stats_query_domain": "Top queried domains",
|
"stats_query_domain": "Top queried domains",
|
||||||
"for_last_24_hours": "for the last 24 hours",
|
"for_last_hours": "for the last {{count}} hour",
|
||||||
|
"for_last_hours_plural": "for the last {{count}} hours",
|
||||||
"for_last_days": "for the last {{count}} day",
|
"for_last_days": "for the last {{count}} day",
|
||||||
"for_last_days_plural": "for the last {{count}} days",
|
"for_last_days_plural": "for the last {{count}} days",
|
||||||
"stats_disabled": "The statistics have been disabled. You can turn it on from the <0>settings page</0>.",
|
"stats_disabled": "The statistics have been disabled. You can turn it on from the <0>settings page</0>.",
|
||||||
@ -134,7 +135,8 @@
|
|||||||
"no_upstreams_data_found": "No upstreams data found",
|
"no_upstreams_data_found": "No upstreams data found",
|
||||||
"number_of_dns_query_days": "The number of DNS queries processed for the last {{count}} day",
|
"number_of_dns_query_days": "The number of DNS queries processed for the last {{count}} day",
|
||||||
"number_of_dns_query_days_plural": "The number of DNS queries processed for the last {{count}} days",
|
"number_of_dns_query_days_plural": "The number of DNS queries processed for the last {{count}} days",
|
||||||
"number_of_dns_query_24_hours": "The number of DNS queries processed for the last 24 hours",
|
"number_of_dns_query_hours": "The number of DNS queries processed for the last {{count}} hour",
|
||||||
|
"number_of_dns_query_hours_plural": "The number of DNS queries processed for the last {{count}} hours",
|
||||||
"number_of_dns_query_blocked_24_hours": "The number of DNS requests blocked by adblock filters and hosts blocklists",
|
"number_of_dns_query_blocked_24_hours": "The number of DNS requests blocked by adblock filters and hosts blocklists",
|
||||||
"number_of_dns_query_blocked_24_hours_by_sec": "The number of DNS requests blocked by the AdGuard browsing security module",
|
"number_of_dns_query_blocked_24_hours_by_sec": "The number of DNS requests blocked by the AdGuard browsing security module",
|
||||||
"number_of_dns_query_blocked_24_hours_adult": "The number of adult websites blocked",
|
"number_of_dns_query_blocked_24_hours_adult": "The number of adult websites blocked",
|
||||||
|
@ -4,9 +4,9 @@ import { Trans, useTranslation } from 'react-i18next';
|
|||||||
import round from 'lodash/round';
|
import round from 'lodash/round';
|
||||||
import { shallowEqual, useSelector } from 'react-redux';
|
import { shallowEqual, useSelector } from 'react-redux';
|
||||||
import Card from '../ui/Card';
|
import Card from '../ui/Card';
|
||||||
import { formatNumber } from '../../helpers/helpers';
|
import { formatNumber, msToDays, msToHours } from '../../helpers/helpers';
|
||||||
import LogsSearchLink from '../ui/LogsSearchLink';
|
import LogsSearchLink from '../ui/LogsSearchLink';
|
||||||
import { RESPONSE_FILTER, DAY } from '../../helpers/constants';
|
import { RESPONSE_FILTER, TIME_UNITS } from '../../helpers/constants';
|
||||||
import Tooltip from '../ui/Tooltip';
|
import Tooltip from '../ui/Tooltip';
|
||||||
|
|
||||||
const Row = ({
|
const Row = ({
|
||||||
@ -52,14 +52,19 @@ const Counters = ({ refreshButton, subtitle }) => {
|
|||||||
numReplacedParental,
|
numReplacedParental,
|
||||||
numReplacedSafesearch,
|
numReplacedSafesearch,
|
||||||
avgProcessingTime,
|
avgProcessingTime,
|
||||||
|
timeUnits,
|
||||||
} = useSelector((state) => state.stats, shallowEqual);
|
} = useSelector((state) => state.stats, shallowEqual);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const days = interval / DAY;
|
|
||||||
|
const dnsQueryTooltip = timeUnits === TIME_UNITS.HOURS
|
||||||
|
? t('number_of_dns_query_hours', { count: msToHours(interval) })
|
||||||
|
: t('number_of_dns_query_days', { count: msToDays(interval) });
|
||||||
|
|
||||||
const rows = [
|
const rows = [
|
||||||
{
|
{
|
||||||
label: 'dns_query',
|
label: 'dns_query',
|
||||||
count: numDnsQueries,
|
count: numDnsQueries,
|
||||||
tooltipTitle: days === 1 ? 'number_of_dns_query_24_hours' : t('number_of_dns_query_days', { count: days }),
|
tooltipTitle: dnsQueryTooltip,
|
||||||
response_status: RESPONSE_FILTER.ALL.QUERY,
|
response_status: RESPONSE_FILTER.ALL.QUERY,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,12 @@ import Counters from './Counters';
|
|||||||
import Clients from './Clients';
|
import Clients from './Clients';
|
||||||
import QueriedDomains from './QueriedDomains';
|
import QueriedDomains from './QueriedDomains';
|
||||||
import BlockedDomains from './BlockedDomains';
|
import BlockedDomains from './BlockedDomains';
|
||||||
import { DISABLE_PROTECTION_TIMINGS, ONE_SECOND_IN_MS, SETTINGS_URLS } from '../../helpers/constants';
|
import {
|
||||||
|
DISABLE_PROTECTION_TIMINGS,
|
||||||
|
ONE_SECOND_IN_MS,
|
||||||
|
SETTINGS_URLS,
|
||||||
|
TIME_UNITS,
|
||||||
|
} from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
msToSeconds,
|
msToSeconds,
|
||||||
msToMinutes,
|
msToMinutes,
|
||||||
@ -46,15 +51,12 @@ const Dashboard = ({
|
|||||||
getAllStats();
|
getAllStats();
|
||||||
}, []);
|
}, []);
|
||||||
const getSubtitle = () => {
|
const getSubtitle = () => {
|
||||||
const ONE_DAY = 1;
|
if (!stats.enabled) {
|
||||||
const intervalInDays = msToDays(stats.interval);
|
|
||||||
|
|
||||||
if (intervalInDays < ONE_DAY) {
|
|
||||||
return t('stats_disabled_short');
|
return t('stats_disabled_short');
|
||||||
}
|
}
|
||||||
|
|
||||||
return intervalInDays === ONE_DAY
|
return stats.timeUnits === TIME_UNITS.HOURS
|
||||||
? t('for_last_24_hours')
|
? t('for_last_hours', { count: msToHours(stats.interval) })
|
||||||
: t('for_last_days', { count: msToDays(stats.interval) });
|
: t('for_last_days', { count: msToDays(stats.interval) });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ResponsiveLine } from '@nivo/line';
|
import { ResponsiveLine } from '@nivo/line';
|
||||||
import addDays from 'date-fns/add_days';
|
import addDays from 'date-fns/add_days';
|
||||||
import addHours from 'date-fns/add_hours';
|
|
||||||
import subDays from 'date-fns/sub_days';
|
import subDays from 'date-fns/sub_days';
|
||||||
import subHours from 'date-fns/sub_hours';
|
import subHours from 'date-fns/sub_hours';
|
||||||
import dateFormat from 'date-fns/format';
|
import dateFormat from 'date-fns/format';
|
||||||
@ -9,12 +8,14 @@ import round from 'lodash/round';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './Line.css';
|
import './Line.css';
|
||||||
import { msToDays } from '../../helpers/helpers';
|
import { msToDays, msToHours } from '../../helpers/helpers';
|
||||||
|
import { TIME_UNITS } from '../../helpers/constants';
|
||||||
|
|
||||||
const Line = ({
|
const Line = ({
|
||||||
data, color = 'black',
|
data, color = 'black',
|
||||||
}) => {
|
}) => {
|
||||||
const interval = msToDays(useSelector((state) => state.stats.interval));
|
const interval = useSelector((state) => state.stats.interval);
|
||||||
|
const timeUnits = useSelector((state) => state.stats.timeUnits);
|
||||||
|
|
||||||
return <ResponsiveLine
|
return <ResponsiveLine
|
||||||
enableArea
|
enableArea
|
||||||
@ -44,12 +45,12 @@ const Line = ({
|
|||||||
enableGridY={false}
|
enableGridY={false}
|
||||||
enablePoints={false}
|
enablePoints={false}
|
||||||
xFormat={(x) => {
|
xFormat={(x) => {
|
||||||
if (interval >= 0 && interval <= 7) {
|
if (timeUnits === TIME_UNITS.HOURS) {
|
||||||
const hoursAgo = subHours(Date.now(), 24 * interval);
|
const hoursAgo = msToHours(interval) - x - 1;
|
||||||
return dateFormat(addHours(hoursAgo, x), 'D MMM HH:00');
|
return dateFormat(subHours(Date.now(), hoursAgo), 'D MMM HH:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
const daysAgo = subDays(Date.now(), interval - 1);
|
const daysAgo = subDays(Date.now(), msToDays(interval) - 1);
|
||||||
return dateFormat(addDays(daysAgo, x), 'D MMM YYYY');
|
return dateFormat(addDays(daysAgo, x), 'D MMM YYYY');
|
||||||
}}
|
}}
|
||||||
yFormat={(y) => round(y, 2)}
|
yFormat={(y) => round(y, 2)}
|
||||||
|
@ -554,3 +554,8 @@ export const DISABLE_PROTECTION_TIMINGS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const LOCAL_TIMEZONE_VALUE = 'Local';
|
export const LOCAL_TIMEZONE_VALUE = 'Local';
|
||||||
|
|
||||||
|
export const TIME_UNITS = {
|
||||||
|
HOURS: 'hours',
|
||||||
|
DAYS: 'days',
|
||||||
|
};
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
import { normalizeTopClients } from '../helpers/helpers';
|
import { normalizeTopClients } from '../helpers/helpers';
|
||||||
import { DAY, HOUR, STATS_INTERVALS_DAYS } from '../helpers/constants';
|
import {
|
||||||
|
DAY,
|
||||||
|
HOUR,
|
||||||
|
STATS_INTERVALS_DAYS,
|
||||||
|
TIME_UNITS,
|
||||||
|
} from '../helpers/constants';
|
||||||
|
|
||||||
import * as actions from '../actions/stats';
|
import * as actions from '../actions/stats';
|
||||||
|
|
||||||
@ -18,6 +23,7 @@ const defaultStats = {
|
|||||||
numReplacedSafebrowsing: 0,
|
numReplacedSafebrowsing: 0,
|
||||||
numReplacedSafesearch: 0,
|
numReplacedSafesearch: 0,
|
||||||
avgProcessingTime: 0,
|
avgProcessingTime: 0,
|
||||||
|
timeUnits: TIME_UNITS.HOURS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const stats = handleActions(
|
const stats = handleActions(
|
||||||
@ -60,6 +66,7 @@ const stats = handleActions(
|
|||||||
avg_processing_time: avgProcessingTime,
|
avg_processing_time: avgProcessingTime,
|
||||||
top_upstreams_responses: topUpstreamsResponses,
|
top_upstreams_responses: topUpstreamsResponses,
|
||||||
top_upstrems_avg_time: topUpstreamsAvgTime,
|
top_upstrems_avg_time: topUpstreamsAvgTime,
|
||||||
|
time_units: timeUnits,
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
const newState = {
|
const newState = {
|
||||||
@ -81,6 +88,7 @@ const stats = handleActions(
|
|||||||
avgProcessingTime,
|
avgProcessingTime,
|
||||||
topUpstreamsResponses,
|
topUpstreamsResponses,
|
||||||
topUpstreamsAvgTime,
|
topUpstreamsAvgTime,
|
||||||
|
timeUnits,
|
||||||
};
|
};
|
||||||
|
|
||||||
return newState;
|
return newState;
|
||||||
|
Loading…
Reference in New Issue
Block a user