Skip to content

Commit

Permalink
[ISSUE #12017] Update console frontend by using Console API (#12687)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
RickonZhang0929 authored Oct 21, 2024
1 parent 76cab27 commit 5f12172
Show file tree
Hide file tree
Showing 32 changed files with 189 additions and 171 deletions.
2 changes: 1 addition & 1 deletion console-ui/src/components/BatchHandle/BatchHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
2 changes: 1 addition & 1 deletion console-ui/src/components/CloneDialog/CloneDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 12 additions & 7 deletions console-ui/src/components/EditorNameSpace/EditorNameSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
},
Expand Down
2 changes: 1 addition & 1 deletion console-ui/src/components/ImportDialog/ImportDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ImportDialog extends React.Component {
};

formatter = res => {
if (res.code === 200) {
if (res.code === 0) {
return {
code: '0',
retData: res,
Expand Down
6 changes: 3 additions & 3 deletions console-ui/src/components/NameSpaceList/NameSpaceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
10 changes: 6 additions & 4 deletions console-ui/src/components/NewNameSpace/NewNameSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: {
Expand All @@ -139,6 +140,7 @@ class NewNameSpace extends React.Component {
namespaceDesc: values.namespaceDesc,
},
success: res => {
res = res.data;
this.disabled = false;
this.setState({
disabled: false,
Expand Down Expand Up @@ -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;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
})
Expand Down Expand Up @@ -226,14 +226,15 @@ 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() {
self.openLoading();
},
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');
Expand All @@ -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');
Expand Down Expand Up @@ -319,7 +321,7 @@ class ConfigDetail extends React.Component {
)}
<Form inline={false} field={this.field} {...formItemLayout}>
<FormItem label={locale.namespace} required>
<p>{this.tenant}</p>
<p>{this.namespaceId}</p>
</FormItem>
<FormItem label={'Data ID'} required>
<Input htmlType={'text'} readOnly {...init('dataId')} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
});
}

Expand Down
Loading

0 comments on commit 5f12172

Please sign in to comment.