mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Added navigation bar user menu
This commit is contained in:
@@ -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);
|
||||
})
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user