Skip to content

Commit

Permalink
Updated mark function
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-lperezra committed Aug 23, 2024
1 parent 75f3fe6 commit 951c54f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion encoder-ui/src/app/analysis/analysis.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<tbody>
@for (textAndDiagnostic of textAndDiagnosticList; track $index) {
@for (diagnostic of textAndDiagnostic.diagnostics; track diagnostic; let i = $index) {
<tr>
<tr (mouseover)="markDiagnosis(textAndDiagnostic.rawText)" (mouseout)="unmarkDiagnosis()">
<td>{{textAndDiagnostic.rawText}}</td>
<td>
{{ diagnostic.code }}
Expand Down
22 changes: 19 additions & 3 deletions encoder-ui/src/app/analysis/analysis.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Diagnostic {
}

interface TextAndDiagnostic {
rawText: String;
rawText: string;
diagnostics: Array<Diagnostic>;
}

Expand All @@ -25,7 +25,7 @@ interface AnalysisText {
})
export class AnalysisComponent implements OnInit{

textUpdated = "";
textUpdated: String = "";
diagnostics: Array<any> = [];
loading = false;
loadingMain = false;
Expand All @@ -38,6 +38,7 @@ export class AnalysisComponent implements OnInit{
collectionSize = 0;
textOriginal: string = "";
screenHeight: number = 0;
textToMark: String = "";

constructor(private irisService: IrisService)
{
Expand Down Expand Up @@ -83,6 +84,7 @@ export class AnalysisComponent implements OnInit{
this.diagnostics = [];
this.textAndDiagnosticList = [];
var textHTML = textSelected;
this.textToMark = textSelected;
this.loading = true;
this.irisService.getAnalysisDetails(idAnalysis).subscribe({next: res => {
if (res.length > 0){
Expand Down Expand Up @@ -118,7 +120,6 @@ export class AnalysisComponent implements OnInit{
const diagnosticEncoded: Diagnostic = {code: diagnostic.CodeId, description: diagnostic.Description, similarity: diagnostic.Similarity}
if (indexDiag == -1)
{
textHTML = textHTML.replace(phrase,"<mark>"+phrase+"</mark>");
let textAndDiagnostic: TextAndDiagnostic = {rawText: phrase, diagnostics: []};
textAndDiagnostic.diagnostics.push(diagnosticEncoded);
this.textAndDiagnosticList.push(textAndDiagnostic);
Expand All @@ -131,4 +132,19 @@ export class AnalysisComponent implements OnInit{
this.loading = false;
}})
}

markDiagnosis(text: string) {
var textHTML = this.textToMark;
textHTML = textHTML.replace("<mark>","");
textHTML = textHTML.replace("</mark>","");
textHTML = textHTML.replace(text,"<mark>"+text+"</mark>");
this.textUpdated = textHTML;
}

unmarkDiagnosis() {
var textHTML = this.textToMark;
textHTML = textHTML.replace("<mark>","");
textHTML = textHTML.replace("</mark>","");
this.textUpdated = textHTML;
}
}
2 changes: 1 addition & 1 deletion encoder-ui/src/app/analyzer/analyzer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<tbody>
@for (textAndDiagnostic of textAndDiagnosticList; track $index) {
@for (diagnostic of textAndDiagnostic.diagnostics; track diagnostic; let i = $index) {
<tr>
<tr (mouseover)="markDiagnosis(textAndDiagnostic.rawText)" (mouseout)="unmarkDiagnosis()">
<td>{{textAndDiagnostic.rawText}}</td>
<td>
{{ diagnostic.code }}
Expand Down
18 changes: 16 additions & 2 deletions encoder-ui/src/app/analyzer/analyzer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export class AnalyzerComponent {
const diagnosticEncoded: Diagnostic = {code: diagnostic.CodeId, description: diagnostic.Description, similarity: diagnostic.Similarity}
if (indexDiag == -1)
{
textHTML = textHTML.replace(phrase,"<mark>"+phrase+"</mark>");
let textAndDiagnostic: TextAndDiagnostic = {rawText: phrase, diagnostics: []};
textAndDiagnostic.diagnostics.push(diagnosticEncoded);
this.textAndDiagnosticList.push(textAndDiagnostic);
Expand Down Expand Up @@ -134,9 +133,24 @@ export class AnalyzerComponent {
this.error = true;
this.loading = false;
}});
}
}

markDiagnosis(text: String) {
var textHTML = this.textToAnalyze?.value;
textHTML = textHTML.replace("<mark>","");
textHTML = textHTML.replace("</mark>","");
textHTML = textHTML.replace(text,"<mark>"+text+"</mark>");
this.textUpdated = textHTML;
}

createAlert() {
alert("Es un diagnóstico");
}

unmarkDiagnosis() {
var textHTML = this.textToAnalyze?.value;
textHTML = textHTML.replace("<mark>","");
textHTML = textHTML.replace("</mark>","");
this.textUpdated = textHTML;
}
}

0 comments on commit 951c54f

Please sign in to comment.