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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3E96E6CEFB for ; Wed, 3 Feb 2021 12:00:37 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 22C2B19679 for ; Wed, 3 Feb 2021 12:00:07 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 62DD319670 for ; Wed, 3 Feb 2021 12:00:06 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 19B004616A for ; Wed, 3 Feb 2021 12:00:06 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Wed, 3 Feb 2021 11:59:55 +0100 Message-Id: <20210203105955.12252-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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 manager] ui: storage: pbs: allow to set port 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 Feb 2021 11:00:37 -0000 This patch allows to set a custom port to a PBS storage, by appending it to the Server field (e.g. pbs.proxmox.com:443). The code was taken from the RemoteEdit widget in the proxmox-backup repository. While the storage config stores the port as separate line, the current approach seems a bit more concise and does not mess up the balanced layout. Quickly tested on my setup. Signed-off-by: Stoiko Ivanov --- Thanks to Dominik for pointing me to the RemoteEdit.js! www/manager6/storage/PBSEdit.js | 57 +++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/www/manager6/storage/PBSEdit.js b/www/manager6/storage/PBSEdit.js index 2479304a..45f35c76 100644 --- a/www/manager6/storage/PBSEdit.js +++ b/www/manager6/storage/PBSEdit.js @@ -463,11 +463,49 @@ Ext.define('PVE.storage.PBSInputPanel', { me.column1 = [ { xtype: me.isCreate ? 'textfield' : 'displayfield', - name: 'server', + name: 'serverport', value: '', - vtype: 'DnsOrIp', + vtype: 'HostPort', + submitValue: false, fieldLabel: gettext('Server'), allowBlank: false, + 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, + cbind: { + deleteEmpty: '{!isCreate}', + }, + name: 'port', }, { xtype: me.isCreate ? 'textfield' : 'displayfield', @@ -522,4 +560,19 @@ Ext.define('PVE.storage.PBSInputPanel', { me.callParent(); }, + + 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.serverport = server; + + return me.callParent([values]); + }, }); -- 2.20.1