public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] ui: guest import: allow setting mac addresses to unique
@ 2024-03-26 13:25 Aaron Lauterer
  2024-03-27 10:26 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Lauterer @ 2024-03-26 13:25 UTC (permalink / raw)
  To: pve-devel

by adding a new checkbox and render the grid accordingly.

If unique MAC addresses are enabled, set them to undefined when getting
the values from the grid.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
not sure if setting `uniqueMac` directly on the component is okay.
Though we do that dynamically for the `vmConfig` as well. So probably
okayish.

 www/manager6/window/GuestImport.js | 39 +++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/www/manager6/window/GuestImport.js b/www/manager6/window/GuestImport.js
index ae9bac5b..aee54706 100644
--- a/www/manager6/window/GuestImport.js
+++ b/www/manager6/window/GuestImport.js
@@ -15,6 +15,8 @@ Ext.define('PVE.window.GuestImport', {
     showTaskViewer: true,
     method: 'POST',
 
+    uniqueMac: false,
+
     loadUrl: function(_url, { storage, nodename, volumeName }) {
 	let args = Ext.Object.toQueryString({ volume: volumeName });
 	return `/nodes/${nodename}/storage/${storage}/import-metadata?${args}`;
@@ -187,6 +189,7 @@ Ext.define('PVE.window.GuestImport', {
 	refreshGrids: function() {
 	    this.lookup('diskGrid').reconfigure();
 	    this.lookup('cdGrid').reconfigure();
+	    this.lookup('netGrid').reconfigure();
 	},
 
 	onOSTypeChange: function(_cb, value) {
@@ -226,6 +229,21 @@ Ext.define('PVE.window.GuestImport', {
 	    me.getView().vmConfig.scsihw = value;
 	},
 
+	onUniqueMacChange: function(_cb, value) {
+	    let me = this;
+	    me.getView().uniqueMac = value;
+
+	    me.refreshGrids();
+	},
+
+	renderMacAddress: function(value, metaData, record, rowIndex, colIndex, store, view) {
+	    let me = this;
+	    if (me.getView().uniqueMac) {
+		return 'auto';
+	    }
+	    return value ? value : 'auto';
+	},
+
 	control: {
 	    'grid field': {
 		// update records from widgetcolumns
@@ -256,6 +274,9 @@ Ext.define('PVE.window.GuestImport', {
 	    'pveScsiHwSelector': {
 		change: 'onScsiHwChange',
 	    },
+	    'proxmoxcheckbox[reference=uniqueMac]': {
+		change: 'onUniqueMacChange',
+	    },
 	},
     },
 
@@ -364,6 +385,9 @@ Ext.define('PVE.window.GuestImport', {
 			    if (!data.bridge) {
 				data.bridge = defaultBridge;
 			    }
+			    if (grid.uniqueMac) {
+				data.macaddr = undefined;
+			    }
 			    config[id] = PVE.Parser.printQemuNetwork(data);
 			});
 
@@ -778,7 +802,7 @@ Ext.define('PVE.window.GuestImport', {
 				    text: gettext('MAC address'),
 				    flex: 1,
 				    dataIndex: 'macaddr',
-				    renderer: value => value ?? 'auto',
+				    renderer: 'renderMacAddress',
 				},
 				{
 				    text: gettext('Model'),
@@ -809,6 +833,19 @@ Ext.define('PVE.window.GuestImport', {
 				},
 			    ],
 			},
+			{
+			    xtype: 'proxmoxcheckbox',
+			    name: 'uniqueMACs',
+			    reference: 'uniqueMac',
+			    labelWidth: 200,
+			    fieldLabel: gettext('Unique MAC addresses'),
+			    uncheckedValue: false,
+			    checked: false,
+			    autoEl: {
+				tag: 'div',
+				'data-qtip': gettext('Generate new unique MAC addresses.'),
+			    },
+			},
 		    ],
 		},
 		{
-- 
2.39.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH manager] ui: guest import: allow setting mac addresses to unique
  2024-03-26 13:25 [pve-devel] [PATCH manager] ui: guest import: allow setting mac addresses to unique Aaron Lauterer
@ 2024-03-27 10:26 ` Thomas Lamprecht
  2024-03-27 10:32   ` Aaron Lauterer
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2024-03-27 10:26 UTC (permalink / raw)
  To: Proxmox VE development discussion, Aaron Lauterer

Am 26/03/2024 um 14:25 schrieb Aaron Lauterer:
> by adding a new checkbox and render the grid accordingly.
> 
> If unique MAC addresses are enabled, set them to undefined when getting
> the values from the grid.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
> not sure if setting `uniqueMac` directly on the component is okay.
> Though we do that dynamically for the `vmConfig` as well. So probably
> okayish.
> 
>  www/manager6/window/GuestImport.js | 39 +++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
>

applied, with a follow-up to rework this using the viewModel for tracking
the state instead of doing that in a config option of the widget, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] applied: [PATCH manager] ui: guest import: allow setting mac addresses to unique
  2024-03-27 10:26 ` [pve-devel] applied: " Thomas Lamprecht
@ 2024-03-27 10:32   ` Aaron Lauterer
  2024-03-27 10:33     ` Thomas Lamprecht
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Lauterer @ 2024-03-27 10:32 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion



On  2024-03-27  11:26, Thomas Lamprecht wrote:
> Am 26/03/2024 um 14:25 schrieb Aaron Lauterer:
>> by adding a new checkbox and render the grid accordingly.
>>
>> If unique MAC addresses are enabled, set them to undefined when getting
>> the values from the grid.
>>
>> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
>> ---
>> not sure if setting `uniqueMac` directly on the component is okay.
>> Though we do that dynamically for the `vmConfig` as well. So probably
>> okayish.
>>
>>   www/manager6/window/GuestImport.js | 39 +++++++++++++++++++++++++++++-
>>   1 file changed, 38 insertions(+), 1 deletion(-)
>>
>>
> 
> applied, with a follow-up to rework this using the viewModel for tracking
> the state instead of doing that in a config option of the widget, thanks!

thanks!

I did choose the 'labelWidth' and 'fieldLabel' to match the look and 
feel of the 'Prepare for Virtio-SCSI" checkbox further up for 
consistency though.

Maybe we want to change that back?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] applied: [PATCH manager] ui: guest import: allow setting mac addresses to unique
  2024-03-27 10:32   ` Aaron Lauterer
@ 2024-03-27 10:33     ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2024-03-27 10:33 UTC (permalink / raw)
  To: Aaron Lauterer, Proxmox VE development discussion

Am 27/03/2024 um 11:32 schrieb Aaron Lauterer:
> I did choose the 'labelWidth' and 'fieldLabel' to match the look and 
> feel of the 'Prepare for Virtio-SCSI" checkbox further up for 
> consistency though.
> 
> Maybe we want to change that back?

No, those are separate grids, it's fine to not have them align all components
100% as they're visually separate anyway.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-27 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 13:25 [pve-devel] [PATCH manager] ui: guest import: allow setting mac addresses to unique Aaron Lauterer
2024-03-27 10:26 ` [pve-devel] applied: " Thomas Lamprecht
2024-03-27 10:32   ` Aaron Lauterer
2024-03-27 10:33     ` Thomas Lamprecht

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