Commits

Bruno Roemers authored 511a2e18aba
80113: Display loading indicator after using pagination nav
No tags

src/app/access-control/group-registry/groups-registry.component.ts

Modified
1 1 import { Component, OnDestroy, OnInit } from '@angular/core';
2 2 import { FormBuilder } from '@angular/forms';
3 3 import { Router } from '@angular/router';
4 4 import { TranslateService } from '@ngx-translate/core';
5 5 import {
6 6 BehaviorSubject,
7 7 combineLatest as observableCombineLatest,
8 8 Observable,
9 9 of as observableOf,
10 10 Subscription
11 11 } from 'rxjs';
12 -import { catchError, map, switchMap, take } from 'rxjs/operators';
12 +import { catchError, map, switchMap, take, tap } from 'rxjs/operators';
13 13 import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
14 14 import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
15 15 import { FeatureID } from '../../core/data/feature-authorization/feature-id';
16 16 import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
17 17 import { RemoteData } from '../../core/data/remote-data';
18 18 import { RequestService } from '../../core/data/request.service';
19 19 import { EPersonDataService } from '../../core/eperson/eperson-data.service';
20 20 import { GroupDataService } from '../../core/eperson/group-data.service';
21 21 import { EPerson } from '../../core/eperson/models/eperson.model';
22 22 import { GroupDtoModel } from '../../core/eperson/models/group-dto.model';
111 111
112 112 ngOnInit() {
113 113 this.search({ query: this.currentSearchQuery });
114 114 }
115 115
116 116 /**
117 117 * Search in the groups (searches by group name and by uuid exact match)
118 118 * @param data Contains query param
119 119 */
120 120 search(data: any) {
121 - this.loading$.next(true);
122 121 if (hasValue(this.searchSub)) {
123 122 this.searchSub.unsubscribe();
124 123 this.subs = this.subs.filter((sub: Subscription) => sub !== this.searchSub);
125 124 }
126 125 this.searchSub = this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
126 + tap(() => this.loading$.next(true)),
127 127 switchMap((paginationOptions) => {
128 128 const query: string = data.query;
129 129 if (query != null && this.currentSearchQuery !== query) {
130 130 this.currentSearchQuery = query;
131 131 this.paginationService.updateRouteWithUrl(this.config.id, [], {page: 1});
132 132 }
133 133 return this.groupService.searchGroups(this.currentSearchQuery.trim(), {
134 134 currentPage: paginationOptions.currentPage,
135 135 elementsPerPage: paginationOptions.pageSize
136 136 });

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut