[pve-devel] [PATCH 2/2] firewall autodisable GUI patch v2
Alen Grizonic
a.grizonic at proxmox.com
Tue Jun 30 16:01:18 CEST 2015
Changes since [PATCH]:
- removed all the unnecessary code removed
- 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 !
Signed-off-by: Alen Grizonic <a.grizonic at proxmox.com>
---
www/manager/grid/FirewallOptions.js | 60 ++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/www/manager/grid/FirewallOptions.js b/www/manager/grid/FirewallOptions.js
index f94be6c..9c70e6b 100644
--- a/www/manager/grid/FirewallOptions.js
+++ b/www/manager/grid/FirewallOptions.js
@@ -25,6 +25,63 @@ 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;
+ }
+
+ if (me.digest) {
+ if (values.enable == 2) {
+ me.digest = "";
+ } else {
+ values.digest = me.digest;
+ }
+ }
+
+ PVE.Utils.API2Request({
+ url: me.url,
+ waitMsgTarget: me,
+ method: me.method || (me.backgroundDelay ? 'POST' : 'PUT'),
+ params: values,
+ failure: function(response, options) {
+ if (response.result && response.result.errors) {
+ form.markInvalid(response.result.errors);
+ }
+ confirm ("Connection lost: Disabling firewall (in 60 seconds).");
+ },
+ success: function(response, options) {
+ if ((enable == 2) || (enable == 0)) {
+ me.close();
+ }
+ if ((me.backgroundDelay || me.showProgress) &&
+ response.result.data) {
+ var upid = response.result.data;
+ var win = Ext.create('PVE.window.TaskProgress', {
+ upid: upid
+ });
+ win.show();
+ }
+ if (enable == 2) {
+ submit_twice.call(me, 1);
+ }
+ }
+ });
+ };
+
+
var add_boolean_row = function(name, text, defaultValue, labelWidth) {
rows[name] = {
header: text,
@@ -42,7 +99,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