1 import {Component, Input, Renderer2} from '@angular/core';
2 import {DomSanitizer} from '@angular/platform-browser';
4 const OPAC_BASE_URL = '/eg/opac/record';
7 selector: 'eg-opac-record-detail',
8 templateUrl: 'opac.component.html'
10 export class OpacViewComponent {
12 url; // SafeResourceUrlImpl
16 @Input() set recordId(id: number) {
18 // Verify record ID is numeric only
19 if (id && (id + '').match(/^\d+$/)) {
21 this.url = this.sanitizer.bypassSecurityTrustResourceUrl(
22 `${OPAC_BASE_URL}/${id}?readonly=1`);
24 this._recordId = null;
29 get recordId(): number {
30 return this._recordId;
34 private sanitizer: DomSanitizer,
35 private renderer: Renderer2) {}
38 const iframe = this.renderer.selectRootElement('#opac-iframe');
40 // 50 extra px adds enough space to avoid the scrollbar altogether
41 const height = 50 + iframe.contentWindow.document.body.offsetHeight;
43 iframe.style.height = `${height}px`;