From ebade2b6cec89793d852473eb918861b545fe1d4 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Wed, 14 Jul 2021 16:01:12 +0300 Subject: [PATCH] Pull request: 3313 statistics settings UI Closes #3313 Squashed commit of the following: commit 6f2ff98a8282789e2dbb16694ca87a1f4cc8c076 Merge: 1221f02f f4dde3f2 Author: Ainar Garipov Date: Wed Jul 14 15:53:18 2021 +0300 Merge branch 'master' into 3313-statistics commit 1221f02f40628964febd22967d85d5185f87b08d Author: Ildar Kamalov Date: Wed Jul 14 15:23:09 2021 +0300 client: make client names clickable commit 99770ec065e14ce2522a59820f9851d79001923c Author: Ildar Kamalov Date: Wed Jul 14 15:06:30 2021 +0300 client: decreasing interval confirm, disabled stats message --- client/src/__locales/en.json | 2 ++ client/src/components/Dashboard/index.js | 33 ++++++++++++++++--- .../src/components/Logs/Cells/ClientCell.js | 9 +++-- client/src/components/Logs/Logs.css | 9 +++++ .../components/Settings/StatsConfig/index.js | 16 ++++++--- .../src/helpers/renderFormattedClientCell.js | 2 +- 6 files changed, 59 insertions(+), 12 deletions(-) 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 <>