Skip to content

Commit

Permalink
Add comment for clusters and UI display (#5072)
Browse files Browse the repository at this point in the history
* Complete the feature initially

* reformat ui terms from 'comment' to 'remarks'

* add brackets for RemarksTips

* update CHANGES.md
  • Loading branch information
BlackBear2003 authored Jan 13, 2024
1 parent 6657a58 commit 63a68f5
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Cluster extends BaseEntity implements Comparable<Cluster> {
@Column(name = "`ParentClusterId`", nullable = false)
private long parentClusterId;

@Column(name = "`Comment`")
private String comment;

public String getAppId() {
return appId;
}
Expand All @@ -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("comment", comment).toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ClusterDTO extends BaseDTO{

private long parentClusterId;

private String comment;

public long getId() {
return id;
}
Expand Down Expand Up @@ -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;
}
}
9 changes: 9 additions & 0 deletions apollo-portal/src/main/resources/static/cluster.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ <h4>{{'Cluster.CreateCluster' | translate }}</h4>
<small>{{'Cluster.CreateNameTips' | translate }}</small>
</div>
</div>
<div class="form-group" valdr-form-group>
<label class="col-sm-2 control-label">
{{'Common.ClusterRemarks' | translate }}</label>
<div class="col-sm-6">
<textarea class="form-control" rows="3" name="clusterComment"
ng-model="clusterComment"></textarea>
<small>{{'Cluster.CreateRemarksTips' | translate }}</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfield></apollorequiredfield>
Expand Down
2 changes: 2 additions & 0 deletions apollo-portal/src/main/resources/static/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Common.AppOwnerLong": "App Owner",
"Common.AppAdmin": "App Administrators",
"Common.ClusterName": "Cluster Name",
"Common.ClusterRemarks": "Remarks",
"Common.Submit": "Submit",
"Common.Save": "Save",
"Common.Created": "Create Successfully",
Expand Down Expand Up @@ -352,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",
Expand Down
2 changes: 2 additions & 0 deletions apollo-portal/src/main/resources/static/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Common.AppOwnerLong": "应用负责人",
"Common.AppAdmin": "应用管理员",
"Common.ClusterName": "集群名称",
"Common.ClusterRemarks": "集群备注",
"Common.Submit": "提交",
"Common.Save": "保存",
"Common.Created": "创建成功",
Expand Down Expand Up @@ -352,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": "集群创建成功",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cluster_module.controller('ClusterController',
});

$scope.clusterName = '';
$scope.clusterComment = '';

$scope.switchChecked = function (env, $event) {
env.checked = !env.checked;
Expand All @@ -59,6 +60,7 @@ cluster_module.controller('ClusterController',
ClusterService.create_cluster($scope.appId, env.name,
{
name: $scope.clusterName,
comment: $scope.clusterComment,
appId: $scope.appId
}).then(function (result) {
toastr.success(env.name, $translate.instant('Cluster.ClusterCreated'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, $trans
parentNode.push(node.text);
clusterNode.tags = [$translate.instant('Common.Cluster')];
clusterNode.parentNode = parentNode;
clusterNode.comment = cluster.comment;
clusterNodes.push(clusterNode);

});
Expand Down Expand Up @@ -287,6 +288,17 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, $trans
$rootScope.showSideBar = false;
}
});
$('#treeview .node-treeview').hover(
function () {
// get comment by nodeid
var commentValue = $('#treeview').treeview('getNode', $(this).data('nodeid')).comment;
if (typeof commentValue !== 'undefined') {
$(this).attr('title', commentValue);
}
},
function () {
}
);

var envMapClusters = {};
navTree.forEach(function (node) {
Expand Down
1 change: 1 addition & 0 deletions scripts/sql/apolloconfigdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +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 '备注',
`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 '创建人邮箱前缀',
Expand Down
21 changes: 21 additions & 0 deletions scripts/sql/delta/v220-v230/apolloconfigdb-v220-v230.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--
-- Copyright 2024 Apollo Authors
--
-- 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.
--
# delta schema to upgrade apollo config db from v2.2.0 to v2.3.0

Use ApolloConfigDB;

ALTER TABLE `Cluster`
ADD COLUMN `Comment` varchar(64) DEFAULT NULL COMMENT '备注';

0 comments on commit 63a68f5

Please sign in to comment.