]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: backup: allow to set notification-target for one-off backups
authorLukas Wagner <l.wagner@proxmox.com>
Thu, 3 Aug 2023 12:17:06 +0000 (14:17 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 16 Aug 2023 09:11:15 +0000 (11:11 +0200)
In essence the same change as for backup jobs.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
www/manager6/window/Backup.js

index 4b21c746ce987a06bc2a64834b3baa30660c211f..17a37e1293f0a72553f7dafd6d59f1ace01eadf1 100644 (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;
                }