Initial commit (code only without large binaries)
This commit is contained in:
67
EdgeUser/internal/web/actions/default/dashboard/ns.go
Normal file
67
EdgeUser/internal/web/actions/default/dashboard/ns.go
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type NsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *NsAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *NsAction) RunGet(params struct{}) {
|
||||
// 是否开启了CDN
|
||||
registerConfig, err := configloaders.LoadRegisterConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if registerConfig != nil && !registerConfig.NSIsOn {
|
||||
// 显示空白
|
||||
this.View("@blank")
|
||||
this.Show()
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := this.RPC().NSRPC().ComposeNSUserBoard(this.UserContext(), &pb.ComposeNSUserBoardRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var planName = ""
|
||||
if resp.NsUserPlan != nil && resp.NsUserPlan.NsPlan != nil {
|
||||
planName = resp.NsUserPlan.NsPlan.Name
|
||||
}
|
||||
|
||||
this.Data["board"] = maps.Map{
|
||||
"countDomains": resp.CountNSDomains,
|
||||
"countRecords": resp.CountNSRecords,
|
||||
"countRoutes": resp.CountNSRoutes,
|
||||
"planName": planName,
|
||||
}
|
||||
|
||||
// 域名排行
|
||||
{
|
||||
var statMaps = []maps.Map{}
|
||||
for _, stat := range resp.TopNSDomainStats {
|
||||
statMaps = append(statMaps, maps.Map{
|
||||
"domainId": stat.NsDomainId,
|
||||
"domainName": stat.NsDomainName,
|
||||
"countRequests": stat.CountRequests,
|
||||
"bytes": stat.Bytes,
|
||||
})
|
||||
}
|
||||
this.Data["topDomainStats"] = statMaps
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user