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