openaire-library/sharedComponents/bottom.component.ts

58 lines
1.5 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() showSocialButton:boolean = true;
@Input() showOpenaire:boolean = true;
@Input() showMenu:boolean = true;
@Input() showDnet:boolean = true;
@Input() assetsPath:string ='assets/common-assets/';
@Input() menuItems:MenuItem [];
@Input() APIUrl;
@Input() communityId;
@Input() environment:string = "beta";
showPage ={};
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
}
ngOnInit() {
this.route.queryParams.subscribe(params => {
if(!this.showMenu){
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;
}
}