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
import {properties} from '../../../environments/environment';
9

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

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

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

    
35
subs: Subscription[] = [];
36

    
37
constructor(private config: ConfigurationService, private  route: ActivatedRoute,) {
38
}
39

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

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

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

    
68
  isEnabled(required, enabled){
69

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