修复点击修改WAF规则时未保存时也会生效的Bug

This commit is contained in:
刘祥超
2022-12-06 10:46:46 +08:00
parent e9a47041fd
commit 892ee0013a
5 changed files with 19 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ Vue.component("http-firewall-rules-box", {
}) })
}, },
updateRule: function (index, rule) { updateRule: function (index, rule) {
window.UPDATING_RULE = rule window.UPDATING_RULE = teaweb.clone(rule)
let that = this let that = this
teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, { teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, {
height: "30em", height: "30em",

View File

@@ -49,6 +49,10 @@ window.teaweb = {
} }
return true; return true;
}, },
clone: function (source) {
let s = JSON.stringify(source)
return JSON.parse(s)
},
loadJS: function (file, callback) { loadJS: function (file, callback) {
let element = document.createElement("script") let element = document.createElement("script")
@@ -940,7 +944,7 @@ window.teaweb = {
}, },
chartMap: {}, // dom id => chart chartMap: {}, // dom id => chart
initChart: function (dom, cache) { initChart: function (dom, cache) {
if (typeof(cache) != "boolean") { if (typeof (cache) != "boolean") {
cache = true cache = true
} }

View File

@@ -27,7 +27,7 @@ Tea.context(function () {
this.rule.checkpointPrefix = param this.rule.checkpointPrefix = param
} }
this.$delay(function () { this.$delay(function () {
this.changeCheckpoint() this.loadCheckpoint()
if (this.rule.checkpointOptions != null && this.checkpoint != null && this.checkpoint.options != null) { if (this.rule.checkpointOptions != null && this.checkpoint != null && this.checkpoint.options != null) {
let that = this let that = this
this.checkpoint.options.forEach(function (option) { this.checkpoint.options.forEach(function (option) {
@@ -43,6 +43,18 @@ Tea.context(function () {
* checkpoint * checkpoint
*/ */
this.checkpoint = null this.checkpoint = null
this.loadCheckpoint = function () {
if (this.rule.checkpointPrefix.length == 0) {
this.checkpoint = null
return
}
let that = this
this.checkpoint = this.checkpoints.$find(function (k, v) {
return v.prefix == that.rule.checkpointPrefix
})
}
this.changeCheckpoint = function () { this.changeCheckpoint = function () {
if (this.rule.checkpointPrefix.length == 0) { if (this.rule.checkpointPrefix.length == 0) {
this.checkpoint = null this.checkpoint = null

View File

@@ -57,7 +57,6 @@ Tea.context(function () {
// 添加分组 // 添加分组
this.createGroup = function (type) { this.createGroup = function (type) {
teaweb.popup("/servers/components/waf/createGroupPopup?firewallPolicyId=" + this.firewallPolicyId + "&type=" + type, { teaweb.popup("/servers/components/waf/createGroupPopup?firewallPolicyId=" + this.firewallPolicyId + "&type=" + type, {
height: "16em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()

View File

@@ -57,7 +57,6 @@ Tea.context(function () {
// 添加分组 // 添加分组
this.createGroup = function (type) { this.createGroup = function (type) {
teaweb.popup("/servers/components/waf/createGroupPopup?firewallPolicyId=" + this.firewallPolicyId + "&type=" + type, { teaweb.popup("/servers/components/waf/createGroupPopup?firewallPolicyId=" + this.firewallPolicyId + "&type=" + type, {
height: "16em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()