file upload integration fixes
This commit is contained in:
@@ -58,17 +58,14 @@
|
||||
</mat-tab>
|
||||
<mat-tab label="Datei">
|
||||
<div class="tab-content">
|
||||
<app-file-upload
|
||||
[requiredFileType]="'text/plain,application/pdf'"
|
||||
[maxFileSize]="5 * 1024 * 1024"
|
||||
[maxFiles]="3"
|
||||
[uploadedFiles]="uploadedFiles()"
|
||||
(filesChange)="onFilesSelected($event)">
|
||||
</app-file-upload>
|
||||
<div class="actions">
|
||||
<app-file-upload
|
||||
[requiredFileType]="
|
||||
'text/plain,application/pdf,image/png,image/jpeg'
|
||||
"
|
||||
[maxFileSize]="10 * 1024 * 1024"
|
||||
[maxFiles]="5"
|
||||
(filesSelected)="onFilesSelected($event)"
|
||||
(uploadProgressChange)="onUploadProgress($event)"
|
||||
(uploadError)="onUploadError($event)"
|
||||
class="file-upload-wrapper" />
|
||||
<button
|
||||
mat-flat-button
|
||||
type="button"
|
||||
@@ -167,13 +164,13 @@
|
||||
<div class="toolbar-divider"></div>
|
||||
|
||||
<div class="toolbar-group toolbar-group--view">
|
||||
<mat-slide-toggle
|
||||
(change)="onToggleTopicMappingSearch($event)"
|
||||
labelPosition="before"
|
||||
[checked]="topicMappingSearch()"
|
||||
class="mapping-toggle">
|
||||
Topic Mapping
|
||||
</mat-slide-toggle>
|
||||
<div class="toggle-container">
|
||||
<mat-slide-toggle
|
||||
(change)="onToggleTopicMappingSearch($event)"
|
||||
[checked]="topicMappingSearch()">
|
||||
Topic Mapping
|
||||
</mat-slide-toggle>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -276,36 +273,48 @@
|
||||
|
||||
<div class="table-body">
|
||||
<div class="table-col broad-col">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: broadKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && broadKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: broadKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="table-col coarse-col">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: coarseKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && coarseKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: coarseKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="table-col fine-col thick-border">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: fineKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && fineKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: fineKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="table-col own-col">
|
||||
@@ -322,14 +331,18 @@
|
||||
<span class="tab-count">{{ broadKeywords().length }}</span>
|
||||
</ng-template>
|
||||
<div class="mobile-tab-panel">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: broadKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && broadKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: broadKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
@@ -339,14 +352,18 @@
|
||||
<span class="tab-count">{{ coarseKeywords().length }}</span>
|
||||
</ng-template>
|
||||
<div class="mobile-tab-panel">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: coarseKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && coarseKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: coarseKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
@@ -356,14 +373,18 @@
|
||||
<span class="tab-count">{{ fineKeywords().length }}</span>
|
||||
</ng-template>
|
||||
<div class="mobile-tab-panel">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: fineKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
@if (isExtracting() && fineKeywords().length === 0) {
|
||||
<app-loading icon="manage_search" [size]="60" [diameter]="60" />
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
keywordChipStack;
|
||||
context: {
|
||||
keywords: fineKeywords(),
|
||||
emptyText: 'Nichts extrahiert',
|
||||
}
|
||||
"></ng-container>
|
||||
}
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
@@ -378,30 +399,27 @@
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
}
|
||||
|
||||
<!-- Source content display -->
|
||||
@if (sourceContent().length > 0) {
|
||||
<mat-divider></mat-divider>
|
||||
<mat-expansion-panel class="source-expansion">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Quellentext: {{ sourceUrl() }}</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<div
|
||||
class="source-text"
|
||||
[innerHTML]="highlightedSourceContent()"></div>
|
||||
</mat-expansion-panel>
|
||||
}
|
||||
</mat-card-content>
|
||||
@if (isExtracting() && !keywordsExist()) {
|
||||
<!-- @if (isExtracting() && !keywordsExist()) {
|
||||
<app-loading
|
||||
text="{{ statusMessage() }}"
|
||||
icon="manage_search"
|
||||
[size]="200"
|
||||
[diameter]="200" />
|
||||
} -->
|
||||
<!-- Source content display -->
|
||||
@if (sourceContent().length > 0) {
|
||||
<mat-divider></mat-divider>
|
||||
<mat-expansion-panel class="source-expansion">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Quellentext: {{ sourceUrl() }}</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<div class="source-text" [innerHTML]="highlightedSourceContent()"></div>
|
||||
</mat-expansion-panel>
|
||||
}
|
||||
</mat-card>
|
||||
|
||||
@if (isExtracting() && keywordsExist()) {
|
||||
@if (isExtracting()) {
|
||||
<div class="status-message">{{ statusMessage() }}</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,9 @@ $touch-target: 44px;
|
||||
margin-top: 0.5rem;
|
||||
gap: 0.5rem;
|
||||
align-items: top;
|
||||
justify-content: center;
|
||||
app-file-upload {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.full-width {
|
||||
@@ -87,7 +89,6 @@ $touch-target: 44px;
|
||||
gap: auto;
|
||||
|
||||
::ng-deep .mdc-switch {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
::ng-deep .mdc-form-field {
|
||||
@@ -564,7 +565,7 @@ mat-button-toggle-group {
|
||||
SOURCE EXPANSION PANEL
|
||||
============================================================ */
|
||||
.source-expansion {
|
||||
margin: 0.75rem 0;
|
||||
margin: 0.5rem 1rem;
|
||||
background: var(--sg-background-muted, #f5f5f5);
|
||||
border-radius: 4px;
|
||||
//border-left: 4px solid var(--sg-primary, #1976d2);
|
||||
|
||||
@@ -152,39 +152,58 @@ export class KeywordsSearchComponent {
|
||||
|
||||
let highlightedContent = content;
|
||||
|
||||
// replace the keyword with highlighted spans
|
||||
const normalizeText = (text: string): string => {
|
||||
return text
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[\u2010-\u2015\u2026—–]/g, '-')
|
||||
.replace(/[\u2018\u2019\u201b\u201c\u201d\u201f]/g, "'")
|
||||
.replace(/[\s\n\r\t]+/g, ' ')
|
||||
.replace(/[^a-zA-Z0-9\s\-]/g, '');
|
||||
};
|
||||
|
||||
// Normalize keyword for matching
|
||||
const normalizeKeyword = (keyword: string): string => {
|
||||
return keyword
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[\s\-]+/g, '')
|
||||
.replace(/[^a-zA-Z0-9]/g, '');
|
||||
};
|
||||
|
||||
for (const keyword of selectedKeywords) {
|
||||
const normalizedKeyword = this.normalizeKeyword(keyword);
|
||||
const normalizedKeyword = normalizeKeyword(keyword);
|
||||
|
||||
// Find the first keyword entry that matches this normalized keyword
|
||||
const entry = this.allKeywordEntries().find(
|
||||
(e) =>
|
||||
this.normalizeKeyword(this.getKeywordLabel(e)) === normalizedKeyword,
|
||||
);
|
||||
const entry = this.allKeywordEntries().find((e) => {
|
||||
const label = this.getKeywordLabel(e);
|
||||
return normalizeKeyword(label) === normalizedKeyword;
|
||||
});
|
||||
|
||||
if (entry) {
|
||||
const topic = this.getTopic(entry);
|
||||
if (topic) {
|
||||
const color = this.getTopicColor(topic);
|
||||
// Escape HTML special characters in the keyword before using it in HTML
|
||||
const escapedKeyword = keyword
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
if (!entry) continue;
|
||||
|
||||
// Create the replacement span HTML
|
||||
const replacement = `<span style="text-decoration: underline; background-color: color-mix(in srgb, ${color} 27%, #ffffff); 100%); font-weight: bold;" title="Keyword: ${keyword}">${escapedKeyword}</span>`;
|
||||
const topic = this.getTopic(entry);
|
||||
if (!topic) continue;
|
||||
|
||||
const escapedRegexKeyword = keyword.replace(
|
||||
/[.*+?^${}()|[\]\\]/g,
|
||||
'\\$&',
|
||||
);
|
||||
const regex = new RegExp(escapedRegexKeyword, 'g');
|
||||
const color = this.getTopicColor(topic);
|
||||
|
||||
highlightedContent = highlightedContent.replace(regex, replacement);
|
||||
}
|
||||
}
|
||||
const escapedKeyword = keyword
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
|
||||
const escapedRegexKeyword = keyword
|
||||
.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
.replace(/\s+/g, '\\s*');
|
||||
|
||||
const regex = new RegExp(escapedRegexKeyword, 'gi');
|
||||
|
||||
const replacement = `<span style="text-decoration: underline; background-color: color-mix(in srgb, ${color} 27%, #ffffff); font-weight: bold;" title="Keyword: ${escapedKeyword}">${escapedKeyword}</span>`;
|
||||
|
||||
highlightedContent = highlightedContent.replace(regex, replacement);
|
||||
}
|
||||
|
||||
return this.sanitizer.bypassSecurityTrustHtml(highlightedContent);
|
||||
});
|
||||
|
||||
@@ -378,13 +397,6 @@ export class KeywordsSearchComponent {
|
||||
this.uploadedFiles.set(files);
|
||||
}
|
||||
|
||||
// Helper: Update progress bar
|
||||
private updateProgress(processed: number, total: number) {
|
||||
const progress = Math.round((processed / total) * 100);
|
||||
this.progress.set(progress);
|
||||
this.statusMessage.set(`Reading ${processed}/${total} files...`);
|
||||
}
|
||||
|
||||
// Helper: Send files to WebSocket for server-side extraction
|
||||
private sendFilesToWebSocket(files: FileUpload[]) {
|
||||
const keywordsRequest: KeywordsRequest = {
|
||||
@@ -407,17 +419,6 @@ export class KeywordsSearchComponent {
|
||||
this.isExtracting.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
onUploadProgress(event: { id: string; progress: number }) {
|
||||
console.log('Upload progress:', event.progress + '%');
|
||||
this.progress.set(event.progress);
|
||||
}
|
||||
|
||||
onUploadError(error: { id: string; error: string }) {
|
||||
console.error('Upload error:', error);
|
||||
this.statusMessage.set('Upload failed: ' + error.error);
|
||||
this.isExtracting.set(false);
|
||||
}
|
||||
// --- Keyword selection & manual entry ------------------------------------
|
||||
|
||||
private keywordExists(keyword: string): boolean {
|
||||
@@ -589,6 +590,7 @@ export class KeywordsSearchComponent {
|
||||
}
|
||||
|
||||
onExtractKeywordsClick(): void {
|
||||
this.clearKeywords();
|
||||
if (this.isExtracting()) {
|
||||
this.cancelKeywordExtraction();
|
||||
return;
|
||||
@@ -626,7 +628,6 @@ export class KeywordsSearchComponent {
|
||||
};
|
||||
|
||||
processedFiles++;
|
||||
this.updateProgress(processedFiles, totalFiles);
|
||||
|
||||
if (processedFiles === totalFiles) {
|
||||
this.sendFilesToWebSocket(fileUploads);
|
||||
@@ -642,7 +643,6 @@ export class KeywordsSearchComponent {
|
||||
};
|
||||
|
||||
processedFiles++;
|
||||
this.updateProgress(processedFiles, totalFiles);
|
||||
|
||||
if (processedFiles === totalFiles) {
|
||||
this.sendFilesToWebSocket(fileUploads);
|
||||
|
||||
Reference in New Issue
Block a user