Page MenuHomec4science

info-box.component.ts
No OneTemporary

File Metadata

Created
Mon, Jun 24, 00:47

info-box.component.ts

import {Component, Input, OnChanges, Output} from '@angular/core';
import { MatExpansionModule } from '@angular/material/expansion';
import { Subscription} from 'rxjs';
import { WordService} from '../services/field-interaction.service';
import { Word } from '../models/models';
import {AnnotationService, TextStyleService} from '../services/annotation.service';
import { QueryService } from '../services/query.service';
import {DialogComponent} from '../dialog-component/dialog.component';
import {MatDialog} from '@angular/material';
@Component({
selector: 'app-info-box',
templateUrl: './info-box.component.html',
styleUrls: ['./info-box.component.css']
})
export class InfoBoxComponent implements OnChanges {
@Input() manuscript: any;
@Output() queryResponse: any;
@Output() markupData;
@Output() wordToMarkUp;
query: string;
word: Word;
wordSubscription: Subscription;
showInfo: boolean = false;
expansion: boolean = true;
constructor(private wordService: WordService,
private matExpansionModule: MatExpansionModule,
private textStyleService: TextStyleService,
private queryService: QueryService,
private annotationService: AnnotationService,
private dialog: MatDialog ) {
}
ngOnChanges() {
this.wordSubscription = this.wordService.wordChange$.subscribe(
word => {
if (this.word === word) {
this.toggleShowInfo();
} else {
this.word = word;
this.wordToMarkUp = word.text;
this.updateRDFData(word);
if (!this.showInfo) {
this.toggleShowInfo();
}
}
});
}
private toggleShowInfo() {
this.showInfo = !this.showInfo;
}
public updateRDFData(word) {
this.query = this.queryService.getQueryforResourceData( encodeURI('http://rdfh.ch/projects/0068#_W_II_1_Page131_Word206'), 'subject');
this.queryService.getData(this.query).subscribe(data => {
this.queryResponse = data;
});
this.markupData = null; // maybe not needed
this.markupData = this.annotationService.getAnnotationMarkup2(word);
console.log('this.markupData for', word , ': ', this.markupData);
// TODO: parse the annotations and apply them
// const fuu = 'PREFIX c: <' + decodeURI( 'http://example.org/cartoons#' ) + '> c:Tom a c:Cat. c:Jerry a c:Mouse; c:smarterThan c:Tom.'
// this.textStyleService.parseStyles(fuu);
}
private openInBrowser(word, shrunkTitle) {
// TODO: Change this to actual word.iri
word = encodeURI('http://rdfh.ch/projects/0068#_W_II_1_Page131_Word206');
this.dialog.open(DialogComponent, {
data: {
message: word, buttonText: {cancel: 'close'}, title: shrunkTitle, contentType: 1
},
});
}
}

Event Timeline