monitor-dashboard/src/app/users/users.component.ts

58 lines
2.0 KiB
TypeScript

import {Component, Input, OnInit} from "@angular/core";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {properties} from "../../environments/environment";
import {Subscriber} from "rxjs";
import {Title} from "@angular/platform-browser";
@Component({
selector: 'users',
templateUrl: 'users.component.html'
})
export class UsersComponent implements OnInit{
public alias: string;
public name: string;
public type: string;
public link: string;
public loading: boolean;
public messages: Map<"member" | "manager", string> = new Map<"member"|"manager", string>();
public tab: "manager" | "member" = 'manager';
private subscription;
constructor(private stakeholderService: StakeholderService,
private title: Title) {
}
ngOnInit() {
this.loading = true;
this.subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if(stakeholder) {
this.alias = stakeholder.alias;
this.name = stakeholder.name;
this.title.setTitle(this.name + " | Users");
this.type = stakeholder.type;
this.link = this.getURL(this.alias);
this.messages.set("member", 'A member has the right to view the <b>restricted access</b> areas of this indicator\'s profile. ' +
'A member has <b>no access</b> to the administration part of the profile.');
this.messages.set("manager", 'A manager has the right to access the administration part of this indicator\'s profile, ' +
'where he is able to customize and manage indicators, and invite other users as members.');
this.loading = false;
}
})
}
ngOnDestroy() {
if (this.subscription instanceof Subscriber) {
this.subscription.unsubscribe();
}
}
changeTab(tab: "manager" | "member") {
this.tab = tab;
}
private getURL(id: string): string {
return properties.domain + properties.baseLink + "/" + id + "?verify=";
}
}