public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-manager] sdn: adapt edit panels for new API endpoints
Date: Wed, 22 Nov 2023 18:41:05 +0100	[thread overview]
Message-ID: <20231122174105.621179-1-s.hanreich@proxmox.com> (raw)

PUT endpoints have changed so they work like the other SectionConfig
endpoints. Reflect those changes in the UI.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 www/manager6/sdn/SubnetEdit.js       | 23 ++++++++++-------
 www/manager6/sdn/VnetEdit.js         | 18 +++++++++-----
 www/manager6/sdn/zones/Base.js       |  2 +-
 www/manager6/sdn/zones/EvpnEdit.js   | 37 ++++++++--------------------
 www/manager6/sdn/zones/SimpleEdit.js |  3 ++-
 5 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index 8851b013a..8fc3f52b0 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -11,13 +11,6 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
 	    delete values.cidr;
 	}
 
-	if (!values.gateway) {
-	    delete values.gateway;
-	}
-	if (!values.snat) {
-	    delete values.snat;
-	}
-
 	return values;
     },
 
@@ -33,18 +26,25 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
 	    fieldLabel: gettext('Subnet'),
 	},
 	{
-	    xtype: 'textfield',
+	    xtype: 'proxmoxtextfield',
 	    name: 'gateway',
 	    vtype: 'IP64Address',
 	    fieldLabel: gettext('Gateway'),
 	    allowBlank: true,
+	    skipEmptyText: true,
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
 	{
 	    xtype: 'proxmoxcheckbox',
 	    name: 'snat',
-	    uncheckedValue: 0,
+	    uncheckedValue: null,
 	    checked: false,
 	    fieldLabel: 'SNAT',
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
 	{
 	    xtype: 'proxmoxtextfield',
@@ -52,6 +52,9 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
 	    skipEmptyText: true,
 	    fieldLabel: gettext('DNS Zone Prefix'),
 	    allowBlank: true,
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
     ],
 });
@@ -101,6 +104,8 @@ Ext.define('PVE.sdn.SubnetDhcpRangePanel', {
 
 	if (value.length) {
 	    data[me.getName()] = value;
+	} else if (!me.isCreate) {
+	    data.delete = me.getName();
 	}
 
 	return data;
diff --git a/www/manager6/sdn/VnetEdit.js b/www/manager6/sdn/VnetEdit.js
index 0f55595f8..cdd83ed40 100644
--- a/www/manager6/sdn/VnetEdit.js
+++ b/www/manager6/sdn/VnetEdit.js
@@ -9,10 +9,6 @@ Ext.define('PVE.sdn.VnetInputPanel', {
 	    values.type = 'vnet';
 	}
 
-	if (!values.vlanaware) {
-	    delete values.vlanaware;
-	}
-
 	return values;
     },
 
@@ -29,10 +25,14 @@ Ext.define('PVE.sdn.VnetInputPanel', {
 	    fieldLabel: gettext('Name'),
 	},
 	{
-	    xtype: 'textfield',
+	    xtype: 'proxmoxtextfield',
 	    name: 'alias',
 	    fieldLabel: gettext('Alias'),
 	    allowBlank: true,
+	    skipEmptyText: true,
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
 	{
 	    xtype: 'pveSDNZoneSelector',
@@ -48,13 +48,19 @@ Ext.define('PVE.sdn.VnetInputPanel', {
 	    maxValue: 16777216,
 	    fieldLabel: gettext('Tag'),
 	    allowBlank: true,
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
 	{
 	    xtype: 'proxmoxcheckbox',
 	    name: 'vlanaware',
-	    uncheckedValue: 0,
+	    uncheckedValue: null,
 	    checked: false,
 	    fieldLabel: gettext('VLAN Aware'),
+	    cbind: {
+		deleteEmpty: "{!isCreate}",
+	    },
 	},
     ],
 });
diff --git a/www/manager6/sdn/zones/Base.js b/www/manager6/sdn/zones/Base.js
index db9b47b18..2eecb101a 100644
--- a/www/manager6/sdn/zones/Base.js
+++ b/www/manager6/sdn/zones/Base.js
@@ -34,9 +34,9 @@ Ext.define('PVE.panel.SDNZoneBase', {
                 minValue: 100,
                 maxValue: 65000,
                 fieldLabel: 'MTU',
-                skipEmptyText: true,
                 allowBlank: true,
                 emptyText: 'auto',
+		deleteEmpty: !me.isCreate,
             },
             {
                 xtype: 'pveNodeSelector',
diff --git a/www/manager6/sdn/zones/EvpnEdit.js b/www/manager6/sdn/zones/EvpnEdit.js
index cac1ef4d5..a08faef2d 100644
--- a/www/manager6/sdn/zones/EvpnEdit.js
+++ b/www/manager6/sdn/zones/EvpnEdit.js
@@ -8,30 +8,8 @@ Ext.define('PVE.sdn.zones.EvpnInputPanel', {
 
 	if (me.isCreate) {
 	    values.type = me.type;
-	} else {
-	    delete values.zone;
 	}
 
-        if (!values.mac) {
-            delete values.mac;
-        }
-
-        if (values['advertise-subnets'] === 0) {
-            delete values['advertise-subnets'];
-        }
-
-        if (values['exitnodes-local-routing'] === 0) {
-            delete values['exitnodes-local-routing'];
-        }
-
-        if (values['disable-arp-nd-suppression'] === 0) {
-            delete values['disable-arp-nd-suppression'];
-        }
-
-        if (values['exitnodes-primary'] === '') {
-            delete values['exitnodes-primary'];
-        }
-
 	return values;
     },
 
@@ -55,12 +33,13 @@ Ext.define('PVE.sdn.zones.EvpnInputPanel', {
 		allowBlank: false,
 	    },
 	    {
-		xtype: 'textfield',
+		xtype: 'proxmoxtextfield',
 		name: 'mac',
 		fieldLabel: gettext('VNet MAC Address'),
 		vtype: 'MacAddress',
 		allowBlank: true,
 		emptyText: 'auto',
+		deleteEmpty: !me.isCreate,
 	    },
 	    {
 		xtype: 'pveNodeSelector',
@@ -79,29 +58,33 @@ Ext.define('PVE.sdn.zones.EvpnInputPanel', {
 	    {
 		xtype: 'proxmoxcheckbox',
 		name: 'exitnodes-local-routing',
-		uncheckedValue: 0,
+		uncheckedValue: null,
 		checked: false,
 		fieldLabel: gettext('Exit Nodes Local Routing'),
+		deleteEmpty: !me.isCreate,
 	    },
 	    {
 		xtype: 'proxmoxcheckbox',
 		name: 'advertise-subnets',
-		uncheckedValue: 0,
+		uncheckedValue: null,
 		checked: false,
 		fieldLabel: gettext('Advertise Subnets'),
+		deleteEmpty: !me.isCreate,
 	    },
 	    {
 		xtype: 'proxmoxcheckbox',
 		name: 'disable-arp-nd-suppression',
-		uncheckedValue: 0,
+		uncheckedValue: null,
 		checked: false,
 		fieldLabel: gettext('Disable ARP-nd Suppression'),
+		deleteEmpty: !me.isCreate,
 	    },
 	    {
-		xtype: 'textfield',
+		xtype: 'proxmoxtextfield',
 		name: 'rt-import',
 		fieldLabel: gettext('Route Target Import'),
 		allowBlank: true,
+		deleteEmpty: !me.isCreate,
 	    },
 	];
 
diff --git a/www/manager6/sdn/zones/SimpleEdit.js b/www/manager6/sdn/zones/SimpleEdit.js
index 7a6f1d0d9..89bd0031f 100644
--- a/www/manager6/sdn/zones/SimpleEdit.js
+++ b/www/manager6/sdn/zones/SimpleEdit.js
@@ -24,9 +24,10 @@ Ext.define('PVE.sdn.zones.SimpleInputPanel', {
 		xtype: 'proxmoxcheckbox',
 		name: 'dhcp',
 		inputValue: 'dnsmasq',
-		uncheckedValue: undefined,
+		uncheckedValue: null,
 		checked: false,
 		fieldLabel: gettext('automatic DHCP'),
+		deleteEmpty: !me.isCreate,
 	    },
 	];
 
-- 
2.39.2




             reply	other threads:[~2023-11-22 17:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 17:41 Stefan Hanreich [this message]
2023-11-22 18:35 ` [pve-devel] applied: " Thomas Lamprecht
2023-11-23  7:30 ` [pve-devel] " Thomas Lamprecht

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=20231122174105.621179-1-s.hanreich@proxmox.com \
    --to=s.hanreich@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal