集群可以设置默认的WAF策略、缓存策略

This commit is contained in:
GoEdgeLab
2020-12-17 15:50:44 +08:00
parent ee549b945d
commit 41ac159e23
100 changed files with 1172 additions and 488 deletions

View File

@@ -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>

View File

@@ -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}} &nbsp; <a :href="'/servers/components/cache/policy?cachePolicyId=' + cachePolicy.id" target="_blank"><i class="icon pencil small"></i></a>&nbsp; <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> &nbsp; &nbsp; </span><a href="" @click.prevent="create">[创建新策略]</a>
</div>
</div>`
})

View File

@@ -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>

View File

@@ -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}} &nbsp; <a :href="'/servers/components/waf/policy?firewallPolicyId=' + selectedPolicy.id">详情&raquo;</a> </p>
</div>
</td>
</tr>
</tbody>
</table>
<div class="margin"></div>
</div>`

View File

@@ -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}} &nbsp; <a :href="'/servers/components/waf/policy?firewallPolicyId=' + firewallPolicy.id" target="_blank"><i class="icon pencil small"></i></a>&nbsp; <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> &nbsp; &nbsp; </span><a href="" @click.prevent="create">[创建新策略]</a>
</div>
</div>`
})