Project

General

Profile

1
import {Component} from '@angular/core';
2
import {ActivatedRoute, Router}       from '@angular/router';
3

    
4
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
5

    
6
@Component({
7
  selector: 'community-wrapper',
8
  template:`
9
      <community *ngIf="dashboard && communityId" [communityId]=communityId></community>
10
      <communities *ngIf="dashboard!=null && !dashboard" ></communities>
11
  `
12
})
13

    
14
export class CommunityWrapperComponent {
15
  communityId:string;
16
  dashboard:boolean = null;
17

    
18
  constructor (
19
      private route: ActivatedRoute,
20
      private _router: Router
21

    
22
  ) {
23
    this.route.data
24
        .subscribe((data: { envSpecific: any }) => {
25
          this.route.queryParams.subscribe(
26
              communityId => {
27
                this.communityId  = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
28
                if(!this.communityId) {
29
                  this.communityId = communityId['communityId'];
30
                }
31

    
32
                if(this.communityId){
33
                  this.dashboard = true;
34
                }else{
35
                  this.dashboard = false;
36
                }
37

    
38
              });
39
        });
40

    
41
  }
42

    
43
  public ngOnInit() {
44
  }
45

    
46

    
47

    
48
}
(2-2/3)