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 8AE7874991 for ; Mon, 11 Oct 2021 11:52:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 82A731D1B0 for ; Mon, 11 Oct 2021 11:52:06 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 533011D1A5 for ; Mon, 11 Oct 2021 11:52:05 +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 2C5AF45C98 for ; Mon, 11 Oct 2021 11:52:05 +0200 (CEST) From: Lorenz Stechauner To: pve-devel@lists.proxmox.com Date: Mon, 11 Oct 2021 11:52:00 +0200 Message-Id: <20211011095200.700466-1-l.stechauner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.401 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pve-devel] [PATCH v2 manager] ui: storage/PBSEdit: add port to server field 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: Mon, 11 Oct 2021 09:52:06 -0000 this gives users the chance to supply the port nr in the gui, without having to add a extra new field to the panel. using the same implementation as in RemoteEdit.js in PBS. Signed-off-by: Lorenz Stechauner --- www/manager6/storage/PBSEdit.js | 58 ++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/www/manager6/storage/PBSEdit.js b/www/manager6/storage/PBSEdit.js index fcbc9548..b273a465 100644 --- a/www/manager6/storage/PBSEdit.js +++ b/www/manager6/storage/PBSEdit.js @@ -453,17 +453,67 @@ Ext.define('PVE.storage.PBSInputPanel', { }, ], + setValues: function(values) { + let me = this; + + let server = values.server; + if (values.port !== undefined) { + if (Proxmox.Utils.IP6_match.test(server)) { + server = `[${server}]`; + } + server += `:${values.port}`; + } + values.hostport = server; + + return me.callParent([values]); + }, + initComponent: function() { var me = this; me.column1 = [ { - xtype: me.isCreate ? 'textfield' : 'displayfield', - name: 'server', - value: '', - vtype: 'DnsOrIp', + xtype: me.isCreate ? 'proxmoxtextfield' : 'displayfield', fieldLabel: gettext('Server'), allowBlank: false, + name: 'hostport', + submitValue: false, + vtype: 'HostPort', + listeners: { + change: function(field, newvalue) { + let server = newvalue; + let port; + + let match = Proxmox.Utils.HostPort_match.exec(newvalue); + if (match === null) { + match = Proxmox.Utils.HostPortBrackets_match.exec(newvalue); + if (match === null) { + match = Proxmox.Utils.IP6_dotnotation_match.exec(newvalue); + } + } + + if (match !== null) { + server = match[1]; + if (match[2] !== undefined) { + port = match[2]; + } + } + + field.up('inputpanel').down('field[name=server]').setValue(server); + field.up('inputpanel').down('field[name=port]').setValue(port); + }, + }, + }, + { + xtype: 'proxmoxtextfield', + hidden: true, + name: 'server', + }, + { + xtype: 'proxmoxtextfield', + hidden: true, + deleteEmpty: !me.isCreate, + name: 'port', }, { xtype: me.isCreate ? 'textfield' : 'displayfield', -- 2.30.2