#885 fix loading bitstream format

This commit is contained in:
Dániel Péter Sipos
2020-11-03 10:59:31 +01:00
parent 401bbf3a8e
commit 4312776b2d
4 changed files with 11 additions and 20 deletions

View File

@@ -46,7 +46,9 @@ export class MediaViewerImageComponent implements OnInit {
small: image.thumbnail
? image.thumbnail
: './assets/images/replacement_image.svg',
medium: image.bitstream._links.content.href,
medium: image.thumbnail
? image.thumbnail
: './assets/images/replacement_image.svg',
big: image.bitstream._links.content.href,
});
}

View File

@@ -0,0 +1,4 @@
.media-viewer{
width: 340px;
height: 279px;
}

View File

@@ -15,8 +15,6 @@ import { MediaViewerItem } from '../../core/shared/media-viewer-item.model';
import { VarDirective } from '../../shared/utils/var.directive';
import { MetadataFieldWrapperComponent } from '../field-components/metadata-field-wrapper/metadata-field-wrapper.component';
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
import { BitstreamFormatDataService } from '../../core/data/bitstream-format-data.service';
describe('MediaViewerComponent', () => {
let comp: MediaViewerComponent;
@@ -57,13 +55,6 @@ describe('MediaViewerComponent', () => {
),
});
const bitstreamFormatDataService = jasmine.createSpyObj(
'bitstreamFormatDataService',
{
findByBitstream: createSuccessfulRemoteDataObject$(new BitstreamFormat()),
}
);
const mockMediaViewerItem: MediaViewerItem = Object.assign(
new MediaViewerItem(),
{ bitstream: mockBitstream, format: 'image', thumbnail: null }
@@ -88,10 +79,6 @@ describe('MediaViewerComponent', () => {
],
providers: [
{ provide: BitstreamDataService, useValue: bitstreamDataService },
{
provide: BitstreamFormatDataService,
useValue: bitstreamFormatDataService,
},
],
schemas: [NO_ERRORS_SCHEMA],

View File

@@ -2,7 +2,6 @@ import { Component, Input, OnInit } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { filter, take } from 'rxjs/operators';
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
import { BitstreamFormatDataService } from '../../core/data/bitstream-format-data.service';
import { PaginatedList } from '../../core/data/paginated-list';
import { RemoteData } from '../../core/data/remote-data';
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
@@ -11,6 +10,7 @@ import { Item } from '../../core/shared/item.model';
import { MediaViewerItem } from '../../core/shared/media-viewer-item.model';
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
import { hasValue } from '../../shared/empty.util';
import { followLink } from '../../shared/utils/follow-link-config.model';
/**
* This componenet renders the media viewers
@@ -32,7 +32,6 @@ export class MediaViewerComponent implements OnInit {
constructor(
protected bitstreamDataService: BitstreamDataService,
protected bitstreamFormatDataService: BitstreamFormatDataService
) {}
/**
@@ -44,9 +43,8 @@ export class MediaViewerComponent implements OnInit {
this.loadRemoteData('ORIGINAL').subscribe((bitstreamsRD) => {
this.loadRemoteData('THUMBNAIL').subscribe((thumbnailsRD) => {
for (let index = 0; index < bitstreamsRD.payload.page.length; index++) {
this.bitstreamFormatDataService
.findByBitstream(bitstreamsRD.payload.page[index])
.pipe(getFirstSucceededRemoteDataPayload())
bitstreamsRD.payload.page[index].format
.pipe(getFirstSucceededRemoteDataPayload())
.subscribe((format) => {
const current = this.mediaList$.getValue();
const mediaItem = this.createMediaViewerItem(
@@ -70,7 +68,7 @@ export class MediaViewerComponent implements OnInit {
bundleName: string
): Observable<RemoteData<PaginatedList<Bitstream>>> {
return this.bitstreamDataService
.findAllByItemAndBundleName(this.item, bundleName)
.findAllByItemAndBundleName(this.item, bundleName, {}, followLink('format'))
.pipe(
filter(
(bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) =>