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
|
public tab: "manager" | "member" = 'manager';
|
20
|
private subscription;
|
21
|
|
22
|
constructor(private stakeholderService: StakeholderService,
|
23
|
private title: Title) {
|
24
|
}
|
25
|
|
26
|
ngOnInit() {
|
27
|
this.loading = true;
|
28
|
this.subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
29
|
if(stakeholder) {
|
30
|
this.alias = stakeholder.alias;
|
31
|
this.name = stakeholder.name;
|
32
|
this.title.setTitle(this.name + " | Users");
|
33
|
this.type = stakeholder.type;
|
34
|
this.link = this.getURL(this.alias);
|
35
|
this.messages.set("member", 'A member has the right to view the <b>restricted access</b> areas of this indicator\'s profile. ' +
|
36
|
'A member has <b>no access</b> to the administration part of the profile.');
|
37
|
this.messages.set("manager", 'A manager has the right to access the administration part of this indicator\'s profile, ' +
|
38
|
'where he is able to customize and manage indicators, and invite other users as members.');
|
39
|
this.loading = false;
|
40
|
}
|
41
|
})
|
42
|
}
|
43
|
|
44
|
ngOnDestroy() {
|
45
|
if (this.subscription instanceof Subscriber) {
|
46
|
this.subscription.unsubscribe();
|
47
|
}
|
48
|
}
|
49
|
|
50
|
changeTab(tab: "manager" | "member") {
|
51
|
this.tab = tab;
|
52
|
}
|
53
|
|
54
|
private getURL(id: string): string {
|
55
|
return properties.domain + properties.baseLink + "/" + id + "?verify=";
|
56
|
}
|
57
|
}
|