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' ;
2019-06-03 15:20:36 +02:00
import 'rxjs' ;
2018-05-23 15:15:56 +02:00
import { MenuItem } from './menu' ;
import { ConfigurationService } from '../utils/configuration/configuration.service' ;
2019-06-05 15:33:18 +02:00
import { EnvProperties } from "../utils/properties/env-properties" ;
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 ( ) communityId ;
2019-06-05 15:33:18 +02: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 ;
2020-04-23 15:21:39 +02:00
grantAdvanceText = "OpenAIRE-Advance receives funding from the European Union's Horizon 2020 Research and Innovation programme under Grant Agreement No. 777541." ;
2020-05-07 15:10:27 +02:00
grantConenctText = "OpenAIRE-Connect receives funding from the European Union's Horizon 2020 Research and Innovation programme under grant agreement No. 731011 and No. 777541." ;
2019-06-05 15:33:18 +02:00
@Input ( ) properties :EnvProperties ;
2020-04-23 15:21:39 +02:00
@Input ( ) darkBackground :boolean = true ;
@Input ( ) centered :boolean = false ;
sectionClass = "uk-section-primary" ;
2019-02-01 13:14:46 +01:00
2018-12-07 12:07:19 +01:00
constructor ( private config : ConfigurationService , private route : ActivatedRoute , ) {
2018-05-23 15:15:56 +02:00
}
ngOnInit() {
2020-04-23 15:21:39 +02:00
if ( ! this . darkBackground ) {
this . sectionClass = " footer-light-background" ;
}
2018-12-07 12:07:19 +01:00
this . route . queryParams . subscribe ( params = > {
2019-02-01 13:14:46 +01:00
if ( this . showMenuItems ) {
2019-06-05 15:33:18 +02:00
if ( this . properties . adminToolsAPIURL && this . communityId ) {
this . config . getCommunityInformation ( this . properties , this . communityId ) . subscribe ( data = > {
2019-06-03 15:20:36 +02: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
}