IP列表可以使用级别筛选

This commit is contained in:
GoEdgeLab
2022-03-30 09:41:14 +08:00
parent c415c36e86
commit 19dbc31162
4 changed files with 37 additions and 10 deletions

View File

@@ -23,16 +23,19 @@ func (this *IndexAction) RunGet(params struct {
Ip string
GlobalOnly bool
Unread bool
EventLevel string
}) {
this.Data["type"] = ""
this.Data["ip"] = params.Ip
this.Data["globalOnly"] = params.GlobalOnly
this.Data["unread"] = params.Unread
this.Data["eventLevel"] = params.EventLevel
countUnreadResp, err := this.RPC().IPItemRPC().CountAllEnabledIPItems(this.AdminContext(), &pb.CountAllEnabledIPItemsRequest{
Ip: params.Ip,
GlobalOnly: params.GlobalOnly,
Unread: true,
EventLevel: params.EventLevel,
})
if err != nil {
this.ErrorPage(err)
@@ -44,6 +47,7 @@ func (this *IndexAction) RunGet(params struct {
Ip: params.Ip,
GlobalOnly: params.GlobalOnly,
Unread: params.Unread,
EventLevel: params.EventLevel,
})
if err != nil {
this.ErrorPage(err)
@@ -57,6 +61,7 @@ func (this *IndexAction) RunGet(params struct {
Ip: params.Ip,
GlobalOnly: params.GlobalOnly,
Unread: params.Unread,
EventLevel: params.EventLevel,
Offset: page.Offset,
Size: page.Size,
})
@@ -166,5 +171,8 @@ func (this *IndexAction) RunGet(params struct {
}
this.Data["items"] = itemMaps
// 所有级别
this.Data["eventLevels"] = firewallconfigs.FindAllFirewallEventLevels()
this.Show()
}

View File

@@ -22,8 +22,10 @@ func (this *ItemsAction) Init() {
func (this *ItemsAction) RunGet(params struct {
ListId int64
Keyword string
EventLevel string
}) {
this.Data["keyword"] = params.Keyword
this.Data["eventLevel"] = params.EventLevel
err := InitIPList(this.Parent(), params.ListId)
if err != nil {
@@ -36,6 +38,7 @@ func (this *ItemsAction) RunGet(params struct {
countResp, err := this.RPC().IPItemRPC().CountIPItemsWithListId(this.AdminContext(), &pb.CountIPItemsWithListIdRequest{
IpListId: listId,
Keyword: params.Keyword,
EventLevel: params.EventLevel,
})
if err != nil {
this.ErrorPage(err)
@@ -49,6 +52,7 @@ func (this *ItemsAction) RunGet(params struct {
itemsResp, err := this.RPC().IPItemRPC().ListIPItemsWithListId(this.AdminContext(), &pb.ListIPItemsWithListIdRequest{
IpListId: listId,
Keyword: params.Keyword,
EventLevel: params.EventLevel,
Offset: page.Offset,
Size: page.Size,
})
@@ -118,5 +122,8 @@ func (this *ItemsAction) RunGet(params struct {
}
this.Data["items"] = itemMaps
// 所有级别
this.Data["eventLevels"] = firewallconfigs.FindAllFirewallEventLevels()
this.Show()
}

View File

@@ -7,6 +7,12 @@
<div class="ui field">
<input type="text" name="ip" placeholder="x.x.x.x" v-model="ip"/>
</div>
<div class="ui field">
<select class="ui dropdown" name="eventLevel" v-model="eventLevel">
<option value="">[级别]</option>
<option v-for="level in eventLevels" :value="level.code">{{level.name}}</option>
</select>
</div>
<div class="ui field">
<div class="ui checkbox">
<input type="checkbox" name="globalOnly" value="1" v-model="globalOnly"/>
@@ -22,7 +28,7 @@
<div class="ui field">
<button class="ui button" type="submit">搜索</button>
&nbsp;
<a href="/servers/iplists" v-if="ip.length > 0 || globalOnly || unread">[清除条件]</a>
<a href="/servers/iplists" v-if="ip.length > 0 || globalOnly || unread || eventLevel.length > 0">[清除条件]</a>
</div>
<div class="ui field" v-if="countUnread > 0">
<span class="disabled">|</span>

View File

@@ -11,10 +11,16 @@
<div class="ui field">
<input type="text" size="20" placeholder="x.x.x.x" name="keyword" v-model="keyword"/>
</div>
<div class="ui field">
<select class="ui dropdown" name="eventLevel" v-model="eventLevel">
<option value="">[级别]</option>
<option v-for="level in eventLevels" :value="level.code">{{level.name}}</option>
</select>
</div>
<div class="ui field">
<button class="ui button" type="submit">搜索</button>
&nbsp;
<a :href="'/servers/iplists/items?listId=' + list.id" v-if="keyword.length > 0">[清除条件]</a>
<a :href="'/servers/iplists/items?listId=' + list.id" v-if="keyword.length > 0 || eventLevel.length > 0">[清除条件]</a>
</div>
</div>
<div class="margin"></div>