diff --git a/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.html b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.html new file mode 100644 index 00000000..e5f4062b --- /dev/null +++ b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.html @@ -0,0 +1,31 @@ +
+ + + groups +

Patentenliste

+

+ Die aktuelle Gewichtung ist unter normalized verfügbar. +

+
+
+ + + + + + +
diff --git a/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.scss new file mode 100644 index 00000000..ffeea20d --- /dev/null +++ b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.scss @@ -0,0 +1,29 @@ +/* ============================================================ + RESULT LAYOUT + ============================================================ */ +.result-layout { + display: grid; + grid-template-columns: minmax(300px, 420px) 1fr; + grid-template-areas: 'summary results'; + gap: 0.75rem; + align-items: start; +} + +.search-summary-card { + grid-area: summary; +} + +.results-card { + grid-area: results; +} + +.search-summary-card, +.results-card { + background: var(--sg-surface, #ffffff); + border: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12)); + box-shadow: none; + + .mat-mdc-card-content { + padding: 0.75rem; + } +} diff --git a/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.ts new file mode 100644 index 00000000..659c9064 --- /dev/null +++ b/webapp/src/app/modules/keywords-search/search-results/patents-results/patents-results.component.ts @@ -0,0 +1,112 @@ +import { Component, inject, signal } from '@angular/core'; + +import { MatCardModule } from '@angular/material/card'; +import { MatIconModule } from '@angular/material/icon'; + +import { + WeightMap, + WeightSliderOption, + WeightsSlidersComponent, + WeightsSlidersValue, +} from '../../../../shared/ui/weights-sliders/weights-sliders.component'; +import { SearchResultsStateService } from '../search-results-state.service'; + +@Component({ + selector: 'app-patents-results', + imports: [MatCardModule, MatIconModule, WeightsSlidersComponent], + templateUrl: './patents-results.component.html', + styleUrl: './patents-results.component.scss', +}) +export class KeywordsToPatentsResultsComponent { + // injects the state set by the parent route — no duplicate parsing here + private readonly state = inject(SearchResultsStateService); + + readonly defaultWeights: WeightMap = { + param1: 0.33, + param2: 0.33, + param3: 0.34, + }; + + readonly weightOptions: WeightSliderOption[] = [ + { + key: 'param1', + label: 'Parameter 1', + icon: 'workspace_premium', + description: 'Gewichtet Parameter 1.', + defaultValue: 0.5, + queryParamName: 'wParam1', + }, + { + key: 'param2', + label: 'Parameter 2', + icon: 'workspace_premium', + description: 'Gewichtet Parameter 2.', + defaultValue: 0.5, + queryParamName: 'wParam2', + }, + { + key: 'param3', + label: 'Parameter 3', + icon: 'workspace_premium', + description: 'Gewichtet Parameter 3.', + defaultValue: 0.5, + queryParamName: 'wParam3', + }, + ]; + + readonly currentWeights = signal({ + raw: this.defaultWeights, + normalized: { + param1: 0.33, + param2: 0.33, + param3: 0.34, + }, + rawSum: 2.5, + normalizedSum: 1, + valid: true, + }); + + readonly projects = signal([]); // placeholder until the results service lands + + private hasLoadedInitial = false; + + onWeightsChange(value: WeightsSlidersValue): void { + this.currentWeights.set(value); + + // fires once with the query-param-aware initial state — use it to load + if (!this.hasLoadedInitial) { + this.hasLoadedInitial = true; + this.loadprojects(); + } + } + + onApplyWeights(value: WeightsSlidersValue): void { + this.currentWeights.set(value); + this.loadprojects(); + } + + private loadprojects(): void { + const weights = this.currentWeights(); + + const requestPayload = { + manualKeywords: this.state.manualKeywords(), + extractedKeywords: this.state.extractedKeywords(), + keywords: this.state.keywords(), + softSearch: this.state.softSearch(), + weights: { + raw: weights.raw, + normalized: weights.normalized, + }, + }; + + console.log(requestPayload); + + /** + * TODO: + * this.projectsService.searchprojects(requestPayload).subscribe({ + * next: results => this.projects.set(results), + * error: error => console.error(error), + * }); + */ + } +}