From 51ce42593b5a7c5bab4ddc249957886b296c7552 Mon Sep 17 00:00:00 2001 From: LoadChange Date: Sun, 15 Mar 2020 18:19:35 +0800 Subject: [PATCH] fix: closes #2449 --- .../static/console-fe/src/constants.js | 2 + .../static/console-fe/src/globalLib.js | 9 +- .../ConfigurationManagement.js | 565 +++++++++--------- .../ConfigurationManagement/index.scss | 7 +- .../console-fe/src/reducers/configuration.js | 35 ++ .../static/console-fe/src/reducers/index.js | 3 +- .../static/console-fe/src/utils/request.js | 8 +- 7 files changed, 339 insertions(+), 290 deletions(-) create mode 100644 console/src/main/resources/static/console-fe/src/reducers/configuration.js diff --git a/console/src/main/resources/static/console-fe/src/constants.js b/console/src/main/resources/static/console-fe/src/constants.js index c54e60382..cea183963 100644 --- a/console/src/main/resources/static/console-fe/src/constants.js +++ b/console/src/main/resources/static/console-fe/src/constants.js @@ -33,3 +33,5 @@ export const ROLE_LIST = 'ROLE_LIST'; export const PERMISSIONS_LIST = 'PERMISSIONS_LIST'; export const GET_NAMESPACES = 'GET_NAMESPACES'; + +export const GET_CONFIGURATION = 'GET_CONFIGURATION'; diff --git a/console/src/main/resources/static/console-fe/src/globalLib.js b/console/src/main/resources/static/console-fe/src/globalLib.js index fc5de4bec..852ce84a1 100644 --- a/console/src/main/resources/static/console-fe/src/globalLib.js +++ b/console/src/main/resources/static/console-fe/src/globalLib.js @@ -482,8 +482,13 @@ const request = (function(_global) { // 处理后置中间件 config = handleMiddleWare.apply(this, [config, ...args, middlewareBackList]); - - const { accessToken = '' } = JSON.parse(localStorage.token || '{}'); + let token = {}; + try { + token = JSON.parse(localStorage.token || '{}'); + } catch (e) { + console.log(e); + } + const { accessToken = '' } = token; const [url, paramsStr = ''] = config.url.split('?'); const params = paramsStr.split('&'); params.push(`accessToken=${accessToken}`); diff --git a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js index aa26dca68..780bbd88c 100644 --- a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js +++ b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js @@ -39,15 +39,20 @@ import ShowCodeing from 'components/ShowCodeing'; import DeleteDialog from 'components/DeleteDialog'; import DashboardCard from './DashboardCard'; import { getParams, setParams, request, aliwareIntl } from '@/globalLib'; -import axios from 'axios'; +import { connect } from 'react-redux'; +import { getConfigs } from '../../../reducers/configuration'; import './index.scss'; import { LANGUAGE_KEY } from '../../../constants'; const { Panel } = Collapse; -const { Row, Col } = Grid; const configsTableSelected = new Map(); - +@connect( + state => ({ + configurations: state.configuration.configurations, + }), + { getConfigs } +) @ConfigProvider.config class ConfigurationManagement extends React.Component { static displayName = 'ConfigurationManagement'; @@ -273,12 +278,22 @@ class ConfigurationManagement extends React.Component { const self = this; this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数 this.serverId = getParams('serverId') || ''; + const params = { + dataId: this.dataId, + group: this.group, + appName: this.appName, + config_tags: this.state.config_tags.join(','), + pageNo, + pageSize: this.state.pageSize, + }; let urlPrefix = ''; if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) { - urlPrefix = 'v1/cs/configs?search=blur'; + params.search = 'blur'; } else { - urlPrefix = 'v1/cs/configs?search=accurate'; + params.search = 'accurate'; } + this.setState({ loading: true }); + this.props.getConfigs(params).then(() => this.setState({ loading: false })); request({ url: `${urlPrefix}&dataId=${this.dataId}&group=${this.group}&appName=${ @@ -430,7 +445,7 @@ class ConfigurationManagement extends React.Component { changePage(value, e) { this.setState( { - isPageEnter: e.keyCode && e.keyCode === 13, + isPageEnter: e && e.keyCode && e.keyCode === 13, currentPage: value, }, () => this.getData(value, false) @@ -498,6 +513,7 @@ class ConfigurationManagement extends React.Component { setConfigTags(value) { this.setState({ config_tags: value, + tagLst: value, }); } @@ -615,7 +631,7 @@ class ConfigurationManagement extends React.Component { {'failedItems' in res.data && res.data.failedItems.length > 0 ? ( - +
@@ -625,7 +641,7 @@ class ConfigurationManagement extends React.Component { )} {'succeededItems' in res.data && res.data.succeededItems.length > 0 ? ( - +
@@ -635,7 +651,7 @@ class ConfigurationManagement extends React.Component { )} {'unprocessedItems' in res.data && res.data.unprocessedItems.length > 0 ? ( - +
@@ -844,7 +860,7 @@ class ConfigurationManagement extends React.Component { title: locale.cloningConfiguration, footer: false, content: ( -
+ <>
{locale.source} {self.state.nownamespace_name} |{' '} @@ -962,25 +978,19 @@ class ConfigurationManagement extends React.Component {
- + {locale.cloneEditableTitle}
-
- - - -
-
-
+ + + +
+ ), }); }, @@ -1167,272 +1177,259 @@ class ConfigurationManagement extends React.Component { } render() { - const { locale = {} } = this.props; + const { locale = {}, configurations = {} } = this.props; return ( <> (this.batchHandle = ref)} /> - -
-
-
- -
-
-

- - {locale.configurationManagement8} - - | - - {this.state.nownamespace_name} - - - {this.state.nownamespace_id} - - {locale.queryResults} - {this.state.total} - {locale.articleMeetRequirements} -

-
-
-
-
- - - - - - - - - - - -
- - {locale.advancedQuery9} - - -
-
- - - - - - -
- - - - - + + + + + + + + + +
+ + {locale.advancedQuery9} + + +
+
+ + + + + + +
+ + + + +