Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #12017] Update console frontend by using Console API #12687

Open
wants to merge 21 commits into
base: summer-ospp#12017
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f524ec
[ISSUE #12017] Add the console backend API for config section
RickonZhang0929 Aug 26, 2024
0ad172f
[ISSUE #12017] Add the console backend API for naming section
RickonZhang0929 Aug 26, 2024
052112a
[ISSUE #12017] Add the console backend API for auth section
RickonZhang0929 Aug 26, 2024
2ab42c0
[ISSUE #12017] Add the console backend API for core section
RickonZhang0929 Aug 26, 2024
e3a35c1
[ISSUE #12017] Fix the error by adding ApiType
RickonZhang0929 Aug 28, 2024
ba15b90
Merge branch 'summer-ospp#12017' into develop-issue#12017-api-config
RickonZhang0929 Aug 28, 2024
bc91264
[ISSUE #12017] Refactor the old version of the console's controller
RickonZhang0929 Aug 30, 2024
4824ab0
Revert "[ISSUE #12017] Add the console backend API for auth section"
RickonZhang0929 Sep 3, 2024
363048c
[ISSUE #12017] Updated ControllerV3 for auth section
RickonZhang0929 Sep 4, 2024
215ab4b
[ISSUE #12017] Fix errors
RickonZhang0929 Sep 4, 2024
5018051
Merge remote-tracking branch 'origin/develop-issue#12017-api-old' int…
RickonZhang0929 Sep 5, 2024
819a8e1
[ISSUE #12017] Add unit tests for all sections
RickonZhang0929 Sep 6, 2024
24359ec
[ISSUE #12017] Fix bugs
RickonZhang0929 Sep 6, 2024
fac084f
Merge branch 'summer-ospp#12017' into develop-issue#12017-api-test
RickonZhang0929 Sep 6, 2024
633f7cf
[ISSUE #12017] Add language validate
RickonZhang0929 Sep 10, 2024
69ddc71
Merge remote-tracking branch 'origin/develop-issue#12017-api-test' in…
RickonZhang0929 Sep 10, 2024
a260de0
[ISSUE #12017] Add validation operations
RickonZhang0929 Sep 10, 2024
78549f1
[ISSUE #12017] Fix namespace update method
RickonZhang0929 Sep 10, 2024
1761ee8
[ISSUE #12017] Add config error codes
RickonZhang0929 Sep 10, 2024
0b4e2b0
[ISSUE #12017] Optimize API
RickonZhang0929 Sep 24, 2024
92e4845
[ISSUE #12017] Update the frontend of the console by using the Consol…
RickonZhang0929 Sep 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

</dependencies>
</project>
15 changes: 14 additions & 1 deletion api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,20 @@ public enum ErrorCode {
/**
* server error.
*/
SERVER_ERROR(30000, "server error");
SERVER_ERROR(30000, "server error"),

/**
* Config use 100001 ~ 100999.
**/
METADATA_ILLEGAL(100002, "导入的元数据非法"),

DATA_VALIDATION_FAILED(100003, "未读取到合法数据"),

PARSING_DATA_FAILED(100004, "解析数据失败"),

DATA_EMPTY(100005, "导入的文件数据为空"),

NO_SELECTED_CONFIG(100006, "没有选择任何配置");

private final Integer code;

Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/model/v2/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.alibaba.nacos.api.model.v2;

import java.io.Serializable;
import org.springframework.http.HttpStatus;

/**
* Response Result.
Expand Down Expand Up @@ -96,6 +97,15 @@ public static <T> Result<T> failure(ErrorCode errorCode, T data) {
return new Result<>(errorCode.getCode(), errorCode.getMsg(), data);
}

/**
* Failed return with httpStatus, message and data.
* @param <T> data type
* @return Result
*/
public static <T> Result<T> failure(HttpStatus httpStatus, T data) {
return new Result<>(httpStatus.value(), httpStatus.getReasonPhrase(), data);
}

@Override
public String toString() {
return "Result{" + "errorCode=" + code + ", message='" + message + '\'' + ", data=" + data + '}';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 1999-2024 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.alibaba.nacos.api.model.v2;

/**
* Supported languages for announcements.
*
* @author zhangyukun on:2024/9/24
*/
public enum SupportedLanguage {
/**
* Chinese language.
*/
ZH_CN("zh-CN"),

/**
* English language.
*/
EN_US("en-US");

private final String language;

SupportedLanguage(String language) {
this.language = language;
}

public String getLanguage() {
return language;
}

/**
* Check if the given language is supported.
*
* @param language the language to check
* @return true if the language is supported, false otherwise
*/
public static boolean isSupported(String language) {
for (SupportedLanguage lang : SupportedLanguage.values()) {
if (lang.getLanguage().equals(language)) {
return true;
}
}
return false;
}
}
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
4 changes: 2 additions & 2 deletions console-ui/src/components/NameSpaceList/NameSpaceList.js
Original file line number Diff line number Diff line change
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,7 +107,7 @@ 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) {
Message.success(locale.leaveSucc);
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
Loading