1.5.0
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build plus
|
||||
|
||||
package boards
|
||||
|
||||
import (
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard/boards/boardutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type HTTPDNSAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAction) Init() {
|
||||
this.Nav("", "", "httpdns")
|
||||
this.ViewDir("@default")
|
||||
this.View("dashboard/boards/httpdns")
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAction) RunGet(params struct{}) {
|
||||
if !teaconst.IsPlus {
|
||||
this.RedirectURL("/dashboard")
|
||||
return
|
||||
}
|
||||
|
||||
err := boardutils.InitBoard(this.Parent())
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["board"] = maps.Map{
|
||||
"countApps": 0,
|
||||
"countDomains": 0,
|
||||
"countClusters": 0,
|
||||
"countNodes": 0,
|
||||
"countOfflineNodes": 0,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAction) 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,
|
||||
}
|
||||
|
||||
{
|
||||
var 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
|
||||
}
|
||||
|
||||
{
|
||||
var 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
|
||||
}
|
||||
|
||||
{
|
||||
var 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
|
||||
}
|
||||
|
||||
{
|
||||
var 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
|
||||
}
|
||||
|
||||
{
|
||||
var 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()
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
"regexp"
|
||||
"time"
|
||||
@@ -409,5 +410,55 @@ func (this *IndexAction) RunPost(params struct {
|
||||
}
|
||||
this.Data["countWeakAdmins"] = countWeakAdminsResp.Count
|
||||
|
||||
upgradeConfig, err := configloaders.LoadUpgradeConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["autoUpgrade"] = upgradeConfig.AutoUpgrade
|
||||
|
||||
httpdnsNodeUpgradeInfo, err := this.composeHTTPDNSNodeUpgradeInfo()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["httpdnsNodeUpgradeInfo"] = httpdnsNodeUpgradeInfo
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
func (this *IndexAction) composeHTTPDNSNodeUpgradeInfo() (maps.Map, error) {
|
||||
clustersResp, err := this.RPC().HTTPDNSClusterRPC().ListHTTPDNSClusters(this.AdminContext(), &pb.ListHTTPDNSClustersRequest{
|
||||
Offset: 0,
|
||||
Size: 10000,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count := 0
|
||||
version := ""
|
||||
for _, cluster := range clustersResp.Clusters {
|
||||
resp, err := this.RPC().HTTPDNSNodeRPC().FindAllUpgradeHTTPDNSNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeHTTPDNSNodesWithClusterIdRequest{
|
||||
ClusterId: cluster.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count += len(resp.Nodes)
|
||||
for _, nodeUpgrade := range resp.Nodes {
|
||||
if len(nodeUpgrade.NewVersion) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(version) == 0 || stringutil.VersionCompare(version, nodeUpgrade.NewVersion) < 0 {
|
||||
version = nodeUpgrade.NewVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maps.Map{
|
||||
"count": count,
|
||||
"version": version,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -245,5 +245,12 @@ func (this *IndexAction) RunPost(params struct{}) {
|
||||
}
|
||||
this.Data["countWeakAdmins"] = countWeakAdminsResp.Count
|
||||
|
||||
upgradeConfig, err := configloaders.LoadUpgradeConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["autoUpgrade"] = upgradeConfig.AutoUpgrade
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ func init() {
|
||||
Get("/waf", new(boards.WafAction)).
|
||||
Post("/wafLogs", new(boards.WafLogsAction)).
|
||||
GetPost("/dns", new(boards.DnsAction)).
|
||||
GetPost("/httpdns", new(boards.HTTPDNSAction)).
|
||||
Get("/user", new(boards.UserAction)).
|
||||
Get("/events", new(boards.EventsAction)).
|
||||
Post("/readLogs", new(boards.ReadLogsAction)).
|
||||
|
||||
Reference in New Issue
Block a user