1 Ext
.define('PVE.dc.OptionView', {
2 extend
: 'Proxmox.grid.ObjectGrid',
3 alias
: ['widget.pveDcOptionView'],
5 onlineHelp
: 'datacenter_configuration_file',
9 add_inputpanel_row: function(name
, text
, opts
) {
13 me
.rows
= me
.rows
|| {};
15 let canEdit
= !Object
.prototype.hasOwnProperty
.call(opts
, 'caps') || opts
.caps
;
18 defaultValue
: opts
.defaultValue
,
20 renderer
: opts
.renderer
,
22 xtype
: 'proxmoxWindowEdit',
23 width
: opts
.width
|| 350,
25 onlineHelp
: opts
.onlineHelp
,
27 labelWidth
: opts
.labelWidth
|| 100,
29 setValues: function(values
) {
30 var edit_value
= values
[name
];
32 if (opts
.parseBeforeSet
) {
33 edit_value
= PVE
.Parser
.parsePropertyString(edit_value
);
36 Ext
.Array
.each(this.query('inputpanel'), function(panel
) {
37 panel
.setValues(edit_value
);
43 onGetValues: function(values
) {
44 if (values
=== undefined || Object
.keys(values
).length
=== 0) {
45 return { 'delete': name
};
48 ret_val
[name
] = PVE
.Parser
.printPropertyString(values
);
57 render_bwlimits: function(value
) {
59 return gettext("None");
62 let parsed
= PVE
.Parser
.parsePropertyString(value
);
63 return Object
.entries(parsed
)
64 .map(([k
, v
]) => k
+ ": " + Proxmox
.Utils
.format_size(v
* 1024) + "/s")
68 initComponent: function() {
71 me
.add_combobox_row('keyboard', gettext('Keyboard Layout'), {
72 renderer
: PVE
.Utils
.render_kvm_language
,
73 comboItems
: Object
.entries(PVE
.Utils
.kvm_keymaps
),
74 defaultValue
: '__default__',
77 me
.add_text_row('http_proxy', gettext('HTTP proxy'), {
78 defaultValue
: Proxmox
.Utils
.noneText
,
82 me
.add_combobox_row('console', gettext('Console Viewer'), {
83 renderer
: PVE
.Utils
.render_console_viewer
,
84 comboItems
: Object
.entries(PVE
.Utils
.console_map
),
85 defaultValue
: '__default__',
88 me
.add_text_row('email_from', gettext('Email from address'), {
91 defaultValue
: 'root@$hostname',
93 me
.add_text_row('mac_prefix', gettext('MAC address prefix'), {
96 defaultValue
: Proxmox
.Utils
.noneText
,
98 me
.add_inputpanel_row('migration', gettext('Migration Settings'), {
99 renderer
: PVE
.Utils
.render_as_property_string
,
101 url
: "/api2/extjs/cluster/options",
104 xtype
: 'displayfield',
106 fieldLabel
: gettext('Type'),
110 xtype
: 'proxmoxNetworkSelector',
112 fieldLabel
: gettext('Network'),
114 emptyText
: Proxmox
.Utils
.defaultText
,
119 me
.add_inputpanel_row('ha', gettext('HA Settings'), {
120 renderer
: PVE
.Utils
.render_dc_ha_opts
,
122 url
: "/api2/extjs/cluster/options",
123 onlineHelp
: 'ha_manager_shutdown_policy',
125 xtype
: 'proxmoxKVComboBox',
126 name
: 'shutdown_policy',
127 fieldLabel
: gettext('Shutdown Policy'),
129 value
: '__default__',
131 ['__default__', Proxmox
.Utils
.defaultText
+ ' (conditional)'],
132 ['freeze', 'freeze'],
133 ['failover', 'failover'],
134 ['migrate', 'migrate'],
135 ['conditional', 'conditional'],
137 defaultValue
: '__default__',
140 me
.add_inputpanel_row('u2f', gettext('U2F Settings'), {
141 renderer
: v
=> !v
? Proxmox
.Utils
.NoneText
: PVE
.Parser
.printPropertyString(v
),
143 url
: "/api2/extjs/cluster/options",
144 onlineHelp
: 'pveum_configure_u2f',
148 fieldLabel
: gettext('U2F AppID URL'),
149 emptyText
: gettext('Defaults to origin'),
153 submitEmptyText
: false,
157 fieldLabel
: gettext('U2F Origin'),
158 emptyText
: gettext('Defaults to requesting host URI'),
162 submitEmptyText
: false,
167 html
: `<span class='pmx-hint'>${gettext('Note:')}</span> `
168 + Ext
.String
.format(gettext('{0} is deprecated, use {1}'), 'U2F', 'WebAuthn'),
171 xtype
: 'displayfield',
173 value
: gettext('NOTE: Changing an AppID breaks existing U2F registrations!'),
176 me
.add_inputpanel_row('webauthn', gettext('WebAuthn Settings'), {
177 renderer
: v
=> !v
? Proxmox
.Utils
.NoneText
: PVE
.Parser
.printPropertyString(v
),
179 url
: "/api2/extjs/cluster/options",
180 onlineHelp
: 'pveum_configure_webauthn',
183 fieldLabel
: gettext('Name'),
184 name
: 'rp', // NOTE: relying party consists of name and id, this is the name
189 fieldLabel
: gettext('Origin'),
190 emptyText
: Ext
.String
.format(gettext("Domain Lockdown (e.g., {0})"), document
.location
.origin
),
200 dirtychange
: (f
, isDirty
) =>
201 f
.up('panel').down('box[id=idChangeWarning]').setHidden(!f
.originalValue
|| !isDirty
),
214 text
: gettext('Auto-fill'),
215 iconCls
: 'fa fa-fw fa-pencil-square-o',
216 handler: function(button
, ev
) {
217 let panel
= this.up('panel');
218 let fqdn
= document
.location
.hostname
;
220 panel
.down('field[name=rp]').setValue(fqdn
);
222 let idField
= panel
.down('field[name=id]');
223 let currentID
= idField
.getValue();
224 if (!currentID
|| currentID
.length
=== 0) {
225 idField
.setValue(fqdn
);
234 html
: `<span class='pmx-hint'>${gettext('Note:')}</span> `
235 + gettext('WebAuthn requires using a trusted certificate.'),
239 id
: 'idChangeWarning',
242 html
: '<i class="fa fa-exclamation-triangle warning"></i> '
243 + gettext('Changing the ID breaks existing WebAuthn TFA entries.'),
246 me
.add_inputpanel_row('bwlimit', gettext('Bandwidth Limits'), {
247 renderer
: me
.render_bwlimits
,
249 url
: "/api2/extjs/cluster/options",
250 parseBeforeSet
: true,
253 xtype
: 'pveBandwidthField',
255 fieldLabel
: gettext('Default'),
256 emptyText
: gettext('none'),
260 xtype
: 'pveBandwidthField',
262 fieldLabel
: gettext('Backup Restore'),
263 emptyText
: gettext('default'),
267 xtype
: 'pveBandwidthField',
269 fieldLabel
: gettext('Migration'),
270 emptyText
: gettext('default'),
274 xtype
: 'pveBandwidthField',
276 fieldLabel
: gettext('Clone'),
277 emptyText
: gettext('default'),
281 xtype
: 'pveBandwidthField',
283 fieldLabel
: gettext('Disk Move'),
284 emptyText
: gettext('default'),
288 me
.add_integer_row('max_workers', gettext('Maximal Workers/bulk-action'), {
292 maxValue
: 64, // arbitrary but generous limit as limits are good
294 me
.add_inputpanel_row('next-id', gettext('Next Free VMID Range'), {
295 renderer
: PVE
.Utils
.render_as_property_string
,
296 url
: "/api2/extjs/cluster/options",
298 xtype
: 'proxmoxintegerfield',
300 fieldLabel
: gettext('Lower'),
303 maxValue
: 1000 * 1000 * 1000 - 1,
306 xtype
: 'proxmoxintegerfield',
308 fieldLabel
: gettext('Upper'),
309 emptyText
: '1.000.000',
311 maxValue
: 1000 * 1000 * 1000 - 1,
316 me
.selModel
= Ext
.create('Ext.selection.RowModel', {});
320 text
: gettext('Edit'),
321 xtype
: 'proxmoxButton',
323 handler: function() { me
.run_editor(); },
324 selModel
: me
.selModel
,
326 url
: "/api2/json/cluster/options",
328 url
: "/api2/extjs/cluster/options",
333 itemdblclick
: me
.run_editor
,
339 // set the new value for the default console
340 me
.mon(me
.rstore
, 'load', function(store
, records
, success
) {
345 var rec
= store
.getById('console');
346 PVE
.UIOptions
.console
= rec
.data
.value
;
347 if (rec
.data
.value
=== '__default__') {
348 delete PVE
.UIOptions
.console
;
352 me
.on('activate', me
.rstore
.startUpdate
);
353 me
.on('destroy', me
.rstore
.stopUpdate
);
354 me
.on('deactivate', me
.rstore
.stopUpdate
);