111 lines
2.6 KiB
Go
111 lines
2.6 KiB
Go
package httpdns
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type IndexAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *IndexAction) Init() {
|
|
this.Nav("", "", "httpdns")
|
|
}
|
|
|
|
func (this *IndexAction) RunGet(params struct{}) {
|
|
this.Data["board"] = maps.Map{
|
|
"countApps": 0,
|
|
"countDomains": 0,
|
|
"countClusters": 0,
|
|
"countNodes": 0,
|
|
"countOfflineNodes": 0,
|
|
}
|
|
|
|
this.Show()
|
|
}
|
|
|
|
func (this *IndexAction) RunPost(params struct{}) {
|
|
resp, err := this.RPC().HTTPDNSBoardRPC().ComposeHTTPDNSBoard(this.AdminContext(), &pb.ComposeHTTPDNSBoardRequest{})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
|
|
this.Data["board"] = maps.Map{
|
|
"countApps": resp.CountApps,
|
|
"countDomains": resp.CountDomains,
|
|
"countClusters": resp.CountClusters,
|
|
"countNodes": resp.CountNodes,
|
|
"countOfflineNodes": resp.CountOfflineNodes,
|
|
}
|
|
|
|
{
|
|
statMaps := []maps.Map{}
|
|
for _, stat := range resp.HourlyTrafficStats {
|
|
statMaps = append(statMaps, maps.Map{
|
|
"day": stat.Hour[4:6] + "月" + stat.Hour[6:8] + "日",
|
|
"hour": stat.Hour[8:],
|
|
"countRequests": stat.CountRequests,
|
|
"bytes": stat.Bytes,
|
|
})
|
|
}
|
|
this.Data["hourlyStats"] = statMaps
|
|
}
|
|
|
|
{
|
|
statMaps := []maps.Map{}
|
|
for _, stat := range resp.DailyTrafficStats {
|
|
statMaps = append(statMaps, maps.Map{
|
|
"day": stat.Day[4:6] + "月" + stat.Day[6:] + "日",
|
|
"countRequests": stat.CountRequests,
|
|
"bytes": stat.Bytes,
|
|
})
|
|
}
|
|
this.Data["dailyStats"] = statMaps
|
|
}
|
|
|
|
{
|
|
statMaps := []maps.Map{}
|
|
for _, stat := range resp.TopAppStats {
|
|
statMaps = append(statMaps, maps.Map{
|
|
"appId": stat.AppId,
|
|
"appName": stat.AppName,
|
|
"countRequests": stat.CountRequests,
|
|
"bytes": stat.Bytes,
|
|
})
|
|
}
|
|
this.Data["topAppStats"] = statMaps
|
|
}
|
|
|
|
{
|
|
statMaps := []maps.Map{}
|
|
for _, stat := range resp.TopDomainStats {
|
|
statMaps = append(statMaps, maps.Map{
|
|
"domainId": stat.DomainId,
|
|
"domainName": stat.DomainName,
|
|
"countRequests": stat.CountRequests,
|
|
"bytes": stat.Bytes,
|
|
})
|
|
}
|
|
this.Data["topDomainStats"] = statMaps
|
|
}
|
|
|
|
{
|
|
statMaps := []maps.Map{}
|
|
for _, stat := range resp.TopNodeStats {
|
|
statMaps = append(statMaps, maps.Map{
|
|
"clusterId": stat.ClusterId,
|
|
"nodeId": stat.NodeId,
|
|
"nodeName": stat.NodeName,
|
|
"countRequests": stat.CountRequests,
|
|
"bytes": stat.Bytes,
|
|
})
|
|
}
|
|
this.Data["topNodeStats"] = statMaps
|
|
}
|
|
|
|
this.Success()
|
|
}
|