Skip to content

Commit c3e635b

Browse files
Merge branch 'refactor-comcol-pages_contribute-7.6' into w2p-122357_browse-performance-fixes_contribute-main
2 parents 76ae286 + 0570542 commit c3e635b

3 files changed

Lines changed: 51 additions & 82 deletions

File tree

src/app/browse-by/browse-by-date/browse-by-date.component.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
Observable,
2020
} from 'rxjs';
2121
import {
22+
distinctUntilChanged,
2223
map,
23-
take,
2424
} from 'rxjs/operators';
2525
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
2626

@@ -38,21 +38,14 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
3838
import { RemoteData } from '../../core/data/remote-data';
3939
import { PaginationService } from '../../core/pagination/pagination.service';
4040
import { Item } from '../../core/shared/item.model';
41-
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
42-
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
43-
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
44-
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
45-
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
4641
import { isValidDate } from '../../shared/date.util';
47-
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
4842
import {
4943
hasValue,
5044
isNotEmpty,
5145
} from '../../shared/empty.util';
5246
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
5347
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
5448
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
55-
import { VarDirective } from '../../shared/utils/var.directive';
5649
import {
5750
BrowseByMetadataComponent,
5851
browseParamsToOptions,
@@ -64,15 +57,8 @@ import {
6457
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
6558
standalone: true,
6659
imports: [
67-
VarDirective,
6860
AsyncPipe,
69-
ComcolPageHeaderComponent,
70-
ComcolPageLogoComponent,
7161
NgIf,
72-
ThemedComcolPageHandleComponent,
73-
ThemedComcolPageContentComponent,
74-
DsoEditMenuComponent,
75-
ThemedComcolPageBrowseByComponent,
7662
TranslateModule,
7763
ThemedLoadingComponent,
7864
ThemedBrowseByComponent,
@@ -108,18 +94,20 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
10894
this.startsWithType = StartsWithType.date;
10995
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
11096
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
97+
const routeParams$: Observable<Params> = observableCombineLatest([
98+
this.route.params,
99+
this.route.queryParams,
100+
]).pipe(
101+
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
102+
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.startsWith === curr.startsWith),
103+
);
111104
this.subs.push(
112-
observableCombineLatest(
113-
[ this.route.params.pipe(take(1)),
114-
this.route.queryParams,
115-
this.scope$,
116-
this.currentPagination$,
117-
this.currentSort$,
118-
]).pipe(
119-
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
120-
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
121-
}),
122-
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
105+
observableCombineLatest([
106+
routeParams$,
107+
this.scope$,
108+
this.currentPagination$,
109+
this.currentSort$,
110+
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
123111
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
124112
this.browseId = params.id || this.defaultBrowseId;
125113
this.startsWith = +params.startsWith || params.startsWith;

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
OnChanges,
1010
OnDestroy,
1111
OnInit,
12+
SimpleChanges,
1213
} from '@angular/core';
1314
import {
1415
ActivatedRoute,
@@ -24,8 +25,8 @@ import {
2425
Subscription,
2526
} from 'rxjs';
2627
import {
28+
distinctUntilChanged,
2729
map,
28-
take,
2930
} from 'rxjs/operators';
3031
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
3132

@@ -48,20 +49,13 @@ import { BrowseEntry } from '../../core/shared/browse-entry.model';
4849
import { Context } from '../../core/shared/context.model';
4950
import { Item } from '../../core/shared/item.model';
5051
import { getFirstSucceededRemoteData } from '../../core/shared/operators';
51-
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
52-
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
53-
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
54-
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
55-
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
56-
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
5752
import {
5853
hasValue,
5954
isNotEmpty,
6055
} from '../../shared/empty.util';
6156
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
6257
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
6358
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
64-
import { VarDirective } from '../../shared/utils/var.directive';
6559
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
6660

6761
export const BBM_PAGINATION_ID = 'bbm';
@@ -71,15 +65,8 @@ export const BBM_PAGINATION_ID = 'bbm';
7165
styleUrls: ['./browse-by-metadata.component.scss'],
7266
templateUrl: './browse-by-metadata.component.html',
7367
imports: [
74-
VarDirective,
7568
AsyncPipe,
76-
ComcolPageHeaderComponent,
77-
ComcolPageLogoComponent,
7869
NgIf,
79-
ThemedComcolPageHandleComponent,
80-
ThemedComcolPageContentComponent,
81-
DsoEditMenuComponent,
82-
ThemedComcolPageBrowseByComponent,
8370
TranslateModule,
8471
ThemedLoadingComponent,
8572
ThemedBrowseByComponent,
@@ -215,21 +202,22 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
215202
ngOnInit(): void {
216203

217204
const sortConfig = new SortOptions('default', SortDirection.ASC);
218-
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
219205
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
220206
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
207+
const routeParams$: Observable<Params> = observableCombineLatest([
208+
this.route.params,
209+
this.route.queryParams,
210+
]).pipe(
211+
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
212+
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.authority === curr.authority && prev.value === curr.value && prev.startsWith === curr.startsWith),
213+
);
221214
this.subs.push(
222-
observableCombineLatest(
223-
[ this.route.params.pipe(take(1)),
224-
this.route.queryParams,
225-
this.scope$,
226-
this.currentPagination$,
227-
this.currentSort$,
228-
]).pipe(
229-
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
230-
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
231-
}),
232-
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
215+
observableCombineLatest([
216+
routeParams$,
217+
this.scope$,
218+
this.currentPagination$,
219+
this.currentSort$,
220+
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
233221
this.browseId = params.id || this.defaultBrowseId;
234222
this.authority = params.authority;
235223

@@ -257,8 +245,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
257245

258246
}
259247

260-
ngOnChanges(): void {
261-
this.scope$.next(this.scope);
248+
ngOnChanges(changes: SimpleChanges): void {
249+
if (hasValue(changes.scope)) {
250+
this.scope$.next(this.scope);
251+
}
262252
}
263253

264254
/**

src/app/browse-by/browse-by-title/browse-by-title.component.ts

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ import {
88
} from '@angular/core';
99
import { Params } from '@angular/router';
1010
import { TranslateModule } from '@ngx-translate/core';
11-
import { combineLatest as observableCombineLatest } from 'rxjs';
1211
import {
12+
combineLatest as observableCombineLatest,
13+
Observable,
14+
} from 'rxjs';
15+
import {
16+
distinctUntilChanged,
1317
map,
14-
take,
1518
} from 'rxjs/operators';
1619

1720
import {
1821
SortDirection,
1922
SortOptions,
2023
} from '../../core/cache/models/sort-options.model';
2124
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
22-
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
23-
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
24-
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
25-
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
26-
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
27-
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
2825
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
2926
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
30-
import { VarDirective } from '../../shared/utils/var.directive';
3127
import {
3228
BrowseByMetadataComponent,
3329
browseParamsToOptions,
@@ -39,15 +35,8 @@ import {
3935
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
4036
standalone: true,
4137
imports: [
42-
VarDirective,
4338
AsyncPipe,
44-
ComcolPageHeaderComponent,
45-
ComcolPageLogoComponent,
4639
NgIf,
47-
ThemedComcolPageHandleComponent,
48-
ThemedComcolPageContentComponent,
49-
DsoEditMenuComponent,
50-
ThemedComcolPageBrowseByComponent,
5140
TranslateModule,
5241
ThemedLoadingComponent,
5342
ThemedBrowseByComponent,
@@ -62,18 +51,20 @@ export class BrowseByTitleComponent extends BrowseByMetadataComponent implements
6251
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
6352
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
6453
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
54+
const routeParams$: Observable<Params> = observableCombineLatest([
55+
this.route.params,
56+
this.route.queryParams,
57+
]).pipe(
58+
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
59+
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.startsWith === curr.startsWith),
60+
);
6561
this.subs.push(
66-
observableCombineLatest(
67-
[ this.route.params.pipe(take(1)),
68-
this.route.queryParams,
69-
this.scope$,
70-
this.currentPagination$,
71-
this.currentSort$,
72-
]).pipe(
73-
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
74-
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
75-
}),
76-
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
62+
observableCombineLatest([
63+
routeParams$,
64+
this.scope$,
65+
this.currentPagination$,
66+
this.currentSort$,
67+
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
7768
this.startsWith = +params.startsWith || params.startsWith;
7869
this.browseId = params.id || this.defaultBrowseId;
7970
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);

0 commit comments

Comments
 (0)