From d16b1544b9817bb49fa2166dc7c939f323b3463d Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sun, 12 Jul 2026 14:19:37 +0200 Subject: [PATCH] add silder for relevant years --- .../persons-results.component.html | 61 +++++++++++++------ .../persons-results.component.scss | 26 +++++++- .../persons-results.component.ts | 59 +++++++++++++++++- 3 files changed, 123 insertions(+), 23 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html index a6597a14..fa2c9511 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html @@ -28,23 +28,46 @@ - - - - - +
+ + + + + + + + +
+ date_range + Zeitraum: {{ timespanFrom() }} – {{ timespanTo() }} +
+ + + + +
+
+
diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss index ccf3aa50..4a8757b4 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss @@ -7,12 +7,21 @@ grid-template-areas: 'summary results'; gap: 0.75rem; align-items: start; + width: 100%; } -.search-summary-card { +.search-summary-card, +.controls-column { grid-area: summary; } +.controls-column { + display: flex; + flex-direction: column; + gap: 0.75rem; + min-width: 0; +} + .results-card { grid-area: results; } @@ -65,3 +74,18 @@ .results-hint { padding: 0.5rem 0.25rem; } + +/* ============================================================ + TIMESPAN + ============================================================ */ +.timespan-header { + display: flex; + align-items: center; + gap: 0.5rem; + margin-bottom: 0.25rem; + font-weight: 500; +} + +.timespan-card mat-slider { + width: 100%; +} diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index 290966e8..835e9aef 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -1,9 +1,10 @@ -import { Component, inject, signal } from '@angular/core'; +import { Component, OnInit, inject, signal } from '@angular/core'; import { DecimalPipe } from '@angular/common'; -import { RouterLink } from '@angular/router'; +import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; +import { MatSliderModule } from '@angular/material/slider'; import { WeightMap, @@ -28,15 +29,18 @@ import { SearchResultsStateService } from '../search-results-state.service'; RouterLink, MatCardModule, MatIconModule, + MatSliderModule, WeightsSlidersComponent, ], templateUrl: './persons-results.component.html', styleUrl: './persons-results.component.scss', }) -export class KeywordsToPersonsResultsComponent { +export class KeywordsToPersonsResultsComponent implements OnInit { // injects the state set by the parent route — no duplicate parsing here private readonly state = inject(SearchResultsStateService); private readonly rankingService = inject(RankingService); + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); // for now only works and citations are used as metrics/weights readonly defaultWeights: WeightMap = { @@ -96,11 +100,47 @@ export class KeywordsToPersonsResultsComponent { valid: true, }); + // publication-year timespan filter (range slider) + readonly minYear = 1900; + readonly maxYear = 2026; + readonly timespanFrom = signal(this.minYear); + readonly timespanTo = signal(this.maxYear); + readonly authors = signal([]); readonly loading = signal(false); private hasLoadedInitial = false; + ngOnInit(): void { + // restore the timespan from the URL so the range is shareable/bookmarkable + this.timespanFrom.set(this.readYearParam('tFrom', this.minYear)); + this.timespanTo.set(this.readYearParam('tTo', this.maxYear)); + } + + // reads a year query param, clamped to the valid range; falls back on invalid input + private readYearParam(name: string, fallback: number): number { + const rawValue = this.route.snapshot.queryParamMap.get(name); + if (rawValue === null) { + return fallback; + } + + const year = Number(rawValue); + if (!Number.isFinite(year)) { + return fallback; + } + + return Math.min(this.maxYear, Math.max(this.minYear, Math.round(year))); + } + + private writeTimespanToUrl(): void { + this.router.navigate([], { + relativeTo: this.route, + queryParams: { tFrom: this.timespanFrom(), tTo: this.timespanTo() }, + queryParamsHandling: 'merge', + replaceUrl: true, + }); + } + onWeightsChange(value: WeightsSlidersValue): void { this.currentWeights.set(value); @@ -116,6 +156,15 @@ export class KeywordsToPersonsResultsComponent { this.loadAuthors(); } + // called when a timespan thumb is released — persist to the URL and reload + onTimespanChange(): void { + if (this.timespanFrom() > this.timespanTo()) { + return; + } + this.writeTimespanToUrl(); + this.loadAuthors(); + } + // the backend returns the full OpenAlex url; the profile route needs only the id authorProfileId(author: RankedAuthor): string { const parts = author.author_id.split('/'); @@ -138,6 +187,10 @@ export class KeywordsToPersonsResultsComponent { works: rawWeights['works'], citation: rawWeights['citations'], }, + timespan: { + from: this.timespanFrom(), + to: this.timespanTo(), + }, }; this.loading.set(true);