diff --git a/client/src/components/Filters/Check/Info.js b/client/src/components/Filters/Check/Info.js index d3cd0136..c5d3cafa 100644 --- a/client/src/components/Filters/Check/Info.js +++ b/client/src/components/Filters/Check/Info.js @@ -2,7 +2,17 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withNamespaces } from 'react-i18next'; -import { checkFiltered, checkRewrite, checkBlackList, checkNotFilteredNotFound, checkWhiteList } from '../../../helpers/helpers'; +import { + checkFiltered, + checkRewrite, + checkBlackList, + checkNotFilteredNotFound, + checkWhiteList, + checkSafeSearch, + checkSafeBrowsing, + checkParental, +} from '../../../helpers/helpers'; +import { FILTERED } from '../../../helpers/constants'; const getFilterName = (id, filters, t) => { if (id === 0) { @@ -18,7 +28,7 @@ const getFilterName = (id, filters, t) => { return ''; }; -const getTitle = (reason, filterName, t) => { +const getTitle = (reason, filterName, t, onlyFiltered) => { if (checkNotFilteredNotFound(reason)) { return t('check_not_found'); } @@ -44,6 +54,16 @@ const getTitle = (reason, filterName, t) => { ); } + if (onlyFiltered) { + const filterKey = reason.replace(FILTERED, ''); + + return ( +
+ {t('query_log_filtered', { filter: filterKey })} +
+ ); + } + return (
@@ -80,9 +100,24 @@ const Info = ({ t, }) => { const filterName = getFilterName(filter_id, filters, t); - const title = getTitle(reason, filterName, t); + const onlyFiltered = checkSafeSearch(reason) + || checkSafeBrowsing(reason) + || checkParental(reason); + const title = getTitle(reason, filterName, t, onlyFiltered); const color = getColor(reason); + if (onlyFiltered) { + return ( +
+
+ {hostname} +
+ +
{title}
+
+ ); + } + return (
diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index f57fb704..46f0de28 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -10,8 +10,13 @@ import { formatTime, formatDateTime, isToday, + checkFiltered, + checkRewrite, + checkWhiteList, + checkBlackList, + checkBlockedService, } from '../../helpers/helpers'; -import { SERVICES, FILTERED_STATUS, TABLE_DEFAULT_PAGE_SIZE, CUSTOM_FILTERING_RULES_ID } from '../../helpers/constants'; +import { SERVICES, TABLE_DEFAULT_PAGE_SIZE, CUSTOM_FILTERING_RULES_ID, FILTERED } from '../../helpers/constants'; import { getTrackerData } from '../../helpers/trackers/trackers'; import { formatClientCell } from '../../helpers/formatClientCell'; @@ -27,7 +32,6 @@ import CellWrap from '../ui/CellWrap'; const TABLE_FIRST_PAGE = 0; const INITIAL_REQUEST = true; const INITIAL_REQUEST_DATA = ['', TABLE_FIRST_PAGE, INITIAL_REQUEST]; -const FILTERED_REASON = 'Filtered'; class Logs extends Component { componentDidMount() { @@ -111,16 +115,6 @@ class Logs extends Component { ); } - checkFiltered = reason => reason.indexOf(FILTERED_REASON) === 0; - - checkRewrite = reason => reason === FILTERED_STATUS.REWRITE; - - checkWhiteList = reason => reason === FILTERED_STATUS.NOT_FILTERED_WHITE_LIST; - - checkBlackList = reason => reason === FILTERED_STATUS.FILTERED_BLACK_LIST; - - checkBlockedService = reason => reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE; - getDateCell = row => CellWrap( row, (isToday(row.value) ? formatTime : formatDateTime), @@ -172,14 +166,14 @@ class Logs extends Component { const { t, filtering } = this.props; const { filters } = filtering; - const isFiltered = this.checkFiltered(reason); - const isBlackList = this.checkBlackList(reason); - const isRewrite = this.checkRewrite(reason); - const isWhiteList = this.checkWhiteList(reason); - const isBlockedService = this.checkBlockedService(reason); + const isFiltered = checkFiltered(reason); + const isBlackList = checkBlackList(reason); + const isRewrite = checkRewrite(reason); + const isWhiteList = checkWhiteList(reason); + const isBlockedService = checkBlockedService(reason); const isBlockedCnameIp = originalAnswer; - const filterKey = reason.replace(FILTERED_REASON, ''); + const filterKey = reason.replace(FILTERED, ''); const parsedFilteredReason = t('query_log_filtered', { filter: filterKey }); const currentService = SERVICES.find(service => service.id === original.serviceName); const serviceName = currentService && currentService.name; @@ -238,8 +232,8 @@ class Logs extends Component { const { original } = row; const { t } = this.props; const { reason, domain } = original; - const isFiltered = this.checkFiltered(reason); - const isRewrite = this.checkRewrite(reason); + const isFiltered = checkFiltered(reason); + const isRewrite = checkRewrite(reason); return ( @@ -360,15 +354,15 @@ class Logs extends Component { const { reason } = rowInfo.original; - if (this.checkFiltered(reason)) { + if (checkFiltered(reason)) { return { className: 'red', }; - } else if (this.checkWhiteList(reason)) { + } else if (checkWhiteList(reason)) { return { className: 'green', }; - } else if (this.checkRewrite(reason)) { + } else if (checkRewrite(reason)) { return { className: 'blue', }; diff --git a/client/src/helpers/constants.js b/client/src/helpers/constants.js index 2c457736..247dd74c 100644 --- a/client/src/helpers/constants.js +++ b/client/src/helpers/constants.js @@ -241,6 +241,9 @@ export const FILTERED_STATUS = { NOT_FILTERED_NOT_FOUND: 'NotFilteredNotFound', FILTERED_BLOCKED_SERVICE: 'FilteredBlockedService', REWRITE: 'Rewrite', + FILTERED_SAFE_SEARCH: 'FilteredSafeSearch', + FILTERED_SAFE_BROWSING: 'FilteredSafeBrowsing', + FILTERED_PARENTAL: 'FilteredParental', }; export const FILTERED = 'Filtered'; diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 977b0eae..68a9c33d 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -432,3 +432,7 @@ export const checkRewrite = reason => reason === FILTERED_STATUS.REWRITE; export const checkBlackList = reason => reason === FILTERED_STATUS.FILTERED_BLACK_LIST; export const checkWhiteList = reason => reason === FILTERED_STATUS.NOT_FILTERED_WHITE_LIST; export const checkNotFilteredNotFound = reason => reason === FILTERED_STATUS.NOT_FILTERED_NOT_FOUND; +export const checkSafeSearch = reason => reason === FILTERED_STATUS.FILTERED_SAFE_SEARCH; +export const checkSafeBrowsing = reason => reason === FILTERED_STATUS.FILTERED_SAFE_BROWSING; +export const checkParental = reason => reason === FILTERED_STATUS.FILTERED_PARENTAL; +export const checkBlockedService = reason => reason === FILTERED_STATUS.FILTERED_BLOCKED_SERVICE;