2018-12-04 19:53:10 +03:00
Ext . define ( 'PBS.Application' , {
extend : 'Ext.app.Application' ,
name : 'PBS' ,
appProperty : 'app' ,
stores : [
2020-09-25 19:36:58 +03:00
'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 ;
2020-09-25 19:36:58 +03:00
if ( me . currentView !== undefined ) {
2019-01-30 17:14:20 +03:00
me . currentView . destroy ( ) ;
}
me . currentView = Ext . create ( {
xtype : view ,
} ) ;
if ( skipCheck !== true ) {
2020-11-10 15:38:30 +03:00
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 ) ;
2021-07-04 00:12:03 +03:00
let isOpenIDLogin = Proxmox . Utils . getOpenIDRedirectionAuthorization ( ) !== undefined ;
let alreadyLoggedIn = Proxmox . Utils . authOK ( ) ;
2021-06-14 12:58:52 +03:00
2021-07-04 00:12:03 +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 ) ;
}
2020-09-25 19:36:58 +03:00
} ,
2018-12-04 19:53:10 +03:00
} ) ;
Ext . application ( 'PBS.Application' ) ;