From dc573433d98ed70700ec09d9b3fee29e560dfa39 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Tue, 16 Jun 2026 16:27:31 +0200 Subject: [PATCH 01/29] Log career metrics runtime --- service/src/main/inse/persons/logic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index 76db43c7..f142ee37 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -389,7 +389,13 @@ def get_person_by_id( raise HTTPException(status_code=500, detail=f"Elasticsearch error: {str(e)}") author = util.get_persons_data(hit) + start_time = time.time() career_metrics = get_career_metrics_for_author(author_id) + elapsed_time = time.time() - start_time + + logger.info( + f"Career metrics calculation for author {author_id} took {elapsed_time:.2f} seconds" + ) custom_author = CustomAuthor( **author.model_dump(), -- 2.56.1 From 6a6e07a0dc213c110d66a98d9e6b30a1e890afdf Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Thu, 18 Jun 2026 22:10:41 +0200 Subject: [PATCH 02/29] display career stage in profile --- service/src/main/inse/persons/logic.py | 6 ++--- .../app/modules/person/person.component.html | 12 +++++++++ .../app/modules/person/person.component.scss | 27 +++++++++++++++++++ .../app/modules/person/person.component.ts | 25 ++++++++++++----- webapp/src/app/resolvers/person.resolver.ts | 22 ++++++--------- 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index f142ee37..609b8b88 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -371,15 +371,13 @@ def generate_person_bio(author_id: str, include: Optional[set[str]] = None) -> s def get_person_by_id( author_id: str, include: Optional[str] = None ) -> CustomAuthorsListResponse: - body = { - "_source": include.split(",") if include else True, - } + source = include.split(",") if include else None try: hit = elasticsearch.get( index="openalex-authors", - body=body, doc_id=author_id, + source=source, ) except NotFoundError: raise HTTPException( diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index a0b50703..e58bd84d 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -29,6 +29,18 @@ } } + @if (displayCareerStage()) { +
+ Career Stage: + + {{ displayCareerStage() }} + +
+ }
diff --git a/webapp/src/app/modules/person/person.component.scss b/webapp/src/app/modules/person/person.component.scss index be93f021..e232d508 100644 --- a/webapp/src/app/modules/person/person.component.scss +++ b/webapp/src/app/modules/person/person.component.scss @@ -85,6 +85,33 @@ font-size: 13px; } +.career-stage-line { + display: flex; + align-items: center; + gap: 8px; + color: var(--sg-text-muted); + font-size: 13px; +} + +.career-stage-label { + color: var(--sg-text-muted); +} + +.career-stage-chip { + display: inline-flex; + align-items: center; + min-height: 24px; + padding: 2px 10px; + border: 1px solid var(--sg-border); + border-radius: 999px; + background: var(--sg-surface-muted); + color: var(--sg-primary); + font-size: 13px; + font-weight: 600; + line-height: 1.2; + cursor: help; +} + .profile-contact { display: grid; gap: 16px; diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index 724e9882..0f756693 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -7,6 +7,7 @@ import { import { MatIconModule } from '@angular/material/icon'; import { MatProgressSpinner } from '@angular/material/progress-spinner'; import { MatTabsModule } from '@angular/material/tabs'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { ActivatedRoute, ResolveEnd, @@ -19,7 +20,7 @@ import { import { of, switchMap, finalize, map, catchError } from 'rxjs'; import { PersonInterestingComponent } from '../person-interesting/person-interesting.component'; -import { PersonsService, WorksService } from '../../api'; +import { WorksService } from '../../api'; import { LoadingComponent } from '../../shared/ui/loading/loading.component'; import { PersonBioResolved } from '../../resolvers/person-bio.resolver'; @@ -28,6 +29,7 @@ import { PersonBioResolved } from '../../resolvers/person-bio.resolver'; imports: [ MatIconModule, MatTabsModule, + MatTooltipModule, PersonInterestingComponent, RouterOutlet, RouterModule, @@ -41,7 +43,6 @@ export class PersonComponent { private readonly router = inject(Router); private readonly activatedRoute = inject(ActivatedRoute); - private readonly personsApi = inject(PersonsService); private readonly worksApi = inject(WorksService); private readonly destroyRef = inject(DestroyRef); @@ -62,9 +63,9 @@ export class PersonComponent { const event = this.routerEvents(); if ( - !(event instanceof RouterEvent) || // not a router event - !this.isResolverEvent(event) || // not a resolver event - !this.isNetworkRouterEvent(event) // not navigating to network route + !(event instanceof RouterEvent) || + !this.isResolverEvent(event) || + !this.isNetworkRouterEvent(event) ) { return false; } @@ -84,7 +85,6 @@ export class PersonComponent { return event.url.startsWith(`/person/${this.authorId()}/network`); } - // loading states readonly isPersonLoading = signal(false); readonly isBioLoading = signal(false); @@ -111,6 +111,7 @@ export class PersonComponent { ), { initialValue: null }, ); + readonly displayName = computed( () => this.person()?.display_name ?? 'Unbekannte Person', ); @@ -142,6 +143,17 @@ export class PersonComponent { readonly h_index = computed( () => this.person()?.summary_stats?.h_index ?? null, ); + readonly displayCareerStage = computed(() => { + const stage = this.person()?.career_metrics?.career_stage; + + if (!stage || stage === 'unknown') { + return null; + } + + return stage; + }); + readonly careerStageTooltip = + 'Dies ist eine Einschätzung zur Karrierephase, die ausschließlich auf OpenAlex-Publikationsdaten basiert. Es ist kein offizieller akademischer Status.'; readonly orcid = computed(() => { const rawOrcid = this.getId('orcid'); if (!rawOrcid) { @@ -168,6 +180,7 @@ export class PersonComponent { ), { initialValue: [] }, ); + links = [ { label: 'Übersicht', path: 'overview', disabled: false }, { diff --git a/webapp/src/app/resolvers/person.resolver.ts b/webapp/src/app/resolvers/person.resolver.ts index a20198f2..64bde7da 100644 --- a/webapp/src/app/resolvers/person.resolver.ts +++ b/webapp/src/app/resolvers/person.resolver.ts @@ -1,23 +1,17 @@ import { ResolveFn } from '@angular/router'; import { inject } from '@angular/core'; -import { AuthorsListResponse, PersonsService } from '../api'; +import { CustomAuthorsListResponse, PersonsService } from '../api'; -export const personResolver: ResolveFn = ( +export const personResolver: ResolveFn = ( route, state, ) => { - const parseQueryParamArray = (val: any): string[] => { - if (!val) return []; - if (Array.isArray(val)) return val; - return [val]; - }; - const PERSON_INCLUDE_TAGS = - 'topics_full,topic_share,summary_stats,ids,last_known_institutions,' + - 'sources,counts_by_year,works_api_url,dates,cited_by_count_boost'; - const params = route.paramMap; - - const query = params.get('id') || undefined; + const authorId = route.paramMap.get('id'); const personsService = inject(PersonsService); - return personsService.searchPersons(query, undefined, PERSON_INCLUDE_TAGS); + if (!authorId) { + return { results: [] }; + } + + return personsService.getPersonByID(authorId); }; -- 2.56.1 From 6e3c5107f1bf551e17e1fdc9e0cc5c262ff8d4b0 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Thu, 18 Jun 2026 23:09:32 +0200 Subject: [PATCH 03/29] show career stage on person cards --- service/src/main/inse/persons/logic.py | 11 +++++++ .../person-card/person-card.component.html | 12 +++++++ .../person-card/person-card.component.scss | 33 +++++++++++++++++++ .../person-card/person-card.component.ts | 22 ++++++++++++- .../src/app/resolvers/person-list.resolver.ts | 2 +- 5 files changed, 78 insertions(+), 2 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index 609b8b88..63c4d128 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -680,11 +680,22 @@ def advanced_search_persons( hits = response_dict.get("hits", {}).get("hits", []) total_count = response_dict.get("hits", {}).get("total", {}).get("value", 0) + include_career_metrics = include is None or "career_metrics" in include results = [] for hit in hits: raw_data = util.get_persons_data(hit) custom_author = _enrich_author_data(raw_data) if custom_author: + if include_career_metrics: + start_time = time.time() + custom_author.career_metrics = get_career_metrics_for_author( + custom_author.id + ) + elapsed_time = time.time() - start_time + logger.info( + f"Career metrics calculation for author {custom_author.id} took " + f"{elapsed_time:.2f} seconds" + ) results.append(custom_author) return CustomAuthorsListResponse( diff --git a/webapp/src/app/modules/person-card/person-card.component.html b/webapp/src/app/modules/person-card/person-card.component.html index 43698f60..59e1fc6b 100644 --- a/webapp/src/app/modules/person-card/person-card.component.html +++ b/webapp/src/app/modules/person-card/person-card.component.html @@ -33,6 +33,18 @@

{{ getHIndexString() }}

+ @if (!loading && getCareerStage(); as careerStage) { +
+ Career Stage: + + {{ careerStage }} + +
+ }
diff --git a/webapp/src/app/modules/person-card/person-card.component.scss b/webapp/src/app/modules/person-card/person-card.component.scss index f3a53722..8aebf59a 100644 --- a/webapp/src/app/modules/person-card/person-card.component.scss +++ b/webapp/src/app/modules/person-card/person-card.component.scss @@ -193,6 +193,39 @@ white-space: nowrap; } +.career-stage-line { + display: flex; + align-items: center; + gap: 6px; + margin-top: 6px; + color: var(--sg-text-muted); + font-size: 10px; + min-height: 18px; +} + +.career-stage-label { + flex-shrink: 0; +} + +.career-stage-chip { + display: inline-flex; + align-items: center; + min-width: 0; + max-width: 100%; + padding: 2px 8px; + border: 1px solid var(--sg-border); + border-radius: 999px; + background: var(--sg-surface-muted); + color: var(--sg-primary); + font-size: 10px; + font-weight: 600; + line-height: 1.2; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + cursor: help; +} + .card-body { padding: 16px; flex-grow: 1; diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index 89f0440c..c7815275 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -2,12 +2,19 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api'; import { SkTextDirective } from '../../custom-directives/sk-text.directive'; @Component({ selector: 'app-person-card', standalone: true, - imports: [CommonModule, RouterLink, MatIconModule, SkTextDirective], + imports: [ + CommonModule, + RouterLink, + MatIconModule, + MatTooltipModule, + SkTextDirective, + ], templateUrl: './person-card.component.html', styleUrl: './person-card.component.scss', }) @@ -94,6 +101,19 @@ export class PersonCardComponent { return ''; } + getCareerStage(): string | null { + const stage = this.person.career_metrics?.career_stage; + + if (!stage || stage === 'unknown') { + return null; + } + + return stage; + } + + readonly careerStageTooltip = + 'Dies ist eine Einschätzung zur Karrierephase, die ausschließlich auf OpenAlex-Publikationsdaten basiert. Es ist kein offizieller akademischer Status.'; + toggleBookmark(): void { this.bookmarkToggle.emit(this.person); } diff --git a/webapp/src/app/resolvers/person-list.resolver.ts b/webapp/src/app/resolvers/person-list.resolver.ts index 8e4b824c..926dd58c 100644 --- a/webapp/src/app/resolvers/person-list.resolver.ts +++ b/webapp/src/app/resolvers/person-list.resolver.ts @@ -12,7 +12,7 @@ export const personListResolver: ResolveFn = ( return [val]; }; const defaultIncludes = - 'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations'; + 'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations,career_metrics'; const params = route.queryParamMap; const query = params.get('query') || undefined; -- 2.56.1 From c62f284866c880b7bfd3fbf663ec4e39b07a54ec Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 19 Jun 2026 13:35:17 +0200 Subject: [PATCH 04/29] batch career metrics for search results --- service/src/main/inse/persons/logic.py | 137 +++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 11 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index 63c4d128..273b649b 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -188,8 +188,17 @@ def _fetch_works_and_topics(author_id: str) -> tuple[list, list]: return works, topics +def _get_openalex_author_url(author_id: str) -> str: + author_id = author_id.strip() + + if author_id.startswith("https://openalex.org/"): + return author_id + + return f"https://openalex.org/{author_id}" + + def _get_publication_years_for_author(author_id: str) -> list[int]: - author_url = f"https://openalex.org/{author_id.strip()}" + author_url = _get_openalex_author_url(author_id) body = { "size": 0, @@ -237,6 +246,7 @@ def _get_publication_years_for_author(author_id: str) -> list[int]: return publication_years + def _classify_career_stage(active_years: int) -> str: if active_years <= 0: return "unknown" @@ -297,11 +307,108 @@ def _compute_career_metrics(publication_years: list[int]) -> CareerMetrics: ) +def _get_publication_years_for_authors(author_ids: list[str]) -> dict[str, list[int]]: + author_ids = list(dict.fromkeys(author_id for author_id in author_ids if author_id)) + + if not author_ids: + return {} + + author_url_by_id = { + author_id: _get_openalex_author_url(author_id) for author_id in author_ids + } + + body = { + "size": 0, + "query": { + "nested": { + "path": "authorships", + "query": { + "terms": { + "authorships.author.id": list(author_url_by_id.values()) + }, + }, + }, + }, + "aggs": { + "authors": { + "filters": { + "filters": { + author_id: { + "nested": { + "path": "authorships", + "query": { + "term": { + "authorships.author.id": author_url + }, + }, + }, + } + for author_id, author_url in author_url_by_id.items() + }, + }, + "aggs": { + "publication_years": { + "terms": { + "field": "publication_year", + "size": 1000, + }, + }, + }, + }, + }, + } + + try: + response = elasticsearch.search( + index=config.settings.openalex_works_search_index, + body=body, + ) + except httpx.TimeoutException: + logger.warning( + "Batch career metrics Elasticsearch request timed out. " + "Returning empty career metrics for this search page." + ) + return {author_id: [] for author_id in author_ids} + + publication_years_by_author = {author_id: [] for author_id in author_ids} + author_buckets = ( + response.get("aggregations", {}) + .get("authors", {}) + .get("buckets", {}) + ) + + for author_id, author_bucket in author_buckets.items(): + year_buckets = ( + author_bucket.get("publication_years", {}) + .get("buckets", []) + ) + + for year_bucket in year_buckets: + year = year_bucket.get("key") + count = year_bucket.get("doc_count", 0) + + if isinstance(year, int): + publication_years_by_author[author_id].extend([year] * count) + + return publication_years_by_author + + def get_career_metrics_for_author(author_id: str) -> CareerMetrics: publication_years = _get_publication_years_for_author(author_id) return _compute_career_metrics(publication_years) +def get_career_metrics_for_authors(author_ids: list[str]) -> dict[str, CareerMetrics]: + publication_years_by_author = _get_publication_years_for_authors(author_ids) + + return { + author_id: _compute_career_metrics( + publication_years_by_author.get(author_id, []) + ) + for author_id in author_ids + } + + def _build_papers(works: list) -> list: papers = [] @@ -686,18 +793,26 @@ def advanced_search_persons( raw_data = util.get_persons_data(hit) custom_author = _enrich_author_data(raw_data) if custom_author: - if include_career_metrics: - start_time = time.time() - custom_author.career_metrics = get_career_metrics_for_author( - custom_author.id - ) - elapsed_time = time.time() - start_time - logger.info( - f"Career metrics calculation for author {custom_author.id} took " - f"{elapsed_time:.2f} seconds" - ) results.append(custom_author) + if include_career_metrics and results: + author_ids = [custom_author.id for custom_author in results if custom_author.id] + + start_time = time.time() + career_metrics_by_author = get_career_metrics_for_authors(author_ids) + elapsed_time = time.time() - start_time + + logger.info( + f"Batch career metrics calculation for {len(author_ids)} authors took " + f"{elapsed_time:.2f} seconds" + ) + + for custom_author in results: + if custom_author.id: + custom_author.career_metrics = career_metrics_by_author.get( + custom_author.id, CareerMetrics() + ) + return CustomAuthorsListResponse( results=results, meta=Meta(count=total_count, page=page, per_page=page_size) ) -- 2.56.1 From eba2b73c6b4276578d08b785ba9ae27e77a7ca5a Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 19 Jun 2026 14:03:41 +0200 Subject: [PATCH 05/29] update career stage tooltip --- .../person-card/person-card.component.html | 5 ++-- .../person-card/person-card.component.ts | 18 +++++++++++++-- .../app/modules/person/person.component.html | 5 ++-- .../app/modules/person/person.component.ts | 23 +++++++++++++++++-- webapp/src/styles.scss | 8 ++++++- 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/webapp/src/app/modules/person-card/person-card.component.html b/webapp/src/app/modules/person-card/person-card.component.html index 59e1fc6b..1ce09684 100644 --- a/webapp/src/app/modules/person-card/person-card.component.html +++ b/webapp/src/app/modules/person-card/person-card.component.html @@ -38,8 +38,9 @@ Career Stage: {{ careerStage }} diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index c7815275..c9c9fa48 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -111,8 +111,22 @@ export class PersonCardComponent { return stage; } - readonly careerStageTooltip = - 'Dies ist eine Einschätzung zur Karrierephase, die ausschließlich auf OpenAlex-Publikationsdaten basiert. Es ist kein offizieller akademischer Status.'; + getCareerStageTooltip(careerStage: string): string { + const activeYears = this.person.career_metrics?.active_years ?? '-'; + + return [ + `Aktuell: ${careerStage}`, + `Aktive Publikationsjahre: ${activeYears}`, + '', + 'Einteilung:', + 'Early Researcher: 1\u20134 aktive Publikationsjahre', + 'Emerging Researcher: 5\u201310 aktive Publikationsjahre', + 'Established Researcher: 11\u201320 aktive Publikationsjahre', + 'Senior Researcher: 20+ aktive Publikationsjahre', + '', + 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', + ].join('\n'); + } toggleBookmark(): void { this.bookmarkToggle.emit(this.person); diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index e58bd84d..0dea7f11 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -34,8 +34,9 @@ Career Stage: {{ displayCareerStage() }} diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index 55afbb2a..bd8c5fd2 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -152,8 +152,27 @@ export class PersonComponent { return stage; }); - readonly careerStageTooltip = - 'Dies ist eine Einschätzung zur Karrierephase, die ausschließlich auf OpenAlex-Publikationsdaten basiert. Es ist kein offizieller akademischer Status.'; + readonly careerStageTooltip = computed(() => { + const stage = this.displayCareerStage(); + if (!stage) { + return ''; + } + + const activeYears = this.person()?.career_metrics?.active_years ?? '-'; + + return [ + `Aktuell: ${stage}`, + `Aktive Publikationsjahre: ${activeYears}`, + '', + 'Einteilung:', + 'Early Researcher: 1\u20134 aktive Publikationsjahre', + 'Emerging Researcher: 5\u201310 aktive Publikationsjahre', + 'Established Researcher: 11\u201320 aktive Publikationsjahre', + 'Senior Researcher: 20+ aktive Publikationsjahre', + '', + 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', + ].join('\n'); + }); readonly orcid = computed(() => { const rawOrcid = this.getId('orcid'); if (!rawOrcid) { diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index b69df54f..d2edeee7 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -218,4 +218,10 @@ h3 { .cdk-overlay-pane .mat-mdc-option:hover, .cdk-overlay-pane .mat-mdc-option.mdc-list-item--focused { background: rgba(0, 0, 0, 0.04); -} \ No newline at end of file +} + +.career-stage-tooltip, +.career-stage-tooltip .mdc-tooltip__surface { + max-width: 360px; + white-space: pre-line; +} -- 2.56.1 From 5def7ac5f13d964f4f7aa42939bfe1e6593f55b6 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 19 Jun 2026 14:29:50 +0200 Subject: [PATCH 06/29] fix(persons): include required detail fields in resolver --- webapp/src/app/resolvers/person.resolver.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/src/app/resolvers/person.resolver.ts b/webapp/src/app/resolvers/person.resolver.ts index 1dc145ac..b8175a50 100644 --- a/webapp/src/app/resolvers/person.resolver.ts +++ b/webapp/src/app/resolvers/person.resolver.ts @@ -7,8 +7,10 @@ export const personResolver: ResolveFn = ( state, ) => { const PERSON_INCLUDE_TAGS = - 'topics_full,topic_share,summary_stats,ids,last_known_institutions,' + - 'sources,counts_by_year,works_api_url,dates,cited_by_count_boost,career_metrics'; + 'display_name,works_count,cited_by_count,summary_stats,ids,' + + 'last_known_institutions,affiliations,topics,orcid,' + + 'topics_full,topic_share,sources,counts_by_year,works_api_url,' + + 'dates,cited_by_count_boost,career_metrics'; const authorId = route.paramMap.get('id') || undefined; const personsService = inject(PersonsService); -- 2.56.1 From 123db12ac4e100fdbd98e00d75d21a9aa7be0f2e Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Fri, 19 Jun 2026 14:46:42 +0200 Subject: [PATCH 07/29] Update career stage backend thresholds --- service/src/main/inse/persons/logic.py | 141 +++---------------------- 1 file changed, 13 insertions(+), 128 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index 273b649b..ac94a469 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -188,17 +188,8 @@ def _fetch_works_and_topics(author_id: str) -> tuple[list, list]: return works, topics -def _get_openalex_author_url(author_id: str) -> str: - author_id = author_id.strip() - - if author_id.startswith("https://openalex.org/"): - return author_id - - return f"https://openalex.org/{author_id}" - - def _get_publication_years_for_author(author_id: str) -> list[int]: - author_url = _get_openalex_author_url(author_id) + author_url = f"https://openalex.org/{author_id.strip()}" body = { "size": 0, @@ -246,7 +237,6 @@ def _get_publication_years_for_author(author_id: str) -> list[int]: return publication_years - def _classify_career_stage(active_years: int) -> str: if active_years <= 0: return "unknown" @@ -254,10 +244,10 @@ def _classify_career_stage(active_years: int) -> str: if active_years <= 4: return "Early Researcher" - if active_years <= 10: + if active_years <= 9: return "Emerging Researcher" - if active_years <= 20: + if active_years <= 14: return "Established Researcher" return "Senior Researcher" @@ -307,108 +297,11 @@ def _compute_career_metrics(publication_years: list[int]) -> CareerMetrics: ) -def _get_publication_years_for_authors(author_ids: list[str]) -> dict[str, list[int]]: - author_ids = list(dict.fromkeys(author_id for author_id in author_ids if author_id)) - - if not author_ids: - return {} - - author_url_by_id = { - author_id: _get_openalex_author_url(author_id) for author_id in author_ids - } - - body = { - "size": 0, - "query": { - "nested": { - "path": "authorships", - "query": { - "terms": { - "authorships.author.id": list(author_url_by_id.values()) - }, - }, - }, - }, - "aggs": { - "authors": { - "filters": { - "filters": { - author_id: { - "nested": { - "path": "authorships", - "query": { - "term": { - "authorships.author.id": author_url - }, - }, - }, - } - for author_id, author_url in author_url_by_id.items() - }, - }, - "aggs": { - "publication_years": { - "terms": { - "field": "publication_year", - "size": 1000, - }, - }, - }, - }, - }, - } - - try: - response = elasticsearch.search( - index=config.settings.openalex_works_search_index, - body=body, - ) - except httpx.TimeoutException: - logger.warning( - "Batch career metrics Elasticsearch request timed out. " - "Returning empty career metrics for this search page." - ) - return {author_id: [] for author_id in author_ids} - - publication_years_by_author = {author_id: [] for author_id in author_ids} - author_buckets = ( - response.get("aggregations", {}) - .get("authors", {}) - .get("buckets", {}) - ) - - for author_id, author_bucket in author_buckets.items(): - year_buckets = ( - author_bucket.get("publication_years", {}) - .get("buckets", []) - ) - - for year_bucket in year_buckets: - year = year_bucket.get("key") - count = year_bucket.get("doc_count", 0) - - if isinstance(year, int): - publication_years_by_author[author_id].extend([year] * count) - - return publication_years_by_author - - def get_career_metrics_for_author(author_id: str) -> CareerMetrics: publication_years = _get_publication_years_for_author(author_id) return _compute_career_metrics(publication_years) -def get_career_metrics_for_authors(author_ids: list[str]) -> dict[str, CareerMetrics]: - publication_years_by_author = _get_publication_years_for_authors(author_ids) - - return { - author_id: _compute_career_metrics( - publication_years_by_author.get(author_id, []) - ) - for author_id in author_ids - } - - def _build_papers(works: list) -> list: papers = [] @@ -793,25 +686,17 @@ def advanced_search_persons( raw_data = util.get_persons_data(hit) custom_author = _enrich_author_data(raw_data) if custom_author: - results.append(custom_author) - - if include_career_metrics and results: - author_ids = [custom_author.id for custom_author in results if custom_author.id] - - start_time = time.time() - career_metrics_by_author = get_career_metrics_for_authors(author_ids) - elapsed_time = time.time() - start_time - - logger.info( - f"Batch career metrics calculation for {len(author_ids)} authors took " - f"{elapsed_time:.2f} seconds" - ) - - for custom_author in results: - if custom_author.id: - custom_author.career_metrics = career_metrics_by_author.get( - custom_author.id, CareerMetrics() + if include_career_metrics: + start_time = time.time() + custom_author.career_metrics = get_career_metrics_for_author( + custom_author.id ) + elapsed_time = time.time() - start_time + logger.info( + f"Career metrics calculation for author {custom_author.id} took " + f"{elapsed_time:.2f} seconds" + ) + results.append(custom_author) return CustomAuthorsListResponse( results=results, meta=Meta(count=total_count, page=page, per_page=page_size) -- 2.56.1 From ae04eae6e65e849a6c6d18330db7466c73f38280 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 19 Jun 2026 14:57:58 +0200 Subject: [PATCH 08/29] update career stage tooltip boundaries --- webapp/src/app/modules/person-card/person-card.component.ts | 6 +++--- webapp/src/app/modules/person/person.component.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index c9c9fa48..48e4ed9a 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -120,9 +120,9 @@ export class PersonCardComponent { '', 'Einteilung:', 'Early Researcher: 1\u20134 aktive Publikationsjahre', - 'Emerging Researcher: 5\u201310 aktive Publikationsjahre', - 'Established Researcher: 11\u201320 aktive Publikationsjahre', - 'Senior Researcher: 20+ aktive Publikationsjahre', + 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', + 'Established Researcher: 10\u201314 aktive Publikationsjahre', + 'Senior Researcher: ab 15 aktiven Publikationsjahre', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index bd8c5fd2..3bd44f29 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -166,9 +166,9 @@ export class PersonComponent { '', 'Einteilung:', 'Early Researcher: 1\u20134 aktive Publikationsjahre', - 'Emerging Researcher: 5\u201310 aktive Publikationsjahre', - 'Established Researcher: 11\u201320 aktive Publikationsjahre', - 'Senior Researcher: 20+ aktive Publikationsjahre', + 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', + 'Established Researcher: 10\u201314 aktive Publikationsjahre', + 'Senior Researcher: ab 15 aktiven Publikationsjahre', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); -- 2.56.1 From 79854123b6d63dbdca51788827b6c0afae07b3e9 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Fri, 19 Jun 2026 15:01:19 +0200 Subject: [PATCH 09/29] correct career stage tooltip wording --- webapp/src/app/modules/person-card/person-card.component.ts | 2 +- webapp/src/app/modules/person/person.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index 48e4ed9a..2844a6c3 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -122,7 +122,7 @@ export class PersonCardComponent { 'Early Researcher: 1\u20134 aktive Publikationsjahre', 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', 'Established Researcher: 10\u201314 aktive Publikationsjahre', - 'Senior Researcher: ab 15 aktiven Publikationsjahre', + 'Senior Researcher: ab 15 aktiven Publikationsjahren', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index 3bd44f29..4d7986ef 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -168,7 +168,7 @@ export class PersonComponent { 'Early Researcher: 1\u20134 aktive Publikationsjahre', 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', 'Established Researcher: 10\u201314 aktive Publikationsjahre', - 'Senior Researcher: ab 15 aktiven Publikationsjahre', + 'Senior Researcher: ab 15 aktiven Publikationsjahren', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); -- 2.56.1 From 110977c847cbbd027d1aeca989e9ba56f58b823c Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 20 Jun 2026 10:55:41 +0200 Subject: [PATCH 10/29] Update career stage labels --- service/src/main/inse/persons/logic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index ac94a469..3b535d2d 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -242,15 +242,15 @@ def _classify_career_stage(active_years: int) -> str: return "unknown" if active_years <= 4: - return "Early Researcher" + return "Early" if active_years <= 9: - return "Emerging Researcher" + return "Emerging" if active_years <= 14: - return "Established Researcher" + return "Established" - return "Senior Researcher" + return "Senior" def _compute_career_metrics(publication_years: list[int]) -> CareerMetrics: -- 2.56.1 From 522c8ca3e861f948fbf41a1ab810976bade2178a Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sat, 20 Jun 2026 15:30:31 +0200 Subject: [PATCH 11/29] Update career stage labels (frontend) --- .../app/modules/person-card/person-card.component.ts | 10 +++++----- webapp/src/app/modules/person/person.component.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index 2844a6c3..0017a99a 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -115,14 +115,14 @@ export class PersonCardComponent { const activeYears = this.person.career_metrics?.active_years ?? '-'; return [ - `Aktuell: ${careerStage}`, + `Aktuell: ${careerStage.replace(' Researcher', '')}`, `Aktive Publikationsjahre: ${activeYears}`, '', 'Einteilung:', - 'Early Researcher: 1\u20134 aktive Publikationsjahre', - 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', - 'Established Researcher: 10\u201314 aktive Publikationsjahre', - 'Senior Researcher: ab 15 aktiven Publikationsjahren', + 'Early: 1\u20134 aktive Publikationsjahre', + 'Emerging: 5\u20139 aktive Publikationsjahre', + 'Established: 10\u201314 aktive Publikationsjahre', + 'Senior: ab 15 aktiven Publikationsjahren', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts index 4d7986ef..edc7f00d 100644 --- a/webapp/src/app/modules/person/person.component.ts +++ b/webapp/src/app/modules/person/person.component.ts @@ -161,14 +161,14 @@ export class PersonComponent { const activeYears = this.person()?.career_metrics?.active_years ?? '-'; return [ - `Aktuell: ${stage}`, + `Aktuell: ${stage.replace(' Researcher', '')}`, `Aktive Publikationsjahre: ${activeYears}`, '', 'Einteilung:', - 'Early Researcher: 1\u20134 aktive Publikationsjahre', - 'Emerging Researcher: 5\u20139 aktive Publikationsjahre', - 'Established Researcher: 10\u201314 aktive Publikationsjahre', - 'Senior Researcher: ab 15 aktiven Publikationsjahren', + 'Early: 1\u20134 aktive Publikationsjahre', + 'Emerging: 5\u20139 aktive Publikationsjahre', + 'Established: 10\u201314 aktive Publikationsjahre', + 'Senior: ab 15 aktiven Publikationsjahren', '', 'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.', ].join('\n'); -- 2.56.1 From 535e5d165f0391c3e851acfbfe0e251e00a08931 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sat, 20 Jun 2026 17:33:49 +0200 Subject: [PATCH 12/29] Create reusable topic chip component --- .../person-interesting.component.html | 21 +-- .../person-interesting.component.scss | 92 ----------- .../person-interesting.component.ts | 10 +- .../research-timeline.component.html | 74 +++------ .../research-timeline.component.scss | 107 +----------- .../research-timeline.component.ts | 13 +- .../ui/topic-chip/topic-chip.component.html | 27 +++ .../ui/topic-chip/topic-chip.component.scss | 108 ++++++++++++ .../ui/topic-chip/topic-chip.component.ts | 156 ++++++++++++++++++ 9 files changed, 345 insertions(+), 263 deletions(-) create mode 100644 webapp/src/app/shared/ui/topic-chip/topic-chip.component.html create mode 100644 webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss create mode 100644 webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index 92f4d52a..1a853cf8 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -11,19 +11,16 @@
@if (tags().length > 0) { @for (tag of tags(); track tag.label; let i = $index) { - + countIcon="article" + descriptionTooltipTarget="button" + (chipClick)="onTagClick(tag)"> + } } @else { Keine Themen gefunden diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.scss b/webapp/src/app/modules/person-interesting/person-interesting.component.scss index 178b12b0..1405142c 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.scss +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.scss @@ -29,98 +29,6 @@ gap: 12px; } -.topic-chip { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - align-items: center; - justify-items: center; - column-gap: 8px; - box-sizing: border-box; - min-height: 34px; - padding: 6px 12px; - border: 1px solid var(--topic-border); - border-radius: 8px; - background: var(--topic-bg); - color: var(--topic-color); - font-family: inherit; - font-size: 12px; - font-weight: 500; - line-height: 1.25; - cursor: pointer; - transition: - transform 0.15s ease, - box-shadow 0.15s ease; - - &:hover:not(:disabled) { - transform: translateY(-1px); - box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12); - text-decoration: none; - } - - &:disabled { - cursor: default; - } -} - -.topic-name { - min-width: 0; - text-align: center; - overflow-wrap: anywhere; -} - -.topic-count { - display: inline-flex; - flex: 0 0 auto; - align-items: center; - justify-content: center; - gap: 2px; - min-width: 18px; - height: 18px; - padding: 0 5px; - border-radius: 999px; - background: rgba(255, 255, 255, 0.78); - color: inherit; - font-size: 11px; - font-weight: 700; -} - -.topic-count .count-icon { - width: 13px; - height: 13px; - font-size: 13px; - line-height: 1; -} - -.purple { - --topic-border: #d8cafe; - --topic-bg: #f6f0ff; - --topic-color: #7255d9; -} - -.blue { - --topic-border: #bdd4ff; - --topic-bg: #f0f6ff; - --topic-color: #0b63ce; -} - -.green { - --topic-border: #bdebcf; - --topic-bg: #effaf3; - --topic-color: #24834f; -} - -.orange { - --topic-border: #ffd796; - --topic-bg: #fff7e8; - --topic-color: #c67500; -} - -.pink { - --topic-border: #ffc7d7; - --topic-bg: #fff1f5; - --topic-color: #d12f61; -} - .interest-footnote { display: inline-flex; align-items: center; diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts index d137caa6..40575afb 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -1,9 +1,12 @@ import { Component, input, computed, output } from '@angular/core'; -import { MatTooltipModule } from '@angular/material/tooltip'; import { MatIconModule } from '@angular/material/icon'; import { CommonModule } from '@angular/common'; import { TopicCount } from '../../api'; +import { + TOPIC_CHIP_PALETTE, + TopicChipComponent, +} from '../../shared/ui/topic-chip/topic-chip.component'; interface InterestTag { id: string; @@ -13,11 +16,10 @@ interface InterestTag { } const MAX_TAGS = 5; -const colors = ['purple', 'blue', 'green', 'orange', 'pink']; @Component({ selector: 'app-person-interesting', - imports: [CommonModule, MatTooltipModule, MatIconModule], + imports: [CommonModule, MatIconModule, TopicChipComponent], templateUrl: './person-interesting.component.html', styleUrl: './person-interesting.component.scss', }) @@ -46,7 +48,7 @@ export class PersonInterestingComponent { }); getColorClass(index: number): string { - return colors[index % colors.length]; + return TOPIC_CHIP_PALETTE[index % TOPIC_CHIP_PALETTE.length]; } onTagClick(tag: InterestTag): void { diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index dc6026c8..bb7ba6f1 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -248,28 +248,20 @@ getDisplayedTopics(item).length > 0; else noTopicsForYear "> - + (chipClick)="selectTopic(topic, [item.year])"> + @@ -344,25 +336,17 @@
- + (chipClick)="selectTopic(topic, getPhaseYears(phase))"> + @@ -420,8 +404,7 @@ ).length > 0; else noPhaseYearTopics "> - + (chipClick)="selectTopic(topic, [year.year])"> + diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss index adf3af43..540b5793 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss @@ -11,9 +11,6 @@ button { font-family: inherit; - } - - button:not(:where(.topic-chip, .mini-topic-chip)) { border: 0; background: transparent; padding: 0; @@ -366,60 +363,9 @@ gap: 8px; } -.topic-chip { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - align-items: center; - justify-items: center; - column-gap: 8px; +app-topic-chip.timeline-topic-chip { width: 100%; max-width: 210px; - box-sizing: border-box; - min-height: 34px; - padding: 6px 10px; - border: 1px solid var(--topic-border); - border-radius: 8px; - background: var(--topic-bg); - color: var(--topic-color); - font-family: inherit; - font-size: 12px; - font-weight: 500; - line-height: 1.25; - cursor: pointer; - transition: - transform 0.15s ease, - box-shadow 0.15s ease; - - &:hover:not(:disabled) { - transform: translateY(-1px); - box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12); - text-decoration: none; - } - - &:disabled { - cursor: default; - } -} - -.topic-name, -.mini-topic-chip span { - min-width: 0; - text-align: center; - overflow-wrap: anywhere; -} - -.topic-count { - display: inline-flex; - align-items: center; - justify-content: center; - min-width: 18px; - height: 18px; - padding: 0 5px; - border-radius: 999px; - background: rgba(255, 255, 255, 0.78); - color: inherit; - font-size: 11px; - font-weight: 700; } .no-topics { @@ -505,7 +451,7 @@ gap: 7px; margin-top: 14px; - .topic-chip { + app-topic-chip.phase-topic-chip { flex: 0 0 calc((100% - 7px) / 2); width: calc((100% - 7px) / 2); max-width: none; @@ -574,73 +520,24 @@ gap: 6px; } -.mini-topic-chip { - display: inline-grid; - grid-template-columns: minmax(0, 1fr) auto; - align-items: center; - column-gap: 5px; - max-width: 100%; - padding: 4px 7px; - border: 0; - border-radius: 7px; - background: #f2f6ff; - color: #40506f; - font-family: inherit; - font-size: 11px; - line-height: 1.25; - cursor: pointer; - - &:hover:not(:disabled) { - color: var(--accent); - text-decoration: none; - } - - &:disabled { - cursor: default; - } - - strong { - display: inline-flex; - align-items: center; - gap: 2px; - color: var(--accent); - font-size: 10px; - } -} - .purple { --timeline-color: #7255d9; - --topic-border: #d8cafe; - --topic-bg: #f6f0ff; - --topic-color: #7255d9; } .blue { --timeline-color: #2678e8; - --topic-border: #bdd4ff; - --topic-bg: #f0f6ff; - --topic-color: #0b63ce; } .green { --timeline-color: #39a96b; - --topic-border: #bdebcf; - --topic-bg: #effaf3; - --topic-color: #24834f; } .orange { --timeline-color: #f59e0b; - --topic-border: #ffd796; - --topic-bg: #fff7e8; - --topic-color: #c67500; } .pink { --timeline-color: #e0527c; - --topic-border: #ffc7d7; - --topic-bg: #fff1f5; - --topic-color: #d12f61; } .timeline-note { diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts index 43c99ff3..608ed040 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts @@ -12,6 +12,10 @@ import { SimpleChanges, ViewChild, } from '@angular/core'; +import { + TOPIC_CHIP_PALETTE, + TopicChipComponent, +} from '../../../../shared/ui/topic-chip/topic-chip.component'; export interface TopicTimelineTopic { id?: string; @@ -68,7 +72,12 @@ interface TimelineScrollAnchor { @Component({ selector: 'app-research-timeline', standalone: true, - imports: [CommonModule, MatProgressSpinnerModule, MatTooltipModule], + imports: [ + CommonModule, + MatProgressSpinnerModule, + MatTooltipModule, + TopicChipComponent, + ], templateUrl: './research-timeline.component.html', styleUrl: './research-timeline.component.scss', }) @@ -98,7 +107,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { selectedStartYear = 0; selectedEndYear = 0; - private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink']; + private readonly colors = TOPIC_CHIP_PALETTE; private readonly columnWidth = 240; private readonly displayedTopicLimit = 3; private readonly displayedPhaseTopicLimit = 4; diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.html b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.html new file mode 100644 index 00000000..9ad26847 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.html @@ -0,0 +1,27 @@ + diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss new file mode 100644 index 00000000..fd1c2675 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.scss @@ -0,0 +1,108 @@ +:host { + display: inline-flex; + width: fit-content; + max-width: 100%; +} + +.topic-chip__button { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + align-items: center; + justify-items: center; + box-sizing: border-box; + width: 100%; + max-width: 100%; + color: inherit; + font-family: inherit; + line-height: 1.25; + cursor: pointer; + + &:disabled { + cursor: default; + } +} + +:host(.topic-chip--normal) .topic-chip__button { + column-gap: 8px; + min-height: 34px; + padding: 6px 10px; + border: 1px solid var(--topic-border); + border-radius: 8px; + background: var(--topic-bg); + color: var(--topic-color); + font-size: 12px; + font-weight: 500; + transition: + transform 0.15s ease, + box-shadow 0.15s ease; + + &:hover:not(:disabled) { + transform: translateY(-1px); + box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12); + text-decoration: none; + } +} + +:host(.topic-chip--mini) .topic-chip__button { + column-gap: 5px; + padding: 4px 7px; + border: 0; + border-radius: 7px; + background: #f2f6ff; + color: #40506f; + font-size: 11px; + + &:hover:not(:disabled) { + color: var(--accent); + text-decoration: none; + } +} + +:host(.topic-chip--active.topic-chip--normal) .topic-chip__button { + border-color: var(--topic-color); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--topic-color) 18%, transparent); +} + +:host(.topic-chip--active.topic-chip--mini) .topic-chip__button { + background: #eaf1ff; + color: var(--accent); +} + +.topic-chip__label { + min-width: 0; + text-align: center; + overflow-wrap: anywhere; +} + +.topic-chip__count { + display: inline-flex; + flex: 0 0 auto; + align-items: center; + justify-content: center; + gap: 2px; + min-width: 18px; + height: 18px; + padding: 0 5px; + border-radius: 999px; + background: rgba(255, 255, 255, 0.78); + color: inherit; + font-size: 11px; + font-weight: 700; +} + +:host(.topic-chip--mini) .topic-chip__count { + min-width: 0; + height: auto; + padding: 0; + border-radius: 0; + background: transparent; + color: var(--accent); + font-size: 10px; +} + +.topic-chip__count-icon { + width: 13px; + height: 13px; + font-size: 13px; + line-height: 1; +} diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts new file mode 100644 index 00000000..695b777b --- /dev/null +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts @@ -0,0 +1,156 @@ +import { + Component, + EventEmitter, + HostBinding, + Input, + Output, +} from '@angular/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; + +export const TOPIC_CHIP_PALETTE = [ + 'purple', + 'blue', + 'green', + 'orange', + 'pink', +] as const; + +export type TopicChipPaletteColor = (typeof TOPIC_CHIP_PALETTE)[number]; +export type TopicChipColor = TopicChipPaletteColor | string; +export type TopicChipSize = 'normal' | 'mini'; +export type TopicChipTooltipTarget = 'label' | 'button'; + +interface TopicChipColorTokens { + border: string; + background: string; + color: string; +} + +const TOPIC_CHIP_COLORS: Record = { + purple: { + border: '#d8cafe', + background: '#f6f0ff', + color: '#7255d9', + }, + blue: { + border: '#bdd4ff', + background: '#f0f6ff', + color: '#0b63ce', + }, + green: { + border: '#bdebcf', + background: '#effaf3', + color: '#24834f', + }, + orange: { + border: '#ffd796', + background: '#fff7e8', + color: '#c67500', + }, + pink: { + border: '#ffc7d7', + background: '#fff1f5', + color: '#d12f61', + }, +}; + +@Component({ + selector: 'app-topic-chip', + imports: [MatIconModule, MatTooltipModule], + templateUrl: './topic-chip.component.html', + styleUrl: './topic-chip.component.scss', + standalone: true, +}) +export class TopicChipComponent { + @Input() label = ''; + @Input() count: number | string | null | undefined; + @Input() description: string | null | undefined = ''; + @Input() countTooltip: string | null | undefined = ''; + @Input() countIcon: string | null | undefined; + @Input() color: TopicChipColor = 'purple'; + @Input() size: TopicChipSize = 'normal'; + @Input() disabled = false; + @Input() active = false; + @Input() descriptionTooltipTarget: TopicChipTooltipTarget = 'label'; + + @Output() chipClick = new EventEmitter(); + + @HostBinding('class.topic-chip--normal') + get normalSize(): boolean { + return this.size === 'normal'; + } + + @HostBinding('class.topic-chip--mini') + get miniSize(): boolean { + return this.size === 'mini'; + } + + @HostBinding('class.topic-chip--active') + get activeState(): boolean { + return this.active; + } + + @HostBinding('style.--topic-border') + get topicBorder(): string { + return ( + this.colorTokens?.border ?? + `color-mix(in srgb, ${this.topicColor} 35%, #ffffff)` + ); + } + + @HostBinding('style.--topic-bg') + get topicBackground(): string { + return ( + this.colorTokens?.background ?? + `color-mix(in srgb, ${this.topicColor} 10%, #ffffff)` + ); + } + + @HostBinding('style.--topic-color') + get topicColor(): string { + return this.colorTokens?.color ?? this.color; + } + + get hasCount(): boolean { + return ( + this.count !== undefined && this.count !== null && `${this.count}` !== '' + ); + } + + get labelTooltip(): string { + return this.descriptionTooltipTarget === 'label' + ? this.normalizedDescription + : ''; + } + + get buttonTooltip(): string { + return this.descriptionTooltipTarget === 'button' + ? this.normalizedDescription + : ''; + } + + get normalizedCountTooltip(): string { + return (this.countTooltip ?? '').trim(); + } + + get countIconName(): string { + return (this.countIcon ?? '').trim(); + } + + handleClick(): void { + if (this.disabled) { + return; + } + + this.chipClick.emit(); + } + + private get normalizedDescription(): string { + return (this.description ?? '').trim(); + } + + private get colorTokens(): TopicChipColorTokens | undefined { + return TOPIC_CHIP_COLORS[this.color as TopicChipPaletteColor]; + } +} -- 2.56.1 From 424918404f21e2314febb420db5f975aea442142 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sun, 21 Jun 2026 22:11:06 +0200 Subject: [PATCH 13/29] Extend TopicCount (backend) with domain, field and subfield metadata --- .../main/inse/models/openalex/topic_count.py | 24 ++++++++++ service/src/main/inse/works/logic.py | 47 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/service/src/main/inse/models/openalex/topic_count.py b/service/src/main/inse/models/openalex/topic_count.py index 445ef480..4a5d0c3d 100644 --- a/service/src/main/inse/models/openalex/topic_count.py +++ b/service/src/main/inse/models/openalex/topic_count.py @@ -8,3 +8,27 @@ class TopicCount(BaseModel): name: str = Field(description="The topic display name.") count: int = Field(default=0, description="The number of occurrences.") description: Optional[str] = Field(default=None, description="The topic description.") + subfield_id: Optional[str] = Field( + default=None, + description="The topic subfield id.", + ) + subfield_name: Optional[str] = Field( + default=None, + description="The topic subfield display name.", + ) + field_id: Optional[str] = Field( + default=None, + description="The topic field id.", + ) + field_name: Optional[str] = Field( + default=None, + description="The topic field display name.", + ) + domain_id: Optional[str] = Field( + default=None, + description="The topic domain id.", + ) + domain_name: Optional[str] = Field( + default=None, + description="The topic domain display name.", + ) diff --git a/service/src/main/inse/works/logic.py b/service/src/main/inse/works/logic.py index 37540cda..fc6bf3e1 100644 --- a/service/src/main/inse/works/logic.py +++ b/service/src/main/inse/works/logic.py @@ -29,6 +29,15 @@ from .search_client import OpenAlexWorksSearchClient logger = logging.getLogger(__name__) +TOPIC_DETAIL_SOURCE_FIELDS = [ + "id", + "display_name", + "description", + "subfield", + "field", + "domain", +] + async def get_author_works( author_id: str, @@ -121,6 +130,7 @@ async def get_primary_topic_counts( name=name, count=item["count"], description=info.get("description"), + **_topic_hierarchy_fields(info), ) ) @@ -208,7 +218,7 @@ def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]: response = elasticsearch.search( index="openalex-topics", query={"terms": {"id": topic_ids}}, - source=["id", "display_name", "description"], + source=TOPIC_DETAIL_SOURCE_FIELDS, size=len(topic_ids), ) except httpx.HTTPError: @@ -225,11 +235,41 @@ def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]: details[topic_id] = { "display_name": source.get("display_name"), "description": source.get("description"), + "subfield": _extract_topic_hierarchy_item(source, "subfield"), + "field": _extract_topic_hierarchy_item(source, "field"), + "domain": _extract_topic_hierarchy_item(source, "domain"), } return details +def _extract_topic_hierarchy_item(source: dict, key: str) -> dict[str, str | None]: + hierarchy_item = source.get(key) + + if not isinstance(hierarchy_item, dict): + return {"id": None, "display_name": None} + + return { + "id": hierarchy_item.get("id"), + "display_name": hierarchy_item.get("display_name"), + } + + +def _topic_hierarchy_fields(topic_details: dict) -> dict[str, str | None]: + subfield = topic_details.get("subfield") or {} + field = topic_details.get("field") or {} + domain = topic_details.get("domain") or {} + + return { + "subfield_id": subfield.get("id"), + "subfield_name": subfield.get("display_name"), + "field_id": field.get("id"), + "field_name": field.get("display_name"), + "domain_id": domain.get("id"), + "domain_name": domain.get("display_name"), + } + + def _limit_works_by_complete_years( work_results: list[Work], target_publications: int, @@ -445,6 +485,7 @@ async def _get_topics_by_time_by_author_from_work_pages( name=topic["name"], count=topic["count"], description=info.get("description"), + **_topic_hierarchy_fields(info), ) ) @@ -462,6 +503,7 @@ async def _get_topics_by_time_by_author_from_work_pages( name=topic["name"], count=topic["count"], description=info.get("description"), + **_topic_hierarchy_fields(info), ) ) @@ -776,6 +818,7 @@ def _build_topic_counts_from_buckets( name=display_name, count=count, description=info.get("description"), + **_topic_hierarchy_fields(info), ) ) @@ -860,4 +903,4 @@ def _parse_full_work_search_response(data: dict) -> tuple[list[Work], int]: detail="OpenAlex works search response could not be parsed.", ) from exc - return elements, total \ No newline at end of file + return elements, total -- 2.56.1 From 7a7e04d2f01ae2967e0e0357bbf02203cfeac3db Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sun, 21 Jun 2026 22:15:50 +0200 Subject: [PATCH 14/29] add shared topic color utility --- webapp/src/app/shared/utils/topic-colors.ts | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 webapp/src/app/shared/utils/topic-colors.ts diff --git a/webapp/src/app/shared/utils/topic-colors.ts b/webapp/src/app/shared/utils/topic-colors.ts new file mode 100644 index 00000000..e498b153 --- /dev/null +++ b/webapp/src/app/shared/utils/topic-colors.ts @@ -0,0 +1,108 @@ +export interface TopicHierarchyColorInput { + id?: string | null; + name?: string | null; + subfield_id?: string | null; + subfield_name?: string | null; + field_id?: string | null; + field_name?: string | null; + domain_id?: string | null; + domain_name?: string | null; +} + +const FIELD_HUES: Record = { + 'agricultural and biological sciences': 127, + 'arts and humanities': 28, + 'biochemistry, genetics and molecular biology': 154, + 'business, management and accounting': 44, + 'chemical engineering': 188, + chemistry: 174, + 'computer science': 214, + 'decision sciences': 202, + dentistry: 348, + 'earth and planetary sciences': 112, + 'economics, econometrics and finance': 52, + energy: 88, + engineering: 199, + 'environmental science': 142, + 'health professions': 334, + 'immunology and microbiology': 163, + 'materials science': 258, + mathematics: 233, + medicine: 348, + neuroscience: 282, + nursing: 326, + 'pharmacology, toxicology and pharmaceutics': 5, + 'physics and astronomy': 246, + psychology: 302, + 'social sciences': 20, + veterinary: 135, +}; + +const DOMAIN_FALLBACK_HUES: Record = { + 'health sciences': 348, + 'life sciences': 145, + 'physical sciences': 214, + 'social sciences': 24, +}; + +const SUBFIELD_HUE_OFFSETS = [-18, -12, -7, -3, 3, 7, 12, 18]; + +export function topicHierarchyColor( + topic: TopicHierarchyColorInput | undefined | null, +): string { + if (!topic) { + return 'hsl(214 58% 38%)'; + } + + const fieldKey = normalizeColorKey(topic.field_name); + const domainKey = normalizeColorKey(topic.domain_name); + const fieldIdentity = + topic.field_id ?? fieldKey ?? topic.domain_id ?? domainKey; + const subfieldIdentity = + topic.subfield_id ?? + normalizeColorKey(topic.subfield_name) ?? + topic.id ?? + normalizeColorKey(topic.name) ?? + fieldIdentity ?? + 'topic'; + + const baseHue = + (fieldKey ? FIELD_HUES[fieldKey] : undefined) ?? + (domainKey ? DOMAIN_FALLBACK_HUES[domainKey] : undefined) ?? + stableHue(fieldIdentity ?? subfieldIdentity); + + const variantHash = stableHash(subfieldIdentity); + const offset = + SUBFIELD_HUE_OFFSETS[variantHash % SUBFIELD_HUE_OFFSETS.length]; + const hue = normalizeHue(baseHue + offset); + const saturation = 55 + ((variantHash >> 3) % 14); + const lightness = 32 + ((variantHash >> 7) % 10); + + return `hsl(${hue} ${saturation}% ${lightness}%)`; +} + +function normalizeColorKey( + value: string | null | undefined, +): string | undefined { + const normalized = value?.trim().toLowerCase(); + + return normalized || undefined; +} + +function stableHue(value: string): number { + return stableHash(value) % 360; +} + +function stableHash(value: string): number { + let hash = 0; + + for (let index = 0; index < value.length; index += 1) { + hash = Math.imul(hash ^ value.charCodeAt(index), 16777619); + } + + return hash >>> 0; +} + +function normalizeHue(value: number): number { + return ((value % 360) + 360) % 360; +} -- 2.56.1 From 6d2b7a9873293abb850686b2dcdf9911cbb8a4a1 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sun, 21 Jun 2026 22:17:11 +0200 Subject: [PATCH 15/29] color interest topics semantically --- webapp/src/app/api/model/topicCount.ts | 6 ++++++ .../person-interesting.component.html | 4 ++-- .../person-interesting.component.ts | 12 ++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/webapp/src/app/api/model/topicCount.ts b/webapp/src/app/api/model/topicCount.ts index 559242d9..720ba500 100644 --- a/webapp/src/app/api/model/topicCount.ts +++ b/webapp/src/app/api/model/topicCount.ts @@ -19,4 +19,10 @@ export interface TopicCount { */ count?: number; description?: string | null; + subfield_id?: string | null; + subfield_name?: string | null; + field_id?: string | null; + field_name?: string | null; + domain_id?: string | null; + domain_name?: string | null; } diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index 1a853cf8..11b6989a 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -10,12 +10,12 @@
@if (tags().length > 0) { - @for (tag of tags(); track tag.label; let i = $index) { + @for (tag of tags(); track tag.label) { b.count - a.count).slice(0, MAX_TAGS); }); - getColorClass(index: number): string { - return TOPIC_CHIP_PALETTE[index % TOPIC_CHIP_PALETTE.length]; - } - onTagClick(tag: InterestTag): void { if (!tag.id) return; this.tagClick.emit({ id: tag.id, name: tag.label }); -- 2.56.1 From 6651737b65eeb5b8e7518c8e0aaccc5e489a0ba9 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Sun, 21 Jun 2026 22:23:21 +0200 Subject: [PATCH 16/29] color research timeline topics semantically --- .../research-timeline.component.html | 23 ++--- .../research-timeline.component.scss | 20 ----- .../research-timeline.component.ts | 89 +++++++++++++++++-- .../person-overview.component.ts | 6 ++ .../ui/topic-chip/topic-chip.component.scss | 12 +-- 5 files changed, 103 insertions(+), 47 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index bb7ba6f1..46eb050e 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -157,13 +157,11 @@
+ [style.--timeline-color]=" + getTopicColor(getMainTopicItem(item)) + "> +
+
- -
+
+
+ {{ group.name }} - + + + + {{ item.name }} + + +
+ + +
+ + + +
(); @@ -193,25 +196,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { return groups; } - let remainingItems = this.collapsedSubfieldLegendLimit; - const visibleGroups: TopicFieldLegendGroup[] = []; - - for (const group of groups) { - if (remainingItems <= 0) { - break; - } - - const items = group.items.slice(0, remainingItems); - - if (items.length === 0) { - continue; - } - - visibleGroups.push({ ...group, items }); - remainingItems -= items.length; - } - - return visibleGroups; + return groups.slice(0, this.collapsedSubfieldLegendGroupLimit); } get hiddenSubfieldLegendItemCount(): number { @@ -219,10 +204,9 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { return 0; } - return Math.max( - this.allSubfieldLegendItemCount - this.collapsedSubfieldLegendLimit, - 0, - ); + return this.allSubfieldLegendGroups + .slice(this.collapsedSubfieldLegendGroupLimit) + .reduce((count, group) => count + group.items.length, 0); } get showSubfieldLegendToggle(): boolean { @@ -461,6 +445,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { this.subfieldLegendExpanded = !this.subfieldLegendExpanded; } + toggleSubfieldLegendVisibility(): void { + this.subfieldLegendVisible = !this.subfieldLegendVisible; + } + trackByLegendGroup(_: number, group: TopicFieldLegendGroup): string { return group.id; } @@ -669,13 +657,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { .sort((left, right) => left.name.localeCompare(right.name)); } - private get allSubfieldLegendItemCount(): number { - return this.allSubfieldLegendGroups.reduce( - (count, group) => count + group.items.length, - 0, - ); - } - private get visibleLegendTopics(): TopicTimelineTopic[] { if (this.timelineViewMode === 'compact') { return this.compactPhases.flatMap((phase) => [ -- 2.56.1 From 95a9dcceff9c219f1fa77d44b6f7f8257f145138 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Mon, 22 Jun 2026 23:35:05 +0200 Subject: [PATCH 25/29] translate openalex labels --- .../research-timeline/research-timeline.component.html | 6 +++--- webapp/src/app/shared/utils/topic-tooltip.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index ac4b5a32..1416ac78 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -11,13 +11,13 @@ *ngIf="subfieldLegendGroups.length > 0" class="subfield-legend" [class.expanded]="subfieldLegendExpanded" - aria-label="Aktuell sichtbare Subfields"> + aria-label="Aktuell sichtbare Themenbereiche">
- Farben nach Subfield + Farben nach Themenbereich info_outline diff --git a/webapp/src/app/shared/utils/topic-tooltip.ts b/webapp/src/app/shared/utils/topic-tooltip.ts index d8315852..87ff4e61 100644 --- a/webapp/src/app/shared/utils/topic-tooltip.ts +++ b/webapp/src/app/shared/utils/topic-tooltip.ts @@ -22,22 +22,22 @@ export function buildTopicHierarchyTooltip( return ''; } - const lines = [`Topic: ${topicName}`]; + const lines = [`Forschungsthema: ${topicName}`]; if (subfieldName) { - lines.push(`Subfield: ${subfieldName}`); + lines.push(`Themenbereich: ${subfieldName}`); } if (fieldName) { - lines.push(`Field: ${fieldName}`); + lines.push(`Fachgebiet: ${fieldName}`); } if (domainName) { - lines.push(`Domain: ${domainName}`); + lines.push(`Wissenschaftsbereich: ${domainName}`); } if (description) { - lines.push(`Description: ${description}`); + lines.push(`Beschreibung: ${description}`); } return lines.join('\n\n'); -- 2.56.1 From 6ea5ac1b172c0def94b5f0e8d3838c242ec7fda9 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Mon, 22 Jun 2026 23:54:23 +0200 Subject: [PATCH 26/29] add expandable topic color legend --- .../person-interesting.component.html | 64 +++++++++---- .../person-interesting.component.scss | 91 ++++++++++++++++--- .../person-interesting.component.ts | 26 +++++- 3 files changed, 145 insertions(+), 36 deletions(-) diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index d88ebffc..650677af 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -6,28 +6,52 @@ article Anzahl Publikationen zum Thema - @if (legendGroups().length > 0) { -
- @for (group of legendGroups(); track group.id) { - - {{ group.name }} - - @for (item of group.items; track item.id) { - - - {{ item.name }} - - } - - - } -
- } }
+ @if (visibleLegendGroups().length > 0) { +
+ + info_outline + + +
+ @for (group of visibleLegendGroups(); track group.id) { + + {{ group.name }} + + @for (item of group.items; track item.id) { + + + {{ item.name }} + + } + + + } + + @if (hasHiddenLegendGroups()) { + + } +
+
+ }
@if (tags().length > 0) { @for (tag of tags(); track tag.label) { diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.scss b/webapp/src/app/modules/person-interesting/person-interesting.component.scss index ebd1babb..ec4f6a04 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.scss +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.scss @@ -15,7 +15,7 @@ align-items: baseline; gap: 10px; flex-wrap: wrap; - margin: 0 0 18px; + margin: 0 0 12px; } .interest-card h3 { @@ -46,50 +46,87 @@ } .interest-legend { + display: flex; + align-items: flex-start; + gap: 9px; + width: fit-content; + max-width: 100%; + margin: 0 0 16px; + padding: 8px 10px; + border: 1px solid #dbe5f6; + border-radius: 8px; + background: #ffffff; + box-sizing: border-box; +} + +.interest-legend-content, +.interest-legend-group, +.interest-legend-items, +.interest-legend-item { display: inline-flex; - flex-wrap: wrap; align-items: center; - gap: 6px; +} + +.interest-legend-info { + flex: 0 0 auto; + width: 14px; + height: 14px; + color: #7d8aa8; + font-size: 14px; + line-height: 14px; +} + +.interest-legend-content { + gap: 7px; + flex: 0 1 auto; min-width: 0; + max-width: 100%; + flex-wrap: wrap; } .interest-legend-group { - display: inline-flex; - align-items: center; gap: 6px; + flex: 0 1 auto; + flex-wrap: wrap; + min-width: 0; max-width: 100%; - min-height: 22px; + min-height: 24px; padding: 3px 7px; border: 1px solid #dbe5f6; border-radius: 999px; - background: rgba(255, 255, 255, 0.68); + background: #fbfdff; } .interest-legend-field { - flex: 0 0 auto; - color: #1b2a4a; + flex: 0 1 auto; + min-width: 0; + color: #07163d; font-size: 10px; font-weight: 800; line-height: 1.2; } .interest-legend-items { - display: inline-flex; - flex-wrap: wrap; - align-items: center; + flex: 0 1 auto; gap: 4px 7px; min-width: 0; + flex-wrap: wrap; } .interest-legend-item { - display: inline-flex; - align-items: center; gap: 4px; + flex: 0 0 auto; min-width: 0; color: #53617e; font-size: 10px; font-weight: 600; line-height: 1.2; + white-space: nowrap; + + span:last-child { + overflow: visible; + text-overflow: clip; + } } .interest-legend-dot { @@ -101,6 +138,32 @@ box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2); } +.interest-legend-more { + display: inline-flex; + align-items: center; + flex: 0 0 auto; + min-height: 24px; + padding: 0 2px; + border: 0; + background: transparent; + color: var(--accent, #0057ff); + cursor: pointer; + font: inherit; + font-size: 11px; + font-weight: 700; + white-space: nowrap; + + &:hover { + text-decoration: underline; + } + + &:focus-visible { + outline: 2px solid var(--accent, #0057ff); + outline-offset: 2px; + border-radius: 4px; + } +} + .interest-tags .interest-empty { padding: 9px 16px; border: 1px solid #e2e8f0; diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts index 0e0fd749..1a695ead 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -1,5 +1,6 @@ -import { Component, input, computed, output } from '@angular/core'; +import { Component, input, computed, output, signal } from '@angular/core'; import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { CommonModule } from '@angular/common'; import { TopicCount } from '../../api'; @@ -33,15 +34,17 @@ interface InterestLegendItem { } const MAX_TAGS = 5; +const MAX_LEGEND_GROUPS = 3; @Component({ selector: 'app-person-interesting', - imports: [CommonModule, MatIconModule, TopicChipComponent], + imports: [CommonModule, MatIconModule, MatTooltipModule, TopicChipComponent], templateUrl: './person-interesting.component.html', styleUrl: './person-interesting.component.scss', }) export class PersonInterestingComponent { readonly topics = input(null); + readonly legendExpanded = signal(false); readonly tagClick = output<{ id: string; name: string }>(); @@ -114,8 +117,27 @@ export class PersonInterestingComponent { .sort((left, right) => left.name.localeCompare(right.name)); }); + readonly visibleLegendGroups = computed(() => { + const groups = this.legendGroups(); + return this.legendExpanded() ? groups : groups.slice(0, MAX_LEGEND_GROUPS); + }); + + readonly hasHiddenLegendGroups = computed( + () => this.legendGroups().length > MAX_LEGEND_GROUPS, + ); + + readonly hiddenLegendItemCount = computed(() => + this.legendGroups() + .slice(MAX_LEGEND_GROUPS) + .reduce((count, group) => count + group.items.length, 0), + ); + onTagClick(tag: InterestTag): void { if (!tag.id) return; this.tagClick.emit({ id: tag.id, name: tag.label }); } + + toggleLegend(): void { + this.legendExpanded.update((expanded) => !expanded); + } } -- 2.56.1 From ddb3439324c61b9d625010fbd8e17136a2227a8d Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Tue, 23 Jun 2026 00:03:38 +0200 Subject: [PATCH 27/29] enlarge topic color markers --- .../research-timeline.component.scss | 14 +++++++------- .../shared/ui/topic-chip/topic-chip.component.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss index e9c2aae5..f03956dc 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss @@ -411,8 +411,8 @@ } .dot { - width: 14px; - height: 14px; + width: 18px; + height: 18px; border: 3px solid #ffffff; border-radius: 50%; background: var(--timeline-color); @@ -527,9 +527,9 @@ app-topic-chip.timeline-topic-chip { } .phase-marker { - width: 12px; - height: 12px; - margin-top: 5px; + width: 16px; + height: 16px; + margin-top: 3px; border: 3px solid #ffffff; border-radius: 50%; background: var(--timeline-color); @@ -660,8 +660,8 @@ app-topic-chip.timeline-topic-chip { } .note-dot { - width: 10px; - height: 10px; + width: 12px; + height: 12px; border: 3px solid #dce5f5; border-radius: 50%; background: #52627f; diff --git a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts index 7558584b..f8d7f81c 100644 --- a/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts +++ b/webapp/src/app/shared/ui/topic-chip/topic-chip.component.ts @@ -99,7 +99,7 @@ export class TopicChipComponent { get topicBorder(): string { return ( this.colorTokens?.border ?? - `color-mix(in srgb, ${this.topicColor} 52%, #ffffff)` + `color-mix(in srgb, ${this.topicColor} 72%, #ffffff)` ); } -- 2.56.1 From 03e21fcb3254e61719a1f95b999820e45eedccb3 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Tue, 23 Jun 2026 00:21:52 +0200 Subject: [PATCH 28/29] expanded state in URL --- .../person-interesting.component.spec.ts | 2 + .../person-interesting.component.ts | 70 ++++++++++++++++++- .../research-timeline.component.ts | 10 +-- .../person-overview.component.html | 4 ++ .../person-overview.component.ts | 65 ++++++++++++++++- 5 files changed, 143 insertions(+), 8 deletions(-) diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts index 0a056035..c20e79de 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts @@ -1,4 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; import { PersonInterestingComponent } from './person-interesting.component'; @@ -9,6 +10,7 @@ describe('PersonInterestingComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [PersonInterestingComponent], + providers: [provideRouter([])], }).compileComponents(); fixture = TestBed.createComponent(PersonInterestingComponent); diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts index 1a695ead..122cda7e 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -1,7 +1,18 @@ -import { Component, input, computed, output, signal } from '@angular/core'; +import { + Component, + DestroyRef, + OnInit, + computed, + inject, + input, + output, + signal, +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; import { CommonModule } from '@angular/common'; +import { ActivatedRoute, Router } from '@angular/router'; import { TopicCount } from '../../api'; import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component'; @@ -42,7 +53,14 @@ const MAX_LEGEND_GROUPS = 3; templateUrl: './person-interesting.component.html', styleUrl: './person-interesting.component.scss', }) -export class PersonInterestingComponent { +export class PersonInterestingComponent implements OnInit { + private static readonly legendExpandedQueryParam = + 'interesting_legend_expanded'; + + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); + private readonly destroyRef = inject(DestroyRef); + readonly topics = input(null); readonly legendExpanded = signal(false); @@ -132,12 +150,58 @@ export class PersonInterestingComponent { .reduce((count, group) => count + group.items.length, 0), ); + ngOnInit(): void { + this.route.queryParamMap + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((queryParams) => { + this.legendExpanded.set( + this.parseBooleanQueryParam( + queryParams.get( + PersonInterestingComponent.legendExpandedQueryParam, + ), + false, + ), + ); + }); + } + onTagClick(tag: InterestTag): void { if (!tag.id) return; this.tagClick.emit({ id: tag.id, name: tag.label }); } toggleLegend(): void { - this.legendExpanded.update((expanded) => !expanded); + const expanded = !this.legendExpanded(); + this.legendExpanded.set(expanded); + + void this.router.navigate([], { + relativeTo: this.route, + queryParams: { + [PersonInterestingComponent.legendExpandedQueryParam]: expanded + ? 'true' + : null, + }, + queryParamsHandling: 'merge', + replaceUrl: true, + }); + } + + private parseBooleanQueryParam( + value: string | null, + fallback: boolean, + ): boolean { + if (value === null) { + return fallback; + } + + if (value === 'true' || value === '1') { + return true; + } + + if (value === 'false' || value === '0') { + return false; + } + + return fallback; } } diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts index 268dc074..60fb616f 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts @@ -112,12 +112,16 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { @Input() viewMode: TimelineViewMode = 'years'; @Input() startYear: number | undefined; @Input() endYear: number | undefined; + @Input() subfieldLegendVisible = true; + @Input() subfieldLegendExpanded = false; @Output() viewModeChange = new EventEmitter(); @Output() yearRangeChange = new EventEmitter(); @Output() topicSelect = new EventEmitter(); @Output() yearSelect = new EventEmitter(); @Output() loadEarlierYears = new EventEmitter(); + @Output() subfieldLegendVisibleChange = new EventEmitter(); + @Output() subfieldLegendExpandedChange = new EventEmitter(); timelineViewMode: TimelineViewMode = 'years'; @@ -125,8 +129,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { maxYear = 0; selectedStartYear = 0; selectedEndYear = 0; - subfieldLegendVisible = true; - subfieldLegendExpanded = false; private readonly columnWidth = 240; private readonly displayedTopicLimit = 3; @@ -146,12 +148,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { this.timelineViewMode = this.isTimelineViewMode(this.viewMode) ? this.viewMode : 'years'; - this.subfieldLegendExpanded = false; } if (changes['elements']) { this.initializeYearBounds(); - this.subfieldLegendExpanded = false; } if (changes['elements'] || changes['startYear'] || changes['endYear']) { @@ -443,10 +443,12 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { toggleSubfieldLegend(): void { this.subfieldLegendExpanded = !this.subfieldLegendExpanded; + this.subfieldLegendExpandedChange.emit(this.subfieldLegendExpanded); } toggleSubfieldLegendVisibility(): void { this.subfieldLegendVisible = !this.subfieldLegendVisible; + this.subfieldLegendVisibleChange.emit(this.subfieldLegendVisible); } trackByLegendGroup(_: number, group: TopicFieldLegendGroup): string { diff --git a/webapp/src/app/modules/person-overview/person-overview.component.html b/webapp/src/app/modules/person-overview/person-overview.component.html index 31ac9ae8..ae891993 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -9,8 +9,12 @@ [viewMode]="timelineViewMode" [startYear]="timelineStartYear" [endYear]="timelineEndYear" + [subfieldLegendVisible]="timelineLegendVisible" + [subfieldLegendExpanded]="timelineLegendExpanded" (viewModeChange)="onTimelineViewModeChange($event)" (yearRangeChange)="onTimelineYearRangeChange($event)" + (subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)" + (subfieldLegendExpandedChange)="onTimelineLegendExpandedChange($event)" (topicSelect)="onTimelineTopicSelect($event)" (yearSelect)="onTimelineYearSelect($event)" (loadEarlierYears)="onTimelineLoadEarlierYears()"> diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index 97fb8c8b..fa76ba7e 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -28,6 +28,10 @@ export class PersonOverviewComponent implements OnInit { private static readonly timelineViewQueryParam = 'timeline_view'; private static readonly timelineStartYearQueryParam = 'timeline_start_year'; private static readonly timelineEndYearQueryParam = 'timeline_end_year'; + private static readonly timelineLegendVisibleQueryParam = + 'timeline_legend_visible'; + private static readonly timelineLegendExpandedQueryParam = + 'timeline_legend_expanded'; private static readonly timelineTopicCountLimit = 4; private static readonly initialTimelineTargetPublications = 250; @@ -49,6 +53,8 @@ export class PersonOverviewComponent implements OnInit { timelineViewMode: TimelineViewMode = 'years'; timelineStartYear: number | undefined; timelineEndYear: number | undefined; + timelineLegendVisible = true; + timelineLegendExpanded = false; wordCloudOptions: EChartsOption | null = null; loadingWordCloud = false; @@ -84,6 +90,18 @@ export class PersonOverviewComponent implements OnInit { this.timelineEndYear = this.parseOptionalYear( queryParams.get(PersonOverviewComponent.timelineEndYearQueryParam), ); + this.timelineLegendVisible = this.parseBooleanQueryParam( + queryParams.get( + PersonOverviewComponent.timelineLegendVisibleQueryParam, + ), + true, + ); + this.timelineLegendExpanded = this.parseBooleanQueryParam( + queryParams.get( + PersonOverviewComponent.timelineLegendExpandedQueryParam, + ), + false, + ); }); } @@ -112,6 +130,32 @@ export class PersonOverviewComponent implements OnInit { ); } + onTimelineLegendVisibleChange(visible: boolean): void { + this.timelineLegendVisible = visible; + + this.updateTimelineQueryParams( + { + [PersonOverviewComponent.timelineLegendVisibleQueryParam]: visible + ? null + : 'false', + }, + true, + ); + } + + onTimelineLegendExpandedChange(expanded: boolean): void { + this.timelineLegendExpanded = expanded; + + this.updateTimelineQueryParams( + { + [PersonOverviewComponent.timelineLegendExpandedQueryParam]: expanded + ? 'true' + : null, + }, + true, + ); + } + onTimelineTopicSelect(selection: TimelineTopicSelection): void { if (!selection.topic.id) { return; @@ -499,8 +543,27 @@ export class PersonOverviewComponent implements OnInit { return year; } + private parseBooleanQueryParam( + value: string | null, + fallback: boolean, + ): boolean { + if (value === null) { + return fallback; + } + + if (value === 'true' || value === '1') { + return true; + } + + if (value === 'false' || value === '0') { + return false; + } + + return fallback; + } + private updateTimelineQueryParams( - queryParams: Record, + queryParams: Record, replaceUrl: boolean, ): void { void this.router.navigate([], { -- 2.56.1 From 9905750d75b9bd3f1fd96edb5d992a1d669151b8 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Tue, 23 Jun 2026 00:47:39 +0200 Subject: [PATCH 29/29] show subfields, fields and domains descriptions in tooltips --- .../main/inse/models/openalex/topic_count.py | 12 ++ service/src/main/inse/works/logic.py | 66 ++++++++++- webapp/src/app/api/model/topicCount.ts | 3 + .../person-interesting.component.html | 16 ++- .../person-interesting.component.scss | 2 + .../person-interesting.component.ts | 72 ++++++++++++ .../research-timeline.component.html | 15 ++- .../research-timeline.component.scss | 2 + .../research-timeline.component.ts | 105 ++++++++++++++++++ .../person-overview.component.ts | 3 + 10 files changed, 291 insertions(+), 5 deletions(-) diff --git a/service/src/main/inse/models/openalex/topic_count.py b/service/src/main/inse/models/openalex/topic_count.py index 4a5d0c3d..8d6be897 100644 --- a/service/src/main/inse/models/openalex/topic_count.py +++ b/service/src/main/inse/models/openalex/topic_count.py @@ -16,6 +16,10 @@ class TopicCount(BaseModel): default=None, description="The topic subfield display name.", ) + subfield_description: Optional[str] = Field( + default=None, + description="The topic subfield description.", + ) field_id: Optional[str] = Field( default=None, description="The topic field id.", @@ -24,6 +28,10 @@ class TopicCount(BaseModel): default=None, description="The topic field display name.", ) + field_description: Optional[str] = Field( + default=None, + description="The topic field description.", + ) domain_id: Optional[str] = Field( default=None, description="The topic domain id.", @@ -32,3 +40,7 @@ class TopicCount(BaseModel): default=None, description="The topic domain display name.", ) + domain_description: Optional[str] = Field( + default=None, + description="The topic domain description.", + ) diff --git a/service/src/main/inse/works/logic.py b/service/src/main/inse/works/logic.py index 070251d4..9d5918cf 100644 --- a/service/src/main/inse/works/logic.py +++ b/service/src/main/inse/works/logic.py @@ -38,6 +38,17 @@ TOPIC_DETAIL_SOURCE_FIELDS = [ "domain", ] +TOPIC_HIERARCHY_DESCRIPTION_INDICES = { + "subfield": "openalex-subfields", + "field": "openalex-fields", + "domain": "openalex-domains", +} + +TOPIC_HIERARCHY_DESCRIPTION_SOURCE_FIELDS = [ + "id", + "description", +] + async def get_author_works( author_id: str, @@ -240,6 +251,8 @@ def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]: "domain": _extract_topic_hierarchy_item(source, "domain"), } + _enrich_topic_hierarchy_descriptions(details) + return details @@ -247,14 +260,62 @@ def _extract_topic_hierarchy_item(source: dict, key: str) -> dict[str, str | Non hierarchy_item = source.get(key) if not isinstance(hierarchy_item, dict): - return {"id": None, "display_name": None} + return {"id": None, "display_name": None, "description": None} return { "id": hierarchy_item.get("id"), "display_name": hierarchy_item.get("display_name"), + "description": hierarchy_item.get("description"), } +def _enrich_topic_hierarchy_descriptions(details: dict[str, dict]) -> None: + for hierarchy_key, index in TOPIC_HIERARCHY_DESCRIPTION_INDICES.items(): + hierarchy_ids = { + item.get(hierarchy_key, {}).get("id") + for item in details.values() + if item.get(hierarchy_key, {}).get("id") + } + + descriptions = _get_topic_hierarchy_descriptions(index, list(hierarchy_ids)) + + for item in details.values(): + hierarchy_item = item.get(hierarchy_key) or {} + hierarchy_id = hierarchy_item.get("id") + + if hierarchy_id and hierarchy_id in descriptions: + hierarchy_item["description"] = descriptions[hierarchy_id] + + +def _get_topic_hierarchy_descriptions( + index: str, + hierarchy_ids: list[str], +) -> dict[str, str | None]: + if not hierarchy_ids: + return {} + + try: + response = elasticsearch.search( + index=index, + query={"terms": {"id": hierarchy_ids}}, + source=TOPIC_HIERARCHY_DESCRIPTION_SOURCE_FIELDS, + size=len(hierarchy_ids), + ) + except httpx.HTTPError: + logger.exception("Could not load topic hierarchy details from %s.", index) + return {} + + descriptions = {} + for hit in response.get("hits", {}).get("hits", []): + source = hit.get("_source", {}) + hierarchy_id = source.get("id") + + if hierarchy_id: + descriptions[hierarchy_id] = source.get("description") + + return descriptions + + def _topic_hierarchy_fields(topic_details: dict) -> dict[str, str | None]: subfield = topic_details.get("subfield") or {} field = topic_details.get("field") or {} @@ -263,10 +324,13 @@ def _topic_hierarchy_fields(topic_details: dict) -> dict[str, str | None]: return { "subfield_id": subfield.get("id"), "subfield_name": subfield.get("display_name"), + "subfield_description": subfield.get("description"), "field_id": field.get("id"), "field_name": field.get("display_name"), + "field_description": field.get("description"), "domain_id": domain.get("id"), "domain_name": domain.get("display_name"), + "domain_description": domain.get("description"), } diff --git a/webapp/src/app/api/model/topicCount.ts b/webapp/src/app/api/model/topicCount.ts index 720ba500..1d2abe90 100644 --- a/webapp/src/app/api/model/topicCount.ts +++ b/webapp/src/app/api/model/topicCount.ts @@ -21,8 +21,11 @@ export interface TopicCount { description?: string | null; subfield_id?: string | null; subfield_name?: string | null; + subfield_description?: string | null; field_id?: string | null; field_name?: string | null; + field_description?: string | null; domain_id?: string | null; domain_name?: string | null; + domain_description?: string | null; } diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index 650677af..7a9e4e45 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -21,10 +21,22 @@
@for (group of visibleLegendGroups(); track group.id) { - {{ group.name }} + {{ group.name }} @for (item of group.items; track item.id) { - + , + ): string { + const lines: string[] = []; + + for (const entry of entries) { + if (!entry.value && !entry.description) { + continue; + } + + if (lines.length > 0) { + lines.push(''); + } + + if (entry.value) { + lines.push(`${entry.label}: ${entry.value}`); + } + + if (entry.description) { + lines.push(''); + lines.push(`Beschreibung: ${entry.description}`); + } + } + + return lines.join('\n'); + } } diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index 1416ac78..dd8801dc 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -49,12 +49,23 @@ trackBy: trackByLegendGroup " class="subfield-legend-group"> - {{ group.name }} + {{ group.name }} + class="subfield-legend-item" + [matTooltip]="item.tooltip" + [matTooltipDisabled]="!item.tooltip" + matTooltipClass="topic-chip-tooltip" + matTooltipPosition="above"> 0; } + buildLegendTooltip( + entries: Array<{ label: string; value: string; description: string }>, + ): string { + const lines: string[] = []; + + for (const entry of entries) { + if (!entry.value && !entry.description) { + continue; + } + + if (lines.length > 0) { + lines.push(''); + } + + if (entry.value) { + lines.push(`${entry.label}: ${entry.value}`); + } + + if (entry.description) { + lines.push(''); + lines.push(`Beschreibung: ${entry.description}`); + } + } + + return lines.join('\n'); + } + getYearTopicCountTooltip( topic: TopicTimelineTopic, item: TopicTimelineElement, @@ -632,6 +668,21 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { groups.set(fieldKey, { id: fieldKey, name: fieldName, + description: topic.field_description?.trim() ?? '', + domainName: topic.domain_name?.trim() ?? '', + domainDescription: topic.domain_description?.trim() ?? '', + tooltip: this.buildLegendTooltip([ + { + label: 'Fachgebiet', + value: fieldName, + description: topic.field_description?.trim() ?? '', + }, + { + label: 'Wissenschaftsbereich', + value: topic.domain_name?.trim() ?? '', + description: topic.domain_description?.trim() ?? '', + }, + ]), items: [], }); } @@ -645,7 +696,25 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { group.items.push({ id: subfieldKey, name: subfieldName, + description: topic.subfield_description?.trim() ?? '', color: this.getTopicColor(topic), + tooltip: this.buildLegendTooltip([ + { + label: 'Themenbereich', + value: subfieldName, + description: topic.subfield_description?.trim() ?? '', + }, + { + label: 'Fachgebiet', + value: fieldName, + description: topic.field_description?.trim() ?? '', + }, + { + label: 'Wissenschaftsbereich', + value: topic.domain_name?.trim() ?? '', + description: topic.domain_description?.trim() ?? '', + }, + ]), }); } @@ -812,10 +881,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { let description = primaryTopic.description; let subfieldId = primaryTopic.subfield_id; let subfieldName = primaryTopic.subfield_name; + let subfieldDescription = primaryTopic.subfield_description; let fieldId = primaryTopic.field_id; let fieldName = primaryTopic.field_name; + let fieldDescription = primaryTopic.field_description; let domainId = primaryTopic.domain_id; let domainName = primaryTopic.domain_name; + let domainDescription = primaryTopic.domain_description; for (const year of years) { for (const topic of year.primary_topics ?? []) { @@ -841,6 +913,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { subfieldName = topic.subfield_name; } + if (!subfieldDescription && topic.subfield_description) { + subfieldDescription = topic.subfield_description; + } + if (!fieldId && topic.field_id) { fieldId = topic.field_id; } @@ -849,6 +925,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { fieldName = topic.field_name; } + if (!fieldDescription && topic.field_description) { + fieldDescription = topic.field_description; + } + if (!domainId && topic.domain_id) { domainId = topic.domain_id; } @@ -856,6 +936,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { if (!domainName && topic.domain_name) { domainName = topic.domain_name; } + + if (!domainDescription && topic.domain_description) { + domainDescription = topic.domain_description; + } } } @@ -866,10 +950,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { description, subfield_id: subfieldId, subfield_name: subfieldName, + subfield_description: subfieldDescription, field_id: fieldId, field_name: fieldName, + field_description: fieldDescription, domain_id: domainId, domain_name: domainName, + domain_description: domainDescription, }; } @@ -883,10 +970,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { const descriptions = new Map(); const subfieldIds = new Map(); const subfieldNames = new Map(); + const subfieldDescriptions = new Map(); const fieldIds = new Map(); const fieldNames = new Map(); + const fieldDescriptions = new Map(); const domainIds = new Map(); const domainNames = new Map(); + const domainDescriptions = new Map(); for (const year of years) { for (const topic of year.topics ?? []) { @@ -914,6 +1004,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { subfieldNames.set(normalizedName, topic.subfield_name); } + if (topic.subfield_description) { + subfieldDescriptions.set(normalizedName, topic.subfield_description); + } + if (topic.field_id) { fieldIds.set(normalizedName, topic.field_id); } @@ -922,6 +1016,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { fieldNames.set(normalizedName, topic.field_name); } + if (topic.field_description) { + fieldDescriptions.set(normalizedName, topic.field_description); + } + if (topic.domain_id) { domainIds.set(normalizedName, topic.domain_id); } @@ -930,6 +1028,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { domainNames.set(normalizedName, topic.domain_name); } + if (topic.domain_description) { + domainDescriptions.set(normalizedName, topic.domain_description); + } + counts.set( normalizedName, (counts.get(normalizedName) ?? 0) + topic.count, @@ -945,10 +1047,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { description: descriptions.get(normalizedName), subfield_id: subfieldIds.get(normalizedName), subfield_name: subfieldNames.get(normalizedName), + subfield_description: subfieldDescriptions.get(normalizedName), field_id: fieldIds.get(normalizedName), field_name: fieldNames.get(normalizedName), + field_description: fieldDescriptions.get(normalizedName), domain_id: domainIds.get(normalizedName), domain_name: domainNames.get(normalizedName), + domain_description: domainDescriptions.get(normalizedName), })) .sort((left, right) => { if (right.count !== left.count) { diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index fa76ba7e..3d30ee16 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -482,10 +482,13 @@ export class PersonOverviewComponent implements OnInit { description: topic.description ?? undefined, subfield_id: topic.subfield_id ?? undefined, subfield_name: topic.subfield_name ?? undefined, + subfield_description: topic.subfield_description ?? undefined, field_id: topic.field_id ?? undefined, field_name: topic.field_name ?? undefined, + field_description: topic.field_description ?? undefined, domain_id: topic.domain_id ?? undefined, domain_name: topic.domain_name ?? undefined, + domain_description: topic.domain_description ?? undefined, })); } -- 2.56.1