可以批量远程安装和升级节点

This commit is contained in:
GoEdgeLab
2021-01-31 16:03:52 +08:00
parent 081f3b1ffc
commit 74f2e86f51
24 changed files with 495 additions and 217 deletions

View File

@@ -1,12 +1,34 @@
package cluster
import (
"context"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"strconv"
)
// 安装升级相关的左侧菜单
func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
func LeftMenuItemsForInstall(ctx context.Context, clusterId int64, selectedItem string) []maps.Map {
rpcClient, _ := rpc.SharedRPC()
countNotInstalled := int64(0)
countUpgrade := int64(0)
if rpcClient != nil {
{
resp, err := rpcClient.NodeRPC().CountAllNotInstalledNodesWithClusterId(ctx, &pb.CountAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: clusterId})
if err == nil {
countNotInstalled = resp.Count
}
}
{
resp, err := rpcClient.NodeRPC().CountAllUpgradeNodesWithClusterId(ctx, &pb.CountAllUpgradeNodesWithClusterIdRequest{NodeClusterId: clusterId})
if err == nil {
countUpgrade = resp.Count
}
}
}
return []maps.Map{
{
"name": "手动安装",
@@ -19,12 +41,12 @@ func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
"isActive": selectedItem == "register",
},
{
"name": "远程安装",
"name": "远程安装(" + strconv.FormatInt(countNotInstalled, 10) + ")",
"url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "install",
},
{
"name": "远程升级",
"name": "远程升级(" + strconv.FormatInt(countUpgrade, 10) + ")",
"url": "/clusters/cluster/upgradeRemote?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "upgrade",
},