]> git.proxmox.com Git - pve-manager.git/commitdiff
firewall: add scope field to IPRefSelector
authorLeo Nunner <l.nunner@proxmox.com>
Tue, 13 Jun 2023 12:06:34 +0000 (14:06 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 15 Jun 2023 07:35:32 +0000 (09:35 +0200)
and send the scoped value to the firewall when choosing new values.
This happens for both IPSets and aliases.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
www/manager6/form/IPRefSelector.js

index 9ccc2fe1068acf3e4eaf518b1f9bb2a49f781d9a..b50ac1e1048aee8c6e6e114a075297057b28605c 100644 (file)
@@ -8,7 +8,7 @@ Ext.define('PVE.form.IPRefSelector', {
 
     ref_type: undefined, // undefined = any [undefined, 'ipset' or 'alias']
 
-    valueField: 'ref',
+    valueField: 'scopedref',
     displayField: 'ref',
     notFoundIsValid: true,
 
@@ -26,7 +26,23 @@ Ext.define('PVE.form.IPRefSelector', {
 
        var store = Ext.create('Ext.data.Store', {
            autoLoad: true,
-           fields: ['type', 'name', 'ref', 'comment'],
+           fields: [
+               'type',
+               'name',
+               'ref',
+               'comment',
+               'scope',
+               {
+                   name: 'scopedref',
+                   calculate: function(v) {
+                       if (v.type === 'alias') {
+                           return `${v.scope}/${v.name}`;
+                       } else {
+                           return `+${v.scope}/${v.name}`;
+                       }
+                   },
+               },
+           ],
            idProperty: 'ref',
            proxy: {
                type: 'proxmox',
@@ -65,17 +81,30 @@ Ext.define('PVE.form.IPRefSelector', {
                hideable: false,
                width: 140,
            },
+           {
+               header: gettext('Scope'),
+               dataIndex: 'scope',
+               hideable: false,
+               width: 140,
+               renderer: function(value) {
+                   return value === 'dc' ? gettext("Datacenter") : gettext("Guest");
+               },
+           },
            {
                header: gettext('Comment'),
                dataIndex: 'comment',
                renderer: Ext.String.htmlEncode,
+               minWidth: 60,
                flex: 1,
            },
        );
 
        Ext.apply(me, {
            store: store,
-            listConfig: { columns: columns },
+            listConfig: {
+               columns: columns,
+               width: 500,
+           },
        });
 
        me.on('change', disable_query_for_ips);