Files
EdgeAdmin/web/public/js/components/server/http-location-labels.js

100 lines
5.6 KiB
JavaScript
Raw Normal View History

2020-09-27 18:40:55 +08:00
Vue.component("http-location-labels", {
2020-10-05 16:54:34 +08:00
props: ["v-location-config", "v-server-id"],
2020-09-27 18:40:55 +08:00
data: function () {
return {
location: this.vLocationConfig
}
},
methods: {
// 判断是否已启用某配置
configIsOn: function (config) {
return config != null && config.isPrior && config.isOn
},
refIsOn: function (ref, config) {
return this.configIsOn(ref) && config != null && config.isOn
},
len: function (arr) {
return (arr == null) ? 0 : arr.length
2020-10-05 16:54:34 +08:00
},
url: function (path) {
return "/servers/server/settings/locations" + path + "?serverId=" + this.vServerId + "&locationId=" + this.location.id
2020-09-27 18:40:55 +08:00
}
},
template: ` <div class="labels-box">
2020-09-28 16:25:26 +08:00
<!-- 基本信息 -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.name != null && location.name.length > 0" :class="'olive'" :href="url('/location')">{{location.name}}</http-location-labels-label>
2021-12-12 16:38:52 +08:00
<!-- domains -->
<div v-if="location.domains != null && location.domains.length > 0">
<grey-label v-for="domain in location.domains">{{domain}}</grey-label>
</div>
<!-- break -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.isBreak" :href="url('/location')">BREAK</http-location-labels-label>
2020-09-28 16:25:26 +08:00
2020-09-27 18:40:55 +08:00
<!-- redirectToHTTPS -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.redirectToHTTPS)" :href="url('/http')">自动跳转HTTPS</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- Web -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.root)" :href="url('/web')">文档根目录</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- 反向代理 -->
2022-09-22 15:27:23 +08:00
<http-location-labels-label v-if="refIsOn(location.reverseProxyRef, location.reverseProxy)" :v-href="url('/reverseProxy')">源站</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- WAF -->
<!-- TODO -->
<!-- Cache -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.cache)" :v-href="url('/cache')">CACHE</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- Charset -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.charset) && location.web.charset.charset.length > 0" :href="url('/charset')">{{location.web.charset.charset}}</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- 访问日志 -->
<!-- TODO -->
<!-- 统计 -->
<!-- TODO -->
<!-- Gzip -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.gzipRef, location.web.gzip) && location.web.gzip.level > 0" :href="url('/gzip')">Gzip:{{location.web.gzip.level}}</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- HTTP Header -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.requestHeaderPolicyRef, location.web.requestHeaderPolicy) && (len(location.web.requestHeaderPolicy.addHeaders) > 0 || len(location.web.requestHeaderPolicy.setHeaders) > 0 || len(location.web.requestHeaderPolicy.replaceHeaders) > 0 || len(location.web.requestHeaderPolicy.deleteHeaders) > 0)" :href="url('/headers')">请求Header</http-location-labels-label>
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.responseHeaderPolicyRef, location.web.responseHeaderPolicy) && (len(location.web.responseHeaderPolicy.addHeaders) > 0 || len(location.web.responseHeaderPolicy.setHeaders) > 0 || len(location.web.responseHeaderPolicy.replaceHeaders) > 0 || len(location.web.responseHeaderPolicy.deleteHeaders) > 0)" :href="url('/headers')">响应Header</http-location-labels-label>
2020-09-27 18:40:55 +08:00
<!-- Websocket -->
2020-10-05 16:54:34 +08:00
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.websocketRef, location.web.websocket)" :href="url('/websocket')">Websocket</http-location-labels-label>
2020-09-27 18:40:55 +08:00
2022-03-26 22:10:34 +08:00
<!-- 请求脚本 -->
<http-location-labels-label v-if="location.web != null && location.web.requestScripts != null && ((location.web.requestScripts.initGroup != null && location.web.requestScripts.initGroup.isPrior) || (location.web.requestScripts.requestGroup != null && location.web.requestScripts.requestGroup.isPrior))" :href="url('/requestScripts')">请求脚本</http-location-labels-label>
2022-07-30 10:43:53 +08:00
<!-- 自定义访客IP地址 -->
<http-location-labels-label v-if="location.web != null && location.web.remoteAddr != null && location.web.remoteAddr.isPrior" :href="url('/remoteAddr')" :class="{disabled: !location.web.remoteAddr.isOn}">访客IP地址</http-location-labels-label>
<!-- 请求限制 -->
<http-location-labels-label v-if="location.web != null && location.web.requestLimit != null && location.web.requestLimit.isPrior" :href="url('/requestLimit')" :class="{disabled: !location.web.requestLimit.isOn}">请求限制</http-location-labels-label>
2022-03-31 14:53:07 +08:00
<!-- 自定义页面 -->
2020-09-27 18:40:55 +08:00
<div v-if="location.web != null && location.web.pages != null && location.web.pages.length > 0">
2020-10-05 16:54:34 +08:00
<div v-for="page in location.web.pages" :key="page.id"><http-location-labels-label :href="url('/pages')">PAGE [状态码{{page.status[0]}}] -&gt; {{page.url}}</http-location-labels-label></div>
2020-09-27 18:40:55 +08:00
</div>
<div v-if="location.web != null && configIsOn(location.web.shutdown)">
2020-10-05 16:54:34 +08:00
<http-location-labels-label :v-class="'red'" :href="url('/pages')">临时关闭</http-location-labels-label>
2020-09-27 18:40:55 +08:00
</div>
2020-09-28 16:25:26 +08:00
<!-- 重写规则 -->
2020-10-05 16:54:34 +08:00
<div v-if="location.web != null && location.web.rewriteRules != null && location.web.rewriteRules.length > 0">
<div v-for="rewriteRule in location.web.rewriteRules">
<http-location-labels-label :href="url('/rewrite')">REWRITE {{rewriteRule.pattern}} -&gt; {{rewriteRule.replace}}</http-location-labels-label>
</div>
</div>
2020-09-27 18:40:55 +08:00
</div>`
})
Vue.component("http-location-labels-label", {
2020-10-05 16:54:34 +08:00
props: ["v-class", "v-href"],
2022-03-26 22:10:34 +08:00
template: `<a :href="vHref" class="ui label tiny basic" :class="vClass" style="font-size:0.7em;padding:4px;margin-top:0.3em;margin-bottom:0.3em"><slot></slot></a>`
2020-09-27 18:40:55 +08:00
})