openaire-library/sharedComponents/bottom.component.ts

58 lines
1.7 KiB
TypeScript
Raw Normal View History

import { Component, Input } from '@angular/core';
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 = false;
@Input() showMenu:boolean = true;
@Input() showDnet:boolean = true;
@Input() assetsPath:string ='assets/common-assets/';
@Input() menuItems:MenuItem [];
// [
// new MenuItem("","About","https://beta.openaire.eu/project-factsheets","",false,[],[],{}),
// // new MenuItem("","Services","","",false,[],[],{}),
// new MenuItem("","News - Events","https://beta.openaire.eu/news-events","",false,[],[],{}),
// new MenuItem("","Blog","https://blogs.openaire.eu/","",false,[],[],{}),
// new MenuItem("","Contact us","https://beta.openaire.eu/contact-us","",false,[],[],{})
// ];
@Input() APIUrl;
@Input() communityId;
showPage ={};
constructor(private config: ConfigurationService) {
}
ngOnInit() {
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.menuItems)
}
isEnabled(required, enabled){
if(!required ){
return true;
}
for(let requiredEntity of required){
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
return false;
}
}
return true;
}
}