package node import ( "github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/iwind/TeaGo/maps" ) type InstallAction struct { actionutils.ParentAction } func (this *InstallAction) Init() { this.Nav("", "node", "install") this.SecondMenu("nodes") } func (this *InstallAction) RunGet(params struct { NodeId int64 }) { this.Data["nodeId"] = params.NodeId // 节点 nodeResp, err := this.RPC().NodeRPC().FindEnabledNode(this.AdminContext(), &pb.FindEnabledNodeRequest{NodeId: params.NodeId}) if err != nil { this.ErrorPage(err) return } node := nodeResp.Node if node == nil { this.WriteString("找不到要操作的节点") return } // 集群 var clusterMap maps.Map = nil if node.Cluster != nil { clusterId := node.Cluster.Id clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: clusterId}) if err != nil { this.ErrorPage(err) return } cluster := clusterResp.Cluster if cluster != nil { clusterMap = maps.Map{ "id": cluster.Id, "name": cluster.Name, "installDir": cluster.InstallDir, } } } this.Data["node"] = maps.Map{ "id": node.Id, "name": node.Name, "installDir": node.InstallDir, "isInstalled": node.IsInstalled, "uniqueId": node.UniqueId, "secret": node.Secret, "cluster": clusterMap, } this.Show() }