Vue.component("http-firewall-rules-box", { props: ["v-rules", "v-type"], data: function () { let rules = this.vRules if (rules == null) { rules = [] } return { rules: rules } }, methods: { addRule: function () { window.UPDATING_RULE = null let that = this teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, { height: "30em", callback: function (resp) { that.rules.push(resp.data.rule) } }) }, updateRule: function (index, rule) { window.UPDATING_RULE = teaweb.clone(rule) let that = this teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, { height: "30em", callback: function (resp) { Vue.set(that.rules, index, resp.data.rule) } }) }, removeRule: function (index) { let that = this teaweb.confirm("确定要删除此规则吗?", function () { that.rules.$remove(index) }) }, operatorName: function (operatorCode) { let operatorName = operatorCode if (typeof (window.WAF_RULE_OPERATORS) != null) { window.WAF_RULE_OPERATORS.forEach(function (v) { if (v.code == operatorCode) { operatorName = v.name } }) } return operatorName }, operatorDataType: function (operatorCode) { let operatorDataType = "none" if (typeof (window.WAF_RULE_OPERATORS) != null) { window.WAF_RULE_OPERATORS.forEach(function (v) { if (v.code == operatorCode) { operatorDataType = v.dataType } }) } return operatorDataType }, calculateParamName: function (param) { let paramName = "" if (param != null) { window.WAF_RULE_CHECKPOINTS.forEach(function (checkpoint) { if (param == "${" + checkpoint.prefix + "}" || param.startsWith("${" + checkpoint.prefix + ".")) { paramName = checkpoint.name } }) } return paramName }, isEmptyString: function (v) { return typeof v == "string" && v.length == 0 } }, template: `
{{rule.name}}{{calculateParamName(rule.param)}} {{rule.param}} {{rule.checkpointOptions.period}}秒内请求数 允许{{rule.checkpointOptions.allowDomains}} 禁止{{rule.checkpointOptions.denyDomains}} | {{paramFilter.code}} <{{operatorName(rule.operator)}}> {{rule.value}} [空] ({{rule.description}})
` })