From 8c89973365e660d47fa5fce88113414011961acb Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 5 Sep 2019 12:12:58 +0300 Subject: [PATCH] - client: fix api client export --- client/src/actions/access.js | 4 +--- client/src/actions/clients.js | 4 +--- client/src/actions/encryption.js | 4 +--- client/src/actions/index.js | 4 +--- client/src/actions/install.js | 4 +--- client/src/actions/queryLogs.js | 4 +--- client/src/actions/rewrites.js | 4 +--- client/src/actions/services.js | 4 +--- client/src/actions/stats.js | 4 +--- client/src/api/Api.js | 5 ++++- client/src/components/Logs/index.js | 2 +- client/src/containers/Settings.js | 3 +-- 12 files changed, 15 insertions(+), 31 deletions(-) diff --git a/client/src/actions/access.js b/client/src/actions/access.js index b10062cb..5b5272d7 100644 --- a/client/src/actions/access.js +++ b/client/src/actions/access.js @@ -1,10 +1,8 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { normalizeTextarea } from '../helpers/helpers'; -const apiClient = new Api(); - export const getAccessListRequest = createAction('GET_ACCESS_LIST_REQUEST'); export const getAccessListFailure = createAction('GET_ACCESS_LIST_FAILURE'); export const getAccessListSuccess = createAction('GET_ACCESS_LIST_SUCCESS'); diff --git a/client/src/actions/clients.js b/client/src/actions/clients.js index 6af28871..3974a38c 100644 --- a/client/src/actions/clients.js +++ b/client/src/actions/clients.js @@ -1,11 +1,9 @@ import { createAction } from 'redux-actions'; import { t } from 'i18next'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast, getClients } from './index'; import { CLIENT_ID } from '../helpers/constants'; -const apiClient = new Api(); - export const toggleClientModal = createAction('TOGGLE_CLIENT_MODAL'); export const addClientRequest = createAction('ADD_CLIENT_REQUEST'); diff --git a/client/src/actions/encryption.js b/client/src/actions/encryption.js index 6d6f3332..be86bd59 100644 --- a/client/src/actions/encryption.js +++ b/client/src/actions/encryption.js @@ -1,10 +1,8 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { redirectToCurrentProtocol } from '../helpers/helpers'; -const apiClient = new Api(); - export const getTlsStatusRequest = createAction('GET_TLS_STATUS_REQUEST'); export const getTlsStatusFailure = createAction('GET_TLS_STATUS_FAILURE'); export const getTlsStatusSuccess = createAction('GET_TLS_STATUS_SUCCESS'); diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 70913e29..8a132060 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -7,9 +7,7 @@ import versionCompare from '../helpers/versionCompare'; import { normalizeFilteringStatus, normalizeTextarea, sortClients } from '../helpers/helpers'; import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants'; import { getTlsStatus } from './encryption'; -import Api from '../api/Api'; - -const apiClient = new Api(); +import apiClient from '../api/Api'; export const addErrorToast = createAction('ADD_ERROR_TOAST'); export const addSuccessToast = createAction('ADD_SUCCESS_TOAST'); diff --git a/client/src/actions/install.js b/client/src/actions/install.js index 3070ff2d..62983892 100644 --- a/client/src/actions/install.js +++ b/client/src/actions/install.js @@ -1,9 +1,7 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; -const apiClient = new Api(); - export const nextStep = createAction('NEXT_STEP'); export const prevStep = createAction('PREV_STEP'); diff --git a/client/src/actions/queryLogs.js b/client/src/actions/queryLogs.js index 1295ff6a..c68ddf15 100644 --- a/client/src/actions/queryLogs.js +++ b/client/src/actions/queryLogs.js @@ -1,11 +1,9 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { normalizeLogs } from '../helpers/helpers'; -const apiClient = new Api(); - export const getLogsRequest = createAction('GET_LOGS_REQUEST'); export const getLogsFailure = createAction('GET_LOGS_FAILURE'); export const getLogsSuccess = createAction('GET_LOGS_SUCCESS'); diff --git a/client/src/actions/rewrites.js b/client/src/actions/rewrites.js index df846fdd..1ff4a012 100644 --- a/client/src/actions/rewrites.js +++ b/client/src/actions/rewrites.js @@ -1,10 +1,8 @@ import { createAction } from 'redux-actions'; import { t } from 'i18next'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; -const apiClient = new Api(); - export const toggleRewritesModal = createAction('TOGGLE_REWRITES_MODAL'); export const getRewritesListRequest = createAction('GET_REWRITES_LIST_REQUEST'); diff --git a/client/src/actions/services.js b/client/src/actions/services.js index 7aae500f..c6e478de 100644 --- a/client/src/actions/services.js +++ b/client/src/actions/services.js @@ -1,9 +1,7 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; -const apiClient = new Api(); - export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST'); export const getBlockedServicesFailure = createAction('GET_BLOCKED_SERVICES_FAILURE'); export const getBlockedServicesSuccess = createAction('GET_BLOCKED_SERVICES_SUCCESS'); diff --git a/client/src/actions/stats.js b/client/src/actions/stats.js index e8483443..d8ab5bf5 100644 --- a/client/src/actions/stats.js +++ b/client/src/actions/stats.js @@ -1,11 +1,9 @@ import { createAction } from 'redux-actions'; -import Api from '../api/Api'; +import apiClient from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; -const apiClient = new Api(); - export const getStatsConfigRequest = createAction('GET_STATS_CONFIG_REQUEST'); export const getStatsConfigFailure = createAction('GET_STATS_CONFIG_FAILURE'); export const getStatsConfigSuccess = createAction('GET_STATS_CONFIG_SUCCESS'); diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 495be5b8..f39b28dc 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -1,6 +1,6 @@ import axios from 'axios'; -export default class Api { +class Api { baseUrl = 'control'; async makeRequest(path, method = 'POST', config) { @@ -528,3 +528,6 @@ export default class Api { return this.makeRequest(path, method); } } + +const apiClient = new Api(); +export default apiClient; diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index d9cd3bfa..e4f880b0 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -371,7 +371,7 @@ class Logs extends Component { )} {enabled && isDataReady && this.renderLogs(queryLogs.logs)} - {!enabled && isDataReady && ( + {!enabled && !processingGetConfig && (
link]}> query_log_disabled diff --git a/client/src/containers/Settings.js b/client/src/containers/Settings.js index 726e10a0..b78e140d 100644 --- a/client/src/containers/Settings.js +++ b/client/src/containers/Settings.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux'; import { initSettings, toggleSetting } from '../actions'; import { getBlockedServices, setBlockedServices } from '../actions/services'; import { getStatsConfig, setStatsConfig, resetStats } from '../actions/stats'; -import { toggleLogStatus, clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; +import { clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; import Settings from '../components/Settings'; const mapStateToProps = (state) => { @@ -26,7 +26,6 @@ const mapDispatchToProps = { getStatsConfig, setStatsConfig, resetStats, - toggleLogStatus, clearLogs, getLogsConfig, setLogsConfig,