diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 97f6564d..8254c9ea 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -112,6 +112,8 @@ "for_last_24_hours": "for the last 24 hours", "for_last_days": "for the last {{count}} day", "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.", + "stats_disabled_short": "The statistics have been disabled", "no_domains_found": "No domains found", "requests_count": "Requests count", "top_blocked_domains": "Top blocked domains", diff --git a/client/src/components/Dashboard/index.js b/client/src/components/Dashboard/index.js index d7e8874e..9bde0ea7 100644 --- a/client/src/components/Dashboard/index.js +++ b/client/src/components/Dashboard/index.js @@ -1,12 +1,15 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; +import { HashLink as Link } from 'react-router-hash-link'; import { Trans, useTranslation } from 'react-i18next'; import classNames from 'classnames'; + import Statistics from './Statistics'; import Counters from './Counters'; import Clients from './Clients'; import QueriedDomains from './QueriedDomains'; import BlockedDomains from './BlockedDomains'; +import { SETTINGS_URLS } from '../../helpers/constants'; import PageTitle from '../ui/PageTitle'; import Loading from '../ui/Loading'; @@ -34,6 +37,16 @@ const Dashboard = ({ getAllStats(); }, []); + const getSubtitle = () => { + if (stats.interval === 0) { + return t('stats_disabled_short'); + } + + return stats.interval === 1 + ? t('for_last_24_hours') + : t('for_last_days', { count: stats.interval }); + }; + const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; const buttonClass = classNames('btn btn-sm dashboard-title__button', { @@ -52,14 +65,12 @@ const Dashboard = ({ ; - const subtitle = stats.interval === 1 - ? t('for_last_24_hours') - : t('for_last_days', { count: stats.interval }); - const statsProcessing = stats.processingStats || stats.processingGetConfig || access.processing; + const subtitle = getSubtitle(); + return <>