]>
Commit | Line | Data |
---|---|---|
bb4741c7 FE |
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 | ||
6b3dddb0 TL |
15 | viewModel: { |
16 | data: {}, | |
17 | }, | |
18 | ||
9f2b84be FE |
19 | controller: { |
20 | xclass: 'Ext.app.ViewController', | |
21e5ae5b DC |
21 | |
22 | toggleFleecing: function(cb, value) { | |
23 | let me = this; | |
24 | me.lookup('fleecingStorage').setDisabled(!value); | |
25 | }, | |
26 | ||
27 | control: { | |
28 | 'proxmoxcheckbox[reference=fleecingEnabled]': { | |
29 | change: 'toggleFleecing', | |
30 | }, | |
7ad48f3c | 31 | }, |
9f2b84be FE |
32 | }, |
33 | ||
bb4741c7 | 34 | onGetValues: function(formValues) { |
249ac8aa TL |
35 | let me = this; |
36 | if (me.needMask) { // isMasked() may not yet be true if not rendered once | |
bb4741c7 FE |
37 | return {}; |
38 | } | |
39 | ||
249ac8aa TL |
40 | let options = {}; |
41 | ||
42 | if (!me.isCreate) { | |
43 | options.delete = []; // to avoid having to check this all the time | |
44 | } | |
45 | const deletePropertyOnEdit = me.isCreate | |
46 | ? () => { /* no-op on create */ } | |
47 | : key => options.delete.push(key); | |
bb4741c7 | 48 | |
6b3dddb0 | 49 | let fleecing = {}, fleecingOptions = ['fleecing-enabled', 'fleecing-storage']; |
249ac8aa | 50 | let performance = {}, performanceOptions = ['max-workers', 'pbs-entries-max']; |
bb4741c7 FE |
51 | |
52 | for (const [key, value] of Object.entries(formValues)) { | |
53 | if (performanceOptions.includes(key)) { | |
54 | performance[key] = value; | |
55 | // deleteEmpty is not currently implemented for pveBandwidthField | |
56 | } else if (key === 'bwlimit' && value === '') { | |
249ac8aa | 57 | deletePropertyOnEdit('bwlimit'); |
bb4741c7 FE |
58 | } else if (key === 'delete') { |
59 | if (Array.isArray(value)) { | |
60 | value.filter(opt => !performanceOptions.includes(opt)).forEach( | |
249ac8aa | 61 | opt => deletePropertyOnEdit(opt), |
bb4741c7 FE |
62 | ); |
63 | } else if (!performanceOptions.includes(formValues.delete)) { | |
249ac8aa | 64 | deletePropertyOnEdit(value); |
bb4741c7 | 65 | } |
6b3dddb0 TL |
66 | } else if (fleecingOptions.includes(key)) { |
67 | let fleecingKey = key.slice('fleecing-'.length); | |
68 | fleecing[fleecingKey] = value; | |
bb4741c7 FE |
69 | } else { |
70 | options[key] = value; | |
71 | } | |
72 | } | |
73 | ||
74 | if (Object.keys(performance).length > 0) { | |
75 | options.performance = PVE.Parser.printPropertyString(performance); | |
76 | } else { | |
249ac8aa | 77 | deletePropertyOnEdit('performance'); |
bb4741c7 FE |
78 | } |
79 | ||
6b3dddb0 TL |
80 | if (Object.keys(fleecing).length > 0) { |
81 | options.fleecing = PVE.Parser.printPropertyString(fleecing); | |
82 | } else { | |
83 | deletePropertyOnEdit('fleecing'); | |
84 | } | |
85 | ||
86 | if (me.isCreate) { | |
87 | delete options.delete; | |
88 | } | |
89 | ||
bb4741c7 FE |
90 | return options; |
91 | }, | |
92 | ||
6b3dddb0 TL |
93 | onSetValues: function(values) { |
94 | if (values.fleecing) { | |
95 | for (const [key, value] of Object.entries(values.fleecing)) { | |
96 | values[`fleecing-${key}`] = value; | |
97 | } | |
98 | delete values.fleecing; | |
99 | } | |
100 | return values; | |
101 | }, | |
102 | ||
9f2b84be | 103 | updateCompression: function(value, disabled) { |
dddcfc2e | 104 | this.lookup('zstdThreadCount').setDisabled(disabled || value !== 'zstd'); |
9f2b84be FE |
105 | }, |
106 | ||
9486317c | 107 | items: [ |
bb4741c7 | 108 | { |
9486317c DC |
109 | xtype: 'pveTwoColumnContainer', |
110 | startColumn: { | |
111 | xtype: 'pveBandwidthField', | |
112 | name: 'bwlimit', | |
113 | fieldLabel: gettext('Bandwidth Limit'), | |
9e917dd7 | 114 | emptyText: gettext('Fallback'), |
9486317c DC |
115 | backendUnit: 'KiB', |
116 | allowZero: true, | |
117 | emptyValue: '', | |
118 | autoEl: { | |
119 | tag: 'div', | |
120 | 'data-qtip': Ext.String.format(gettext('Use {0} for unlimited'), 0), | |
121 | }, | |
122 | }, | |
123 | endFlex: 2, | |
124 | endColumn: { | |
125 | xtype: 'displayfield', | |
9e917dd7 | 126 | value: `${gettext('Limit I/O bandwidth.')} ${Ext.String.format(gettext("Schema default: {0}"), 0)}`, |
bb4741c7 FE |
127 | }, |
128 | }, | |
129 | { | |
9486317c DC |
130 | xtype: 'pveTwoColumnContainer', |
131 | startColumn: { | |
132 | xtype: 'proxmoxintegerfield', | |
133 | name: 'zstd', | |
134 | reference: 'zstdThreadCount', | |
135 | fieldLabel: Ext.String.format(gettext('{0} Threads'), 'Zstd'), | |
136 | fieldStyle: 'text-align: right', | |
9e917dd7 | 137 | emptyText: gettext('Fallback'), |
9486317c DC |
138 | minValue: 0, |
139 | cbind: { | |
140 | deleteEmpty: '{!isCreate}', | |
141 | }, | |
142 | autoEl: { | |
143 | tag: 'div', | |
144 | 'data-qtip': gettext('With 0, half of the available cores are used'), | |
145 | }, | |
bb4741c7 | 146 | }, |
9486317c DC |
147 | endFlex: 2, |
148 | endColumn: { | |
149 | xtype: 'displayfield', | |
9e917dd7 | 150 | value: `${gettext('Threads used for zstd compression (non-PBS).')} ${Ext.String.format(gettext("Schema default: {0}"), 1)}`, |
bb4741c7 FE |
151 | }, |
152 | }, | |
153 | { | |
9486317c DC |
154 | xtype: 'pveTwoColumnContainer', |
155 | startColumn: { | |
156 | xtype: 'proxmoxintegerfield', | |
157 | name: 'max-workers', | |
158 | minValue: 1, | |
159 | maxValue: 256, | |
160 | fieldLabel: gettext('IO-Workers'), | |
161 | fieldStyle: 'text-align: right', | |
9e917dd7 | 162 | emptyText: gettext('Fallback'), |
9486317c DC |
163 | cbind: { |
164 | deleteEmpty: '{!isCreate}', | |
165 | }, | |
166 | }, | |
167 | endFlex: 2, | |
168 | endColumn: { | |
169 | xtype: 'displayfield', | |
9e917dd7 | 170 | value: `${gettext('I/O workers in the QEMU process (VMs only).')} ${Ext.String.format(gettext("Schema default: {0}"), 16)}`, |
bb4741c7 FE |
171 | }, |
172 | }, | |
6b3dddb0 TL |
173 | { |
174 | xtype: 'pveTwoColumnContainer', | |
175 | startColumn: { | |
176 | xtype: 'proxmoxcheckbox', | |
177 | name: 'fleecing-enabled', | |
178 | reference: 'fleecingEnabled', | |
179 | fieldLabel: gettext('Fleecing'), | |
180 | uncheckedValue: 0, | |
181 | value: 0, | |
182 | }, | |
183 | endFlex: 2, | |
184 | endColumn: { | |
185 | xtype: 'displayfield', | |
186 | value: gettext('Backup write cache that can reduce IO pressure inside guests (VMs only).'), | |
187 | }, | |
188 | }, | |
189 | { | |
190 | xtype: 'pveTwoColumnContainer', | |
191 | startColumn: { | |
192 | xtype: 'pveStorageSelector', | |
193 | name: 'fleecing-storage', | |
194 | fieldLabel: gettext('Fleecing Storage'), | |
21e5ae5b | 195 | reference: 'fleecingStorage', |
6b3dddb0 TL |
196 | clusterView: true, |
197 | storageContent: 'images', | |
198 | allowBlank: false, | |
569b0388 | 199 | disabled: true, |
6b3dddb0 TL |
200 | }, |
201 | endFlex: 2, | |
202 | endColumn: { | |
203 | xtype: 'displayfield', | |
204 | value: gettext('Prefer a fast and local storage, ideally with support for discard and thin-provisioning or sparse files.'), | |
205 | }, | |
206 | }, | |
bb4741c7 FE |
207 | { |
208 | // It's part of the 'performance' property string, so have a field to preserve the | |
209 | // value, but don't expose it. It's a rather niche setting and difficult to | |
210 | // convey/understand what it does. | |
211 | xtype: 'proxmoxintegerfield', | |
212 | name: 'pbs-entries-max', | |
213 | hidden: true, | |
214 | fieldLabel: 'TODO', | |
215 | fieldStyle: 'text-align: right', | |
5abdd1e4 | 216 | emptyText: 'TODO', |
bb4741c7 FE |
217 | cbind: { |
218 | deleteEmpty: '{!isCreate}', | |
219 | }, | |
220 | }, | |
1d777a46 | 221 | { |
9486317c DC |
222 | xtype: 'pveTwoColumnContainer', |
223 | startColumn: { | |
224 | xtype: 'proxmoxcheckbox', | |
225 | fieldLabel: gettext('Repeat missed'), | |
226 | name: 'repeat-missed', | |
227 | uncheckedValue: 0, | |
228 | defaultValue: 0, | |
229 | cbind: { | |
230 | deleteDefaultValue: '{!isCreate}', | |
231 | }, | |
232 | }, | |
233 | endFlex: 2, | |
234 | endColumn: { | |
235 | xtype: 'displayfield', | |
236 | value: gettext("Run jobs as soon as possible if they couldn't start on schedule, for example, due to the node being offline."), | |
1d777a46 FE |
237 | }, |
238 | }, | |
bb4741c7 FE |
239 | { |
240 | xtype: 'component', | |
bb4741c7 | 241 | padding: '5 1', |
a32a5c4a | 242 | html: `<span class="pmx-hint">${gettext('Note')}</span>: ${ |
9e917dd7 | 243 | gettext("The node-specific 'vzdump.conf' or, if this is not set, the default from the config schema is used to determine fallback values.")}`, |
bb4741c7 FE |
244 | }, |
245 | ], | |
246 | }); |