From 2ed8f8bad85a5c57299e34e84f6da1ea2150e249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Fern=C3=A1ndez=20Celorio?= Date: Fri, 4 Nov 2022 10:40:29 +0000 Subject: [PATCH 1/5] Numbre of bitstreams in item page is now configurable --- config/config.example.yml | 7 ++++ .../full-file-section.component.ts | 33 ++++++++++--------- .../file-section/file-section.component.ts | 9 +++-- src/config/default-app-config.ts | 11 ++++++- src/config/item-config.interface.ts | 11 +++++++ src/environments/environment.test.ts | 11 ++++++- 6 files changed, 62 insertions(+), 20 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 27400f0041..52a0720230 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -207,6 +207,13 @@ item: undoTimeout: 10000 # 10 seconds # Show the item access status label in items lists showAccessStatuses: false + simpleView: + bitstreamPageSize: 5 + fullView: + # Number of entries in the bitstream list in the full item view page. + # Rounded to the nearest size in the list of selectable sizes on the + # settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + bitstreamPageSize: 5 # Collection Page Config collection: diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts index e21c1a32eb..89134a321e 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.service'; @@ -14,6 +14,7 @@ import { NotificationsService } from '../../../../shared/notifications/notificat import { TranslateService } from '@ngx-translate/core'; import { hasValue, isEmpty } from '../../../../shared/empty.util'; import { PaginationService } from '../../../../core/pagination/pagination.service'; +import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface'; /** * This component renders the file section of the item @@ -34,26 +35,28 @@ export class FullFileSectionComponent extends FileSectionComponent implements On originals$: Observable>>; licenses$: Observable>>; - pageSize = 5; - originalOptions = Object.assign(new PaginationComponentOptions(), { - id: 'obo', - currentPage: 1, - pageSize: this.pageSize - }); - - licenseOptions = Object.assign(new PaginationComponentOptions(), { - id: 'lbo', - currentPage: 1, - pageSize: this.pageSize - }); + originalOptions: PaginationComponentOptions; + licenseOptions: PaginationComponentOptions; constructor( bitstreamDataService: BitstreamDataService, protected notificationsService: NotificationsService, protected translateService: TranslateService, - protected paginationService: PaginationService + protected paginationService: PaginationService, + @Inject(APP_CONFIG) protected appConfig: AppConfig ) { - super(bitstreamDataService, notificationsService, translateService); + super(bitstreamDataService, notificationsService, translateService, appConfig); + this.originalOptions = Object.assign(new PaginationComponentOptions(), { + id: 'obo', + currentPage: 1, + pageSize: this.appConfig.item.fullView.bitstreamPageSize + }); + + this.licenseOptions = Object.assign(new PaginationComponentOptions(), { + id: 'lbo', + currentPage: 1, + pageSize: this.appConfig.item.fullView.bitstreamPageSize + }); } ngOnInit(): void { diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.ts index d28b579996..a0e40376e5 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.service'; @@ -10,6 +10,7 @@ import { PaginatedList } from '../../../../core/data/paginated-list.model'; import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; +import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface'; /** * This component renders the file section of the item @@ -35,13 +36,15 @@ export class FileSectionComponent implements OnInit { isLastPage: boolean; - pageSize = 5; + pageSize: number; constructor( protected bitstreamDataService: BitstreamDataService, protected notificationsService: NotificationsService, - protected translateService: TranslateService + protected translateService: TranslateService, + @Inject(APP_CONFIG) protected appConfig: AppConfig ) { + this.pageSize = this.appConfig.item.simpleView.bitstreamPageSize } ngOnInit(): void { diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index f489abc53b..3940ea1c19 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -245,7 +245,16 @@ export class DefaultAppConfig implements AppConfig { undoTimeout: 10000 // 10 seconds }, // Show the item access status label in items lists - showAccessStatuses: false + showAccessStatuses: false, + simpleView: { + bitstreamPageSize: 5 + }, + fullView: { + // Number of entries in the bitstream list in the full item view page. + // Rounded to the nearest size in the list of selectable sizes on the + // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + bitstreamPageSize: 5 + } }; // Collection Page Config diff --git a/src/config/item-config.interface.ts b/src/config/item-config.interface.ts index f842c37c05..1351911334 100644 --- a/src/config/item-config.interface.ts +++ b/src/config/item-config.interface.ts @@ -6,4 +6,15 @@ export interface ItemConfig extends Config { }; // This is used to show the access status label of items in results lists showAccessStatuses: boolean; + + simpleView: { + bitstreamPageSize: number; + }; + + fullView: { + // Number of entries in the bitstream list in the full item view page. + // Rounded to the nearest size in the list of selectable sizes on the + // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + bitstreamPageSize: number; + } } diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index edd1cb9109..7410b17f37 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -229,7 +229,16 @@ export const environment: BuildConfig = { undoTimeout: 10000 // 10 seconds }, // Show the item access status label in items lists - showAccessStatuses: false + showAccessStatuses: false, + simpleView: { + bitstreamPageSize: 5 + }, + fullView: { + // Number of entries in the bitstream list in the full item view page. + // Rounded to the nearest size in the list of selectable sizes on the + // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. + bitstreamPageSize: 5 + } }, collection: { edit: { From 87a211ca669b4f882a56661572887f49ae8fcbe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Fern=C3=A1ndez=20Celorio?= Date: Mon, 7 Nov 2022 12:20:00 +0100 Subject: [PATCH 2/5] Tests fixed --- .../file-section/full-file-section.component.spec.ts | 5 ++++- .../file-section/file-section.component.spec.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts index 396e6c3216..3a8e45475d 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts @@ -21,6 +21,8 @@ import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-o import { PaginationService } from '../../../../core/pagination/pagination.service'; import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub'; import { FindListOptions } from '../../../../core/data/find-list-options.model'; +import { APP_CONFIG } from 'src/config/app-config.interface'; +import { environment } from 'src/environments/environment'; describe('FullFileSectionComponent', () => { let comp: FullFileSectionComponent; @@ -72,7 +74,8 @@ describe('FullFileSectionComponent', () => { providers: [ { provide: BitstreamDataService, useValue: bitstreamDataService }, { provide: NotificationsService, useValue: new NotificationsServiceStub() }, - { provide: PaginationService, useValue: paginationService } + { provide: PaginationService, useValue: paginationService }, + { provide: APP_CONFIG, useValue: environment }, ], schemas: [NO_ERRORS_SCHEMA] diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts index 2d185aef9c..83f92d5af8 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts @@ -17,6 +17,8 @@ import { MetadataFieldWrapperComponent } from '../../../field-components/metadat import { createPaginatedList } from '../../../../shared/testing/utils.test'; import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub'; +import { APP_CONFIG } from 'src/config/app-config.interface'; +import { environment } from 'src/environments/environment'; describe('FileSectionComponent', () => { let comp: FileSectionComponent; @@ -65,7 +67,8 @@ describe('FileSectionComponent', () => { declarations: [FileSectionComponent, VarDirective, FileSizePipe, MetadataFieldWrapperComponent], providers: [ { provide: BitstreamDataService, useValue: bitstreamDataService }, - { provide: NotificationsService, useValue: new NotificationsServiceStub() } + { provide: NotificationsService, useValue: new NotificationsServiceStub() }, + { provide: APP_CONFIG, useValue: environment } ], schemas: [NO_ERRORS_SCHEMA] From 1e523382d06633aaf0c88b700b2a953aeedd9423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Fern=C3=A1ndez=20Celorio?= Date: Mon, 7 Nov 2022 16:50:46 +0100 Subject: [PATCH 3/5] Fix lint error --- .../field-components/file-section/file-section.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.ts index a0e40376e5..2907a33482 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.ts @@ -44,7 +44,7 @@ export class FileSectionComponent implements OnInit { protected translateService: TranslateService, @Inject(APP_CONFIG) protected appConfig: AppConfig ) { - this.pageSize = this.appConfig.item.simpleView.bitstreamPageSize + this.pageSize = this.appConfig.item.simpleView.bitstreamPageSize; } ngOnInit(): void { From f7e78dccd129458c6f4828e8ac1fe309d925a64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Fern=C3=A1ndez=20Celorio?= Date: Mon, 7 Nov 2022 19:27:54 +0000 Subject: [PATCH 4/5] Use the same property for both item pages --- config/config.example.yml | 6 ++--- .../full-file-section.component.ts | 24 +++++++++---------- .../file-section/file-section.component.ts | 2 +- src/config/default-app-config.ts | 9 +++---- src/config/item-config.interface.ts | 10 +++----- src/environments/environment.test.ts | 9 +++---- 6 files changed, 23 insertions(+), 37 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 52a0720230..bb4c691f6b 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -207,13 +207,11 @@ item: undoTimeout: 10000 # 10 seconds # Show the item access status label in items lists showAccessStatuses: false - simpleView: - bitstreamPageSize: 5 - fullView: + bitstream: # Number of entries in the bitstream list in the full item view page. # Rounded to the nearest size in the list of selectable sizes on the # settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. - bitstreamPageSize: 5 + pageSize: 5 # Collection Page Config collection: diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts index 89134a321e..3be0d58c81 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -35,8 +35,17 @@ export class FullFileSectionComponent extends FileSectionComponent implements On originals$: Observable>>; licenses$: Observable>>; - originalOptions: PaginationComponentOptions; - licenseOptions: PaginationComponentOptions; + originalOptions = Object.assign(new PaginationComponentOptions(), { + id: 'obo', + currentPage: 1, + pageSize: this.appConfig.item.bitstream.pageSize + }); + + licenseOptions = Object.assign(new PaginationComponentOptions(), { + id: 'lbo', + currentPage: 1, + pageSize: this.appConfig.item.bitstream.pageSize + }); constructor( bitstreamDataService: BitstreamDataService, @@ -46,17 +55,6 @@ export class FullFileSectionComponent extends FileSectionComponent implements On @Inject(APP_CONFIG) protected appConfig: AppConfig ) { super(bitstreamDataService, notificationsService, translateService, appConfig); - this.originalOptions = Object.assign(new PaginationComponentOptions(), { - id: 'obo', - currentPage: 1, - pageSize: this.appConfig.item.fullView.bitstreamPageSize - }); - - this.licenseOptions = Object.assign(new PaginationComponentOptions(), { - id: 'lbo', - currentPage: 1, - pageSize: this.appConfig.item.fullView.bitstreamPageSize - }); } ngOnInit(): void { diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.ts index 2907a33482..08e792fc8b 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.ts @@ -44,7 +44,7 @@ export class FileSectionComponent implements OnInit { protected translateService: TranslateService, @Inject(APP_CONFIG) protected appConfig: AppConfig ) { - this.pageSize = this.appConfig.item.simpleView.bitstreamPageSize; + this.pageSize = this.appConfig.item.bitstream.pageSize; } ngOnInit(): void { diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 3940ea1c19..f87a5b868b 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -246,14 +246,11 @@ export class DefaultAppConfig implements AppConfig { }, // Show the item access status label in items lists showAccessStatuses: false, - simpleView: { - bitstreamPageSize: 5 - }, - fullView: { - // Number of entries in the bitstream list in the full item view page. + bitstream: { + // Number of entries in the bitstream list in the item view page. // Rounded to the nearest size in the list of selectable sizes on the // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. - bitstreamPageSize: 5 + pageSize: 5 } }; diff --git a/src/config/item-config.interface.ts b/src/config/item-config.interface.ts index 1351911334..35cb5260ae 100644 --- a/src/config/item-config.interface.ts +++ b/src/config/item-config.interface.ts @@ -7,14 +7,10 @@ export interface ItemConfig extends Config { // This is used to show the access status label of items in results lists showAccessStatuses: boolean; - simpleView: { - bitstreamPageSize: number; - }; - - fullView: { - // Number of entries in the bitstream list in the full item view page. + bitstream: { + // Number of entries in the bitstream list in the item view page. // Rounded to the nearest size in the list of selectable sizes on the // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. - bitstreamPageSize: number; + pageSize: number; } } diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 7410b17f37..ec49ff6009 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -230,14 +230,11 @@ export const environment: BuildConfig = { }, // Show the item access status label in items lists showAccessStatuses: false, - simpleView: { - bitstreamPageSize: 5 - }, - fullView: { - // Number of entries in the bitstream list in the full item view page. + bitstream: { + // Number of entries in the bitstream list in the item view page. // Rounded to the nearest size in the list of selectable sizes on the // settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. - bitstreamPageSize: 5 + pageSize: 5 } }, collection: { From 599a5fdca03387f7e6879b584619661564d02fc9 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 7 Dec 2022 14:46:28 -0600 Subject: [PATCH 5/5] Correct comment text --- config/config.example.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index bb4c691f6b..86c60073f0 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -208,7 +208,7 @@ item: # Show the item access status label in items lists showAccessStatuses: false bitstream: - # Number of entries in the bitstream list in the full item view page. + # Number of entries in the bitstream list in the item view page. # Rounded to the nearest size in the list of selectable sizes on the # settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. pageSize: 5 @@ -300,4 +300,4 @@ info: # display in supported metadata fields. By default, only dc.description.abstract is supported. markdown: enabled: false - mathjax: false \ No newline at end of file + mathjax: false