1.4.5.2
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package trafficstats
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type ServerOptionsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *ServerOptionsAction) RunPost(params struct {
|
||||
UserId int64
|
||||
}) {
|
||||
if params.UserId == 0 {
|
||||
this.Data["servers"] = []maps.Map{}
|
||||
return
|
||||
}
|
||||
|
||||
serversResp, err := this.RPC().ServerRPC().FindAllUserServers(this.AdminContext(), &pb.FindAllUserServersRequest{UserId: params.UserId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var serverMaps = []maps.Map{
|
||||
{"id": 0, "name": this.Lang(codes.ServerTrafficStat_AllServers, 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()
|
||||
}
|
||||
Reference in New Issue
Block a user