mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
User profile state (#438)
* user data * fix missing store selector * profile state * use ProfileStatus * remove tests * test fixes
This commit is contained in:
committed by
Denys Vuika
parent
9e08b8a232
commit
fec3f8aaf7
@@ -24,9 +24,13 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { PeopleContentService } from '@alfresco/adf-core';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states/app.state';
|
||||
import { selectUser } from '../../store/selectors/app.selectors';
|
||||
import { ProfileState } from '../../store/states/profile.state';
|
||||
|
||||
@Component({
|
||||
selector: 'aca-current-user',
|
||||
templateUrl: './current-user.component.html',
|
||||
@@ -36,39 +40,17 @@ import { Subscription } from 'rxjs/Rx';
|
||||
export class CurrentUserComponent implements OnInit, OnDestroy {
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
user: any = null;
|
||||
user: ProfileState;
|
||||
|
||||
constructor(
|
||||
private peopleApi: PeopleContentService
|
||||
) {}
|
||||
constructor(private store: Store<AppStore>) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscriptions = this.subscriptions.concat([
|
||||
this.peopleApi.getCurrentPerson().subscribe((person: any) => this.user = person.entry)
|
||||
this.store.select(selectUser).subscribe((user) => this.user = user)
|
||||
]);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
|
||||
get userFirstName(): string {
|
||||
const { user } = this;
|
||||
return user ? (user.firstName || '') : '';
|
||||
}
|
||||
|
||||
get userLastName(): string {
|
||||
const { user } = this;
|
||||
return user ? (user.lastName || '') : '';
|
||||
}
|
||||
|
||||
get userName(): string {
|
||||
const { userFirstName: first, userLastName: last } = this;
|
||||
return `${first} ${last}`;
|
||||
}
|
||||
|
||||
get userInitials(): string {
|
||||
const { userFirstName: first, userLastName: last } = this;
|
||||
return [ first[0], last[0] ].join('');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user