2018-04-03 10:39:17 +02:00
import { Component , Input } from '@angular/core' ;
2018-12-07 12:07:19 +01:00
import { ActivatedRoute } from '@angular/router' ;
2017-12-19 13:53:46 +01:00
import 'rxjs/Rx' ;
2018-05-23 15:15:56 +02:00
import { MenuItem } from './menu' ;
import { ConfigurationService } from '../utils/configuration/configuration.service' ;
2017-12-19 13:53:46 +01:00
@Component ( {
selector : 'bottom' ,
2018-04-03 10:39:17 +02:00
templateUrl : 'bottom.component.html'
2017-12-19 13:53:46 +01:00
} )
export class BottomComponent {
2019-02-01 13:14:46 +01:00
@Input ( ) showSocialButtons :boolean = true ;
2018-10-04 12:12:54 +02:00
@Input ( ) showOpenaire :boolean = true ;
2019-02-01 13:14:46 +01:00
@Input ( ) showMenuItems :boolean = false ;
@Input ( ) showCommision :boolean = true ;
2018-05-11 13:33:50 +02:00
@Input ( ) assetsPath :string = 'assets/common-assets/' ;
2018-05-23 15:15:56 +02:00
@Input ( ) menuItems :MenuItem [ ] ;
2018-12-13 10:21:26 +01:00
2018-05-23 15:15:56 +02:00
@Input ( ) APIUrl ;
@Input ( ) communityId ;
2018-12-13 10:21:26 +01:00
@Input ( ) environment :string = "beta" ;
2018-05-23 15:15:56 +02:00
showPage = { } ;
2019-02-01 13:14:46 +01:00
@Input ( ) grantAdvance :boolean = true ;
grantAdvanceText = "OpenAIRE-Advance receives funding from the European Union's Horizon 2020 Research and Innovation programme under Grant Agreement No. 777541."
grantConenctText = "OpenAIRE-Connect receives funding from the European Union's Horizon 2020 Research and Innovation programme under grant agreement No. 731011."
2018-12-07 12:07:19 +01:00
constructor ( private config : ConfigurationService , private route : ActivatedRoute , ) {
2018-05-23 15:15:56 +02:00
}
ngOnInit() {
2018-12-07 12:07:19 +01:00
this . route . queryParams . subscribe ( params = > {
2019-02-01 13:14:46 +01:00
if ( this . showMenuItems ) {
2018-12-07 12:07:19 +01:00
if ( this . APIUrl && this . communityId ) {
2018-05-23 15:15:56 +02:00
this . config . getCommunityInformation ( this . APIUrl , this . communityId ) . subscribe ( data = > {
2018-12-07 12:07:19 +01:00
for ( var i = 0 ; i < data . pages . length ; i ++ ) {
this . showPage [ data . pages [ i ] [ "route" ] ] = data . pages [ i ] [ "isEnabled" ] ;
2018-05-23 15:15:56 +02:00
2018-12-07 12:07:19 +01:00
}
// console.log(this.showPage)
2018-05-23 15:15:56 +02:00
2018-12-07 12:07:19 +01:00
} ) ;
2018-05-23 15:15:56 +02:00
}
}
2018-12-07 12:07:19 +01:00
} ) ;
2018-05-23 15:15:56 +02:00
}
isEnabled ( required , enabled ) {
2018-12-07 12:07:19 +01:00
2018-05-23 15:15:56 +02:00
if ( ! required ) {
return true ;
}
for ( let requiredEntity of required ) {
2018-12-07 12:07:19 +01:00
// console.log("R "+requiredEntity +" E " + enabled[requiredEntity])
2018-05-23 15:15:56 +02:00
if ( typeof enabled [ requiredEntity ] === "undefined" || enabled [ requiredEntity ] == false ) {
return false ;
}
}
return true ;
}
2017-12-19 13:53:46 +01:00
}