From: "Dominic Jäger" <d.jaeger@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v3] ui: fw: Close #2815: Add warning if fw is disabled
Date: Fri, 24 Jul 2020 10:54:25 +0200 [thread overview]
Message-ID: <20200724085425.22554-1-d.jaeger@proxmox.com> (raw)
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.
The existence of a rule alone should not yet trigger the warning. Only if it is
enabled but the whole firewall for that level is not.
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
v2->v3:
- rebased
- squashed both commits to make review easier
- one whitespace error
www/manager6/grid/FirewallRules.js | 43 ++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/www/manager6/grid/FirewallRules.js b/www/manager6/grid/FirewallRules.js
index ec2d1c84..9a9dd286 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 = !response.result.data.enable
+ && me.store.findExact('enable', true) >= 0;
+ 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,33 @@ Ext.define('PVE.FirewallRules', {
}
});
+ let getLevel = (id) => {
+ let invalid = 'this';
+ let level = /root/.test(id) ? 'datacenter'
+ : /node/.test(id) ? 'node'
+ : /qemu/.test(id) ? 'VM'
+ : /lxc/.test(id) ? 'container'
+ : invalid;
+ if (level === invalid) { console.warn(`Finding level failed for ${id}`)};
+ return level;
+ };
+ me.warningField = Ext.create('Ext.form.field.Display',{
+ xtype: 'displayfield',
+ userCls: 'pmx-hint',
+ name: 'fw-warning',
+ margin: 'auto 0 0 0', // Avoid field randomly sticking at top
+ value: gettext(`Warning: Firewall still disabled at `
+ + `${getLevel(me.pveSelNode.id)} 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
reply other threads:[~2020-07-24 8:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200724085425.22554-1-d.jaeger@proxmox.com \
--to=d.jaeger@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.