前端页面
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
package resolveLogs
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/httpdnsutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("httpdns", "resolveLogs", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
NodeId int64
|
||||
AppId string
|
||||
Domain string
|
||||
Status string
|
||||
Keyword string
|
||||
}) {
|
||||
httpdnsutils.AddLeftMenu(this.Parent())
|
||||
|
||||
this.Data["clusterId"] = params.ClusterId
|
||||
this.Data["nodeId"] = params.NodeId
|
||||
this.Data["appId"] = params.AppId
|
||||
this.Data["domain"] = params.Domain
|
||||
this.Data["status"] = params.Status
|
||||
this.Data["keyword"] = params.Keyword
|
||||
|
||||
clusters := []map[string]interface{}{
|
||||
{"id": int64(1), "name": "gateway-cn-hz"},
|
||||
{"id": int64(2), "name": "gateway-cn-bj"},
|
||||
}
|
||||
nodes := []map[string]interface{}{
|
||||
{"id": int64(101), "clusterId": int64(1), "name": "hz-node-01"},
|
||||
{"id": int64(102), "clusterId": int64(1), "name": "hz-node-02"},
|
||||
{"id": int64(201), "clusterId": int64(2), "name": "bj-node-01"},
|
||||
}
|
||||
this.Data["clusters"] = clusters
|
||||
this.Data["nodes"] = nodes
|
||||
|
||||
allLogs := []map[string]interface{}{
|
||||
{
|
||||
"time": "2026-02-23 10:21:51",
|
||||
"clusterId": int64(1),
|
||||
"clusterName": "gateway-cn-hz",
|
||||
"nodeId": int64(101),
|
||||
"nodeName": "hz-node-01",
|
||||
"appName": "\u4e3b\u7ad9\u79fb\u52a8\u4e1a\u52a1",
|
||||
"appId": "ab12xc34s2",
|
||||
"domain": "api.business.com",
|
||||
"query": "A",
|
||||
"clientIp": "203.0.113.25",
|
||||
"os": "Android",
|
||||
"sdkVersion": "2.4.1",
|
||||
"ips": "198.51.100.10,198.51.100.11",
|
||||
"status": "success",
|
||||
"errorCode": "none",
|
||||
"costMs": 37,
|
||||
"pinningMode": "report",
|
||||
"pinningResult": "warn",
|
||||
"sanMode": "strict",
|
||||
"sanResult": "pass",
|
||||
},
|
||||
{
|
||||
"time": "2026-02-23 10:18:02",
|
||||
"clusterId": int64(2),
|
||||
"clusterName": "gateway-cn-bj",
|
||||
"nodeId": int64(201),
|
||||
"nodeName": "bj-node-01",
|
||||
"appName": "\u652f\u4ed8\u7f51\u5173\u4e1a\u52a1",
|
||||
"appId": "vd8992ksm1",
|
||||
"domain": "payment.business.com",
|
||||
"query": "A",
|
||||
"clientIp": "198.51.100.67",
|
||||
"os": "iOS",
|
||||
"sdkVersion": "2.3.9",
|
||||
"ips": "198.51.100.22",
|
||||
"status": "failed",
|
||||
"errorCode": "40301",
|
||||
"costMs": 52,
|
||||
"pinningMode": "enforce",
|
||||
"pinningResult": "fail",
|
||||
"sanMode": "strict",
|
||||
"sanResult": "fail",
|
||||
},
|
||||
{
|
||||
"time": "2026-02-23 10:12:44",
|
||||
"clusterId": int64(1),
|
||||
"clusterName": "gateway-cn-hz",
|
||||
"nodeId": int64(102),
|
||||
"nodeName": "hz-node-02",
|
||||
"appName": "\u4e3b\u7ad9\u79fb\u52a8\u4e1a\u52a1",
|
||||
"appId": "ab12xc34s2",
|
||||
"domain": "www.aliyun.com",
|
||||
"query": "A",
|
||||
"clientIp": "106.11.63.180",
|
||||
"os": "Unknown",
|
||||
"sdkVersion": "none",
|
||||
"ips": "3.33.120.190,15.197.120.33",
|
||||
"status": "success",
|
||||
"errorCode": "none",
|
||||
"costMs": 41,
|
||||
"pinningMode": "off",
|
||||
"pinningResult": "na",
|
||||
"sanMode": "report",
|
||||
"sanResult": "warn",
|
||||
},
|
||||
}
|
||||
|
||||
status := strings.TrimSpace(strings.ToLower(params.Status))
|
||||
appID := strings.TrimSpace(strings.ToLower(params.AppId))
|
||||
domain := strings.TrimSpace(strings.ToLower(params.Domain))
|
||||
keyword := strings.TrimSpace(strings.ToLower(params.Keyword))
|
||||
|
||||
filtered := make([]map[string]interface{}, 0)
|
||||
for _, log := range allLogs {
|
||||
if params.ClusterId > 0 && log["clusterId"].(int64) != params.ClusterId {
|
||||
continue
|
||||
}
|
||||
if params.NodeId > 0 && log["nodeId"].(int64) != params.NodeId {
|
||||
continue
|
||||
}
|
||||
if len(status) > 0 && log["status"].(string) != status {
|
||||
continue
|
||||
}
|
||||
if len(appID) > 0 && !strings.Contains(strings.ToLower(log["appId"].(string)), appID) {
|
||||
continue
|
||||
}
|
||||
if len(domain) > 0 && !strings.Contains(strings.ToLower(log["domain"].(string)), domain) {
|
||||
continue
|
||||
}
|
||||
if len(keyword) > 0 {
|
||||
if !strings.Contains(strings.ToLower(log["appName"].(string)), keyword) &&
|
||||
!strings.Contains(strings.ToLower(log["domain"].(string)), keyword) &&
|
||||
!strings.Contains(strings.ToLower(log["clientIp"].(string)), keyword) &&
|
||||
!strings.Contains(strings.ToLower(log["ips"].(string)), keyword) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
filtered = append(filtered, log)
|
||||
}
|
||||
|
||||
this.Data["resolveLogs"] = filtered
|
||||
this.Show()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package resolveLogs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeHttpDNS)).
|
||||
Data("teaMenu", "httpdns").
|
||||
Data("teaSubMenu", "resolveLogs").
|
||||
Prefix("/httpdns/resolveLogs").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user