mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Added global config for list thumbnails
This commit is contained in:
@@ -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);
|
||||
|
@@ -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
|
||||
);
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
@@ -105,10 +105,8 @@ export class BrowseService {
|
||||
return href;
|
||||
})
|
||||
);
|
||||
|
||||
if (options.metadataDefinition == 'title' || options.metadataDefinition == 'dateissued' ) {
|
||||
if (options.embedThumbnail) {
|
||||
return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(href$, {}, null, null, ...BROWSE_ENTRY_LINKS_TO_FOLLOW);
|
||||
|
||||
}
|
||||
return this.hrefOnlyDataService.findAllByHref<BrowseEntry>(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<Item>(href$, {}, null, null, ...BROWSE_ITEM_LINKS_TO_FOLLOW);
|
||||
}
|
||||
return this.hrefOnlyDataService.findAllByHref<Item>(href$);
|
||||
|
@@ -1,12 +1,12 @@
|
||||
<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"
|
||||
[routerLink]="[itemPageRoute]" class="lead item-list-title dont-break-out">
|
||||
<ds-thumbnail [thumbnail]="dso?.thumbnail | async" [limitWidth]="true">
|
||||
</ds-thumbnail>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<div [ngClass]="showThumbnails ? 'col-md-10' : 'col-md-12'">
|
||||
<div class="d-flex">
|
||||
<ds-type-badge *ngIf="showLabel" [object]="dso"></ds-type-badge>
|
||||
<ds-access-status-badge [item]="dso" class="pl-1"></ds-access-status-badge>
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ interface AppConfig extends Config {
|
||||
defaultLanguage: string;
|
||||
languages: LangConfig[];
|
||||
browseBy: BrowseByConfig;
|
||||
showItemThumbnails: boolean;
|
||||
item: ItemConfig;
|
||||
collection: CollectionPageConfig;
|
||||
themes: ThemeConfig[];
|
||||
|
@@ -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: {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user