Files
waf-platform/EdgeUser/internal/web/actions/default/servers/traffic-stats/serverOptions.go
2026-02-04 20:27:13 +08:00

39 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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()
}