[pbs-devel] [PATCH v3 proxmox-backup 25/33] ui: sync job: adapt edit window to be used for pull and push

Christian Ebner c.ebner at proxmox.com
Thu Sep 12 16:33:14 CEST 2024


Switch the subject and labels to be shown based on the direction of
the sync job, and set the `sync-direction` parameter from the
submit values in case of push direction.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 2:
- switch owner label based on jobs sync direction

 www/window/SyncJobEdit.js | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
index 9ca79eaa9..b3aa06057 100644
--- a/www/window/SyncJobEdit.js
+++ b/www/window/SyncJobEdit.js
@@ -9,7 +9,7 @@ Ext.define('PBS.window.SyncJobEdit', {
 
     isAdd: true,
 
-    subject: gettext('Sync Job'),
+    subject: gettext('Sync Job - Pull Direction'),
 
     bodyPadding: 0,
 
@@ -29,6 +29,26 @@ Ext.define('PBS.window.SyncJobEdit', {
 	me.scheduleValue = id ? null : 'hourly';
 	me.authid = id ? null : Proxmox.UserName;
 	me.editDatastore = me.datastore === undefined && me.isCreate;
+
+	if (me.syncDirection === 'push') {
+	    me.subject = gettext('Sync Job - Push Direction');
+	    me.syncDirectionPush = true;
+	    me.syncRemoteLabel = gettext('Target Remote');
+	    me.syncRemoteDatastore = gettext('Target Datastore');
+	    me.syncRemoteNamespace = gettext('Target Namespace');
+	    me.syncLocalOwner = gettext('Local User');
+	    me.extraRequestParams = {
+		"sync-direction": 'push',
+	    };
+	} else {
+	    me.subject = gettext('Sync Job - Pull Direction');
+	    me.syncDirectionPush = false;
+	    me.syncRemoteLabel = gettext('Source Remote');
+	    me.syncRemoteDatastore = gettext('Source Datastore');
+	    me.syncRemoteNamespace = gettext('Source Namespace');
+	    me.syncLocalOwner = gettext('Local Owner');
+	}
+
 	return { };
     },
 
@@ -118,10 +138,10 @@ Ext.define('PBS.window.SyncJobEdit', {
 			},
 		    },
 		    {
-			fieldLabel: gettext('Local Owner'),
 			xtype: 'pbsAuthidSelector',
 			name: 'owner',
 			cbind: {
+			    fieldLabel: '{syncLocalOwner}',
 			    value: '{authid}',
 			    deleteEmpty: '{!isCreate}',
 			},
@@ -151,6 +171,9 @@ Ext.define('PBS.window.SyncJobEdit', {
 			xtype: 'radiogroup',
 			fieldLabel: gettext('Location'),
 			defaultType: 'radiofield',
+			cbind: {
+			    disabled: '{syncDirectionPush}',
+			},
 			items: [
 			    {
 				boxLabel: 'Local',
@@ -201,7 +224,9 @@ Ext.define('PBS.window.SyncJobEdit', {
 			},
 		    },
 		    {
-			fieldLabel: gettext('Source Remote'),
+			cbind: {
+			    fieldLabel: '{syncRemoteLabel}',
+			},
 			xtype: 'pbsRemoteSelector',
 			allowBlank: false,
 			name: 'remote',
@@ -222,13 +247,13 @@ Ext.define('PBS.window.SyncJobEdit', {
 			},
 		    },
 		    {
-			fieldLabel: gettext('Source Datastore'),
 			xtype: 'pbsRemoteStoreSelector',
 			allowBlank: false,
 			autoSelect: false,
 			name: 'remote-store',
 			cbind: {
 			    datastore: '{datastore}',
+			    fieldLabel: '{syncRemoteDatastore}',
 			},
 			listeners: {
 			    change: function(field, value) {
@@ -249,7 +274,9 @@ Ext.define('PBS.window.SyncJobEdit', {
 			},
 		    },
 		    {
-			fieldLabel: gettext('Source Namespace'),
+			cbind: {
+			    fieldLabel: '{syncRemoteNamespace}',
+			},
 			xtype: 'pbsRemoteNamespaceSelector',
 			allowBlank: true,
 			autoSelect: false,
-- 
2.39.2





More information about the pbs-devel mailing list