blob: 7d9afcd7b753e379a4dc5035814b048df14d5f8f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import {Component, OnInit, Inject, ViewChild} from '@angular/core';
import {BehaviorSubject, Observable} from 'rxjs';
import { DOCUMENT } from '@angular/common';
import {AuthService} from './services/auth.service';
import {ToastType} from './services/toasts.service';
interface ToastProps {
type: ToastType, message: string, action?: {label: string, onAction: () => void}
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: false,
styleUrl: './app.component.css'
})
export class AppComponent implements OnInit {
// title = 'ufund-ui';
currentUser$: BehaviorSubject<string> = new BehaviorSubject<string>("Logged out.");
toast = new BehaviorSubject<ToastProps>({type: ToastType.INFO, message: "testToast"})
constructor(
private authService: AuthService,
@Inject(DOCUMENT) private document: Document
) {}
reloadPage() {
this.document.defaultView?.location.reload();
}
ngOnInit() {
this.authService.getCurrentUserSubject().subscribe(r => {
this.currentUser$?.next(r
? "Logged in as " + r.username
: "Logged out."
)
})
}
}
|