支持更多的分组全局设置功能

This commit is contained in:
刘祥超
2021-10-07 16:47:14 +08:00
parent 870f1aaaec
commit 0b5a27e674
126 changed files with 3969 additions and 220 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-is-location"],
props: ["v-access-log-config", "v-fields", "v-default-field-codes", "v-is-location", "v-is-group"],
data: function () {
let that = this
@@ -47,9 +47,9 @@ Vue.component("http-access-log-config-box", {
},
template: `<div>
<input type="hidden" name="accessLogJSON" :value="JSON.stringify(accessLog)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="accessLog" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || accessLog.isPrior">
<table class="ui table definition selectable" :class="{'opacity-mask': this.accessLog.firewallOnly}">
<prior-checkbox :v-config="accessLog" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || accessLog.isPrior">
<tr>
<td class="title">是否开启访问日志存储</td>
<td>
@@ -61,7 +61,7 @@ Vue.component("http-access-log-config-box", {
</td>
</tr>
</tbody>
<tbody v-show="(!vIsLocation || accessLog.isPrior) && accessLog.isOn">
<tbody v-show="((!vIsLocation && !vIsGroup) || accessLog.isPrior) && accessLog.isOn">
<tr>
<td>要存储的访问日志字段</td>
<td>
@@ -99,7 +99,7 @@ Vue.component("http-access-log-config-box", {
</tbody>
</table>
<div v-show="(!vIsLocation || accessLog.isPrior) && accessLog.isOn">
<div v-show="((!vIsLocation && !vIsGroup) || accessLog.isPrior) && accessLog.isOn">
<h4>WAF相关</h4>
<table class="ui table definition selectable">
<tr>

View File

@@ -1,5 +1,5 @@
Vue.component("http-cache-config-box", {
props: ["v-cache-config", "v-is-location", "v-cache-policy"],
props: ["v-cache-config", "v-is-location", "v-is-group", "v-cache-policy"],
data: function () {
let cacheConfig = this.vCacheConfig
if (cacheConfig == null) {
@@ -16,15 +16,15 @@ Vue.component("http-cache-config-box", {
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.cacheConfig.isPrior) && this.cacheConfig.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.cacheConfig.isPrior) && this.cacheConfig.isOn
}
},
template: `<div>
<input type="hidden" name="cacheJSON" :value="JSON.stringify(cacheConfig)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="cacheConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || cacheConfig.isPrior">
<tr>
<prior-checkbox :v-config="cacheConfig" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || cacheConfig.isPrior">
<tr v-show="!vIsGroup">
<td>缓存策略</td>
<td>
<div v-if="vCachePolicy != null">{{vCachePolicy.name}} <link-icon :href="'/servers/components/cache/policy?cachePolicyId=' + vCachePolicy.id"></link-icon>

View File

@@ -1,5 +1,5 @@
Vue.component("http-charsets-box", {
props: ["v-usual-charsets", "v-all-charsets", "v-charset-config", "v-is-location"],
props: ["v-usual-charsets", "v-all-charsets", "v-charset-config", "v-is-location", "v-is-group"],
data: function () {
let charsetConfig = this.vCharsetConfig
if (charsetConfig == null) {
@@ -23,8 +23,8 @@ Vue.component("http-charsets-box", {
template: `<div>
<input type="hidden" name="charsetJSON" :value="JSON.stringify(charsetConfig)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="charsetConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || charsetConfig.isPrior">
<prior-checkbox :v-config="charsetConfig" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || charsetConfig.isPrior">
<tr>
<td class="title">是否启用</td>
<td>
@@ -35,7 +35,7 @@ Vue.component("http-charsets-box", {
</td>
</tr>
</tbody>
<tbody v-show="(!vIsLocation || charsetConfig.isPrior) && charsetConfig.isOn">
<tbody v-show="((!vIsLocation && !vIsGroup) || charsetConfig.isPrior) && charsetConfig.isOn">
<tr>
<td class="title">选择字符编码</td>
<td><select class="ui dropdown" style="width:20em" name="charset" v-model="charsetConfig.charset">
@@ -48,8 +48,8 @@ Vue.component("http-charsets-box", {
</td>
</tr>
</tbody>
<more-options-tbody @change="changeAdvancedVisible" v-if="(!vIsLocation || charsetConfig.isPrior) && charsetConfig.isOn"></more-options-tbody>
<tbody v-show="(!vIsLocation || charsetConfig.isPrior) && charsetConfig.isOn && advancedVisible">
<more-options-tbody @change="changeAdvancedVisible" v-if="((!vIsLocation && !vIsGroup) || charsetConfig.isPrior) && charsetConfig.isOn"></more-options-tbody>
<tbody v-show="((!vIsLocation && !vIsGroup) || charsetConfig.isPrior) && charsetConfig.isOn && advancedVisible">
<tr>
<td>字符编码是否大写</td>
<td>

View File

@@ -1,6 +1,6 @@
// 压缩配置
Vue.component("http-compression-config-box", {
props: ["v-compression-config", "v-is-location"],
props: ["v-compression-config", "v-is-location", "v-is-group"],
mounted: function () {
let that = this
sortLoad(function () {
@@ -92,7 +92,7 @@ Vue.component("http-compression-config-box", {
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.config.isPrior) && this.config.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
},
changeExtensions: function (values) {
values.forEach(function (v, k) {
@@ -144,8 +144,8 @@ Vue.component("http-compression-config-box", {
template: `<div>
<input type="hidden" name="compressionJSON" :value="JSON.stringify(config)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="config" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || config.isPrior">
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || config.isPrior">
<tr>
<td class="title">是否启用</td>
<td>

View File

@@ -1,5 +1,5 @@
Vue.component("http-firewall-config-box", {
props: ["v-firewall-config", "v-is-location", "v-firewall-policy"],
props: ["v-firewall-config", "v-is-location", "v-is-group", "v-firewall-policy"],
data: function () {
let firewall = this.vFirewallConfig
if (firewall == null) {
@@ -17,12 +17,12 @@ Vue.component("http-firewall-config-box", {
template: `<div>
<input type="hidden" name="firewallJSON" :value="JSON.stringify(firewall)"/>
<table class="ui table selectable definition">
<prior-checkbox :v-config="firewall" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || firewall.isPrior">
<tr>
<prior-checkbox :v-config="firewall" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || firewall.isPrior">
<tr v-show="!vIsGroup">
<td>WAF策略</td>
<td>
<div v-if="vFirewallPolicy != null">{{vFirewallPolicy.name}} <span v-if="vFirewallPolicy.modeInfo != null">&nbsp; <span :class="{green: vFirewallPolicy.modeInfo.code == 'defend', blue: vFirewallPolicy.modeInfo.code == 'observe', grey: vFirewallPolicy.modeInfo.code == 'pass'}">[{{vFirewallPolicy.modeInfo.name}}]</span>&nbsp;</span> <link-icon :href="'/servers/components/waf/policy?firewallPolicyId=' + vFirewallPolicy.id"></link-icon>
<div v-if="vFirewallPolicy != null">{{vFirewallPolicy.name}} <span v-if="vFirewallPolicy.modeInfo != null">&nbsp; <span :class="{green: vFirewallPolicy.modeInfo.code == 'defend', blue: vFirewallPolicy.modeInfo.code == 'observe', grey: vFirewallPolicy.modeInfo.code == 'bypass'}">[{{vFirewallPolicy.modeInfo.name}}]</span>&nbsp;</span> <link-icon :href="'/servers/components/waf/policy?firewallPolicyId=' + vFirewallPolicy.id"></link-icon>
<p class="comment">使用当前服务所在集群的设置。</p>
</div>
<span v-else class="red">当前集群没有设置WAF策略当前配置无法生效。</span>

View File

@@ -1,5 +1,5 @@
Vue.component("http-header-policy-box", {
props: ["v-request-header-policy", "v-request-header-ref", "v-response-header-policy", "v-response-header-ref", "v-params", "v-is-location"],
props: ["v-request-header-policy", "v-request-header-ref", "v-response-header-policy", "v-response-header-ref", "v-params", "v-is-location", "v-is-group", "v-has-group-request-config", "v-has-group-response-config", "v-group-setting-url"],
data: function () {
let type = "request"
let hash = window.location.hash
@@ -127,7 +127,7 @@ Vue.component("http-header-policy-box", {
<input type="hidden" name="type" :value="type"/>
<!-- 请求 -->
<div v-if="vIsLocation && type == 'request'">
<div v-if="(vIsLocation || vIsGroup) && type == 'request'">
<input type="hidden" name="requestHeaderJSON" :value="JSON.stringify(requestHeaderRef)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="requestHeaderRef"></prior-checkbox>
@@ -135,41 +135,47 @@ Vue.component("http-header-policy-box", {
<submit-btn></submit-btn>
</div>
<div v-if="(!vIsLocation || requestHeaderRef.isPrior) && type == 'request'">
<div v-if="((!vIsLocation && !vIsGroup) || requestHeaderRef.isPrior) && type == 'request'">
<div v-if="vHasGroupRequestConfig">
<div class="margin"></div>
<warning-message>由于已经在当前<a :href="vGroupSettingUrl + '#request'">服务分组</a>中进行了对应的配置,在这里的配置将不会生效。</warning-message>
</div>
<div :class="{'opacity-mask': vHasGroupRequestConfig}">
<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 celled" v-if="requestSettingHeaders.length > 0">
<thead>
<tr>
<th>名称</th>
<th>值</th>
<th class="two op">操作</th>
<p class="comment" v-if="requestSettingHeaders.length == 0">暂时还没有Header。</p>
<table class="ui table selectable celled" v-if="requestSettingHeaders.length > 0">
<thead>
<tr>
<th>名称</th>
<th>值</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="header in requestSettingHeaders">
<td class="five wide">{{header.name}}</td>
<td>{{header.value}}</td>
<td><a href="" @click.prevent="updateSettingPopup(vRequestHeaderPolicy.id, header.id)">修改</a> &nbsp; <a href="" @click.prevent="deleteHeader(vRequestHeaderPolicy.id, 'setHeader', header.id)">删除</a> </td>
</tr>
</thead>
<tr v-for="header in requestSettingHeaders">
<td class="five wide">{{header.name}}</td>
<td>{{header.value}}</td>
<td><a href="" @click.prevent="updateSettingPopup(vRequestHeaderPolicy.id, header.id)">修改</a> &nbsp; <a href="" @click.prevent="deleteHeader(vRequestHeaderPolicy.id, 'setHeader', header.id)">删除</a> </td>
</tr>
</table>
<h3>删除请求Header</h3>
<p class="comment">这里可以设置需要从请求中删除的Header。</p>
<table class="ui table definition selectable">
<td class="title">需要删除的Header</td>
<td>
<div v-if="requestDeletingHeaders.length > 0">
<div class="ui label small basic" v-for="headerName in requestDeletingHeaders">{{headerName}} <a href=""><i class="icon remove" title="删除" @click.prevent="deleteDeletingHeader(vRequestHeaderPolicy.id, headerName)"></i></a> </div>
<div class="ui divider" ></div>
</div>
<button class="ui button small" type="button" @click.prevent="addDeletingHeader(vRequestHeaderPolicy.id, 'request')">+</button>
</td>
</table>
</table>
<h3>删除请求Header</h3>
<p class="comment">这里可以设置需要从请求中删除的Header。</p>
<table class="ui table definition selectable">
<td class="title">需要删除的Header</td>
<td>
<div v-if="requestDeletingHeaders.length > 0">
<div class="ui label small basic" v-for="headerName in requestDeletingHeaders">{{headerName}} <a href=""><i class="icon remove" title="删除" @click.prevent="deleteDeletingHeader(vRequestHeaderPolicy.id, headerName)"></i></a> </div>
<div class="ui divider" ></div>
</div>
<button class="ui button small" type="button" @click.prevent="addDeletingHeader(vRequestHeaderPolicy.id, 'request')">+</button>
</td>
</table>
</div>
</div>
<!-- 响应 -->
<div v-if="vIsLocation && type == 'response'">
<div v-if="(vIsLocation || vIsGroup) && type == 'response'">
<input type="hidden" name="responseHeaderJSON" :value="JSON.stringify(responseHeaderRef)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="responseHeaderRef"></prior-checkbox>
@@ -177,38 +183,44 @@ Vue.component("http-header-policy-box", {
<submit-btn></submit-btn>
</div>
<div v-if="type == 'response'">
<h3>设置响应Header <a href="" @click.prevent="addSettingHeader(vResponseHeaderPolicy.id)">[添加新Header]</a></h3>
<p class="comment" style="margin-top: 0; padding-top: 0">将会覆盖已有的同名Header。</p>
<p class="comment" v-if="responseSettingHeaders.length == 0">暂时还没有Header。</p>
<table class="ui table selectable celled" v-if="responseSettingHeaders.length > 0">
<thead>
<tr>
<th>名称</th>
<th>值</th>
<th class="two op">操作</th>
<div v-if="((!vIsLocation && !vIsGroup) || requestHeaderRef.isPrior) && type == 'response'">
<div v-if="vHasGroupResponseConfig">
<div class="margin"></div>
<warning-message>由于已经在当前<a :href="vGroupSettingUrl + '#response'">服务分组</a>中进行了对应的配置,在这里的配置将不会生效。</warning-message>
</div>
<div :class="{'opacity-mask': vHasGroupResponseConfig}">
<h3>设置响应Header <a href="" @click.prevent="addSettingHeader(vResponseHeaderPolicy.id)">[添加新Header]</a></h3>
<p class="comment" style="margin-top: 0; padding-top: 0">将会覆盖已有的同名Header。</p>
<p class="comment" v-if="responseSettingHeaders.length == 0">暂时还没有Header。</p>
<table class="ui table selectable celled" v-if="responseSettingHeaders.length > 0">
<thead>
<tr>
<th>名称</th>
<th>值</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="header in responseSettingHeaders">
<td class="five wide">{{header.name}}</td>
<td>{{header.value}}</td>
<td><a href="" @click.prevent="updateSettingPopup(vResponseHeaderPolicy.id, header.id)">修改</a> &nbsp; <a href="" @click.prevent="deleteHeader(vResponseHeaderPolicy.id, 'setHeader', header.id)">删除</a> </td>
</tr>
</thead>
<tr v-for="header in responseSettingHeaders">
<td class="five wide">{{header.name}}</td>
<td>{{header.value}}</td>
<td><a href="" @click.prevent="updateSettingPopup(vResponseHeaderPolicy.id, header.id)">修改</a> &nbsp; <a href="" @click.prevent="deleteHeader(vResponseHeaderPolicy.id, 'setHeader', header.id)">删除</a> </td>
</tr>
</table>
<h3>删除响应Header</h3>
<p class="comment">这里可以设置需要从响应中删除的Header。</p>
<table class="ui table definition selectable">
<td class="title">需要删除的Header</td>
<td>
<div v-if="responseDeletingHeaders.length > 0">
<div class="ui label small basic" v-for="headerName in responseDeletingHeaders">{{headerName}} <a href=""><i class="icon remove" title="删除" @click.prevent="deleteDeletingHeader(vResponseHeaderPolicy.id, headerName)"></i></a> </div>
<div class="ui divider" ></div>
</div>
<button class="ui button small" type="button" @click.prevent="addDeletingHeader(vResponseHeaderPolicy.id, 'response')">+</button>
</td>
</table>
</table>
<h3>删除响应Header</h3>
<p class="comment">这里可以设置需要从响应中删除的Header。</p>
<table class="ui table definition selectable">
<td class="title">需要删除的Header</td>
<td>
<div v-if="responseDeletingHeaders.length > 0">
<div class="ui label small basic" v-for="headerName in responseDeletingHeaders">{{headerName}} <a href=""><i class="icon remove" title="删除" @click.prevent="deleteDeletingHeader(vResponseHeaderPolicy.id, headerName)"></i></a> </div>
<div class="ui divider" ></div>
</div>
<button class="ui button small" type="button" @click.prevent="addDeletingHeader(vResponseHeaderPolicy.id, 'response')">+</button>
</td>
</table>
</div>
</div>
<div class="margin"></div>
</div>`

View File

@@ -1,5 +1,5 @@
Vue.component("http-remote-addr-config-box", {
props: ["v-remote-addr-config", "v-is-location"],
props: ["v-remote-addr-config", "v-is-location", "v-is-group"],
data: function () {
let config = this.vRemoteAddrConfig
if (config == null) {
@@ -15,14 +15,14 @@ Vue.component("http-remote-addr-config-box", {
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.config.isPrior) && this.config.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
}
},
template: `<div>
<input type="hidden" name="remoteAddrJSON" :value="JSON.stringify(config)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="config" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || config.isPrior">
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || config.isPrior">
<tr>
<td class="title">是否启用</td>
<td>

View File

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

View File

@@ -1,5 +1,5 @@
Vue.component("http-web-root-box", {
props: ["v-root-config", "v-is-location"],
props: ["v-root-config", "v-is-location", "v-is-group"],
data: function () {
let rootConfig = this.vRootConfig
if (rootConfig == null) {
@@ -38,14 +38,14 @@ Vue.component("http-web-root-box", {
this.rootConfig.indexes.$remove(i)
},
isOn: function () {
return (!this.vIsLocation || this.rootConfig.isPrior) && this.rootConfig.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.rootConfig.isPrior) && this.rootConfig.isOn
}
},
template: `<div>
<input type="hidden" name="rootJSON" :value="JSON.stringify(rootConfig)"/>
<table class="ui table selectable definition">
<prior-checkbox :v-config="rootConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || rootConfig.isPrior">
<prior-checkbox :v-config="rootConfig" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || rootConfig.isPrior">
<tr>
<td class="title">是否开启静态资源分发</td>
<td>

View File

@@ -1,5 +1,5 @@
Vue.component("http-webp-config-box", {
props: ["v-webp-config", "v-is-location"],
props: ["v-webp-config", "v-is-location", "v-is-group"],
data: function () {
let config = this.vWebpConfig
if (config == null) {
@@ -43,7 +43,7 @@ Vue.component("http-webp-config-box", {
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.config.isPrior) && this.config.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
},
changeExtensions: function (values) {
values.forEach(function (v, k) {
@@ -66,8 +66,8 @@ Vue.component("http-webp-config-box", {
template: `<div>
<input type="hidden" name="webpJSON" :value="JSON.stringify(config)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="config" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || config.isPrior">
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="(!vIsLocation && !vIsGroup) || config.isPrior">
<tr>
<td class="title">是否启用</td>
<td>

View File

@@ -1,5 +1,5 @@
Vue.component("http-websocket-box", {
props: ["v-websocket-ref", "v-websocket-config", "v-is-location"],
props: ["v-websocket-ref", "v-websocket-config", "v-is-location", "v-is-group"],
data: function () {
let websocketRef = this.vWebsocketRef
if (websocketRef == null) {
@@ -55,7 +55,7 @@ Vue.component("http-websocket-box", {
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.websocketRef.isPrior) && this.websocketRef.isOn
return ((!this.vIsLocation && !this.vIsGroup) || this.websocketRef.isPrior) && this.websocketRef.isOn
},
changeAdvancedVisible: function (v) {
this.advancedVisible = v
@@ -77,8 +77,8 @@ Vue.component("http-websocket-box", {
<input type="hidden" name="websocketRefJSON" :value="JSON.stringify(websocketRef)"/>
<input type="hidden" name="websocketJSON" :value="JSON.stringify(websocketConfig)"/>
<table class="ui table definition selectable">
<prior-checkbox :v-config="websocketRef" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="(!this.vIsLocation || this.websocketRef.isPrior)">
<prior-checkbox :v-config="websocketRef" v-if="vIsLocation || vIsGroup"></prior-checkbox>
<tbody v-show="((!vIsLocation && !vIsGroup) || websocketRef.isPrior)">
<tr>
<td class="title">是否启用配置</td>
<td>

View File

@@ -18,7 +18,7 @@ Vue.component("prior-checkbox", {
<input type="checkbox" v-model="isPrior"/>
<label class="red"></label>
</div>
<p class="comment"><strong v-if="isPrior">[已打开]</strong> 打开后可以覆盖父级配置。</p>
<p class="comment"><strong v-if="isPrior">[已打开]</strong> 打开后可以覆盖父级或子级配置。</p>
</td>
</tr>
</tbody>`