[pve-devel] [PATCH v3 2/2] firewall autodisable GUI patch

Alen Grizonic a.grizonic at proxmox.com
Wed Jul 1 12:03:21 CEST 2015


Changes since [PATCH]:

- removed all the unnecessary code
- direct call of the warning message without using the hook method
- additional function submit_first to pass the enable flag parameter in the correct way
- added additional condition for the close method
- optimized enable flag change conditions
- the patch needs the keepalive feature disabled to work correctly

Changes since [PATCH] v2:

- removed some more unused code
- changed the digest handling by removing it on the second API call
( this version still uses the disabled keepalive feature )

Signed-off-by: Alen Grizonic <a.grizonic at proxmox.com>
---
 www/manager/grid/FirewallOptions.js | 42 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/www/manager/grid/FirewallOptions.js b/www/manager/grid/FirewallOptions.js
index f94be6c..3b8f8ac 100644
--- a/www/manager/grid/FirewallOptions.js
+++ b/www/manager/grid/FirewallOptions.js
@@ -25,6 +25,45 @@ Ext.define('PVE.FirewallOptions', {
 
 	var rows = {};
 
+	var submit_first = function() {
+	    var me = this;
+	    var form = me.formPanel.getForm();
+	    var form_values = me.getValues();
+	    submit_twice.call(me, form_values.enable ? 2 : 0);
+	}
+
+	var submit_twice = function(enable) {
+	    var me = this;
+	    var form = me.formPanel.getForm();
+	    var values = me.getValues();
+
+	    if (enable == 2) {
+		values.enable = 2;
+	    } else if (enable == 1) {
+		values.enable = 1;
+		delete me.digest;
+	    }
+
+	    PVE.Utils.API2Request({
+		url: me.url,
+		waitMsgTarget: me,
+		method: me.method || (me.backgroundDelay ? 'POST' : 'PUT'),
+		params: values,
+		failure: function(response, options) {
+		    confirm ("Connection lost: Disabling firewall (in 60 seconds).");
+		},
+		success: function(response, options) {
+		    if ((enable == 2) || (enable == 0)) {
+			me.close();
+		    }
+		    if (enable == 2) {
+			submit_twice.call(me, 1);
+		    }
+		}
+	    });
+	};
+
+
 	var add_boolean_row = function(name, text, defaultValue, labelWidth) {
 	    rows[name] = {
 		header: text,
@@ -42,7 +81,8 @@ Ext.define('PVE.FirewallOptions', {
 			name: name,
 			uncheckedValue: 0,
 			fieldLabel: text
-		    }
+		    },
+		    submit: submit_first
 		}
 	    };
 	};
-- 
2.1.4





More information about the pve-devel mailing list