]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #5337: ui: parse a port in the server field
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Mar 2024 17:06:34 +0000 (18:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Mar 2024 17:07:31 +0000 (18:07 +0100)
Based on how we handle this for PBS but without the hidden fields,
which do not really make this simpler, at least not if the logic is
only required on creation due to the field being only editable then.

As example, if the port of the ESXi host would be 8080, one would
enter `192.168.1.2:8080` for an IPv4 address or `[2001:db8::42]:8443`
for an IPv6 one.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/storage/ESXIEdit.js

index b105b1e3893f98973fe02903e316bdd9847f99c7..f665ca975bbff96081399689b56038659dbddd29 100644 (file)
@@ -1,6 +1,21 @@
 Ext.define('PVE.storage.ESXIInputPanel', {
     extend: 'PVE.panel.StorageBase',
 
+    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.server = server;
+
+       return me.callParent([values]);
+    },
+
     onGetValues: function(values) {
        let me = this;
 
@@ -11,6 +26,23 @@ Ext.define('PVE.storage.ESXIInputPanel', {
            delete values.username;
        }
 
+       if (me.isCreate) {
+           let serverPortMatch = Proxmox.Utils.HostPort_match.exec(values.server);
+           if (serverPortMatch === null) {
+               serverPortMatch = Proxmox.Utils.HostPortBrackets_match.exec(values.server);
+               if (serverPortMatch === null) {
+                   serverPortMatch = Proxmox.Utils.IP6_dotnotation_match.exec(values.server);
+               }
+           }
+
+           if (serverPortMatch !== null) {
+               values.server = serverPortMatch[1];
+               if (serverPortMatch[2] !== undefined) {
+                   values.port = serverPortMatch[2];
+               }
+           }
+       }
+
        return me.callParent([values]);
     },