all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: storage: pbs: allow to set port
Date: Wed,  3 Feb 2021 11:59:55 +0100	[thread overview]
Message-ID: <20210203105955.12252-1-s.ivanov@proxmox.com> (raw)

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 <s.ivanov@proxmox.com>
---
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





                 reply	other threads:[~2021-02-03 11:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210203105955.12252-1-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal