Vue.component("http-access-log-box", { props: ["v-access-log", "v-keyword", "v-show-server-link"], data: function () { let accessLog = this.vAccessLog if (accessLog.header != null && accessLog.header.Upgrade != null && accessLog.header.Upgrade.values != null && accessLog.header.Upgrade.values.$contains("websocket")) { if (accessLog.scheme == "http") { accessLog.scheme = "ws" } else if (accessLog.scheme == "https") { accessLog.scheme = "wss" } } return { accessLog: accessLog } }, methods: { formatCost: function (seconds) { if (seconds == null) { return "0" } let s = (seconds * 1000).toString(); let pieces = s.split("."); if (pieces.length < 2) { return s; } return pieces[0] + "." + pieces[1].substring(0, 3); }, showLog: function () { let that = this let requestId = this.accessLog.requestId this.$parent.$children.forEach(function (v) { if (v.deselect != null) { v.deselect() } }) this.select() teaweb.popup("/servers/server/log/viewPopup?requestId=" + requestId, { width: "50em", height: "28em", onClose: function () { that.deselect() } }) }, select: function () { this.$refs.box.parentNode.style.cssText = "background: rgba(0, 0, 0, 0.1)" }, deselect: function () { this.$refs.box.parentNode.style.cssText = "" } }, template: `
[{{accessLog.node.name}}节点] [服务] [{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} cache {{accessLog.attrs['cache.status'].toLowerCase()}} waf {{accessLog.firewallActions}} - {{tag}} WAF -- {{accessLog.wafInfo.group.name}} -- {{accessLog.wafInfo.set.name}} - 耗时:{{formatCost(accessLog.requestTime)}} ms   ({{accessLog.humanTime}})  
` })