diff --git a/client/package-lock.json b/client/package-lock.json index 8419dae8..697279db 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -12725,6 +12725,11 @@ "requires-port": "^1.0.0" } }, + "url-polyfill": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.7.tgz", + "integrity": "sha512-ZrAxYWCREjmMtL8gSbSiKKLZZticgihCvVBtrFbUVpyoETt8GQJeG2okMWA8XryDAaHMjJfhnc+rnhXRbI4DXA==" + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", diff --git a/client/package.json b/client/package.json index 7c2b1d18..93620f74 100644 --- a/client/package.json +++ b/client/package.json @@ -33,7 +33,8 @@ "redux-actions": "^2.4.0", "redux-form": "^7.4.2", "redux-thunk": "^2.3.0", - "svg-url-loader": "^2.3.2" + "svg-url-loader": "^2.3.2", + "url-polyfill": "^1.1.7" }, "devDependencies": { "autoprefixer": "^8.6.3", diff --git a/client/src/actions/queryLogs.js b/client/src/actions/queryLogs.js index 20672cf6..09e93a60 100644 --- a/client/src/actions/queryLogs.js +++ b/client/src/actions/queryLogs.js @@ -15,7 +15,7 @@ export const getLogs = config => async (dispatch) => { dispatch(getLogsRequest()); try { const { filter, lastRowTime: older_than } = config; - const logs = normalizeLogs(await apiClient.getQueryLog({ filter, older_than })); + const logs = normalizeLogs(await apiClient.getQueryLog({ ...filter, older_than })); dispatch(getLogsSuccess({ logs, ...config })); } catch (error) { dispatch(addErrorToast({ error })); diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 9cd0e650..c067d3f3 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -1,5 +1,7 @@ import axios from 'axios'; +import { getPathWithQueryParams } from '../helpers/helpers'; + class Api { baseUrl = 'control'; @@ -90,16 +92,16 @@ class Api { } // Filtering - FILTERING_INFO = { path: 'filtering_info', method: 'GET' }; + FILTERING_STATUS = { path: 'filtering/status', method: 'GET' }; FILTERING_ADD_FILTER = { path: 'filtering/add_url', method: 'POST' }; FILTERING_REMOVE_FILTER = { path: 'filtering/remove_url', method: 'POST' }; FILTERING_SET_RULES = { path: 'filtering/set_rules', method: 'POST' }; FILTERING_REFRESH = { path: 'filtering/refresh', method: 'POST' }; FILTERING_SET_URL = { path: 'filtering/set_url', method: 'POST' }; - FILTERING_CONFIG = { path: 'filtering_config', method: 'POST' }; + FILTERING_CONFIG = { path: 'filtering/config', method: 'POST' }; getFilteringStatus() { - const { path, method } = this.FILTERING_INFO; + const { path, method } = this.FILTERING_STATUS; return this.makeRequest(path, method); } @@ -482,18 +484,15 @@ class Api { } // Query log - GET_QUERY_LOG = { path: 'querylog', method: 'POST' }; + GET_QUERY_LOG = { path: 'querylog', method: 'GET' }; QUERY_LOG_CONFIG = { path: 'querylog_config', method: 'POST' }; QUERY_LOG_INFO = { path: 'querylog_info', method: 'GET' }; QUERY_LOG_CLEAR = { path: 'querylog_clear', method: 'POST' }; - getQueryLog(data) { + getQueryLog(params) { const { path, method } = this.GET_QUERY_LOG; - const config = { - data, - headers: { 'Content-Type': 'application/json' }, - }; - return this.makeRequest(path, method, config); + const url = getPathWithQueryParams(path, params); + return this.makeRequest(url, method); } getQueryLogInfo() { diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index 6ce8eef2..e61b19d1 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -255,10 +255,10 @@ class Logs extends Component { } = filteredObj; return { - domain: domain || '', - client: client || '', - question_type: isValidQuestionType(type) ? type.toUpperCase() : '', - response_status: response === RESPONSE_FILTER.FILTERED ? response : '', + filter_domain: domain || '', + filter_client: client || '', + filter_question_type: isValidQuestionType(type) ? type.toUpperCase() : '', + filter_response_status: response === RESPONSE_FILTER.FILTERED ? response : '', }; }; diff --git a/client/src/helpers/constants.js b/client/src/helpers/constants.js index a0b6a6fa..99d147b9 100644 --- a/client/src/helpers/constants.js +++ b/client/src/helpers/constants.js @@ -372,8 +372,8 @@ export const DNS_RECORD_TYPES = [ ]; export const DEFAULT_LOGS_FILTER = { - domain: '', - client: '', - question_type: '', - response_status: '', + filter_domain: '', + filter_client: '', + filter_question_type: '', + filter_response_status: '', }; diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index ebb96923..fd9e5d3a 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -1,3 +1,4 @@ +import 'url-polyfill'; import dateParse from 'date-fns/parse'; import dateFormat from 'date-fns/format'; import subHours from 'date-fns/sub_hours'; @@ -321,3 +322,9 @@ export const normalizeWhois = (whois) => { }; export const isValidQuestionType = type => type && DNS_RECORD_TYPES.includes(type.toUpperCase()); + +export const getPathWithQueryParams = (path, params) => { + const searchParams = new URLSearchParams(params); + + return `${path}?${searchParams.toString()}`; +};