Skip to content
Snippets Groups Projects
Commit 7d26fd47 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

69432: Groups on profile page

parent 892a9851
Branches
Tags
No related merge requests found
...@@ -1421,6 +1421,8 @@ ...@@ -1421,6 +1421,8 @@
"profile.form.submit": "Update Profile", "profile.form.submit": "Update Profile",
"profile.groups.head": "Authorization groups you belong to",
"profile.head": "Update Profile", "profile.head": "Update Profile",
"profile.metadata.form.error.firstname.required": "First Name is required", "profile.metadata.form.error.firstname.required": "First Name is required",
......
...@@ -14,5 +14,14 @@ ...@@ -14,5 +14,14 @@
</div> </div>
</div> </div>
<button class="btn btn-outline-primary" (click)="updateProfile()">{{'profile.form.submit' | translate}}</button> <button class="btn btn-outline-primary" (click)="updateProfile()">{{'profile.form.submit' | translate}}</button>
<ng-container *ngVar="(groupsRD$ | async)?.payload?.page as groups">
<div *ngIf="groups">
<h3 class="mt-4">{{'profile.groups.head' | translate}}</h3>
<ul class="list-group list-group-flush">
<li *ngFor="let group of groups" class="list-group-item">{{group.name}}</li>
</ul>
</div>
</ng-container>
</div> </div>
</ng-container> </ng-container>
...@@ -8,6 +8,14 @@ import { ProfilePageMetadataFormComponent } from './profile-page-metadata-form/p ...@@ -8,6 +8,14 @@ import { ProfilePageMetadataFormComponent } from './profile-page-metadata-form/p
import { ProfilePageSecurityFormComponent } from './profile-page-security-form/profile-page-security-form.component'; import { ProfilePageSecurityFormComponent } from './profile-page-security-form/profile-page-security-form.component';
import { NotificationsService } from '../shared/notifications/notifications.service'; import { NotificationsService } from '../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { Group } from '../core/eperson/models/group.model';
import { RemoteData } from '../core/data/remote-data';
import { PaginatedList } from '../core/data/paginated-list';
import { filter, switchMap, tap } from 'rxjs/operators';
import { EPersonDataService } from '../core/eperson/eperson-data.service';
import { getAllSucceededRemoteData, getRemoteDataPayload, getSucceededRemoteData } from '../core/shared/operators';
import { hasValue } from '../shared/empty.util';
import { followLink } from '../shared/utils/follow-link-config.model';
@Component({ @Component({
selector: 'ds-profile-page', selector: 'ds-profile-page',
...@@ -27,15 +35,28 @@ export class ProfilePageComponent implements OnInit { ...@@ -27,15 +35,28 @@ export class ProfilePageComponent implements OnInit {
*/ */
user$: Observable<EPerson>; user$: Observable<EPerson>;
/**
* The groups the user belongs to
*/
groupsRD$: Observable<RemoteData<PaginatedList<Group>>>;
NOTIFICATIONS_PREFIX = 'profile.notifications.'; NOTIFICATIONS_PREFIX = 'profile.notifications.';
constructor(private store: Store<AppState>, constructor(private store: Store<AppState>,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private translate: TranslateService) { private translate: TranslateService,
private epersonService: EPersonDataService) {
} }
ngOnInit(): void { ngOnInit(): void {
this.user$ = this.store.pipe(select(getAuthenticatedUser)); this.user$ = this.store.pipe(
select(getAuthenticatedUser),
filter((user: EPerson) => hasValue(user.id)),
switchMap((user: EPerson) => this.epersonService.findById(user.id, followLink('groups'))),
getAllSucceededRemoteData(),
getRemoteDataPayload()
);
this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups));
} }
updateProfile() { updateProfile() {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment