ui: sync job: adapt edit window to be used for pull and push

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@proxmox.com>
This commit is contained in:
Christian Ebner 2024-11-11 16:43:49 +01:00 committed by Fabian Grünbichler
parent 262395abaf
commit 9aa213b88e

View File

@ -9,7 +9,7 @@ Ext.define('PBS.window.SyncJobEdit', {
isAdd: true, isAdd: true,
subject: gettext('Sync Job'), subject: gettext('Sync Job - Pull Direction'),
bodyPadding: 0, bodyPadding: 0,
@ -29,6 +29,30 @@ Ext.define('PBS.window.SyncJobEdit', {
me.scheduleValue = id ? null : 'hourly'; me.scheduleValue = id ? null : 'hourly';
me.authid = id ? null : Proxmox.UserName; me.authid = id ? null : Proxmox.UserName;
me.editDatastore = me.datastore === undefined && me.isCreate; 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');
// Sync direction request parameter is only required for creating new jobs,
// for edit and delete it is derived from the job config given by it's id.
if (me.isCreate) {
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 { }; return { };
}, },
@ -118,10 +142,10 @@ Ext.define('PBS.window.SyncJobEdit', {
}, },
}, },
{ {
fieldLabel: gettext('Local Owner'),
xtype: 'pbsAuthidSelector', xtype: 'pbsAuthidSelector',
name: 'owner', name: 'owner',
cbind: { cbind: {
fieldLabel: '{syncLocalOwner}',
value: '{authid}', value: '{authid}',
deleteEmpty: '{!isCreate}', deleteEmpty: '{!isCreate}',
}, },
@ -151,6 +175,9 @@ Ext.define('PBS.window.SyncJobEdit', {
xtype: 'radiogroup', xtype: 'radiogroup',
fieldLabel: gettext('Location'), fieldLabel: gettext('Location'),
defaultType: 'radiofield', defaultType: 'radiofield',
cbind: {
disabled: '{syncDirectionPush}',
},
items: [ items: [
{ {
boxLabel: 'Local', boxLabel: 'Local',
@ -201,7 +228,9 @@ Ext.define('PBS.window.SyncJobEdit', {
}, },
}, },
{ {
fieldLabel: gettext('Source Remote'), cbind: {
fieldLabel: '{syncRemoteLabel}',
},
xtype: 'pbsRemoteSelector', xtype: 'pbsRemoteSelector',
allowBlank: false, allowBlank: false,
name: 'remote', name: 'remote',
@ -222,13 +251,13 @@ Ext.define('PBS.window.SyncJobEdit', {
}, },
}, },
{ {
fieldLabel: gettext('Source Datastore'),
xtype: 'pbsRemoteStoreSelector', xtype: 'pbsRemoteStoreSelector',
allowBlank: false, allowBlank: false,
autoSelect: false, autoSelect: false,
name: 'remote-store', name: 'remote-store',
cbind: { cbind: {
datastore: '{datastore}', datastore: '{datastore}',
fieldLabel: '{syncRemoteDatastore}',
}, },
listeners: { listeners: {
change: function(field, value) { change: function(field, value) {
@ -249,7 +278,9 @@ Ext.define('PBS.window.SyncJobEdit', {
}, },
}, },
{ {
fieldLabel: gettext('Source Namespace'), cbind: {
fieldLabel: '{syncRemoteNamespace}',
},
xtype: 'pbsRemoteNamespaceSelector', xtype: 'pbsRemoteNamespaceSelector',
allowBlank: true, allowBlank: true,
autoSelect: false, autoSelect: false,