client: add ignored domains for querylog
This commit is contained in:
parent
24d75c4376
commit
97e31cff70
|
@ -177,7 +177,7 @@ export const getLogsConfigSuccess = createAction('GET_LOGS_CONFIG_SUCCESS');
|
||||||
export const getLogsConfig = () => async (dispatch) => {
|
export const getLogsConfig = () => async (dispatch) => {
|
||||||
dispatch(getLogsConfigRequest());
|
dispatch(getLogsConfigRequest());
|
||||||
try {
|
try {
|
||||||
const data = await apiClient.getQueryLogInfo();
|
const data = await apiClient.getQueryLogConfig();
|
||||||
dispatch(getLogsConfigSuccess(data));
|
dispatch(getLogsConfigSuccess(data));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
|
|
|
@ -529,9 +529,9 @@ class Api {
|
||||||
// Query log
|
// Query log
|
||||||
GET_QUERY_LOG = { path: 'querylog', method: 'GET' };
|
GET_QUERY_LOG = { path: 'querylog', method: 'GET' };
|
||||||
|
|
||||||
QUERY_LOG_CONFIG = { path: 'querylog_config', method: 'POST' };
|
UPDATE_QUERY_LOG_CONFIG = { path: 'querylog/config/update', method: 'PUT' };
|
||||||
|
|
||||||
QUERY_LOG_INFO = { path: 'querylog_info', method: 'GET' };
|
GET_QUERY_LOG_CONFIG = { path: 'querylog/config', method: 'GET' };
|
||||||
|
|
||||||
QUERY_LOG_CLEAR = { path: 'querylog_clear', method: 'POST' };
|
QUERY_LOG_CLEAR = { path: 'querylog_clear', method: 'POST' };
|
||||||
|
|
||||||
|
@ -543,13 +543,13 @@ class Api {
|
||||||
return this.makeRequest(url, method);
|
return this.makeRequest(url, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
getQueryLogInfo() {
|
getQueryLogConfig() {
|
||||||
const { path, method } = this.QUERY_LOG_INFO;
|
const { path, method } = this.GET_QUERY_LOG_CONFIG;
|
||||||
return this.makeRequest(path, method);
|
return this.makeRequest(path, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
setQueryLogConfig(data) {
|
setQueryLogConfig(data) {
|
||||||
const { path, method } = this.QUERY_LOG_CONFIG;
|
const { path, method } = this.UPDATE_QUERY_LOG_CONFIG;
|
||||||
const config = {
|
const config = {
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,18 +4,28 @@ import { Field, reduxForm } from 'redux-form';
|
||||||
import { Trans, withTranslation } from 'react-i18next';
|
import { Trans, withTranslation } from 'react-i18next';
|
||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
|
|
||||||
import { CheckboxField, renderRadioField, toFloatNumber } from '../../../helpers/form';
|
import {
|
||||||
import { FORM_NAME, QUERY_LOG_INTERVALS_DAYS } from '../../../helpers/constants';
|
CheckboxField,
|
||||||
|
renderRadioField,
|
||||||
|
toFloatNumber,
|
||||||
|
renderTextareaField,
|
||||||
|
} from '../../../helpers/form';
|
||||||
|
import {
|
||||||
|
FORM_NAME,
|
||||||
|
QUERY_LOG_INTERVALS_DAYS,
|
||||||
|
HOUR,
|
||||||
|
DAY,
|
||||||
|
} from '../../../helpers/constants';
|
||||||
import '../FormButton.css';
|
import '../FormButton.css';
|
||||||
|
|
||||||
const getIntervalTitle = (interval, t) => {
|
const getIntervalTitle = (interval, t) => {
|
||||||
switch (interval) {
|
switch (interval) {
|
||||||
case 0.25:
|
case 6 * HOUR:
|
||||||
return t('interval_6_hour');
|
return t('interval_6_hour');
|
||||||
case 1:
|
case DAY:
|
||||||
return t('interval_24_hour');
|
return t('interval_24_hour');
|
||||||
default:
|
default:
|
||||||
return t('interval_days', { count: interval });
|
return t('interval_days', { count: interval / DAY });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,6 +76,15 @@ const Form = (props) => {
|
||||||
{getIntervalFields(processing, t, toFloatNumber)}
|
{getIntervalFields(processing, t, toFloatNumber)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="form__group form__group--settings">
|
||||||
|
<Field
|
||||||
|
name="ignored"
|
||||||
|
type="textarea"
|
||||||
|
component={renderTextareaField}
|
||||||
|
placeholder={t('statistics_ignore_domains')}
|
||||||
|
disabled={processing}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
|
@ -10,13 +10,15 @@ class LogsConfig extends Component {
|
||||||
const { t, interval: prevInterval } = this.props;
|
const { t, interval: prevInterval } = this.props;
|
||||||
const { interval } = values;
|
const { interval } = values;
|
||||||
|
|
||||||
|
const data = { ...values, ignored: values.ignored ? values.ignored.split('\n') : [] };
|
||||||
|
|
||||||
if (interval !== prevInterval) {
|
if (interval !== prevInterval) {
|
||||||
// eslint-disable-next-line no-alert
|
// eslint-disable-next-line no-alert
|
||||||
if (window.confirm(t('query_log_retention_confirm'))) {
|
if (window.confirm(t('query_log_retention_confirm'))) {
|
||||||
this.props.setLogsConfig(values);
|
this.props.setLogsConfig(data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.props.setLogsConfig(values);
|
this.props.setLogsConfig(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ class LogsConfig extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
t, enabled, interval, processing, processingClear, anonymize_client_ip,
|
t, enabled, interval, processing, processingClear, anonymize_client_ip, ignored,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -45,6 +47,7 @@ class LogsConfig extends Component {
|
||||||
enabled,
|
enabled,
|
||||||
interval,
|
interval,
|
||||||
anonymize_client_ip,
|
anonymize_client_ip,
|
||||||
|
ignored: ignored.join('\n'),
|
||||||
}}
|
}}
|
||||||
onSubmit={this.handleFormSubmit}
|
onSubmit={this.handleFormSubmit}
|
||||||
processing={processing}
|
processing={processing}
|
||||||
|
@ -62,6 +65,7 @@ LogsConfig.propTypes = {
|
||||||
enabled: PropTypes.bool.isRequired,
|
enabled: PropTypes.bool.isRequired,
|
||||||
anonymize_client_ip: PropTypes.bool.isRequired,
|
anonymize_client_ip: PropTypes.bool.isRequired,
|
||||||
processing: PropTypes.bool.isRequired,
|
processing: PropTypes.bool.isRequired,
|
||||||
|
ignored: PropTypes.array.isRequired,
|
||||||
processingClear: PropTypes.bool.isRequired,
|
processingClear: PropTypes.bool.isRequired,
|
||||||
setLogsConfig: PropTypes.func.isRequired,
|
setLogsConfig: PropTypes.func.isRequired,
|
||||||
clearLogs: PropTypes.func.isRequired,
|
clearLogs: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -98,6 +98,7 @@ class Settings extends Component {
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<LogsConfig
|
<LogsConfig
|
||||||
enabled={queryLogs.enabled}
|
enabled={queryLogs.enabled}
|
||||||
|
ignored={queryLogs.ignored}
|
||||||
interval={queryLogs.interval}
|
interval={queryLogs.interval}
|
||||||
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
anonymize_client_ip={queryLogs.anonymize_client_ip}
|
||||||
processing={queryLogs.processingSetConfig}
|
processing={queryLogs.processingSetConfig}
|
||||||
|
@ -153,6 +154,7 @@ Settings.propTypes = {
|
||||||
processingSetConfig: PropTypes.bool,
|
processingSetConfig: PropTypes.bool,
|
||||||
processingClear: PropTypes.bool,
|
processingClear: PropTypes.bool,
|
||||||
processingGetConfig: PropTypes.bool,
|
processingGetConfig: PropTypes.bool,
|
||||||
|
ignored: PropTypes.array,
|
||||||
}),
|
}),
|
||||||
filtering: PropTypes.shape({
|
filtering: PropTypes.shape({
|
||||||
interval: PropTypes.number,
|
interval: PropTypes.number,
|
||||||
|
|
|
@ -218,7 +218,7 @@ export const DAY = HOUR * 24;
|
||||||
|
|
||||||
export const STATS_INTERVALS_DAYS = [DAY, DAY * 7, DAY * 30, DAY * 90];
|
export const STATS_INTERVALS_DAYS = [DAY, DAY * 7, DAY * 30, DAY * 90];
|
||||||
|
|
||||||
export const QUERY_LOG_INTERVALS_DAYS = [0.25, 1, 7, 30, 90];
|
export const QUERY_LOG_INTERVALS_DAYS = [HOUR * 6, DAY, DAY * 7, DAY * 30, DAY * 90];
|
||||||
|
|
||||||
export const FILTERS_INTERVALS_HOURS = [0, 1, 12, 24, 72, 168];
|
export const FILTERS_INTERVALS_HOURS = [0, 1, 12, 24, 72, 168];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue