Added navigation bar user menu

This commit is contained in:
Giuseppe Digilio
2019-03-08 17:37:36 +01:00
parent f07aafaf15
commit af75beac78
7 changed files with 66 additions and 43 deletions

View File

@@ -0,0 +1,45 @@
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { select, Store } from '@ngrx/store';
import { EPerson } from '../../../core/eperson/models/eperson.model';
import { AppState } from '../../../app.reducer';
import { getAuthenticatedUser, isAuthenticationLoading } from '../../../core/auth/selectors';
@Component({
selector: 'ds-user-menu',
templateUrl: './user-menu.component.html',
styleUrls: ['./user-menu.component.scss']
})
export class UserMenuComponent implements OnInit {
/**
* True if the authentication is loading.
* @type {Observable<boolean>}
*/
public loading$: Observable<boolean>;
/**
* The authenticated user.
* @type {Observable<EPerson>}
*/
public user$: Observable<EPerson>;
constructor(private store: Store<AppState>) {
}
ngOnInit(): void {
// set loading
this.loading$ = this.store.pipe(select(isAuthenticationLoading));
// set user
this.user$ = this.store.pipe(select(getAuthenticatedUser));
this.user$.subscribe((user) => {
console.log(user, user.name);
})
}
}