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