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