实现基本的访问日志策略

This commit is contained in:
GoEdgeLab
2021-07-29 16:51:22 +08:00
parent 6703d631a9
commit 953b880456
28 changed files with 1397 additions and 87 deletions

View File

@@ -1,8 +1,13 @@
let sourceCodeBoxIndex = 0
Vue.component("source-code-box", {
props: ["type", "id"],
props: ["name", "type", "id", "read-only"],
mounted: function () {
let readOnly = this.readOnly
if (typeof readOnly != "boolean") {
readOnly = true
}
console.log("readonly:", readOnly) // TODO
let box = document.getElementById("source-code-box-" + this.index)
let valueBox = document.getElementById(this.valueBoxId)
let value = ""
@@ -15,7 +20,7 @@ Vue.component("source-code-box", {
theme: "idea",
lineNumbers: true,
value: "",
readOnly: true,
readOnly: readOnly,
showCursorWhenSelecting: true,
height: "auto",
//scrollbarStyle: null,
@@ -49,6 +54,6 @@ Vue.component("source-code-box", {
},
template: `<div class="source-code-box">
<div style="display: none" :id="valueBoxId"><slot></slot></div>
<textarea :id="'source-code-box-' + index"></textarea>
<textarea :id="'source-code-box-' + index" :name="name"></textarea>
</div>`
})

View File

@@ -1,12 +1,11 @@
Vue.component("http-access-log-config-box", {
props: ["v-access-log-config", "v-fields", "v-default-field-codes", "v-access-log-policies", "v-is-location"],
props: ["v-access-log-config", "v-fields", "v-default-field-codes", "v-is-location"],
data: function () {
let that = this
// 初始化
setTimeout(function () {
that.changeFields()
that.changePolicy()
}, 100)
let accessLog = {
@@ -19,9 +18,6 @@ Vue.component("http-access-log-config-box", {
status4: true,
status5: true,
storageOnly: false,
storagePolicies: [],
firewallOnly: false
}
if (this.vAccessLogConfig != null) {
@@ -35,9 +31,6 @@ Vue.component("http-access-log-config-box", {
v.isChecked = accessLog.fields.$contains(v.code)
}
})
this.vAccessLogPolicies.forEach(function (v) {
v.isChecked = accessLog.storagePolicies.$contains(v.id)
})
return {
accessLog: accessLog
@@ -50,13 +43,6 @@ Vue.component("http-access-log-config-box", {
}).map(function (v) {
return v.code
})
},
changePolicy: function () {
this.accessLog.storagePolicies = this.vAccessLogPolicies.filter(function (v) {
return v.isChecked
}).map(function (v) {
return v.id
})
}
},
template: `<div>
@@ -110,28 +96,6 @@ Vue.component("http-access-log-config-box", {
</div>
</td>
</tr>
<tr v-show="vAccessLogPolicies.length > 0">
<td>选择输出的日志策略</td>
<td>
<span class="disabled" v-if="vAccessLogPolicies.length == 0">暂时还没有缓存策略。</span>
<div v-if="vAccessLogPolicies.length > 0">
<div class="ui checkbox" v-for="policy in vAccessLogPolicies" style="width:10em;margin-bottom:0.8em">
<input type="checkbox" v-model="policy.isChecked" @change="changePolicy" />
<label>{{policy.name}}</label>
</div>
</div>
</td>
</tr>
<tr v-show="vAccessLogPolicies.length > 0">
<td>是否只输出到日志策略</td>
<td>
<div class="ui checkbox">
<input type="checkbox" v-model="accessLog.storageOnly"/>
<label></label>
</div>
<p class="comment">选中表示只输出日志到日志策略,而停止默认的日志存储。</p>
</td>
</tr>
</tbody>
</table>

View File

@@ -345,17 +345,19 @@ Vue.component("metric-chart", {
]
})
// IP相关操作
if (this.item.keys != null && this.item.keys.$contains("${remoteAddr}")) {
let that = this
chart.on("click", function (args) {
let index = that.item.keys.$indexesOf("${remoteAddr}")[0]
let value = that.stats[args.dataIndex].keys[index]
teaweb.popup("/servers/ipbox?ip=" + value, {
width: "50em",
height: "30em"
if (this.item.keys != null) {
// IP相关操作
if (this.item.keys.$contains("${remoteAddr}")) {
let that = this
chart.on("click", function (args) {
let index = that.item.keys.$indexesOf("${remoteAddr}")[0]
let value = that.stats[args.dataIndex].keys[index]
teaweb.popup("/servers/ipbox?ip=" + value, {
width: "50em",
height: "30em"
})
})
})
}
}
},
renderTable: function (chart) {