]>
Commit | Line | Data |
---|---|---|
1 | Ext.define('PBS.Application', { | |
2 | extend: 'Ext.app.Application', | |
3 | ||
4 | name: 'PBS', | |
5 | appProperty: 'app', | |
6 | ||
7 | stores: [ | |
8 | 'NavigationStore', | |
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; | |
22 | Proxmox.Utils.authClear(); | |
23 | me.changeView('loginview', true); | |
24 | }, | |
25 | ||
26 | changeView: function(view, skipCheck) { | |
27 | var me = this; | |
28 | PBS.view = view; | |
29 | me.view = view; | |
30 | ||
31 | if (me.currentView !== undefined) { | |
32 | me.currentView.destroy(); | |
33 | } | |
34 | ||
35 | me.currentView = Ext.create({ | |
36 | xtype: view, | |
37 | }); | |
38 | if (skipCheck !== true) { | |
39 | // fixme: | |
40 | // Proxmox.Utils.checked_command(function() {}); // display subscription status | |
41 | } | |
42 | }, | |
43 | ||
44 | view: 'loginview', | |
45 | ||
46 | launch: function() { | |
47 | var me = this; | |
48 | Ext.on('resize', me.realignWindows); | |
49 | ||
50 | var provider = new Ext.state.LocalStorageProvider({ prefix: 'ext-pbs-' }); | |
51 | Ext.state.Manager.setProvider(provider); | |
52 | ||
53 | // show login window if not loggedin | |
54 | var loggedin = Proxmox.Utils.authOK(); | |
55 | if (!loggedin) { | |
56 | me.changeView('loginview', true); | |
57 | } else { | |
58 | me.changeView('mainview', true); | |
59 | } | |
60 | }, | |
61 | }); | |
62 | ||
63 | Ext.application('PBS.Application'); |