proxmox-backup/www/Application.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-12-04 19:53:10 +03:00
Ext.define('PBS.Application', {
extend: 'Ext.app.Application',
name: 'PBS',
appProperty: 'app',
stores: [
'NavigationStore',
2018-12-04 19:53:10 +03:00
],
layout: 'fit',
realignWindows: function() {
var modalwindows = Ext.ComponentQuery.query('window[modal]');
Ext.Array.forEach(modalwindows, function(item) {
item.center();
});
},
logout: function() {
var me = this;
2019-01-30 17:14:20 +03:00
Proxmox.Utils.authClear();
me.changeView('loginview', true);
2018-12-04 19:53:10 +03:00
},
changeView: function(view, skipCheck) {
var me = this;
2019-01-30 17:14:20 +03:00
PBS.view = view;
me.view = view;
if (me.currentView !== undefined) {
2019-01-30 17:14:20 +03:00
me.currentView.destroy();
}
me.currentView = Ext.create({
xtype: view,
});
if (skipCheck !== true) {
Proxmox.Utils.checked_command(Ext.emptyFn);
2019-01-30 17:14:20 +03:00
}
2018-12-04 19:53:10 +03:00
},
2019-01-30 17:14:20 +03:00
view: 'loginview',
2018-12-04 19:53:10 +03:00
launch: function() {
var me = this;
Ext.on('resize', me.realignWindows);
var provider = new Ext.state.LocalStorageProvider({ prefix: 'ext-pbs-' });
Ext.state.Manager.setProvider(provider);
let isOpenIDLogin = Proxmox.Utils.getOpenIDRedirectionAuthorization() !== undefined;
let alreadyLoggedIn = Proxmox.Utils.authOK();
2021-06-14 12:58:52 +03:00
if (isOpenIDLogin || !alreadyLoggedIn) {
me.changeView('loginview', true); // show login window if not loggedin
2019-01-30 17:14:20 +03:00
} else {
me.changeView('mainview', true);
}
},
2018-12-04 19:53:10 +03:00
});
Ext.application('PBS.Application');