intermediate commit

This commit is contained in:
lotte
2018-08-29 15:12:01 +02:00
parent 2cbe6a6d91
commit 777facf5cd
91 changed files with 1150 additions and 964 deletions

View File

@@ -1,3 +1,4 @@
import {map, startWith, filter} from 'rxjs/operators';
import { Observable } from 'rxjs';
import { DSpaceObject } from './dspace-object.model';
@@ -58,9 +59,9 @@ export class Item extends DSpaceObject {
// TODO: currently this just picks the first thumbnail
// should be adjusted when we have a way to determine
// the primary thumbnail from rest
return this.getBitstreamsByBundleName('THUMBNAIL')
.filter((thumbnails) => isNotEmpty(thumbnails))
.map((thumbnails) => thumbnails[0])
return this.getBitstreamsByBundleName('THUMBNAIL').pipe(
filter((thumbnails) => isNotEmpty(thumbnails)),
map((thumbnails) => thumbnails[0]),)
}
/**
@@ -68,10 +69,10 @@ export class Item extends DSpaceObject {
* @returns {Observable<Bitstream>} the primaryBitstream of the 'THUMBNAIL' bundle
*/
getThumbnailForOriginal(original: Bitstream): Observable<Bitstream> {
return this.getBitstreamsByBundleName('THUMBNAIL')
.map((files) => {
return this.getBitstreamsByBundleName('THUMBNAIL').pipe(
map((files) => {
return files.find((thumbnail) => thumbnail.name.startsWith(original.name))
}).startWith(undefined);
}),startWith(undefined),);
}
/**
@@ -88,15 +89,15 @@ export class Item extends DSpaceObject {
* @returns {Observable<Bitstream[]>} the bitstreams with the given bundleName
*/
getBitstreamsByBundleName(bundleName: string): Observable<Bitstream[]> {
return this.bitstreams
.map((rd: RemoteData<PaginatedList<Bitstream>>) => rd.payload.page)
.filter((bitstreams: Bitstream[]) => hasValue(bitstreams))
.startWith([])
.map((bitstreams) => {
return this.bitstreams.pipe(
map((rd: RemoteData<PaginatedList<Bitstream>>) => rd.payload.page),
filter((bitstreams: Bitstream[]) => hasValue(bitstreams)),
startWith([]),
map((bitstreams) => {
return bitstreams
.filter((bitstream) => hasValue(bitstream))
.filter((bitstream) => bitstream.bundleName === bundleName)
});
}),);
}
}