package nodes import ( "github.com/TeaOSLab/EdgeAdmin/internal/rpc/pb" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/iwind/TeaGo/maps" ) type IndexAction struct { actionutils.ParentAction } func (this *IndexAction) Init() { this.Nav("", "node", "index") } func (this *IndexAction) RunGet(params struct{}) { countResp, err := this.RPC().NodeRPC().CountAllEnabledNodes(this.AdminContext(), &pb.CountAllEnabledNodesRequest{}) if err != nil { this.ErrorPage(err) return } page := this.NewPage(countResp.Count) this.Data["page"] = page.AsHTML() nodesResp, err := this.RPC().NodeRPC().ListEnabledNodes(this.AdminContext(), &pb.ListEnabledNodesRequest{ Offset: page.Offset, Size: page.Size, }) nodeMaps := []maps.Map{} for _, node := range nodesResp.Nodes { nodeMaps = append(nodeMaps, maps.Map{ "id": node.Id, "name": node.Name, "cluster": maps.Map{ "id": node.Cluster.Id, "name": node.Cluster.Name, }, }) } this.Data["nodes"] = nodeMaps this.Show() }