diff --git a/webapp/src/app/modules/keywords-search/keywords-search.component.html b/webapp/src/app/modules/keywords-search/keywords-search.component.html index a8f41190..3edd92ee 100644 --- a/webapp/src/app/modules/keywords-search/keywords-search.component.html +++ b/webapp/src/app/modules/keywords-search/keywords-search.component.html @@ -154,7 +154,7 @@ + matTooltip="Die Abbildung der extrahierten Keywords auf die bekannten Themenbereiche"> account_tree Topic Mapping @@ -167,7 +167,8 @@
+ [checked]="topicMappingSearch()" + matTooltip="Wenn aktiviert, werden die extrahierten Keywords auf bekannte Themenbereiche abgebildet, was die Suchergebnisse verbessert."> Topic Mapping
diff --git a/webapp/src/app/modules/keywords-search/keywords-search.component.ts b/webapp/src/app/modules/keywords-search/keywords-search.component.ts index 3bf8947e..d009ad67 100644 --- a/webapp/src/app/modules/keywords-search/keywords-search.component.ts +++ b/webapp/src/app/modules/keywords-search/keywords-search.component.ts @@ -1,4 +1,4 @@ -import { Component, computed, signal, inject } from '@angular/core'; +import { Component, computed, signal, inject, effect } from '@angular/core'; import { BreakpointObserver } from '@angular/cdk/layout'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; @@ -33,6 +33,7 @@ import { map } from 'rxjs/operators'; import { toSignal } from '@angular/core/rxjs-interop'; import { MatSliderModule } from '@angular/material/slider'; import { FileUpload } from '../../api/model/fileUpload'; +import { MatSnackBar } from '@angular/material/snack-bar'; import { FileUploadComponent, FileUploadItem, @@ -92,6 +93,7 @@ export class KeywordsSearchComponent { private readonly sanitizer = inject(DomSanitizer); private readonly route = inject(ActivatedRoute); private readonly router = inject(Router); + private readonly _snackBar = inject(MatSnackBar); private readonly destroyRef = inject(DestroyRef); private readonly websocketService = inject(KeywordWebSocketService); private readonly topicsService = inject(TopicsService); @@ -219,6 +221,7 @@ export class KeywordsSearchComponent { readonly progress = signal(0); readonly statusMessage = signal(''); + readonly errorMessage = signal(''); readonly keywordView = signal('llm'); readonly subfieldLegendVisible = signal(true); readonly subfieldLegendExpanded = signal(false); @@ -262,6 +265,14 @@ export class KeywordsSearchComponent { .getMessages() .subscribe((event: WsEvent) => this.handleWsEvent(event)); + effect(() => { + const message = this.errorMessage(); + if (message) { + this._snackBar.open(message, 'Schließen', { + duration: 5000, + }); + } + }); // this.destroyRef.onDestroy(() => { // this.websocketService.close(); // const isReload = this.router.lastSuccessfulNavigation === null; @@ -301,11 +312,15 @@ export class KeywordsSearchComponent { this.statusMessage.set('Fertig!'); this.websocketService.close(); this.isExtracting.set(false); + if (!this.keywordsExist()) { + this.errorMessage.set('Keine Keywords extrahiert'); + } } private handleErrorEvent(event: WsEvent): void { this.progress.set(0); - this.statusMessage.set('Fehler: ' + event.message); + this.errorMessage.set(event.message || 'Unbekannter Fehler'); + //this.statusMessage.set('Fehler: ' + event.message); this.broadKeywordEntries.set([]); this.coarseKeywordEntries.set([]); this.fineKeywordEntries.set([]); @@ -414,8 +429,8 @@ export class KeywordsSearchComponent { this.statusMessage.set('Extracting keywords...'); }) .catch((err) => { - console.error('WebSocket error:', err); - this.statusMessage.set('Failed to send content'); + console.error('WebSocket error: OPA', err); + this.errorMessage.set('Failed to send content'); this.isExtracting.set(false); }); } @@ -435,7 +450,7 @@ export class KeywordsSearchComponent { if (!normalizedKeyword) return; if (this.keywordExists(normalizedKeyword)) { - this.statusMessage.set(`"${normalizedKeyword}" ist bereits vorhanden.`); + this.errorMessage.set(`"${normalizedKeyword}" ist bereits vorhanden.`); return; } @@ -466,7 +481,7 @@ export class KeywordsSearchComponent { error: (err) => { console.error('vectorSearchTopics failed', err); this.loadingNewKeyword.set(false); - this.statusMessage.set( + this.errorMessage.set( `Fehler beim Hinzufügen von "${normalizedKeyword}".`, ); }, @@ -601,7 +616,7 @@ export class KeywordsSearchComponent { if (mode === 'file') { const files = this.uploadedFiles(); if (!files || files.length === 0) { - this.statusMessage.set('Bitte Datei hochladen.'); + this.errorMessage.set('Bitte Datei hochladen.'); return; } @@ -712,7 +727,7 @@ export class KeywordsSearchComponent { } catch (error) { console.error('WebSocket send error:', error); this.isExtracting.set(false); - this.statusMessage.set('Fehler beim Senden der Anfrage'); + this.errorMessage.set('Fehler beim Senden der Anfrage'); } } @@ -720,7 +735,7 @@ export class KeywordsSearchComponent { this.websocketService.close(); this.isExtracting.set(false); this.progress.set(0); - this.statusMessage.set('Extraktion abgebrochen'); + this.errorMessage.set('Extraktion abgebrochen'); } search(): void {