]>
Commit | Line | Data |
---|---|---|
8a20ffa5 DC |
1 | Ext.define('PMG.Application', { |
2 | extend: 'Ext.app.Application', | |
3 | ||
4 | name: 'PMG', | |
99bba12c | 5 | appProperty: 'app', |
8a20ffa5 | 6 | |
8a20ffa5 | 7 | stores: [ |
c87d46fb | 8 | 'NavigationStore', |
8a20ffa5 DC |
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 | ||
99bba12c DC |
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 | PMG.view = view; | |
29 | me.view = view; | |
30 | me.currentView.destroy(); | |
31 | me.currentView = Ext.create({ | |
32 | xtype: view, | |
c87d46fb | 33 | targetview: me.targetview, |
99bba12c DC |
34 | }); |
35 | if (skipCheck !== true) { | |
28eb60c0 | 36 | Proxmox.Utils.checked_command(Ext.emptyFn); // display subscription status |
99bba12c DC |
37 | } |
38 | }, | |
39 | ||
40 | view: 'loginview', | |
41 | targetview: 'mainview', | |
42 | ||
8a20ffa5 DC |
43 | launch: function() { |
44 | var me = this; | |
99bba12c | 45 | Ext.on('resize', me.realignWindows); |
6cbc3de3 DM |
46 | |
47 | var provider = new Ext.state.LocalStorageProvider({ prefix: 'ext-pmg-' }); | |
48 | Ext.state.Manager.setProvider(provider); | |
49 | ||
8a20ffa5 DC |
50 | // show login window if not loggedin |
51 | var loggedin = Proxmox.Utils.authOK(); | |
99bba12c DC |
52 | var cookie = Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name); |
53 | var qs = Ext.Object.fromQueryString(location.search); | |
0277bfeb | 54 | |
fcf672c5 DM |
55 | var pathname = location.pathname.replace(/\/+$/, ''); |
56 | ||
57 | if (pathname === "/quarantine") { | |
99bba12c DC |
58 | me.targetview = 'quarantineview'; |
59 | ||
28eb60c0 | 60 | if (qs.ticket === undefined && loggedin) { |
99bba12c | 61 | me.view = 'quarantineview'; |
0277bfeb | 62 | } |
99bba12c DC |
63 | } else if (loggedin && cookie.substr(0, 7) !== 'PMGQUAR') { |
64 | me.view = 'mainview'; | |
0277bfeb | 65 | } |
99bba12c DC |
66 | |
67 | PMG.view = me.view; | |
68 | me.currentView = Ext.create({ | |
69 | xtype: me.view, | |
c87d46fb | 70 | targetview: me.targetview, |
99bba12c | 71 | }); |
c87d46fb | 72 | }, |
8a20ffa5 DC |
73 | }); |
74 | ||
75 | Ext.application('PMG.Application'); |