mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 04:55:33 +03:00
+ client: use search params for querylog request
This commit is contained in:
parent
92b6adbdc1
commit
7b29c56791
7 changed files with 32 additions and 20 deletions
5
client/package-lock.json
generated
vendored
5
client/package-lock.json
generated
vendored
|
@ -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",
|
||||
|
|
3
client/package.json
vendored
3
client/package.json
vendored
|
@ -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",
|
||||
|
|
|
@ -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 }));
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 : '',
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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: '',
|
||||
};
|
||||
|
|
|
@ -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()}`;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue