From 0c84b4437d7ff39b96af372cc97e9274909aa46f Mon Sep 17 00:00:00 2001 From: weizhile <348358584@qq.com> Date: Mon, 8 Jan 2024 22:08:33 +0800 Subject: [PATCH 1/4] Complete the feature initially --- .../framework/apollo/biz/entity/Cluster.java | 13 +++++++++++- .../apollo/common/dto/ClusterDTO.java | 10 +++++++++ .../src/main/resources/static/cluster.html | 9 ++++++++ .../src/main/resources/static/i18n/en.json | 2 ++ .../src/main/resources/static/i18n/zh-CN.json | 2 ++ .../scripts/controller/ClusterController.js | 2 ++ .../config/ConfigBaseInfoController.js | 12 +++++++++++ scripts/sql/apolloconfigdb.sql | 1 + .../v220-v230/apolloconfigdb-v220-v230.sql | 21 +++++++++++++++++++ 9 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index af41b1951dd..33e2c419011 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -43,6 +43,9 @@ public class Cluster extends BaseEntity implements Comparable { @Column(name = "`ParentClusterId`", nullable = false) private long parentClusterId; + @Column(name = "`Comment`") + private String comment; + public String getAppId() { return appId; } @@ -67,9 +70,17 @@ public void setParentClusterId(long parentClusterId) { this.parentClusterId = parentClusterId; } + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + public String toString() { return toStringHelper().add("name", name).add("appId", appId) - .add("parentClusterId", parentClusterId).toString(); + .add("parentClusterId", parentClusterId).add("comments", comment).toString(); } @Override diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java index f78dd56ca01..ac2ae3fc662 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java @@ -36,6 +36,8 @@ public class ClusterDTO extends BaseDTO{ private long parentClusterId; + private String comment; + public long getId() { return id; } @@ -67,4 +69,12 @@ public long getParentClusterId() { public void setParentClusterId(long parentClusterId) { this.parentClusterId = parentClusterId; } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } } diff --git a/apollo-portal/src/main/resources/static/cluster.html b/apollo-portal/src/main/resources/static/cluster.html index 825e7aa8760..a45e733ab6f 100644 --- a/apollo-portal/src/main/resources/static/cluster.html +++ b/apollo-portal/src/main/resources/static/cluster.html @@ -80,6 +80,15 @@

{{'Cluster.CreateCluster' | translate }}

{{'Cluster.CreateNameTips' | translate }} +
+ +
+ + {{'Cluster.CreateCommentTips' | translate }} +
+
+ {{'Common.ClusterRemarks' | translate }}
- - {{'Cluster.CreateCommentTips' | translate }} + + {{'Cluster.CreateRemarksTips' | translate }}
diff --git a/apollo-portal/src/main/resources/static/i18n/en.json b/apollo-portal/src/main/resources/static/i18n/en.json index 4255c8c96aa..94b530b4495 100644 --- a/apollo-portal/src/main/resources/static/i18n/en.json +++ b/apollo-portal/src/main/resources/static/i18n/en.json @@ -27,8 +27,7 @@ "Common.AppOwnerLong": "App Owner", "Common.AppAdmin": "App Administrators", "Common.ClusterName": "Cluster Name", - "Common.ClusterComment": "Cluster Comment", - "Cluster.CreateCommentTips": "Adding comment to clusters can help users better understand the purpose of each cluster.", + "Common.ClusterRemarks": "Remarks", "Common.Submit": "Submit", "Common.Save": "Save", "Common.Created": "Create Successfully", @@ -354,6 +353,7 @@ "Cluster.Tips.3": "By default, Apollo reads IDC attributes in /opt/settings/server.properties(Linux) or C:\\opt\\settings\\server.properties(Windows) files on the machine as cluster names, such as SHAJQ (Jinqiao Data Center), SHAOY (Ouyang Data Center)", "Cluster.Tips.4": "The cluster name created here should be consistent with the IDC attribute in server.properties on the machine", "Cluster.CreateNameTips": "(Cluster names such as SHAJQ, SHAOY or customized clusters such as SHAJQ-xx, SHAJQ-yy)", + "Cluster.CreateRemarksTips": "Adding remarks to clusters can help users better understand the purpose of each cluster.", "Cluster.ChooseEnvironment": "Environment", "Cluster.LoadingEnvironmentError": "Error in loading environment information", "Cluster.ClusterCreated": "Create cluster successfully", diff --git a/apollo-portal/src/main/resources/static/i18n/zh-CN.json b/apollo-portal/src/main/resources/static/i18n/zh-CN.json index 1d24188fd39..4999bf1e3d9 100644 --- a/apollo-portal/src/main/resources/static/i18n/zh-CN.json +++ b/apollo-portal/src/main/resources/static/i18n/zh-CN.json @@ -27,8 +27,7 @@ "Common.AppOwnerLong": "应用负责人", "Common.AppAdmin": "应用管理员", "Common.ClusterName": "集群名称", - "Common.ClusterComment": "集群备注", - "Cluster.CreateCommentTips": "为新建集群增加备注说明可以帮助用户更好地理解每个集群的用途", + "Common.ClusterRemarks": "集群备注", "Common.Submit": "提交", "Common.Save": "保存", "Common.Created": "创建成功", @@ -354,6 +353,7 @@ "Cluster.Tips.3": "Apollo 默认会读取机器上 /opt/settings/server.properties(linux)或C:\\opt\\settings\\server.properties(windows)文件中的 idc 属性作为集群名字, 如 SHAJQ(金桥数据中心)、SHAOY(欧阳数据中心)", "Cluster.Tips.4": "在这里创建的集群名字需要和机器上 server.properties 中的 idc 属性一致", "Cluster.CreateNameTips": "(部署集群如: SHAJQ,SHAOY 或自定义集群如: SHAJQ-xx,SHAJQ-yy)", + "Cluster.CreateRemarksTips": "为新建集群增加备注说明可以帮助用户更好地理解每个集群的用途", "Cluster.ChooseEnvironment": "选择环境", "Cluster.LoadingEnvironmentError": "加载环境信息出错", "Cluster.ClusterCreated": "集群创建成功", diff --git a/apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js b/apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js index 716a0cc946a..59f7f30d84d 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js @@ -293,7 +293,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, $trans // get comment by nodeid var commentValue = $('#treeview').treeview('getNode', $(this).data('nodeid')).comment; if (typeof commentValue !== 'undefined') { - $(this).attr('title', 'comment: ' + commentValue); + $(this).attr('title', commentValue); } }, function () { diff --git a/scripts/sql/apolloconfigdb.sql b/scripts/sql/apolloconfigdb.sql index 3a7cc2775e3..301f1ebe838 100644 --- a/scripts/sql/apolloconfigdb.sql +++ b/scripts/sql/apolloconfigdb.sql @@ -113,7 +113,7 @@ CREATE TABLE `Cluster` ( `Name` varchar(32) NOT NULL DEFAULT '' COMMENT '集群名字', `AppId` varchar(64) NOT NULL DEFAULT '' COMMENT 'App id', `ParentClusterId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父cluster', - `Comment` varchar(64) DEFAULT NULL COMMENT '注释', + `Comment` varchar(64) DEFAULT NULL COMMENT '备注', `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal', `DeletedAt` BIGINT(20) NOT NULL DEFAULT '0' COMMENT 'Delete timestamp based on milliseconds', `DataChange_CreatedBy` varchar(64) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀', diff --git a/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql b/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql index 58e17187cc4..412b67f5fd2 100644 --- a/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql +++ b/scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql @@ -18,4 +18,4 @@ Use ApolloConfigDB; ALTER TABLE `Cluster` - ADD COLUMN `Comment` varchar(64) DEFAULT NULL COMMENT '注释'; \ No newline at end of file + ADD COLUMN `Comment` varchar(64) DEFAULT NULL COMMENT '备注'; \ No newline at end of file From 12ac4284329280e68adbf6e5344a039508215c18 Mon Sep 17 00:00:00 2001 From: weizhile <348358584@qq.com> Date: Tue, 9 Jan 2024 15:05:46 +0800 Subject: [PATCH 3/4] add brackets for RemarksTips --- apollo-portal/src/main/resources/static/i18n/en.json | 2 +- apollo-portal/src/main/resources/static/i18n/zh-CN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apollo-portal/src/main/resources/static/i18n/en.json b/apollo-portal/src/main/resources/static/i18n/en.json index 94b530b4495..dbe1d698520 100644 --- a/apollo-portal/src/main/resources/static/i18n/en.json +++ b/apollo-portal/src/main/resources/static/i18n/en.json @@ -353,7 +353,7 @@ "Cluster.Tips.3": "By default, Apollo reads IDC attributes in /opt/settings/server.properties(Linux) or C:\\opt\\settings\\server.properties(Windows) files on the machine as cluster names, such as SHAJQ (Jinqiao Data Center), SHAOY (Ouyang Data Center)", "Cluster.Tips.4": "The cluster name created here should be consistent with the IDC attribute in server.properties on the machine", "Cluster.CreateNameTips": "(Cluster names such as SHAJQ, SHAOY or customized clusters such as SHAJQ-xx, SHAJQ-yy)", - "Cluster.CreateRemarksTips": "Adding remarks to clusters can help users better understand the purpose of each cluster.", + "Cluster.CreateRemarksTips": "(Adding remarks to clusters can help users better understand the purpose of each cluster.)", "Cluster.ChooseEnvironment": "Environment", "Cluster.LoadingEnvironmentError": "Error in loading environment information", "Cluster.ClusterCreated": "Create cluster successfully", diff --git a/apollo-portal/src/main/resources/static/i18n/zh-CN.json b/apollo-portal/src/main/resources/static/i18n/zh-CN.json index 4999bf1e3d9..e166237c306 100644 --- a/apollo-portal/src/main/resources/static/i18n/zh-CN.json +++ b/apollo-portal/src/main/resources/static/i18n/zh-CN.json @@ -353,7 +353,7 @@ "Cluster.Tips.3": "Apollo 默认会读取机器上 /opt/settings/server.properties(linux)或C:\\opt\\settings\\server.properties(windows)文件中的 idc 属性作为集群名字, 如 SHAJQ(金桥数据中心)、SHAOY(欧阳数据中心)", "Cluster.Tips.4": "在这里创建的集群名字需要和机器上 server.properties 中的 idc 属性一致", "Cluster.CreateNameTips": "(部署集群如: SHAJQ,SHAOY 或自定义集群如: SHAJQ-xx,SHAJQ-yy)", - "Cluster.CreateRemarksTips": "为新建集群增加备注说明可以帮助用户更好地理解每个集群的用途", + "Cluster.CreateRemarksTips": "(为新建集群增加备注说明可以帮助用户更好地理解每个集群的用途)", "Cluster.ChooseEnvironment": "选择环境", "Cluster.LoadingEnvironmentError": "加载环境信息出错", "Cluster.ClusterCreated": "集群创建成功", From 8db44fa4ab3630ff8f16530707bdbef38e3fa083 Mon Sep 17 00:00:00 2001 From: weizhile <348358584@qq.com> Date: Sat, 13 Jan 2024 19:26:01 +0800 Subject: [PATCH 4/4] update CHANGES.md --- CHANGES.md | 1 + .../java/com/ctrip/framework/apollo/biz/entity/Cluster.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ec4d138378b..6a4930af5d0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Apollo 2.3.0 ------------------ * [Fix circular references on LdapAutoConfiguration](https://github.com/apolloconfig/apollo/pull/5055) +* [Add comment for clusters and UI display](https://github.com/apolloconfig/apollo/pull/5072) ------------------ diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java index 33e2c419011..e69b8019e66 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java @@ -80,7 +80,7 @@ public void setComment(String comment) { public String toString() { return toStringHelper().add("name", name).add("appId", appId) - .add("parentClusterId", parentClusterId).add("comments", comment).toString(); + .add("parentClusterId", parentClusterId).add("comment", comment).toString(); } @Override