Skip to content

Commit

Permalink
show navbar on login menu
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Nov 20, 2023
1 parent 0b08318 commit 44c8fff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 6 additions & 4 deletions frontend/src/app/menu/menu.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="navbar is-primary" *ngIf="user$ | async as user" aria-label="primary navigation">
<nav class="navbar is-primary" aria-label="primary navigation">
<div class="container is-fluid">
<!-- skip link for keyboard navigation.
Complicated setup because the menu is outside of router-outlet and so
Expand Down Expand Up @@ -26,13 +26,15 @@
<div class="navbar-menu" id="navigation-menu" [class.is-active]="menuOpen">
<div class="navbar-start">
<!-- navbar items -->
<a class="navbar-item" [routerLinkActive]="'is-active'" [routerLink]="['/home']">
<a class="navbar-item" *ngIf="user$ | async"
[routerLinkActive]="'is-active'" [routerLink]="['/home']">
<span class="icon" aria-hidden="true">
<fa-icon [icon]="icons.corpora"></fa-icon>
</span>
Corpora
</a>
<a class="navbar-item" [routerLinkActive]="'is-active'" [routerLink]="['/manual', 'main']">
<a class="navbar-item" *ngIf="user$ | async"
[routerLinkActive]="'is-active'" [routerLink]="['/manual', 'main']">
<span class="icon" aria-hidden="true">
<fa-icon [icon]="icons.manual"></fa-icon>
</span>
Expand All @@ -45,7 +47,7 @@
About
</a>
</div>
<div class="navbar-end">
<div class="navbar-end" *ngIf="user$ | async as user">
<!-- navbar items -->
<div class="navbar-item has-dropdown"
[class.is-active]="dropdownOpen$ | async">
Expand Down
10 changes: 3 additions & 7 deletions frontend/src/app/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BehaviorSubject, Observable, Subject, fromEvent, merge, of, timer } fro
import { User } from '../models/index';
import { environment } from '../../environments/environment';
import { AuthService } from '../services/auth.service';
import { filter, map, switchMap, take, takeUntil } from 'rxjs/operators';
import { catchError, filter, map, switchMap, take, takeUntil } from 'rxjs/operators';
import * as _ from 'lodash';
import {
faBook, faCog, faCogs, faDatabase, faDownload, faHistory, faInfoCircle, faSignOut,
Expand Down Expand Up @@ -57,7 +57,8 @@ export class MenuComponent implements OnDestroy, OnInit {
}

ngOnInit() {
this.checkCurrentUser();
this.user$ = this.authService.currentUser$;
this.isAdmin$ = this.user$.pipe(map(user => user?.isAdmin));

this.dropdownOpen$.pipe(
takeUntil(this.destroy$),
Expand Down Expand Up @@ -126,9 +127,4 @@ export class MenuComponent implements OnDestroy, OnInit {
).subscribe(() => this.dropdownOpen$.next(false));
}

private checkCurrentUser() {
this.user$ = this.authService.currentUser$;
this.isAdmin$ = this.user$.pipe(map(user => user?.isAdmin));
}

}

0 comments on commit 44c8fff

Please sign in to comment.