mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Correction in the image count method.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Injectable, isDevMode } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
||||
import { filter, last, map, switchMap } from 'rxjs/operators';
|
||||
import {
|
||||
getFirstCompletedRemoteData,
|
||||
} from '../../core/shared/operators';
|
||||
import { filter, last, map, mergeMap, switchMap } from 'rxjs/operators';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||
@@ -36,36 +38,44 @@ export class MiradorViewerService {
|
||||
* @returns the total image count
|
||||
*/
|
||||
getImageCount(item: Item, bitstreamDataService: BitstreamDataService, bundleDataService: BundleDataService):
|
||||
Observable<number> {
|
||||
let count = 0;
|
||||
return bundleDataService.findAllByItem(item).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((bundlesRD: RemoteData<PaginatedList<Bundle>>) => bundlesRD.payload),
|
||||
map((paginatedList: PaginatedList<Bundle>) => paginatedList.page),
|
||||
switchMap((bundles: Bundle[]) => bundles),
|
||||
filter((b: Bundle) => this.isIiifBundle(b.name)),
|
||||
switchMap((bundle: Bundle) => {
|
||||
return bitstreamDataService.findAllByItemAndBundleName(item, bundle.name, {
|
||||
currentPage: 1,
|
||||
elementsPerPage: 5
|
||||
}, true, true, ...this.LINKS_TO_FOLLOW).pipe(
|
||||
Observable<number> {
|
||||
let count = 0;
|
||||
return bundleDataService.findAllByItem(item).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => bitstreamsRD.payload),
|
||||
map((paginatedList: PaginatedList<Bitstream>) => paginatedList.page),
|
||||
switchMap((bitstreams: Bitstream[]) => bitstreams),
|
||||
switchMap((bitstream: Bitstream) => bitstream.format.pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
map((format: BitstreamFormat) => format)
|
||||
)),
|
||||
map((format: BitstreamFormat) => {
|
||||
if (format.mimetype.includes('image')) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
map((bundlesRD: RemoteData<PaginatedList<Bundle>>) => {
|
||||
return bundlesRD.payload
|
||||
}),
|
||||
map((paginatedList: PaginatedList<Bundle>) => paginatedList.page),
|
||||
switchMap((bundles: Bundle[]) => bundles),
|
||||
filter((b: Bundle) => this.isIiifBundle(b.name)),
|
||||
mergeMap((bundle: Bundle) => {
|
||||
return bitstreamDataService.findAllByItemAndBundleName(item, bundle.name, {
|
||||
currentPage: 1,
|
||||
elementsPerPage: 5
|
||||
}, true, true, ...this.LINKS_TO_FOLLOW).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {
|
||||
return bitstreamsRD.payload;
|
||||
}),
|
||||
map((paginatedList: PaginatedList<Bitstream>) => paginatedList.page),
|
||||
switchMap((bitstreams: Bitstream[]) => bitstreams),
|
||||
switchMap((bitstream: Bitstream) => bitstream.format.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((formatRD: RemoteData<BitstreamFormat>) => {
|
||||
return formatRD.payload
|
||||
}),
|
||||
map((format: BitstreamFormat) => {
|
||||
if (format.mimetype.includes('image')) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}),
|
||||
)
|
||||
)
|
||||
);
|
||||
}),
|
||||
last()
|
||||
);
|
||||
}));
|
||||
);
|
||||
}
|
||||
|
||||
isIiifBundle(bundleName: string): boolean {
|
||||
|
Reference in New Issue
Block a user