diff --git a/client/src/actions/queryLogs.js b/client/src/actions/queryLogs.js
index 29f5bc45..ce6b5a0c 100644
--- a/client/src/actions/queryLogs.js
+++ b/client/src/actions/queryLogs.js
@@ -4,8 +4,19 @@ import apiClient from '../api/Api';
import { addErrorToast, addSuccessToast } from './index';
import { normalizeLogs } from '../helpers/helpers';
+const getLogsWithParams = async (config) => {
+ const { older_than, filter, ...values } = config;
+ const rawLogs = await apiClient.getQueryLog({ ...filter, older_than });
+ const { data, oldest } = rawLogs;
+ const logs = normalizeLogs(data);
+
+ return {
+ logs, oldest, older_than, filter, ...values,
+ };
+};
+
export const setLogsPagination = createAction('LOGS_PAGINATION');
-export const setLogsFilter = createAction('LOGS_FILTER');
+export const setLogsPage = createAction('SET_LOG_PAGE');
export const getLogsRequest = createAction('GET_LOGS_REQUEST');
export const getLogsFailure = createAction('GET_LOGS_FAILURE');
@@ -14,19 +25,30 @@ export const getLogsSuccess = createAction('GET_LOGS_SUCCESS');
export const getLogs = config => async (dispatch) => {
dispatch(getLogsRequest());
try {
- const { filter, older_than } = config;
- const rawLogs = await apiClient.getQueryLog({ ...filter, older_than });
- const { data, oldest } = rawLogs;
- const logs = normalizeLogs(data);
- dispatch(getLogsSuccess({
- logs, oldest, filter, ...config,
- }));
+ const logs = await getLogsWithParams(config);
+ dispatch(getLogsSuccess(logs));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getLogsFailure(error));
}
};
+export const setLogsFilterRequest = createAction('SET_LOGS_FILTER_REQUEST');
+export const setLogsFilterFailure = createAction('SET_LOGS_FILTER_FAILURE');
+export const setLogsFilterSuccess = createAction('SET_LOGS_FILTER_SUCCESS');
+
+export const setLogsFilter = filter => async (dispatch) => {
+ dispatch(setLogsFilterRequest());
+ try {
+ const logs = await getLogsWithParams({ older_than: '', filter });
+ dispatch(setLogsFilterSuccess(logs));
+ dispatch(setLogsPage(0));
+ } catch (error) {
+ dispatch(addErrorToast({ error }));
+ dispatch(setLogsFilterFailure(error));
+ }
+};
+
export const clearLogsRequest = createAction('CLEAR_LOGS_REQUEST');
export const clearLogsFailure = createAction('CLEAR_LOGS_FAILURE');
export const clearLogsSuccess = createAction('CLEAR_LOGS_SUCCESS');
diff --git a/client/src/components/Logs/Filters/Form.js b/client/src/components/Logs/Filters/Form.js
new file mode 100644
index 00000000..9b175fc9
--- /dev/null
+++ b/client/src/components/Logs/Filters/Form.js
@@ -0,0 +1,116 @@
+import React, { Fragment } from 'react';
+import PropTypes from 'prop-types';
+import { Field, reduxForm } from 'redux-form';
+import { withNamespaces, Trans } from 'react-i18next';
+import flow from 'lodash/flow';
+
+import { renderField } from '../../../helpers/form';
+import { RESPONSE_FILTER } from '../../../helpers/constants';
+import Tooltip from '../../ui/Tooltip';
+
+const renderFilterField = ({
+ input,
+ id,
+ className,
+ placeholder,
+ type,
+ disabled,
+ autoComplete,
+ tooltip,
+ meta: { touched, error },
+}) => (
+