mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-15 04:41:25 +08:00
审计日志列表增加级别筛选
This commit is contained in:
@@ -23,6 +23,7 @@ func (this *ExportExcelAction) RunGet(params struct {
|
|||||||
DayTo string
|
DayTo string
|
||||||
Keyword string
|
Keyword string
|
||||||
UserType string
|
UserType string
|
||||||
|
Level string
|
||||||
}) {
|
}) {
|
||||||
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
|
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
|
||||||
Offset: 0,
|
Offset: 0,
|
||||||
@@ -31,6 +32,7 @@ func (this *ExportExcelAction) RunGet(params struct {
|
|||||||
DayTo: params.DayTo,
|
DayTo: params.DayTo,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
UserType: params.UserType,
|
UserType: params.UserType,
|
||||||
|
Level: params.Level,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -56,6 +58,7 @@ func (this *ExportExcelAction) RunGet(params struct {
|
|||||||
row.AddCell().SetString("区域")
|
row.AddCell().SetString("区域")
|
||||||
row.AddCell().SetString("运营商")
|
row.AddCell().SetString("运营商")
|
||||||
row.AddCell().SetString("页面地址")
|
row.AddCell().SetString("页面地址")
|
||||||
|
row.AddCell().SetString("级别")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
@@ -95,6 +98,17 @@ func (this *ExportExcelAction) RunGet(params struct {
|
|||||||
row.AddCell().SetString(regionName)
|
row.AddCell().SetString(regionName)
|
||||||
row.AddCell().SetString(ispName)
|
row.AddCell().SetString(ispName)
|
||||||
row.AddCell().SetString(log.Action)
|
row.AddCell().SetString(log.Action)
|
||||||
|
|
||||||
|
var levelName = ""
|
||||||
|
switch log.Level {
|
||||||
|
case "info":
|
||||||
|
levelName = "信息"
|
||||||
|
case "warn", "warning":
|
||||||
|
levelName = "警告"
|
||||||
|
case "error":
|
||||||
|
levelName = "错误"
|
||||||
|
}
|
||||||
|
row.AddCell().SetString(levelName)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.AddHeader("Content-Type", "application/vnd.ms-excel")
|
this.AddHeader("Content-Type", "application/vnd.ms-excel")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
DayTo string
|
DayTo string
|
||||||
Keyword string
|
Keyword string
|
||||||
UserType string
|
UserType string
|
||||||
|
Level string
|
||||||
}) {
|
}) {
|
||||||
// 读取配置
|
// 读取配置
|
||||||
config, err := configloaders.LoadLogConfig()
|
config, err := configloaders.LoadLogConfig()
|
||||||
@@ -35,18 +36,36 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
this.Data["userType"] = params.UserType
|
this.Data["userType"] = params.UserType
|
||||||
|
|
||||||
|
// 级别
|
||||||
|
this.Data["level"] = params.Level
|
||||||
|
this.Data["levelOptions"] = []maps.Map{
|
||||||
|
{
|
||||||
|
"code": "info",
|
||||||
|
"name": "信息",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "warn",
|
||||||
|
"name": "警告",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "error",
|
||||||
|
"name": "错误",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
countResp, err := this.RPC().LogRPC().CountLogs(this.AdminContext(), &pb.CountLogRequest{
|
countResp, err := this.RPC().LogRPC().CountLogs(this.AdminContext(), &pb.CountLogRequest{
|
||||||
DayFrom: params.DayFrom,
|
DayFrom: params.DayFrom,
|
||||||
DayTo: params.DayTo,
|
DayTo: params.DayTo,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
UserType: params.UserType,
|
UserType: params.UserType,
|
||||||
|
Level: params.Level,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
count := countResp.Count
|
var count = countResp.Count
|
||||||
page := this.NewPage(count)
|
var page = this.NewPage(count)
|
||||||
this.Data["page"] = page.AsHTML()
|
this.Data["page"] = page.AsHTML()
|
||||||
|
|
||||||
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
|
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
|
||||||
@@ -56,12 +75,13 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
DayTo: params.DayTo,
|
DayTo: params.DayTo,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
UserType: params.UserType,
|
UserType: params.UserType,
|
||||||
|
Level: params.Level,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logMaps := []maps.Map{}
|
var logMaps = []maps.Map{}
|
||||||
for _, log := range logsResp.Logs {
|
for _, log := range logsResp.Logs {
|
||||||
regionName := ""
|
regionName := ""
|
||||||
regionResp, err := this.RPC().IPLibraryRPC().LookupIPRegion(this.AdminContext(), &pb.LookupIPRegionRequest{Ip: log.Ip})
|
regionResp, err := this.RPC().IPLibraryRPC().LookupIPRegion(this.AdminContext(), &pb.LookupIPRegionRequest{Ip: log.Ip})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<first-menu>
|
<first-menu>
|
||||||
<menu-item href="/log" code="list">查询</menu-item>
|
<menu-item href="/log" code="list">查询</menu-item>
|
||||||
|
<span class="item disabled">|</span>
|
||||||
<menu-item href="/log/clean" code="clean" v-if="logConfig.canClean">清理</menu-item>
|
<menu-item href="/log/clean" code="clean" v-if="logConfig.canClean">清理</menu-item>
|
||||||
<menu-item href="/log/settings" code="setting">设置</menu-item>
|
<menu-item href="/log/settings" code="setting">设置</menu-item>
|
||||||
</first-menu>
|
</first-menu>
|
||||||
@@ -15,6 +15,12 @@
|
|||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<select class="ui dropdown" name="level" v-model="level">
|
||||||
|
<option value="">[级别]</option>
|
||||||
|
<option v-for="levelOption in levelOptions" :value="levelOption.code">{{levelOption.name}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<select class="ui dropdown auto-width" name="userType" v-model="userType">
|
<select class="ui dropdown auto-width" name="userType" v-model="userType">
|
||||||
<option value="">[用户类型]</option>
|
<option value="">[用户类型]</option>
|
||||||
@@ -25,7 +31,7 @@
|
|||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">查询</button>
|
<button type="submit" class="ui button">查询</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0">
|
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0">
|
||||||
<a href="/log">[清除条件]</a>
|
<a href="/log">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Tea.context(function () {
|
|||||||
this.exportExcel = function () {
|
this.exportExcel = function () {
|
||||||
let that = this
|
let that = this
|
||||||
teaweb.confirm("确定要将当前列表导出到Excel吗?", function () {
|
teaweb.confirm("确定要将当前列表导出到Excel吗?", function () {
|
||||||
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword + "&userType=" + that.userType
|
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword + "&userType=" + that.userType + '&level=' + that.level
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user