]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/window/Settings.js
set the default console in the gui when setting the option
[pve-manager.git] / www / manager6 / window / Settings.js
CommitLineData
ce11a8af
DC
1Ext.define('PVE.window.Settings', {
2 extend: 'Ext.window.Window',
3
4 width: '400px',
5 title: gettext('My Settings'),
6 iconCls: 'fa fa-gear',
7 modal: true,
8 bodyPadding: 10,
9 resizable: false,
10
11 buttons: [{
12 text: gettext('Close'),
13 handler: function() {
14 this.up('window').close();
15 }
16 }],
17
18 layout: {
19 type: 'vbox',
20 align: 'center'
21 },
22
23 controller: {
24 xclass: 'Ext.app.ViewController',
25
26 control: {
27 '#': {
28 show: function() {
29 var me = this;
30 var sp = Ext.state.Manager.getProvider();
31
e7ade592 32 var username = sp.get('login-username') || Proxmox.Utils.noneText;
ce11a8af
DC
33 me.lookupReference('savedUserName').setValue(username);
34 }
35 },
36 'button[name=reset]': {
37 click: function () {
2488c226 38 var blacklist = ['GuiCap', 'login-username', 'dash-storages'];
ce11a8af
DC
39 var sp = Ext.state.Manager.getProvider();
40 var state;
41 for (state in sp.state) {
42 if (sp.state.hasOwnProperty(state)) {
43 if (blacklist.indexOf(state) !== -1) {
44 continue;
45 }
46
47 sp.clear(state);
48 }
49 }
50
51 window.location.reload();
52 }
53 },
54 'button[name=clear-username]': {
55 click: function () {
56 var me = this;
57 var usernamefield = me.lookupReference('savedUserName');
58 var sp = Ext.state.Manager.getProvider();
59
e7ade592 60 usernamefield.setValue(Proxmox.Utils.noneText);
ce11a8af
DC
61 sp.clear('login-username');
62 }
2488c226
DC
63 },
64 'grid[reference=dashboard-storages]': {
65 selectionchange: function(grid, selected) {
66 var me = this;
67 var sp = Ext.state.Manager.getProvider();
68
69 // saves the selected storageids as
70 // "id1,id2,id3,..."
71 // or clears the variable
72 if (selected.length > 0) {
73 sp.set('dash-storages',
74 Ext.Array.pluck(selected, 'id').join(','));
75 } else {
76 sp.clear('dash-storages');
77 }
78 },
79 afterrender: function(grid) {
80 var me = grid;
81 var sp = Ext.state.Manager.getProvider();
82 var store = me.getStore();
83 var items = [];
84 me.suspendEvent('selectionchange');
85 var storages = sp.get('dash-storages') || '';
86 storages.split(',').forEach(function(storage){
87 // we have to get the records
88 // to be able to select them
89 if (storage !== '') {
90 var item = store.getById(storage);
91 if (item) {
92 items.push(item);
93 }
94 }
95 });
96 me.getSelectionModel().select(items);
97 me.resumeEvent('selectionchange');
98 }
ce11a8af
DC
99 }
100 }
101 },
102
103 items: [{
104 xtype: 'fieldset',
105 width: '90%',
106 title: gettext('Browser Settings'),
107 layout: {
108 type: 'vbox',
61516423 109 align: 'left'
ce11a8af
DC
110 },
111 defaults: {
112 width: '100%',
113 margin: '0 0 10 0'
114 },
115 items: [
2488c226
DC
116 {
117 xtype: 'displayfield',
118 fieldLabel: gettext('Dashboard Storages'),
119 labelAlign: 'left',
120 labelWidth: '50%'
121 },
122 {
123 xtype: 'grid',
124 maxHeight: 150,
125 reference: 'dashboard-storages',
126 selModel: {
127 selType: 'checkboxmodel'
128 },
129 columns: [{
130 header: gettext('Name'),
131 dataIndex: 'storage',
132 flex: 1
133 },{
134 header: gettext('Node'),
135 dataIndex: 'node',
136 flex: 1
137 }],
138 store: {
139 type: 'diff',
140 field: ['type', 'storage', 'id', 'node'],
141 rstore: PVE.data.ResourceStore,
142 filters: [{
143 property: 'type',
144 value: 'storage'
145 }],
146 sorters: [ 'node','storage']
147 }
148 },
149 {
150 xtype: 'box',
151 autoEl: { tag: 'hr'}
152 },
ce11a8af
DC
153 {
154 xtype: 'displayfield',
155 fieldLabel: gettext('Saved User name'),
156 labelAlign: 'left',
157 labelWidth: '50%',
ce11a8af
DC
158 stateId: 'login-username',
159 reference: 'savedUserName',
160 value: ''
161 },
162 {
163 xtype: 'button',
672a6270 164 cls: 'x-btn-default-toolbar-small proxmox-inline-button',
ce11a8af
DC
165 text: gettext('Clear User name'),
166 width: 'auto',
167 name: 'clear-username'
168 },
169 {
170 xtype: 'box',
171 autoEl: { tag: 'hr'}
172 },
173 {
174 xtype: 'displayfield',
175 fieldLabel: gettext('Layout'),
176 labelAlign: 'left',
177 labelWidth: '50%'
178 },
179 {
180 xtype: 'button',
672a6270 181 cls: 'x-btn-default-toolbar-small proxmox-inline-button',
ce11a8af
DC
182 text: gettext('Reset Layout'),
183 width: 'auto',
184 name: 'reset'
185 }
186 ]
187 }],
188
189 onShow: function() {
190 var me = this;
191 me.callParent();
192
193 }
194});