* [pve-devel] [PATCH manager] ui: storage: pbs: allow to set port
@ 2021-02-03 10:59 Stoiko Ivanov
0 siblings, 0 replies; only message in thread
From: Stoiko Ivanov @ 2021-02-03 10:59 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-02-03 11:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 10:59 [pve-devel] [PATCH manager] ui: storage: pbs: allow to set port Stoiko Ivanov
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