From: Lorenz Stechauner <l.stechauner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager] ui: storage/PBSEdit: add port to server field
Date: Mon, 11 Oct 2021 11:52:00 +0200 [thread overview]
Message-ID: <20211011095200.700466-1-l.stechauner@proxmox.com> (raw)
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 <l.stechauner@proxmox.com>
---
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
next reply other threads:[~2021-10-11 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 9:52 Lorenz Stechauner [this message]
2021-10-28 13:59 ` [pve-devel] applie: " Dominik Csapak
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=20211011095200.700466-1-l.stechauner@proxmox.com \
--to=l.stechauner@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