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 { Injectable, isDevMode } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
import {
|
||||||
import { filter, last, map, switchMap } from 'rxjs/operators';
|
getFirstCompletedRemoteData,
|
||||||
|
} from '../../core/shared/operators';
|
||||||
|
import { filter, last, map, mergeMap, switchMap } from 'rxjs/operators';
|
||||||
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 { Bitstream } from '../../core/shared/bitstream.model';
|
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||||
@@ -36,36 +38,44 @@ export class MiradorViewerService {
|
|||||||
* @returns the total image count
|
* @returns the total image count
|
||||||
*/
|
*/
|
||||||
getImageCount(item: Item, bitstreamDataService: BitstreamDataService, bundleDataService: BundleDataService):
|
getImageCount(item: Item, bitstreamDataService: BitstreamDataService, bundleDataService: BundleDataService):
|
||||||
Observable<number> {
|
Observable<number> {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
return bundleDataService.findAllByItem(item).pipe(
|
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(
|
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
map((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => bitstreamsRD.payload),
|
map((bundlesRD: RemoteData<PaginatedList<Bundle>>) => {
|
||||||
map((paginatedList: PaginatedList<Bitstream>) => paginatedList.page),
|
return bundlesRD.payload
|
||||||
switchMap((bitstreams: Bitstream[]) => bitstreams),
|
}),
|
||||||
switchMap((bitstream: Bitstream) => bitstream.format.pipe(
|
map((paginatedList: PaginatedList<Bundle>) => paginatedList.page),
|
||||||
getFirstSucceededRemoteDataPayload(),
|
switchMap((bundles: Bundle[]) => bundles),
|
||||||
map((format: BitstreamFormat) => format)
|
filter((b: Bundle) => this.isIiifBundle(b.name)),
|
||||||
)),
|
mergeMap((bundle: Bundle) => {
|
||||||
map((format: BitstreamFormat) => {
|
return bitstreamDataService.findAllByItemAndBundleName(item, bundle.name, {
|
||||||
if (format.mimetype.includes('image')) {
|
currentPage: 1,
|
||||||
count++;
|
elementsPerPage: 5
|
||||||
}
|
}, true, true, ...this.LINKS_TO_FOLLOW).pipe(
|
||||||
return count;
|
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()
|
last()
|
||||||
);
|
);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isIiifBundle(bundleName: string): boolean {
|
isIiifBundle(bundleName: string): boolean {
|
||||||
|
Reference in New Issue
Block a user