]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/panel/BackupAdvancedOptions.js
ui: backup job: rework assembling deleted keys + style fixes
[pve-manager.git] / www / manager6 / panel / BackupAdvancedOptions.js
1 /*
2 * Input panel for advanced backup options intended to be used as part of an edit/create window.
3 */
4 Ext.define('PVE.panel.BackupAdvancedOptions', {
5 extend: 'Proxmox.panel.InputPanel',
6 xtype: 'pveBackupAdvancedOptionsPanel',
7 mixins: ['Proxmox.Mixin.CBind'],
8
9 cbindData: function() {
10 let me = this;
11 me.isCreate = !!me.isCreate;
12 return {};
13 },
14
15 controller: {
16 xclass: 'Ext.app.ViewController',
17 },
18
19 onGetValues: function(formValues) {
20 let me = this;
21 if (me.needMask) { // isMasked() may not yet be true if not rendered once
22 return {};
23 }
24
25 let options = {};
26
27 if (!me.isCreate) {
28 options.delete = []; // to avoid having to check this all the time
29 }
30 const deletePropertyOnEdit = me.isCreate
31 ? () => { /* no-op on create */ }
32 : key => options.delete.push(key);
33
34 let performance = {}, performanceOptions = ['max-workers', 'pbs-entries-max'];
35
36 for (const [key, value] of Object.entries(formValues)) {
37 if (performanceOptions.includes(key)) {
38 performance[key] = value;
39 // deleteEmpty is not currently implemented for pveBandwidthField
40 } else if (key === 'bwlimit' && value === '') {
41 deletePropertyOnEdit('bwlimit');
42 } else if (key === 'delete') {
43 if (Array.isArray(value)) {
44 value.filter(opt => !performanceOptions.includes(opt)).forEach(
45 opt => deletePropertyOnEdit(opt),
46 );
47 } else if (!performanceOptions.includes(formValues.delete)) {
48 deletePropertyOnEdit(value);
49 }
50 } else {
51 options[key] = value;
52 }
53 }
54
55 if (Object.keys(performance).length > 0) {
56 options.performance = PVE.Parser.printPropertyString(performance);
57 } else {
58 deletePropertyOnEdit('performance');
59 }
60
61 return options;
62 },
63
64 updateCompression: function(value, disabled) {
65 this.lookup('zstdThreadCount').setDisabled(disabled || value !== 'zstd');
66 },
67
68 items: [
69 {
70 xtype: 'pveTwoColumnContainer',
71 startColumn: {
72 xtype: 'pveBandwidthField',
73 name: 'bwlimit',
74 fieldLabel: gettext('Bandwidth Limit'),
75 emptyText: gettext('Fallback'),
76 backendUnit: 'KiB',
77 allowZero: true,
78 emptyValue: '',
79 autoEl: {
80 tag: 'div',
81 'data-qtip': Ext.String.format(gettext('Use {0} for unlimited'), 0),
82 },
83 },
84 endFlex: 2,
85 endColumn: {
86 xtype: 'displayfield',
87 value: `${gettext('Limit I/O bandwidth.')} ${Ext.String.format(gettext("Schema default: {0}"), 0)}`,
88 },
89 },
90 {
91 xtype: 'pveTwoColumnContainer',
92 startColumn: {
93 xtype: 'proxmoxintegerfield',
94 name: 'zstd',
95 reference: 'zstdThreadCount',
96 fieldLabel: Ext.String.format(gettext('{0} Threads'), 'Zstd'),
97 fieldStyle: 'text-align: right',
98 emptyText: gettext('Fallback'),
99 minValue: 0,
100 cbind: {
101 deleteEmpty: '{!isCreate}',
102 },
103 autoEl: {
104 tag: 'div',
105 'data-qtip': gettext('With 0, half of the available cores are used'),
106 },
107 },
108 endFlex: 2,
109 endColumn: {
110 xtype: 'displayfield',
111 value: `${gettext('Threads used for zstd compression (non-PBS).')} ${Ext.String.format(gettext("Schema default: {0}"), 1)}`,
112 },
113 },
114 {
115 xtype: 'pveTwoColumnContainer',
116 startColumn: {
117 xtype: 'proxmoxintegerfield',
118 name: 'max-workers',
119 minValue: 1,
120 maxValue: 256,
121 fieldLabel: gettext('IO-Workers'),
122 fieldStyle: 'text-align: right',
123 emptyText: gettext('Fallback'),
124 cbind: {
125 deleteEmpty: '{!isCreate}',
126 },
127 },
128 endFlex: 2,
129 endColumn: {
130 xtype: 'displayfield',
131 value: `${gettext('I/O workers in the QEMU process (VMs only).')} ${Ext.String.format(gettext("Schema default: {0}"), 16)}`,
132 },
133 },
134 {
135 // It's part of the 'performance' property string, so have a field to preserve the
136 // value, but don't expose it. It's a rather niche setting and difficult to
137 // convey/understand what it does.
138 xtype: 'proxmoxintegerfield',
139 name: 'pbs-entries-max',
140 hidden: true,
141 fieldLabel: 'TODO',
142 fieldStyle: 'text-align: right',
143 emptyText: 'TODO',
144 cbind: {
145 deleteEmpty: '{!isCreate}',
146 },
147 },
148 {
149 xtype: 'pveTwoColumnContainer',
150 startColumn: {
151 xtype: 'proxmoxcheckbox',
152 fieldLabel: gettext('Repeat missed'),
153 name: 'repeat-missed',
154 uncheckedValue: 0,
155 defaultValue: 0,
156 cbind: {
157 deleteDefaultValue: '{!isCreate}',
158 },
159 },
160 endFlex: 2,
161 endColumn: {
162 xtype: 'displayfield',
163 value: gettext("Run jobs as soon as possible if they couldn't start on schedule, for example, due to the node being offline."),
164 },
165 },
166 {
167 xtype: 'component',
168 padding: '5 1',
169 html: `<span class="pmx-hint">${gettext('Note')}</span>: ${
170 gettext("The node-specific 'vzdump.conf' or, if this is not set, the default from the config schema is used to determine fallback values.")}`,
171 },
172 ],
173 });