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';
|
2017-12-19 13:53:46 +01:00
|
|
|
import 'rxjs/Rx';
|
2018-05-23 15:15:56 +02:00
|
|
|
import{MenuItem} from './menu';
|
|
|
|
import { ConfigurationService } from '../utils/configuration/configuration.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 {
|
|
|
|
|
2018-04-03 10:39:17 +02:00
|
|
|
@Input() showSocialButton:boolean = true;
|
2018-10-04 12:12:54 +02:00
|
|
|
@Input() showOpenaire:boolean = true;
|
2018-04-03 10:39:17 +02:00
|
|
|
@Input() showMenu:boolean = true;
|
|
|
|
@Input() showDnet: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() APIUrl;
|
|
|
|
@Input() communityId;
|
2018-12-13 10:21:26 +01:00
|
|
|
@Input() environment:string = "beta";
|
2018-05-23 15:15:56 +02:00
|
|
|
showPage ={};
|
2018-12-07 12:07:19 +01:00
|
|
|
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
|
2018-05-23 15:15:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-12-07 12:07:19 +01:00
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
if(!this.showMenu){
|
|
|
|
if( this.APIUrl && this.communityId ){
|
2018-05-23 15:15:56 +02:00
|
|
|
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
|
2018-12-07 12:07:19 +01:00
|
|
|
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
|
|
|
|
2018-12-07 12:07:19 +01:00
|
|
|
}
|
|
|
|
// console.log(this.showPage)
|
2018-05-23 15:15:56 +02:00
|
|
|
|
2018-12-07 12:07:19 +01:00
|
|
|
});
|
2018-05-23 15:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
2018-12-07 12:07:19 +01:00
|
|
|
});
|
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;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|