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

43 lines
1.2 KiB
TypeScript

import {Component, OnInit} from "@angular/core";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {properties} from "../../environments/environment";
import {Subscriber} from "rxjs";
@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;
constructor(private stakeholderService: StakeholderService) {
}
subscription;
ngOnDestroy() {
if (this.subscription instanceof Subscriber) {
this.subscription.unsubscribe();
}
}
ngOnInit() {
this.loading = true;
this.subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if(stakeholder) {
this.alias = stakeholder.alias;
this.name = stakeholder.name;
this.type = stakeholder.type;
this.link = this.getURL(this.alias);
this.loading = false;
}
})
}
private getURL(id: string): string {
return properties.domain + properties.baseLink + "/" + id + "?verify=";
}
}