[pve-devel] [PATCH pve-manager] fix #1108: add copy firewall rule to GUI
Dominik Csapak
d.csapak at proxmox.com
Tue Oct 4 16:55:19 CEST 2016
looks good, one comment inline
On 09/22/2016 11:03 AM, Wolfgang Link wrote:
> It is now possible to select a firewall rule on the GUI
> and copy it as template for the new rule.
> ---
> www/manager6/grid/FirewallRules.js | 35 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/www/manager6/grid/FirewallRules.js b/www/manager6/grid/FirewallRules.js
> index 09f1074..4d151e7 100644
> --- a/www/manager6/grid/FirewallRules.js
> +++ b/www/manager6/grid/FirewallRules.js
> @@ -280,6 +280,8 @@ Ext.define('PVE.FirewallRuleEdit', {
> }
> }
> });
> + } else if (me.rec) {
> + ipanel.setValues(me.rec.data);
> }
> }
> });
> @@ -549,6 +551,37 @@ Ext.define('PVE.FirewallRules', {
> }
> });
>
> + var run_copy_editor = function() {
> + var rec = sm.getSelection()[0];
> +
> + if (!rec) {
> + return;
> + }
> + var type = rec.data.type;
> +
> +
> + if (!(type === 'in' || type === 'out')) {
> + return;
> + }
> +
> + var win = Ext.create('PVE.FirewallRuleEdit', {
> + allow_iface: me.allow_iface,
> + base_url: me.base_url,
> + list_refs_url: me.list_refs_url,
> + rec: rec,
> + });
> +
> + win.show();
> + win.on('destroy', reload);
> + };
> +
> + me.copyBtn = Ext.create('PVE.button.Button',{
> + text: gettext('Copy'),
> + selModel: sm,
> + disabled: true,
> + handler: run_copy_editor,
> + });
in the button definition you could add a
enableFN like this:
enableFn: function(rec) {
return (rec.data.type === 'in' || rec.data.type === 'out');
},
this would disable the button on everything except in/out rules instead
of simply doing nothing
but this can be added in a seperate patch
> +
> if (me.allow_groups) {
> me.groupBtn = Ext.create('Ext.Button', {
> text: gettext('Insert') + ': ' +
> @@ -579,7 +612,7 @@ Ext.define('PVE.FirewallRules', {
> });
>
> var tbar = me.tbar_prefix ? [ me.tbar_prefix ] : [];
> - tbar.push(me.addBtn);
> + tbar.push(me.addBtn, me.copyBtn);
> if (me.groupBtn) {
> tbar.push(me.groupBtn);
> }
>
More information about the pve-devel
mailing list