Added nav-bar to show home link and user status
This commit is contained in:
@ -1,10 +1,4 @@
|
||||
<div fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['/', 'login']" *ngIf="!(user | async)">
|
||||
<h3 class="item-name">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Login
|
||||
</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Guest Book')" [routerLink]="['/', 'guest-book']">
|
||||
<h3 class="item-name">Guest Book</h3>
|
||||
</mat-card>
|
||||
@ -74,10 +68,4 @@
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Users')" [routerLink]="['/', 'users']">
|
||||
<h3 class="item-name">Users</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['/', 'logout']"
|
||||
*ngIf="user | async as name">
|
||||
<h3 class="item-name">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Logout {{name}}</h3>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { Component, OnInit} from '@angular/core';
|
||||
import { AuthService} from '../auth/auth.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, share } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@ -9,15 +7,10 @@ import { map, share } from 'rxjs/operators';
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
public user: Observable<string>;
|
||||
|
||||
constructor(public auth: AuthService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.user = this.auth.userObservable.pipe(
|
||||
map (x => x.isAuthenticated ? x.name : null),
|
||||
share()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user