Pull request 1782: 5630-fix-interval

Merge in DNS/adguard-home from 5630-fix-interval to master

Updates #5630.

Squashed commit of the following:

commit eb3839bb63cde40c477843cad1262c8eaa95406a
Author: Ildar Kamalov <ik@adguard.com>
Date:   Fri Mar 24 16:25:23 2023 +0300

    fix lint

commit 1899810ba8e3d2496f35bb052aeda60da565ffa3
Merge: 52526687 2409282d
Author: Ildar Kamalov <ik@adguard.com>
Date:   Fri Mar 24 16:01:50 2023 +0300

    Merge branch 'master' into 5630-fix-interval

commit 52526687e651254a81da091106d88b50b656af2f
Author: Ildar Kamalov <ik@adguard.com>
Date:   Fri Mar 24 15:26:01 2023 +0300

    convert milliseconds to days for stats interval

commit e719814e84bf0ddaec8f4d47a94cc2b5075a7dc5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Mar 24 14:05:55 2023 +0300

    openapi: fix description
This commit is contained in:
Stanislav Chzhen 2023-03-24 16:49:02 +03:00
parent 2409282d51
commit 67c9abe119
5 changed files with 20 additions and 9 deletions

View File

@ -10,7 +10,12 @@ import Clients from './Clients';
import QueriedDomains from './QueriedDomains';
import BlockedDomains from './BlockedDomains';
import { DISABLE_PROTECTION_TIMINGS, ONE_SECOND_IN_MS, SETTINGS_URLS } from '../../helpers/constants';
import { msToSeconds, msToMinutes, msToHours } from '../../helpers/helpers';
import {
msToSeconds,
msToMinutes,
msToHours,
msToDays,
} from '../../helpers/helpers';
import PageTitle from '../ui/PageTitle';
import Loading from '../ui/Loading';
@ -39,13 +44,16 @@ const Dashboard = ({
getAllStats();
}, []);
const getSubtitle = () => {
if (stats.interval === 0) {
const ONE_DAY = 1;
const intervalInDays = msToDays(stats.interval);
if (intervalInDays < ONE_DAY) {
return t('stats_disabled_short');
}
return stats.interval === 1
return intervalInDays === ONE_DAY
? t('for_last_24_hours')
: t('for_last_days', { count: stats.interval });
: t('for_last_days', { count: msToDays(stats.interval) });
};
const buttonClass = classNames('btn btn-sm dashboard-protection-button', {

View File

@ -402,6 +402,8 @@ export const secondsToMilliseconds = (seconds) => {
return seconds;
};
export const msToDays = (milliseconds) => Math.floor(milliseconds / 1000 / 60 / 60 / 24);
export const normalizeRulesTextarea = (text) => text?.replace(/^\n/g, '')
.replace(/\n\s*\n/g, '\n');

View File

@ -1,7 +1,7 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/queryLogs';
import { DEFAULT_LOGS_FILTER } from '../helpers/constants';
import { DEFAULT_LOGS_FILTER, DAY } from '../helpers/constants';
const queryLogs = handleActions(
{
@ -86,7 +86,7 @@ const queryLogs = handleActions(
processingGetConfig: false,
processingSetConfig: false,
processingAdditionalLogs: false,
interval: 1,
interval: DAY,
logs: [],
enabled: true,
oldest: '',

View File

@ -1,5 +1,6 @@
import { handleActions } from 'redux-actions';
import { normalizeTopClients } from '../helpers/helpers';
import { DAY } from '../helpers/constants';
import * as actions from '../actions/stats';
@ -91,7 +92,7 @@ const stats = handleActions(
processingSetConfig: false,
processingStats: true,
processingReset: false,
interval: 1,
interval: DAY,
...defaultStats,
},
);

View File

@ -1777,7 +1777,7 @@
'description': 'Are statistics enabled'
'type': 'boolean'
'interval':
'description': 'Statistics rotation interval'
'description': 'Statistics rotation interval in milliseconds'
'type': 'number'
'ignored':
'description': 'List of host names, which should not be counted'
@ -2203,7 +2203,7 @@
'description': 'Is query log enabled'
'interval':
'description': >
Time period for query log rotation.
Time period for query log rotation in milliseconds.
'type': 'number'
'anonymize_client_ip':
'type': 'boolean'