diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b5da66d56f5235ad854d5a471633d846dd21d275..d312301a809c030934ea2c1415306880331ab9e5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,7 +21,7 @@ import { MatTabsModule } from '@angular/material/tabs'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { LogoutComponent } from './logout/logout.component'; import { HistoryTrackingComponent } from './history-tracking/history-tracking.component'; -import { MatProgressSpinnerModule, MatProgressBarModule, MatDialogModule } from '@angular/material' +import { MatProgressSpinnerModule, MatProgressBarModule, MatDialogModule, MatSelectModule, MatOptionModule } from '@angular/material' import { OAuthModule } from "angular-oauth2-oidc"; import { UploadFilesComponent } from './upload-files/upload-files.component'; import { authConfigFactory } from './auth-config-factory'; @@ -67,7 +67,9 @@ import { DeleteReportDialog } from './delete-report-dialog/delete-report-dialog. MatProgressSpinnerModule, MatProgressBarModule, OAuthModule.forRoot(), - MatDialogModule + MatDialogModule, + MatSelectModule, + MatOptionModule /*OAuthModule.forRoot({ resourceServer: { //allowedUrls: [environment.apiUrl], diff --git a/src/app/document-detail/document-detail.component.html b/src/app/document-detail/document-detail.component.html index d1172384c8825ea62ba859c39661ae2ab9753da8..b40b2e554deb7c020e1bdef9e145989b68db9092 100644 --- a/src/app/document-detail/document-detail.component.html +++ b/src/app/document-detail/document-detail.component.html @@ -14,17 +14,18 @@
-

{{report.name}}

+

{{report.fileName}}

-
- - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + + All + + {{section.name}} + + + +
diff --git a/src/app/document-detail/document-detail.component.ts b/src/app/document-detail/document-detail.component.ts index 777d8bcc560d8e475d5f33d9844bb3d1343ad2d8..d677821c960de836dfe56531a7420c5f3e9fee72 100644 --- a/src/app/document-detail/document-detail.component.ts +++ b/src/app/document-detail/document-detail.component.ts @@ -14,6 +14,7 @@ import { Router } from '@angular/router'; import { CdisSendCtService } from '../services/cdis-send-ct.service'; import { Status } from '../model/srdomainfindingstatus'; import { Report } from '../model/report'; +import { Section } from '../model/section'; //brat declare var head: any; @@ -62,6 +63,10 @@ export class DocumentDetailComponent implements OnInit { addFindingEnabled: boolean; + currentSection: any = "all"; + + sections: Section[]; + data: SafeHtml; docData: string; @@ -194,7 +199,7 @@ export class DocumentDetailComponent implements OnInit { this.router.events.subscribe((res) => { this.activeLinkIndex = this.navLinks.indexOf(this.navLinks.find(tab => tab.link === '.' + this.router.url)); }); - this.getDocument(); + this.getReport(); this.findSRDomainComboValues(); } @@ -206,87 +211,102 @@ export class DocumentDetailComponent implements OnInit { this.cdiscSendCTService.findStudyDomainList(); } - getDocument(): void { - const id = this.route.snapshot.paramMap.get('id'); - this.reportService.getReport(id) - .subscribe(report => { - this.report = report; - this.setNextStatus(this.report.status); - var data_relevant_sentences = []; - var srDomainFindingsGlobal = []; - report.sections.forEach(section => { - section.annotations.relevantSentences.forEach(annotation => { - var findings = []; - annotation.findings.forEach(find => { - var srDomainFindings = []; - find.srDomainFindings.forEach(srDomainFinding => { - const currentFinding = ({ - studyid: srDomainFinding.studyid, - domain: srDomainFinding.domain, - srseq: srDomainFinding.srseq, - srrisk: srDomainFinding.srrisk, - - spgrpcd: srDomainFinding.spgrpcd, - srgrpnam: srDomainFinding.srgrpnam, - srgrpdos: srDomainFinding.srgrpdos, - srsex: srDomainFinding.srsex, - - srstdy: srDomainFinding.srstdy, - srstphse: srDomainFinding.srstphse, - srobstdy: srDomainFinding.srobstdy, - srendy: srDomainFinding.srendy, - - srenphse: srDomainFinding.srenphse, - srobendy: srDomainFinding.srobendy, - srdomain: srDomainFinding.srdomain, - srspec: srDomainFinding.srspec, - - srtstcd: srDomainFinding.srtstcd, - srfndg: srDomainFinding.srfndg, - srores: srDomainFinding.srores, - srobsv: srDomainFinding.srobsv, - - srobsq: srDomainFinding.srobsq, - srsev: srDomainFinding.srsev, - srpcnt: srDomainFinding.srpcnt, - srsigf: srDomainFinding.srsigf, - - srtrtef: srDomainFinding.srpcnt, - srcomnt: srDomainFinding.srsigf, - - export: srDomainFinding.export, - srDomainId: srDomainFinding.srDomainId, - findingId: srDomainFinding.findingId, - status: srDomainFinding.status, - section: section.name, - documentId: section.annotations.documentId - }); - - findings.push(currentFinding); - srDomainFindings.push(currentFinding); - }); - - srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); - }); - - data_relevant_sentences.push({ - id: annotation.id, - text: annotation.text, - findings: findings, + loadReport(report) { + this.report = report; + this.setNextStatus(this.report.status); + var data_relevant_sentences = []; + var srDomainFindingsGlobal = []; + report.sections.forEach(section => { + section.annotations.relevantSentences.forEach(annotation => { + var findings = []; + annotation.findings.forEach(find => { + var srDomainFindings = []; + find.srDomainFindings.forEach(srDomainFinding => { + const currentFinding = ({ + studyid: srDomainFinding.studyid, + domain: srDomainFinding.domain, + srseq: srDomainFinding.srseq, + srrisk: srDomainFinding.srrisk, + + spgrpcd: srDomainFinding.spgrpcd, + srgrpnam: srDomainFinding.srgrpnam, + srgrpdos: srDomainFinding.srgrpdos, + srsex: srDomainFinding.srsex, + + srstdy: srDomainFinding.srstdy, + srstphse: srDomainFinding.srstphse, + srobstdy: srDomainFinding.srobstdy, + srendy: srDomainFinding.srendy, + + srenphse: srDomainFinding.srenphse, + srobendy: srDomainFinding.srobendy, + srdomain: srDomainFinding.srdomain, + srspec: srDomainFinding.srspec, + + srtstcd: srDomainFinding.srtstcd, + srfndg: srDomainFinding.srfndg, + srores: srDomainFinding.srores, + srobsv: srDomainFinding.srobsv, + + srobsq: srDomainFinding.srobsq, + srsev: srDomainFinding.srsev, + srpcnt: srDomainFinding.srpcnt, + srsigf: srDomainFinding.srsigf, + + srtrtef: srDomainFinding.srpcnt, + srcomnt: srDomainFinding.srsigf, + + export: srDomainFinding.export, + srDomainId: srDomainFinding.srDomainId, + findingId: srDomainFinding.findingId, + status: srDomainFinding.status, + section: section.name, documentId: section.annotations.documentId }); + + findings.push(currentFinding); + srDomainFindings.push(currentFinding); }); - if (section.annotations.srdomainfindings) { - section.annotations.srdomainfindings.forEach(newFinding => { - srDomainFindingsGlobal.push(newFinding); - }); - } + srDomainFindingsGlobal = srDomainFindingsGlobal.concat(srDomainFindings); }); - this.tableDataPretoxSentences = data_relevant_sentences; - this.tableDataSRDomainTemplate = srDomainFindingsGlobal; + data_relevant_sentences.push({ + id: annotation.id, + text: annotation.text, + findings: findings, + documentId: section.annotations.documentId + }); }); + + if (section.annotations.srdomainfindings) { + section.annotations.srdomainfindings.forEach(newFinding => { + srDomainFindingsGlobal.push(newFinding); + }); + } + }); + + this.tableDataPretoxSentences = data_relevant_sentences; + this.tableDataSRDomainTemplate = srDomainFindingsGlobal; + this.eventService.changeSectionEvent.emit(this); + } + + getReport(): void { + const id = this.route.snapshot.paramMap.get('id'); + if (this.currentSection && this.currentSection.name) { + this.reportService.findReportSection(id, this.currentSection.id) + .subscribe(report => { + this.loadReport(report); + this.getSentencesEvidence(); + }); + } else { + this.reportService.getReport(id) + .subscribe(report => { + this.loadReport(report); + this.sections = report.sections; + this.getSentencesEvidence(); + }); + } } rowClickSentenceEvidence(dataRow: any): void { @@ -365,50 +385,55 @@ export class DocumentDetailComponent implements OnInit { }); } + loadEvidence(text) { + this.docData = text; + 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 = ''; + }, 1000); + }); + } + getAllEvidence() { - //const id = +this.route.snapshot.paramMap.get('id'); const id = this.report.id; - this.reportService.getAllEvidence(id) - .subscribe(text => { - this.docData = text; - 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); - // setTimeout(() => { - // document.getElementById('loadingDiv').className = ''; - // }, 4000); + if (this.currentSection == undefined || this.currentSection == "all") { + this.reportService.getAllEvidence(id) + .subscribe(text => { + this.loadEvidence(text) }); - }); + } else { + this.reportService.getSectionEvidence(id, this.currentSection.id) + .subscribe(text => { + this.loadEvidence(text) + }); + } } getSentencesEvidence() { //const id = +this.route.snapshot.paramMap.get('id'); const id = this.report.id; - this.reportService.getSentencesEvidence(id) - .subscribe(text => { - this.docData = text; - 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); + if (this.currentSection == undefined || this.currentSection == "all") { + this.reportService.getSentencesEvidence(id) + .subscribe(text => { + this.loadEvidence(text); }); - }); + } else { + this.reportService.getSectionSentencesEvidence(id, this.currentSection.id) + .subscribe(text => { + this.loadEvidence(text); + }); + } } setExportSRDomain(data) { @@ -534,6 +559,10 @@ export class DocumentDetailComponent implements OnInit { } } + onSectionChange() { + this.getReport(); + } + goBack(): void { this.location.back(); } diff --git a/src/app/model/srdomainfinding.ts b/src/app/model/srdomainfinding.ts index d1bb1b24ead686733a1863a107f19d2758de4db6..7f6dfebd42a5a2bb683bfbcc640ea575b8106b26 100644 --- a/src/app/model/srdomainfinding.ts +++ b/src/app/model/srdomainfinding.ts @@ -1,6 +1,7 @@ export class SRDomainFinding { studyid: String; domain: String; + section: String; srseq: String; srrisk: String; spgrpcd: String; diff --git a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts index 2186e5cbf1edb53b64c5c6f1b933303fb96c04dd..ef54fca3a73ac43b7b892caa26607ea7d9a373b6 100644 --- a/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts +++ b/src/app/pretoxsentences-tabulator/pretoxsentences-tabulator.component.ts @@ -1,10 +1,10 @@ -import { Component, Input, OnChanges, SimpleChanges, OnInit, EventEmitter, Output } from '@angular/core'; +import { Component, Input, SimpleChanges, OnInit, EventEmitter, Output } from '@angular/core'; +import { Subscription } from 'rxjs'; import { TabulatorFull as Tabulator } from 'tabulator-tables'; -import { ActivatedRoute } from '@angular/router'; -import { DocumentService } from '../services/document.service'; import { Document } from '../model/document'; +import { EventService } from '../services/event.service'; @Component({ selector: 'app-pretoxsentences-tabulator', @@ -13,15 +13,11 @@ import { Document } from '../model/document'; }) export class PretoxsentencesTabulatorComponent implements OnInit { - //@Input() tableData: any[] = []; - //@Input() columnNames: any[] = []; - tableData: any[] = []; - sentence_data: any[] = []; + changeSectionEvent: Subscription; + @Input() document: Document; @Input() height = '100%'; - //@Input() height = '600px'; - // list properties you want to set per implementation here... @Output() rowClickEvent = new EventEmitter(); @Output() rowClickExportSRDomainEvent = new EventEmitter(); @@ -31,20 +27,25 @@ export class PretoxsentencesTabulatorComponent implements OnInit { tab = document.createElement('div'); - constructor(private route: ActivatedRoute, private documentService: DocumentService) { + constructor(private eventService: EventService) { } ngOnInit(): void { - this.tableData = this.sentence_data; - this.drawTable(this); + this.changeSectionEvent = this.eventService.changeSectionEvent.subscribe((parentComponent) => { + this.loadData(parentComponent); + }); + } + + activation(parentComponent) { + this.loadData(parentComponent); } - activation(parentComponent){ - this.document = parentComponent.document; - this.sentence_data = parentComponent.tableDataPretoxSentences; + ngOnDestroy() { + this.changeSectionEvent.unsubscribe(); } - ngOnChanges(changes: SimpleChanges): void { + loadData(parentComponent) { + this.tableData = parentComponent.tableDataPretoxSentences; this.drawTable(this); } diff --git a/src/app/services/event.service.ts b/src/app/services/event.service.ts index 4b80dd04145fe76409761d55d112eaabba92018e..9d2dbf823a088add1b8734b4a883e5543430d568 100644 --- a/src/app/services/event.service.ts +++ b/src/app/services/event.service.ts @@ -7,5 +7,7 @@ export class EventService { addFindingEvent: EventEmitter = new EventEmitter(); + changeSectionEvent: EventEmitter = new EventEmitter(); + constructor() { } } \ No newline at end of file diff --git a/src/app/services/report.service.ts b/src/app/services/report.service.ts index 24a1de90f99215dbc3908cb71c6c4f24583d05c2..55db43b3786173266f1415e8cba4223d4b011b03 100644 --- a/src/app/services/report.service.ts +++ b/src/app/services/report.service.ts @@ -31,7 +31,7 @@ export class ReportService { return this.http.get(url); } - findReportSection(reportId:string, sectionId: string): Observable { + findReportSection(reportId:string, sectionId: number): Observable { const url = `${this.reportsUrl}${reportId}/section/${sectionId}`; return this.http.get(url); } diff --git a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts index f92d891f2c189d703b09aa472d5082ac82532b97..ea09b19fbd0b43f11255f07def02f678ca6ac968 100644 --- a/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts +++ b/src/app/srdomaintemplate-tabulator/srdomaintemplate-tabulator.component.ts @@ -1,13 +1,13 @@ import { Component, Input, OnInit, EventEmitter, Output } from '@angular/core'; import { TabulatorFull as Tabulator } from 'tabulator-tables'; import { CdisSendCtService } from '../services/cdis-send-ct.service'; -import { ActivatedRoute } from '@angular/router'; -import { DocumentService } from '../services/document.service'; -import { Document } from '../model/document'; import { cloneDeep } from 'lodash'; import { EventService } from '../services/event.service'; import { Status } from '../model/srdomainfindingstatus'; import { SRDomainFinding } from '../model/srdomainfinding'; +import { Report } from '../model/report'; +import { Subscription } from 'rxjs'; +import { Section } from '../model/section'; @Component({ selector: 'app-srdomaintemplate-tabulator', @@ -16,12 +16,13 @@ import { SRDomainFinding } from '../model/srdomainfinding'; }) export class SrdomaintemplateTabulatorComponent implements OnInit { + currentSection: string; tableData: any[] = []; table: Tabulator; originalData: any[] = []; - finding_data: any[] = []; - @Input() document: Document; + changeSectionEvent: Subscription; + @Input() report: Report; @Input() height = '100%'; @Output() rowClickEventSRDomainTemplateEvidence = new EventEmitter(); @@ -33,7 +34,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { tab = document.createElement('div'); - constructor(private route: ActivatedRoute, private documentService: DocumentService, private cdiscSendCTService: CdisSendCtService, private eventService: EventService) { } + constructor(private cdiscSendCTService: CdisSendCtService, private eventService: EventService) { } ellipsisFormatter(cell, formatterParams, onRendered) { onRendered(function () { @@ -45,23 +46,36 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { }; ngOnInit(): void { - this.tableData = this.finding_data; - this.originalData = cloneDeep(this.finding_data); - this.drawTable(this); this.enableAddFindingEvent.emit(true); this.eventService.addFindingEvent.subscribe(() => { this.addFinding(); }); + + this.changeSectionEvent = this.eventService.changeSectionEvent.subscribe((parentComponent) => { + this.loadData(parentComponent, true); + }); } ngOnDestroy() { this.enableAddFindingEvent.emit(false); + this.changeSectionEvent.unsubscribe(); + } + + activation(parentComponent) { + this.loadData(parentComponent, false); } - activation(parentComponent){ - this.document = parentComponent.document; - this.finding_data= parentComponent.tableDataSRDomainTemplate; - } + loadData(parentComponent, update) { + this.currentSection = parentComponent.currentSection && parentComponent.currentSection.name; + this.report = parentComponent.report; + this.tableData = parentComponent.tableDataSRDomainTemplate; + this.originalData = cloneDeep(parentComponent.tableDataSRDomainTemplate); + if (update) { + this.table.setData(this.tableData); + } else { + this.drawTable(this); + } + } editCheck(cell) { return cell.getRow().getData().inEdition == true; @@ -181,10 +195,11 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { addFinding() { const findingId = this.table.getDataCount() + 1; const newFinding = new SRDomainFinding(); - newFinding.studyid = this.document.name; + newFinding.studyid = this.report.id + "_" + this.report.fileName; newFinding.srDomainId = findingId; newFinding.findingId = findingId; newFinding.status = Status.ADDED; + newFinding.section = this.currentSection; this.tableData.push(newFinding); this.table.addRow(newFinding); @@ -290,10 +305,10 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var row = cell.getRow(); var data = row.getData(); if (data.inEdition == false || data.inEdition == undefined) { - if (pretoxSRDomainTemplateTab.document.findingInEdition == undefined || - pretoxSRDomainTemplateTab.document.findingInEdition == -1) { + if (pretoxSRDomainTemplateTab.report.findingInEdition == undefined || + pretoxSRDomainTemplateTab.report.findingInEdition == -1) { data.inEdition = true; - pretoxSRDomainTemplateTab.document.findingInEdition = 1; + pretoxSRDomainTemplateTab.report.findingInEdition = 1; pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(false); row.getCell('ed2').getElement().innerHTML = '
'; cell.getElement().innerHTML = '
'; @@ -304,7 +319,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { } } else if (data.inEdition == true) { data.inEdition = false; - pretoxSRDomainTemplateTab.document.findingInEdition = -1; + pretoxSRDomainTemplateTab.report.findingInEdition = -1; pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(true); row.getCell('ed2').getElement().innerHTML = ''; cell.getElement().innerHTML = '
'; @@ -325,7 +340,7 @@ export class SrdomaintemplateTabulatorComponent implements OnInit { var data = cell.getRow().getData(); if (data.inEdition == true) { data.inEdition = false; - pretoxSRDomainTemplateTab.document.findingInEdition = -1; + pretoxSRDomainTemplateTab.report.findingInEdition = -1; pretoxSRDomainTemplateTab.enableAddFindingEvent.emit(true); row.getElement().className = "tabulator-row"; row.getCells().forEach(rowCell => {