2018-08-24 17:21:02 +02:00
|
|
|
import { JsonSerializer } from '../../../utilities/JsonSerializer';
|
|
|
|
import { RequestItem } from '../../../models/criteria/RequestItem';
|
|
|
|
import { Component, OnInit, Inject } from "@angular/core";
|
|
|
|
import { FormGroup } from '@angular/forms';
|
|
|
|
import { Params, ActivatedRoute, Router } from '@angular/router';
|
|
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
|
|
|
import { ResearcherModel } from '../../../models/researcher/ResearcherModel';
|
|
|
|
import { ResearcherService } from '../../../services/researchers/researchers.service';
|
|
|
|
import { AuthService } from '../../../services/auth/auth.service';
|
|
|
|
import { Principal } from '../../../models/login/Principal';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'user-dialog-component',
|
|
|
|
templateUrl: 'user-dialog.component.html',
|
|
|
|
|
|
|
|
})
|
|
|
|
export class UserDialogComponent implements OnInit {
|
|
|
|
|
|
|
|
public formGroup: FormGroup;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private authentication: AuthService,
|
|
|
|
public router: Router,
|
|
|
|
public dialogRef: MatDialogRef<UserDialogComponent>,
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
}
|
|
|
|
|
|
|
|
public logout(): void {
|
|
|
|
this.dialogRef.close();
|
|
|
|
this.authentication.logout();
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPrincipalName(): string {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
if (principal) { return principal.name; }
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
public principalHasAvatar(): boolean {
|
2018-09-04 11:36:18 +02:00
|
|
|
return this.authentication.current() && this.authentication.current().avatarUrl != null;
|
2018-08-24 17:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public getPrincipalAvatar(): string {
|
2018-09-04 11:36:18 +02:00
|
|
|
return this.authentication.current() && this.authentication.current().avatarUrl;
|
2018-08-24 17:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public navigateToProfile() {
|
2018-08-27 11:00:09 +02:00
|
|
|
this.dialogRef.close();
|
2018-08-24 17:21:02 +02:00
|
|
|
this.router.navigate(["/users/" + this.authentication.current().id]);
|
|
|
|
}
|
|
|
|
}
|