mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
集群可以设置默认的WAF策略、缓存策略
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
Vue.component("http-cache-config-box", {
|
||||
props: ["v-cache-config", "v-cache-policies", "v-is-location"],
|
||||
props: ["v-cache-config", "v-is-location", "v-cache-policy"],
|
||||
data: function () {
|
||||
let cacheConfig = this.vCacheConfig
|
||||
if (cacheConfig == null) {
|
||||
@@ -86,6 +86,15 @@ Vue.component("http-cache-config-box", {
|
||||
<table class="ui table definition selectable">
|
||||
<prior-checkbox :v-config="cacheConfig" v-if="vIsLocation"></prior-checkbox>
|
||||
<tbody v-show="!vIsLocation || cacheConfig.isPrior">
|
||||
<tr>
|
||||
<td>缓存策略</td>
|
||||
<td>
|
||||
<div v-if="vCachePolicy != null">{{vCachePolicy.name}}
|
||||
<p class="comment">使用当前服务所在集群的设置。</p>
|
||||
</div>
|
||||
<span v-else class="red">当前集群没有设置缓存策略,当前配置无法生效。</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">是否开启缓存</td>
|
||||
<td>
|
||||
@@ -102,13 +111,11 @@ Vue.component("http-cache-config-box", {
|
||||
<table class="ui table selectable" v-show="cacheConfig.cacheRefs.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>缓存策略</th>
|
||||
<th>条件</th>
|
||||
<th>缓存时间</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
<tr v-for="(cacheRef, index) in cacheConfig.cacheRefs">
|
||||
<td><a :href="'/servers/components/cache/policy?cachePolicyId=' + cacheRef.cachePolicyId">{{cacheRef.cachePolicy.name}}</a></td>
|
||||
<td>
|
||||
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
Vue.component("http-cache-policy-selector", {
|
||||
props: ["v-cache-policy"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/servers/components/cache/count")
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.count = resp.data.count
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
let cachePolicy = this.vCachePolicy
|
||||
return {
|
||||
count: 0,
|
||||
cachePolicy: cachePolicy
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
remove: function () {
|
||||
this.cachePolicy = null
|
||||
},
|
||||
select: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/components/cache/selectPopup", {
|
||||
callback: function (resp) {
|
||||
that.cachePolicy = resp.data.cachePolicy
|
||||
}
|
||||
})
|
||||
},
|
||||
create: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/components/cache/createPopup", {
|
||||
height: "26em",
|
||||
callback: function (resp) {
|
||||
that.cachePolicy = resp.data.cachePolicy
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<div v-if="cachePolicy != null" class="ui label basic">
|
||||
<input type="hidden" name="cachePolicyId" :value="cachePolicy.id"/>
|
||||
{{cachePolicy.name}} <a :href="'/servers/components/cache/policy?cachePolicyId=' + cachePolicy.id" target="_blank"><i class="icon pencil small"></i></a> <a href="" @click.prevent="remove()"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div v-if="cachePolicy == null">
|
||||
<span v-if="count > 0"><a href="" @click.prevent="select">[选择已有策略]</a> </span><a href="" @click.prevent="create">[创建新策略]</a>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
@@ -43,7 +43,7 @@ Vue.component("http-cache-ref-box", {
|
||||
},
|
||||
template: `<tbody>
|
||||
<tr>
|
||||
<td>匹配条件 *</td>
|
||||
<td class="title">匹配条件 *</td>
|
||||
<td>
|
||||
<http-request-conds-box :v-conds="ref.conds" @change="changeConds"></http-request-conds-box>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("http-firewall-config-box", {
|
||||
props: ["v-firewall-config", "v-firewall-policies", "v-is-location"],
|
||||
props: ["v-firewall-config", "v-is-location", "v-firewall-policy"],
|
||||
data: function () {
|
||||
let firewall = this.vFirewallConfig
|
||||
if (firewall == null) {
|
||||
@@ -11,22 +11,7 @@ Vue.component("http-firewall-config-box", {
|
||||
}
|
||||
|
||||
return {
|
||||
firewall: firewall,
|
||||
selectedPolicy: this.lookupPolicy(firewall.firewallPolicyId)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changePolicyId: function () {
|
||||
this.firewall.firewallPolicyId = parseInt(this.firewall.firewallPolicyId)
|
||||
this.selectedPolicy = this.lookupPolicy(this.firewall.firewallPolicyId)
|
||||
},
|
||||
lookupPolicy: function (policyId) {
|
||||
if (policyId <= 0) {
|
||||
return null
|
||||
}
|
||||
return this.vFirewallPolicies.$find(function (k, v) {
|
||||
return v.id == policyId
|
||||
})
|
||||
firewall: firewall
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
@@ -34,6 +19,15 @@ Vue.component("http-firewall-config-box", {
|
||||
<table class="ui table selectable definition">
|
||||
<prior-checkbox :v-config="firewall" v-if="vIsLocation"></prior-checkbox>
|
||||
<tbody v-show="!vIsLocation || firewall.isPrior">
|
||||
<tr>
|
||||
<td>WAF策略</td>
|
||||
<td>
|
||||
<div v-if="vFirewallPolicy != null">{{vFirewallPolicy.name}}
|
||||
<p class="comment">使用当前服务所在集群的设置。</p>
|
||||
</div>
|
||||
<span v-else class="red">当前集群没有设置WAF策略,当前配置无法生效。</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">是否启用Web防火墙</td>
|
||||
<td>
|
||||
@@ -44,21 +38,6 @@ Vue.component("http-firewall-config-box", {
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody v-show="(!vIsLocation || firewall.isPrior) && firewall.isOn">
|
||||
<tr>
|
||||
<td>选择Web防火墙策略</td>
|
||||
<td>
|
||||
<span class="disabled" v-if="vFirewallPolicies.length == 0">暂时还没有防火墙策略</span>
|
||||
<div v-if="vFirewallPolicies.length > 0">
|
||||
<select class="ui dropdown auto-width" v-model="firewall.firewallPolicyId" @change="changePolicyId">
|
||||
<option value="0">[请选择]</option>
|
||||
<option v-for="policy in vFirewallPolicies" :value="policy.id">{{policy.name}}</option>
|
||||
</select>
|
||||
<p class="comment" v-if="selectedPolicy != null"><span v-if="!selectedPolicy.isOn" class="red">[正在停用的策略]</span>{{selectedPolicy.description}} <a :href="'/servers/components/waf/policy?firewallPolicyId=' + selectedPolicy.id">详情»</a> </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="margin"></div>
|
||||
</div>`
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
Vue.component("http-firewall-policy-selector", {
|
||||
props: ["v-http-firewall-policy"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/servers/components/waf/count")
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.count = resp.data.count
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
let firewallPolicy = this.vHttpFirewallPolicy
|
||||
return {
|
||||
count: 0,
|
||||
firewallPolicy: firewallPolicy
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
remove: function () {
|
||||
this.firewallPolicy = null
|
||||
},
|
||||
select: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/components/waf/selectPopup", {
|
||||
callback: function (resp) {
|
||||
that.firewallPolicy = resp.data.firewallPolicy
|
||||
}
|
||||
})
|
||||
},
|
||||
create: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/components/waf/createPopup", {
|
||||
height: "26em",
|
||||
callback: function (resp) {
|
||||
that.firewallPolicy = resp.data.firewallPolicy
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<div v-if="firewallPolicy != null" class="ui label basic">
|
||||
<input type="hidden" name="httpFirewallPolicyId" :value="firewallPolicy.id"/>
|
||||
{{firewallPolicy.name}} <a :href="'/servers/components/waf/policy?firewallPolicyId=' + firewallPolicy.id" target="_blank"><i class="icon pencil small"></i></a> <a href="" @click.prevent="remove()"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div v-if="firewallPolicy == null">
|
||||
<span v-if="count > 0"><a href="" @click.prevent="select">[选择已有策略]</a> </span><a href="" @click.prevent="create">[创建新策略]</a>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
Reference in New Issue
Block a user