Added global config for list thumbnails

This commit is contained in:
Michael Spalti
2022-08-21 09:06:27 -07:00
parent 56c8c8c370
commit d01bfe2cb1
10 changed files with 49 additions and 19 deletions

View File

@@ -50,7 +50,8 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
ngOnInit(): void { ngOnInit(): void {
const sortConfig = new SortOptions('default', SortDirection.ASC); const sortConfig = new SortOptions('default', SortDirection.ASC);
this.startsWithType = StartsWithType.date; 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.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);
this.subs.push( this.subs.push(
@@ -63,7 +64,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
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;
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.updatePageWithItems(searchOptions, this.value, undefined);
this.updateParent(params.scope); this.updateParent(params.scope);
this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope); this.updateStartsWithOptions(this.browseId, metadataKeys, params.scope);

View File

@@ -1,5 +1,5 @@
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs'; 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 { RemoteData } from '../../core/data/remote-data';
import { PaginatedList } from '../../core/data/paginated-list.model'; import { PaginatedList } from '../../core/data/paginated-list.model';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.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 { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-by-decorator';
import { PaginationService } from '../../core/pagination/pagination.service'; import { PaginationService } from '../../core/pagination/pagination.service';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { environment } from '../../../environments/environment';
export const BBM_PAGINATION_ID = 'bbm'; export const BBM_PAGINATION_ID = 'bbm';
@@ -111,16 +113,24 @@ export class BrowseByMetadataPageComponent implements OnInit {
*/ */
startsWith: string; startsWith: string;
/**
* Determines whether to request embedded thumbnail.
*/
embedThumbnail: boolean;
public constructor(protected route: ActivatedRoute, public constructor(protected route: ActivatedRoute,
protected browseService: BrowseService, protected browseService: BrowseService,
protected dsoService: DSpaceObjectDataService, protected dsoService: DSpaceObjectDataService,
protected paginationService: PaginationService, protected paginationService: PaginationService,
protected router: Router) { protected router: Router) {
this.embedThumbnail = environment.showItemThumbnails;
} }
ngOnInit(): void { ngOnInit(): void {
const sortConfig = new SortOptions('default', SortDirection.ASC); 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.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);
this.subs.push( this.subs.push(
@@ -133,15 +143,16 @@ export class BrowseByMetadataPageComponent implements OnInit {
this.authority = params.authority; this.authority = params.authority;
this.value = +params.value || params.value || ''; this.value = +params.value || params.value || '';
this.startsWith = +params.startsWith || params.startsWith; this.startsWith = +params.startsWith || params.startsWith;
const searchOptions = browseParamsToOptions(params, currentPage, currentSort, this.browseId);
if (isNotEmpty(this.value)) { 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 { } else {
this.updatePage(searchOptions); this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
} }
this.updateParent(params.scope); this.updateParent(params.scope);
})); }));
this.updateStartsWithTextOptions(); this.updateStartsWithTextOptions();
} }
/** /**
@@ -234,16 +245,19 @@ export class BrowseByMetadataPageComponent implements OnInit {
* @param paginationConfig Pagination configuration * @param paginationConfig Pagination configuration
* @param sortConfig Sorting configuration * @param sortConfig Sorting configuration
* @param metadata Optional metadata definition to fetch browse entries/items for * @param metadata Optional metadata definition to fetch browse entries/items for
* @param embedThumbnails Optional parameter for requesting thumbnail images
*/ */
export function browseParamsToOptions(params: any, export function browseParamsToOptions(params: any,
paginationConfig: PaginationComponentOptions, paginationConfig: PaginationComponentOptions,
sortConfig: SortOptions, sortConfig: SortOptions,
metadata?: string): BrowseEntrySearchOptions { metadata?: string,
embedThumbnails?: boolean): BrowseEntrySearchOptions {
return new BrowseEntrySearchOptions( return new BrowseEntrySearchOptions(
metadata, metadata,
paginationConfig, paginationConfig,
sortConfig, sortConfig,
+params.startsWith || params.startsWith, +params.startsWith || params.startsWith,
params.scope params.scope,
embedThumbnails
); );
} }

View File

@@ -30,13 +30,15 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
protected browseService: BrowseService, protected browseService: BrowseService,
protected dsoService: DSpaceObjectDataService, protected dsoService: DSpaceObjectDataService,
protected paginationService: PaginationService, protected paginationService: PaginationService,
protected router: Router) { protected router: Router,
) {
super(route, browseService, dsoService, paginationService, router); super(route, browseService, dsoService, paginationService, router);
} }
ngOnInit(): void { ngOnInit(): void {
const sortConfig = new SortOptions('dc.title', SortDirection.ASC); 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.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);
this.subs.push( this.subs.push(
@@ -47,7 +49,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => { ).subscribe(([params, currentPage, currentSort]: [Params, 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, currentPage, currentSort, this.browseId), undefined, undefined); this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.embedThumbnail), undefined, undefined);
this.updateParent(params.scope); this.updateParent(params.scope);
})); }));
this.updateStartsWithTextOptions(); this.updateStartsWithTextOptions();

View File

@@ -6,13 +6,16 @@ import { SortOptions } from '../cache/models/sort-options.model';
* - metadataDefinition: The metadata definition to fetch entries or items for * - metadataDefinition: The metadata definition to fetch entries or items for
* - pagination: Optional pagination options to use * - pagination: Optional pagination options to use
* - sort: Optional sorting 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 * - 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 { export class BrowseEntrySearchOptions {
constructor(public metadataDefinition: string, constructor(public metadataDefinition: string,
public pagination?: PaginationComponentOptions, public pagination?: PaginationComponentOptions,
public sort?: SortOptions, public sort?: SortOptions,
public startsWith?: string, public startsWith?: string,
public scope?: string) { public scope?: string,
public embedThumbnail?: boolean) {
} }
} }

View File

@@ -105,10 +105,8 @@ export class BrowseService {
return href; return href;
}) })
); );
if (options.embedThumbnail) {
if (options.metadataDefinition == 'title' || options.metadataDefinition == 'dateissued' ) {
return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_ENTRY_LINKS_TO_FOLLOW); return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_ENTRY_LINKS_TO_FOLLOW);
} }
return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(href$); return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(href$);
} }
@@ -155,7 +153,7 @@ export class BrowseService {
return href; return href;
}), }),
); );
if (options.metadataDefinition == 'title' || options.metadataDefinition == 'dateissued' || hasValue(filterValue)) { if (options.embedThumbnail) {
return this.hrefOnlyDataService.findAllByHref<Item>(href$, {}, null, null, ...BROWSE_ITEM_LINKS_TO_FOLLOW); return this.hrefOnlyDataService.findAllByHref<Item>(href$, {}, null, null, ...BROWSE_ITEM_LINKS_TO_FOLLOW);
} }
return this.hrefOnlyDataService.findAllByHref<Item>(href$); return this.hrefOnlyDataService.findAllByHref<Item>(href$);

View File

@@ -1,12 +1,12 @@
<div class="row"> <div class="row">
<div class="col-md-2"> <div *ngIf="showThumbnails" class="col-md-2">
<a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer" <a *ngIf="linkType != linkTypes.None" [target]="(linkType == linkTypes.ExternalLink) ? '_blank' : '_self'" rel="noopener noreferrer"
[routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out"> [routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out">
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true"> <ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
</ds-thumbnail> </ds-thumbnail>
</a> </a>
</div> </div>
<div class="col-md-10"> <div [ngClass]="showThumbnails ? 'col-md-10' : 'col-md-12'">
<div class="d-flex"> <div class="d-flex">
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge> <ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
<ds-access-status-badge [item]="dso" class="pl-1"></ds-access-status-badge> <ds-access-status-badge [item]="dso" class="pl-1"></ds-access-status-badge>

View File

@@ -5,6 +5,7 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s
import { SearchResultListElementComponent } from '../../../search-result-list-element.component'; import { SearchResultListElementComponent } from '../../../search-result-list-element.component';
import { Item } from '../../../../../../core/shared/item.model'; import { Item } from '../../../../../../core/shared/item.model';
import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-paths'; import { getItemPageRoute } from '../../../../../../item-page/item-page-routing-paths';
import { environment } from '../../../../../../../environments/environment';
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement) @listableObjectComponent('PublicationSearchResult', ViewMode.ListElement)
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement) @listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
@@ -22,8 +23,14 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
*/ */
itemPageRoute: string; itemPageRoute: string;
/**
* Display thumbnails if required by configuration
*/
showThumbnails: boolean;
ngOnInit(): void { ngOnInit(): void {
super.ngOnInit(); super.ngOnInit();
this.showThumbnails = environment.showItemThumbnails;
this.itemPageRoute = getItemPageRoute(this.dso); this.itemPageRoute = getItemPageRoute(this.dso);
} }
} }

View File

@@ -31,6 +31,7 @@ interface AppConfig extends Config {
defaultLanguage: string; defaultLanguage: string;
languages: LangConfig[]; languages: LangConfig[];
browseBy: BrowseByConfig; browseBy: BrowseByConfig;
showItemThumbnails: boolean;
item: ItemConfig; item: ItemConfig;
collection: CollectionPageConfig; collection: CollectionPageConfig;
themes: ThemeConfig[]; themes: ThemeConfig[];

View File

@@ -208,6 +208,9 @@ export class DefaultAppConfig implements AppConfig {
defaultLowerLimit: 1900 defaultLowerLimit: 1900
}; };
// Whether to add item thumbnail images to browse and search result lists.
showItemThumbnails: false;
// Item Config // Item Config
item: ItemConfig = { item: ItemConfig = {
edit: { edit: {

View File

@@ -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) // The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
defaultLowerLimit: 1900, defaultLowerLimit: 1900,
}, },
showItemThumbnails: false,
item: { item: {
edit: { edit: {
undoTimeout: 10000 // 10 seconds undoTimeout: 10000 // 10 seconds