throw "no VM type specified";
}
- let compressionSelector = Ext.create('PVE.form.CompressionSelector', {
+ let compressionSelector = Ext.create('PVE.form.BackupCompressionSelector', {
name: 'compress',
value: 'zstd',
fieldLabel: gettext('Compression'),
emptyText: Proxmox.Utils.noneText,
});
+ let notificationModeSelector = Ext.create({
+ xtype: 'proxmoxKVComboBox',
+ comboItems: [
+ ['auto', gettext('Auto')],
+ ['legacy-sendmail', gettext('Email (legacy)')],
+ ['notification-system', gettext('Notification system')],
+ ],
+ fieldLabel: gettext('Notification mode'),
+ name: 'notification-mode',
+ value: 'auto',
+ listeners: {
+ change: function(field, value) {
+ mailtoField.setDisabled(value === 'notification-system');
+ },
+ },
+ });
+
const keepNames = [
- 'keep-last',
- 'keep-hourly',
- 'keep-daily',
- 'keep-weekly',
- 'keep-monthly',
- 'keep-yearly',
+ ['keep-last', gettext('Keep Last')],
+ ['keep-hourly', gettext('Keep Hourly')],
+ ['keep-daily', gettext('Keep Daily')],
+ ['keep-weekly', gettext('Keep Weekly')],
+ ['keep-monthly', gettext('Keep Monthly')],
+ ['keep-yearly', gettext('Keep Yearly')],
];
let pruneSettings = keepNames.map(
name => Ext.create('Ext.form.field.Display', {
- name: name,
- fieldLabel: gettext(name),
+ name: name[0],
+ fieldLabel: name[1],
hidden: true,
- disabled: true,
}),
);
'data-qtip': gettext('Prune older backups afterwards'),
},
handler: function(checkbox, value) {
- pruneSettings.forEach(field => field.setDisabled(!value));
+ pruneSettings.forEach(field => field.setHidden(!value));
+ me.down('label[name="pruneLabel"]').setHidden(!value);
},
});
allowBlank: false,
listeners: {
change: function(f, v) {
+ if (!initialDefaults) {
+ me.setLoading(false);
+ }
+
+ if (v === null || v === undefined || v === '') {
+ return;
+ }
+
let store = f.getStore();
let rec = store.findRecord('storage', v, 0, false, true, true);
if (!initialDefaults && data.mailto !== undefined) {
mailtoField.setValue(data.mailto);
}
+ if (!initialDefaults && data['notification-mode'] !== undefined) {
+ notificationModeSelector.setValue(data['notification-mode']);
+ }
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;
const keep = keepParams[field.name];
if (keep) {
field.setValue(keep);
- field.setHidden(false);
} else {
field.reset();
- field.setHidden(true);
}
});
return;
// no defaults or keep-all=1
removeCheckbox.setHidden(true);
removeCheckbox.setValue(false);
- pruneSettings.forEach(function(field) {
- field.reset();
- field.setHidden(true);
- });
+ pruneSettings.forEach(field => field.reset());
},
failure: function(response, opts) {
+ initialDefaults = true;
+
+ removeCheckbox.setHidden(true);
+ removeCheckbox.setValue(false);
+ pruneSettings.forEach(field => field.reset());
+
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
});
},
},
});
- storagesel.setValue(me.storage);
- me.formPanel = Ext.create('Ext.form.Panel', {
+ 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,
- fieldDefaults: {
- labelWidth: 100,
- anchor: '100%',
- },
- items: [
+ column1: [
storagesel,
modeSelector,
+ protectedCheckbox,
+ ],
+ column2: [
compressionSelector,
+ notificationModeSelector,
mailtoField,
removeCheckbox,
- ].concat(pruneSettings),
+ ],
+ 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',
+ text: gettext('Storage Retention Configuration') + ':',
+ hidden: true,
+ },
+ {
+ layout: 'hbox',
+ border: false,
+ defaults: {
+ border: false,
+ layout: 'anchor',
+ flex: 1,
+ },
+ items: [
+ {
+ padding: '0 10 0 0',
+ defaults: {
+ labelWidth: 110,
+ },
+ items: [
+ pruneSettings[0],
+ pruneSettings[2],
+ pruneSettings[4],
+ ],
+ },
+ {
+ padding: '0 0 0 10',
+ defaults: {
+ labelWidth: 110,
+ },
+ items: [
+ pruneSettings[1],
+ pruneSettings[3],
+ pruneSettings[5],
+ ],
+ },
+ ],
+ },
+ ],
});
- var form = me.formPanel.getForm();
-
var submitBtn = Ext.create('Ext.Button', {
text: gettext('Backup'),
handler: function() {
var storage = storagesel.getValue();
- var values = form.getValues();
+ let values = me.formPanel.getValues();
var params = {
storage: storage,
vmid: me.vmid,
params.mailto = values.mailto;
}
+ if (values['notification-mode']) {
+ params['notification-mode'] = values['notification-mode'];
+ }
+
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,
Ext.apply(me, {
title: title,
- width: 350,
modal: true,
layout: 'auto',
border: false,
+ width: 600,
items: [me.formPanel],
buttons: [helpBtn, '->', submitBtn],
+ listeners: {
+ afterrender: function() {
+ /// cleared within the storage selector's change listener
+ me.setLoading(gettext('Please wait...'));
+ storagesel.setValue(me.storage);
+ },
+ },
});
me.callParent();