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

Add comment for clusters and UI display #5072

Merged
merged 4 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
@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 @@
this.parentClusterId = parentClusterId;
}

public String getComment() {
return comment;

Check warning on line 74 in apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java

View check run for this annotation

Codecov / codecov/patch

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java#L74

Added line #L74 was not covered by tests
}

public void setComment(String comment) {
this.comment = comment;
}

Check warning on line 79 in apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java

View check run for this annotation

Codecov / codecov/patch

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java#L78-L79

Added lines #L78 - L79 were not covered by tests

public String toString() {
return toStringHelper().add("name", name).add("appId", appId)
.add("parentClusterId", parentClusterId).toString();
.add("parentClusterId", parentClusterId).add("comments", comment).toString();

Check warning on line 83 in apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java

View check run for this annotation

Codecov / codecov/patch

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java#L83

Added line #L83 was not covered by tests
nobodyiam marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

private long parentClusterId;

private String comment;

public long getId() {
return id;
}
Expand Down Expand Up @@ -67,4 +69,12 @@
public void setParentClusterId(long parentClusterId) {
this.parentClusterId = parentClusterId;
}

public String getComment() {
return comment;

Check warning on line 74 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java

View check run for this annotation

Codecov / codecov/patch

apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java#L74

Added line #L74 was not covered by tests
}

public void setComment(String comment) {
this.comment = comment;
}

Check warning on line 79 in apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java

View check run for this annotation

Codecov / codecov/patch

apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java#L78-L79

Added lines #L78 - L79 were not covered by tests
}
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 '备注';
Loading