mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-08 16:00:26 +08:00
增加全局查看、检索IP功能
This commit is contained in:
@@ -5,8 +5,9 @@ package iplists
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexAction struct {
|
type IndexAction struct {
|
||||||
@@ -18,32 +19,22 @@ func (this *IndexAction) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
Type string
|
Ip string
|
||||||
Keyword string
|
|
||||||
}) {
|
}) {
|
||||||
if len(params.Type) == 0 {
|
this.Data["type"] = ""
|
||||||
params.Type = ipconfigs.IPListTypeBlack
|
this.Data["ip"] = params.Ip
|
||||||
}
|
|
||||||
this.Data["type"] = params.Type
|
|
||||||
this.Data["keyword"] = params.Keyword
|
|
||||||
|
|
||||||
countResp, err := this.RPC().IPListRPC().CountAllEnabledIPLists(this.AdminContext(), &pb.CountAllEnabledIPListsRequest{
|
countResp, err := this.RPC().IPItemRPC().CountAllEnabledIPItems(this.AdminContext(), &pb.CountAllEnabledIPItemsRequest{Ip: params.Ip})
|
||||||
Type: params.Type,
|
|
||||||
IsPublic: true,
|
|
||||||
Keyword: params.Keyword,
|
|
||||||
})
|
|
||||||
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()
|
||||||
|
|
||||||
listsResp, err := this.RPC().IPListRPC().ListEnabledIPLists(this.AdminContext(), &pb.ListEnabledIPListsRequest{
|
itemsResp, err := this.RPC().IPItemRPC().ListAllEnabledIPItems(this.AdminContext(), &pb.ListAllEnabledIPItemsRequest{
|
||||||
Type: params.Type,
|
Ip: params.Ip,
|
||||||
IsPublic: true,
|
|
||||||
Keyword: params.Keyword,
|
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
@@ -51,27 +42,93 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var listMaps = []maps.Map{}
|
|
||||||
for _, list := range listsResp.IpLists {
|
|
||||||
// 包含的IP数量
|
|
||||||
countItemsResp, err := this.RPC().IPItemRPC().CountIPItemsWithListId(this.AdminContext(), &pb.CountIPItemsWithListIdRequest{IpListId: list.Id})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var countItems = countItemsResp.Count
|
|
||||||
|
|
||||||
listMaps = append(listMaps, maps.Map{
|
var itemMaps = []maps.Map{}
|
||||||
"id": list.Id,
|
for _, result := range itemsResp.Results {
|
||||||
"isOn": list.IsOn,
|
var item = result.IpItem
|
||||||
"name": list.Name,
|
expiredTime := ""
|
||||||
"description": list.Description,
|
if item.ExpiredAt > 0 {
|
||||||
"countItems": countItems,
|
expiredTime = timeutil.FormatTime("Y-m-d H:i:s", item.ExpiredAt)
|
||||||
"type": list.Type,
|
}
|
||||||
"isGlobal": list.IsGlobal,
|
|
||||||
|
// policy
|
||||||
|
var sourcePolicyMap = maps.Map{"id": 0}
|
||||||
|
if item.SourceHTTPFirewallPolicy != nil {
|
||||||
|
sourcePolicyMap = maps.Map{
|
||||||
|
"id": item.SourceHTTPFirewallPolicy.Id,
|
||||||
|
"name": item.SourceHTTPFirewallPolicy.Name,
|
||||||
|
"serverId": item.SourceHTTPFirewallPolicy.ServerId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// group
|
||||||
|
var sourceGroupMap = maps.Map{"id": 0}
|
||||||
|
if item.SourceHTTPFirewallRuleGroup != nil {
|
||||||
|
sourceGroupMap = maps.Map{
|
||||||
|
"id": item.SourceHTTPFirewallRuleGroup.Id,
|
||||||
|
"name": item.SourceHTTPFirewallRuleGroup.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set
|
||||||
|
var sourceSetMap = maps.Map{"id": 0}
|
||||||
|
if item.SourceHTTPFirewallRuleSet != nil {
|
||||||
|
sourceSetMap = maps.Map{
|
||||||
|
"id": item.SourceHTTPFirewallRuleSet.Id,
|
||||||
|
"name": item.SourceHTTPFirewallRuleSet.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// server
|
||||||
|
var sourceServerMap = maps.Map{"id": 0}
|
||||||
|
if item.SourceServer != nil {
|
||||||
|
sourceServerMap = maps.Map{
|
||||||
|
"id": item.SourceServer.Id,
|
||||||
|
"name": item.SourceServer.Name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IP名单
|
||||||
|
var listMap = maps.Map{"id": 0}
|
||||||
|
if result.IpList != nil {
|
||||||
|
listMap = maps.Map{
|
||||||
|
"id": result.IpList.Id,
|
||||||
|
"name": result.IpList.Name,
|
||||||
|
"type": result.IpList.Type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// policy
|
||||||
|
var policyMap = maps.Map{"id": 0}
|
||||||
|
if result.HttpFirewallPolicy != nil {
|
||||||
|
policyMap = maps.Map{
|
||||||
|
"id": result.HttpFirewallPolicy.Id,
|
||||||
|
"name": result.HttpFirewallPolicy.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Server != nil {
|
||||||
|
policyMap["server"] = maps.Map{"id": result.Server.Id, "name": result.Server.Name}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemMaps = append(itemMaps, maps.Map{
|
||||||
|
"id": item.Id,
|
||||||
|
"ipFrom": item.IpFrom,
|
||||||
|
"ipTo": item.IpTo,
|
||||||
|
"createdTime": timeutil.FormatTime("Y-m-d", item.CreatedAt),
|
||||||
|
"expiredTime": expiredTime,
|
||||||
|
"reason": item.Reason,
|
||||||
|
"type": item.Type,
|
||||||
|
"eventLevelName": firewallconfigs.FindFirewallEventLevelName(item.EventLevel),
|
||||||
|
"sourcePolicy": sourcePolicyMap,
|
||||||
|
"sourceGroup": sourceGroupMap,
|
||||||
|
"sourceSet": sourceSetMap,
|
||||||
|
"sourceServer": sourceServerMap,
|
||||||
|
"list": listMap,
|
||||||
|
"policy": policyMap,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.Data["lists"] = listMaps
|
this.Data["items"] = itemMaps
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func init() {
|
|||||||
Data("teaSubMenu", "iplist").
|
Data("teaSubMenu", "iplist").
|
||||||
Prefix("/servers/iplists").
|
Prefix("/servers/iplists").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
|
Get("/lists", new(ListsAction)).
|
||||||
GetPost("/createPopup", new(CreatePopupAction)).
|
GetPost("/createPopup", new(CreatePopupAction)).
|
||||||
Get("/list", new(ListAction)).
|
Get("/list", new(ListAction)).
|
||||||
GetPost("/import", new(ImportAction)).
|
GetPost("/import", new(ImportAction)).
|
||||||
@@ -38,7 +39,6 @@ func init() {
|
|||||||
|
|
||||||
// 选项数据
|
// 选项数据
|
||||||
Post("/levelOptions", new(LevelOptionsAction)).
|
Post("/levelOptions", new(LevelOptionsAction)).
|
||||||
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
77
internal/web/actions/default/servers/iplists/lists.go
Normal file
77
internal/web/actions/default/servers/iplists/lists.go
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
// 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"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListsAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ListsAction) Init() {
|
||||||
|
this.Nav("", "", "lists")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ListsAction) RunGet(params struct {
|
||||||
|
Type string
|
||||||
|
Keyword string
|
||||||
|
}) {
|
||||||
|
if len(params.Type) == 0 {
|
||||||
|
params.Type = ipconfigs.IPListTypeBlack
|
||||||
|
}
|
||||||
|
this.Data["type"] = params.Type
|
||||||
|
this.Data["keyword"] = params.Keyword
|
||||||
|
|
||||||
|
countResp, err := this.RPC().IPListRPC().CountAllEnabledIPLists(this.AdminContext(), &pb.CountAllEnabledIPListsRequest{
|
||||||
|
Type: params.Type,
|
||||||
|
IsPublic: true,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
count := countResp.Count
|
||||||
|
page := this.NewPage(count)
|
||||||
|
this.Data["page"] = page.AsHTML()
|
||||||
|
|
||||||
|
listsResp, err := this.RPC().IPListRPC().ListEnabledIPLists(this.AdminContext(), &pb.ListEnabledIPListsRequest{
|
||||||
|
Type: params.Type,
|
||||||
|
IsPublic: true,
|
||||||
|
Keyword: params.Keyword,
|
||||||
|
Offset: page.Offset,
|
||||||
|
Size: page.Size,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var listMaps = []maps.Map{}
|
||||||
|
for _, list := range listsResp.IpLists {
|
||||||
|
// 包含的IP数量
|
||||||
|
countItemsResp, err := this.RPC().IPItemRPC().CountIPItemsWithListId(this.AdminContext(), &pb.CountIPItemsWithListIdRequest{IpListId: list.Id})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var countItems = countItemsResp.Count
|
||||||
|
|
||||||
|
listMaps = append(listMaps, maps.Map{
|
||||||
|
"id": list.Id,
|
||||||
|
"isOn": list.IsOn,
|
||||||
|
"name": list.Name,
|
||||||
|
"description": list.Description,
|
||||||
|
"countItems": countItems,
|
||||||
|
"type": list.Type,
|
||||||
|
"isGlobal": list.IsGlobal,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["lists"] = listMaps
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
@@ -38,7 +38,24 @@ Vue.component("ip-list-table", {
|
|||||||
<span v-if="item.type != 'all'"><keyword :v-word="keyword">{{item.ipFrom}}</keyword><span v-if="item.ipTo.length > 0"> - <keyword :v-word="keyword">{{item.ipTo}}</keyword></span></span>
|
<span v-if="item.type != 'all'"><keyword :v-word="keyword">{{item.ipFrom}}</keyword><span v-if="item.ipTo.length > 0"> - <keyword :v-word="keyword">{{item.ipTo}}</keyword></span></span>
|
||||||
<span v-else class="disabled">*</span>
|
<span v-else class="disabled">*</span>
|
||||||
<div v-if="item.createdTime != null">
|
<div v-if="item.createdTime != null">
|
||||||
<span class="small disabled">添加于 {{item.createdTime}}</span>
|
<span class="small grey">添加于 {{item.createdTime}}
|
||||||
|
<span v-if="item.list != null && item.list.id > 0">
|
||||||
|
@
|
||||||
|
|
||||||
|
<a :href="'/servers/iplists/list?listId=' + item.list.id" v-if="item.policy.id == 0"><span>[<span v-if="item.list.type == 'black'">黑</span><span v-if="item.list.type == 'white'">白</span>名单:{{item.list.name}}]</span></a>
|
||||||
|
<span v-else>[<span v-if="item.list.type == 'black'">黑</span><span v-if="item.list.type == 'white'">白</span>名单:{{item.list.name}}</span>
|
||||||
|
|
||||||
|
<span v-if="item.policy.id > 0">
|
||||||
|
<span v-if="item.policy.server != null">
|
||||||
|
<a :href="'/servers/server/settings/waf/ipadmin/allowList?serverId=' + item.policy.server.id + '&firewallPolicyId=' + item.policy.id" v-if="item.list.type == 'white'">[服务:{{item.policy.server.name}}]</a>
|
||||||
|
<a :href="'/servers/server/settings/waf/ipadmin/denyList?serverId=' + item.policy.server.id + '&firewallPolicyId=' + item.policy.id" v-if="item.list.type == 'black'">[服务:{{item.policy.server.name}}]</a>
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
<a :href="'/servers/components/waf/ipadmin/lists?firewallPolicyId=' + item.policy.id + '&type=' + item.list.type">[策略:{{item.policy.name}}]</a>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -65,11 +82,11 @@ Vue.component("ip-list-table", {
|
|||||||
<span v-else class="disabled">-</span>
|
<span v-else class="disabled">-</span>
|
||||||
|
|
||||||
<div style="margin-top: 0.4em" v-if="item.sourceServer != null && item.sourceServer.id > 0">
|
<div style="margin-top: 0.4em" v-if="item.sourceServer != null && item.sourceServer.id > 0">
|
||||||
<a :href="'/servers/server?serverId=' + item.sourceServer.id" class="ui label tiny basic grey" target="_blank"><i class="icon clone outline"></i>{{item.sourceServer.name}}</a>
|
<a :href="'/servers/server?serverId=' + item.sourceServer.id" style="border: 0"><span class="small "><i class="icon clone outline"></i>{{item.sourceServer.name}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.sourcePolicy != null && item.sourcePolicy.id > 0" style="margin-top: 0.4em">
|
<div v-if="item.sourcePolicy != null && item.sourcePolicy.id > 0" style="margin-top: 0.4em">
|
||||||
<a :href="'/servers/components/waf/group?firewallPolicyId=' + item.sourcePolicy.id + '&type=inbound&groupId=' + item.sourceGroup.id" v-if="item.sourcePolicy.serverId == 0" class="ui label tiny basic grey" target="_blank"><i class="icon shield"></i>{{item.sourcePolicy.name}} » {{item.sourceGroup.name}} » {{item.sourceSet.name}}</a>
|
<a :href="'/servers/components/waf/group?firewallPolicyId=' + item.sourcePolicy.id + '&type=inbound&groupId=' + item.sourceGroup.id" v-if="item.sourcePolicy.serverId == 0"><span class="small "><i class="icon shield"></i>{{item.sourcePolicy.name}} » {{item.sourceGroup.name}} » {{item.sourceSet.name}}</span></a>
|
||||||
<a :href="'/servers/server/settings/waf/group?serverId=' + item.sourcePolicy.serverId + '&firewallPolicyId=' + item.sourcePolicy.id + '&type=inbound&groupId=' + item.sourceGroup.id" v-if="item.sourcePolicy.serverId > 0" class="ui label tiny basic grey" target="_blank"><i class="icon shield"></i> {{item.sourcePolicy.name}} » {{item.sourceGroup.name}} » {{item.sourceSet.name}}</a>
|
<a :href="'/servers/server/settings/waf/group?serverId=' + item.sourcePolicy.serverId + '&firewallPolicyId=' + item.sourcePolicy.id + '&type=inbound&groupId=' + item.sourceGroup.id" v-if="item.sourcePolicy.serverId > 0"><span class="small "><i class="icon shield"></i> {{item.sourcePolicy.name}} » {{item.sourceGroup.name}} » {{item.sourceSet.name}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<first-menu>
|
<first-menu>
|
||||||
<menu-item :href="'/servers/iplists?type=' + list.type">{{list.typeName}}</menu-item>
|
<menu-item :href="'/servers/iplists/lists?type=' + list.type">{{list.typeName}}</menu-item>
|
||||||
<span class="disabled item">|</span>
|
<span class="disabled item">|</span>
|
||||||
<menu-item :href="'/servers/iplists/list?listId=' + list.id" code="list">"{{list.name}}"详情</menu-item>
|
<menu-item :href="'/servers/iplists/list?listId=' + list.id" code="list">"{{list.name}}"详情</menu-item>
|
||||||
<menu-item :href="'/servers/iplists/items?listId=' + list.id" code="item">IP({{list.countItems}})</menu-item>
|
<menu-item :href="'/servers/iplists/items?listId=' + list.id" code="item">IP({{list.countItems}})</menu-item>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<first-menu>
|
<first-menu>
|
||||||
<menu-item href="/servers/iplists" :active="type == 'black'">黑名单</menu-item>
|
<menu-item href="/servers/iplists" code="index">所有IP</menu-item>
|
||||||
<menu-item href="/servers/iplists?type=white" :active="type == 'white'">白名单</menu-item>
|
<menu-item href="/servers/iplists/lists?type=black" :active="type == 'black'">公共黑名单</menu-item>
|
||||||
<span class="item disabled">|</span>
|
<menu-item href="/servers/iplists/lists?type=white" :active="type == 'white'">公共白名单</menu-item>
|
||||||
<menu-item @click.prevent="createList">[创建]</menu-item>
|
<span class="item disabled" v-if="type.length > 0">|</span>
|
||||||
<span class="item disabled">|</span>
|
<menu-item @click.prevent="createList" v-if="type.length > 0">[创建]</menu-item>
|
||||||
<span class="item"><tip-icon content="可以在WAF策略里直接引用这些公用名单。"></tip-icon></span>
|
<span class="item disabled" v-if="type.length > 0">|</span>
|
||||||
|
<span class="item" v-if="type.length > 0"><tip-icon content="可以在WAF策略里直接引用这些公用名单。"></tip-icon></span>
|
||||||
</first-menu>
|
</first-menu>
|
||||||
@@ -1,56 +1,22 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "menu"}
|
||||||
|
|
||||||
<tip-message-box code="iplist-public-tip">这里是公用的IP名单,可以在WAF策略里直接引用。</tip-message-box>
|
|
||||||
|
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
<form class="ui form" action="/servers/iplists">
|
<form class="ui form" action="/servers/iplists" method="get">
|
||||||
<input type="hidden" name="type" :value="type"/>
|
|
||||||
<div class="ui fields inline">
|
<div class="ui fields inline">
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" placeholder="名称..." name="keyword" v-model="keyword"/>
|
<input type="text" name="ip" placeholder="x.x.x.x" v-model="ip"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">搜索</button>
|
<button class="ui button" type="submit">搜索</button>
|
||||||
|
|
||||||
<a :href="'/servers/iplists?type=' + type" v-if="keyword.length > 0">[清除条件]</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="comment" v-if="lists.length == 0">暂时还没有公用IP名单。</p>
|
<div class="margin"></div>
|
||||||
|
|
||||||
<table class="ui table selectable celled" v-if="lists.length > 0">
|
<p class="comment" v-if="items.length == 0">暂时还没有IP。</p>
|
||||||
<thead>
|
|
||||||
<tr>
|
<ip-list-table v-if="items.length > 0" :v-items="items" @update-item="updateItem" @delete-item="deleteItem" :v-keyword="ip"></ip-list-table>
|
||||||
<th class="one wide center">ID</th>
|
|
||||||
<th class="three wide">名称</th>
|
|
||||||
<th class="two wide center">类型</th>
|
|
||||||
<th>备注</th>
|
|
||||||
<th class="two wide center">IP数量</th>
|
|
||||||
<th class="two op">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tr v-for="list in lists">
|
|
||||||
<td class="center">{{list.id}}</td>
|
|
||||||
<td>
|
|
||||||
<a :href="'/servers/iplists/list?listId=' + list.id"><keyword :v-word="keyword">{{list.name}}</keyword></a>
|
|
||||||
<div v-if="list.isGlobal" style="margin-top: 0.3em"><grey-label>全局</grey-label></div>
|
|
||||||
</td>
|
|
||||||
<td class="center">
|
|
||||||
<span v-if="list.type == 'black'">黑名单</span>
|
|
||||||
<span v-if="list.type == 'white'">白名单</span>
|
|
||||||
</td>
|
|
||||||
<td>{{list.description}}</td>
|
|
||||||
<td class="center">
|
|
||||||
<a :href="'/servers/iplists/items?listId=' + list.id" v-if="list.countItems > 0">{{list.countItems}}</a>
|
|
||||||
<span v-else class="disabled">0</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a :href="'/servers/iplists/list?listId=' + list.id">详情</a>
|
|
||||||
<a href="" @click.prevent="deleteList(list.id)">删除</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="page" v-html="page"></div>
|
<div class="page" v-html="page"></div>
|
||||||
@@ -1,27 +1,23 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.createList = function () {
|
this.updateItem = function (itemId) {
|
||||||
teaweb.popup(Tea.url(".createPopup", {type: this.type}), {
|
teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), {
|
||||||
height: "24em",
|
height: "26em",
|
||||||
callback: function (resp) {
|
callback: function () {
|
||||||
teaweb.success("保存成功", function () {
|
teaweb.success("保存成功", function () {
|
||||||
window.location = "/servers/iplists?type=" + resp.data.list.type
|
teaweb.reload()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deleteList = function (listId) {
|
this.deleteItem = function (itemId) {
|
||||||
let that = this
|
let that = this
|
||||||
teaweb.confirm("确定要删除此IP名单吗?", function () {
|
teaweb.confirm("确定要删除这个IP吗?", function () {
|
||||||
that.$post(".delete")
|
that.$post(".deleteIP")
|
||||||
.params({
|
.params({
|
||||||
listId: listId
|
"itemId": itemId
|
||||||
})
|
|
||||||
.success(function () {
|
|
||||||
teaweb.success("删除成功", function () {
|
|
||||||
teaweb.reload()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
.refresh()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
56
web/views/@default/servers/iplists/lists.html
Normal file
56
web/views/@default/servers/iplists/lists.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<tip-message-box code="iplist-public-tip">这里是公用的IP名单,可以在WAF策略里直接引用。</tip-message-box>
|
||||||
|
|
||||||
|
<div class="margin"></div>
|
||||||
|
<form class="ui form" action="/servers/iplists">
|
||||||
|
<input type="hidden" name="type" :value="type"/>
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" placeholder="名称..." name="keyword" v-model="keyword"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<button type="submit" class="ui button">搜索</button>
|
||||||
|
|
||||||
|
<a :href="'/servers/iplists?type=' + type" v-if="keyword.length > 0">[清除条件]</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p class="comment" v-if="lists.length == 0">暂时还没有公用IP名单。</p>
|
||||||
|
|
||||||
|
<table class="ui table selectable celled" v-if="lists.length > 0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="one wide center">ID</th>
|
||||||
|
<th class="three wide">名称</th>
|
||||||
|
<th class="two wide center">类型</th>
|
||||||
|
<th>备注</th>
|
||||||
|
<th class="two wide center">IP数量</th>
|
||||||
|
<th class="two op">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr v-for="list in lists">
|
||||||
|
<td class="center">{{list.id}}</td>
|
||||||
|
<td>
|
||||||
|
<a :href="'/servers/iplists/list?listId=' + list.id"><keyword :v-word="keyword">{{list.name}}</keyword></a>
|
||||||
|
<div v-if="list.isGlobal" style="margin-top: 0.3em"><grey-label>全局</grey-label></div>
|
||||||
|
</td>
|
||||||
|
<td class="center">
|
||||||
|
<span v-if="list.type == 'black'">黑名单</span>
|
||||||
|
<span v-if="list.type == 'white'">白名单</span>
|
||||||
|
</td>
|
||||||
|
<td>{{list.description}}</td>
|
||||||
|
<td class="center">
|
||||||
|
<a :href="'/servers/iplists/items?listId=' + list.id" v-if="list.countItems > 0">{{list.countItems}}</a>
|
||||||
|
<span v-else class="disabled">0</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a :href="'/servers/iplists/list?listId=' + list.id">详情</a>
|
||||||
|
<a href="" @click.prevent="deleteList(list.id)">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="page" v-html="page"></div>
|
||||||
27
web/views/@default/servers/iplists/lists.js
Normal file
27
web/views/@default/servers/iplists/lists.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.createList = function () {
|
||||||
|
teaweb.popup(Tea.url(".createPopup", {type: this.type}), {
|
||||||
|
height: "24em",
|
||||||
|
callback: function (resp) {
|
||||||
|
teaweb.success("保存成功", function () {
|
||||||
|
window.location = "/servers/iplists/lists?type=" + resp.data.list.type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.deleteList = function (listId) {
|
||||||
|
let that = this
|
||||||
|
teaweb.confirm("确定要删除此IP名单吗?", function () {
|
||||||
|
that.$post(".delete")
|
||||||
|
.params({
|
||||||
|
listId: listId
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
teaweb.success("删除成功", function () {
|
||||||
|
teaweb.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user