From 7d8f3a9d9b473c45368cf40c384a02c22044d15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 18 Jul 2021 17:09:31 +0800 Subject: [PATCH] =?UTF-8?q?IP=E5=90=8D=E5=8D=95=E4=B8=AD=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87IP=E6=9F=A5=E6=89=BE=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/iplists/accessLogsPopup.go | 51 +++++++++++++++++++ .../actions/default/servers/iplists/init.go | 1 + .../js/components/iplist/ip-list-table.js | 39 ++++++++------ .../servers/iplists/accessLogsPopup.html | 10 ++++ 4 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 internal/web/actions/default/servers/iplists/accessLogsPopup.go create mode 100644 web/views/@default/servers/iplists/accessLogsPopup.html diff --git a/internal/web/actions/default/servers/iplists/accessLogsPopup.go b/internal/web/actions/default/servers/iplists/accessLogsPopup.go new file mode 100644 index 00000000..4dc82c93 --- /dev/null +++ b/internal/web/actions/default/servers/iplists/accessLogsPopup.go @@ -0,0 +1,51 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package iplists + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + timeutil "github.com/iwind/TeaGo/utils/time" +) + +type AccessLogsPopupAction struct { + actionutils.ParentAction +} + +func (this *AccessLogsPopupAction) Init() { + this.Nav("", "", "") +} + +func (this *AccessLogsPopupAction) RunGet(params struct { + ItemId int64 +}) { + itemResp, err := this.RPC().IPItemRPC().FindEnabledIPItem(this.AdminContext(), &pb.FindEnabledIPItemRequest{IpItemId: params.ItemId}) + if err != nil { + this.ErrorPage(err) + return + } + var item = itemResp.IpItem + if item == nil { + this.NotFound("ipItem", params.ItemId) + return + } + this.Data["ipFrom"] = item.IpFrom + this.Data["ipTo"] = item.IpTo + + accessLogsResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{ + Day: timeutil.Format("Ymd"), + Keyword: "ip:" + item.IpFrom + "," + item.IpTo, + Size: 10, + }) + if err != nil { + this.ErrorPage(err) + return + } + var accessLogs = accessLogsResp.HttpAccessLogs + if len(accessLogs) == 0 { + accessLogs = []*pb.HTTPAccessLog{} + } + this.Data["accessLogs"] = accessLogs + + this.Show() +} diff --git a/internal/web/actions/default/servers/iplists/init.go b/internal/web/actions/default/servers/iplists/init.go index ab71056c..6c7238a9 100644 --- a/internal/web/actions/default/servers/iplists/init.go +++ b/internal/web/actions/default/servers/iplists/init.go @@ -29,6 +29,7 @@ func init() { GetPost("/createIPPopup", new(CreateIPPopupAction)). GetPost("/updateIPPopup", new(UpdateIPPopupAction)). Post("/deleteIP", new(DeleteIPAction)). + Get("/accessLogsPopup", new(AccessLogsPopupAction)). // 防火墙 GetPost("/bindHTTPFirewallPopup", new(BindHTTPFirewallPopupAction)). diff --git a/web/public/js/components/iplist/ip-list-table.js b/web/public/js/components/iplist/ip-list-table.js index e8b86bb5..0d4a7731 100644 --- a/web/public/js/components/iplist/ip-list-table.js +++ b/web/public/js/components/iplist/ip-list-table.js @@ -1,19 +1,25 @@ Vue.component("ip-list-table", { - props: ["v-items"], - data: function () { - return { - items: this.vItems - } - }, - methods: { - updateItem: function (itemId) { - this.$emit("update-item", itemId) - }, - deleteItem: function (itemId) { - this.$emit("delete-item", itemId) - } - }, - template: `
+ props: ["v-items"], + data: function () { + return { + items: this.vItems + } + }, + methods: { + updateItem: function (itemId) { + this.$emit("update-item", itemId) + }, + deleteItem: function (itemId) { + this.$emit("delete-item", itemId) + }, + viewLogs: function (itemId) { + teaweb.popup("/servers/iplists/accessLogsPopup?itemId=" + itemId, { + width: "50em", + height: "30em" + }) + } + }, + template: `
@@ -22,7 +28,7 @@ Vue.component("ip-list-table", { - + @@ -54,6 +60,7 @@ Vue.component("ip-list-table", { - diff --git a/web/views/@default/servers/iplists/accessLogsPopup.html b/web/views/@default/servers/iplists/accessLogsPopup.html new file mode 100644 index 00000000..63d0e754 --- /dev/null +++ b/web/views/@default/servers/iplists/accessLogsPopup.html @@ -0,0 +1,10 @@ +{$layout "layout_popup"} + +

访问日志({{ipFrom}} - {{ipTo}})({{ipFrom}})

+ +

暂时还没有访问日志。

+
级别 过期时间 备注操作操作
+ 日志   修改   删除
+ + + +
\ No newline at end of file