openaire-library/sharedComponents/bottom.component.ts

63 lines
1.9 KiB
TypeScript
Raw Normal View History

import { Component, Input } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import 'rxjs/Rx';
import{MenuItem} from './menu';
import { ConfigurationService } from '../utils/configuration/configuration.service';
@Component({
selector: 'bottom',
templateUrl: 'bottom.component.html'
})
export class BottomComponent {
@Input() showSocialButtons:boolean = true;
@Input() showOpenaire:boolean = true;
@Input() showMenuItems:boolean = false;
@Input() showCommision:boolean = true;
@Input() assetsPath:string ='assets/common-assets/';
@Input() menuItems:MenuItem [];
@Input() APIUrl;
@Input() communityId;
@Input() environment:string = "beta";
showPage ={};
@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."
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
}
ngOnInit() {
this.route.queryParams.subscribe(params => {
if(this.showMenuItems){
if( this.APIUrl && this.communityId ){
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
for(var i=0; i< data.pages.length; i++){
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"];
}
// console.log(this.showPage)
});
}
}
});
}
isEnabled(required, enabled){
if(!required ){
return true;
}
for(let requiredEntity of required){
// console.log("R "+requiredEntity +" E " + enabled[requiredEntity])
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
return false;
}
}
return true;
}
}