]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/dc/Backup.js
close #4513: ui: backup job: add tab for advanced options
[pve-manager.git] / www / manager6 / dc / Backup.js
index 03a026513a3ef9de94c25e2241f994a9f41dcb45..7024df6c355d998de19f9f1dcabf74ec9a218a27 100644 (file)
@@ -36,6 +36,14 @@ Ext.define('PVE.dc.BackupEdit', {
                delete values.node;
            }
 
+           // Get rid of new-old parameters for notification settings.
+           // These should only be set for those selected few who ran
+           // pve-manager from pvetest.
+           if (!isCreate) {
+               Proxmox.Utils.assemble_field_data(values, { 'delete': 'notification-policy' });
+               Proxmox.Utils.assemble_field_data(values, { 'delete': 'notification-target' });
+           }
+
            if (!values.id && isCreate) {
                values.id = 'backup-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 13);
            }
@@ -146,6 +154,16 @@ Ext.define('PVE.dc.BackupEdit', {
                    success: function(response, _options) {
                        let data = response.result.data;
 
+                       // Migrate 'new'-old notification-policy back to
+                       // old-old mailnotification. Only should affect
+                       // users who used pve-manager from pvetest.
+                       // This was a remnant of notifications before the
+                       // overhaul.
+                       let policy = data['notification-policy'];
+                       if (policy === 'always' || policy === 'failure') {
+                           data.mailnotification = policy;
+                       }
+
                        if (data.exclude) {
                            data.vmid = data.exclude;
                            data.selMode = 'exclude';
@@ -178,6 +196,11 @@ Ext.define('PVE.dc.BackupEdit', {
                                PVE.Utils.unEscapeNotesTemplate(data['notes-template']);
                        }
 
+                       if (data.performance) {
+                           Object.assign(data, data.performance);
+                           delete data.performance;
+                       }
+
                        view.setValues(data);
                    },
                });
@@ -188,11 +211,14 @@ Ext.define('PVE.dc.BackupEdit', {
     viewModel: {
        data: {
            selMode: 'include',
+           notificationMode: '__default__',
        },
 
        formulas: {
            poolMode: (get) => get('selMode') === 'pool',
            disableVMSelection: (get) => get('selMode') !== 'include' && get('selMode') !== 'exclude',
+           showMailtoFields: (get) =>
+               ['auto', 'legacy-sendmail', '__default__'].includes(get('notificationMode')),
        },
     },
 
@@ -283,21 +309,49 @@ Ext.define('PVE.dc.BackupEdit', {
                            ],
                            column2: [
                                {
-                                   xtype: 'textfield',
-                                   fieldLabel: gettext('Send email to'),
-                                   name: 'mailto',
+                                   xtype: 'proxmoxKVComboBox',
+                                   comboItems: [
+                                       [
+                                           '__default__',
+                                           Ext.String.format(
+                                               gettext('{0} (Auto)'), Proxmox.Utils.defaultText,
+                                           ),
+                                       ],
+                                       ['auto', gettext('Auto')],
+                                       ['legacy-sendmail', gettext('Email (legacy)')],
+                                       ['notification-system', gettext('Notification system')],
+                                   ],
+                                   fieldLabel: gettext('Notification mode'),
+                                   name: 'notification-mode',
+                                   cbind: {
+                                       deleteEmpty: '{!isCreate}',
+                                   },
+                                   bind: {
+                                       value: '{notificationMode}',
+                                   },
                                },
                                {
                                    xtype: 'pveEmailNotificationSelector',
-                                   fieldLabel: gettext('Email'),
+                                   fieldLabel: gettext('Send email'),
                                    name: 'mailnotification',
                                    cbind: {
                                        value: (get) => get('isCreate') ? 'always' : '',
                                        deleteEmpty: '{!isCreate}',
                                    },
+                                   bind: {
+                                       disabled: '{!showMailtoFields}',
+                                   },
+                               },
+                               {
+                                   xtype: 'textfield',
+                                   fieldLabel: gettext('Send email to'),
+                                   name: 'mailto',
+                                   bind: {
+                                       disabled: '{!showMailtoFields}',
+                                   },
                                },
                                {
-                                   xtype: 'pveCompressionSelector',
+                                   xtype: 'pveBackupCompressionSelector',
                                    reference: 'compressionSelector',
                                    fieldLabel: gettext('Compression'),
                                    name: 'compress',
@@ -417,6 +471,13 @@ Ext.define('PVE.dc.BackupEdit', {
                        },
                    ],
                },
+               {
+                   xtype: 'pveBackupAdvancedOptionsPanel',
+                   title: gettext('Advanced'),
+                   cbind: {
+                       isCreate: '{isCreate}',
+                   },
+               },
            ],
        },
     ],
@@ -466,11 +527,13 @@ Ext.define('PVE.dc.BackupView', {
                return;
            }
 
-           let win = Ext.create('PVE.dc.BackupEdit', {
+           Ext.create('PVE.dc.BackupEdit', {
+               autoShow: true,
                jobid: rec.data.id,
+               listeners: {
+                   destroy: () => reload(),
+               },
            });
-           win.on('destroy', reload);
-           win.show();
        };
 
        let run_detail = function() {
@@ -722,8 +785,7 @@ Ext.define('PVE.dc.BackupView', {
                    width: 80,
                    dataIndex: 'enabled',
                    align: 'center',
-                   // TODO: switch to Proxmox.Utils.renderEnabledIcon once available
-                   renderer: enabled => `<i class="fa fa-${enabled ? 'check' : 'minus'}"></i>`,
+                   renderer: Proxmox.Utils.renderEnabledIcon,
                    sortable: true,
                },
                {