]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/window/Settings.js
1 Ext
.define('PVE.window.Settings', {
2 extend
: 'Ext.window.Window',
5 title
: gettext('My Settings'),
13 xtype
: 'proxmoxHelpButton',
14 onlineHelp
: 'gui_my_settings',
19 text
: gettext('Close'),
21 this.up('window').close();
29 xclass
: 'Ext.app.ViewController',
31 init: function(view
) {
33 var sp
= Ext
.state
.Manager
.getProvider();
35 var username
= sp
.get('login-username') || Proxmox
.Utils
.noneText
;
36 me
.lookupReference('savedUserName').setValue(Ext
.String
.htmlEncode(username
));
37 var vncMode
= sp
.get('novnc-scaling');
38 if (vncMode
!== undefined) {
39 me
.lookupReference('noVNCScalingGroup').setValue({ noVNCScalingField
: vncMode
});
42 let summarycolumns
= sp
.get('summarycolumns', 'auto');
43 me
.lookup('summarycolumns').setValue(summarycolumns
);
45 me
.lookup('guestNotesCollapse').setValue(sp
.get('guest-notes-collapse', 'never'));
47 var settings
= ['fontSize', 'fontFamily', 'letterSpacing', 'lineHeight'];
48 settings
.forEach(function(setting
) {
49 var val
= localStorage
.getItem('pve-xterm-' + setting
);
50 if (val
!== undefined && val
!== null) {
51 var field
= me
.lookup(setting
);
53 field
.resetOriginalValue();
58 set_button_status: function() {
61 var form
= me
.lookup('xtermform');
62 var valid
= form
.isValid();
63 var dirty
= form
.isDirty();
65 var hasvalues
= false;
66 var values
= form
.getValues();
67 Ext
.Object
.eachValue(values
, function(value
) {
74 me
.lookup('xtermsave').setDisabled(!dirty
|| !valid
);
75 me
.lookup('xtermreset').setDisabled(!hasvalues
);
80 dirtychange
: 'set_button_status',
81 validitychange
: 'set_button_status',
84 click: function(button
) {
86 var settings
= ['fontSize', 'fontFamily', 'letterSpacing', 'lineHeight'];
87 settings
.forEach(function(setting
) {
88 var field
= me
.lookup(setting
);
89 if (button
.reference
=== 'xtermsave') {
90 var value
= field
.getValue();
92 localStorage
.setItem('pve-xterm-' + setting
, value
);
94 localStorage
.removeItem('pve-xterm-' + setting
);
96 } else if (button
.reference
=== 'xtermreset') {
97 field
.setValue(undefined);
98 localStorage
.removeItem('pve-xterm-' + setting
);
100 field
.resetOriginalValue();
102 me
.set_button_status();
105 'button[name=reset]': {
107 var blacklist
= ['GuiCap', 'login-username', 'dash-storages'];
108 var sp
= Ext
.state
.Manager
.getProvider();
110 for (state
in sp
.state
) {
111 if (sp
.state
.hasOwnProperty(state
)) {
112 if (blacklist
.indexOf(state
) !== -1) {
120 window
.location
.reload();
123 'button[name=clear-username]': {
126 var usernamefield
= me
.lookupReference('savedUserName');
127 var sp
= Ext
.state
.Manager
.getProvider();
129 usernamefield
.setValue(Proxmox
.Utils
.noneText
);
130 sp
.clear('login-username');
133 'grid[reference=dashboard-storages]': {
134 selectionchange: function(grid
, selected
) {
136 var sp
= Ext
.state
.Manager
.getProvider();
138 // saves the selected storageids as
140 // or clears the variable
141 if (selected
.length
> 0) {
142 sp
.set('dash-storages',
143 Ext
.Array
.pluck(selected
, 'id').join(','));
145 sp
.clear('dash-storages');
148 afterrender: function(grid
) {
150 var sp
= Ext
.state
.Manager
.getProvider();
151 var store
= me
.getStore();
153 me
.suspendEvent('selectionchange');
154 var storages
= sp
.get('dash-storages') || '';
155 storages
.split(',').forEach(function(storage
) {
156 // we have to get the records
157 // to be able to select them
158 if (storage
!== '') {
159 var item
= store
.getById(storage
);
165 me
.getSelectionModel().select(items
);
166 me
.resumeEvent('selectionchange');
169 'field[reference=summarycolumns]': {
170 change: function(el
, newValue
) {
171 var sp
= Ext
.state
.Manager
.getProvider();
172 sp
.set('summarycolumns', newValue
);
175 'field[reference=guestNotesCollapse]': {
176 change: function(e
, v
) {
177 Ext
.state
.Manager
.getProvider().set('guest-notes-collapse', v
);
186 title
: gettext('Webinterface Settings'),
198 xtype
: 'displayfield',
199 fieldLabel
: gettext('Dashboard Storages'),
206 reference
: 'dashboard-storages',
208 selType
: 'checkboxmodel',
211 header
: gettext('Name'),
212 dataIndex
: 'storage',
215 header
: gettext('Node'),
221 field
: ['type', 'storage', 'id', 'node'],
222 rstore
: PVE
.data
.ResourceStore
,
227 sorters
: ['node', 'storage'],
232 autoEl
: { tag
: 'hr' },
239 xtype
: 'displayfield',
240 fieldLabel
: gettext('Saved User Name') + ':',
242 stateId
: 'login-username',
243 reference
: 'savedUserName',
249 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
250 text
: gettext('Reset'),
251 name
: 'clear-username',
257 autoEl
: { tag
: 'hr' },
264 xtype
: 'displayfield',
265 fieldLabel
: gettext('Layout') + ':',
270 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
271 text
: gettext('Reset'),
272 tooltip
: gettext('Reset all layout changes (for example, column widths)'),
279 autoEl
: { tag
: 'hr' },
282 xtype
: 'proxmoxKVComboBox',
283 fieldLabel
: gettext('Summary columns') + ':',
285 stateId
: 'summarycolumns',
286 reference
: 'summarycolumns',
295 xtype
: 'proxmoxKVComboBox',
296 fieldLabel
: gettext('Guest Notes') + ':',
298 stateId
: 'guest-notes-collapse',
299 reference
: 'guestNotesCollapse',
301 ['never', 'Show by default'],
302 ['always', 'Collapse by default'],
303 ['auto', 'auto (Collapse if empty)'],
315 // right margin ensures that the right border of the fieldsets
323 title
: gettext('xterm.js Settings'),
326 reference
: 'xtermform',
340 reference
: 'fontFamily',
341 emptyText
: Proxmox
.Utils
.defaultText
,
342 fieldLabel
: gettext('Font-Family'),
345 xtype
: 'proxmoxintegerfield',
346 emptyText
: Proxmox
.Utils
.defaultText
,
348 reference
: 'fontSize',
350 fieldLabel
: gettext('Font-Size'),
353 xtype
: 'numberfield',
354 name
: 'letterSpacing',
355 reference
: 'letterSpacing',
356 emptyText
: Proxmox
.Utils
.defaultText
,
357 fieldLabel
: gettext('Letter Spacing'),
360 xtype
: 'numberfield',
363 reference
: 'lineHeight',
364 emptyText
: Proxmox
.Utils
.defaultText
,
365 fieldLabel
: gettext('Line Height'),
379 reference
: 'xtermreset',
381 text
: gettext('Reset'),
385 reference
: 'xtermsave',
387 text
: gettext('Save'),
395 title
: gettext('noVNC Settings'),
399 fieldLabel
: gettext('Scaling mode'),
400 reference
: 'noVNCScalingGroup',
401 height
: '15px', // renders faster with value assigned
408 name
: 'noVNCScalingField',
410 boxLabel
: 'Local Scaling',
414 name
: 'noVNCScalingField',
421 change: function(el
, newValue
, undefined) {
422 var sp
= Ext
.state
.Manager
.getProvider();
423 sp
.set('novnc-scaling', newValue
.noVNCScalingField
);