mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 05:00:25 +08:00
可以批量远程安装和升级节点
This commit is contained in:
@@ -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",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user