[pve-devel] [PATCH v5 pve-manager 17/30] ui: backup: allow to set notification-target for one-off backups

Lukas Wagner l.wagner at proxmox.com
Wed Jul 26 11:49:49 CEST 2023


In essence the same change as for backup jobs.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 www/manager6/window/Backup.js | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js
index 4b21c746..17a37e12 100644
--- a/www/manager6/window/Backup.js
+++ b/www/manager6/window/Backup.js
@@ -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;
 		}
-- 
2.39.2






More information about the pve-devel mailing list