diff --git a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts index 271828a38e..caa7891861 100644 --- a/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts +++ b/src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts @@ -50,7 +50,8 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { ngOnInit(): void { const sortConfig = new SortOptions('default', SortDirection.ASC); this.startsWithType = StartsWithType.date; - this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig)); + this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null, + null, this.embedThumbnail)); this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig); this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig); this.subs.push( @@ -63,7 +64,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent { const metadataKeys = params.browseDefinition ? params.browseDefinition.metadataKeys : this.defaultMetadataKeys; this.browseId = params.id || this.defaultBrowseId; this.startsWith = +params.startsWith || params.startsWith; - const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId); + const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail); this.updatePageWithItems(searchOptions, this.value, undefined); this.updateParent(params.scope); this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope); diff --git a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts index c685fe31a7..bd25a38b91 100644 --- a/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts +++ b/src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts @@ -1,5 +1,5 @@ import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs'; -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { RemoteData } from '../../core/data/remote-data'; import { PaginatedList } from '../../core/data/paginated-list.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; @@ -17,6 +17,8 @@ import { StartsWithType } from '../../shared/starts-with/starts-with-decorator'; import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator'; import { PaginationService } from '../../core/pagination/pagination.service'; import { map } from 'rxjs/operators'; +import { environment } from '../../../environments/environment'; + export const BBM_PAGINATION_ID = 'bbm'; @@ -111,16 +113,24 @@ export class BrowseByMetadataPageComponent implements OnInit { */ startsWith: string; + /** + * Determines whether to request embedded thumbnail. + */ + embedThumbnail: boolean; + public constructor(protected route: ActivatedRoute, protected browseService: BrowseService, protected dsoService: DSpaceObjectDataService, protected paginationService: PaginationService, protected router: Router) { + this.embedThumbnail = environment.showItemThumbnails; } ngOnInit(): void { + const sortConfig = new SortOptions('default', SortDirection.ASC); - this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig)); + this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null, + null, false)); this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig); this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig); this.subs.push( @@ -133,15 +143,16 @@ export class BrowseByMetadataPageComponent implements OnInit { this.authority = params.authority; this.value = +params.value || params.value || ''; this.startsWith = +params.startsWith || params.startsWith; - const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId); if (isNotEmpty(this.value)) { - this.updatePageWithItems(searchOptions, this.value, this.authority); + this.updatePageWithItems( + browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail), this.value, this.authority); } else { - this.updatePage(searchOptions); + this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false)); } this.updateParent(params.scope); })); this.updateStartsWithTextOptions(); + } /** @@ -234,16 +245,19 @@ export class BrowseByMetadataPageComponent implements OnInit { * @param paginationConfig Pagination configuration * @param sortConfig Sorting configuration * @param metadata Optional metadata definition to fetch browse entries/items for + * @param embedThumbnails Optional parameter for requesting thumbnail images */ export function browseParamsToOptions(params: any, paginationConfig: PaginationComponentOptions, sortConfig: SortOptions, - metadata?: string): BrowseEntrySearchOptions { + metadata?: string, + embedThumbnails?: boolean): BrowseEntrySearchOptions { return new BrowseEntrySearchOptions( metadata, paginationConfig, sortConfig, +params.startsWith || params.startsWith, - params.scope + params.scope, + embedThumbnails ); } diff --git a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts index 6504a8700a..fbc3916400 100644 --- a/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts +++ b/src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts @@ -30,13 +30,15 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent { protected browseService: BrowseService, protected dsoService: DSpaceObjectDataService, protected paginationService: PaginationService, - protected router: Router) { + protected router: Router, + ) { super(route, browseService, dsoService, paginationService, router); } ngOnInit(): void { const sortConfig = new SortOptions('dc.title', SortDirection.ASC); - this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig)); + this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig, null, + null, this.embedThumbnail)); this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig); this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig); this.subs.push( @@ -47,7 +49,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent { ).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => { this.startsWith = +params.startsWith || params.startsWith; this.browseId = params.id || this.defaultBrowseId; - this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId), undefined, undefined); + this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail), undefined, undefined); this.updateParent(params.scope); })); this.updateStartsWithTextOptions(); diff --git a/src/app/core/browse/browse-entry-search-options.model.ts b/src/app/core/browse/browse-entry-search-options.model.ts index 417bf7ce75..a4b04e0d57 100644 --- a/src/app/core/browse/browse-entry-search-options.model.ts +++ b/src/app/core/browse/browse-entry-search-options.model.ts @@ -6,13 +6,16 @@ import { SortOptions } from '../cache/models/sort-options.model'; * - metadataDefinition: The metadata definition to fetch entries or items for * - pagination: Optional pagination options to use * - sort: Optional sorting options to use + * - startsWith An optional value to use to filter the browse results * - scope: An optional scope to limit the results within a specific collection or community + * - embedThumbnail An optional boolean to request thumbnail for items */ export class BrowseEntrySearchOptions { constructor(public metadataDefinition: string, public pagination?: PaginationComponentOptions, public sort?: SortOptions, public startsWith?: string, - public scope?: string) { + public scope?: string, + public embedThumbnail?: boolean) { } } diff --git a/src/app/core/browse/browse.service.ts b/src/app/core/browse/browse.service.ts index c34c32d9c2..46524e4385 100644 --- a/src/app/core/browse/browse.service.ts +++ b/src/app/core/browse/browse.service.ts @@ -105,10 +105,8 @@ export class BrowseService { return href; }) ); - - if (options.metadataDefinition == 'title' || options.metadataDefinition == 'dateissued' ) { + if (options.embedThumbnail) { return this.hrefOnlyDataService.findAllByHref(href$, {}, null, null, ...BROWSE_ENTRY_LINKS_TO_FOLLOW); - } return this.hrefOnlyDataService.findAllByHref(href$); } @@ -155,7 +153,7 @@ export class BrowseService { return href; }), ); - if (options.metadataDefinition == 'title' || options.metadataDefinition == 'dateissued' || hasValue(filterValue)) { + if (options.embedThumbnail) { return this.hrefOnlyDataService.findAllByHref(href$, {}, null, null, ...BROWSE_ITEM_LINKS_TO_FOLLOW); } return this.hrefOnlyDataService.findAllByHref(href$); diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html index c13821a153..fb0429a8b9 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html @@ -1,12 +1,12 @@
-
+ -
+
diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts index b5eb64869d..46c3efd126 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.ts @@ -5,6 +5,7 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; import { Item } from '../../../../../../core/shared/item.model'; import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-paths'; +import { environment } from '../../../../../../../environments/environment'; @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) @listableObjectComponent(ItemSearchResult, ViewMode.ListElement) @@ -22,8 +23,14 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen */ itemPageRoute: string; + /** + * Display thumbnails if required by configuration + */ + showThumbnails: boolean; + ngOnInit(): void { super.ngOnInit(); + this.showThumbnails = environment.showItemThumbnails; this.itemPageRoute = getItemPageRoute(this.dso); } } diff --git a/src/config/app-config.interface.ts b/src/config/app-config.interface.ts index cd9ef103ae..515de9613f 100644 --- a/src/config/app-config.interface.ts +++ b/src/config/app-config.interface.ts @@ -31,6 +31,7 @@ interface AppConfig extends Config { defaultLanguage: string; languages: LangConfig[]; browseBy: BrowseByConfig; + showItemThumbnails: boolean; item: ItemConfig; collection: CollectionPageConfig; themes: ThemeConfig[]; diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index d2d0608a03..8c4731d3b2 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -208,6 +208,9 @@ export class DefaultAppConfig implements AppConfig { defaultLowerLimit: 1900 }; + // Whether to add item thumbnail images to browse and search result lists. + showItemThumbnails: false; + // Item Config item: ItemConfig = { edit: { diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 4d466bd37b..edf986b88f 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -200,6 +200,7 @@ export const environment: BuildConfig = { // The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items) defaultLowerLimit: 1900, }, + showItemThumbnails: false, item: { edit: { undoTimeout: 10000 // 10 seconds