mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #3846 from alexandrevryghem/w2p-122357_browse-performance-fixes_contribute-main
Browse performance fixes
This commit is contained in:
@@ -22,8 +22,8 @@ import {
|
|||||||
of as observableOf,
|
of as observableOf,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import {
|
import {
|
||||||
|
distinctUntilChanged,
|
||||||
map,
|
map,
|
||||||
take,
|
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
|
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
|
||||||
|
|
||||||
@@ -42,13 +42,7 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
|
|||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
|
|
||||||
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
|
|
||||||
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
|
|
||||||
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
|
|
||||||
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
|
|
||||||
import { isValidDate } from '../../shared/date.util';
|
import { isValidDate } from '../../shared/date.util';
|
||||||
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
|
|
||||||
import {
|
import {
|
||||||
hasValue,
|
hasValue,
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
@@ -56,7 +50,6 @@ import {
|
|||||||
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
|
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
|
||||||
import {
|
import {
|
||||||
BrowseByMetadataComponent,
|
BrowseByMetadataComponent,
|
||||||
browseParamsToOptions,
|
browseParamsToOptions,
|
||||||
@@ -68,15 +61,8 @@ import {
|
|||||||
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
|
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
VarDirective,
|
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
ComcolPageHeaderComponent,
|
|
||||||
ComcolPageLogoComponent,
|
|
||||||
NgIf,
|
NgIf,
|
||||||
ThemedComcolPageHandleComponent,
|
|
||||||
ThemedComcolPageContentComponent,
|
|
||||||
DsoEditMenuComponent,
|
|
||||||
ThemedComcolPageBrowseByComponent,
|
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
ThemedLoadingComponent,
|
ThemedLoadingComponent,
|
||||||
ThemedBrowseByComponent,
|
ThemedBrowseByComponent,
|
||||||
@@ -117,18 +103,20 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
|
|||||||
this.startsWithType = StartsWithType.date;
|
this.startsWithType = StartsWithType.date;
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
|
const routeParams$: Observable<Params> = observableCombineLatest([
|
||||||
|
this.route.params,
|
||||||
|
this.route.queryParams,
|
||||||
|
]).pipe(
|
||||||
|
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
|
||||||
|
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.startsWith === curr.startsWith),
|
||||||
|
);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest(
|
observableCombineLatest([
|
||||||
[ this.route.params.pipe(take(1)),
|
routeParams$,
|
||||||
this.route.queryParams,
|
this.scope$,
|
||||||
this.scope$,
|
this.currentPagination$,
|
||||||
this.currentPagination$,
|
this.currentSort$,
|
||||||
this.currentSort$,
|
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
]).pipe(
|
|
||||||
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
|
|
||||||
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
|
|
||||||
}),
|
|
||||||
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
|
||||||
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
|
@@ -11,6 +11,7 @@ import {
|
|||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
PLATFORM_ID,
|
PLATFORM_ID,
|
||||||
|
SimpleChanges,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ActivatedRoute,
|
ActivatedRoute,
|
||||||
@@ -26,8 +27,8 @@ import {
|
|||||||
Subscription,
|
Subscription,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import {
|
import {
|
||||||
|
distinctUntilChanged,
|
||||||
map,
|
map,
|
||||||
take,
|
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
|
import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component';
|
||||||
|
|
||||||
@@ -51,12 +52,6 @@ import { BrowseEntry } from '../../core/shared/browse-entry.model';
|
|||||||
import { Context } from '../../core/shared/context.model';
|
import { Context } from '../../core/shared/context.model';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { getFirstSucceededRemoteData } from '../../core/shared/operators';
|
import { getFirstSucceededRemoteData } from '../../core/shared/operators';
|
||||||
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
|
|
||||||
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
|
|
||||||
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
|
|
||||||
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
|
|
||||||
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
|
|
||||||
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
|
|
||||||
import {
|
import {
|
||||||
hasValue,
|
hasValue,
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
@@ -64,7 +59,6 @@ import {
|
|||||||
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
|
import { StartsWithType } from '../../shared/starts-with/starts-with-type';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
|
||||||
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type';
|
||||||
|
|
||||||
export const BBM_PAGINATION_ID = 'bbm';
|
export const BBM_PAGINATION_ID = 'bbm';
|
||||||
@@ -74,15 +68,8 @@ export const BBM_PAGINATION_ID = 'bbm';
|
|||||||
styleUrls: ['./browse-by-metadata.component.scss'],
|
styleUrls: ['./browse-by-metadata.component.scss'],
|
||||||
templateUrl: './browse-by-metadata.component.html',
|
templateUrl: './browse-by-metadata.component.html',
|
||||||
imports: [
|
imports: [
|
||||||
VarDirective,
|
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
ComcolPageHeaderComponent,
|
|
||||||
ComcolPageLogoComponent,
|
|
||||||
NgIf,
|
NgIf,
|
||||||
ThemedComcolPageHandleComponent,
|
|
||||||
ThemedComcolPageContentComponent,
|
|
||||||
DsoEditMenuComponent,
|
|
||||||
ThemedComcolPageBrowseByComponent,
|
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
ThemedLoadingComponent,
|
ThemedLoadingComponent,
|
||||||
ThemedBrowseByComponent,
|
ThemedBrowseByComponent,
|
||||||
@@ -232,21 +219,22 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
||||||
this.updatePage(getBrowseSearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
|
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
|
const routeParams$: Observable<Params> = observableCombineLatest([
|
||||||
|
this.route.params,
|
||||||
|
this.route.queryParams,
|
||||||
|
]).pipe(
|
||||||
|
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
|
||||||
|
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.authority === curr.authority && prev.value === curr.value && prev.startsWith === curr.startsWith),
|
||||||
|
);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest(
|
observableCombineLatest([
|
||||||
[ this.route.params.pipe(take(1)),
|
routeParams$,
|
||||||
this.route.queryParams,
|
this.scope$,
|
||||||
this.scope$,
|
this.currentPagination$,
|
||||||
this.currentPagination$,
|
this.currentSort$,
|
||||||
this.currentSort$,
|
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
]).pipe(
|
|
||||||
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
|
|
||||||
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
|
|
||||||
}),
|
|
||||||
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.authority = params.authority;
|
this.authority = params.authority;
|
||||||
|
|
||||||
@@ -274,8 +262,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
this.scope$.next(this.scope);
|
if (hasValue(changes.scope)) {
|
||||||
|
this.scope$.next(this.scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,11 +11,12 @@ import { Params } from '@angular/router';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
combineLatest as observableCombineLatest,
|
combineLatest as observableCombineLatest,
|
||||||
|
Observable,
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import {
|
import {
|
||||||
|
distinctUntilChanged,
|
||||||
map,
|
map,
|
||||||
take,
|
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
@@ -24,15 +25,8 @@ import {
|
|||||||
SortOptions,
|
SortOptions,
|
||||||
} from '../../core/cache/models/sort-options.model';
|
} from '../../core/cache/models/sort-options.model';
|
||||||
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
|
import { ThemedBrowseByComponent } from '../../shared/browse-by/themed-browse-by.component';
|
||||||
import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
|
|
||||||
import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
|
|
||||||
import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
|
|
||||||
import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component';
|
|
||||||
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
|
|
||||||
import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
|
|
||||||
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
|
||||||
import {
|
import {
|
||||||
BrowseByMetadataComponent,
|
BrowseByMetadataComponent,
|
||||||
browseParamsToOptions,
|
browseParamsToOptions,
|
||||||
@@ -44,15 +38,8 @@ import {
|
|||||||
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
|
templateUrl: '../browse-by-metadata/browse-by-metadata.component.html',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
VarDirective,
|
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
ComcolPageHeaderComponent,
|
|
||||||
ComcolPageLogoComponent,
|
|
||||||
NgIf,
|
NgIf,
|
||||||
ThemedComcolPageHandleComponent,
|
|
||||||
ThemedComcolPageContentComponent,
|
|
||||||
DsoEditMenuComponent,
|
|
||||||
ThemedComcolPageBrowseByComponent,
|
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
ThemedLoadingComponent,
|
ThemedLoadingComponent,
|
||||||
ThemedBrowseByComponent,
|
ThemedBrowseByComponent,
|
||||||
@@ -71,18 +58,20 @@ export class BrowseByTitleComponent extends BrowseByMetadataComponent implements
|
|||||||
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||||
|
const routeParams$: Observable<Params> = observableCombineLatest([
|
||||||
|
this.route.params,
|
||||||
|
this.route.queryParams,
|
||||||
|
]).pipe(
|
||||||
|
map(([params, queryParams]: [Params, Params]) => Object.assign({}, params, queryParams)),
|
||||||
|
distinctUntilChanged((prev: Params, curr: Params) => prev.id === curr.id && prev.startsWith === curr.startsWith),
|
||||||
|
);
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
observableCombineLatest(
|
observableCombineLatest([
|
||||||
[ this.route.params.pipe(take(1)),
|
routeParams$,
|
||||||
this.route.queryParams,
|
this.scope$,
|
||||||
this.scope$,
|
this.currentPagination$,
|
||||||
this.currentPagination$,
|
this.currentSort$,
|
||||||
this.currentSort$,
|
]).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
||||||
]).pipe(
|
|
||||||
map(([routeParams, queryParams, scope, currentPage, currentSort]) => {
|
|
||||||
return [Object.assign({}, routeParams, queryParams), scope, currentPage, currentSort];
|
|
||||||
}),
|
|
||||||
).subscribe(([params, scope, currentPage, currentSort]: [Params, string, PaginationComponentOptions, SortOptions]) => {
|
|
||||||
this.startsWith = +params.startsWith || params.startsWith;
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
|
this.updatePageWithItems(browseParamsToOptions(params, scope, currentPage, currentSort, this.browseId, this.fetchThumbnails), undefined, undefined);
|
||||||
|
@@ -11,6 +11,7 @@ import {
|
|||||||
from as observableFrom,
|
from as observableFrom,
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
|
shareReplay,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import {
|
import {
|
||||||
map,
|
map,
|
||||||
@@ -288,6 +289,10 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
|
|||||||
isNotEmptyOperator(),
|
isNotEmptyOperator(),
|
||||||
take(1),
|
take(1),
|
||||||
map((href: string) => this.buildHrefFromFindOptions(href, {}, [], ...linksToFollow)),
|
map((href: string) => this.buildHrefFromFindOptions(href, {}, [], ...linksToFollow)),
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const startTime: number = new Date().getTime();
|
const startTime: number = new Date().getTime();
|
||||||
@@ -343,6 +348,10 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
|
|||||||
isNotEmptyOperator(),
|
isNotEmptyOperator(),
|
||||||
take(1),
|
take(1),
|
||||||
map((href: string) => this.buildHrefFromFindOptions(href, options, [], ...linksToFollow)),
|
map((href: string) => this.buildHrefFromFindOptions(href, options, [], ...linksToFollow)),
|
||||||
|
shareReplay({
|
||||||
|
bufferSize: 1,
|
||||||
|
refCount: true,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const startTime: number = new Date().getTime();
|
const startTime: number = new Date().getTime();
|
||||||
|
Reference in New Issue
Block a user