Page MenuHomec4science

tln-fulltext.component.ts
No OneTemporary

File Metadata

Created
Sun, Aug 18, 02:22

tln-fulltext.component.ts

import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TLN_CROSSREF_ROUTE, TLN_SEARCH_ROUTE, TLN_MANUSCRIPT_ROUTE, TLN_VIEWER_ROUTE, TLN_CONTEXT_VIEW_PARAM, TLN_FULLSCREEN_PARAM, TLN_FIND_PARAM, TLN_PAGE_PARAM, TLN_MANUSCRIPT_PARAM,
TLN_SELECTED_LINES_PARAM, TLN_TEXT_GENETIC_ORDER_PARAM, TLN_VIEW_OPTION_PARAM, TLN_ZOOM_PARAM, VIEW_OPTIONS, ONTOLOTY_PREFIX } from '../constants';
import { DataHandler } from '../data_handler';
import { FoundPage} from '../datatypes/search';
import { Mapping } from '../route-reader';
import { RouteUpdater } from '../route-updater';
import { TlnQueryService } from '../services';
@Component({
selector: 'tln-fulltext',
templateUrl: './tln-fulltext.component.html',
styleUrls: ['./tln-fulltext.component.css']
})
export class TlnFulltextComponent extends RouteUpdater implements OnInit {
protected currentRoute: string = TLN_SEARCH_ROUTE;
current_page_iri: string;
current_manuscript_unity: string;
dataHandler: DataHandler = new DataHandler(this);
fullscreen: boolean;
max_width: number = -1;
max_height: number = -1;
searchTerm: string;
resultsReceived: boolean = false;
selectedViewOption: string = VIEW_OPTIONS.TRANSKRIPTION
startSearch: boolean = false;
protected mapping: Mapping = {
current_page_iri: { param: TLN_PAGE_PARAM, type: "string" },
searchTerm: { param: TLN_FIND_PARAM, type: "string" },
current_manuscript_unity: { param: TLN_MANUSCRIPT_PARAM, type: "string" },
fullscreen: { param: TLN_FULLSCREEN_PARAM, type: "boolean" },
}
pages: FoundPage[] = [];
private readonly margin_width: number = 280;
private readonly initialPreviewWidth : number = 300;
previewWidth: number = this.initialPreviewWidth;
constructor(private tlnQueryService: TlnQueryService, protected router: Router, protected activatedRoute: ActivatedRoute ) {
super(router, activatedRoute);
}
ngOnInit() {
if (screen.availWidth - this.initialPreviewWidth - this.margin_width > 1000){
this.previewWidth = screen.availWidth - this.initialPreviewWidth - 1000;
}
this.max_width = screen.availWidth - this.previewWidth - this.margin_width;
this.max_height = screen.availHeight - 200;
this.dataHandler.addHandler('pages', { 'handler': FoundPage});
this.dataHandler['pages']['service'] = this
this.dataHandler.setQueryService(this.tlnQueryService);
this.dataHandler.start_processing.subscribe(
(started: boolean) =>{
this.resultsReceived = false;
this.startSearch = true;
});
this.dataHandler.processing_finished.subscribe(
(finished: boolean) =>{
this.resultsReceived = true;
this.startSearch = false;
});
super.ngOnInit();
}
private clearFindText() {
this.searchTerm = '';
this.pages = [];
super.updateParams();
}
private search(){
super.updateParams();
if (this.searchTerm != undefined && this.searchTerm != null && this.searchTerm != ''){
this.dataHandler.getData('pages', this.searchTerm);
}
}
protected readParams(params: Params){
let oldSearchTerm = this.searchTerm;
super.readParams(params);
if (this.searchTerm != undefined && this.searchTerm != null && this.searchTerm != '' && this.searchTerm != oldSearchTerm){
this.dataHandler.getData('pages', this.searchTerm);
}
}
getSearchTerms(): string[] {
return this.searchTerm.split(' ');
}
}

Event Timeline