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.laute...@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 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel