]>
Commit | Line | Data |
---|---|---|
5c7a1b15 DM |
1 | Ext.define('PBS.Application', { |
2 | extend: 'Ext.app.Application', | |
3 | ||
4 | name: 'PBS', | |
5 | appProperty: 'app', | |
6 | ||
7 | stores: [ | |
264c1958 | 8 | 'NavigationStore', |
5c7a1b15 DM |
9 | ], |
10 | ||
11 | layout: 'fit', | |
12 | ||
13 | realignWindows: function() { | |
14 | var modalwindows = Ext.ComponentQuery.query('window[modal]'); | |
15 | Ext.Array.forEach(modalwindows, function(item) { | |
16 | item.center(); | |
17 | }); | |
18 | }, | |
19 | ||
20 | logout: function() { | |
21 | var me = this; | |
34f956bc DM |
22 | Proxmox.Utils.authClear(); |
23 | me.changeView('loginview', true); | |
5c7a1b15 DM |
24 | }, |
25 | ||
26 | changeView: function(view, skipCheck) { | |
27 | var me = this; | |
34f956bc DM |
28 | PBS.view = view; |
29 | me.view = view; | |
30 | ||
264c1958 | 31 | if (me.currentView !== undefined) { |
34f956bc DM |
32 | me.currentView.destroy(); |
33 | } | |
34 | ||
35 | me.currentView = Ext.create({ | |
36 | xtype: view, | |
37 | }); | |
38 | if (skipCheck !== true) { | |
38efbfc1 | 39 | Proxmox.Utils.checked_command(Ext.emptyFn); |
34f956bc | 40 | } |
5c7a1b15 DM |
41 | }, |
42 | ||
34f956bc DM |
43 | view: 'loginview', |
44 | ||
5c7a1b15 DM |
45 | launch: function() { |
46 | var me = this; | |
47 | Ext.on('resize', me.realignWindows); | |
48 | ||
49 | var provider = new Ext.state.LocalStorageProvider({ prefix: 'ext-pbs-' }); | |
50 | Ext.state.Manager.setProvider(provider); | |
51 | ||
dc99315c TL |
52 | let isOpenIDLogin = Proxmox.Utils.getOpenIDRedirectionAuthorization() !== undefined; |
53 | let alreadyLoggedIn = Proxmox.Utils.authOK(); | |
cd975e57 | 54 | |
dc99315c TL |
55 | if (isOpenIDLogin || !alreadyLoggedIn) { |
56 | me.changeView('loginview', true); // show login window if not loggedin | |
34f956bc DM |
57 | } else { |
58 | me.changeView('mainview', true); | |
59 | } | |
264c1958 | 60 | }, |
5c7a1b15 DM |
61 | }); |
62 | ||
63 | Ext.application('PBS.Application'); |