mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-17 22:30:25 +08:00
[日志审计]区分用户操作日志和管理员操作日志
This commit is contained in:
@@ -23,6 +23,7 @@ func (this *ExportExcelAction) RunGet(params struct {
|
||||
DayFrom string
|
||||
DayTo string
|
||||
Keyword string
|
||||
UserType string
|
||||
}) {
|
||||
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
|
||||
Offset: 0,
|
||||
@@ -30,6 +31,7 @@ func (this *ExportExcelAction) RunGet(params struct {
|
||||
DayFrom: params.DayFrom,
|
||||
DayTo: params.DayTo,
|
||||
Keyword: params.Keyword,
|
||||
UserType: params.UserType,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -88,7 +90,11 @@ func (this *ExportExcelAction) RunGet(params struct {
|
||||
row.SetHeight(25)
|
||||
row.AddCell().SetInt64(log.Id)
|
||||
row.AddCell().SetString(timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt))
|
||||
if log.UserId > 0 {
|
||||
row.AddCell().SetString("用户 | " + log.UserName)
|
||||
} else {
|
||||
row.AddCell().SetString(log.UserName)
|
||||
}
|
||||
row.AddCell().SetString(log.Description)
|
||||
row.AddCell().SetString(log.Ip)
|
||||
row.AddCell().SetString(regionName)
|
||||
|
||||
@@ -22,6 +22,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
DayFrom string
|
||||
DayTo string
|
||||
Keyword string
|
||||
UserType string
|
||||
}) {
|
||||
// 读取配置
|
||||
config, err := configloaders.LoadLogConfig()
|
||||
@@ -34,11 +35,13 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["dayFrom"] = params.DayFrom
|
||||
this.Data["dayTo"] = params.DayTo
|
||||
this.Data["keyword"] = params.Keyword
|
||||
this.Data["userType"] = params.UserType
|
||||
|
||||
countResp, err := this.RPC().LogRPC().CountLogs(this.AdminContext(), &pb.CountLogRequest{
|
||||
DayFrom: params.DayFrom,
|
||||
DayTo: params.DayTo,
|
||||
Keyword: params.Keyword,
|
||||
UserType: params.UserType,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -54,6 +57,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
DayFrom: params.DayFrom,
|
||||
DayTo: params.DayTo,
|
||||
Keyword: params.Keyword,
|
||||
UserType: params.UserType,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -86,6 +90,8 @@ func (this *IndexAction) RunGet(params struct {
|
||||
|
||||
logMaps = append(logMaps, maps.Map{
|
||||
"id": log.Id,
|
||||
"adminId": log.AdminId,
|
||||
"userId": log.UserId,
|
||||
"description": log.Description,
|
||||
"userName": log.UserName,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
<div class="ui field">
|
||||
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown auto-width" name="userType" v-model="userType">
|
||||
<option value="">[用户类型]</option>
|
||||
<option value="admin">管理员</option>
|
||||
<option value="user">用户</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button type="submit" class="ui button">查询</button>
|
||||
</div>
|
||||
@@ -43,7 +50,7 @@
|
||||
<table class="ui table selectable" v-for="log in logs">
|
||||
<tr :class="{error: log.level == 'error', warning: log.level == 'warn'}">
|
||||
<td class="log-row">{{log.createdTime}} <span class="grey"> <span
|
||||
v-if="log.userName.length > 0">| {{log.userName}}</span> | {{log.ip}}<span
|
||||
v-if="log.userName.length > 0">| <span v-if="log.userId>0">用户 | </span> {{log.userName}}</span> | {{log.ip}}<span
|
||||
v-if="log.region.length > 0"> | {{log.region}}</span> <a href="" @click.prevent="showMore(log)" title="显示更多">...</a> <span v-if="log.moreVisible">{{log.action}}</span></span>
|
||||
<span class="buttons"><a v-if="logConfig.canDelete" href="" title="删除" @click.prevent="deleteLog(log.id)"><i class="icon remove small"></i></a> </span>
|
||||
</td>
|
||||
|
||||
@@ -15,7 +15,7 @@ Tea.context(function () {
|
||||
this.exportExcel = function () {
|
||||
let that = this
|
||||
teaweb.confirm("确定要将当前列表导出到Excel吗?", function () {
|
||||
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword
|
||||
window.location = "/log/exportExcel?dayFrom=" + that.dayFrom + "&dayTo=" + that.dayTo + "&keyword=" + that.keyword + "&userType=" + that.userType
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user