[pve-devel] [PATCH v4 manager 2/2] fix #1065: ui: fail2ban gui for nodes

Dominik Csapak d.csapak at proxmox.com
Tue Oct 19 15:47:20 CEST 2021


looks mostly ok (besides my comment about the propertystring and options
thing of the previous patch)

comment inline:

On 10/11/21 12:57, Oguz Bektas wrote:
> adds a simple grid for fail2ban options into the node config panel
> 
> ---
> v4:
> * no changes
> 
> 
>   www/manager6/Makefile                |  1 +
>   www/manager6/grid/Fail2banOptions.js | 51 ++++++++++++++++++++++++++++
>   www/manager6/node/Config.js          |  7 ++++
>   3 files changed, 59 insertions(+)
>   create mode 100644 www/manager6/grid/Fail2banOptions.js
> 
> diff --git a/www/manager6/Makefile b/www/manager6/Makefile
> index 7d491f57..ad9fe58a 100644
> --- a/www/manager6/Makefile
> +++ b/www/manager6/Makefile
> @@ -74,6 +74,7 @@ JSSRC= 							\
>   	grid/BackupView.js				\
>   	grid/FirewallAliases.js				\
>   	grid/FirewallOptions.js				\
> +	grid/Fail2banOptions.js				\
>   	grid/FirewallRules.js				\
>   	grid/PoolMembers.js				\
>   	grid/Replication.js				\
> diff --git a/www/manager6/grid/Fail2banOptions.js b/www/manager6/grid/Fail2banOptions.js
> new file mode 100644
> index 00000000..5de0c18c
> --- /dev/null
> +++ b/www/manager6/grid/Fail2banOptions.js
> @@ -0,0 +1,51 @@
> +Ext.define('PVE.Fail2banOptions', {
> +    extend: 'Proxmox.grid.ObjectGrid',
> +    alias: ['widget.pveFail2banOptions'],
> +
> +    base_url: undefined,
> +
> +    initComponent: function() {
> +	var me = this;
> +
> +	me.rows = {};
> +
> +	me.add_boolean_row('enable', gettext("Enable Fail2Ban"));
> +	me.add_integer_row('maxretry', gettext("Max retries"));
> +	me.add_integer_row('bantime', gettext("Minutes to ban"));
> +
> +	var edit_btn = new Ext.Button({
> +	    text: gettext('Edit'),
> +	    disabled: true,
> +	    handler: function() { me.run_editor(); },
> +	});
> +
> +	var set_button_status = function() {
> +	    var sm = me.getSelectionModel();
> +	    var rec = sm.getSelection()[0];
> +
> +	    if (!rec) {
> +		edit_btn.disable();
> +		return;
> +	    }
> +	    var rowdef = me.rows[rec.data.key];
> +	    edit_btn.setDisabled(!rowdef.editor);
> +	};
> +
> +	Ext.apply(me, {
> +	    url: "/api2/json" + me.base_url,
> +	    tbar: [edit_btn],
> +	    editorConfig: {
> +		url: "/api2/extjs" + me.base_url,
> +	    },
> +	    listeners: {
> +		itemdblclick: me.run_editor,
> +		selectionchange: set_button_status,
> +	    },
> +	});

i know its mostly copy&pasted, but i'd still rather see a more
declarative approach to this, even if it just defining the functions 
inline here.

> +
> +	me.callParent();
> +	me.on('activate', me.rstore.startUpdate);
> +	me.on('destroy', me.rstore.stopUpdate);
> +	me.on('deactivate', me.rstore.stopUpdate);
> +    },
> +});
> diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 68f80391..9dbe8d0c 100644
> --- a/www/manager6/node/Config.js
> +++ b/www/manager6/node/Config.js
> @@ -276,6 +276,13 @@ Ext.define('PVE.node.Config', {
>   		    base_url: '/nodes/' + nodename + '/firewall/options',
>   		    fwtype: 'node',
>   		    itemId: 'firewall-options',
> +		},
> +		{
> +		    xtype: 'pveFail2banOptions',
> +		    iconCls: 'fa fa-legal',
> +		    title: gettext('Fail2ban'),
> +		    base_url: '/nodes/' + nodename + '/firewall/fail2ban',
> +		    itemId: 'fail2ban-options',
>   		});
>   	}
>   
> 






More information about the pve-devel mailing list