diff --git a/src/app/annotate/annotate.component.ts b/src/app/annotate/annotate.component.ts index 5964d75..bfc6057 100644 --- a/src/app/annotate/annotate.component.ts +++ b/src/app/annotate/annotate.component.ts @@ -1,69 +1,60 @@ import { Component } from '@angular/core'; -import { CommonModule, NgFor } from '@angular/common'; +import { CommonModule } from '@angular/common'; import { TagListComponent } from '../tag-list/tag-list.component'; import { FormsModule } from '@angular/forms'; -import { TabComponent } from '../tabs/tab.component'; -import { TabsComponent } from '../tabs/tabs.component'; -import { AnnotateSimpleTabComponent } from '../annotate-simple-tab/annotate-simple-tab.component'; -import { AnnotateRdfTabComponent } from '../annotate-rdf-tab/annotate-rdf-tab.component'; @Component({ selector: 'app-annotate', - standalone: true, - imports: [ - CommonModule, - TagListComponent, - FormsModule, - NgFor, - TabsComponent, - TabComponent, - AnnotateSimpleTabComponent, - AnnotateRdfTabComponent - ], + // Remove standalone property + exports: [TagListComponent], + imports: [CommonModule, FormsModule], templateUrl: './annotate.component.html', - styleUrl: './annotate.component.scss' + // Change styleUrl to styleUrls + styleUrls: ['./annotate.component.scss'] }) -export default class AnnotateComponent { +export class AnnotateComponent { - fileInput : string = ""; - annotations : any; + fileInput: string = ""; + annotations: any[] = []; // Define type explicitly assuming annotations is an array baseUrl = 'http://akswnc7.informatik.uni-leipzig.de:19899/api/search?id='; async query(term: string) { let query = `${this.baseUrl}${term}` - const data = await fetch(query); - return await data.json() ?? []; + try { + const data = await fetch(query); + return await data.json() ?? []; + } catch (error) { + console.error('Error fetching data:', error); + return []; + } } - - onSelectAnnotation(event : any) { - var annotation = event.tag; - - + onSelectAnnotation(event: any) { + // Utilize the annotation variable if needed + console.log('Selected annotation:', event.tag); } - onFileChange(event : Event) { - this.search(this.fileInput); + onFileChange(event: Event) { + // Handle file input change appropriately + console.log('File input changed:', event); } - async search(input : string) { + async search(input: string) { var result = await this.query(input); - if(result == null || result.docs == null || result.docs.length == 0) { + const noResult = result == null || result.docs == null || result.docs.length === 0; + if (noResult) { this.annotations = []; return; } - var doc = result.docs[0]; - - if(doc.annotation == null) { + const doc = result.docs[0]; + if (doc.annotation == null) { this.annotations = []; return; } this.annotations = doc.annotation; - - } }