Page MenuHomec4science

navigation.component.ts
No OneTemporary

File Metadata

Created
Sat, Nov 16, 07:03

navigation.component.ts

import { Component, OnInit, Input } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import {MatBottomSheet, MatBottomSheetRef} from '@angular/material/bottom-sheet';
import { TlnQueryServiceInterface, Reference, ManuscriptUnity, NavigationPage } from '../../models';
import { TlnManuscriptUnity, TlnNavigationPage} from '../../datatypes/navigation';
import { DEFAULT_VIEW_OPTION, TLN_VIEWER_ROUTE, TLN_CROSSREF_ROUTE, TLN_CONTEXT_VIEW_PARAM, TLN_FULLSCREEN_PARAM, TLN_FIND_PARAM, TLN_PAGE_PARAM, TLN_MANUSCRIPT_PARAM,
TLN_SELECTED_LINES_PARAM, TLN_VIEW_OPTION_PARAM, TLN_ZOOM_PARAM, VIEW_OPTIONS, ONTOLOTY_PREFIX } from '../../constants';
import { IsReconstructedKonvolut } from '../../datatypes/basic_datatype';
import { TlnLine} from '../../datatypes/line';
import { TlnTextGeneticOrder} from '../../datatypes/text_version';
import { Mapping } from '../../route-reader';
import { RouteUpdater } from '../../route-updater';
import { ComplexKeyIriMapping, DataHandler, KeyIriMapping } from '../../data_handler';
import { PageViewService, TlnQueryService } from '../../services';
import { TlnInformationComponent, ParentInformation } from '../../tln-information/tln-information.component';
import { PageInformation } from '../../tln-information/page-information';
@Component({
selector: 'crossref-navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.css']
})
export class NavigationComponent extends RouteUpdater {
/**
* OPTIONAL pass a queryService with method
* {@link /interfaces/TlnQueryServiceInterface.html#getData|getData}
* to TlnPageViewComponent.
**/
@Input() queryService: TlnQueryServiceInterface;
/**
* whether or not to show page view in fullscreen mode.
**/
fullscreen: boolean = false;
zoomFactor: number = 1;
findText: string;
current_iri: string;
current_manuscript_iri: string;
current_page: NavigationPage;
pageInformation: PageInformation;
previous_page: NavigationPage;
next_page: NavigationPage;
showArchivalManuscriptUnity: boolean = false;
dataHandler: DataHandler = new DataHandler(this);
geneticOrders: TlnTextGeneticOrder[] = [];
selectedLines: string[] = [];
private readonly PAGE_CONTEXT_VIEW: string = TLN_PAGE_PARAM;
private readonly MANUSCRIPT_CONTEXT_VIEW: string = TLN_MANUSCRIPT_PARAM;
contextView: string = this.PAGE_CONTEXT_VIEW;
private readonly increment: number = 0.333;
private readonly decrement: number = this.increment*-1;
protected currentRoute: string = TLN_CROSSREF_ROUTE;
protected mapping: Mapping = { findText: { param: TLN_FIND_PARAM, type: "string" },
contextView: { param: TLN_CONTEXT_VIEW_PARAM, type: "string" },
current_iri: { param: TLN_PAGE_PARAM, type: "string" },
current_manuscript_iri: { param: TLN_MANUSCRIPT_PARAM, type: "string" },
fullscreen: { param: TLN_FULLSCREEN_PARAM, type: "boolean" },
zoomFactor: { param: TLN_ZOOM_PARAM, type: "number" }
}
routerParams: Params;
selectedViewOption: string = DEFAULT_VIEW_OPTION
updating: boolean = false;
viewOptions: string[] = [ VIEW_OPTIONS.TRANSKRIPTION, VIEW_OPTIONS.FAKSIMILE, VIEW_OPTIONS.SYNOPSIS, VIEW_OPTIONS.SYNOPSIS_B ];
constructor(private bottomSheet: MatBottomSheet, private pageViewService: PageViewService, private localQueryService: TlnQueryService, protected router: Router, protected activatedRoute: ActivatedRoute ) {
super(router, activatedRoute);
}
ngOnInit() {
let tlnQueryService = (this.queryService != null) ? this.queryService : this.localQueryService;
this.dataHandler.addHandler('navigation_page', ['current_page', 'geneticOrders'] );
this.dataHandler.addHandler('current_page', { 'handler': TlnNavigationPage });
this.dataHandler.addHandler('geneticOrders', { 'handler': TlnTextGeneticOrder});
this.dataHandler.setQueryService(tlnQueryService);
this.dataHandler.start_processing.subscribe(
(started: boolean) =>{ this.updating = true;
});
this.dataHandler.processing_finished.subscribe(
(finished: boolean) =>{ this.updating = false;
});
super.ngOnInit();
this.pageViewService.reference.subscribe(
(newReference: Reference) => {
this.updatePageToReference(newReference)
})
this.pageViewService.onClickedLine.subscribe(
(clickedLine: TlnLine) => {
let index = this.selectedLines.indexOf(clickedLine.id)
if (index > -1){
this.selectedLines.splice(index, 1);
} else {
this.selectedLines.push(clickedLine.id);
}
this.updateParams();
});
}
private clearFindText() {
this.findText = '';
this.updateParams();
}
changeContext(){
this.contextView = (this.contextView == this.PAGE_CONTEXT_VIEW) ? this.MANUSCRIPT_CONTEXT_VIEW : this.PAGE_CONTEXT_VIEW;
//this.current_genetic_order_iri = 'none';
this.updateParams();
}
private getPageTitle(page?: NavigationPage, numPages?: number): string {
if (page == null){
return '';
}
let indexPrefix = (numPages != null) ? page.index + '/' + numPages : page.index;
return indexPrefix + ': ' + page.title + ' ' + page.number;
}
private getZoomTitle(changeValue: number): string {
if (this.zoomFactor+changeValue < 0){
return Math.round(this.zoomFactor*50) + '%';
}
return Math.round((this.zoomFactor+changeValue)*100) + '%';
}
protected readParams(params: Params){
super.readParams(params);
if (this.dataHandler.ready && (this.current_page == null || this.current_page.id != this.current_iri)){
this.dataHandler.resetData('navigation_page')
this.dataHandler.getData('current_page', this.current_iri);
}
}
private setZoomFactor(newZoomFactor: number){
if (newZoomFactor > 0){
this.zoomFactor = Math.round(newZoomFactor*100)/100;
} else {
this.zoomFactor = this.zoomFactor/2
}
this.updateParams();
}
private setCurrentIri(pageIri: string){
this.dataHandler.stop_processing.emit(true);
this.current_iri = pageIri;
this.currentRoute = TLN_VIEWER_ROUTE;
this.updateParams();
}
private showInformation() {
let parentData: ParentInformation = {
geneticOrders: this.geneticOrders,
page: this.current_page,
manuscript_iri: this.current_manuscript_iri
}
this.bottomSheet.open(TlnInformationComponent, {
data: parentData
});
}
private updatePageToReference(reference: Reference){
this.current_iri = <string>reference.page.id;
this.selectedLines = [ <string>reference.line.id ]
this.updateParams();
}
private toggleFullscreen(){
this.fullscreen = !this.fullscreen;
this.updateParams();
}
public test(iri?: string){
this.bottomSheet.open(TlnInformationComponent);
//this.dataHandler.isOfType('showArchivalManuscriptUnity', 'http://rdfh.ch/projects/0068#_Mp_XIV', 'http://www.nie.org/ontology/nietzsche#ArchivalManuscriptUnity')
}
}

Event Timeline