Page MenuHomec4science

open-in-viewer.component.ts
No OneTemporary

File Metadata

Created
Sat, Aug 3, 22:29

open-in-viewer.component.ts

import { Component, Input, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TLN_VIEWER_ROUTE, TLN_PAGE_PARAM, TLN_MANUSCRIPT_PARAM } from '../constants';
import { Mapping } from '../route-reader';
import { RouteUpdater } from '../route-updater';
import { NavigationPage } from '../models';
interface ViewerRouteInformation {
title: string;
number: string;
page: string;
manuscript?: string;
launchExternally?: boolean;
}
@Component({
selector: 'open-in-viewer',
templateUrl: './open-in-viewer.component.html',
styleUrls: ['./open-in-viewer.component.scss']
})
export class OpenInViewerComponent extends RouteUpdater {
@Input() routerInformation: ViewerRouteInformation;
launch: boolean = false;
page: NavigationPage;
protected currentRoute: string = TLN_VIEWER_ROUTE;
current_iri: string;
current_manuscript_unity: string;
protected mapping: Mapping = { current_iri: { param: TLN_PAGE_PARAM, type: "string" },
current_manuscript_unity: { param: TLN_MANUSCRIPT_PARAM, type: "string" }}
constructor(protected router: Router, protected activatedRoute: ActivatedRoute ) {
super(router, activatedRoute);
}
ngOnInit(){
super.ngOnInit();
this.page = { id: this.routerInformation.page,
number: this.routerInformation.number,
title: this.routerInformation.title };
this.launch = (this.routerInformation.launchExternally != undefined
&& this.routerInformation.launchExternally != null
&& this.routerInformation.launchExternally)
}
private openInViewer(){
if (this.routerInformation != undefined && this.routerInformation != null){
this.current_iri = this.routerInformation.page;
if (this.routerInformation.manuscript != undefined && this.routerInformation != null){
this.current_manuscript_unity = this.routerInformation.manuscript;
}
this.updateParams(this.launch);
}
}
}

Event Timeline