mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
#885 fix loading bitstream format
This commit is contained in:
@@ -46,7 +46,9 @@ export class MediaViewerImageComponent implements OnInit {
|
|||||||
small: image.thumbnail
|
small: image.thumbnail
|
||||||
? image.thumbnail
|
? image.thumbnail
|
||||||
: './assets/images/replacement_image.svg',
|
: './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,
|
big: image.bitstream._links.content.href,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
.media-viewer{
|
||||||
|
width: 340px;
|
||||||
|
height: 279px;
|
||||||
|
}
|
||||||
|
@@ -15,8 +15,6 @@ import { MediaViewerItem } from '../../core/shared/media-viewer-item.model';
|
|||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
import { VarDirective } from '../../shared/utils/var.directive';
|
||||||
import { MetadataFieldWrapperComponent } from '../field-components/metadata-field-wrapper/metadata-field-wrapper.component';
|
import { MetadataFieldWrapperComponent } from '../field-components/metadata-field-wrapper/metadata-field-wrapper.component';
|
||||||
import { FileSizePipe } from '../../shared/utils/file-size-pipe';
|
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', () => {
|
describe('MediaViewerComponent', () => {
|
||||||
let comp: MediaViewerComponent;
|
let comp: MediaViewerComponent;
|
||||||
@@ -57,13 +55,6 @@ describe('MediaViewerComponent', () => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const bitstreamFormatDataService = jasmine.createSpyObj(
|
|
||||||
'bitstreamFormatDataService',
|
|
||||||
{
|
|
||||||
findByBitstream: createSuccessfulRemoteDataObject$(new BitstreamFormat()),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const mockMediaViewerItem: MediaViewerItem = Object.assign(
|
const mockMediaViewerItem: MediaViewerItem = Object.assign(
|
||||||
new MediaViewerItem(),
|
new MediaViewerItem(),
|
||||||
{ bitstream: mockBitstream, format: 'image', thumbnail: null }
|
{ bitstream: mockBitstream, format: 'image', thumbnail: null }
|
||||||
@@ -88,10 +79,6 @@ describe('MediaViewerComponent', () => {
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BitstreamDataService, useValue: bitstreamDataService },
|
{ provide: BitstreamDataService, useValue: bitstreamDataService },
|
||||||
{
|
|
||||||
provide: BitstreamFormatDataService,
|
|
||||||
useValue: bitstreamFormatDataService,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
|
@@ -2,7 +2,6 @@ import { Component, Input, OnInit } from '@angular/core';
|
|||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { filter, take } from 'rxjs/operators';
|
import { filter, take } from 'rxjs/operators';
|
||||||
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
|
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 { PaginatedList } from '../../core/data/paginated-list';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
|
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 { MediaViewerItem } from '../../core/shared/media-viewer-item.model';
|
||||||
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../shared/empty.util';
|
||||||
|
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This componenet renders the media viewers
|
* This componenet renders the media viewers
|
||||||
@@ -32,7 +32,6 @@ export class MediaViewerComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected bitstreamDataService: BitstreamDataService,
|
protected bitstreamDataService: BitstreamDataService,
|
||||||
protected bitstreamFormatDataService: BitstreamFormatDataService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,9 +43,8 @@ export class MediaViewerComponent implements OnInit {
|
|||||||
this.loadRemoteData('ORIGINAL').subscribe((bitstreamsRD) => {
|
this.loadRemoteData('ORIGINAL').subscribe((bitstreamsRD) => {
|
||||||
this.loadRemoteData('THUMBNAIL').subscribe((thumbnailsRD) => {
|
this.loadRemoteData('THUMBNAIL').subscribe((thumbnailsRD) => {
|
||||||
for (let index = 0; index < bitstreamsRD.payload.page.length; index++) {
|
for (let index = 0; index < bitstreamsRD.payload.page.length; index++) {
|
||||||
this.bitstreamFormatDataService
|
bitstreamsRD.payload.page[index].format
|
||||||
.findByBitstream(bitstreamsRD.payload.page[index])
|
.pipe(getFirstSucceededRemoteDataPayload())
|
||||||
.pipe(getFirstSucceededRemoteDataPayload())
|
|
||||||
.subscribe((format) => {
|
.subscribe((format) => {
|
||||||
const current = this.mediaList$.getValue();
|
const current = this.mediaList$.getValue();
|
||||||
const mediaItem = this.createMediaViewerItem(
|
const mediaItem = this.createMediaViewerItem(
|
||||||
@@ -70,7 +68,7 @@ export class MediaViewerComponent implements OnInit {
|
|||||||
bundleName: string
|
bundleName: string
|
||||||
): Observable<RemoteData<PaginatedList<Bitstream>>> {
|
): Observable<RemoteData<PaginatedList<Bitstream>>> {
|
||||||
return this.bitstreamDataService
|
return this.bitstreamDataService
|
||||||
.findAllByItemAndBundleName(this.item, bundleName)
|
.findAllByItemAndBundleName(this.item, bundleName, {}, followLink('format'))
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(
|
filter(
|
||||||
(bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) =>
|
(bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) =>
|
||||||
|
Reference in New Issue
Block a user