From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B3C9F91184 for ; Wed, 3 Apr 2024 12:10:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 94646157D1 for ; Wed, 3 Apr 2024 12:10:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 3 Apr 2024 12:10:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5790C44CE0 for ; Wed, 3 Apr 2024 12:10:16 +0200 (CEST) From: Christian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 3 Apr 2024 12:10:01 +0200 Message-Id: <20240403101001.182389-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [record.id] Subject: [pve-devel] [PATCH pve-manager] ui: node: extend option editor for wake on lan X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2024 10:10:17 -0000 Commit 3f83a0332ef5850c7b2324ca5958fa9b4b4dd61c switched the nodes `wakeonlan` configuration parameter to be a property string and the subsequent patches added bind-interface and broadcast-address as additional optional parameters. Make this editable in the node options, by adding a dedicated editor component. The editor is used for the wake on lan record of the grid only, by adding the `handle_editor` function, to calls the required editor based on the selected record of the grid. Signed-off-by: Christian Ebner --- www/manager6/node/NodeOptionsView.js | 87 +++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/www/manager6/node/NodeOptionsView.js b/www/manager6/node/NodeOptionsView.js index 661c0e90..6a9e3826 100644 --- a/www/manager6/node/NodeOptionsView.js +++ b/www/manager6/node/NodeOptionsView.js @@ -1,3 +1,55 @@ +Ext.define('PVE.node.WakeOnLanEdit', { + extend: 'Proxmox.window.Edit', + xtype: 'pveNodeWakeOnLanEdit', + + subject: gettext('Wake on LAN settings'), + width: 350, + + items: [ + { + xtype: 'textfield', + name: 'mac', + fieldLabel: gettext('MAC address'), + labelWidth: 130, + vtype: 'MacAddress', + }, + { + xtype: 'textfield', + name: 'bind-interface', + fieldLabel: gettext('Bind interface'), + labelWidth: 130, + }, + { + xtype: 'textfield', + name: 'broadcast-address', + fieldLabel: gettext('Broadcast address'), + labelWidth: 130, + vtype: 'IPAddress', + }, + ], + + getValues: function() { + let me = this; + let wolConfig = { + mac: me.down('textfield[name=mac]').getValue(), + "bind-interface": me.down('textfield[name=bind-interface]').getValue(), + "broadcast-address": me.down('textfield[name=broadcast-address]').getValue(), + }; + let wolString = PVE.Parser.printPropertyString(wolConfig, 'mac'); + return { wakeonlan: wolString }; + }, + + setValues: function(values) { + let me = this; + if (values.wakeonlan) { + let wolConfig = PVE.Parser.parsePropertyString(values.wakeonlan, 'mac'); + Ext.Object.each(wolConfig, function(name, value) { + me.down('textfield[name=' + name + ']').setValue(value); + }); + } + }, +}); + Ext.define('Proxmox.node.NodeOptionsView', { extend: 'Proxmox.grid.ObjectGrid', alias: ['widget.proxmoxNodeOptionsView'], @@ -15,8 +67,26 @@ Ext.define('Proxmox.node.NodeOptionsView', { return {}; }, + handle_editor: function() { + let me = this; + var selection_model = me.getSelectionModel(); + let record = selection_model.getSelection()[0]; + if (record.id === 'wakeonlan') { + let baseUrl = `/nodes/${me.nodename}/config`; + Ext.create('PVE.node.WakeOnLanEdit', { + url: `/api2/extjs/${baseUrl}`, + autoLoad: true, + listeners: { + destroy: function() { me.reload(); }, + }, + }).show(); + } else { + me.run_editor(); + } + }, + listeners: { - itemdblclick: function() { this.run_editor(); }, + itemdblclick: function() { this.handle_editor(); }, activate: function() { this.rstore.startUpdate(); }, destroy: function() { this.rstore.stopUpdate(); }, deactivate: function() { this.rstore.stopUpdate(); }, @@ -27,7 +97,7 @@ Ext.define('Proxmox.node.NodeOptionsView', { text: gettext('Edit'), xtype: 'proxmoxButton', disabled: true, - handler: btn => btn.up('grid').run_editor(), + handler: btn => btn.up('grid').handle_editor(), }, ], @@ -52,17 +122,8 @@ Ext.define('Proxmox.node.NodeOptionsView', { { xtype: 'text', name: 'wakeonlan', - text: gettext('MAC address for Wake on LAN'), - vtype: 'MacAddress', - labelWidth: 150, - deleteEmpty: true, - renderer: function(value) { - if (value === undefined) { - return Proxmox.Utils.NoneText; - } - - return value; - }, + text: gettext('Wake on LAN settings'), + defaultValue: Proxmox.Utils.noneText, }, ], }); -- 2.39.2