openaire-library/sharedComponents/bottom.component.ts

69 lines
2.2 KiB
TypeScript
Raw Normal View History

import { Component, Input } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import 'rxjs';
import{MenuItem} from './menu';
import { ConfigurationService } from '../utils/configuration/configuration.service';
import {EnvProperties} from "../utils/properties/env-properties";
@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() 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.";
@Input() properties:EnvProperties;
@Input() darkBackground:boolean=true;
@Input() centered:boolean=false;
sectionClass= "uk-section-primary";
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
}
ngOnInit() {
if(!this.darkBackground){
this.sectionClass= " footer-light-background";
}
this.route.queryParams.subscribe(params => {
if(this.showMenuItems){
if( this.properties.adminToolsAPIURL && this.communityId ){
this.config.getCommunityInformation(this.properties, 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;
}
}