Project

General

Profile

1
/**
2
 * Created by stefania on 3/21/16.
3
 */
4

    
5
import {Component, ElementRef, OnInit} from '@angular/core';
6
import {ActivatedRoute} from '@angular/router';
7
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
8
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
9
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
10
import {Title} from '@angular/platform-browser';
11
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
12

    
13
@Component({
14
    selector: 'dashboard',
15
    templateUrl: 'dashboard.component.html',
16
})
17
export class DashboardComponent implements OnInit {
18
  communityId: string = null;
19
  communityType = null;
20
  properties: EnvProperties;
21

    
22
  constructor( private element: ElementRef,
23
               private  route: ActivatedRoute,
24
               private title: Title,
25
               private _communityService: CommunityService) {}
26

    
27
  ngOnInit() {
28
    this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
29
        this.title.setTitle('Administration Dashboard | Overview');
30
        this.properties = data.envSpecific;
31
        this.route.queryParams.subscribe(data => {
32
          HelperFunctions.scroll();
33
          this.communityId = ((data['communityId']) ? data['communityId'] : data['community']);
34
          ConnectHelper.setPortalTypeFromPid(this.communityId);
35

    
36
          this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe (
37
            community => {
38
                this.communityType = community.type;
39
            },
40
            error => {
41
              console.error('Server responded: ' + error);
42
            }
43
          );
44
        });
45
    });
46

    
47
  }
48
}
(3-3/4)