created a template component for persons results for keyword search

This commit is contained in:
2026-07-08 03:29:04 +02:00
parent 2bfb877e77
commit be72d28bda
3 changed files with 195 additions and 0 deletions
@@ -0,0 +1,31 @@
<div class="result-layout">
<mat-card class="results-card">
<mat-card-content class="results-placeholder">
<mat-icon>groups</mat-icon>
<h2>Personenliste</h2>
<p>
Die aktuelle Gewichtung ist unter <code>normalized</code> verfügbar.
</p>
</mat-card-content>
</mat-card>
<mat-card class="weights-card">
<mat-card-content>
<app-weights-sliders
[options]="weightOptions"
[initialWeights]="defaultWeights"
title="Personen-Gewichtung"
description="Werte zwischen 0 und 1. Summe wird normalisiert zu 1."
resetLabel="Ausgewogen"
applyLabel="Neu gewichten"
normalizedTitle="Normalisiert"
queryParamPrefix="personW_"
[persistInQueryParams]="true"
[showApplyButton]="true"
[showResetButton]="true"
[showNormalizedPreview]="true"
(weightsChange)="onWeightsChange($event)"
(applyWeights)="onApplyWeights($event)" />
</mat-card-content>
</mat-card>
</div>
@@ -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;
}
}
@@ -0,0 +1,135 @@
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-persons-results',
standalone: true,
imports: [MatCardModule, MatIconModule, WeightsSlidersComponent],
templateUrl: './persons-results.component.html',
styleUrl: './persons-results.component.scss',
})
export class KeywordsToPersonsResultsComponent {
// injects the state set by the parent route — no duplicate parsing here
private readonly state = inject(SearchResultsStateService);
readonly defaultWeights: WeightMap = {
publications: 0.5,
citations: 0.5,
patents: 0.5,
projects: 0.5,
mediaVisibility: 0.5,
};
readonly weightOptions: WeightSliderOption[] = [
{
key: 'publications',
label: 'Publikationen',
icon: 'article',
description:
'Gewichtet die Anzahl und Relevanz wissenschaftlicher Arbeiten.',
defaultValue: 0.5,
queryParamName: 'wPublications',
},
{
key: 'citations',
label: 'Zitationen',
icon: 'format_quote',
description: 'Gewichtet wissenschaftlichen Einfluss über Zitationen.',
defaultValue: 0.5,
queryParamName: 'wCitations',
},
{
key: 'patents',
label: 'Patente',
icon: 'workspace_premium',
description: 'Gewichtet Innovations- und Transferleistung.',
defaultValue: 0.5,
queryParamName: 'wPatents',
},
{
key: 'projects',
label: 'Projekte',
icon: 'account_tree',
description: 'Gewichtet Beteiligung an relevanten Forschungsprojekten.',
defaultValue: 0.5,
queryParamName: 'wProjects',
},
{
key: 'mediaVisibility',
label: 'Medien-Sichtbarkeit',
icon: 'visibility',
description: 'Gewichtet öffentliche und mediale Sichtbarkeit.',
defaultValue: 0.5,
queryParamName: 'wMedia',
},
];
readonly currentWeights = signal<WeightsSlidersValue>({
raw: this.defaultWeights,
normalized: {
publications: 0.2,
citations: 0.2,
patents: 0.2,
projects: 0.2,
mediaVisibility: 0.2,
},
rawSum: 2.5,
normalizedSum: 1,
valid: true,
});
readonly persons = signal<unknown[]>([]); // 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.loadPersons();
}
}
onApplyWeights(value: WeightsSlidersValue): void {
this.currentWeights.set(value);
this.loadPersons();
}
private loadPersons(): 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.personsService.searchPersons(requestPayload).subscribe({
* next: results => this.persons.set(results),
* error: error => console.error(error),
* });
*/
}
}