From 93e45af3db3328de629b1b553f12ca0c035d5bf0 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Mon, 2 Nov 2020 09:37:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/actions/default/clusters/cluster/index.go | 8 ++++++-- internal/web/actions/default/servers/index.go | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/web/actions/default/clusters/cluster/index.go b/internal/web/actions/default/clusters/cluster/index.go index 43265536..a272ff2d 100644 --- a/internal/web/actions/default/clusters/cluster/index.go +++ b/internal/web/actions/default/clusters/cluster/index.go @@ -9,6 +9,7 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" + "strconv" "time" ) @@ -143,10 +144,13 @@ func (this *IndexAction) RunGet(params struct { return } countNodes := countResp.Count - + groupName := group.Name + if countNodes > 0 { + groupName += "(" + strconv.FormatInt(countNodes, 10) + ")" + } groupMaps = append(groupMaps, maps.Map{ "id": group.Id, - "name": group.Name, + "name": groupName, "countNodes": countNodes, }) } diff --git a/internal/web/actions/default/servers/index.go b/internal/web/actions/default/servers/index.go index 1fb58bc3..f0b2fda9 100644 --- a/internal/web/actions/default/servers/index.go +++ b/internal/web/actions/default/servers/index.go @@ -6,6 +6,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/maps" + "strconv" ) type IndexAction struct { @@ -151,9 +152,19 @@ func (this *IndexAction) RunGet(params struct { } groupMaps := []maps.Map{} for _, group := range groupsResp.Groups { + countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithGroupIdRequest{GroupId: group.Id}) + if err != nil { + this.ErrorPage(err) + return + } + + groupName := group.Name + if countResp.Count > 0 { + groupName += "(" + strconv.FormatInt(countResp.Count, 10) + ")" + } groupMaps = append(groupMaps, maps.Map{ "id": group.Id, - "name": group.Name, + "name": groupName, }) } this.Data["groups"] = groupMaps