Improved performance of mirador component by avoiding IIIF bundle bitstream lookup.

This commit is contained in:
Michael Spalti
2021-08-19 13:00:58 -07:00
parent 6019a21ebd
commit fb0d51c574

View File

@@ -1,4 +1,4 @@
import {ChangeDetectionStrategy, Component, Inject, Input, OnInit, PLATFORM_ID} from '@angular/core';
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit, PLATFORM_ID } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { Item } from '../../../core/shared/item.model';
import { environment } from '../../../../environments/environment';
@@ -10,7 +10,8 @@ import { Bitstream } from '../../../core/shared/bitstream.model';
import { hasValue } from '../../../shared/empty.util';
import { Observable } from 'rxjs/internal/Observable';
import { map } from 'rxjs/operators';
import {isPlatformBrowser} from '@angular/common';
import { of } from 'rxjs';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'ds-mirador-viewer',
@@ -75,6 +76,21 @@ export class MiradorViewerComponent implements OnInit {
if (window.innerWidth > 768) {
this.notMobile = true;
}
// We need to set the multi property to true if the
// item is searchable or the IIIF bundle contains more
// than 3 bitstreams. The multi property controls the
// Mirador side navigation panel.
if (this.searchable) {
// If it's searchable set multi to true.
const observable = of({multi: true});
this.iframeViewerUrl = observable.pipe(
map((val) => {
this.multi = val.multi;
return this.setURL();
})
);
} else {
this.iframeViewerUrl = this.bitstreamDataService
.findAllByItemAndBundleName(this.item, 'IIIF', {})
.pipe(
@@ -83,8 +99,8 @@ export class MiradorViewerComponent implements OnInit {
if (hasValue(bitstreamsRD.payload)) {
if (bitstreamsRD.payload.totalElements > 2) {
/* IIIF bundle contains multiple images and optionally a
* a single json file, thus multi is true only when the count is 3 or more .
* multi=true enables the side navigation panel in Mirador. */
* a single json file, so multi is true only when the count
* is 3 or more. */
this.multi = true;
}
}
@@ -93,4 +109,5 @@ export class MiradorViewerComponent implements OnInit {
);
}
}
}
}