Commit 978a7269 authored by Javi Corvi's avatar Javi Corvi
Browse files

problems merging

parents dc5ea950 b5156cc9
Pipeline #25771 passed with stage
in 1 minute and 2 seconds
......@@ -8,12 +8,14 @@ import { Finding } from '../finding';
import { Annotation } from '../annotation';
import { environment } from './../../environments/environment';
import {MatToolbarModule} from '@angular/material/toolbar';
import { Router } from '@angular/router';
//brat
declare var head: any;
declare var Util: any;
declare var Visualizer: any;
var displaySpanComment = function (evt, target, spanId, spanType, mods, spanText, commentText, commentType, normalizations) {
var left = evt.clientX + "px";
......@@ -159,36 +161,67 @@ export class DocumentDetailComponent implements OnInit {
this.navLinks = [
{
label: 'Sentence Level',
label: 'Relevant Sentences',
link: './first',
index: 0
}, {
}/*, {
label: 'Findings Level',
link: './second',
index: 1
}, {
label: 'SR-Domain Level',
}*/, {
label: 'Findings',
link: './third',
index: 2
index: 1
}
];
this.nextStatus = ['DRAFT', 'IN_PROGRESS', 'FINISHED'];
;
}
loadBratVisualizer():void{
const bratLocation = environment.bratUrl;
//const bratLocation = 'http://10.32.6.2:8001';
head.js(
// External libraries
bratLocation + '/client/lib/jquery.min.js',
bratLocation + '/client/lib/jquery.svg.min.js',
bratLocation + '/client/lib/jquery.svgdom.min.js',
// brat helper modules
bratLocation + '/client/src/configuration.js',
bratLocation + '/client/src/util.js',
bratLocation + '/client/src/annotation_log.js',
bratLocation + '/client/lib/webfont.js',
// brat modules
bratLocation + '/client/src/dispatcher.js',
bratLocation + '/client/src/url_monitor.js',
bratLocation + '/client/src/visualizer.js'
);
}
// ngOnInit() {
// this.getDocument();
// }
loaded(): void {
alert('loaded');
var loading = document.getElementById('loadingDiv');
loading.style.display='none';
}
ngOnInit(): void {
this.router.events.subscribe((res) => {
this.activeLinkIndex = this.navLinks.indexOf(this.navLinks.find(tab => tab.link === '.' + this.router.url));
});
this.getDocument();
}
save(): void {
this.documentService.updateDocument(this.document)
.subscribe(() => this.goBack());
......@@ -201,26 +234,26 @@ export class DocumentDetailComponent implements OnInit {
.subscribe(document => {
this.document = document;
this.setNextStatus(this.document.status);
var data = [];
//var data = [];
var data_relevant_sentences = [];
document.findings.forEach(find => {
data.push({
id : find.findingId,
finding: find.finding != null ? find.finding.value : '',
study_testcd: find.study_testcd != null ? find.study_testcd.value : '',
manifestation_finding: find.manifestation_finding != null ? find.manifestation_finding.value : '',
study_domain: find.study_domain != null ? find.study_domain.value : '',
specimen: find.specimen != null ? find.specimen.value : '',
sex: find.sex != null ? find.sex.value : '',
dose: find.dose != null ? find.dose.value : '',
group: find.group != null ? find.group.value : '',
is_trf: find.is_treatment_related != null ? find.is_treatment_related.value : ''
});
});
// document.findings.forEach(find => {
// data.push({
// id : find.findingId,
// finding: find.finding != null ? find.finding.value : '',
// study_testcd: find.study_testcd != null ? find.study_testcd.value : '',
// manifestation_finding: find.manifestation_finding != null ? find.manifestation_finding.value : '',
// study_domain: find.study_domain != null ? find.study_domain.value : '',
// specimen: find.specimen != null ? find.specimen.value : '',
// sex: find.sex != null ? find.sex.value : '',
// dose: find.dose != null ? find.dose.value : '',
// group: find.group != null ? find.group.value : '',
// is_trf: find.is_treatment_related != null ? find.is_treatment_related.value : ''
// });
// });
//alert(data);
//alert(JSON.stringify(data));
this.tableData = data;
//this.tableData = data;
//this.clear();
//alert(JSON.stringify(document.findings));
//var j = JSON.parse('{ text:' + document.text + '}');
......@@ -338,39 +371,138 @@ export class DocumentDetailComponent implements OnInit {
findingSelected(finding): void {
this.documentService.findingSelected(this.document.documentId, finding)
.subscribe(text => {
this.docData = text;
console.log(this.docData);
var loading = document.getElementById('loadingDiv');
//loading.style.display='block';
loading.addEventListener("load", this.loaded);
this.docData = text;
//console.log(this.docData);
// console.log(JSON.parse(this.docData));
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
document.getElementById('loadingDiv').className = 'loader';
var j = JSON.parse(this.docData);
this.loadBratVisualizer();
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
setTimeout(() => {
document.getElementById('loadingDiv').className = '';
}, 4000);
});
});
}
pretoxSentenceSelected(pretoxSentence): void {
this.documentService.pretoxSentenceSelected(this.document.documentId, pretoxSentence)
.subscribe(text => {
this.docData = text;
console.log(this.docData);
//console.log(this.docData);
// console.log(JSON.parse(this.docData));
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
document.getElementById('loadingDiv').className = 'loader';
var j = JSON.parse(this.docData);
this.loadBratVisualizer();
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
//dispatcher.post('resetData');
//dispatcher.post('collectionChanged');
//dispatcher.post('triggerRender');
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
setTimeout(() => {
document.getElementById('loadingDiv').className = '';
}, 4000);
});
});
}
findDocumentText(): void {
this.documentService.findDocumentText(this.document.documentId)
.subscribe(text => {
this.docData = text;
//console.log(this.docData);
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
document.getElementById('loadingDiv').className = 'loader';
var j = JSON.parse(this.docData);
this.loadBratVisualizer();
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
setTimeout(() => {
document.getElementById('loadingDiv').className = '';
}, 4000);
});
});
}
getAllEvidence() {
//alert('getAllEvidence');
const id = +this.route.snapshot.paramMap.get('id');
//this.documentService.getAllEvidence(this.document.documentId)
this.documentService.getAllEvidence(id)
.subscribe(text => {
this.docData = text;
//console.log(this.docData);
// console.log(JSON.parse(this.docData));
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
document.getElementById('loadingDiv').className = 'loader';
var j = JSON.parse(this.docData);
this.loadBratVisualizer();
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
setTimeout(() => {
document.getElementById('loadingDiv').className = '';
}, 4000);
});
});
}
getSentencesEvidence() {
//alert('getSentencesEvidence');
const id = +this.route.snapshot.paramMap.get('id');
//this.documentService.getAllEvidence(this.document.documentId)
this.documentService.getSentencesEvidence(id)
.subscribe(text => {
this.docData = text;
//console.log(this.docData);
// console.log(JSON.parse(this.docData));
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
document.getElementById('loadingDiv').className = 'loader';
var j = JSON.parse(this.docData);
this.loadBratVisualizer();
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
document.getElementById('data2').className = 'FixedHeightContainer';
document.getElementById('data1').className = 'brat_div';
setTimeout(() => {
document.getElementById('loadingDiv').className = '';
}, 4000);
});
});
}
setExportSRDomain(data) {
const id = +this.route.snapshot.paramMap.get('id');
//alert(data);
......@@ -426,28 +558,18 @@ export class DocumentDetailComponent implements OnInit {
}
getAllEvidence() {
const id = +this.route.snapshot.paramMap.get('id');
this.documentService.getAllEvidence(this.document.documentId)
.subscribe(text => {
this.docData = text;
console.log(this.docData);
// console.log(JSON.parse(this.docData));
document.getElementById('data2').className = 'collapse show';
document.getElementById('data1').innerHTML = '';
document.getElementById('data1').className = '';
var j = JSON.parse(this.docData);
head.ready( function() {
const dispatcher = Util.embed('data1' , DocumentDetailComponent.collData, j, DocumentDetailComponent.webFontURLs);
dispatcher.on('displaySpanComment', displaySpanComment);
dispatcher.on('hideComment', hideComment);
});
});
}
onActivate(componentReference) {
console.log(componentReference)
componentReference.activation(this.document);
// if(componentReference.constructor.name=='PretoxsentencesTabulatorComponent'){
// this.getSentencesEvidence();
// }else if(componentReference.constructor.name=='SrdomaintemplateTabulatorComponent'){
// this.getAllEvidence();
// }else if(componentReference.constructor.name=='FindingTabulatorComponent'){
// this.getAllEvidence();
// }
//Below will subscribe to the searchItem emitter
if(componentReference.rowClickEventFinding!=undefined){
componentReference.rowClickEventFinding.subscribe((data) => {
......@@ -458,6 +580,8 @@ export class DocumentDetailComponent implements OnInit {
//Below will subscribe to the searchItem emitter
if(componentReference.rowClickEvent!=undefined){
alert('sentence activation');
this.getSentencesEvidence();
componentReference.rowClickEvent.subscribe((data) => {
//alert('rowClickEvent');
this.rowClickSentenceEvidence(data);
......@@ -475,6 +599,8 @@ export class DocumentDetailComponent implements OnInit {
//Below will subscribe to the searchItem emitter
if(componentReference.rowClickEventSRDomainTemplateEvidence!=undefined){
alert('sr-domain activation');
this.getAllEvidence();
componentReference.rowClickEventSRDomainTemplateEvidence.subscribe((data) => {
//alert('rowClickSRDomainTemplateEvidence');
this.rowClickSRDomainTemplateEvidence(data);
......@@ -505,4 +631,3 @@ export class DocumentDetailComponent implements OnInit {
});
}
}
......@@ -117,6 +117,17 @@ export class DocumentService {
catchError(this.handleError<string>(`getFinding id=${finding.findingId}`))
);
}
/** GET Snipped of the full text with no annotations */
findDocumentText(id: number): Observable<string> {
const url = `${this.documentsUrl}${id}/text/`;
return this.http.get(url , {responseType: 'text'}).pipe(
tap(_ => this.log(`fetched text id=${id}`)),
catchError(this.handleError<string>(`getText id=${id}`))
);
}
/** GET Snipped of findings selected just in case is needed, is not complete only the calls againt rest api is done*/
findingsSelected(id: number, finding: Finding): Observable<string> {
......@@ -137,6 +148,14 @@ export class DocumentService {
);
}
/** GET Snipped of sentences evidence */
getSentencesEvidence(id: number): Observable<string> {
const url = `${this.documentsUrl}${id}/evidence/sentences`;
return this.http.get(url , {responseType: 'text'}).pipe(
tap(_ => this.log(`fetched all sentences evidence id=${id}`)),
catchError(this.handleError<string>(`getSentencesEvidence id=${id}`))
);
}
pretoxSentenceSelected(id: number, pretoxSentence: Annotation): Observable<string> {
const url = `${this.documentsUrl}${id}/sentence/${pretoxSentence.id}`;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment