[pbs-devel] [RFC proxmox-backup 24/24] www: sync edit: allow to set sync direction for sync jobs

Christian Ebner c.ebner at proxmox.com
Mon Jul 15 12:16:02 CEST 2024


Adds a radio button which allows to set the sync direction when
creating/editing a sync job.

Forces to provide a remote in case of push direction and switch
fetching of the groups for selection in filters from remote to
local.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 www/window/SyncJobEdit.js | 60 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
index 6543995e8..6b291cdb4 100644
--- a/www/window/SyncJobEdit.js
+++ b/www/window/SyncJobEdit.js
@@ -144,6 +144,57 @@ Ext.define('PBS.window.SyncJobEdit', {
 			submitAutoScaledSizeUnit: true,
 			// NOTE: handle deleteEmpty in onGetValues due to bandwidth field having a cbind too
 		    },
+		    {
+			xtype: 'radiogroup',
+			fieldLabel: gettext('Sync Direction'),
+			defaultType: 'radiofield',
+			items: [
+			    {
+				boxLabel: 'Pull',
+				name: 'sync-direction',
+				inputValue: 'pull',
+				checked: true,
+			    },
+			    {
+				boxLabel: 'Push',
+				name: 'sync-direction',
+				inputValue: 'push',
+			    },
+			],
+			listeners: {
+			    change: function(_group, radio) {
+				let me = this;
+				let form = me.up('pbsSyncJobEdit');
+				let remoteField = form.down('field[name=remote]');
+				let remoteNsField = form.down('field[name=remote-ns]');
+				let remoteStoreField = form.down('field[name=remote-store]');
+				let locationField = form.down('field[name=location]');
+				let groupFilter = form.down('pbsGroupFilter');
+
+				let isSyncDirectionPull = radio['sync-direction'] === 'pull';
+				locationField.setDisabled(!isSyncDirectionPull);
+
+				if (isSyncDirectionPull) {
+				    remoteField.setFieldLabel(gettext("Source Remote"));
+				    remoteNsField.setFieldLabel(gettext("Source Namespace"));
+				    remoteStoreField.setFieldLabel(gettext("Source Store"));
+				    let remote = remoteField.getValue();
+				    let remoteStore = remoteStoreField.getValue();
+				    let remoteNs = remoteNsField.getValue();
+				    groupFilter.setRemoteNamespace(remote, remoteStore, remoteNs);
+				} else {
+				    remoteField.setDisabled(false);
+				    remoteField.setFieldLabel(gettext("Target Remote"));
+				    remoteNsField.setFieldLabel(gettext("Target Namespace"));
+				    remoteStoreField.setFieldLabel(gettext("Target Store"));
+				    locationField.setValue("remote");
+				    let localStore = form.down('field[name=store]').getValue();
+				    let localNamespace = form.down('field[name=ns]').getValue();
+				    groupFilter.setLocalNamespace(localStore, localNamespace);
+				}
+			    },
+			},
+		    },
 		],
 
 		column2: [
@@ -238,7 +289,14 @@ Ext.define('PBS.window.SyncJobEdit', {
 				let remoteNamespaceField = me.up('pbsSyncJobEdit').down('field[name=remote-ns]');
 				remoteNamespaceField.setRemote(remote);
 				remoteNamespaceField.setRemoteStore(value);
-				me.up('tabpanel').down('pbsGroupFilter').setRemoteDatastore(remote, value);
+
+				let syncDirection = me.up('pbsSyncJobEdit').down('field[name=sync-direction]').getValue();
+				if (syncDirection === 'pull') {
+				    me.up('tabpanel').down('pbsGroupFilter').setRemoteDatastore(remote, value);
+				} else {
+				    let localStore = me.up('pbsSyncJobEdit').down('field[name=store]').getValue();
+				    me.up('tabpanel').down('pbsGroupFilter').setLocalDatastore(localStore);
+				}
 			    },
 			},
 		    },
-- 
2.39.2





More information about the pbs-devel mailing list