多处增加是否独立配置选项

This commit is contained in:
刘祥超
2020-09-23 18:43:38 +08:00
parent 6d6fb22d78
commit 94cdd7abb8
50 changed files with 615 additions and 267 deletions

View File

@@ -1,5 +1,5 @@
Vue.component("http-access-log-config-box", {
props: ["v-access-log-config", "v-fields", "v-default-field-codes", "v-access-log-policies"],
props: ["v-access-log-config", "v-fields", "v-default-field-codes", "v-access-log-policies", "v-is-location"],
data: function () {
let that = this
@@ -10,6 +10,7 @@ Vue.component("http-access-log-config-box", {
}, 100)
let accessLog = {
isPrior: false,
isOn: true,
fields: [],
status1: true,
@@ -59,7 +60,8 @@ Vue.component("http-access-log-config-box", {
template: `<div>
<input type="hidden" name="accessLogJSON" :value="JSON.stringify(accessLog)"/>
<table class="ui table definition selectable">
<tbody>
<prior-checkbox :v-config="accessLog" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || accessLog.isPrior">
<tr>
<td class="title">是否开启访问日志存储</td>
<td>
@@ -71,7 +73,7 @@ Vue.component("http-access-log-config-box", {
</td>
</tr>
</tbody>
<tbody v-show="accessLog.isOn">
<tbody v-show="(!vIsLocation || accessLog.isPrior) && accessLog.isOn">
<tr>
<td>要存储的访问日志字段</td>
<td>

View File

@@ -1,9 +1,10 @@
Vue.component("http-cache-config-box", {
props: ["v-cache-config", "v-cache-policies"],
props: ["v-cache-config", "v-cache-policies", "v-is-location"],
data: function () {
let cacheConfig = this.vCacheConfig
if (cacheConfig == null) {
cacheConfig = {
isPrior: false,
isOn: false,
cachePolicyId: 0
}
@@ -20,30 +21,31 @@ Vue.component("http-cache-config-box", {
template: `<div>
<input type="hidden" name="cacheJSON" :value="JSON.stringify(cacheConfig)"/>
<table class="ui table definition selectable">
<tbody>
<tr>
<td class="title">是否开启缓存</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="cacheConfig.isOn"/>
<label></label>
</div>
</td>
</tr>
<prior-checkbox :v-config="cacheConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || cacheConfig.isPrior">
<tr>
<td class="title">是否开启缓存</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="cacheConfig.isOn"/>
<label></label>
</div>
</td>
</tr>
</tbody>
<tbody v-show="cacheConfig.isOn">
<tr>
<td class="title">选择缓存策略</td>
<td>
<span class="disabled" v-if="vCachePolicies.length == 0">暂时没有可选的缓存策略</span>
<div v-if="vCachePolicies.length > 0">
<select class="ui dropdown auto-width" v-model="cacheConfig.cachePolicyId" @change="changePolicyId">
<option value="0">[不使用缓存策略]</option>
<option v-for="policy in vCachePolicies" :value="policy.id">{{policy.name}}</option>
</select>
</div>
</td>
</tr>
<tbody v-show="(!vIsLocation || cacheConfig.isPrior) && cacheConfig.isOn">
<tr>
<td class="title">选择缓存策略</td>
<td>
<span class="disabled" v-if="vCachePolicies.length == 0">暂时没有可选的缓存策略</span>
<div v-if="vCachePolicies.length > 0">
<select class="ui dropdown auto-width" v-model="cacheConfig.cachePolicyId" @change="changePolicyId">
<option value="0">[不使用缓存策略]</option>
<option v-for="policy in vCachePolicies" :value="policy.id">{{policy.name}}</option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
<div class="margin"></div>

View File

@@ -1,27 +1,46 @@
Vue.component("http-charsets-box", {
props: ["v-usual-charsets", "v-all-charsets", "v-charset"],
props: ["v-usual-charsets", "v-all-charsets", "v-charset-config", "v-is-location"],
data: function () {
let charset = this.vCharset
if (charset == null) {
charset = ""
let charsetConfig = this.vCharsetConfig
if (charsetConfig == null) {
charsetConfig = {
isPrior: false,
isOn: false,
charset: ""
}
}
return {
charset: charset
charsetConfig: charsetConfig
}
},
template: `<div>
<input type="hidden" name="charsetJSON" :value="JSON.stringify(charsetConfig)"/>
<table class="ui table definition selectable">
<tr>
<td class="title">选择字符编码</td>
<td><select class="ui dropdown" style="width:20em" name="charset" v-model="charset">
<option value="">[未选择]</option>
<optgroup label="常用字符编码"></optgroup>
<option v-for="charset in vUsualCharsets" :value="charset.charset">{{charset.charset}}{{charset.name}}</option>
<optgroup label="全部字符编码"></optgroup>
<option v-for="charset in vAllCharsets" :value="charset.charset">{{charset.charset}}{{charset.name}}</option>
</select>
</td>
</tr>
<prior-checkbox :v-config="charsetConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || charsetConfig.isPrior">
<tr>
<td class="title">是否启用</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="charsetConfig.isOn"/>
<label></label>
</div>
</td>
</tr>
</tbody>
<tbody v-show="(!vIsLocation || charsetConfig.isPrior) && charsetConfig.isOn">
<tr>
<td class="title">选择字符编码</td>
<td><select class="ui dropdown" style="width:20em" name="charset" v-model="charsetConfig.charset">
<option value="">[未选择]</option>
<optgroup label="常用字符编码"></optgroup>
<option v-for="charset in vUsualCharsets" :value="charset.charset">{{charset.charset}}{{charset.name}}</option>
<optgroup label="全部字符编码"></optgroup>
<option v-for="charset in vAllCharsets" :value="charset.charset">{{charset.charset}}{{charset.name}}</option>
</select>
</td>
</tr>
</tbody>
</table>
<div class="margin"></div>
</div>`

View File

@@ -1,9 +1,10 @@
Vue.component("http-firewall-config-box", {
props: ["v-firewall-config", "v-firewall-policies"],
props: ["v-firewall-config", "v-firewall-policies", "v-is-location"],
data: function () {
let firewall = this.vFirewallConfig
if (firewall == null) {
firewall = {
isPrior: false,
isOn: false,
firewallPolicyId: 0
}
@@ -21,7 +22,8 @@ Vue.component("http-firewall-config-box", {
template: `<div>
<input type="hidden" name="firewallJSON" :value="JSON.stringify(firewall)"/>
<table class="ui table selectable definition">
<tbody>
<prior-checkbox :v-config="firewall" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || firewall.isPrior">
<tr>
<td class="title">是否启用Web防火墙</td>
<td>
@@ -32,7 +34,7 @@ Vue.component("http-firewall-config-box", {
</td>
</tr>
</tbody>
<tbody v-show="firewall.isOn">
<tbody v-show="(!vIsLocation || firewall.isPrior) && firewall.isOn">
<tr>
<td>选择Web防火墙策略</td>
<td>

View File

@@ -1,5 +1,5 @@
Vue.component("http-gzip-box", {
props: ["v-gzip-config"],
props: ["v-gzip-config", "v-gzip-ref", "v-is-location"],
data: function () {
let gzip = this.vGzipConfig
if (gzip == null) {
@@ -16,31 +16,35 @@ Vue.component("http-gzip-box", {
}
},
template: `<div>
<input type="hidden" name="gzipRefJSON" :value="JSON.stringify(vGzipRef)"/>
<table class="ui table selectable definition">
<tr>
<td class="title">压缩级别</td>
<td>
<select class="dropdown auto-width" name="level" v-model="gzip.level">
<option value="0">不压缩</option>
<option v-for="i in 9" :value="i">{{i}}</option>
</select>
<p class="comment">级别越高,压缩比例越大。</p>
</td>
</tr>
<tr>
<td>Gzip内容最小长度</td>
<td>
<size-capacity-box :v-name="'minLength'" :v-value="gzip.minLength" :v-unit="'kb'"></size-capacity-box>
<p class="comment">0表示不限制内容长度从文件尺寸或Content-Length中获取。</p>
</td>
</tr>
<tr>
<td>Gzip内容最大长度</td>
<td>
<size-capacity-box :v-name="'maxLength'" :v-value="gzip.maxLength" :v-unit="'mb'"></size-capacity-box>
<p class="comment">0表示不限制内容长度从文件尺寸或Content-Length中获取。</p>
</td>
</tr>
<prior-checkbox :v-config="vGzipRef" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || vGzipRef.isPrior">
<tr>
<td class="title">压缩级别</td>
<td>
<select class="dropdown auto-width" name="level" v-model="gzip.level">
<option value="0">不压缩</option>
<option v-for="i in 9" :value="i">{{i}}</option>
</select>
<p class="comment">级别越高,压缩比例越大。</p>
</td>
</tr>
<tr>
<td>Gzip内容最小长度</td>
<td>
<size-capacity-box :v-name="'minLength'" :v-value="gzip.minLength" :v-unit="'kb'"></size-capacity-box>
<p class="comment">0表示不限制内容长度从文件尺寸或Content-Length中获取。</p>
</td>
</tr>
<tr>
<td>Gzip内容最大长度</td>
<td>
<size-capacity-box :v-name="'maxLength'" :v-value="gzip.maxLength" :v-unit="'mb'"></size-capacity-box>
<p class="comment">0表示不限制内容长度从文件尺寸或Content-Length中获取。</p>
</td>
</tr>
</tbody>
</table>
</div>`
})

View File

@@ -1,5 +1,5 @@
Vue.component("http-header-policy-box", {
props: ["v-request-header-policy", "v-response-header-policy", "v-params"],
props: ["v-request-header-policy", "v-request-header-ref", "v-response-header-policy", "v-response-header-ref", "v-params", "v-is-location"],
data: function () {
let type = "request"
let hash = window.location.hash
@@ -7,6 +7,25 @@ Vue.component("http-header-policy-box", {
type = "response"
}
// ref
let requestHeaderRef = this.vRequestHeaderRef
if (requestHeaderRef == null) {
requestHeaderRef = {
isPrior: false,
isOn: true,
headerPolicyId: 0
}
}
let responseHeaderRef = this.vResponseHeaderRef
if (responseHeaderRef == null) {
responseHeaderRef = {
isPrior: false,
isOn: true,
headerPolicyId: 0
}
}
// 请求相关
let requestSettingHeaders = []
let requestDeletingHeaders = []
@@ -37,6 +56,9 @@ Vue.component("http-header-policy-box", {
return {
type: type,
typeName: (type == "request") ? "请求" : "响应",
requestHeaderRef: requestHeaderRef,
responseHeaderRef: responseHeaderRef,
requestSettingHeaders: requestSettingHeaders,
requestDeletingHeaders: requestDeletingHeaders,
responseSettingHeaders: responseSettingHeaders,
@@ -47,6 +69,7 @@ Vue.component("http-header-policy-box", {
selectType: function (type) {
this.type = type
window.location.hash = "#" + type
window.location.reload()
},
addSettingHeader: function (policyId) {
teaweb.popup("/servers/server/settings/headers/createSetPopup?" + this.vParams + "&headerPolicyId=" + policyId, {
@@ -101,9 +124,19 @@ Vue.component("http-header-policy-box", {
<div class="margin"></div>
<input type="hidden" name="type" :value="type"/>
<!-- 请求 -->
<div v-if="type == 'request'">
<h3>设置Header <a href="" @click.prevent="addSettingHeader(vRequestHeaderPolicy.id)">[添加新Header]</a></h3>
<div v-if="vIsLocation && type == 'request'">
<input type="hidden" name="requestHeaderJSON" :value="JSON.stringify(requestHeaderRef)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="requestHeaderRef"></prior-checkbox>
</table>
<submit-btn></submit-btn>
</div>
<div v-if="(!vIsLocation || requestHeaderRef.isPrior) && type == 'request'">
<h3>设置请求Header <a href="" @click.prevent="addSettingHeader(vRequestHeaderPolicy.id)">[添加新Header]</a></h3>
<p class="comment" v-if="requestSettingHeaders.length == 0">暂时还没有Header。</p>
<table class="ui table selectable" v-if="requestSettingHeaders.length > 0">
<thead>
@@ -120,7 +153,7 @@ Vue.component("http-header-policy-box", {
</tr>
</table>
<h3>删除Header</h3>
<h3>删除请求Header</h3>
<p class="comment">这里可以设置需要从请求中删除的Header。</p>
<table class="ui table definition selectable">
@@ -136,8 +169,16 @@ Vue.component("http-header-policy-box", {
</div>
<!-- 响应 -->
<div v-if="vIsLocation && type == 'response'">
<input type="hidden" name="responseHeaderJSON" :value="JSON.stringify(responseHeaderRef)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="responseHeaderRef"></prior-checkbox>
</table>
<submit-btn></submit-btn>
</div>
<div v-if="type == 'response'">
<h3>设置Header <a href="" @click.prevent="addSettingHeader(vResponseHeaderPolicy.id)">[添加新Header]</a></h3>
<h3>设置响应Header <a href="" @click.prevent="addSettingHeader(vResponseHeaderPolicy.id)">[添加新Header]</a></h3>
<p class="comment" v-if="responseSettingHeaders.length == 0">暂时还没有Header。</p>
<table class="ui table selectable" v-if="responseSettingHeaders.length > 0">
<thead>
@@ -154,7 +195,7 @@ Vue.component("http-header-policy-box", {
</tr>
</table>
<h3>删除Header</h3>
<h3>删除响应Header</h3>
<p class="comment">这里可以设置需要从响应中删除的Header。</p>
<table class="ui table definition selectable">
@@ -168,6 +209,6 @@ Vue.component("http-header-policy-box", {
</td>
</table>
</div>
<div class="margin"></div>
</div>`
})

View File

@@ -0,0 +1,45 @@
Vue.component("http-redirect-to-https-box", {
props: ["v-redirect-to-https-config", "v-is-location"],
data: function () {
let redirectToHttpsConfig = this.vRedirectToHttpsConfig
if (redirectToHttpsConfig == null) {
redirectToHttpsConfig = {
isPrior: false,
isOn: false
}
}
return {
redirectToHttpsConfig: redirectToHttpsConfig
}
},
template: `<div>
<input type="hidden" name="redirectToHTTPSJSON" :value="JSON.stringify(redirectToHttpsConfig)"/>
<!-- Location -->
<table class="ui table selectable definition" v-if="vIsLocation">
<prior-checkbox :v-config="redirectToHttpsConfig"></prior-checkbox>
<tbody v-show="redirectToHttpsConfig.isPrior">
<tr>
<td class="title">自动跳转到HTTPS</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="redirectToHttpsConfig.isOn"/>
<label></label>
</div>
<p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上。</p>
</td>
</tr>
</tbody>
</table>
<!-- 非Location -->
<div v-if="!vIsLocation">
<div class="ui checkbox">
<input type="checkbox" v-model="redirectToHttpsConfig.isOn"/>
<label></label>
</div>
<p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上。</p>
</div>
<div class="margin"></div>
</div>`
})

View File

@@ -1,9 +1,10 @@
Vue.component("http-stat-config-box", {
props: ["v-stat-config"],
props: ["v-stat-config", "v-is-location"],
data: function () {
let stat = this.vStatConfig
if (stat == null) {
stat = {
isPrior: false,
isOn: true
}
}
@@ -14,15 +15,18 @@ Vue.component("http-stat-config-box", {
template: `<div>
<input type="hidden" name="statJSON" :value="JSON.stringify(stat)"/>
<table class="ui table definition selectable">
<tr>
<td class="title">是否开启统计</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="stat.isOn"/>
<label></label>
</div>
</td>
</tr>
<prior-checkbox :v-config="stat" v-if="vIsLocation" ></prior-checkbox>
<tbody v-show="!vIsLocation || stat.isPrior">
<tr>
<td class="title">是否开启统计</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="stat.isOn"/>
<label></label>
</div>
</td>
</tr>
</tbody>
</table>
<div class="margin"></div>
</div>`

View File

@@ -0,0 +1,25 @@
Vue.component("prior-checkbox", {
props: ["v-config"],
data: function () {
return {
isPrior: this.vConfig.isPrior
}
},
watch: {
isPrior: function (v) {
this.vConfig.isPrior = v
}
},
template: `<tbody>
<tr :class="{active:isPrior}">
<td class="title">打开独立配置</td>
<td>
<div class="ui toggle checkbox">
<input type="checkbox" v-model="isPrior"/>
<label class="red"></label>
</div>
<p class="comment"><strong v-if="isPrior">[已打开]</strong> 打开后可以覆盖父级配置。</p>
</td>
</tr>
</tbody>`
})

View File

@@ -0,0 +1,34 @@
Vue.component("reverse-proxy-box", {
props: ["v-reverse-proxy-ref", "v-is-location"],
data: function () {
let reverseProxyRef = this.vReverseProxyRef
if (reverseProxyRef == null) {
reverseProxyRef = {
isPrior: false,
isOn: false,
reverseProxyId: 0
}
}
return {
reverseProxyRef: reverseProxyRef
}
},
template: `<div>
<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
<table class="ui table selectable definition">
<prior-checkbox :v-config="reverseProxyRef" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || reverseProxyRef.isPrior">
<tr>
<td class="title">是否启用反向代理</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="reverseProxyRef.isOn"/>
<label></label>
</div>
</td>
</tr>
</tbody>
</table>
<div class="margin"></div>
</div>`
})