From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id A9B741FF173
	for <inbox@lore.proxmox.com>; Mon, 10 Mar 2025 18:02:20 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 7E33E1F1BA;
	Mon, 10 Mar 2025 18:02:12 +0100 (CET)
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Mon, 10 Mar 2025 18:01:24 +0100
Message-Id: <20250310170125.528732-1-c.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.029 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] fix: ui: sync job: switch
 rate limit based on sync direction
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

Commit 9aa213b8 ("config: sync: use same config section type `sync`
for push and pull") adapted the sync job edit so jobs in both, push
and pull can be edited using the same window. This however did not
include the switching of the direction to which the http client rate
limit is applied to.

Fix this by renaming the field to `rate-limit` and  conditionally
settings the values to `rate-in` or `rate-out`.

Reported in the community forum:
https://forum.proxmox.com/threads/163414/

Fixes: 9aa213b8 ("config: sync: use same config section type `sync` for push and pull")
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 www/window/SyncJobEdit.js | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
index bcd2f2fb2..f980a2efd 100644
--- a/www/window/SyncJobEdit.js
+++ b/www/window/SyncJobEdit.js
@@ -86,6 +86,13 @@ Ext.define('PBS.window.SyncJobEdit', {
 	} else {
 	    values.location = 'remote';
 	}
+	if (values['rate-out'] && me.syncDirection === 'push') {
+	    values['rate-limit'] = values['rate-out'];
+	    delete values['rate-out'];
+	} else if (values['rate-in']) {
+	    values['rate-limit'] = values['rate-in'];
+	    delete values['rate-in'];
+	}
 	me.callParent([values]);
     },
 
@@ -103,8 +110,15 @@ Ext.define('PBS.window.SyncJobEdit', {
 		    if (!values.id && me.up('pbsSyncJobEdit').isCreate) {
 			values.id = 's-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 13);
 		    }
+		    if (values['rate-limit'] && me.syncDirection === 'push') {
+			values['rate-out'] = values['rate-limit'];
+		    } else {
+			values['rate-in'] = values['rate-limit'];
+		    }
+		    delete values['rate-limit'];
 		    if (!me.isCreate) {
 			PBS.Utils.delete_if_default(values, 'rate-in');
+			PBS.Utils.delete_if_default(values, 'rate-out');
 			PBS.Utils.delete_if_default(values, 'remote');
 			if (typeof values.delete === 'string') {
 			    values.delete = values.delete.split(',');
@@ -185,7 +199,7 @@ Ext.define('PBS.window.SyncJobEdit', {
 		    },
 		    {
 			xtype: 'pmxBandwidthField',
-			name: 'rate-in',
+			name: 'rate-limit',
 			fieldLabel: gettext('Rate Limit'),
 			emptyText: gettext('Unlimited'),
 			submitAutoScaledSizeUnit: true,
@@ -221,7 +235,7 @@ Ext.define('PBS.window.SyncJobEdit', {
 				let me = this;
 				let form = me.up('pbsSyncJobEdit');
 				let nsField = form.down('field[name=remote-ns]');
-				let rateLimitField = form.down('field[name=rate-in]');
+				let rateLimitField = form.down('field[name=rate-limit]');
 				let remoteField = form.down('field[name=remote]');
 				let storeField = form.down('field[name=remote-store]');
 
@@ -263,7 +277,7 @@ Ext.define('PBS.window.SyncJobEdit', {
 				let me = this;
 				let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
 				remoteStoreField.setRemote(value);
-				let rateLimitField = me.up('pbsSyncJobEdit').down('field[name=rate-in]');
+				let rateLimitField = me.up('pbsSyncJobEdit').down('field[name=rate-limit]');
 				rateLimitField.setDisabled(!value);
 				if (!value) {
 				    rateLimitField.setValue(null);
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel