@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component , ElementRef , ViewChild } from '@angular/core' ;
import { AfterViewInit, ChangeDetectorRef, Component , ElementRef , ViewChild } from '@angular/core' ;
import { ActivatedRoute , Router } from '@angular/router' ;
import { EnvProperties } from './openaireLibrary/utils/properties/env-properties' ;
import { MenuItem } from './openaireLibrary/sharedComponents/menu' ;
@ -23,20 +23,21 @@ import {QuickContactService} from './openaireLibrary/sharedComponents/quick-cont
import { LayoutService } from './openaireLibrary/dashboard/sharedComponents/sidebar/layout.service' ;
@Component ( {
//changeDetection: ChangeDetectionStrategy.Default,
//encapsulation: ViewEncapsulation.Emulated,
selector : 'app-root' ,
template : `
< div id = "modal-container" > < / div >
< navbar * ngIf = "properties && header" [ header ] = " header " [ portal ] = " properties.dashboard " [ properties ] = properties
[ onlyTop ] = false [ user ] = "user"
[ communityId ] = "properties.adminToolsCommunity" [ userMenuItems ] = userMenuItems [ menuItems ] = menuItems > < / navbar >
< div * ngIf = "loading" >
< loading [ full ] = " true " > < / loading >
< / div >
< schema2jsonld * ngIf = "properties" [ URL ] = " properties.domain + properties.baseLink "
[ logoURL ] = "properties.domain+properties.baseLink+'/assets/common-assets/logo-services/explore/main.svg'"
type = "home"
name = "OpenAIRE | Find and Share research"
description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide." > < / schema2jsonld >
< div class = "custom-main-content" >
< div [ class.uk - hidden ] = " loading " [ ngClass ] = " rootClass " >
< div id = "modal-container" > < / div >
< main >
< router - outlet > < / r o u t e r - o u t l e t >
< / main >
@ -57,7 +58,9 @@ import {LayoutService} from './openaireLibrary/dashboard/sharedComponents/sideba
< modal - alert # modal [ overflowBody ] = " false " > < / m o d a l - a l e r t >
`
} )
export class AppComponent {
export class AppComponent implements AfterViewInit {
loading : boolean = false ;
rootClass : string ;
isClient : boolean = false ;
userMenuItems : MenuItem [ ] = [ ] ;
menuItems : MenuItem [ ] = [ ] ;
@ -124,7 +127,7 @@ export class AppComponent {
}
} ) ) ;
}
ngOnDestroy() {
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
@ -141,6 +144,31 @@ export class AppComponent {
ngAfterViewInit() {
if ( typeof window !== "undefined" ) {
this . createObservers ( ) ;
this . subscriptions . push ( this . layoutService . rootClass . subscribe ( rootClass = > {
this . loading = true ;
this . cdr . detectChanges ( ) ;
if ( rootClass && this . isClient ) {
let link = < HTMLLinkElement > document . getElementById ( 'theme' ) ;
let append = false ;
if ( ! link ) {
link = document . createElement ( 'link' ) ;
link . rel = 'stylesheet' ;
link . id = 'theme' ;
append = true ;
}
link . href = rootClass + '.css' ;
link . onerror = ( error ) = > console . log ( error ) ;
if ( append ) {
document . head . appendChild ( link ) ;
}
}
this . rootClass = rootClass ;
this . cdr . detectChanges ( ) ;
setTimeout ( ( ) = > {
this . loading = false ;
this . cdr . detectChanges ( ) ;
} , 500 )
} ) ) ;
}
}