ui: backup: allow to set notification-target for one-off backups

In essence the same change as for backup jobs.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
Lukas Wagner 2023-08-03 14:17:06 +02:00 committed by Wolfgang Bumiller
parent 3be4491221
commit d7e1976810

View File

@ -30,12 +30,32 @@ Ext.define('PVE.window.Backup', {
name: 'mode',
});
let notificationTargetSelector = Ext.create('PVE.form.NotificationTargetSelector', {
fieldLabel: gettext('Notification target'),
name: 'notification-target',
emptyText: Proxmox.Utils.noneText,
hidden: true,
});
let mailtoField = Ext.create('Ext.form.field.Text', {
fieldLabel: gettext('Send email to'),
name: 'mailto',
emptyText: Proxmox.Utils.noneText,
});
let notificationModeSelector = Ext.create('PVE.form.NotificationModeSelector', {
fieldLabel: gettext('Notify via'),
value: 'mailto',
name: 'notification-mode',
listeners: {
change: function(f, v) {
let mailSelected = v === 'mailto';
notificationTargetSelector.setHidden(mailSelected);
mailtoField.setHidden(!mailSelected);
},
},
});
const keepNames = [
['keep-last', gettext('Keep Last')],
['keep-hourly', gettext('Keep Hourly')],
@ -107,6 +127,12 @@ Ext.define('PVE.window.Backup', {
success: function(response, opts) {
const data = response.result.data;
if (!initialDefaults && data['notification-mode'] !== undefined) {
notificationModeSelector.setValue(data['notification-mode']);
}
if (!initialDefaults && data['notification-channel'] !== undefined) {
notificationTargetSelector.setValue(data['notification-channel']);
}
if (!initialDefaults && data.mailto !== undefined) {
mailtoField.setValue(data.mailto);
}
@ -176,6 +202,8 @@ Ext.define('PVE.window.Backup', {
],
column2: [
compressionSelector,
notificationModeSelector,
notificationTargetSelector,
mailtoField,
removeCheckbox,
],
@ -252,10 +280,15 @@ Ext.define('PVE.window.Backup', {
remove: values.remove,
};
if (values.mailto) {
if (values.mailto && values['notification-mode'] === 'mailto') {
params.mailto = values.mailto;
}
if (values['notification-target'] &&
values['notification-mode'] === 'notification-target') {
params['notification-target'] = values['notification-target'];
}
if (values.compress) {
params.compress = values.compress;
}