Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 4x 12x 12x 12x 12x 12x 12x 17x 8x 4x 5x 31x 4x 7x 1x 2x 1x 1x | import { Component, OnDestroy, OnInit } from '@angular/core';
import { AsyncPipe, CommonModule } from '@angular/common';
import { MatToolbarModule } from '@angular/material/toolbar';
import { SessionService } from '@core/services/session.service';
import { catchError, filter, Observable, Subject, takeUntil, throwError } from 'rxjs';
import { NavigationEnd, NavigationSkipped, Router, RouterLink } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { LocaleService } from '@core/services/locale.service';
import { MatMenu, MatMenuModule } from '@angular/material/menu';
import { AuthService } from '@core/services/auth.service';
@Component({
selector: 'app-menu',
standalone: true,
imports: [MatToolbarModule, MatMenu, MatMenuModule, MatIconModule, AsyncPipe, RouterLink, CommonModule],
templateUrl: './menu.component.html',
styleUrl: './menu.component.scss'
})
export class MenuComponent implements OnInit, OnDestroy {
private destroy$: Subject<boolean> = new Subject<boolean>();
public menuOpen: boolean = false;
constructor(
private sessionService: SessionService,
private authService: AuthService,
private router: Router,
private localeService: LocaleService
) {}
get lang() {
return this.localeService.currentLocale;
}
public $isLogged(): Observable<boolean> {
return this.sessionService.$isLogged();
}
public openNav() :void {
this.menuOpen = true;
}
public closeNav() :void {
this.menuOpen = false;
}
ngOnInit(): void {
this.router.events.pipe(
takeUntil(this.destroy$),
filter(event => event instanceof NavigationEnd || event instanceof NavigationSkipped)
)
.subscribe(() => {
this.closeNav();
});
}
public ngOnDestroy(): void {
// emit to Subject to unsubscribe from observables
this.destroy$.next(true);
}
public changeLang(lang: 'fr' | 'en'): void {
this.localeService.changeLocale(lang);
}
public logout(): void {
this.authService.logout()
.subscribe(
() => {
this.sessionService.logOut();
this.router.navigate([''])
}
)
}
}
|