// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . package trafficstats import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" ) type ServerOptionsAction struct { actionutils.ParentAction } func (this *ServerOptionsAction) RunPost(params struct{}) { serversResp, err := this.RPC().ServerRPC().FindAllUserServers(this.UserContext(), &pb.FindAllUserServersRequest{UserId: this.UserId()}) if err != nil { this.ErrorPage(err) return } var serverMaps = []maps.Map{ {"id": 0, "name": "全部网站(" + types.String(len(serversResp.Servers)) + ")"}, } for _, server := range serversResp.Servers { if len(server.FirstServerName) > 0 { server.Name = server.FirstServerName } serverMaps = append(serverMaps, maps.Map{ "id": server.Id, "name": server.Name, }) } this.Data["servers"] = serverMaps this.Success() }