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" ;
2020-07-13 00:19:30 +02:00
import { Subscription } from "rxjs" ;
2020-09-15 15:53:18 +02:00
import { properties } from '../../../environments/environment' ;
2021-05-25 00:15:50 +02:00
import { HelperService } from "../utils/helper/helper.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 ( ) 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 ;
2021-05-25 00:15:50 +02:00
// 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 and No. 777541.";
2020-09-15 15:53:18 +02:00
@Input ( ) properties :EnvProperties = properties ;
2020-04-23 15:21:39 +02:00
@Input ( ) darkBackground :boolean = true ;
@Input ( ) centered :boolean = false ;
2020-09-15 15:53:18 +02:00
@Input ( ) shortView : boolean = false ;
2020-04-23 15:21:39 +02:00
sectionClass = "uk-section-primary" ;
2019-02-01 13:14:46 +01:00
2020-07-13 00:19:30 +02:00
subs : Subscription [ ] = [ ] ;
2021-05-25 00:15:50 +02:00
public divContents = null ;
2020-07-13 00:19:30 +02:00
2021-05-25 00:15:50 +02:00
constructor ( private config : ConfigurationService , private route : ActivatedRoute ,
private helper : HelperService ) {
2018-05-23 15:15:56 +02:00
}
ngOnInit() {
2021-05-25 00:15:50 +02:00
if ( ! properties . footerGrantText ) {
this . getDivContents ( ) ;
}
2020-04-23 15:21:39 +02:00
if ( ! this . darkBackground ) {
this . sectionClass = " footer-light-background" ;
}
2020-07-13 00:19:30 +02:00
this . subs . push ( 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 ) {
2020-07-13 00:19:30 +02:00
//this.subs.push(this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
this . subs . push ( this . config . communityInformationState . subscribe ( data = > {
if ( data ) {
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
2020-07-13 00:19:30 +02:00
}
// console.log(this.showPage)
2018-12-07 12:07:19 +01:00
}
2020-07-13 00:19:30 +02:00
} ) ) ;
2018-05-23 15:15:56 +02:00
}
}
2020-07-13 00:19:30 +02:00
} ) ) ;
}
public ngOnDestroy() {
for ( let sub of this . subs ) {
sub . unsubscribe ( ) ;
}
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 ;
}
2021-05-25 00:15:50 +02:00
private getDivContents() {
2021-06-04 11:42:23 +02:00
let communityId = this . communityId ;
if ( ! communityId ) {
communityId = properties . adminToolsCommunity ;
2021-05-25 00:15:50 +02:00
}
2021-06-04 11:42:23 +02:00
this . subs . push ( this . helper . getDivHelpContents ( this . properties , communityId , "/" ) . subscribe ( contents = > {
this . divContents = contents ;
} ) ) ;
2021-05-25 00:15:50 +02:00
}
2017-12-19 13:53:46 +01:00
}