Add links to all the dashboard things

This commit is contained in:
Mark Hicken 2021-06-08 15:05:17 -06:00
parent 4700dea92b
commit 137dcb058e
4 changed files with 22 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import propTypes from 'prop-types'; import propTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next'; 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';
@ -10,7 +11,7 @@ import { RESPONSE_FILTER } from '../../helpers/constants';
import Tooltip from '../ui/Tooltip'; import Tooltip from '../ui/Tooltip';
const Row = ({ const Row = ({
label, count, response_status, tooltipTitle, translationComponents, label, count, response_status, tooltipTitle, translationComponents, href,
}) => { }) => {
const content = response_status const content = response_status
? <LogsSearchLink response_status={response_status}>{formatNumber(count)}</LogsSearchLink> ? <LogsSearchLink response_status={response_status}>{formatNumber(count)}</LogsSearchLink>
@ -18,7 +19,11 @@ const Row = ({
return <tr key={label}> return <tr key={label}>
<td> <td>
{href ? (
<Link to={href}><Trans components={translationComponents}>{label}</Trans></Link>
) : (
<Trans components={translationComponents}>{label}</Trans> <Trans components={translationComponents}>{label}</Trans>
)}
<Tooltip content={tooltipTitle} placement="top" <Tooltip content={tooltipTitle} placement="top"
className="tooltip-container tooltip-custom--narrow text-center"> className="tooltip-container tooltip-custom--narrow text-center">
<svg className="icons icon--20 icon--lightgray ml-2"> <svg className="icons icon--20 icon--lightgray ml-2">
@ -48,31 +53,35 @@ const Counters = ({ refreshButton, subtitle }) => {
count: numDnsQueries, count: numDnsQueries,
tooltipTitle: interval === 1 ? 'number_of_dns_query_24_hours' : t('number_of_dns_query_days', { count: interval }), tooltipTitle: interval === 1 ? 'number_of_dns_query_24_hours' : t('number_of_dns_query_days', { count: interval }),
response_status: RESPONSE_FILTER.ALL.QUERY, response_status: RESPONSE_FILTER.ALL.QUERY,
href: 'logs',
}, },
{ {
label: 'blocked_by', label: 'blocked_by',
count: numBlockedFiltering, count: numBlockedFiltering,
tooltipTitle: 'number_of_dns_query_blocked_24_hours', tooltipTitle: 'number_of_dns_query_blocked_24_hours',
response_status: RESPONSE_FILTER.BLOCKED.QUERY, response_status: RESPONSE_FILTER.BLOCKED.QUERY,
translationComponents: [<a href="#filters" key="0">link</a>], translationComponents: [<Link to="logs?response_status=filtered" key="0">link</Link>],
}, },
{ {
label: 'stats_malware_phishing', label: 'stats_malware_phishing',
count: numReplacedSafebrowsing, count: numReplacedSafebrowsing,
tooltipTitle: 'number_of_dns_query_blocked_24_hours_by_sec', tooltipTitle: 'number_of_dns_query_blocked_24_hours_by_sec',
response_status: RESPONSE_FILTER.BLOCKED_THREATS.QUERY, response_status: RESPONSE_FILTER.BLOCKED_THREATS.QUERY,
href: 'logs?response_status=blocked_safebrowsing',
}, },
{ {
label: 'stats_adult', label: 'stats_adult',
count: numReplacedParental, count: numReplacedParental,
tooltipTitle: 'number_of_dns_query_blocked_24_hours_adult', tooltipTitle: 'number_of_dns_query_blocked_24_hours_adult',
response_status: RESPONSE_FILTER.BLOCKED_ADULT_WEBSITES.QUERY, response_status: RESPONSE_FILTER.BLOCKED_ADULT_WEBSITES.QUERY,
href: 'logs?response_status=blocked_parental',
}, },
{ {
label: 'enforced_save_search', label: 'enforced_save_search',
count: numReplacedSafesearch, count: numReplacedSafesearch,
tooltipTitle: 'number_of_dns_query_to_safe_search', tooltipTitle: 'number_of_dns_query_to_safe_search',
response_status: RESPONSE_FILTER.SAFE_SEARCH.QUERY, response_status: RESPONSE_FILTER.SAFE_SEARCH.QUERY,
href: 'logs?response_status=safe_search',
}, },
{ {
label: 'average_processing_time', label: 'average_processing_time',
@ -101,6 +110,7 @@ Row.propTypes = {
response_status: propTypes.string, response_status: propTypes.string,
tooltipTitle: propTypes.string.isRequired, tooltipTitle: propTypes.string.isRequired,
translationComponents: propTypes.arrayOf(propTypes.element), translationComponents: propTypes.arrayOf(propTypes.element),
href: propTypes.string,
}; };
Counters.propTypes = { Counters.propTypes = {

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { Trans } from 'react-i18next'; import { Trans } from 'react-i18next';
import { getSourceData, getTrackerData } from '../../helpers/trackers/trackers'; import { getSourceData, getTrackerData } from '../../helpers/trackers/trackers';
@ -53,7 +54,7 @@ const DomainCell = ({ value }) => {
return ( return (
<div className="logs__row"> <div className="logs__row">
<div className="logs__text" title={value}> <div className="logs__text" title={value}>
{value} <Link to={`logs?search=${encodeURIComponent(value)}`}>{value}</Link>
</div> </div>
{trackerData {trackerData
&& <Tooltip content={content} placement="top" && <Tooltip content={content} placement="top"

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { withTranslation, Trans } from 'react-i18next'; import { withTranslation, Trans } from 'react-i18next';
import StatsCard from './StatsCard'; import StatsCard from './StatsCard';
@ -25,7 +26,7 @@ const Statistics = ({
<StatsCard <StatsCard
total={numDnsQueries} total={numDnsQueries}
lineData={getNormalizedHistory(dnsQueries, interval, 'dnsQuery')} lineData={getNormalizedHistory(dnsQueries, interval, 'dnsQuery')}
title={<Trans>dns_query</Trans>} title={<Link to="logs"><Trans>dns_query</Trans></Link>}
color="blue" color="blue"
/> />
</div> </div>
@ -34,7 +35,7 @@ const Statistics = ({
total={numBlockedFiltering} total={numBlockedFiltering}
lineData={getNormalizedHistory(blockedFiltering, interval, 'blockedFiltering')} lineData={getNormalizedHistory(blockedFiltering, interval, 'blockedFiltering')}
percent={getPercent(numDnsQueries, numBlockedFiltering)} percent={getPercent(numDnsQueries, numBlockedFiltering)}
title={<Trans components={[<a href="#filters" key="0">link</a>]}>blocked_by</Trans>} title={<Trans components={[<Link to="logs?response_status=filtered" key="0">link</Link>]}>blocked_by</Trans>}
color="red" color="red"
/> />
</div> </div>
@ -47,7 +48,7 @@ const Statistics = ({
'replacedSafebrowsing', 'replacedSafebrowsing',
)} )}
percent={getPercent(numDnsQueries, numReplacedSafebrowsing)} percent={getPercent(numDnsQueries, numReplacedSafebrowsing)}
title={<Trans>stats_malware_phishing</Trans>} title={<Link to="logs?response_status=blocked_safebrowsing"><Trans>stats_malware_phishing</Trans></Link>}
color="green" color="green"
/> />
</div> </div>
@ -56,7 +57,7 @@ const Statistics = ({
total={numReplacedParental} total={numReplacedParental}
lineData={getNormalizedHistory(replacedParental, interval, 'replacedParental')} lineData={getNormalizedHistory(replacedParental, interval, 'replacedParental')}
percent={getPercent(numDnsQueries, numReplacedParental)} percent={getPercent(numDnsQueries, numReplacedParental)}
title={<Trans>stats_adult</Trans>} title={<Link to="logs?response_status=blocked_parental"><Trans>stats_adult</Trans></Link>}
color="yellow" color="yellow"
/> />
</div> </div>

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom';
import { normalizeWhois } from './helpers'; import { normalizeWhois } from './helpers';
import { WHOIS_ICONS } from './constants'; import { WHOIS_ICONS } from './constants';
@ -63,7 +64,7 @@ export const renderFormattedClientCell = (value, info, isDetailed = false, isLog
} }
return <div className="logs__text mw-100" title={value}> return <div className="logs__text mw-100" title={value}>
{nameContainer} <Link to={`logs?search=${encodeURIComponent(value)}`}>{nameContainer}</Link>
{whoisContainer} {whoisContainer}
</div>; </div>;
}; };