]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/Workspace.js
4 * popup login window when auth fails (call onLogin handler)
5 * update (re-login) ticket every 15 minutes
9 Ext
.define('PVE.Workspace', {
10 extend
: 'Ext.container.Viewport',
12 title
: 'Proxmox Virtual Environment',
14 loginData
: null, // Data from last login call
16 onLogin: function(loginData
) {},
19 updateLoginData: function(loginData
) {
21 me
.loginData
= loginData
;
22 Proxmox
.Utils
.setAuthData(loginData
);
24 var rt
= me
.down('pveResourceTree');
25 rt
.setDatacenterText(loginData
.clustername
);
28 Ext
.state
.Manager
.set('GuiCap', loginData
.cap
);
31 me
.onLogin(loginData
);
35 showLogin: function() {
38 Proxmox
.Utils
.authClear();
39 Proxmox
.UserName
= null;
43 me
.login
= Ext
.create('PVE.window.LoginWindow', {
44 handler: function(data
) {
46 me
.updateLoginData(data
);
47 Proxmox
.Utils
.checked_command(function() {}); // display subscription status
55 initComponent : function() {
58 Ext
.tip
.QuickTipManager
.init();
60 // fixme: what about other errors
61 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
62 if (response
.status
== 401 && !PVE
.Utils
.silenceAuthFailures
) { // auth failure
69 if (!Proxmox
.Utils
.authOK()) {
73 me
.onLogin(me
.loginData
);
77 Ext
.TaskManager
.start({
79 var ticket
= Proxmox
.Utils
.authOK();
80 if (!ticket
|| !Proxmox
.UserName
) {
86 username
: Proxmox
.UserName
,
89 url
: '/api2/json/access/ticket',
91 success: function(response
, opts
) {
92 var obj
= Ext
.decode(response
.responseText
);
93 me
.updateLoginData(obj
.data
);
103 Ext
.define('PVE.StdWorkspace', {
104 extend
: 'PVE.Workspace',
106 alias
: ['widget.pveStdWorkspace'],
109 setContent: function(comp
) {
112 var cont
= me
.child('#content');
114 var lay
= cont
.getLayout();
116 var cur
= lay
.getActiveItem();
119 Proxmox
.Utils
.setErrorMask(cont
, false);
122 if (cur
!== null && lay
.getNext()) {
124 var task
= Ext
.create('Ext.util.DelayedTask', function(){
131 // helper for cleaning the content when logging out
136 selectById: function(nodeid
) {
138 var tree
= me
.down('pveResourceTree');
139 tree
.selectById(nodeid
);
142 onLogin: function(loginData
) {
148 PVE
.data
.ResourceStore
.startUpdate();
150 Proxmox
.Utils
.API2Request({
153 success: function(response
) {
154 PVE
.VersionInfo
= response
.result
.data
;
155 me
.updateVersionInfo();
161 updateUserInfo: function() {
163 var ui
= me
.query('#userinfo')[0];
164 ui
.setText(Proxmox
.UserName
|| '');
168 updateVersionInfo: function() {
171 var ui
= me
.query('#versioninfo')[0];
173 if (PVE
.VersionInfo
) {
174 var version
= PVE
.VersionInfo
.version
;
175 ui
.update('Virtual Environment ' + version
);
177 ui
.update('Virtual Environment');
182 initComponent : function() {
187 var sprovider
= Ext
.create('PVE.StateProvider');
188 Ext
.state
.Manager
.setProvider(sprovider
);
190 var selview
= Ext
.create('PVE.form.ViewSelector');
192 var rtree
= Ext
.createWidget('pveResourceTree', {
193 viewFilter
: selview
.getViewFilter(),
196 selType
: 'treemodel',
198 selectionchange: function(sm
, selected
) {
199 if (selected
.length
> 0) {
202 root
: 'PVE.dc.Config',
203 node
: 'PVE.node.Config',
204 qemu
: 'PVE.qemu.Config',
205 lxc
: 'PVE.lxc.Config',
206 storage
: 'PVE.storage.Browser',
207 pool
: 'pvePoolConfig'
210 xtype
: tlckup
[n
.data
.type
|| 'root'] ||
212 showSearch
: (n
.data
.id
=== 'root') ||
213 Ext
.isDefined(n
.data
.groupbyid
),
216 viewFilter
: selview
.getViewFilter()
218 PVE
.curSelectedNode
= n
;
226 selview
.on('select', function(combo
, records
) {
228 var view
= combo
.getViewFilter();
229 rtree
.setViewFilter(view
);
233 var caps
= sprovider
.get('GuiCap');
235 var createVM
= Ext
.createWidget('button', {
239 iconCls
: 'fa fa-desktop',
240 text
: gettext("Create VM"),
241 disabled
: !caps
.vms
['VM.Allocate'],
242 handler: function() {
243 var wiz
= Ext
.create('PVE.qemu.CreateWizard', {});
248 var createCT
= Ext
.createWidget('button', {
252 iconCls
: 'fa fa-cube',
253 text
: gettext("Create CT"),
254 disabled
: !caps
.vms
['VM.Allocate'],
255 handler: function() {
256 var wiz
= Ext
.create('PVE.lxc.CreateWizard', {});
261 sprovider
.on('statechange', function(sp
, key
, value
) {
262 if (key
=== 'GuiCap' && value
) {
264 createVM
.setDisabled(!caps
.vms
['VM.Allocate']);
265 createCT
.setDisabled(!caps
.vms
['VM.Allocate']);
270 layout
: { type
: 'border' },
287 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
288 '<img style="padding-top:4px;padding-right:5px" src="/pve2/images/proxmox_logo.png"/></a>'
293 html
: 'Virtual Environment'
297 html
: '<a href="https://bugzilla.proxmox.com" target="_blank">BETA</a>'
300 xtype
: 'pveGlobalSearchField',
307 xtype
: 'proxmoxHelpButton',
310 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
311 listenToGlobalEvent
: false,
312 onlineHelp
: 'pve_documentation_index',
313 text
: gettext('Documentation'),
325 // proxmox dark grey p light grey as border
326 backgroundColor
: '#464d4d',
327 borderColor
: '#ABBABA'
329 iconCls
: 'fa fa-user',
332 iconCls
: 'fa fa-gear',
333 text
: gettext('My Settings'),
334 handler: function() {
335 var win
= Ext
.create('PVE.window.Settings');
340 text
: gettext('Password'),
341 iconCls
: 'fa fa-fw fa-key',
342 handler: function() {
343 var win
= Ext
.create('Proxmox.window.PasswordEdit', {
344 userid
: Proxmox
.UserName
351 iconCls
: 'fa fa-fw fa-lock',
352 handler: function(btn
, event
, rec
) {
353 var win
= Ext
.create('PVE.window.TFAEdit',{
354 userid
: Proxmox
.UserName
361 iconCls
: 'fa fa-fw fa-sign-out',
362 text
: gettext("Logout"),
363 handler: function() {
364 PVE
.data
.ResourceStore
.loadData([], false);
367 var rt
= me
.down('pveResourceTree');
368 rt
.setDatacenterText(undefined);
371 // empty the stores of the StatusPanel child items
372 var statusPanels
= Ext
.ComponentQuery
.query('pveStatusPanel grid');
373 Ext
.Array
.forEach(statusPanels
, function(comp
) {
374 if (comp
.getStore()) {
375 comp
.getStore().loadData([], false);
387 stateId
: 'pvecenter',
392 layout
: { type
: 'card' },
404 layout
: { type
: 'vbox', align
: 'stretch' },
408 items
: [ selview
, rtree
],
410 resize: function(panel
, width
, height
) {
411 var viewWidth
= me
.getSize().width
;
412 if (width
> viewWidth
- 100) {
413 panel
.setWidth(viewWidth
- 100);
419 xtype
: 'pveStatusPanel',
425 title
: gettext('Logs'),
431 resize: function(panel
, width
, height
) {
432 var viewHeight
= me
.getSize().height
;
433 if (height
> (viewHeight
- 150)) {
434 panel
.setHeight(viewHeight
- 150);
446 // on resize, center all modal windows
447 Ext
.on('resize', function(){
448 var wins
= Ext
.ComponentQuery
.query('window[modal]');
449 if (wins
.length
> 0) {
450 wins
.forEach(function(win
){
451 win
.alignTo(me
, 'c-c');