]> git.proxmox.com Git - pmg-gui.git/blobdiff - js/Application.js
Revert "fix tracking center with newer proxmox-widget-toolkit"
[pmg-gui.git] / js / Application.js
index 93f506adf9de1fbc08830e0eaa029a18c8639a3d..f5f673c5420050fcf1ce1df38210e81835b45b1a 100644 (file)
@@ -2,9 +2,10 @@ Ext.define('PMG.Application', {
     extend: 'Ext.app.Application',
 
     name: 'PMG',
+    appProperty: 'app',
 
     stores: [
-       'NavigationStore'
+       'NavigationStore',
     ],
 
     layout: 'fit',
@@ -16,24 +17,59 @@ Ext.define('PMG.Application', {
        });
     },
 
+    logout: function() {
+       var me = this;
+       Proxmox.Utils.authClear();
+       me.changeView('loginview', true);
+    },
+
+    changeView: function(view, skipCheck) {
+       var me = this;
+       PMG.view = view;
+       me.view = view;
+       me.currentView.destroy();
+       me.currentView = Ext.create({
+           xtype: view,
+           targetview: me.targetview,
+       });
+       if (skipCheck !== true) {
+           Proxmox.Utils.checked_command(Ext.emptyFn); // display subscription status
+       }
+    },
+
+    view: 'loginview',
+    targetview: 'mainview',
+
     launch: function() {
        var me = this;
+       Ext.on('resize', me.realignWindows);
+
+       var provider = new Ext.state.LocalStorageProvider({ prefix: 'ext-pmg-' });
+       Ext.state.Manager.setProvider(provider);
+
        // show login window if not loggedin
        var loggedin = Proxmox.Utils.authOK();
-       Ext.on('resize', me.realignWindows);
+       var cookie = Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
+       var qs = Ext.Object.fromQueryString(location.search);
+
+       var pathname = location.pathname.replace(/\/+$/, '');
 
-       if (loggedin) {
-           if (location.pathname === "/quarantine") {
-               PMG.view = 'quarantine';
-               Ext.create({ xtype: 'quarantineview' });
-           } else {
-               PMG.view = 'main';
-               Ext.create({ xtype: 'mainview' });
+       if (pathname === "/quarantine") {
+           me.targetview = 'quarantineview';
+
+           if (qs.ticket === undefined && loggedin) {
+               me.view = 'quarantineview';
            }
-       } else {
-           Ext.create({ xtype: 'loginview' });
+       } else if (loggedin && cookie.substr(0, 7) !== 'PMGQUAR') {
+           me.view = 'mainview';
        }
-    }
+
+       PMG.view = me.view;
+       me.currentView = Ext.create({
+           xtype: me.view,
+           targetview: me.targetview,
+       });
+    },
 });
 
 Ext.application('PMG.Application');