From 5f1217247ff0b08813379ce1caa5fba162aec5fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=85=9C=E5=9D=A4?= Date: Mon, 21 Oct 2024 09:32:53 +0800 Subject: [PATCH] [ISSUE #12017] Update console frontend by using Console API (#12687) * [ISSUE #12017] Update the frontend of the console by using the Console API for config section * Update the request path * Update the request parameters * Update the return values * [ISSUE #12017] Update the frontend of the console by using the Console API for other section * Update the request path * Update the request parameters * Update the return values * [ISSUE #12017] Fix bug * Fix response code * Fix login --- .../src/components/BatchHandle/BatchHandle.js | 2 +- .../src/components/CloneDialog/CloneDialog.js | 2 +- .../EditorNameSpace/EditorNameSpace.js | 19 +++++---- .../components/ImportDialog/ImportDialog.js | 2 +- .../components/NameSpaceList/NameSpaceList.js | 6 +-- .../components/NewNameSpace/NewNameSpace.js | 10 +++-- .../ClusterNodeList/ClusterNodeList.js | 6 +-- .../ConfigDetail/ConfigCompared.js | 4 +- .../ConfigDetail/ConfigDetail.js | 28 +++++++------ .../ConfigEditor/ConfigEditor.js | 12 +++--- .../ConfigEditor/NewConfigEditor.js | 18 ++++----- .../ConfigRollback/ConfigRollback.js | 16 ++++---- .../ConfigSync/ConfigSync.js | 6 +-- .../ConfigurationManagement.js | 40 +++++++++---------- .../HistoryDetail/HistoryDetail.js | 4 +- .../HistoryRollback/HistoryRollback.js | 24 ++++++----- .../ListeningToQuery/ListeningToQuery.js | 12 +++--- .../NewConfig/NewConfig.js | 30 ++++++++------ console-ui/src/pages/NameSpace/NameSpace.js | 14 ++++--- .../ServiceDetail/EditClusterDialog.js | 4 +- .../ServiceDetail/EditInstanceDialog.js | 4 +- .../ServiceDetail/EditServiceDialog.js | 10 ++--- .../ServiceDetail/InstanceTable.js | 8 ++-- .../ServiceDetail/ServiceDetail.js | 4 +- .../ServiceList/ServiceList.js | 10 ++--- console-ui/src/reducers/authority.js | 28 ++++++------- console-ui/src/reducers/base.js | 14 +++---- console-ui/src/reducers/configuration.js | 8 ++-- console-ui/src/reducers/namespace.js | 4 +- console-ui/src/reducers/subscribers.js | 4 +- console-ui/src/utils/request.js | 2 +- .../v3/ConsoleServerStateController.java | 5 ++- 32 files changed, 189 insertions(+), 171 deletions(-) diff --git a/console-ui/src/components/BatchHandle/BatchHandle.js b/console-ui/src/components/BatchHandle/BatchHandle.js index e6bc9057faa..7f840c74745 100644 --- a/console-ui/src/components/BatchHandle/BatchHandle.js +++ b/console-ui/src/components/BatchHandle/BatchHandle.js @@ -80,7 +80,7 @@ class BatchHandle extends React.Component { dataSource.pageSize }`, success: res => { - if (res.code === 200) { + if (res.code === 0) { this.setState({ dataSourceList: res.data.map(obj => ({ diff --git a/console-ui/src/components/CloneDialog/CloneDialog.js b/console-ui/src/components/CloneDialog/CloneDialog.js index 5d7903c05f8..809cf73a91d 100644 --- a/console-ui/src/components/CloneDialog/CloneDialog.js +++ b/console-ui/src/components/CloneDialog/CloneDialog.js @@ -80,7 +80,7 @@ class CloneDialog extends React.Component { type: 'get', url: `/diamond-ops/service/serverId/${serverId}/namespaceInfo`, success: res => { - if (res.code === 200) { + if (res.code === 0) { const dataSource = []; res.data.forEach(value => { if (value.namespace !== payload.tenantFrom.id) { diff --git a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js index 5e1af4a796d..1f96be34380 100644 --- a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js +++ b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js @@ -72,8 +72,9 @@ class EditorNameSpace extends React.Component { this.field.setValues(record); request({ type: 'get', - url: `v1/console/namespaces?show=all&namespaceId=${record.namespace}`, + url: `v3/console/core/namespace?namespaceId=${record.namespace}`, success: res => { + res = res.data; if (res !== null) { this.field.setValue('namespaceDesc', res.namespaceDesc); } else { @@ -101,15 +102,18 @@ class EditorNameSpace extends React.Component { beforeSend: () => { this.openLoading(); }, - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace', contentType: 'application/x-www-form-urlencoded', data: { - namespace: values.namespace, - namespaceShowName: values.namespaceShowName, + namespaceId: values.namespace, + namespaceName: values.namespaceShowName, namespaceDesc: values.namespaceDesc, }, success: res => { - if (res === true) { + // res = res.data; + console.log(3); + if (res.code === 0) { + res = res.data; this.closeDialog(); this.props.getNameSpaces(); this.refreshNameSpace(); // 刷新全局namespace @@ -131,9 +135,10 @@ class EditorNameSpace extends React.Component { setTimeout(() => { request({ type: 'get', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace', success: res => { - if (res.code === 200) { + console.log(res); + if (res.code === 0) { window.namespaceList = res.data; } }, diff --git a/console-ui/src/components/ImportDialog/ImportDialog.js b/console-ui/src/components/ImportDialog/ImportDialog.js index 0086dd9b2d3..726dde6f5fe 100644 --- a/console-ui/src/components/ImportDialog/ImportDialog.js +++ b/console-ui/src/components/ImportDialog/ImportDialog.js @@ -85,7 +85,7 @@ class ImportDialog extends React.Component { }; formatter = res => { - if (res.code === 200) { + if (res.code === 0) { return { code: '0', retData: res, diff --git a/console-ui/src/components/NameSpaceList/NameSpaceList.js b/console-ui/src/components/NameSpaceList/NameSpaceList.js index 825337cfd53..b7e4d93f936 100644 --- a/console-ui/src/components/NameSpaceList/NameSpaceList.js +++ b/console-ui/src/components/NameSpaceList/NameSpaceList.js @@ -61,7 +61,7 @@ class NameSpaceList extends React.Component { linkKey, }, success: res => { - if (res.code === 200) { + if (res.code === 0) { window[keyName] = res.data; this.setState({ [keyName]: res.data, @@ -111,9 +111,9 @@ class NameSpaceList extends React.Component { } else { request({ type: 'get', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace/list', success: res => { - if (res.code === 200) { + if (res.code === 0) { this.handleNameSpaces(res.data); } else { Dialog.alert({ diff --git a/console-ui/src/components/NewNameSpace/NewNameSpace.js b/console-ui/src/components/NewNameSpace/NewNameSpace.js index 4f50e0c07d7..40b628e58e5 100644 --- a/console-ui/src/components/NewNameSpace/NewNameSpace.js +++ b/console-ui/src/components/NewNameSpace/NewNameSpace.js @@ -111,13 +111,14 @@ class NewNameSpace extends React.Component { } request({ type: 'get', - url: 'v1/console/namespaces?checkNamespaceIdExist=true', + url: 'v3/console/core/namespace/exist', contentType: 'application/x-www-form-urlencoded', beforeSend: () => this.openLoading(), data: { customNamespaceId, }, success: res => { + res = res.data; this.disabled = false; this.setState({ disabled: false, @@ -130,7 +131,7 @@ class NewNameSpace extends React.Component { } else { request({ type: 'post', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace', contentType: 'application/x-www-form-urlencoded', beforeSend: () => this.openLoading(), data: { @@ -139,6 +140,7 @@ class NewNameSpace extends React.Component { namespaceDesc: values.namespaceDesc, }, success: res => { + res = res.data; this.disabled = false; this.setState({ disabled: false, @@ -167,9 +169,9 @@ class NewNameSpace extends React.Component { setTimeout(() => { request({ type: 'get', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace', success: res => { - if (res.code === 200) { + if (res.code === 0) { window.namespaceList = res.data; } }, diff --git a/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js b/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js index 51092c9fa1a..8e4c74ef1d5 100644 --- a/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js +++ b/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js @@ -84,7 +84,7 @@ class ClusterNodeList extends React.Component { `keyword=${keyword}`, ]; request({ - url: `v1/core/cluster/nodes?${parameter.join('&')}`, + url: `v3/console/core/cluster/nodes?${parameter.join('&')}`, beforeSend: () => this.openLoading(), success: ({ count = 0, data = [] } = {}) => { this.setState({ @@ -107,9 +107,9 @@ class ClusterNodeList extends React.Component { const accessToken = JSON.parse(localStorage.token || '{}').accessToken; this.openLoading(); axios - .post(`v1/core/cluster/server/leave?accessToken=${accessToken}`, nodes) + .post(`v3/console/core/cluster/server/leave?accessToken=${accessToken}`, nodes) .then(response => { - if (response.data.code === 200) { + if (response.data.code === 0) { Message.success(locale.leaveSucc); } else { const errorMessage = response.data.message || locale.leaveFail; diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js index 21c97ae2235..bf876e5423b 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js @@ -58,9 +58,9 @@ class ConfigCompared extends React.Component { getNamespaces() { request({ type: 'get', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace/list', success: res => { - if (res.code === 200) { + if (res.code === 0) { const { namespacesDataSource } = this.state; this.setState({ namespacesDataSource: res.data }); } else { diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js index 59db9acfa39..3c87212384f 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js @@ -66,7 +66,7 @@ class ConfigDetail extends React.Component { this.group = getParams('group') || 'DEFAULT_GROUP'; this.ips = ''; this.valueMap = {}; // 存储不同版本的数据 - this.tenant = getParams('namespace') || ''; + this.namespaceId = getParams('namespace') || ''; this.searchDataId = getParams('searchDataId') || ''; this.searchGroup = getParams('searchGroup') || ''; this.pageSize = getParams('pageSize'); @@ -147,18 +147,18 @@ class ConfigDetail extends React.Component { const { locale = {} } = this.props; const self = this; this.serverId = getParams('serverId') || 'center'; - this.tenant = getParams('namespace') || ''; + this.namespaceId = getParams('namespace') || ''; this.edasAppName = getParams('edasAppName') || ''; this.inApp = this.edasAppName; - const url = `v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`; + const url = `v3/console/cs/config?&dataId=${this.dataId}&group=${this.group}`; request({ url, beforeSend() { self.openLoading(); }, success(result) { - if (result != null) { - const data = result; + if (result != null && result.code === 0) { + const data = result.data; self.valueMap.normal = data; self.field.setValue('dataId', data.dataId); self.field.setValue('content', data.content); @@ -186,7 +186,7 @@ class ConfigDetail extends React.Component { serverId: this.serverId, group: this.searchGroup, dataId: this.searchDataId, - namespace: this.tenant, + namespace: this.namespaceId, pageNo: this.pageNo, pageSize: this.pageSize, }) @@ -226,7 +226,7 @@ class ConfigDetail extends React.Component { let self = this; const { locale = {} } = this.props; let leftvalue = this.monacoEditor.getValue(); - let url = `v1/cs/history/previous?id=${this.valueMap.normal.id}&dataId=${this.dataId}&group=${this.group}`; + let url = `v3/console/cs/history/previous?id=${this.valueMap.normal.id}&dataId=${this.dataId}&group=${this.group}`; request({ url, beforeSend() { @@ -234,6 +234,7 @@ class ConfigDetail extends React.Component { }, success(result) { if (result != null) { + const result = result.data; let rightvalue = result.content; leftvalue = leftvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n'); rightvalue = rightvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n'); @@ -248,18 +249,19 @@ class ConfigDetail extends React.Component { }); } - openCompare = ([dataId, group, tenant]) => { + openCompare = ([dataId, group, namespaceId]) => { let self = this; const { locale = {} } = this.props; let leftvalue = this.monacoEditor.getValue(); const params = { - show: 'all', + // show: 'all', group, dataId, - tenant, + namespaceId, }; - requestUtils.get('v1/cs/configs', { params }).then(res => { - if (res != null && res !== '') { + requestUtils.get('v3/console/cs/config', { params }).then(res => { + if (res != null && res !== '' && res.code === 0) { + res = res.data; let rightvalue = res.content; leftvalue = leftvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n'); rightvalue = rightvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n'); @@ -319,7 +321,7 @@ class ConfigDetail extends React.Component { )}
-

{this.tenant}

+

{this.namespaceId}

diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js b/console-ui/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js index e1d181a14f7..97fe5d8c2fb 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigEditor/ConfigEditor.js @@ -184,15 +184,15 @@ class ConfigEditor extends React.Component { const self = this; this.tenant = getParams('namespace') || ''; this.serverId = getParams('serverId') || 'center'; - const url = `v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`; + const url = `v3/console/cs/config?dataId=${this.dataId}&group=${this.group}`; request({ url, beforeSend() { self.openLoading(); }, success(result) { - if (result != null) { - const data = result; + if (result != null && result.code === 0) { + const data = result.data; self.valueMap.normal = data; self.field.setValue('dataId', data.dataId); // self.field.setValue('content', data.content); @@ -369,12 +369,12 @@ class ConfigEditor extends React.Component { appName: this.inApp ? this.edasAppId : this.field.getValue('appName'), group: this.field.getValue('group'), desc: this.field.getValue('desc'), - config_tags: this.state.config_tags.join(','), + configTags: this.state.config_tags.join(','), type: this.state.configType, content, - tenant: this.tenant, + namespaceId: this.tenant, }; - const url = 'v1/cs/configs'; + const url = 'v3/console/cs/config'; request({ type: 'post', contentType: 'application/x-www-form-urlencoded', diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigEditor/NewConfigEditor.js b/console-ui/src/pages/ConfigurationManagement/ConfigEditor/NewConfigEditor.js index a8fdce74e7b..607a2bc5feb 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigEditor/NewConfigEditor.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigEditor/NewConfigEditor.js @@ -264,13 +264,13 @@ class ConfigEditor extends React.Component { const stringify = require('qs/lib/stringify'); this.setState({ loading: true }); return request({ - url: 'v1/cs/configs', + url: 'v3/console/cs/config', method: 'post', data: stringify(payload), headers, }).then( res => { - if (res) { + if (res.data) { if (isNewConfig) { this.setState({ isNewConfig: false }); } @@ -312,14 +312,14 @@ class ConfigEditor extends React.Component { stopBeta() { const { dataId, group } = this.state.form; - const tenant = getParams('namespace'); + const namespaceId = getParams('namespace'); return request - .delete('v1/cs/configs', { + .delete('v3/console/cs/config', { params: { beta: true, dataId, group, - tenant, + namespaceId, }, }) .then(res => { @@ -398,7 +398,7 @@ class ConfigEditor extends React.Component { } else { params.show = 'all'; } - return request.get('v1/cs/configs', { params }).then(res => { + return request.get('v3/console/cs/config', { params }).then(res => { const form = beta ? res.data : res; if (!form) return false; const { type, content, configTags, betaIps, md5 } = form; @@ -424,15 +424,15 @@ class ConfigEditor extends React.Component { tenant: namespace, }; // get subscribes of the namespace - return request.get('v1/cs/configs/listener', { params }).then(res => { + return request.get('v3/console/cs/config/listener', { params }).then(res => { const { subscriberDataSource } = this.state; - const lisentersGroupkeyIpMap = res.lisentersGroupkeyStatus; + const lisentersGroupkeyIpMap = res.data.lisentersGroupkeyStatus; if (lisentersGroupkeyIpMap) { this.setState({ subscriberDataSource: subscriberDataSource.concat(Object.keys(lisentersGroupkeyIpMap)), }); } - return res; + return res.data; }); } diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js b/console-ui/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js index 9d058df05e5..120d79513cf 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigRollback/ConfigRollback.js @@ -73,14 +73,14 @@ class ConfigRollback extends React.Component { getDataDetail() { const self = this; - this.tenant = getParams('namespace') || ''; + this.namespaceId = getParams('namespace') || ''; this.serverId = getParams('serverId') || 'center'; - const url = `v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`; + const url = `v3/console/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`; request({ url, success(result) { if (result != null) { - const data = result; + const data = result.data; const envName = self.serverId; self.id = data.id; // 详情的id self.field.setValue('dataId', data.dataId); @@ -143,12 +143,12 @@ class ConfigRollback extends React.Component { dataId: self.dataId, group: self.group, content: self.field.getValue('content'), - tenant: self.tenant, + namespaceId: self.tenant, }; - let url = 'v1/cs/configs'; + let url = 'v3/console/cs/config'; if (self.opType.trim() === 'I') { - url = `v1/cs/configs?dataId=${self.dataId}&group=${self.group}`; + url = `v3/console/cs/config?dataId=${self.dataId}&group=${self.group}`; postData = {}; } @@ -158,8 +158,8 @@ class ConfigRollback extends React.Component { contentType: 'application/x-www-form-urlencoded', url, data: postData, - success(data) { - if (data === true) { + success(res) { + if (res.data === true) { Dialog.alert({ content: locale.rollbackSuccessful }); } }, diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js b/console-ui/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js index 4ebc89b7ab2..7493c39ef5a 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigSync/ConfigSync.js @@ -79,7 +79,7 @@ class ConfigSync extends React.Component { request({ url: '/diamond-ops/env/domain', success(data) { - if (data.code === 200) { + if (data.code === 0) { const { envGroups } = data.data; self.setState({ @@ -105,7 +105,7 @@ class ConfigSync extends React.Component { self.openLoading(); }, success(result) { - if (result.code === 200) { + if (result.code === 0) { const { data = {} } = result; self.field.setValue('dataId', data.dataId); @@ -177,7 +177,7 @@ class ConfigSync extends React.Component { _payload.content = ''; _payload.dataId = payload.dataId; _payload.group = payload.group; - _payload.isok = res.code === 200; + _payload.isok = res.code === 0; if (!_payload.isok) { _payload.isok = false; _payload.message = res.message; diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js b/console-ui/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js index 7c02c3b269e..067f9126b77 100644 --- a/console-ui/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js +++ b/console-ui/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js @@ -279,7 +279,7 @@ class ConfigurationManagement extends React.Component { config_tags: this.state.config_tags.join(','), pageNo: prePageNo ? prePageNo : pageNo, pageSize: prePageSize ? prePageSize : this.state.pageSize, - tenant: this.tenant, + namespaceId: this.tenant, }; setParams('pageSize', null); setParams('pageNo', null); @@ -294,6 +294,7 @@ class ConfigurationManagement extends React.Component { } props = this.props.getConfigsV2(params); } else { + console.log('Params before request:', params); props = this.props.getConfigs(params); } props @@ -362,7 +363,7 @@ class ConfigurationManagement extends React.Component { ), onOk: () => { - const url = `v1/cs/configs?dataId=${record.dataId}&group=${record.group}`; + const url = `v3/console/cs/config?dataId=${record.dataId}&group=${record.group}`; request({ url, type: 'delete', @@ -579,9 +580,8 @@ class ConfigurationManagement extends React.Component { exportData() { const { group, appName, dataId, openUri } = this; const { accessToken = '', username = '' } = JSON.parse(localStorage.token || '{}'); - openUri('v1/cs/configs', { - export: 'true', - tenant: getParams('namespace'), + openUri('v3/console/cs/config/export', { + namespaceId: getParams('namespace'), group, appName, dataId, @@ -594,9 +594,8 @@ class ConfigurationManagement extends React.Component { exportDataNew() { const { group, appName, dataId, openUri } = this; const { accessToken = '', username = '' } = JSON.parse(localStorage.token || '{}'); - openUri('v1/cs/configs', { - exportV2: 'true', - tenant: getParams('namespace'), + openUri('v3/console/cs/config/export2', { + namespaceId: getParams('namespace'), group, appName, dataId, @@ -619,9 +618,8 @@ class ConfigurationManagement extends React.Component { } configsTableSelected.forEach((value, key, map) => ids.push(key)); if (newVersion) { - this.openUri('v1/cs/configs', { - exportV2: 'true', - tenant: getParams('namespace'), + this.openUri('v3/console/cs/config/export2', { + namespaceId: getParams('namespace'), group: '', appName: '', ids: ids.join(','), @@ -629,9 +627,8 @@ class ConfigurationManagement extends React.Component { username, }); } else { - this.openUri('v1/cs/configs', { - export: 'true', - tenant: getParams('namespace'), + this.openUri('v3/console/cs/config/export', { + namespaceId: getParams('namespace'), group: '', appName: '', ids: ids.join(','), @@ -670,9 +667,9 @@ class ConfigurationManagement extends React.Component { ), onOk: () => { const url = - `v1/cs/configs?delType=ids&ids=${Array.from(configsTableSelected.keys()).join( + `v3/console/cs/config/batchDelete?&ids=${Array.from(configsTableSelected.keys()).join( ',' - )}&tenant=` + self.state.nownamespace_id; + )}&namespaceId=` + self.state.nownamespace_id; request({ url, type: 'delete', @@ -699,13 +696,14 @@ class ConfigurationManagement extends React.Component { return; } request({ - url: 'v1/console/namespaces?namespaceId=', + url: 'v3/console/core/namespace?namespaceId=', beforeSend() { self.openLoading(); }, success(data) { + data = data.data self.closeLoading(); - if (!data || data.code !== 200 || !data.data) { + if (!data || data.code !== 0 || !data.data) { Dialog.alert({ title: locale.getNamespaceFailed, content: locale.getNamespaceFailed, @@ -855,7 +853,7 @@ class ConfigurationManagement extends React.Component { let cloneTargetSpace = self.field.getValue('cloneTargetSpace'); let sameConfigPolicy = self.field.getValue('sameConfigPolicy'); request({ - url: `v1/cs/configs?clone=true&tenant=${cloneTargetSpace}&policy=${sameConfigPolicy}&namespaceId=`, + url: `v3/console/cs/config/clone?namespaceId=${cloneTargetSpace}&policy=${sameConfigPolicy}&namespaceId=`, method: 'post', data: JSON.stringify(clonePostData), contentType: 'application/json', @@ -917,7 +915,7 @@ class ConfigurationManagement extends React.Component { processImportAndCloneResult(ret, locale, confirm, isImport) { const resultCode = ret.code; - if (resultCode === 200) { + if (resultCode === 0) { confirm.hide(); let failCount = ret.data.failData ? ret.data.failData.length : 0; let skipCount = ret.data.skipData ? ret.data.skipData.length : 0; @@ -1037,7 +1035,7 @@ class ConfigurationManagement extends React.Component { const { accessToken = '', username = '' } = token; const uploadProps = { accept: 'application/zip', - action: `v1/cs/configs?import=true&namespace=${getParams( + action: `v3/console/cs/config/import?namespaceId=${getParams( 'namespace' )}&accessToken=${accessToken}&username=${username}&tenant=${getParams('namespace')}`, headers: Object.assign({}, {}, { accessToken }), diff --git a/console-ui/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js b/console-ui/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js index 19b0cecb763..78080e3651a 100644 --- a/console-ui/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js +++ b/console-ui/src/pages/ConfigurationManagement/HistoryDetail/HistoryDetail.js @@ -61,10 +61,10 @@ class HistoryDetail extends React.Component { const { locale = {} } = this.props; const self = this; request({ - url: `v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`, + url: `v3/console/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`, success(result) { if (result != null) { - const data = result; + const data = result.data; self.field.setValue('dataId', data.dataId); self.field.setValue('content', data.content); self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName); diff --git a/console-ui/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js b/console-ui/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js index 4fe7f28d98b..5d6746ba291 100644 --- a/console-ui/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js +++ b/console-ui/src/pages/ConfigurationManagement/HistoryRollback/HistoryRollback.js @@ -115,9 +115,10 @@ class HistoryRollback extends React.Component { beforeSend() { self.openLoading(); }, - url: `v1/cs/history?search=accurate&dataId=${this.state.dataId}&group=${this.state.group}&&pageNo=${pageNo}&pageSize=${this.state.pageSize}`, - success(data) { - if (data != null) { + url: `v3/console/cs/history/list?dataId=${this.state.dataId}&group=${this.state.group}&&pageNo=${pageNo}&pageSize=${this.state.pageSize}`, + success(res) { + if (res != null) { + const data = res.data self.setState({ dataSource: data.pageItems || [], total: data.totalCount, @@ -234,9 +235,9 @@ class HistoryRollback extends React.Component { return new Promise((resolve, reject) => { const { locale = {} } = this.props; const self = this; - this.tenant = tenant; + this.namespaceId = tenant; this.serverId = tenant; - const url = `v1/cs/configs?show=all&dataId=${dataId}&group=${group}`; + const url = `v3/console/cs/config?dataId=${dataId}&group=${group}`; request({ url, beforeSend() { @@ -244,7 +245,7 @@ class HistoryRollback extends React.Component { }, success(result) { if (result != null) { - resolve(result); + resolve(result.data); } }, complete() { @@ -266,10 +267,10 @@ class HistoryRollback extends React.Component { const { locale = {} } = this.props; const self = this; request({ - url: `v1/cs/history?dataId=${dataId}&group=${group}&nid=${nid}`, + url: `v3/console/cs/history?dataId=${dataId}&group=${group}&nid=${nid}`, success(result) { if (result != null) { - resolve(result); + resolve(result.data); } }, }); @@ -291,9 +292,10 @@ class HistoryRollback extends React.Component { this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数 const self = this; request({ - url: `v1/cs/history/configs?tenant=${this.tenant}`, - success(result) { - if (result != null) { + url: `v3/console/cs/history/configs?namespaceId=${this.tenant}`, + success(res) { + if (res != null) { + const result = res.data; const dataIdList = []; const groupList = []; for (let i = 0; i < result.length; i++) { diff --git a/console-ui/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js b/console-ui/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js index 66e14396115..04802407bac 100644 --- a/console-ui/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js +++ b/console-ui/src/pages/ConfigurationManagement/ListeningToQuery/ListeningToQuery.js @@ -92,26 +92,26 @@ class ListeningToQuery extends React.Component { const type = this.getValue('type'); if (type === 1) { const ip = this.getValue('ip'); - queryUrl = `v1/cs/listener?ip=${ip}`; + queryUrl = `v3/console/cs/config/listener/ip?ip=${ip}`; const tenant = window.nownamespace || getParams('namespace') || ''; if (tenant) { - queryUrl += `&tenant=${tenant}`; + queryUrl += `&namespaceId=${tenant}`; } } else { const dataId = this.getValue('dataId'); const group = this.getValue('group'); if (!dataId || !group) return false; - queryUrl = `v1/cs/configs/listener?dataId=${dataId}&group=${group}`; + queryUrl = `v3/console/cs/config/listener?dataId=${dataId}&group=${group}`; } request({ url: queryUrl, beforeSend() { self.openLoading(); }, - success(data) { - if (data.collectStatus === 200) { + success(res) { + if (res.code === 0) { const dataSoureTmp = []; - const status = data.lisentersGroupkeyStatus; + const status = res.data; for (const key in status) { if (type === 1) { const obj = {}; diff --git a/console-ui/src/pages/ConfigurationManagement/NewConfig/NewConfig.js b/console-ui/src/pages/ConfigurationManagement/NewConfig/NewConfig.js index 0109d364e9b..b19bb9cd516 100644 --- a/console-ui/src/pages/ConfigurationManagement/NewConfig/NewConfig.js +++ b/console-ui/src/pages/ConfigurationManagement/NewConfig/NewConfig.js @@ -297,22 +297,28 @@ class NewConfig extends React.Component { const { locale = {} } = this.props; const { addonBefore } = this.state; request({ - url: 'v1/cs/configs', + url: 'v3/console/cs/config', data: { - show: 'all', dataId: addonBefore + this.field.getValue('dataId'), group: this.field.getValue('group'), - tenant: getParams('namespace') || '', + namespaceId: getParams('namespace') || '', }, success: res => { - // 返回成功 说明存在就不提交配置 - Message.error({ - content: locale.dataIdExists, - align: 'cc cc', - }); + // 检查 res.data 是否为 null,如果不是 null,说明存在就不提交配置 + if (res.data !== null) { + console.log('Data exists, not submitting config'); // 输出提示信息 + Message.error({ + content: locale.dataIdExists, + align: 'cc cc', + }); + } else { + console.log('Data does not exist, proceeding to publish config'); // 输出提示信息 + // 如果 res.data 为 null,表示没有数据,可以继续处理 + this._publishConfig(content); + } }, error: err => { - // 后端接口很不规范 响应为空 说明没有数据 就可以新增 + // 后端接口很不规范,响应为空,说明没有数据,可以新增 const { status } = err || {}; if (status === 403) { Dialog.alert({ @@ -335,13 +341,13 @@ class NewConfig extends React.Component { group: this.field.getValue('group'), content, desc: this.field.getValue('desc'), - config_tags: config_tags.join(), + configTags: config_tags.join(), type: configType, appName: this.inApp ? this.edasAppId : this.field.getValue('appName'), - tenant: this.tenant, + namespaceId: this.tenant, }; this.serverId = getParams('serverId') || 'center'; - const url = 'v1/cs/configs'; + const url = 'v3/console/cs/config'; request({ type: 'post', contentType: 'application/x-www-form-urlencoded', diff --git a/console-ui/src/pages/NameSpace/NameSpace.js b/console-ui/src/pages/NameSpace/NameSpace.js index e5e119138e5..34e284aef12 100644 --- a/console-ui/src/pages/NameSpace/NameSpace.js +++ b/console-ui/src/pages/NameSpace/NameSpace.js @@ -57,9 +57,9 @@ class NameSpace extends React.Component { request({ type: 'get', beforeSend() {}, - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace/list', success: res => { - if (res.code === 200) { + if (res.code === 0) { const data = res.data || []; window.namespaceList = data; @@ -113,11 +113,12 @@ class NameSpace extends React.Component { const { namespaceDetails, namespaceName, namespaceID, configuration, description } = locale; const { namespace } = record; // 获取ak,sk request({ - url: `v1/console/namespaces?show=all&namespaceId=${namespace}`, + url: `v3/console/core/namespace?namespaceId=${namespace}`, beforeSend: () => { this.openLoading(); }, success: res => { + res = res.data; if (res !== null) { Dialog.alert({ style: { width: '500px' }, @@ -182,11 +183,12 @@ class NameSpace extends React.Component { ), onOk: () => { - const url = `v1/console/namespaces?namespaceId=${record.namespace}`; + const url = `v3/console/core/namespace?namespaceId=${record.namespace}`; request({ url, type: 'delete', success: res => { + res = res.data; const _payload = {}; _payload.title = configurationManagement; if (res === true) { @@ -210,9 +212,9 @@ class NameSpace extends React.Component { refreshNameSpace() { request({ type: 'get', - url: 'v1/console/namespaces', + url: 'v3/console/core/namespace', success: res => { - if (res.code === 200) { + if (res.code === 0) { window.namespaceList = res.data; } }, diff --git a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js index be8d0e15253..b2e4e07eaa5 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js +++ b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditClusterDialog.js @@ -69,7 +69,7 @@ class EditClusterDialog extends React.Component { } = this.state.editCluster; request({ method: 'PUT', - url: 'v1/ns/cluster', + url: 'v3/console/ns/service/cluster', data: { serviceName, clusterName: name, @@ -81,7 +81,7 @@ class EditClusterDialog extends React.Component { dataType: 'text', beforeSend: () => openLoading(), success: res => { - if (res !== 'ok') { + if (res.data !== 'ok') { Message.error(res); return; } diff --git a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js index 0ae62f5170c..f0541791574 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js +++ b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditInstanceDialog.js @@ -69,7 +69,7 @@ class EditInstanceDialog extends React.Component { const { ip, port, ephemeral, weight, enabled, metadataText } = this.state.editInstance; request({ method: 'PUT', - url: 'v1/ns/instance', + url: 'v3/console/ns/instance', data: { serviceName, clusterName, @@ -84,7 +84,7 @@ class EditInstanceDialog extends React.Component { dataType: 'text', beforeSend: () => openLoading(), success: res => { - if (res !== 'ok') { + if (res.data !== 'ok') { Message.error(res); return; } diff --git a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js index f7ec01bc80c..b6d695b19e8 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js +++ b/console-ui/src/pages/ServiceManagement/ServiceDetail/EditServiceDialog.js @@ -86,7 +86,7 @@ class EditServiceDialog extends React.Component { if (!this.validator({ name, protectThreshold })) return; request({ method: isCreate ? 'POST' : 'PUT', - url: 'v1/ns/service', + url: 'v3/console/ns/service', data: { serviceName: name, groupName: groupName || 'DEFAULT_GROUP', @@ -97,7 +97,7 @@ class EditServiceDialog extends React.Component { dataType: 'text', beforeSend: () => this.setState({ loading: true }), success: res => { - if (res !== 'ok') { + if (res.data !== 'ok') { Message.error(res); return; } @@ -107,7 +107,7 @@ class EditServiceDialog extends React.Component { this.props.getServiceDetail(); } }, - error: res => Message.error(res.responseText || res.statusText), + error: res => Message.error(res.data.responseText || res.data.statusText), complete: () => this.setState({ loading: false }), }); this.hide(); @@ -136,9 +136,9 @@ class EditServiceDialog extends React.Component { getSelectorTypes() { request({ method: 'GET', - url: 'v1/ns/service/selector/types', + url: 'v3/console/ns/service/selector/types', success: response => { - if (response.code !== 200) { + if (response.code !== 0) { Message.error(response.message); return; } diff --git a/console-ui/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js b/console-ui/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js index 3bcbea26d65..30a570ebe4b 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js +++ b/console-ui/src/pages/ServiceManagement/ServiceDetail/InstanceTable.js @@ -69,7 +69,7 @@ class InstanceTable extends React.Component { if (!clusterName) return; const { pageSize, pageNum } = this.state; request({ - url: 'v1/ns/catalog/instances', + url: 'v3/console/ns/instance/list', data: { serviceName, clusterName, @@ -78,7 +78,7 @@ class InstanceTable extends React.Component { pageNo: pageNum, }, beforeSend: () => this.openLoading(), - success: instance => this.setState({ instance }), + success: ({ data: instance }) => this.setState({ instance }), complete: () => this.closeLoading(), }); } @@ -93,7 +93,7 @@ class InstanceTable extends React.Component { const { clusterName, serviceName, groupName } = this.props; request({ method: 'PUT', - url: 'v1/ns/instance', + url: 'v3/console/ns/instance', data: { serviceName, clusterName, @@ -107,7 +107,7 @@ class InstanceTable extends React.Component { }, dataType: 'text', beforeSend: () => this.openLoading(), - success: () => { + success: ({ data }) => { const newVal = Object.assign({}, instance); newVal.list[index].enabled = !enabled; this.setState({ instance: newVal }); diff --git a/console-ui/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js b/console-ui/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js index 651b6b116c2..23b9b5f1259 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js +++ b/console-ui/src/pages/ServiceManagement/ServiceDetail/ServiceDetail.js @@ -72,9 +72,9 @@ class ServiceDetail extends React.Component { getServiceDetail() { const { serviceName, groupName } = this.state; request({ - url: `v1/ns/catalog/service?serviceName=${serviceName}&groupName=${groupName}`, + url: `v3/console/ns/service?serviceName=${serviceName}&groupName=${groupName}`, beforeSend: () => this.openLoading(), - success: ({ clusters = [], service = {} }) => this.setState({ service, clusters }), + success: ({ data: { clusters = [], service = {} } }) => this.setState({ service, clusters }), error: e => Message.error(e.responseText || 'error'), complete: () => this.closeLoading(), }); diff --git a/console-ui/src/pages/ServiceManagement/ServiceList/ServiceList.js b/console-ui/src/pages/ServiceManagement/ServiceList/ServiceList.js index f30ceac8d3e..e272407ac24 100644 --- a/console-ui/src/pages/ServiceManagement/ServiceList/ServiceList.js +++ b/console-ui/src/pages/ServiceManagement/ServiceList/ServiceList.js @@ -103,8 +103,8 @@ class ServiceList extends React.Component { }); this.openLoading(); request({ - url: `v1/ns/catalog/services?${parameter.join('&')}`, - success: ({ count = 0, serviceList = [] } = {}) => { + url: `v3/console/ns/service/list?${parameter.join('&')}`, + success: ({ data: { count = 0, serviceList = [] } = {} }) => { this.setState({ dataSource: serviceList, total: count, @@ -158,17 +158,17 @@ class ServiceList extends React.Component { onOk: () => { request({ method: 'DELETE', - url: `v1/ns/service?serviceName=${service.name}&groupName=${service.groupName}`, + url: `v3/console/ns/service?serviceName=${service.name}&groupName=${service.groupName}`, dataType: 'text', beforeSend: () => this.openLoading(), success: res => { - if (res !== 'ok') { + if (res.data !== 'ok') { Message.error(res); return; } this.queryServiceList(); }, - error: res => Message.error(res.responseText || res.statusText), + error: res => Message.error(res.data.responseText || res.data.statusText), complete: () => this.closeLoading(), }); }, diff --git a/console-ui/src/reducers/authority.js b/console-ui/src/reducers/authority.js index 8c4ece20617..e34367eeb96 100644 --- a/console-ui/src/reducers/authority.js +++ b/console-ui/src/reducers/authority.js @@ -40,7 +40,7 @@ const initialState = { }; const successMsg = res => { - if (res.code === 200) { + if (res.code === 0) { Message.success(res.message); } return res; @@ -51,35 +51,35 @@ const successMsg = res => { * @param {*} params */ const getUsers = params => dispatch => - request.get('v1/auth/users', { params }).then(data => dispatch({ type: USER_LIST, data })); + request.get('v3/auth/user/list', { params }).then(data => dispatch({ type: USER_LIST, data: data.data })); /** * 创建用户 * @param {*} param0 */ const createUser = ([username, password]) => - request.post('v1/auth/users', { username, password }).then(res => successMsg(res)); + request.post('v3/auth/user', { username, password }).then(res => successMsg(res)); /** * 通过username 模糊匹配 * @param {*} param0 */ const searchUsers = username => - request.get('v1/auth/users/search', { params: { username } }).then(res => successMsg(res)); + request.get('v3/auth/user/search', { params: { username } }).then(res => successMsg(res.data)); /** * 删除用户 * @param {*} username */ const deleteUser = username => - request.delete('v1/auth/users', { params: { username } }).then(res => successMsg(res)); + request.delete('v3/auth/user', { params: { username } }).then(res => successMsg(res)); /** * 重置密码 * @param {*} param0 */ const passwordReset = ([username, newPassword]) => - request.put('v1/auth/users', { username, newPassword }).then(res => successMsg(res)); + request.put('v3/auth/user', { username, newPassword }).then(res => successMsg(res)); /** * 角色列表 @@ -87,28 +87,28 @@ const passwordReset = ([username, newPassword]) => */ const getRoles = params => dispatch => - request.get('v1/auth/roles', { params }).then(data => dispatch({ type: ROLE_LIST, data })); + request.get('v3/auth/role/list', { params }).then(data => dispatch({ type: ROLE_LIST, data: data.data })); /** * 通过username 模糊匹配 * @param {*} param0 */ const searchRoles = role => - request.get('v1/auth/roles/search', { params: { role } }).then(res => successMsg(res)); + request.get('v3/auth/role/search', { params: { role } }).then(res => successMsg(res.data)); /** * 创建角色 * @param {*} param0 */ const createRole = ([role, username]) => - request.post('v1/auth/roles', { role, username }).then(res => successMsg(res)); + request.post('v3/auth/role', { role, username }).then(res => successMsg(res)); /** * 删除角色 * @param {*} param0 */ const deleteRole = role => - request.delete('v1/auth/roles', { params: role }).then(res => successMsg(res)); + request.delete('v3/auth/role', { params: role }).then(res => successMsg(res)); /** * 权限列表 @@ -116,22 +116,22 @@ const deleteRole = role => */ const getPermissions = params => dispatch => request - .get('v1/auth/permissions', { params }) - .then(data => dispatch({ type: PERMISSIONS_LIST, data })); + .get('v3/auth/permission/list', { params }) + .then(data => dispatch({ type: PERMISSIONS_LIST, data: data.data })); /** * 给角色添加权限 * @param {*} param0 */ const createPermission = ([role, resource, action]) => - request.post('v1/auth/permissions', { role, resource, action }).then(res => successMsg(res)); + request.post('v3/auth/permission', { role, resource, action }).then(res => successMsg(res)); /** * 删除权限 * @param {*} param0 */ const deletePermission = permission => - request.delete('v1/auth/permissions', { params: permission }).then(res => successMsg(res)); + request.delete('v3/auth/permission', { params: permission }).then(res => successMsg(res)); export default (state = initialState, action) => { switch (action.type) { diff --git a/console-ui/src/reducers/base.js b/console-ui/src/reducers/base.js index b773ec77191..47948f31e44 100644 --- a/console-ui/src/reducers/base.js +++ b/console-ui/src/reducers/base.js @@ -33,22 +33,22 @@ const initialState = { * 用户登录 * @param {*} param0 */ -const login = user => request.post('v1/auth/users/login', user); -const admin = user => request.post('v1/auth/users/admin', user); +const login = user => request.post('v3/auth/user/login', user); +const admin = user => request.post('v3/auth/user/admin', user); /** * 单独在login处调用 获取提示信息 */ -const guide = () => request.get('v1/console/server/guide'); +const guide = () => request.get('v3/console/server/guide'); /** * 单独在login调用 判断是否可以登陆 */ -const state = () => request.get('v1/console/server/state'); +const state = () => request.get('v3/console/server/state'); const getState = () => dispatch => request - .get('v1/console/server/state') + .get('v3/console/server/state') .then(res => { localStorage.setItem(LOGINPAGE_ENABLED, res.login_page_enabled); dispatch({ @@ -82,7 +82,7 @@ const getState = () => dispatch => const getNotice = () => dispatch => request - .get('v1/console/server/announcement?language=' + localStorage.getItem(LANGUAGE_KEY)) + .get('v3/console/server/announcement?language=' + localStorage.getItem(LANGUAGE_KEY)) .then(res => { dispatch({ type: GET_NOTICE, @@ -102,7 +102,7 @@ const getNotice = () => dispatch => const getGuide = () => dispatch => request - .get('v1/console/server/guide') + .get('v3/console/server/guide') .then(res => { dispatch({ type: SERVER_GUIDE, diff --git a/console-ui/src/reducers/configuration.js b/console-ui/src/reducers/configuration.js index 5e5c000bbc7..b7f720c6f3b 100644 --- a/console-ui/src/reducers/configuration.js +++ b/console-ui/src/reducers/configuration.js @@ -23,13 +23,13 @@ const initialState = { const getConfigs = params => dispatch => request - .get('v1/cs/configs', { params }) - .then(data => dispatch({ type: GET_CONFIGURATION, data })); + .get('v3/console/cs/config/list', { params }) + .then(data => dispatch({ type: GET_CONFIGURATION, data: data.data })); const getConfigsV2 = params => dispatch => request - .get('v2/cs/config/searchDetail', { params }) - .then(data => dispatch({ type: GET_CONFIGURATION, data })); + .get('v3/console/cs/config/searchDetail', { params }) + .then(data => dispatch({ type: GET_CONFIGURATION, data: data.data })); export default (state = initialState, action) => { switch (action.type) { diff --git a/console-ui/src/reducers/namespace.js b/console-ui/src/reducers/namespace.js index d5cecd8026a..d84cd9dca54 100644 --- a/console-ui/src/reducers/namespace.js +++ b/console-ui/src/reducers/namespace.js @@ -22,11 +22,11 @@ const initialState = { }; const getNamespaces = params => dispatch => - request.get('v1/console/namespaces', { params }).then(response => { + request.get('v3/console/core/namespace/list', { params }).then(response => { const { code, data } = response; dispatch({ type: GET_NAMESPACES, - data: code === 200 ? data : [], + data: code === 0 ? data : [], }); }); diff --git a/console-ui/src/reducers/subscribers.js b/console-ui/src/reducers/subscribers.js index da5667d2d1f..fb36b1d7f31 100644 --- a/console-ui/src/reducers/subscribers.js +++ b/console-ui/src/reducers/subscribers.js @@ -22,10 +22,10 @@ const initialState = { }; const getSubscribers = params => dispatch => - request.get('v1/ns/service/subscribers', { params }).then(data => { + request.get('v3/console/ns/service/subscribers', { params }).then(data => { dispatch({ type: GET_SUBSCRIBERS, - data, + data: data.data, }); }); const removeSubscribers = () => dispatch => dispatch({ type: REMOVE_SUBSCRIBERS }); diff --git a/console-ui/src/utils/request.js b/console-ui/src/utils/request.js index fd07b92e6b7..18b981d94bd 100644 --- a/console-ui/src/utils/request.js +++ b/console-ui/src/utils/request.js @@ -40,7 +40,7 @@ const request = () => { if (!params) { config.params = {}; } - if (!url.includes('auth/users/login') && localStorage.token) { + if (!url.includes('auth/user/login') && localStorage.token) { let token = {}; try { token = JSON.parse(localStorage.token); diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java b/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java index a2eb4c28839..2928a8553fb 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java @@ -22,6 +22,7 @@ import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.console.proxy.ServerStateProxy; import com.alibaba.nacos.core.paramcheck.ExtractorManager; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -51,9 +52,9 @@ public ConsoleServerStateController(ServerStateProxy serverStateProxy) { * @return state json. */ @GetMapping("/state") - public Result> serverState() { + public ResponseEntity> serverState() { Map serverState = serverStateProxy.getServerState(); - return Result.success(serverState); + return ResponseEntity.ok().body(serverState); } /**