pmg-gui/js/Application.js
Dominik Csapak 99bba12c7f improve login/logout/cookie behaviour
this changes the login/logout/cookie behaviour

if you go to /quarantine
    you get to the loginview
    except you have a valid cookie
    or you have a ticket via url (this takes precedence)

    when you have a valid login
	you go to the quarantineview
else if you have not a quarantine ticket
    you get to the mainview
else
    you get to the loginview

also adds a logout button to the quarantineview
and moves the viewchange/logout logic to the Application.js

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-10-05 12:51:38 +02:00

70 lines
1.5 KiB
JavaScript

Ext.define('PMG.Application', {
extend: 'Ext.app.Application',
name: 'PMG',
appProperty: 'app',
stores: [
'NavigationStore'
],
layout: 'fit',
realignWindows: function() {
var modalwindows = Ext.ComponentQuery.query('window[modal]');
Ext.Array.forEach(modalwindows, function(item) {
item.center();
});
},
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(function() {}); // display subscription status
}
},
view: 'loginview',
targetview: 'mainview',
launch: function() {
var me = this;
Ext.on('resize', me.realignWindows);
// show login window if not loggedin
var loggedin = Proxmox.Utils.authOK();
var cookie = Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
var qs = Ext.Object.fromQueryString(location.search);
if (location.pathname === "/quarantine") {
me.targetview = 'quarantineview';
if (qs.ticket == undefined && loggedin) {
me.view = 'quarantineview';
}
} 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');