Project

General

Profile

1
import { Component, Input } from '@angular/core';
2
import {ActivatedRoute} from '@angular/router';
3
import 'rxjs';
4
import{MenuItem} from './menu';
5
import { ConfigurationService } from '../utils/configuration/configuration.service';
6
import {EnvProperties} from "../utils/properties/env-properties";
7
import {Subscription} from "rxjs";
8

    
9
@Component({
10
  selector: 'bottom',
11
  templateUrl: 'bottom.component.html'
12
})
13
export class BottomComponent {
14

    
15
@Input() showSocialButtons:boolean = true;
16
@Input() showOpenaire:boolean = true;
17
@Input() showMenuItems:boolean = false;
18
@Input() showCommision:boolean = true;
19
@Input() assetsPath:string ='assets/common-assets/';
20
@Input() menuItems:MenuItem [];
21

    
22
@Input() communityId;
23
// @Input() environment:string = "beta";
24
showPage ={};
25
@Input() grantAdvance:boolean = true;
26
grantAdvanceText = "OpenAIRE-Advance receives funding from the European Union's Horizon 2020 Research and Innovation programme under Grant Agreement No. 777541.";
27
grantConenctText = "OpenAIRE-Connect receives funding from the European Union's Horizon 2020 Research and Innovation programme under grant agreement No. 731011 and  No. 777541.";
28
@Input()  properties:EnvProperties;
29
@Input() darkBackground:boolean=true;
30
@Input() centered:boolean=false;
31
sectionClass= "uk-section-primary";
32

    
33
subs: Subscription[] = [];
34

    
35
constructor(private config: ConfigurationService, private  route: ActivatedRoute,) {
36
}
37

    
38
  ngOnInit() {
39
  if(!this.darkBackground){
40
    this.sectionClass= " footer-light-background";
41
  }
42
    this.subs.push(this.route.queryParams.subscribe(params => {
43
      if(this.showMenuItems){
44
        if( this.properties.adminToolsAPIURL && this.communityId ){
45
          //this.subs.push(this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
46
          this.subs.push(this.config.communityInformationState.subscribe(data => {
47
            if(data) {
48
              for (var i = 0; i < data['pages'].length; i++) {
49
                this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
50

    
51
              }
52
              // console.log(this.showPage)
53
            }
54
          }));
55
        }
56
      }
57
    }));
58
  }
59

    
60
  public ngOnDestroy() {
61
    for (let sub of this.subs) {
62
      sub.unsubscribe();
63
    }
64
  }
65

    
66
  isEnabled(required, enabled){
67

    
68
    if(!required ){
69
      return true;
70
    }
71
    for(let requiredEntity of required){
72
      // console.log("R "+requiredEntity +" E "  + enabled[requiredEntity])
73
        if(typeof enabled[requiredEntity] === "undefined" || enabled[requiredEntity] == false){
74
          return false;
75
        }
76
    }
77
    return true;
78
  }
79
}
(2-2/9)