2021-07-03 21:48:27 +00:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
2021-07-18 09:39:39 +00:00
|
|
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
2021-07-03 21:48:27 +00:00
|
|
|
|
|
|
|
import { AccountService } from 'app/core/auth/account.service';
|
|
|
|
import { Account } from 'app/core/auth/account.model';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'jhi-home',
|
|
|
|
templateUrl: './home.component.html',
|
|
|
|
styleUrls: ['./home.component.scss'],
|
|
|
|
})
|
|
|
|
export class HomeComponent implements OnInit, OnDestroy {
|
|
|
|
account: Account | null = null;
|
|
|
|
|
|
|
|
private readonly destroy$ = new Subject<void>();
|
|
|
|
|
2021-07-18 09:39:39 +00:00
|
|
|
constructor(private accountService: AccountService, private router: Router, protected modalService: NgbModal) {}
|
2021-07-03 21:48:27 +00:00
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.accountService
|
|
|
|
.getAuthenticationState()
|
|
|
|
.pipe(takeUntil(this.destroy$))
|
|
|
|
.subscribe(account => (this.account = account));
|
|
|
|
}
|
|
|
|
|
|
|
|
login(): void {
|
|
|
|
this.router.navigate(['/login']);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.destroy$.next();
|
|
|
|
this.destroy$.complete();
|
|
|
|
}
|
|
|
|
}
|