Project

General

Profile

1
import {Component, Input, OnInit} from "@angular/core";
2
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
3
import {properties} from "../../environments/environment";
4
import {Subscriber} from "rxjs";
5
import {Title} from "@angular/platform-browser";
6

    
7
@Component({
8
  selector: 'users',
9
  templateUrl: 'users.component.html'
10
})
11
export class UsersComponent implements OnInit{
12
  
13
  public alias: string;
14
  public name: string;
15
  public type: string;
16
  public link: string;
17
  public loading: boolean;
18
  public messages: Map<"member" | "manager", string> = new Map<"member"|"manager", string>();
19
  private subscription;
20
  
21
  constructor(private stakeholderService: StakeholderService,
22
              private title: Title) {
23
  }
24
  
25
  ngOnInit() {
26
    this.loading = true;
27
    this.subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
28
      if(stakeholder) {
29
        this.alias = stakeholder.alias;
30
        this.name = stakeholder.name;
31
        this.title.setTitle(this.name + " | Users");
32
        this.type = stakeholder.type;
33
        this.link = this.getURL(this.alias);
34
        this.messages.set("member", 'A member has the right to view the <b>restricted access</b> areas of this indicator\'s profile. ' +
35
          'A member has <b>no access</b> to the administration part of the profile.');
36
        this.messages.set("manager", 'A manager has the right to access the administration part of this indicator\'s profile, ' +
37
          'where he is able to customize and manage indicators, and invite other users as members.');
38
        this.loading = false;
39
      }
40
    })
41
  }
42
  
43
  ngOnDestroy() {
44
    if (this.subscription instanceof Subscriber) {
45
      this.subscription.unsubscribe();
46
    }
47
  }
48
  
49
  private getURL(id: string): string {
50
    return properties.domain + properties.baseLink + "/" + id + "?verify=";
51
  }
52
}
(3-3/4)