[pve-devel] [PATCH manager] ui: fw: Close #2815: Add warning if fw is disabled
Dominic Jäger
d.jaeger at proxmox.com
Tue Jun 23 11:31:19 CEST 2020
Currently people add firewall rules but forget to activate the firewall on
guest level. This commit adds a warning to the top bar of the firewall panel to
make them aware of this if necessary.
It seems a little cheaper but still sufficient to check only if some rule
exists and not for every rule if it is really enabled.
Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
www/manager6/grid/FirewallRules.js | 32 ++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/www/manager6/grid/FirewallRules.js b/www/manager6/grid/FirewallRules.js
index ec2d1c84..7cb2baf0 100644
--- a/www/manager6/grid/FirewallRules.js
+++ b/www/manager6/grid/FirewallRules.js
@@ -483,8 +483,26 @@ Ext.define('PVE.FirewallRules', {
throw "no list_refs_url specified";
}
+ let checkWarning = function () {
+ Proxmox.Utils.API2Request({
+ url: me.base_url.replace('rules', 'options'),
+ method: 'GET',
+ failure: function (response) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function (response) {
+ let warningRequired = me.store.getCount() != 0 && !response.result.data.enable;
+ me.down('displayfield[name=fw-warning]').setVisible(warningRequired)
+ },
+ });
+
+ };
+
var store = Ext.create('Ext.data.Store',{
- model: 'pve-fw-rule'
+ model: 'pve-fw-rule',
+ listeners: {
+ 'load': checkWarning,
+ },
});
var reload = function() {
@@ -606,12 +624,22 @@ Ext.define('PVE.FirewallRules', {
}
});
+ me.warningField = Ext.create('Ext.form.field.Display',{
+ xtype: 'displayfield',
+ dock: 'top',
+ userCls: 'pmx-hint',
+ name: 'fw-warning',
+ margin: '10 0 0 0',
+ value: gettext('Warning: Firewall still disabled at guest level! This can be changed in Firewall->Options.'),
+ hidden: true,
+ });
+
var tbar = me.tbar_prefix ? [ me.tbar_prefix ] : [];
tbar.push(me.addBtn, me.copyBtn);
if (me.groupBtn) {
tbar.push(me.groupBtn);
}
- tbar.push(me.removeBtn, me.editBtn);
+ tbar.push(me.removeBtn, me.editBtn, me.warningField);
var render_errors = function(name, value, metaData, record) {
var errors = record.data.errors;
--
2.20.1
More information about the pve-devel
mailing list