mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
域名服务增加访问日志
This commit is contained in:
@@ -372,6 +372,10 @@ func (this *RPCClient) NSRouteRPC() pb.NSRouteServiceClient {
|
|||||||
return pb.NewNSRouteServiceClient(this.pickConn())
|
return pb.NewNSRouteServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *RPCClient) NSAccessLogRPC() pb.NSAccessLogServiceClient {
|
||||||
|
return pb.NewNSAccessLogServiceClient(this.pickConn())
|
||||||
|
}
|
||||||
|
|
||||||
// Context 构造Admin上下文
|
// Context 构造Admin上下文
|
||||||
func (this *RPCClient) Context(adminId int64) context.Context {
|
func (this *RPCClient) Context(adminId int64) context.Context {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
@@ -93,25 +93,71 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 版本升级
|
// 版本升级
|
||||||
this.Data["nodeUpgradeInfo"] = maps.Map{
|
if resp.NodeUpgradeInfo != nil {
|
||||||
"count": resp.NodeUpgradeInfo.CountNodes,
|
this.Data["nodeUpgradeInfo"] = maps.Map{
|
||||||
"version": resp.NodeUpgradeInfo.NewVersion,
|
"count": resp.NodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.NodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["nodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.Data["monitorNodeUpgradeInfo"] = maps.Map{
|
if resp.MonitorNodeUpgradeInfo != nil {
|
||||||
"count": resp.MonitorNodeUpgradeInfo.CountNodes,
|
this.Data["monitorNodeUpgradeInfo"] = maps.Map{
|
||||||
"version": resp.MonitorNodeUpgradeInfo.NewVersion,
|
"count": resp.MonitorNodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.MonitorNodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["monitorNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.Data["apiNodeUpgradeInfo"] = maps.Map{
|
if resp.ApiNodeUpgradeInfo != nil {
|
||||||
"count": resp.ApiNodeUpgradeInfo.CountNodes,
|
this.Data["apiNodeUpgradeInfo"] = maps.Map{
|
||||||
"version": resp.ApiNodeUpgradeInfo.NewVersion,
|
"count": resp.ApiNodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.ApiNodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["apiNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.Data["userNodeUpgradeInfo"] = maps.Map{
|
if resp.UserNodeUpgradeInfo != nil {
|
||||||
"count": resp.UserNodeUpgradeInfo.CountNodes,
|
this.Data["userNodeUpgradeInfo"] = maps.Map{
|
||||||
"version": resp.UserNodeUpgradeInfo.NewVersion,
|
"count": resp.UserNodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.UserNodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["userNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.Data["authorityNodeUpgradeInfo"] = maps.Map{
|
if resp.AuthorityNodeUpgradeInfo != nil {
|
||||||
"count": resp.AuthorityNodeUpgradeInfo.CountNodes,
|
this.Data["authorityNodeUpgradeInfo"] = maps.Map{
|
||||||
"version": resp.AuthorityNodeUpgradeInfo.NewVersion,
|
"count": resp.AuthorityNodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.AuthorityNodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["authorityNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if resp.NsNodeUpgradeInfo != nil {
|
||||||
|
this.Data["nsNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": resp.NsNodeUpgradeInfo.CountNodes,
|
||||||
|
"version": resp.NsNodeUpgradeInfo.NewVersion,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Data["nsNodeUpgradeInfo"] = maps.Map{
|
||||||
|
"count": 0,
|
||||||
|
"version": "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
|
|||||||
166
internal/web/actions/default/ns/clusters/accessLogs/index.go
Normal file
166
internal/web/actions/default/ns/clusters/accessLogs/index.go
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package logs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/lists"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
|
"net"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IndexAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IndexAction) Init() {
|
||||||
|
this.Nav("", "", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IndexAction) RunGet(params struct {
|
||||||
|
RequestId string
|
||||||
|
Day string
|
||||||
|
}) {
|
||||||
|
day := strings.ReplaceAll(params.Day, "-", "")
|
||||||
|
if !regexp.MustCompile(`^\d{8}$`).MatchString(day) {
|
||||||
|
day = timeutil.Format("Ymd")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Data["day"] = day[:4] + "-" + day[4:6] + "-" + day[6:]
|
||||||
|
this.Data["path"] = this.Request.URL.Path
|
||||||
|
|
||||||
|
var size = int64(10)
|
||||||
|
|
||||||
|
resp, err := this.RPC().NSAccessLogRPC().ListNSAccessLogs(this.AdminContext(), &pb.ListNSAccessLogsRequest{
|
||||||
|
RequestId: params.RequestId,
|
||||||
|
NsNodeId: 0,
|
||||||
|
NsDomainId: 0,
|
||||||
|
NsRecordId: 0,
|
||||||
|
Size: size,
|
||||||
|
Day: day,
|
||||||
|
Reverse: false,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ipList := []string{}
|
||||||
|
nodeIds := []int64{}
|
||||||
|
domainIds := []int64{}
|
||||||
|
if len(resp.NsAccessLogs) == 0 {
|
||||||
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
|
} else {
|
||||||
|
this.Data["accessLogs"] = resp.NsAccessLogs
|
||||||
|
for _, accessLog := range resp.NsAccessLogs {
|
||||||
|
// IP
|
||||||
|
if len(accessLog.RemoteAddr) > 0 {
|
||||||
|
// 去掉端口
|
||||||
|
ip, _, err := net.SplitHostPort(accessLog.RemoteAddr)
|
||||||
|
if err == nil {
|
||||||
|
accessLog.RemoteAddr = ip
|
||||||
|
if !lists.ContainsString(ipList, ip) {
|
||||||
|
ipList = append(ipList, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 节点
|
||||||
|
if !lists.ContainsInt64(nodeIds, accessLog.NsNodeId) {
|
||||||
|
nodeIds = append(nodeIds, accessLog.NsNodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 域名
|
||||||
|
if !lists.ContainsInt64(domainIds, accessLog.NsDomainId) {
|
||||||
|
domainIds = append(domainIds, accessLog.NsDomainId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["hasMore"] = resp.HasMore
|
||||||
|
this.Data["nextRequestId"] = resp.RequestId
|
||||||
|
|
||||||
|
// 上一个requestId
|
||||||
|
this.Data["hasPrev"] = false
|
||||||
|
this.Data["lastRequestId"] = ""
|
||||||
|
if len(params.RequestId) > 0 {
|
||||||
|
this.Data["hasPrev"] = true
|
||||||
|
prevResp, err := this.RPC().NSAccessLogRPC().ListNSAccessLogs(this.AdminContext(), &pb.ListNSAccessLogsRequest{
|
||||||
|
RequestId: params.RequestId,
|
||||||
|
NsNodeId: 0,
|
||||||
|
NsDomainId: 0,
|
||||||
|
NsRecordId: 0,
|
||||||
|
Day: day,
|
||||||
|
Size: size,
|
||||||
|
Reverse: true,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if int64(len(prevResp.NsAccessLogs)) == size {
|
||||||
|
this.Data["lastRequestId"] = prevResp.RequestId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据IP查询区域
|
||||||
|
regionMap := map[string]string{} // ip => region
|
||||||
|
if len(ipList) > 0 {
|
||||||
|
resp, err := this.RPC().IPLibraryRPC().LookupIPRegions(this.AdminContext(), &pb.LookupIPRegionsRequest{IpList: ipList})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if resp.IpRegionMap != nil {
|
||||||
|
for ip, region := range resp.IpRegionMap {
|
||||||
|
regionMap[ip] = region.Summary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["regions"] = regionMap
|
||||||
|
|
||||||
|
// 节点信息
|
||||||
|
nodeMap := map[int64]interface{}{} // node id => { ... }
|
||||||
|
for _, nodeId := range nodeIds {
|
||||||
|
nodeResp, err := this.RPC().NSNodeRPC().FindEnabledNSNode(this.AdminContext(), &pb.FindEnabledNSNodeRequest{NsNodeId: nodeId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
node := nodeResp.NsNode
|
||||||
|
if node != nil {
|
||||||
|
nodeMap[node.Id] = maps.Map{
|
||||||
|
"id": node.Id,
|
||||||
|
"name": node.Name,
|
||||||
|
"cluster": maps.Map{
|
||||||
|
"id": node.NsCluster.Id,
|
||||||
|
"name": node.NsCluster.Name,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["nodes"] = nodeMap
|
||||||
|
|
||||||
|
// 域名信息
|
||||||
|
domainMap := map[int64]interface{}{} // domain id => { ... }
|
||||||
|
for _, domainId := range domainIds {
|
||||||
|
domainResp, err := this.RPC().NSDomainRPC().FindEnabledNSDomain(this.AdminContext(), &pb.FindEnabledNSDomainRequest{NsDomainId: domainId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
domain := domainResp.NsDomain
|
||||||
|
if domain != nil {
|
||||||
|
domainMap[domain.Id] = maps.Map{
|
||||||
|
"id": domain.Id,
|
||||||
|
"name": domain.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["domains"] = domainMap
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
19
internal/web/actions/default/ns/clusters/accessLogs/init.go
Normal file
19
internal/web/actions/default/ns/clusters/accessLogs/init.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package logs
|
||||||
|
|
||||||
|
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.AdminModuleCodeNS)).
|
||||||
|
Data("teaMenu", "ns").
|
||||||
|
Data("teaSubMenu", "accessLog").
|
||||||
|
Prefix("/ns/clusters/accessLogs").
|
||||||
|
Get("", new(IndexAction)).
|
||||||
|
EndAll()
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IndexAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IndexAction) Init() {
|
||||||
|
this.Nav("", "setting", "")
|
||||||
|
this.SecondMenu("accessLog")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IndexAction) RunGet(params struct {
|
||||||
|
ClusterId int64
|
||||||
|
}) {
|
||||||
|
accessLogResp, err := this.RPC().NSClusterRPC().FindNSClusterAccessLog(this.AdminContext(), &pb.FindNSClusterAccessLogRequest{NsClusterId: params.ClusterId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
accessLogRef := &dnsconfigs.AccessLogRef{}
|
||||||
|
if len(accessLogResp.AccessLogJSON) > 0 {
|
||||||
|
err = json.Unmarshal(accessLogResp.AccessLogJSON, accessLogRef)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Data["accessLogRef"] = accessLogRef
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *IndexAction) RunPost(params struct {
|
||||||
|
ClusterId int64
|
||||||
|
AccessLogJSON []byte
|
||||||
|
|
||||||
|
Must *actions.Must
|
||||||
|
CSRF *actionutils.CSRF
|
||||||
|
}) {
|
||||||
|
defer this.CreateLogInfo("修改域名服务集群 %d 访问日志配置", params.ClusterId)
|
||||||
|
|
||||||
|
ref := &dnsconfigs.AccessLogRef{}
|
||||||
|
err := json.Unmarshal(params.AccessLogJSON, ref)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("数据格式错误:" + err.Error())
|
||||||
|
}
|
||||||
|
err = ref.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("数据格式错误:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = this.RPC().NSClusterRPC().UpdateNSClusterAccessLog(this.AdminContext(), &pb.UpdateNSClusterAccessLogRequest{
|
||||||
|
NsClusterId: params.ClusterId,
|
||||||
|
AccessLogJSON: params.AccessLogJSON,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/clusterutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
|
"github.com/iwind/TeaGo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||||
|
server.
|
||||||
|
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNS)).
|
||||||
|
Helper(new(clusterutils.ClusterHelper)).
|
||||||
|
Data("teaMenu", "ns").
|
||||||
|
Data("teaSubMenu", "cluster").
|
||||||
|
Prefix("/ns/clusters/cluster/settings/accessLog").
|
||||||
|
GetPost("", new(IndexAction)).
|
||||||
|
EndAll()
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -83,5 +83,10 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NSCluster, selectedItem
|
|||||||
"url": "/ns/clusters/cluster/settings?clusterId=" + clusterId,
|
"url": "/ns/clusters/cluster/settings?clusterId=" + clusterId,
|
||||||
"isActive": selectedItem == "basic",
|
"isActive": selectedItem == "basic",
|
||||||
})
|
})
|
||||||
|
items = append(items, maps.Map{
|
||||||
|
"name": "访问日志",
|
||||||
|
"url": "/ns/clusters/cluster/settings/accessLog?clusterId=" + clusterId,
|
||||||
|
"isActive": selectedItem == "accessLog",
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resp.AccessLogs) == 0 {
|
if len(resp.HttpAccessLogs) == 0 {
|
||||||
this.Data["accessLogs"] = []interface{}{}
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
} else {
|
} else {
|
||||||
this.Data["accessLogs"] = resp.AccessLogs
|
this.Data["accessLogs"] = resp.HttpAccessLogs
|
||||||
for _, accessLog := range resp.AccessLogs {
|
for _, accessLog := range resp.HttpAccessLogs {
|
||||||
if len(accessLog.RemoteAddr) > 0 {
|
if len(accessLog.RemoteAddr) > 0 {
|
||||||
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
||||||
ipList = append(ipList, accessLog.RemoteAddr)
|
ipList = append(ipList, accessLog.RemoteAddr)
|
||||||
@@ -85,7 +85,7 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if int64(len(prevResp.AccessLogs)) == size {
|
if int64(len(prevResp.HttpAccessLogs)) == size {
|
||||||
this.Data["lastRequestId"] = prevResp.RequestId
|
this.Data["lastRequestId"] = prevResp.RequestId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ func (this *HistoryAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resp.AccessLogs) == 0 {
|
if len(resp.HttpAccessLogs) == 0 {
|
||||||
this.Data["accessLogs"] = []interface{}{}
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
} else {
|
} else {
|
||||||
this.Data["accessLogs"] = resp.AccessLogs
|
this.Data["accessLogs"] = resp.HttpAccessLogs
|
||||||
for _, accessLog := range resp.AccessLogs {
|
for _, accessLog := range resp.HttpAccessLogs {
|
||||||
if len(accessLog.RemoteAddr) > 0 {
|
if len(accessLog.RemoteAddr) > 0 {
|
||||||
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
||||||
ipList = append(ipList, accessLog.RemoteAddr)
|
ipList = append(ipList, accessLog.RemoteAddr)
|
||||||
@@ -87,7 +87,7 @@ func (this *HistoryAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if int64(len(prevResp.AccessLogs)) == size {
|
if int64(len(prevResp.HttpAccessLogs)) == size {
|
||||||
this.Data["lastRequestId"] = prevResp.RequestId
|
this.Data["lastRequestId"] = prevResp.RequestId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ipList := []string{}
|
ipList := []string{}
|
||||||
accessLogs := accessLogsResp.AccessLogs
|
accessLogs := accessLogsResp.HttpAccessLogs
|
||||||
if len(accessLogs) == 0 {
|
if len(accessLogs) == 0 {
|
||||||
accessLogs = []*pb.HTTPAccessLog{}
|
accessLogs = []*pb.HTTPAccessLog{}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ func (this *TodayAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ipList := []string{}
|
ipList := []string{}
|
||||||
if len(resp.AccessLogs) == 0 {
|
if len(resp.HttpAccessLogs) == 0 {
|
||||||
this.Data["accessLogs"] = []interface{}{}
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
} else {
|
} else {
|
||||||
this.Data["accessLogs"] = resp.AccessLogs
|
this.Data["accessLogs"] = resp.HttpAccessLogs
|
||||||
for _, accessLog := range resp.AccessLogs {
|
for _, accessLog := range resp.HttpAccessLogs {
|
||||||
if len(accessLog.RemoteAddr) > 0 {
|
if len(accessLog.RemoteAddr) > 0 {
|
||||||
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
if !lists.ContainsString(ipList, accessLog.RemoteAddr) {
|
||||||
ipList = append(ipList, accessLog.RemoteAddr)
|
ipList = append(ipList, accessLog.RemoteAddr)
|
||||||
@@ -71,7 +71,7 @@ func (this *TodayAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if int64(len(prevResp.AccessLogs)) == size {
|
if int64(len(prevResp.HttpAccessLogs)) == size {
|
||||||
this.Data["lastRequestId"] = prevResp.RequestId
|
this.Data["lastRequestId"] = prevResp.RequestId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (this *ViewPopupAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
accessLog := accessLogResp.AccessLog
|
accessLog := accessLogResp.HttpAccessLog
|
||||||
if accessLog == nil {
|
if accessLog == nil {
|
||||||
this.WriteString("not found: " + params.RequestId)
|
this.WriteString("not found: " + params.RequestId)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
|
|||||||
"icon": "cloud",
|
"icon": "cloud",
|
||||||
"subItems": []maps.Map{
|
"subItems": []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "节点日志",
|
"name": "运行日志",
|
||||||
"url": "/clusters/logs",
|
"url": "/clusters/logs",
|
||||||
"code": "log",
|
"code": "log",
|
||||||
},
|
},
|
||||||
@@ -236,7 +236,12 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
|
|||||||
"code": "route",
|
"code": "route",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "节点日志",
|
"name": "访问日志",
|
||||||
|
"url": "/ns/clusters/accessLogs",
|
||||||
|
"code": "accessLog",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "运行日志",
|
||||||
"url": "/ns/clusters/logs",
|
"url": "/ns/clusters/logs",
|
||||||
"code": "log",
|
"code": "log",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,14 +3,20 @@ package web
|
|||||||
import (
|
import (
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/tasks"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/tasks"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/about"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/about"
|
||||||
|
|
||||||
|
// 系统用户
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/groups"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/groups"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/instances"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/instances"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/logs"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/logs"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/tasks"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/tasks"
|
||||||
|
|
||||||
|
// API节点
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api/node"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api/node"
|
||||||
|
|
||||||
|
// 节点集群
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings"
|
||||||
@@ -19,6 +25,8 @@ import (
|
|||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions/items"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions/items"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/tasks"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/tasks"
|
||||||
|
|
||||||
|
// 通用
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/csrf"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/csrf"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"
|
||||||
@@ -31,12 +39,15 @@ import (
|
|||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/logout"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/logout"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/messages"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/messages"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes"
|
||||||
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ui"
|
||||||
|
|
||||||
// 域名服务
|
// 域名服务
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters"
|
||||||
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/accessLogs"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings"
|
||||||
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings/accessLog"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/logs"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/logs"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/routes"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/routes"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/users"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/users"
|
||||||
@@ -116,7 +127,10 @@ import (
|
|||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/upgrade"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/upgrade"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/user-nodes"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/user-nodes"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/user-ui"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/user-ui"
|
||||||
|
|
||||||
|
// 安装
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/setup"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/setup"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ui"
|
|
||||||
|
// 平台用户
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/users"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/users"
|
||||||
)
|
)
|
||||||
|
|||||||
38
web/public/js/components/ns/ns-access-log-box.js
Normal file
38
web/public/js/components/ns/ns-access-log-box.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
Vue.component("ns-access-log-box", {
|
||||||
|
props: ["v-access-log"],
|
||||||
|
data: function () {
|
||||||
|
let accessLog = this.vAccessLog
|
||||||
|
return {
|
||||||
|
accessLog: accessLog
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showLog: function () {
|
||||||
|
let that = this
|
||||||
|
let requestId = this.accessLog.requestId
|
||||||
|
this.$parent.$children.forEach(function (v) {
|
||||||
|
if (v.deselect != null) {
|
||||||
|
v.deselect()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.select()
|
||||||
|
|
||||||
|
teaweb.popup("/ns/clusters/accessLogs/viewPopup?requestId=" + requestId, {
|
||||||
|
width: "50em",
|
||||||
|
height: "24em",
|
||||||
|
onClose: function () {
|
||||||
|
that.deselect()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
select: function () {
|
||||||
|
this.$refs.box.parentNode.style.cssText = "background: rgba(0, 0, 0, 0.1)"
|
||||||
|
},
|
||||||
|
deselect: function () {
|
||||||
|
this.$refs.box.parentNode.style.cssText = ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div class="access-log-row" :style="{'color': (accessLog.nsRecordId == null || accessLog.nsRecordId == 0) ? '#dc143c' : ''}" ref="box">
|
||||||
|
<span v-if="accessLog.region != null && accessLog.region.length > 0" class="grey">[{{accessLog.region}}]</span> {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] [{{accessLog.networking}}] <em>{{accessLog.questionType}} {{accessLog.questionName}}</em> -> <em>{{accessLog.recordType}} {{accessLog.recordValue}}</em><!-- <a href="" @click.prevent="showLog" title="查看详情"><i class="icon expand"></i></a>-->
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
27
web/public/js/components/ns/ns-access-log-ref-box.js
Normal file
27
web/public/js/components/ns/ns-access-log-ref-box.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Vue.component("ns-access-log-ref-box", {
|
||||||
|
props:["v-access-log-ref"],
|
||||||
|
data: function () {
|
||||||
|
let config = this.vAccessLogRef
|
||||||
|
if (config == null) {
|
||||||
|
config = {
|
||||||
|
isOn: false,
|
||||||
|
isPrior: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
config: config
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div>
|
||||||
|
<input type="hidden" name="accessLogJSON" :value="JSON.stringify(config)"/>
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td class="title">是否启用</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="isOn" value="1" v-model="config.isOn"></checkbox>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div class="margin"></div>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
Vue.component("ns-cluster-selector", {
|
Vue.component("ns-cluster-selector", {
|
||||||
|
props: ["v-cluster-id"],
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
let that = this
|
let that = this
|
||||||
|
|
||||||
@@ -8,7 +9,6 @@ Vue.component("ns-cluster-selector", {
|
|||||||
that.clusters = resp.data.clusters
|
that.clusters = resp.data.clusters
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
props: ["v-cluster-id"],
|
|
||||||
data: function () {
|
data: function () {
|
||||||
let clusterId = this.vClusterId
|
let clusterId = this.vClusterId
|
||||||
if (clusterId == null) {
|
if (clusterId == null) {
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
<!-- 升级提醒 -->
|
<!-- 升级提醒 -->
|
||||||
<div class="ui message error" v-if="nodeUpgradeInfo.count > 0"><a href="/clusters">升级提醒:有 {{nodeUpgradeInfo.count}} 个边缘节点需要升级到 v{{nodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
<div class="ui message error" v-if="nodeUpgradeInfo.count > 0"><a href="/clusters">升级提醒:有 {{nodeUpgradeInfo.count}} 个边缘节点需要升级到 v{{nodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
<div class="ui message error" v-if="monitorNodeUpgradeInfo.count > 0"><a href="/settings/monitorNodes">升级提醒:有 {{monitorNodeUpgradeInfo.count}} 个监控节点需要升级到 v{{monitorNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
<div class="ui message error" v-if="monitorNodeUpgradeInfo.count > 0 && teaIsPlus"><a href="/settings/monitorNodes">升级提醒:有 {{monitorNodeUpgradeInfo.count}} 个监控节点需要升级到 v{{monitorNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
<div class="ui message error" v-if="userNodeUpgradeInfo.count > 0"><a href="/settings/userNodes">升级提醒:有 {{userNodeUpgradeInfo.count}} 个用户节点需要升级到 v{{userNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
<div class="ui message error" v-if="userNodeUpgradeInfo.count > 0 && teaIsPlus"><a href="/settings/userNodes">升级提醒:有 {{userNodeUpgradeInfo.count}} 个用户节点需要升级到 v{{userNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
<div class="ui message error" v-if="apiNodeUpgradeInfo.count > 0"><a href="/api">升级提醒:有 {{apiNodeUpgradeInfo.count}} 个API节点需要升级到 v{{apiNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
<div class="ui message error" v-if="apiNodeUpgradeInfo.count > 0"><a href="/api">升级提醒:有 {{apiNodeUpgradeInfo.count}} 个API节点需要升级到 v{{apiNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
|
<div class="ui message error" v-if="nsNodeUpgradeInfo.count > 0 && teaIsPlus"><a href="/ns/clusters">升级提醒:有 {{nsNodeUpgradeInfo.count}} 个DNS节点需要升级到 v{{nsNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
<div class="ui message error" v-if="authorityNodeUpgradeInfo.count > 0 && teaIsPlus"><a href="/settings/authority/nodes">升级提醒:有 {{authorityNodeUpgradeInfo.count}} 个企业版认证节点需要升级到 v{{authorityNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
<div class="ui message error" v-if="authorityNodeUpgradeInfo.count > 0 && teaIsPlus"><a href="/settings/authority/nodes">升级提醒:有 {{authorityNodeUpgradeInfo.count}} 个企业版认证节点需要升级到 v{{authorityNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
||||||
|
|
||||||
<!-- 统计图表 -->
|
<!-- 统计图表 -->
|
||||||
|
|||||||
5
web/views/@default/ns/clusters/accessLogs/index.css
Normal file
5
web/views/@default/ns/clusters/accessLogs/index.css
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.access-log-row em {
|
||||||
|
font-style: italic !important;
|
||||||
|
font-size: 1em !important;
|
||||||
|
}
|
||||||
|
/*# sourceMappingURL=index.css.map */
|
||||||
1
web/views/@default/ns/clusters/accessLogs/index.css.map
Normal file
1
web/views/@default/ns/clusters/accessLogs/index.css.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,eACC;EACC,6BAAA;EACA,yBAAA","file":"index.css"}
|
||||||
65
web/views/@default/ns/clusters/accessLogs/index.html
Normal file
65
web/views/@default/ns/clusters/accessLogs/index.html
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{$layout}
|
||||||
|
|
||||||
|
{$var "header"}
|
||||||
|
<!-- datepicker -->
|
||||||
|
<script type="text/javascript" src="/js/moment.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/pikaday.js"></script>
|
||||||
|
<link rel="stylesheet" href="/js/pikaday.css"/>
|
||||||
|
<link rel="stylesheet" href="/js/pikaday.theme.css"/>
|
||||||
|
<link rel="stylesheet" href="/js/pikaday.triangle.css"/>
|
||||||
|
{$end}
|
||||||
|
|
||||||
|
<first-menu>
|
||||||
|
<div class="item right">
|
||||||
|
<form method="get" class="ui form small" :action="path" autocomplete="off">
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<button class="ui button small" type="submit">查找</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</first-menu>
|
||||||
|
|
||||||
|
<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>
|
||||||
|
|
||||||
|
<table class="ui table selectable" v-if="accessLogs.length > 0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="two wide">集群</th>
|
||||||
|
<th class="two wide">节点</th>
|
||||||
|
<th class="two wide">域名</th>
|
||||||
|
<th>概要</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<!-- 这里之所以需要添加 :key,是因为要不然不会刷新显示 -->
|
||||||
|
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
|
||||||
|
<td>
|
||||||
|
<div v-if="accessLog.node.cluster != null">
|
||||||
|
<link-icon :href="'/ns/clusters/cluster?clusterId=' + accessLog.node.cluster.id">{{accessLog.node.cluster.name}}</link-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div v-if="accessLog.node != null">
|
||||||
|
<link-icon :href="'/ns/clusters/cluster/node?clusterId=' + accessLog.node.cluster.id + '&nodeId=' + accessLog.node.id">{{accessLog.node.name}}</link-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div v-if="accessLog.domain != null">
|
||||||
|
<link-icon :href="'/ns/domains/domain?domainId=' + accessLog.domain.id">{{accessLog.domain.name}}</link-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td><ns-access-log-box :v-access-log="accessLog"></ns-access-log-box></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div v-if="accessLogs.length > 0">
|
||||||
|
<a :href="path + '?requestId=' + lastRequestId + '&day=' + day" v-if="hasPrev">上一页</a>
|
||||||
|
<span v-else class="disabled">上一页</span>
|
||||||
|
<span class="disabled"> | </span>
|
||||||
|
<a :href="path + '?requestId=' + nextRequestId + '&day=' + day" v-if="hasMore">下一页</a>
|
||||||
|
<span v-else class="disabled">下一页</span>
|
||||||
|
</div>
|
||||||
32
web/views/@default/ns/clusters/accessLogs/index.js
Normal file
32
web/views/@default/ns/clusters/accessLogs/index.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
let that = this
|
||||||
|
this.accessLogs.forEach(function (accessLog) {
|
||||||
|
// 区域
|
||||||
|
if (typeof (that.regions[accessLog.remoteAddr]) == "string") {
|
||||||
|
accessLog.region = that.regions[accessLog.remoteAddr]
|
||||||
|
} else {
|
||||||
|
accessLog.region = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// 节点
|
||||||
|
if (typeof (that.nodes[accessLog.nsNodeId]) != "undefined") {
|
||||||
|
accessLog["node"] = that.nodes[accessLog.nsNodeId]
|
||||||
|
} else {
|
||||||
|
accessLog["node"] = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// 域名
|
||||||
|
if (typeof (that.domains[accessLog.nsDomainId]) != "undefined") {
|
||||||
|
accessLog["domain"] = that.domains[accessLog.nsDomainId]
|
||||||
|
} else {
|
||||||
|
accessLog["domain"] = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$delay(function () {
|
||||||
|
let that = this
|
||||||
|
teaweb.datepicker("day-input", function (v) {
|
||||||
|
that.day = v
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
6
web/views/@default/ns/clusters/accessLogs/index.less
Normal file
6
web/views/@default/ns/clusters/accessLogs/index.less
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.access-log-row {
|
||||||
|
em {
|
||||||
|
font-style: italic !important;
|
||||||
|
font-size: 1em !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "/left_menu"}
|
||||||
|
|
||||||
|
<div class="right-box">
|
||||||
|
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
|
<csrf-token></csrf-token>
|
||||||
|
<input type="hidden" name="clusterId" :value="clusterId"/>
|
||||||
|
<ns-access-log-ref-box :v-access-log-ref="accessLogRef"></ns-access-log-ref-box>
|
||||||
|
<submit-btn></submit-btn>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.success = NotifyReloadSuccess("保存成功")
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user