Files
dspace-angular/src/app/shared/auth-nav-menu/user-menu/user-menu.component.ts
Giuseppe Digilio 52906e71c4 Intermediate commit
2019-03-08 19:49:07 +01:00

42 lines
1.0 KiB
TypeScript

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));
}
}