Files
we_bstly-web/src/app/pages/user/user.component.ts
T
2021-09-23 13:53:08 +02:00

44 lines
1000 B
TypeScript

import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {AuthService} from '../../services/auth.service';
import {ProfileService} from '../../services/profile.service';
@Component({
selector: 'app-user',
templateUrl: './user.component.html'
})
export class UserComponent implements OnInit {
username;
model: any;
error = false;
success = false;
isMe = false;
constructor(
private authService: AuthService,
private profileService: ProfileService,
private route: ActivatedRoute) {}
async ngOnInit() {
this.username = this.route.snapshot.paramMap.get('username');
this.profileService.getForUser(this.username).subscribe((data: any) => {
this.success = true;
this.model = data;
this.authService.auth.subscribe((auth: any) => {
this.isMe = auth && auth.principal && auth.principal.username == this.model.username;
});
}, error => {
this.error = error;
})
}
}