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