1
|
import { Component, Input } from '@angular/core';
|
2
|
import 'rxjs/Rx';
|
3
|
import{MenuItem} from './menu';
|
4
|
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
5
|
|
6
|
@Component({
|
7
|
selector: 'bottom',
|
8
|
templateUrl: 'bottom.component.html'
|
9
|
})
|
10
|
export class BottomComponent {
|
11
|
|
12
|
@Input() showSocialButton:boolean = true;
|
13
|
@Input() showOpenaire:boolean = false;
|
14
|
@Input() showMenu:boolean = true;
|
15
|
@Input() showDnet:boolean = true;
|
16
|
@Input() assetsPath:string ='assets/common-assets/';
|
17
|
@Input() menuItems:MenuItem [];
|
18
|
// [
|
19
|
// new MenuItem("","About","https://beta.openaire.eu/project-factsheets","",false,[],[],{}),
|
20
|
// // new MenuItem("","Services","","",false,[],[],{}),
|
21
|
// new MenuItem("","News - Events","https://beta.openaire.eu/news-events","",false,[],[],{}),
|
22
|
// new MenuItem("","Blog","https://blogs.openaire.eu/","",false,[],[],{}),
|
23
|
// new MenuItem("","Contact us","https://beta.openaire.eu/contact-us","",false,[],[],{})
|
24
|
// ];
|
25
|
@Input() APIUrl;
|
26
|
@Input() communityId;
|
27
|
showPage ={};
|
28
|
constructor(private config: ConfigurationService) {
|
29
|
}
|
30
|
|
31
|
ngOnInit() {
|
32
|
if(this.showMenu){
|
33
|
if( this.APIUrl && this.communityId ){
|
34
|
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
|
35
|
for(var i=0; i< data.pages.length; i++){
|
36
|
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"];
|
37
|
|
38
|
}
|
39
|
|
40
|
});
|
41
|
}
|
42
|
}
|
43
|
console.log(this.menuItems)
|
44
|
}
|
45
|
|
46
|
isEnabled(required, enabled){
|
47
|
if(!required ){
|
48
|
return true;
|
49
|
}
|
50
|
for(let requiredEntity of required){
|
51
|
if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
|
52
|
return false;
|
53
|
}
|
54
|
}
|
55
|
return true;
|
56
|
}
|
57
|
}
|