]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/Backup.js
ui: avoid trivial decompression widget, only used once
[pve-manager.git] / www / manager6 / window / Backup.js
index 726122c8d6fe4e6e2443fba3b20106e10b5b09a5..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,12 +127,23 @@ 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);
                            }
                            if (!initialDefaults && data.mode !== undefined) {
                                modeSelector.setValue(data.mode);
                            }
+                           if (!initialDefaults && (data['notes-template'] ?? false)) {
+                               me.down('field[name=notes-template]').setValue(
+                                   PVE.Utils.unEscapeNotesTemplate(data['notes-template']),
+                               );
+                           }
 
                            initialDefaults = true;
 
@@ -154,19 +185,47 @@ Ext.define('PVE.window.Backup', {
            },
        });
 
+       let protectedCheckbox = Ext.create('Proxmox.form.Checkbox', {
+           name: 'protected',
+           checked: false,
+           uncheckedValue: 0,
+           fieldLabel: gettext('Protected'),
+       });
+
        me.formPanel = Ext.create('Proxmox.panel.InputPanel', {
            bodyPadding: 10,
            border: false,
            column1: [
                storagesel,
                modeSelector,
-               removeCheckbox,
+               protectedCheckbox,
            ],
            column2: [
                compressionSelector,
+               notificationModeSelector,
+               notificationTargetSelector,
                mailtoField,
+               removeCheckbox,
            ],
            columnB: [
+               {
+                   xtype: 'textareafield',
+                   name: 'notes-template',
+                   fieldLabel: gettext('Notes'),
+                   anchor: '100%',
+                   value: '{{guestname}}',
+               },
+               {
+                   xtype: 'box',
+                   style: {
+                       margin: '8px 0px',
+                       'line-height': '1.5em',
+                   },
+                   html: Ext.String.format(
+                       gettext('Possible template variables are: {0}'),
+                       PVE.Utils.notesTemplateVars.map(v => `<code>{{${v}}}</code>`).join(', '),
+                   ),
+               },
                {
                    xtype: 'label',
                    name: 'pruneLabel',
@@ -221,14 +280,28 @@ 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;
                }
 
+               if (values.protected) {
+                   params.protected = values.protected;
+               }
+
+               if (values['notes-template']) {
+                   params['notes-template'] = PVE.Utils.escapeNotesTemplate(
+                       values['notes-template']);
+               }
+
                Proxmox.Utils.API2Request({
                    url: '/nodes/' + me.nodename + '/vzdump',
                    params: params,
@@ -272,6 +345,7 @@ Ext.define('PVE.window.Backup', {
            modal: true,
            layout: 'auto',
            border: false,
+           width: 600,
            items: [me.formPanel],
            buttons: [helpBtn, '->', submitBtn],
            listeners: {