import { Component, OnInit, OnDestroy } from '@angular/core'; import { Router, RouterModule } from '@angular/router'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/auth/account.model'; import { SharedModule } from 'app/shared/shared.module'; import { CtxTreeModule } from 'app/ctx-tree/ctx-tree.module'; import { IContextNode } from 'app/services/i-context-node'; import { CtxScreenModule } from 'app/ctx-screen/ctx-screen.module'; @Component({ standalone: true, selector: 'jhi-home', templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], imports: [SharedModule, RouterModule, CtxTreeModule, CtxScreenModule], }) export default class HomeComponent implements OnInit, OnDestroy { account: Account | null = null; currentNodeCtx: IContextNode; private readonly destroy$ = new Subject(); constructor(private accountService: AccountService, private router: Router) { this.currentNodeCtx = {} as IContextNode; } loadTreeNode(node: IContextNode): void { this.currentNodeCtx = node; } 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(); } }