From a278ad300f34d0f3a44da2393ae8428061b2378a Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Thu, 23 Jul 2026 09:47:14 +0200 Subject: [PATCH 01/27] add field, subfield, and topic nodes for topic treemap (backend) --- service/src/main/inse/ranking/logic.py | 48 ++++++++++++++++++++++++++ service/src/main/inse/ranking/model.py | 28 +++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/service/src/main/inse/ranking/logic.py b/service/src/main/inse/ranking/logic.py index faa023bf..5ac80c00 100644 --- a/service/src/main/inse/ranking/logic.py +++ b/service/src/main/inse/ranking/logic.py @@ -28,6 +28,9 @@ from .model import ( RankingWeights, SubfieldShare, Timespan, + FieldNode, + SubfieldNode, + TopicNode, ) logger = logging.getLogger(__name__) @@ -493,6 +496,29 @@ def _topic_profile_query( "size": 10, }, }, + # topic treemap + "by_field": { + "terms": { + "field": "primary_topic.field.display_name.keyword", + "size": 30, + }, + "aggs": { + "by_subfield": { + "terms": { + "field": "primary_topic.subfield.display_name.keyword", + "size": 30, + }, + "aggs": { + "by_topic": { + "terms": { + "field": "primary_topic.display_name.keyword", + "size": 30, + }, + }, + }, + }, + }, + }, "distinct_topics": { "cardinality": {"field": "primary_topic.id"}, }, @@ -555,6 +581,27 @@ async def topic_profile_for_authors( ) for bucket in to_work.get("by_subfield", {}).get("buckets", []) ] + field_tree = [ + FieldNode( + name=field_bucket.get("key", ""), + count=field_bucket.get("doc_count", 0), + subfields=[ + SubfieldNode( + name=subfield_bucket.get("key", ""), + count=subfield_bucket.get("doc_count", 0), + topics=[ + TopicNode( + name=topic_bucket.get("key", ""), + count=topic_bucket.get("doc_count", 0), + ) + for topic_bucket in subfield_bucket.get("by_topic", {}).get("buckets", []) + ], + ) + for subfield_bucket in field_bucket.get("by_subfield", {}).get("buckets", []) + ], + ) + for field_bucket in to_work.get("by_field", {}).get("buckets", []) + ] results.append( AuthorTopicProfile( author_id=author_bucket.get("key", ""), @@ -566,6 +613,7 @@ async def topic_profile_for_authors( distinct_subfields=to_work.get("distinct_subfields", {}).get("value", 0), distinct_fields=to_work.get("distinct_fields", {}).get("value", 0), subfields=subfields, + field_tree=field_tree, ) ) diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index 1321102f..ff8e6b1d 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -288,6 +288,29 @@ class SubfieldShare(BaseModel): count: int = Field(description="Number of works whose primary topic belongs to this subfield.") +class TopicNode(BaseModel): + name: str = Field(description="The primary-topic display name.") + count: int = Field(description="Number of works whose primary topic is this topic.") + + +class SubfieldNode(BaseModel): + name: str = Field(description="The subfield display name.") + count: int = Field(description="Number of works whose primary topic belongs to this subfield.") + topics: List[TopicNode] = Field( + default_factory=list, + description="Primary topics within this subfield, largest first.", + ) + + +class FieldNode(BaseModel): + name: str = Field(description="The field display name.") + count: int = Field(description="Number of works whose primary topic belongs to this field.") + subfields: List[SubfieldNode] = Field( + default_factory=list, + description="Subfields within this field, largest first.", + ) + + class AuthorTopicProfile(BaseModel): author_id: str = Field(description="The OpenAlex ID of the author.") display_name: str = Field(description="The name of the author.") @@ -314,6 +337,11 @@ class AuthorTopicProfile(BaseModel): default_factory=list, description="Top subfields over all works, by primary topic, largest first.", ) + field_tree: List[FieldNode] = Field( + default_factory=list, + description="Field -> subfield -> topic hierarchy over all works, by primary " + "topic, each level largest first. Drives the interactive topic treemap.", + ) class AuthorStaticStats(BaseModel): From 2bdee211694ddffacdb1d048ff4759630b7efeed Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Thu, 23 Jul 2026 13:41:10 +0200 Subject: [PATCH 02/27] remove devcontainer from git --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 50b40718..fb1f98b9 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ angular-app/.angular # Ignore sentence-transformer local model cache service/sentence_transformer/models/ -llm_evaluations/bio_generation/.venv \ No newline at end of file +llm_evaluations/bio_generation/.venv + +.devcontainer From eb84d3014fc78505cd652e59df71c3e12f0b4ba8 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Thu, 23 Jul 2026 13:56:21 +0200 Subject: [PATCH 03/27] update topic profile query and enhance data models with IDs --- service/src/main/inse/ranking/logic.py | 43 +++++++++++++++++++--- service/src/main/inse/ranking/model.py | 3 ++ service/src/main/inse/ranking/ranking.http | 10 +++++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/service/src/main/inse/ranking/logic.py b/service/src/main/inse/ranking/logic.py index 5ac80c00..c4997cb8 100644 --- a/service/src/main/inse/ranking/logic.py +++ b/service/src/main/inse/ranking/logic.py @@ -499,21 +499,41 @@ def _topic_profile_query( # topic treemap "by_field": { "terms": { - "field": "primary_topic.field.display_name.keyword", + "field": "primary_topic.field.id", "size": 30, }, "aggs": { + "field_name": { + "terms": { + "field": "primary_topic.field.display_name.keyword", + "size": 1, + }, + }, "by_subfield": { "terms": { - "field": "primary_topic.subfield.display_name.keyword", + "field": "primary_topic.subfield.id", "size": 30, }, "aggs": { + "subfield_name": { + "terms": { + "field": "primary_topic.subfield.display_name.keyword", + "size": 1, + }, + }, "by_topic": { "terms": { - "field": "primary_topic.display_name.keyword", + "field": "primary_topic.id", "size": 30, }, + "aggs": { + "topic_name": { + "terms": { + "field": "primary_topic.display_name.keyword", + "size": 1, + }, + }, + }, }, }, }, @@ -583,15 +603,18 @@ async def topic_profile_for_authors( ] field_tree = [ FieldNode( - name=field_bucket.get("key", ""), + id=field_bucket.get("key", ""), + name=_bucket_name(field_bucket, "field_name", field_bucket.get("key", "")), count=field_bucket.get("doc_count", 0), subfields=[ SubfieldNode( - name=subfield_bucket.get("key", ""), + id=subfield_bucket.get("key", ""), + name=_bucket_name(subfield_bucket, "subfield_name", subfield_bucket.get("key", "")), count=subfield_bucket.get("doc_count", 0), topics=[ TopicNode( - name=topic_bucket.get("key", ""), + id=topic_bucket.get("key", ""), + name=_bucket_name(topic_bucket, "topic_name", topic_bucket.get("key", "")), count=topic_bucket.get("doc_count", 0), ) for topic_bucket in subfield_bucket.get("by_topic", {}).get("buckets", []) @@ -779,6 +802,14 @@ def _display_name_from_bucket(author_bucket: dict) -> str: return "" +def _bucket_name(bucket: dict, name_agg_key: str, fallback: str) -> str: + """Reads a display name out of a bucket's name sub-aggregation, falling back to its id.""" + name_buckets = bucket.get(name_agg_key, {}).get("buckets", []) + if name_buckets and name_buckets[0].get("key"): + return str(name_buckets[0]["key"]) + return fallback + + def _citations_from_bucket(author_bucket: dict) -> int: """Reads the summed citations out of the reverse_nested sub-aggregation.""" citations_value = ( diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index ff8e6b1d..8fce11ef 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -289,11 +289,13 @@ class SubfieldShare(BaseModel): class TopicNode(BaseModel): + id: str = Field(description="The OpenAlex ID of the primary topic.") name: str = Field(description="The primary-topic display name.") count: int = Field(description="Number of works whose primary topic is this topic.") class SubfieldNode(BaseModel): + id: str = Field(description="The OpenAlex ID of the subfield.") name: str = Field(description="The subfield display name.") count: int = Field(description="Number of works whose primary topic belongs to this subfield.") topics: List[TopicNode] = Field( @@ -303,6 +305,7 @@ class SubfieldNode(BaseModel): class FieldNode(BaseModel): + id: str = Field(description="The OpenAlex ID of the field.") name: str = Field(description="The field display name.") count: int = Field(description="Number of works whose primary topic belongs to this field.") subfields: List[SubfieldNode] = Field( diff --git a/service/src/main/inse/ranking/ranking.http b/service/src/main/inse/ranking/ranking.http index 6fd0c062..d7e49ec3 100644 --- a/service/src/main/inse/ranking/ranking.http +++ b/service/src/main/inse/ranking/ranking.http @@ -116,6 +116,16 @@ Content-Type: application/json "timespan": { "from": 2018, "to": 2025 } } +### +POST http://localhost:8000/api/rank/topic-profile +Content-Type: application/json + +{ + "author_ids": ["https://openalex.org/A504035360", "https://openalex.org/A5019137844"], + "keywords": ["Augmented Reality Applications"], + "operator": "or" +} + ### GET https://project.nes.uni-due.de/elastic/_aliases Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ== From 97b7fe6a6fd0e06c4dd849ec11a5fa58136a6899 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Thu, 23 Jul 2026 14:03:21 +0200 Subject: [PATCH 04/27] add topic treemap component and integrate into author comparison view --- .../src/app/api/model/authorTopicProfile.ts | 67 +++++++ .../compare-authors.component.html | 32 ++++ .../compare-authors.component.scss | 36 ++++ .../compare-authors.component.ts | 62 +++++- .../topic-treemap.component.html | 11 ++ .../topic-treemap.component.scss | 11 ++ .../topic-treemap/topic-treemap.component.ts | 177 ++++++++++++++++++ 7 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.html create mode 100644 webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.scss create mode 100644 webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.ts diff --git a/webapp/src/app/api/model/authorTopicProfile.ts b/webapp/src/app/api/model/authorTopicProfile.ts index 00d5593a..79dd0621 100644 --- a/webapp/src/app/api/model/authorTopicProfile.ts +++ b/webapp/src/app/api/model/authorTopicProfile.ts @@ -22,6 +22,68 @@ export interface SubfieldShare { count: number; } +/** + * A primary topic within a subfield. + */ +export interface TopicNode { + /** + * The OpenAlex ID of the primary topic. + */ + id: string; + /** + * The primary-topic display name. + */ + name: string; + /** + * Number of works whose primary topic is this topic. + */ + count: number; +} + +/** + * A subfield within a field, with its primary topics. + */ +export interface SubfieldNode { + /** + * The OpenAlex ID of the subfield. + */ + id: string; + /** + * The subfield display name. + */ + name: string; + /** + * Number of works whose primary topic belongs to this subfield. + */ + count: number; + /** + * Primary topics within this subfield, largest first. + */ + topics: Array; +} + +/** + * A field with its subfields, top of the primary-topic hierarchy. + */ +export interface FieldNode { + /** + * The OpenAlex ID of the field. + */ + id: string; + /** + * The field display name. + */ + name: string; + /** + * Number of works whose primary topic belongs to this field. + */ + count: number; + /** + * Subfields within this field, largest first. + */ + subfields: Array; +} + /** * Section 3: how an author\'s complete body of work distributes over topics. All counts are based on each work\'s primary topic. */ @@ -62,4 +124,9 @@ export interface AuthorTopicProfile { * Top subfields over all works, by primary topic, largest first. */ subfields: Array; + /** + * Field -> subfield -> topic hierarchy over all works, by primary topic, + * each level largest first. Drives the interactive topic treemap. + */ + field_tree: Array; } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index eac43fd0..6dad5c9d 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -93,6 +93,38 @@
+ +

Themenlandschaft

+

Field → Subfield → Thema

+
+ @for ( + author of orderedProfiles(); + track author.author_id; + let i = $index + ) { + + } +
+ } @else {

Keine Daten für das Themenprofil.

} diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index f05c3335..6e1ac55d 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -262,6 +262,42 @@ height: 320px; } +.treemap-author-tabs { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin: 4px 0 10px; +} + +.treemap-author-tab { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 5px 12px; + border: 1px solid var(--sg-border, #d7deee); + border-radius: 999px; + background: var(--sg-surface, #fff); + color: var(--sg-text-muted, #64708f); + font-size: 12px; + font-weight: 600; + cursor: pointer; + transition: + background 0.15s ease, + border-color 0.15s ease, + color 0.15s ease; + + &:hover { + border-color: var(--sg-primary, #2563eb); + color: var(--sg-text, #101a3d); + } + + &.active { + border-color: var(--sg-primary, #2563eb); + background: color-mix(in srgb, var(--sg-primary, #2563eb) 10%, #fff); + color: var(--sg-text, #101a3d); + } +} + .chart-grid { display: grid; grid-template-columns: 1fr 1fr; diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index 299c1f47..24729c8b 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -12,6 +12,11 @@ import { RankingService, } from '../../api'; +import { + TopicTreemapComponent, + TreemapNode, +} from '../../shared/ui/topic-treemap/topic-treemap.component'; + const AUTHOR_COLORS = ['#1565c0', '#e6550d', '#2ca02c', '#9467bd']; const SUBFIELD_COLORS = [ '#2563eb', @@ -108,7 +113,13 @@ interface SegmentDef { @Component({ selector: 'app-compare-authors', standalone: true, - imports: [DecimalPipe, NgTemplateOutlet, MatIconModule, NgxEchartsDirective], + imports: [ + DecimalPipe, + NgTemplateOutlet, + MatIconModule, + NgxEchartsDirective, + TopicTreemapComponent, + ], templateUrl: './compare-authors.component.html', styleUrl: './compare-authors.component.scss', }) @@ -569,6 +580,55 @@ export class CompareAuthorsComponent implements OnInit { } as EChartsOption; }); + readonly selectedTreemapAuthor = signal(0); + + readonly treemapProfile = computed(() => { + const profiles = this.orderedProfiles(); + if (profiles.length === 0) return null; + const index = Math.min(this.selectedTreemapAuthor(), profiles.length - 1); + return profiles[index]; + }); + + selectTreemapAuthor(index: number): void { + this.selectedTreemapAuthor.set(index); + } + + authorColor(authorId: string): string { + return ( + this.summary().find((a) => a.authorId === authorId)?.color ?? OTHER_COLOR + ); + } + + readonly treemapNodes = computed(() => { + const profile = this.treemapProfile(); + if (!profile) return []; + + return profile.field_tree.map((field) => ({ + id: field.id, + name: field.name, + value: field.count, + children: field.subfields.map((subfield) => ({ + id: subfield.id, + name: subfield.name, + value: subfield.count, + children: subfield.topics.map((topic) => ({ + id: topic.id, + name: topic.name, + value: topic.count, + })), + })), + })); + }); + + readonly treemapTooltip = (params: any): string => { + const path = (params.treePathInfo ?? []) + .slice(1) + .map((p: any) => p.name) + .join(' › '); + const count = Number(params.value ?? 0).toLocaleString('de-DE'); + return `${path || params.name}
${count} Werke`; + }; + // turns row definitions into table rows, marking the best value per row private buildRows(defs: RowDef[]): MetricRow[] { const authors = this.summary(); diff --git a/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.html b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.html new file mode 100644 index 00000000..7d06aaac --- /dev/null +++ b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.html @@ -0,0 +1,11 @@ +@if (nodes.length) { +
+} @else { +

+ {{ loading ? loadingText : emptyText }} +

+} diff --git a/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.scss b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.scss new file mode 100644 index 00000000..90374d18 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.scss @@ -0,0 +1,11 @@ +.topic-treemap-chart { + width: 100%; +} + +.topic-treemap-empty { + display: grid; + min-height: 260px; + margin: 0; + place-items: center; + color: #64748b; +} diff --git a/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.ts b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.ts new file mode 100644 index 00000000..c9fcc7a7 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-treemap/topic-treemap.component.ts @@ -0,0 +1,177 @@ +import { Component, Input, OnChanges } from '@angular/core'; +import { EChartsOption } from 'echarts'; +import { NgxEchartsDirective } from 'ngx-echarts'; + +/** One node of the treemap hierarchy. `children` nests the next level. */ +export interface TreemapNode { + name: string; + value: number; + /** Optional stable id used when colouring by id. */ + id?: string; + children?: TreemapNode[]; + /** Extra payload made available to a custom tooltip formatter. */ + [key: string]: unknown; +} + +const DEFAULT_COLORS = [ + '#2563eb', + '#059669', + '#d97706', + '#dc2626', + '#7c3aed', + '#0284c7', + '#ea580c', + '#4f46e5', + '#0f766e', + '#be123c', +]; + +@Component({ + selector: 'app-topic-treemap', + imports: [NgxEchartsDirective], + templateUrl: './topic-treemap.component.html', + styleUrl: './topic-treemap.component.scss', +}) +export class TopicTreemapComponent implements OnChanges { + @Input() nodes: TreemapNode[] = []; + @Input() loading = false; + @Input() seriesName = ''; + @Input() emptyText = 'Keine Daten vorhanden.'; + @Input() loadingText = 'Wird geladen ...'; + /** CSS height of the chart area. */ + @Input() height = '560px'; + /** Colour buckets by node id or by node name. */ + @Input() colorMappingBy: 'id' | 'name' = 'name'; + /** Override the default tooltip; receives the raw ECharts params. */ + @Input() tooltipFormatter?: (params: any) => string; + + options: EChartsOption = {}; + private readonly colors = DEFAULT_COLORS; + + ngOnChanges(): void { + this.options = this.buildOptions(); + } + + private buildOptions(): EChartsOption { + const options = { + tooltip: { + formatter: this.tooltipFormatter ?? this.defaultTooltip(), + }, + series: [ + { + name: this.seriesName, + type: 'treemap', + data: this.nodes, + roam: false, + nodeClick: 'zoomToNode', + sort: 'desc', + drillDownIcon: '', + leafDepth: 1, + color: this.colors, + colorMappingBy: this.colorMappingBy, + breadcrumb: { + show: true, + bottom: 0, + height: 24, + left: 8, + right: 8, + emptyItemWidth: 80, + itemStyle: { + color: '#f8fafc', + borderColor: '#cbd5e1', + borderWidth: 1, + textStyle: { color: '#334155', fontWeight: 600 }, + }, + emphasis: { + itemStyle: { + color: '#e0f2fe', + borderColor: '#93c5fd', + textStyle: { color: '#0f172a', fontWeight: 700 }, + }, + }, + }, + label: { + show: true, + formatter: (params: any) => + `${params.name}\n${this.formatCount(params.value)}`, + color: '#ffffff', + fontWeight: 600, + lineHeight: 18, + position: 'inside', + align: 'center', + verticalAlign: 'middle', + overflow: 'truncate', + }, + upperLabel: { + show: true, + formatter: (params: any) => + `${params.name} · ${this.formatCount(params.value)}`, + height: 30, + color: '#ffffff', + fontWeight: 700, + overflow: 'truncate', + }, + levels: [ + { + color: this.colors, + upperLabel: { show: false }, + itemStyle: { + borderColor: '#ffffff', + borderWidth: 3, + gapWidth: 3, + }, + }, + { + colorSaturation: [0.35, 0.7], + upperLabel: { show: false }, + itemStyle: { + borderColor: '#ffffff', + borderWidth: 2, + gapWidth: 2, + }, + }, + { + colorSaturation: [0.45, 0.78], + upperLabel: { show: false }, + itemStyle: { + borderColor: '#ffffff', + borderWidth: 2, + gapWidth: 2, + }, + }, + ], + top: 8, + right: 8, + bottom: 32, + left: 8, + animationDurationUpdate: 450, + emphasis: { focus: 'self', label: { color: '#ffffff' } }, + itemStyle: { + borderRadius: 4, + borderColor: '#ffffff', + borderWidth: 3, + gapWidth: 3, + }, + }, + ], + }; + + return options as EChartsOption; + } + + private defaultTooltip(): (params: any) => string { + return (params: any) => { + const path = (params.treePathInfo ?? []) + .slice(1) + .map((p: any) => p.name) + .join(' › '); + return `${path || params.name}
${this.formatCount( + params.value, + )}`; + }; + } + + private formatCount(value: unknown): string { + return Number(value ?? 0).toLocaleString('de-DE'); + } +} From 2a5f10473946c67633705c81802e8d7ebddd0d1b Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 09:22:01 +0200 Subject: [PATCH 05/27] enhance filter layout and integrate component year range slider --- .../persons-results.component.html | 84 +++++++------------ .../persons-results.component.scss | 50 ++++++----- .../persons-results.component.ts | 4 +- 3 files changed, 58 insertions(+), 80 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html index ec2355cd..ae13af47 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html @@ -72,29 +72,22 @@ -
+
+ class="filter-field" + subscriptSizing="dynamic"> + article Art der Work -
- + + link Keyword-Verknüpfung -
-
- + + trending_up Karrierestufe -
-
- + + business Unternehmen -
-
-
- date_range - Zeitraum -
- -
-
- {{ timespanFrom() }} – {{ timespanTo() }} -
- - - - -
+
diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss index 336c8680..5737934b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.scss @@ -122,37 +122,43 @@ } } -/* divider between filter rows — not before the first one */ -::ng-deep .filter-section .filter-row + .filter-row { - margin-top: 0.5rem; - padding-top: 0.5rem; - border-top: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.08)); -} - -::ng-deep .company-filter-row { - font-size: 0.8rem; -} - -/* ============================================================ - TIMESPAN - ============================================================ */ -::ng-deep .timespan-range-label { - justify-content: center !important; - font-weight: 500; - color: var(--sg-text-primary) !important; -} - -::ng-deep .timespan-slider { +.filter-fields { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; + align-items: flex-start; width: 100%; - margin: 0; +} + +.filter-field { + flex: 1 1 220px; + min-width: 200px; + + mat-icon[matPrefix] { + margin-right: 0.4rem; + color: var(--sg-text-secondary, rgba(0, 0, 0, 0.54)); + } +} + +.filter-field-year { + flex: 1 1 100%; } ::ng-deep .pub-type-search { display: flex; align-items: center; + gap: 0.4rem; position: sticky; top: 0; z-index: 10; background: white; + padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12)); + + input { + flex: 1; + border: none; + outline: none; + padding: 0.4rem 0; + } } diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index e0bea4d1..c1b810b2 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -7,7 +7,6 @@ import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatIconModule } from '@angular/material/icon'; -import { MatSliderModule } from '@angular/material/slider'; import { MatSnackBar } from '@angular/material/snack-bar'; import { FormsModule } from '@angular/forms'; import { MatSelectModule } from '@angular/material/select'; @@ -21,6 +20,7 @@ import { WeightsSlidersValue, } from '../../../../shared/ui/weights-sliders/weights-sliders.component'; import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component'; +import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component'; import { KeywordToAuthorRequest, @@ -40,13 +40,13 @@ import { SearchResultsStateService } from '../search-results-state.service'; MatCardModule, MatCheckboxModule, MatIconModule, - MatSliderModule, FormsModule, MatSelectModule, MatInputModule, MatFormFieldModule, QueryParamPaginatorComponent, WeightsSlidersComponent, + YearRangeSliderComponent, ], templateUrl: './persons-results.component.html', styleUrl: './persons-results.component.scss', From de709732960dd5125aab718301ebb6d033184dd6 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 09:39:43 +0200 Subject: [PATCH 06/27] enhance metadata display and integrate chip component --- .../compare-authors.component.html | 52 +++++++++++-------- .../compare-authors.component.scss | 51 ++++++++---------- .../compare-authors.component.ts | 7 +++ 3 files changed, 61 insertions(+), 49 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 6dad5c9d..de385536 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -4,31 +4,41 @@
@if (keywords().length > 0) { - - topic - {{ keywords().join(', ') }} - +
+ Betrachtete Topics: +
+ @for (keyword of keywords(); track keyword) { + + topic + {{ keyword }} + + } +
+ Verknüpfungsoperator: {{ operatorLabel() }} +
} @if (timespan(); as span) { - - date_range - {{ span.from }}–{{ span.to }} - +
+ Betrachteter Zeitraum: + + date_range + {{ span.from }}–{{ span.to }} + +
+ } + @if (hasData()) { +
+ Betrachtete Personen: +
+ @for (author of summary(); track author.authorId) { + {{ author.name }} + } +
+
}
- - @if (hasData()) { -
    - @for (author of summary(); track author.authorId) { -
  • - - {{ author.name }} -
  • - } -
- } @if (loading()) { diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index 6e1ac55d..a4deedf6 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -24,45 +24,40 @@ .compare-meta { display: flex; + flex-direction: column; + gap: 8px; +} + +.meta-row { + display: flex; + align-items: center; flex-wrap: wrap; gap: 8px; } -.meta-chip { - display: inline-flex; - align-items: center; - gap: 6px; - padding: 4px 12px; - border-radius: 999px; - background: var(--sg-surface-muted, #f7f9ff); - border: 1px solid var(--sg-border, #dde5f2); - color: var(--sg-text-muted, #64708f); +.meta-label { font-size: 13px; - - mat-icon { - font-size: 16px; - width: 16px; - height: 16px; - color: var(--sg-text-soft, #8a95b3); - } + font-weight: 600; + color: var(--sg-text-muted, #64708f); } -.author-legend { - list-style: none; - margin: 0; - padding: 0; +.meta-operator { + font-size: 13px; + font-weight: 600; + color: var(--sg-text-muted, #64708f); +} + +.meta-chip-group { display: flex; flex-wrap: wrap; - gap: 8px 18px; + gap: 8px; } -.legend-item { - display: inline-flex; - align-items: center; - gap: 8px; - font-size: 14px; - font-weight: 600; - color: var(--sg-text, #101a3d); +app-chip mat-icon { + font-size: 16px; + width: 16px; + height: 16px; + vertical-align: text-bottom; } .legend-swatch { diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index 24729c8b..8600afb4 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -16,6 +16,7 @@ import { TopicTreemapComponent, TreemapNode, } from '../../shared/ui/topic-treemap/topic-treemap.component'; +import { ChipComponent } from '../../shared/ui/chip/chip.component'; const AUTHOR_COLORS = ['#1565c0', '#e6550d', '#2ca02c', '#9467bd']; const SUBFIELD_COLORS = [ @@ -119,6 +120,7 @@ interface SegmentDef { MatIconModule, NgxEchartsDirective, TopicTreemapComponent, + ChipComponent, ], templateUrl: './compare-authors.component.html', styleUrl: './compare-authors.component.scss', @@ -128,6 +130,10 @@ export class CompareAuthorsComponent implements OnInit { private readonly rankingService = inject(RankingService); readonly keywords = signal([]); + readonly operator = signal<'and' | 'or'>('or'); + readonly operatorLabel = computed(() => + this.operator() === 'and' ? 'UND' : 'ODER', + ); readonly timespan = signal<{ from: number; to: number } | null>(null); // full OpenAlex ids in the requested order — the source of truth for colour + order readonly authorIds = signal([]); @@ -692,6 +698,7 @@ export class CompareAuthorsComponent implements OnInit { } const operator = rawOperator === 'and' ? 'and' : 'or'; + this.operator.set(operator); const publication_types = rawPubType ? this.parseList(rawPubType) : undefined; From 6d5dd88e50acb8c64206a85c66043a45242d6aed Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:04:59 +0200 Subject: [PATCH 07/27] update German labels and hints for clarity in author comparison table 1 --- .../compare-authors.component.html | 13 +- .../compare-authors.component.ts | 152 ++++++++---------- 2 files changed, 76 insertions(+), 89 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index de385536..8ba1fe87 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -5,7 +5,7 @@
@if (keywords().length > 0) {
- Betrachtete Topics: + Betrachtete Themen:
@for (keyword of keywords(); track keyword) { @@ -48,10 +48,13 @@ } @else {
-

Kennzahlen zu den Keywords

+

+ Kennzahlen der Publikationen zu den ausgewählten Themen +

- Bester Wert je Zeile ist hervorgehoben. „–“ bedeutet, dass der Wert für - diese:n Autor:in nicht vorliegt. + Berücksichtigt werden ausschließlich Publikationen zu den ausgewählten + Themen im betrachteten Zeitraum. Bester Wert je Zeile ist hervorgehoben. + „–" bedeutet, dass der Wert für diese:n Autor:in nicht vorliegt.

Themenprofil

-

"Topic-Analyse"

+

"Themen-Analyse"

@if (profileLoading()) {

Lädt…

diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index 8600afb4..fd786d47 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -198,22 +198,22 @@ export class CompareAuthorsComponent implements OnInit { readonly topicRows = computed(() => [ ...this.buildRows([ { - label: 'Werke gesamt', - hint: 'Publikationen zum Thema im Zeitraum', + label: 'Publikationen', + hint: 'Gesamtanzahl der Publikationen', select: (a) => a.totalWorks, }, { - label: 'Corresponding-Author-Werke', - hint: 'Werke, in denen die Person korrespondierende:r Autor:in ist', + label: 'Corresponding-Author', + hint: 'Gesamtanzahl der Publikationen, in denen die Person korrespondierende:r Autor:in ist', select: (a) => a.corresponding, }, ]), this.buildGroupRow( 'Zitationen', - 'Zitationen der Themen-Werke: gesamt | Ø pro Werk', + 'Wie oft die Publikationen zitiert wurden', [ { - label: 'gesamt', + label: 'Gesamt', colorClass: 'cit-total', select: (a) => a.citationsTotal, }, @@ -228,85 +228,73 @@ export class CompareAuthorsComponent implements OnInit { ...this.buildRows([ { label: 'Ø Impact-Perzentil', - hint: 'Feld-normalisiertes Zitations-Perzentil (0–1)', + hint: 'Feld-normalisierte Zitationswirkung (0–1)', select: (a) => a.avgPercentile, decimals: true, }, { label: 'h-Index', - hint: 'h-Index über die Werke zum Thema', + hint: 'Berechnet über alle Publikationen', select: (a) => a.hIndex, }, { - label: 'Meistzitiertes Werk', - hint: 'Zitationen des meistzitierten Werks zum Thema', + label: 'Meistzitierte Publikation', + hint: 'Zitationen der Publikation mit den meisten Zitationen', select: (a) => a.maxCitations, }, { - label: 'Top-10%-Werke', - hint: 'Werke unter den 10% meistzitierten', + label: 'Top-10%-Publikationen', + hint: ' Anzahl unter den 10% meistzitierten', select: (a) => a.top10, }, { - label: 'Top-1%-Werke', - hint: 'Werke unter den 1% meistzitierten', + label: 'Top-1%-Publikationen', + hint: ' Anzahl unter den 1% meistzitierten', select: (a) => a.top1, }, ]), - this.buildGroupRow( - 'FWCI', - 'Field-Weighted Citation Impact: Werke über Feld-Durchschnitt | Ø über alle', - [ - { - label: '> 1', - colorClass: 'fwci-count', - select: (a) => a.fwciAboveOne, - }, - { - label: 'Ø', - colorClass: 'fwci-avg', - decimals: true, - select: (a) => a.avgFwci, - }, - ], - ), - this.buildGroupRow( - 'Themen-Relevanz', - 'Match-Score der Keywords: Werke > 80% | Ø über alle', - [ - { - label: '> 80%', - colorClass: 'rel-count', - select: (a) => a.relevanceAbove80, - }, - { - label: 'Ø', - colorClass: 'rel-avg', - decimals: true, - select: (a) => a.avgRelevance, - }, - ], - ), - this.buildGroupRow( - 'Autor-Position', - 'Werke nach Position (Erst | Mittel | Letzt)', - [ - { - label: 'Erst', - colorClass: 'pos-first', - select: (a) => a.firstAuthor, - }, - { - label: 'Mittel', - colorClass: 'pos-middle', - select: (a) => a.middleAuthor, - }, - { label: 'Letzt', colorClass: 'pos-last', select: (a) => a.lastAuthor }, - ], - ), + this.buildGroupRow('FWCI', ' Field-Weighted Citation Impact', [ + { + label: '> 1', + colorClass: 'fwci-count', + select: (a) => a.fwciAboveOne, + }, + { + label: 'Ø', + colorClass: 'fwci-avg', + decimals: true, + select: (a) => a.avgFwci, + }, + ]), + this.buildGroupRow('Themen-Relevanz', 'Topic-Match-Score (0–1)', [ + { + label: '> 80%', + colorClass: 'rel-count', + select: (a) => a.relevanceAbove80, + }, + { + label: 'Ø', + colorClass: 'rel-avg', + decimals: true, + select: (a) => a.avgRelevance, + }, + ]), + this.buildGroupRow('Autor-Position', 'Nach Platz in der Autorenliste', [ + { + label: 'Erst', + colorClass: 'pos-first', + select: (a) => a.firstAuthor, + }, + { + label: 'Mittel', + colorClass: 'pos-middle', + select: (a) => a.middleAuthor, + }, + { label: 'Letzt', colorClass: 'pos-last', select: (a) => a.lastAuthor }, + ]), this.buildGroupRow( 'Industrie-Kollaboration', - 'Werke mit Co-Autor:in aus einem Unternehmen: Anzahl | Anteil', + 'Publikationen mit Co-Autor:in aus einem Unternehmen', [ { label: 'Anzahl', @@ -321,24 +309,20 @@ export class CompareAuthorsComponent implements OnInit { }, ], ), - this.buildGroupRow( - 'Aktiv im Thema', - 'Erstes und letztes Publikationsjahr zum Thema', - [ - { - label: 'von', - colorClass: 'year-from', - plain: true, - select: (a) => a.firstYear, - }, - { - label: 'bis', - colorClass: 'year-to', - plain: true, - select: (a) => a.lastYear, - }, - ], - ), + this.buildGroupRow('Aktiv im Thema', 'Publikationszeitraum', [ + { + label: 'von', + colorClass: 'year-from', + plain: true, + select: (a) => a.firstYear, + }, + { + label: 'bis', + colorClass: 'year-to', + plain: true, + select: (a) => a.lastYear, + }, + ]), ]); // section 2 table: author-level stats, independent of the keywords From d19003d53144e94f4031b001465c46fbd06af5a3 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:12:09 +0200 Subject: [PATCH 08/27] update table 2 --- .../modules/compare-authors/compare-authors.component.html | 4 +++- .../app/modules/compare-authors/compare-authors.component.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 8ba1fe87..a8e95b32 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -64,7 +64,9 @@

Kennzahlen zur Person

-

Unabhängig von den Keywords und Zeitraum.

+

+ Unabhängig von den ausgewählten Themen und vom Zeitraum. +

diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index fd786d47..4a5a6872 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -335,12 +335,12 @@ export class CompareAuthorsComponent implements OnInit { }, { label: 'News-Artikel', - hint: 'Nachrichtenartikel, die die Person namentlich nennen', + hint: ' Beiträge, die die Person namentlich nennen', select: (a) => a.news, }, { label: 'Patente', - hint: 'Der Person zugeordnete Patente', + hint: ' Der Person zugeordnet', select: (a) => a.patents, }, ]), From e51d3095bcef216989f8a8646b37197afe396f0e Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:23:50 +0200 Subject: [PATCH 09/27] update table 3 --- .../compare-authors.component.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index a8e95b32..4170471a 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -75,15 +75,17 @@

Themenprofil

-

"Themen-Analyse"

+

+ Verteilung und Breite der Themen über alle Publikationen +

@if (profileLoading()) {

Lädt…

} @else if (orderedProfiles().length > 0) {

Themenverteilung nach Subfield

- Von allen Arbeiten der Autor:innen im Zeitraum: der Anteil je - Subfield, bestimmt über das Primärthema jeder Arbeit. (Top 5) + Anteil je Subfield an allen Publikationen im Zeitraum, bestimmt über + das Primärthema. (Top 5)

Themen-Fokus

- Anzahl der Werke zum Suchthema im Verhältnis zum Gesamtwerk – und - wie viele davon das Suchthema als Primärthema tragen. + Publikationen zum Suchthema im Verhältnis zu allen Publikationen – + und wie viele es als Primärthema tragen

Themenbreite

- Einzigartige Primärthemen, Subfields und Fields im Gesamtwerk - (Primary Topic) + Einzigartige Primärthemen, Subfields und Fields über alle + Publikationen (Primärthema)

From ff3ac03520d4448c8643811e0a48f2ae0182d40a Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:27:40 +0200 Subject: [PATCH 10/27] replace author name display with app-chip component --- .../compare-authors/compare-authors.component.html | 7 +------ .../compare-authors/compare-authors.component.scss | 8 -------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 4170471a..665a7a60 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -157,12 +157,7 @@ Kennzahl @for (author of summary(); track author.authorId) { - - - {{ author.name }} - + {{ author.name }} } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index a4deedf6..3182ce8d 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -117,14 +117,6 @@ app-chip mat-icon { text-align: right; } - .th-name { - display: inline-flex; - align-items: center; - gap: 8px; - font-weight: 700; - color: var(--sg-text, #101a3d); - } - tbody tr + tr th, tbody tr + tr td { border-top: 1px solid var(--sg-border, #dde5f2); From 8b1f7d6eb304864dada232b6288b66beadfd4e2e Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:29:56 +0200 Subject: [PATCH 11/27] center align author and value cells in comparison table --- .../modules/compare-authors/compare-authors.component.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index 3182ce8d..2f0555d9 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -114,7 +114,7 @@ app-chip mat-icon { } .author-col { - text-align: right; + text-align: center; } tbody tr + tr th, @@ -147,7 +147,7 @@ app-chip mat-icon { } .value-cell { - text-align: right; + text-align: center; font-variant-numeric: tabular-nums; color: var(--sg-text, #101a3d); white-space: nowrap; From a7548d59c0111763c24d3ac4be2bf59c4f4d0b9c Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 10:32:52 +0200 Subject: [PATCH 12/27] center align table header cells in comparison table --- .../modules/compare-authors/compare-authors.component.scss | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index 2f0555d9..231cf8b9 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -107,16 +107,12 @@ app-chip mat-icon { font-size: 14px; thead th { - text-align: left; + text-align: center; padding: 0 16px 10px; border-bottom: 2px solid var(--sg-border, #dde5f2); vertical-align: bottom; } - .author-col { - text-align: center; - } - tbody tr + tr th, tbody tr + tr td { border-top: 1px solid var(--sg-border, #dde5f2); From 6edca93c1c7601039ae833137333d8b2dad12595 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 11:04:13 +0200 Subject: [PATCH 13/27] replace app-chip with app-topic-chip for keyword display and implement keyword color resolution --- .../compare-authors.component.html | 7 ++- .../compare-authors.component.ts | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 665a7a60..c6b4b6a2 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -8,10 +8,9 @@ Betrachtete Themen:
@for (keyword of keywords(); track keyword) { - - topic - {{ keyword }} - + }
([]); readonly operator = signal<'and' | 'or'>('or'); readonly operatorLabel = computed(() => this.operator() === 'and' ? 'UND' : 'ODER', ); + + // resolved OpenAlex topic (field/domain) per keyword for colour matching + private readonly keywordTopics = signal>({}); + + keywordColor(keyword: string): string { + const topic = this.keywordTopics()[this.normalizeKeyword(keyword)]; + return topicHierarchyColor( + topic + ? { + id: topic.id, + name: topic.display_name, + field_id: topic.field?.id, + field_name: topic.field?.display_name, + domain_id: topic.domain?.id, + domain_name: topic.domain?.display_name, + } + : { name: keyword }, + ); + } + + private normalizeKeyword(keyword: string): string { + return keyword.trim().toLowerCase(); + } + readonly timespan = signal<{ from: number; to: number } | null>(null); // full OpenAlex ids in the requested order — the source of truth for colour + order readonly authorIds = signal([]); @@ -676,6 +706,7 @@ export class CompareAuthorsComponent implements OnInit { const authorIds = this.parseList(rawAuthors); const keywords = this.parseList(rawKeywords); this.keywords.set(keywords); + this.resolveKeywordColors(keywords); if (authorIds.length === 0 || keywords.length === 0) { return; @@ -743,6 +774,25 @@ export class CompareAuthorsComponent implements OnInit { }); } + private resolveKeywordColors(keywords: string[]): void { + if (keywords.length === 0) return; + + this.topicsService.vectorSearchTopicsBatch({ keywords }).subscribe({ + next: ({ results }) => { + const topics: Record = {}; + for (const result of results) { + if (result.topic) { + topics[this.normalizeKeyword(result.keyword)] = result.topic; + } + } + this.keywordTopics.set(topics); + }, + error: (error) => { + console.error('Error resolving keyword topics:', error); + }, + }); + } + private parseList(raw: string): string[] { return raw .split(',') From 103b6180d0e82060112f04bbec0cf4b6b72582eb Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Fri, 24 Jul 2026 11:17:14 +0200 Subject: [PATCH 14/27] table 3: replace legend with app-chip component for author display --- .../compare-authors.component.html | 8 ++--- .../compare-authors.component.scss | 34 ++++++------------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index c6b4b6a2..900261d7 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -126,11 +126,11 @@ [attr.aria-selected]=" treemapProfile()?.author_id === author.author_id " + [style.--tab-color]="authorColor(author.author_id)" (click)="selectTreemapAuthor(i)"> - - {{ author.display_name }} + + {{ author.display_name }} + }
diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index 231cf8b9..f57ba1c1 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -60,13 +60,6 @@ app-chip mat-icon { vertical-align: text-bottom; } -.legend-swatch { - width: 12px; - height: 12px; - border-radius: 3px; - flex: 0 0 auto; -} - /* ---- cards ---- */ .card { background: #fff; @@ -254,30 +247,23 @@ app-chip mat-icon { .treemap-author-tab { display: inline-flex; - align-items: center; - gap: 6px; - padding: 5px 12px; - border: 1px solid var(--sg-border, #d7deee); - border-radius: 999px; - background: var(--sg-surface, #fff); - color: var(--sg-text-muted, #64708f); - font-size: 12px; - font-weight: 600; + border: 0; + padding: 0; + border-radius: 7px; + background: transparent; cursor: pointer; transition: - background 0.15s ease, - border-color 0.15s ease, - color 0.15s ease; + transform 0.15s ease, + box-shadow 0.15s ease; &:hover { - border-color: var(--sg-primary, #2563eb); - color: var(--sg-text, #101a3d); + transform: translateY(-1px); } &.active { - border-color: var(--sg-primary, #2563eb); - background: color-mix(in srgb, var(--sg-primary, #2563eb) 10%, #fff); - color: var(--sg-text, #101a3d); + box-shadow: + 0 0 0 2px #ffffff, + 0 0 0 4px var(--tab-color, var(--sg-primary, #2563eb)); } } From 0b6a74a8e399f171e387e8a59088addb79aabe9c Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Mon, 3 Aug 2026 20:23:51 +0200 Subject: [PATCH 15/27] fix: update type hints from List to built-in list for consistency --- service/src/main/inse/ranking/model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index f5955fc7..75522114 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -292,7 +292,7 @@ class SubfieldNode(BaseModel): id: str = Field(description="The OpenAlex ID of the subfield.") name: str = Field(description="The subfield display name.") count: int = Field(description="Number of works whose primary topic belongs to this subfield.") - topics: List[TopicNode] = Field( + topics: list[TopicNode] = Field( default_factory=list, description="Primary topics within this subfield, largest first.", ) @@ -302,7 +302,7 @@ class FieldNode(BaseModel): id: str = Field(description="The OpenAlex ID of the field.") name: str = Field(description="The field display name.") count: int = Field(description="Number of works whose primary topic belongs to this field.") - subfields: List[SubfieldNode] = Field( + subfields: list[SubfieldNode] = Field( default_factory=list, description="Subfields within this field, largest first.", ) @@ -334,7 +334,7 @@ class AuthorTopicProfile(BaseModel): default_factory=list, description="Top subfields over all works, by primary topic, largest first.", ) - field_tree: List[FieldNode] = Field( + field_tree: list[FieldNode] = Field( default_factory=list, description="Field -> subfield -> topic hierarchy over all works, by primary " "topic, each level largest first. Drives the interactive topic treemap.", From 5633b412d4a874c4d9ff3385e2b2330d0a34157d Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Thu, 13 Aug 2026 22:01:53 +0200 Subject: [PATCH 16/27] refactor(patents): extract shared app-patent-table component built on app-data-table, used by person/institution/keywords patent views --- .../institution-patents.component.html | 189 +----------------- .../institution-patents.component.scss | 128 ------------ .../institution-patents.component.ts | 82 ++------ .../keywords-patents.component.html | 141 +------------ .../keywords-patents.component.scss | 120 ----------- .../keywords-patents.component.ts | 79 +++----- .../patent-detail/patent-detail.utils.ts | 46 +++++ .../person-patents.component.html | 140 +------------ .../person-patents.component.scss | 121 ----------- .../person-patents.component.ts | 70 ++----- .../patent-table/patent-table.component.html | 125 ++++++++++++ .../patent-table/patent-table.component.scss | 149 ++++++++++++++ .../ui/patent-table/patent-table.component.ts | 169 ++++++++++++++++ 13 files changed, 580 insertions(+), 979 deletions(-) create mode 100644 webapp/src/app/shared/ui/patent-table/patent-table.component.html create mode 100644 webapp/src/app/shared/ui/patent-table/patent-table.component.scss create mode 100644 webapp/src/app/shared/ui/patent-table/patent-table.component.ts diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.html b/webapp/src/app/modules/institution-patents/institution-patents.component.html index fbb05df2..e6b144f0 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.html +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.html @@ -57,193 +57,20 @@ [value]="sortColumn" (selectionChange)="setSort($event.value)"> Sortieren nach - Jahr + Jahr Titel Quelle - Match-Typ + Match-Typ
- - - - - - - - - - - - - - @for ( - patent of getPagedPatents(); - track trackPatent($index, patent) - ) { - - - - - - - - - - } - -
Patent - Quelle - @if (sortColumn === 'source') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Jahr - @if (sortColumn === 'year') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - ErfinderApplicant/Assignee - Match-Typ - @if (sortColumn === 'matchType') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - Personen
- {{ patent.title ?? patent.patent_id }} - - - {{ patent.source }} - - - @if (patent.publication_year) { - {{ - patent.publication_year - }} - } @else { - - - } - - @if (patent.inventors && patent.inventors.length) { -
- @for ( - inventor of patent.inventors.slice(0, 2); - track inventor - ) { - - person - {{ inventor }} - - } - @if (patent.inventors.length > 2) { - - - person - {{ patent.inventors[2] }} - - @if (patent.inventors.length > 3) { - +{{ patent.inventors.length - 3 }} - } - - } -
- } @else { - - - } -
- @if (patent.assignees && patent.assignees.length) { -
- @for ( - assignee of patent.assignees.slice(0, 2); - track assignee - ) { - - {{ - isAssigneeLikelyPerson(assignee, patent) - ? 'person' - : 'apartment' - }} - {{ assignee }} - - } - @if (patent.assignees.length > 2) { - - - {{ - isAssigneeLikelyPerson( - patent.assignees[2], - patent - ) - ? 'person' - : 'apartment' - }} - {{ patent.assignees[2] }} - - @if (patent.assignees.length > 3) { - +{{ patent.assignees.length - 3 }} - } - - } -
- } @else { - - - } -
- - {{ getMatchTypeLabel(patent) }} - - -
- @if ( - patent.matched_authors && patent.matched_authors.length - ) { - @for ( - author of patent.matched_authors.slice(0, 2); - track author.openalex_author_id - ) { - - {{ author.author_name }} - - } - } @else { - - - } -
-
+ { switch (this.sortColumn) { - case 'year': { + case 'publication_year': { const yearA = a.publication_date ?? String(a.publication_year ?? ''); const yearB = b.publication_date ?? String(b.publication_year ?? ''); return direction * yearA.localeCompare(yearB); } case 'source': return direction * a.source.localeCompare(b.source); - case 'matchType': + case 'match_type': return direction * a.match_type.localeCompare(b.match_type); default: return ( @@ -239,9 +252,9 @@ export class InstitutionPatentsComponent implements OnInit { private isValidSortColumn(value: string | null): value is SortColumn { return ( value === 'title' || - value === 'year' || + value === 'publication_year' || value === 'source' || - value === 'matchType' + value === 'match_type' ); } @@ -288,15 +301,6 @@ export class InstitutionPatentsComponent implements OnInit { return this.patents.filter((p) => p.match_type === 'both').length; } - trackPatent(_index: number, patent: OrgPatentEntry): string { - return [ - patent.source, - patent.patent_id, - patent.publication_date ?? '', - patent.kind ?? patent.application_type ?? '', - ].join('|'); - } - getAbstractPreview(abstract: string | null | undefined): string | null { if (!abstract?.trim()) { return null; @@ -324,50 +328,4 @@ export class InstitutionPatentsComponent implements OnInit { return patent.match_type; } } - - private static readonly ORG_SUFFIX_PATTERN = - /\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i; - private static readonly PERSON_SUFFIX_PATTERN = - /\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i; - - private normalizeNameForComparison(name: string): string { - return name - .normalize('NFD') - .replace(/[̀-ͯ]/g, '') - .replace(/[.,]/g, '') - .toUpperCase() - .split(/\s+/) - .filter(Boolean) - .sort() - .join(' '); - } - - isAssigneeLikelyPerson(assignee: string, patent: OrgPatentEntry): boolean { - if (InstitutionPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) { - return false; - } - - const normalizedAssignee = this.normalizeNameForComparison( - assignee.replace(InstitutionPatentsComponent.PERSON_SUFFIX_PATTERN, ''), - ); - const matchesInventor = (patent.inventors ?? []).some( - (inventor) => - this.normalizeNameForComparison(inventor) === normalizedAssignee, - ); - if (matchesInventor) { - return true; - } - - return InstitutionPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee); - } - - getMatchedAuthorsPreview(patent: OrgPatentEntry): string { - if (!patent.matched_authors?.length) { - return '-'; - } - return patent.matched_authors - .slice(0, 2) - .map((author) => author.author_name) - .join(', '); - } } diff --git a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html index 838a42ad..3bce037a 100644 --- a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html +++ b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html @@ -34,147 +34,18 @@ [value]="sortColumn()" (selectionChange)="setSort($event.value)"> Sortieren nach - Jahr + Jahr Titel Quelle
- - - - - - - - - - - - @for (item of getPagedMatches(); track trackMatch($index, item)) { - - - - - - - - } - -
Patent - Quelle - @if (sortColumn() === 'source') { - {{ - sortDirection() === 'asc' - ? 'arrow_upward' - : 'arrow_downward' - }} - } - - Jahr - @if (sortColumn() === 'year') { - {{ - sortDirection() === 'asc' - ? 'arrow_upward' - : 'arrow_downward' - }} - } - ErfinderAnmelder
- {{ item.patent.title ?? item.patent.patent_id }} - - - {{ item.patent.source }} - - - @if (item.patent.publication_year) { - {{ - item.patent.publication_year - }} - } @else { - - - } - - @if (item.patent.inventors && item.patent.inventors.length) { -
- @for ( - inventor of item.patent.inventors.slice(0, 2); - track inventor - ) { - - person - {{ inventor }} - - } - @if (item.patent.inventors.length > 2) { - - - person - {{ item.patent.inventors[2] }} - - @if (item.patent.inventors.length > 3) { - +{{ item.patent.inventors.length - 3 }} - } - - } -
- } @else { - - - } -
- @if (item.patent.assignees && item.patent.assignees.length) { -
- @for ( - assignee of item.patent.assignees.slice(0, 2); - track assignee - ) { - - {{ - isAssigneeLikelyPerson(assignee, item.patent) - ? 'person' - : 'apartment' - }} - {{ assignee }} - - } - @if (item.patent.assignees.length > 2) { - - - {{ - isAssigneeLikelyPerson( - item.patent.assignees[2], - item.patent - ) - ? 'person' - : 'apartment' - }} - {{ item.patent.assignees[2] }} - - @if (item.patent.assignees.length > 3) { - +{{ item.patent.assignees.length - 3 }} - } - - } -
- } @else { - - - } -
+ (); activeFilter = signal('all'); - sortColumn = signal('year'); + sortColumn = signal('publication_year'); sortDirection = signal('desc'); selectedMatch = signal(null); @@ -68,6 +75,8 @@ export class KeywordsPatentsComponent { return this.sortMatches(items); }); + readonly selectedPatent = computed(() => this.selectedMatch()?.patent ?? null); + emptyMessage(): string { switch (this.mappingStatus()) { case 'search_error': @@ -82,57 +91,42 @@ export class KeywordsPatentsComponent { return this.filteredMatches().slice(start, start + this.pageSize()); } + getPagedPatents(): PatentEntry[] { + return this.getPagedMatches().map((item) => item.patent); + } + setFilter(filter: SourceFilter): void { this.activeFilter.set(filter); this.selectedMatch.set(null); this.resetPage(); } + onSortChange(sort: Sort): void { + if (!sort.direction || !isValidSortColumn(sort.active)) { + return; + } + this.sortColumn.set(sort.active); + this.sortDirection.set(sort.direction); + this.selectedMatch.set(null); + this.resetPage(); + } + setSort(column: SortColumn): void { if (this.sortColumn() === column) { this.sortDirection.set(this.sortDirection() === 'asc' ? 'desc' : 'asc'); } else { this.sortColumn.set(column); - this.sortDirection.set(column === 'year' ? 'desc' : 'asc'); + this.sortDirection.set(column === 'publication_year' ? 'desc' : 'asc'); } this.selectedMatch.set(null); this.resetPage(); } - isAssigneeLikelyPerson(assignee: string, patent: PatentEntry): boolean { - if (KeywordsPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) { - return false; + selectPatentFromTable(patent: PatentEntry): void { + const match = this.matches().find((item) => item.patent === patent); + if (match) { + this.selectMatch(match); } - - const normalizedAssignee = this.normalizeNameForComparison( - assignee.replace(KeywordsPatentsComponent.PERSON_SUFFIX_PATTERN, ''), - ); - const matchesInventor = (patent.inventors ?? []).some( - (inventor) => - this.normalizeNameForComparison(inventor) === normalizedAssignee, - ); - if (matchesInventor) { - return true; - } - - return KeywordsPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee); - } - - private static readonly ORG_SUFFIX_PATTERN = - /\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i; - private static readonly PERSON_SUFFIX_PATTERN = - /\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i; - - private normalizeNameForComparison(name: string): string { - return name - .normalize('NFD') - .replace(/[̀-ͯ]/g, '') - .replace(/[.,]/g, '') - .toUpperCase() - .split(/\s+/) - .filter(Boolean) - .sort() - .join(' '); } onPatentPageChange(_event: PageEvent): void { @@ -186,23 +180,12 @@ export class KeywordsPatentsComponent { return `${text.slice(0, 160).trimEnd()}…`; } - trackMatch(_index: number, item: KeywordPatentMatch): string { - const patent = item.patent; - return [ - patent.source, - patent.patent_id, - patent.publication_date ?? '', - patent.kind ?? patent.application_type ?? '', - item.match_score, - ].join('|'); - } - private sortMatches(items: KeywordPatentMatch[]): KeywordPatentMatch[] { const column = this.sortColumn(); const direction = this.sortDirection() === 'asc' ? 1 : -1; return [...items].sort((a, b) => { switch (column) { - case 'year': { + case 'publication_year': { const yearA = a.patent.publication_date ?? String(a.patent.publication_year ?? ''); diff --git a/webapp/src/app/modules/patent-detail/patent-detail.utils.ts b/webapp/src/app/modules/patent-detail/patent-detail.utils.ts index bc74fecd..11757964 100644 --- a/webapp/src/app/modules/patent-detail/patent-detail.utils.ts +++ b/webapp/src/app/modules/patent-detail/patent-detail.utils.ts @@ -122,6 +122,52 @@ export function getDescriptionPreview(text: string | null): string { return `${text.slice(0, DESCRIPTION_PREVIEW_LENGTH).trimEnd()}…`; } +const ORG_SUFFIX_PATTERN = + /\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i; +const PERSON_SUFFIX_PATTERN = /\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i; + +function normalizeNameForComparison(name: string): string { + return name + .normalize('NFD') + .replace(/[̀-ͯ]/g, '') + .replace(/[.,]/g, '') + .toUpperCase() + .split(/\s+/) + .filter(Boolean) + .sort() + .join(' '); +} + +export function isAssigneeLikelyPerson( + assignee: string, + inventors: string[] | undefined, +): boolean { + if (ORG_SUFFIX_PATTERN.test(assignee)) { + return false; + } + + const normalizedAssignee = normalizeNameForComparison( + assignee.replace(PERSON_SUFFIX_PATTERN, ''), + ); + const matchesInventor = (inventors ?? []).some( + (inventor) => normalizeNameForComparison(inventor) === normalizedAssignee, + ); + if (matchesInventor) { + return true; + } + + return PERSON_SUFFIX_PATTERN.test(assignee); +} + +export function trackPatentEntry(patent: PatentEntry): string { + return [ + patent.source, + patent.patent_id, + patent.publication_date ?? '', + patent.kind ?? patent.application_type ?? '', + ].join('|'); +} + export function patentExternalLinks( patent: PatentEntry, ): { label: string; url: string }[] { diff --git a/webapp/src/app/modules/person-patents/person-patents.component.html b/webapp/src/app/modules/person-patents/person-patents.component.html index b32185a7..ba80b808 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.html +++ b/webapp/src/app/modules/person-patents/person-patents.component.html @@ -34,146 +34,18 @@ [value]="sortColumn" (selectionChange)="setSort($event.value)"> Sortieren nach - Jahr + Jahr Titel Quelle
- - - - - - - - - - - - @for ( - patent of getPagedPatents(); - track trackPatent($index, patent) - ) { - - - - - - - - } - -
Patent - Quelle - @if (sortColumn === 'source') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Jahr - @if (sortColumn === 'year') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - ErfinderAnmelder
- {{ patent.title ?? patent.patent_id }} - - - {{ patent.source }} - - - @if (patent.publication_year) { - {{ - patent.publication_year - }} - } @else { - - - } - - @if (patent.inventors && patent.inventors.length) { -
- @for ( - inventor of patent.inventors.slice(0, 2); - track inventor - ) { - - person - {{ inventor }} - - } - @if (patent.inventors.length > 2) { - - - person - {{ patent.inventors[2] }} - - @if (patent.inventors.length > 3) { - +{{ patent.inventors.length - 3 }} - } - - } -
- } @else { - - - } -
- @if (patent.assignees && patent.assignees.length) { -
- @for ( - assignee of patent.assignees.slice(0, 2); - track assignee - ) { - - {{ - isAssigneeLikelyPerson(assignee, patent) - ? 'person' - : 'apartment' - }} - {{ assignee }} - - } - @if (patent.assignees.length > 2) { - - - {{ - isAssigneeLikelyPerson( - patent.assignees[2], - patent - ) - ? 'person' - : 'apartment' - }} - {{ patent.assignees[2] }} - - @if (patent.assignees.length > 3) { - +{{ patent.assignees.length - 3 }} - } - - } -
- } @else { - - - } -
+ { switch (this.sortColumn) { - case 'year': { + case 'publication_year': { const yearA = a.publication_date ?? String(a.publication_year ?? ''); const yearB = b.publication_date ?? String(b.publication_year ?? ''); return direction * yearA.localeCompare(yearB); @@ -202,7 +215,9 @@ export class PersonPatentsComponent { } private isValidSortColumn(value: string | null): value is SortColumn { - return value === 'title' || value === 'year' || value === 'source'; + return ( + value === 'title' || value === 'publication_year' || value === 'source' + ); } private isValidSortDirection(value: string | null): value is SortDirection { @@ -214,42 +229,6 @@ export class PersonPatentsComponent { return this.filteredPatents.slice(start, start + this.pageSize); } - private static readonly ORG_SUFFIX_PATTERN = - /\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i; - private static readonly PERSON_SUFFIX_PATTERN = - /\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i; - - private normalizeNameForComparison(name: string): string { - return name - .normalize('NFD') - .replace(/[̀-ͯ]/g, '') - .replace(/[.,]/g, '') - .toUpperCase() - .split(/\s+/) - .filter(Boolean) - .sort() - .join(' '); - } - - isAssigneeLikelyPerson(assignee: string, patent: PatentEntry): boolean { - if (PersonPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) { - return false; - } - - const normalizedAssignee = this.normalizeNameForComparison( - assignee.replace(PersonPatentsComponent.PERSON_SUFFIX_PATTERN, ''), - ); - const matchesInventor = (patent.inventors ?? []).some( - (inventor) => - this.normalizeNameForComparison(inventor) === normalizedAssignee, - ); - if (matchesInventor) { - return true; - } - - return PersonPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee); - } - formatDate(date: string | null | undefined): string { return formatPatentDate(date); } @@ -262,15 +241,6 @@ export class PersonPatentsComponent { return this.patents.filter((p) => p.source === 'USPTO').length; } - trackPatent(_index: number, patent: PatentEntry): string { - return [ - patent.source, - patent.patent_id, - patent.publication_date ?? '', - patent.kind ?? patent.application_type ?? '', - ].join('|'); - } - getAbstractPreview(abstract: string | null | undefined): string | null { if (!abstract?.trim()) { return null; diff --git a/webapp/src/app/shared/ui/patent-table/patent-table.component.html b/webapp/src/app/shared/ui/patent-table/patent-table.component.html new file mode 100644 index 00000000..0a6fcdae --- /dev/null +++ b/webapp/src/app/shared/ui/patent-table/patent-table.component.html @@ -0,0 +1,125 @@ + + + + + + + + + {{ patent.source }} + + + + + @if (patent.publication_year) { + {{ patent.publication_year }} + } @else { + - + } + + + + @let expanded = isInventorsExpanded(patent); + @let visibleInventors = + expanded ? patent.inventors : (patent.inventors ?? []).slice(0, 3); +
+ @for (inventor of visibleInventors; track inventor) { + + person + {{ inventor }} + + } @empty { + - + } + @if ((patent.inventors ?? []).length > 3) { + + } +
+
+ + + @let expanded = isAssigneesExpanded(patent); + @let visibleAssignees = + expanded ? patent.assignees : (patent.assignees ?? []).slice(0, 3); +
+ @for (assignee of visibleAssignees; track assignee) { + + {{ + isAssigneeLikelyPerson(assignee, patent) ? 'person' : 'apartment' + }} + {{ assignee }} + + } @empty { + - + } + @if ((patent.assignees ?? []).length > 3) { + + } +
+
+ + + + {{ getMatchTypeLabel(patent.match_type) }} + + + + +
+ @if (patent.matched_authors && patent.matched_authors.length) { + @for ( + author of patent.matched_authors.slice(0, 3); + track author.openalex_author_id + ) { + + {{ author.author_name }} + + } + } @else { + - + } +
+
+ + + + open_in_new + + diff --git a/webapp/src/app/shared/ui/patent-table/patent-table.component.scss b/webapp/src/app/shared/ui/patent-table/patent-table.component.scss new file mode 100644 index 00000000..76b50023 --- /dev/null +++ b/webapp/src/app/shared/ui/patent-table/patent-table.component.scss @@ -0,0 +1,149 @@ +:host { + display: block; +} + +.empty-text { + color: var(--sg-text-muted); +} + +.patent-title-btn { + display: inline-flex; + align-items: center; + gap: 2px; + padding: 0; + border: 0; + background: none; + color: var(--sg-text); + font-weight: 600; + font-size: 13px; + text-align: left; + white-space: normal; + word-break: break-word; + cursor: pointer; + + &:hover { + color: var(--sg-blue-highlight); + } + + &.selected { + color: var(--sg-blue-highlight); + } + + &__icon { + flex-shrink: 0; + width: 16px; + height: 16px; + font-size: 16px; + } +} + +.year-badge { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 26px; + padding: 2px 10px; + border-radius: 999px; + border: 1px solid var(--sg-border); + color: var(--sg-text); + font-size: 0.8rem; + font-weight: 600; +} + +.person-chips { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 4px; + max-width: 240px; +} + +.person-chip { + display: inline-flex; + align-items: center; + gap: 4px; + max-width: 100%; + padding: 2px 8px; + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: var(--sg-surface-soft); + color: var(--sg-text); + font-size: 0.75rem; + line-height: 1.4; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + mat-icon { + flex-shrink: 0; + width: 14px; + height: 14px; + font-size: 14px; + color: var(--sg-text-soft); + } +} + +.match-badge { + display: inline-flex; + align-items: center; + padding: 3px 10px; + border-radius: 999px; + font-size: 0.72rem; + font-weight: 700; + + &--institution { + background: var(--sg-primary-soft); + color: var(--sg-primary); + border: 1px solid var(--sg-border); + } + + &--name { + background: var(--sg-warning-soft); + color: var(--sg-warning); + border: 1px solid var(--sg-border); + } + + &--both { + background: var(--sg-success-soft); + color: var(--sg-success); + border: 1px solid var(--sg-border); + } +} + +.patent-chip-more { + display: inline-flex; + align-items: center; + min-height: 24px; + padding: 3px 8px; + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: var(--sg-surface); + color: var(--sg-text-muted); + font-family: inherit; + font-size: 11px; + line-height: 1.2; + cursor: pointer; + transition: all 0.2s ease; + + &:hover { + background: var(--sg-surface-soft); + color: var(--sg-text); + } +} + +.cell-authors { + display: flex; + flex-direction: column; + gap: 4px; + min-width: 120px; +} + +.author-link { + color: var(--sg-blue-highlight); + text-decoration: none; + font-size: 0.82rem; + + &:hover { + text-decoration: underline; + } +} diff --git a/webapp/src/app/shared/ui/patent-table/patent-table.component.ts b/webapp/src/app/shared/ui/patent-table/patent-table.component.ts new file mode 100644 index 00000000..44b4d0df --- /dev/null +++ b/webapp/src/app/shared/ui/patent-table/patent-table.component.ts @@ -0,0 +1,169 @@ +import { Component, TemplateRef, input, output, signal, viewChild } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { MatIconModule } from '@angular/material/icon'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { Sort } from '@angular/material/sort'; +import { PatentEntry } from '../../../api/model/patentEntry'; +import { MatchedAuthor } from '../../../api/model/matchedAuthor'; +import { DataTableComponent, GenericColumn } from '../data-table/data-table.component'; +import { ChipComponent } from '../chip/chip.component'; +import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive'; +import { AppAuthorTooltipComponent } from '../app-author-tooltip/app-author-tooltip.component'; +import { isAssigneeLikelyPerson } from '../../../modules/patent-detail/patent-detail.utils'; + +export interface PatentTableEntry extends PatentEntry { + match_type?: string; + matched_authors?: MatchedAuthor[]; +} + +@Component({ + selector: 'app-patent-table', + imports: [ + RouterModule, + MatIconModule, + MatButtonModule, + MatTooltipModule, + DataTableComponent, + ChipComponent, + ComponentTooltipDirective, + ], + templateUrl: './patent-table.component.html', + styleUrl: './patent-table.component.scss', +}) +export class PatentTableComponent { + readonly AuthorTooltipComponent = AppAuthorTooltipComponent; + + patents = input.required(); + selectedPatent = input(null); + showMatchType = input(false); + + queryParamSortKey = input('sortBy'); + queryParamSortDirectionKey = input('sortDir'); + + selectPatent = output(); + handleSortChange = output(); + + titleTmp = viewChild.required>('titleTmp'); + sourceTmp = viewChild.required>('sourceTmp'); + yearTmp = viewChild.required>('yearTmp'); + inventorsTmp = viewChild.required>('inventorsTmp'); + assigneesTmp = viewChild.required>('assigneesTmp'); + matchTypeTmp = viewChild.required>('matchTypeTmp'); + matchedAuthorsTmp = viewChild.required>('matchedAuthorsTmp'); + actionsTmp = viewChild.required>('actionsTmp'); + + columns(): GenericColumn[] { + const baseColumns: GenericColumn[] = [ + { + id: 'title', + header: 'Patent', + type: 'accessor', + accessorKey: 'title' as keyof T, + cellTemplate: this.titleTmp(), + }, + { + id: 'source', + header: 'Quelle', + type: 'accessor', + accessorKey: 'source' as keyof T, + cellTemplate: this.sourceTmp(), + }, + { + id: 'publication_year', + header: 'Jahr', + type: 'accessor', + accessorKey: 'publication_year' as keyof T, + cellTemplate: this.yearTmp(), + }, + { + id: 'inventors', + header: 'Erfinder', + type: 'display', + cellTemplate: this.inventorsTmp(), + }, + { + id: 'assignees', + header: 'Anmelder', + type: 'display', + cellTemplate: this.assigneesTmp(), + }, + ]; + + if (this.showMatchType()) { + baseColumns.push( + { + id: 'match_type', + header: 'Match-Typ', + type: 'display', + cellTemplate: this.matchTypeTmp(), + }, + { + id: 'matched_authors', + header: 'Personen', + type: 'display', + cellTemplate: this.matchedAuthorsTmp(), + }, + ); + } + + baseColumns.push({ + id: 'actions', + header: '', + type: 'display', + cellTemplate: this.actionsTmp(), + }); + + return baseColumns; + } + + private readonly expandedInventorsIds = signal>(new Set()); + private readonly expandedAssigneesIds = signal>(new Set()); + + isInventorsExpanded(patent: T): boolean { + return this.expandedInventorsIds().has(patent.patent_id); + } + + toggleInventorsExpansion(patent: T): void { + this.expandedInventorsIds.update((ids) => toggleId(ids, patent.patent_id)); + } + + isAssigneesExpanded(patent: T): boolean { + return this.expandedAssigneesIds().has(patent.patent_id); + } + + toggleAssigneesExpansion(patent: T): void { + this.expandedAssigneesIds.update((ids) => toggleId(ids, patent.patent_id)); + } + + isSelected(patent: T): boolean { + return this.selectedPatent() === patent; + } + + isAssigneeLikelyPerson(assignee: string, patent: T): boolean { + return isAssigneeLikelyPerson(assignee, patent.inventors); + } + + getMatchTypeLabel(matchType: string | undefined): string { + switch (matchType) { + case 'institution': + return 'Institution'; + case 'name': + return 'Name'; + case 'both': + return 'Beides'; + default: + return matchType ?? '-'; + } + } +} + +function toggleId(ids: Set, id: string): Set { + const next = new Set(ids); + if (next.has(id)) { + next.delete(id); + } else { + next.add(id); + } + return next; +} From 66487c20e7607bdf6ea18d28bf0a8ae44bf70189 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 11:35:36 +0200 Subject: [PATCH 17/27] feat(weights-sliders): add name matching hint with visual indicators --- .../persons-results.component.ts | 3 +++ .../weights-sliders.component.html | 15 +++++++++++++ .../weights-sliders.component.scss | 22 +++++++++++++++++++ .../weights-sliders.component.ts | 10 +++++++++ 4 files changed, 50 insertions(+) diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index fb4a1bf1..3e3ab080 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -116,6 +116,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { icon: 'business', description: 'Gewichtet die Anzahl der Unternehmensgründungen (Handelsregister-Verbindungen).', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wCompanies', }, @@ -125,6 +126,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { icon: 'visibility', description: 'Gewichtet die öffentliche Sichtbarkeit über Nennungen in Nachrichtenartikeln.', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wNews', }, @@ -133,6 +135,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { label: 'Patente', icon: 'workspace_premium', description: 'Gewichtet Innovations- und Transferleistung über Patente.', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wPatents', }, diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html index 0823bf1a..8e4a3d52 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html @@ -25,6 +25,11 @@ {{ option.icon }} } {{ option.label }} + @if (option.nameMatched) { + + }
@@ -51,6 +56,16 @@ }
+ + @if (hasNameMatchedOption) { +

+ star + Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit + externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen + kann. +

+ } + @if (!weightsState().valid) {
diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss index 6b0c7fcd..236e4ed4 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss @@ -108,6 +108,28 @@ $touch-target: 44px; padding: 0 6px; } +::ng-deep .name-match-star { + color: var(--sg-warning, #b8860b); +} + +/* ============================================================ + NAME MATCH NOTE + ============================================================ */ +.name-match-note { + display: flex; + align-items: flex-start; + gap: 0.3rem; + margin: 0.3rem 0 0; + padding: 0.2rem 0.3rem; + font-size: 0.7rem; + color: var(--sg-text-muted); + + mat-icon { + flex: 0 0 auto; + color: var(--sg-warning, #b8860b); + } +} + /* ============================================================ WARNING ============================================================ */ diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts index 436499ff..8f43607c 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts @@ -28,6 +28,12 @@ export interface WeightSliderOption { icon?: string; description?: string; + /** + * Marks this metric with a star, indicating it relies on name matching + * (see weight-name-match-note in the template). + */ + nameMatched?: boolean; + /** * Optional default raw weight. * Must be between 0 and 1. @@ -212,6 +218,10 @@ export class WeightsSlidersComponent implements OnInit, OnChanges { } } + get hasNameMatchedOption(): boolean { + return this.options.some((option) => option.nameMatched); + } + weightControl(key: string): FormControl { const control = this.form.controls[key]; From cbfa60ae46227b1be9e28c207e078fcb23234a58 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 11:42:35 +0200 Subject: [PATCH 18/27] feat(compare-authors): add name matching note to section 2 --- .../compare-authors.component.html | 19 +++++++++++- .../compare-authors.component.scss | 30 ++++++++++++++++++- .../compare-authors.component.ts | 11 +++++++ .../weights-sliders.component.scss | 2 +- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 1ddf076c..b14155e1 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -168,7 +168,16 @@ @for (row of rows; track row.label) { - {{ row.label }} + + {{ row.label }} + @if (row.nameMatched) { + + } + {{ row.hint }} @if (row.kind === 'group') { @@ -222,4 +231,12 @@
+ @if (hasNameMatchedRow(rows)) { +

+ star + Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit + externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen + kann. +

+ } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index f34f907b..64595afd 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -122,7 +122,10 @@ app-chip mat-icon { } .metric-label { - display: block; + display: flex; + align-items: center; + justify-content: center; + gap: 4px; font-weight: 600; color: var(--sg-text); } @@ -135,6 +138,31 @@ app-chip mat-icon { color: var(--sg-text-soft); } +.icon-small { + font-size: 14px; + width: 14px; + height: 14px; + vertical-align: text-bottom; +} + +.name-match-star { + color: var(--sg-warning, #b8860b); +} + +.name-match-note { + display: flex; + align-items: center; + gap: 6px; + margin: 10px 0 0; + font-size: 12px; + color: var(--sg-text-muted); + + mat-icon { + flex: 0 0 auto; + color: var(--sg-warning, #b8860b); + } +} + .value-cell { text-align: center; font-variant-numeric: tabular-nums; diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index d1a38945..cafdc91a 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -98,6 +98,7 @@ interface MetricRow { cells: MetricCell[]; segments: GroupSegment[]; groupCells: GroupCell[]; + nameMatched: boolean; } interface RowDef { @@ -105,6 +106,7 @@ interface RowDef { hint: string; select: (a: AuthorSummary) => number | null; decimals?: boolean; + nameMatched?: boolean; } interface SegmentDef { @@ -385,15 +387,18 @@ export class CompareAuthorsComponent implements OnInit { label: 'Unternehmensgründungen', hint: 'Handelsregister-Verbindungen über den Namen', select: (a) => a.companies, + nameMatched: true, }, { label: 'News-Artikel', hint: 'Nachrichtenartikel, die die Person namentlich nennen', select: (a) => a.news, + nameMatched: true, }, { label: 'Patente', hint: 'Der Person zugeordnete Patente', + nameMatched: true, select: (a) => a.patents, }, ]), @@ -707,6 +712,7 @@ export class CompareAuthorsComponent implements OnInit { })), segments: [], groupCells: [], + nameMatched: def.nameMatched ?? false, }; }); } @@ -731,9 +737,14 @@ export class CompareAuthorsComponent implements OnInit { groupCells: this.summary().map((a) => ({ values: segs.map((s) => s.select(a)), })), + nameMatched: false, }; } + hasNameMatchedRow(rows: MetricRow[]): boolean { + return rows.some((row) => row.nameMatched); + } + ngOnInit(): void { // everything is read from the URL so a shared link lands on the same view const rawAuthors = this.route.snapshot.queryParamMap.get('authors') ?? ''; diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss index 236e4ed4..bb6de978 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss @@ -117,7 +117,7 @@ $touch-target: 44px; ============================================================ */ .name-match-note { display: flex; - align-items: flex-start; + align-items: center; gap: 0.3rem; margin: 0.3rem 0 0; padding: 0.2rem 0.3rem; From 07f8e8bcca8dec12b5d9fb7c63ab09d8142d2c63 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 11:58:07 +0200 Subject: [PATCH 19/27] feat(compare-authors): add author profile link --- .../compare-authors.component.html | 28 +++++++++++++++++-- .../compare-authors.component.scss | 22 +++++++++++++++ .../compare-authors.component.ts | 8 +++++- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index b14155e1..acc2e968 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -32,7 +32,19 @@ Betrachtete Personen:
@for (author of summary(); track author.authorId) { - {{ author.name }} + + + {{ author.name }} + open_in_new + + }
@@ -159,7 +171,19 @@ Kennzahl @for (author of summary(); track author.authorId) { - {{ author.name }} + + + {{ author.name }} + open_in_new + + } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index 64595afd..150ec838 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -60,6 +60,28 @@ app-chip mat-icon { vertical-align: text-bottom; } +.chip-link { + display: inline-flex; + align-items: center; + gap: 4px; + margin: -4px -12px; + padding: 4px 12px; + color: inherit; + text-decoration: none; + cursor: pointer; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + opacity: 0.7; + } + + &:hover mat-icon { + opacity: 1; + } +} + /* ---- cards ---- */ .card { background: var(--sg-card-bg); diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index cafdc91a..bcd14ca5 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, computed, inject, signal } from '@angular/core'; import { DecimalPipe, NgTemplateOutlet } from '@angular/common'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { EChartsOption } from 'echarts'; import { NgxEchartsDirective } from 'ngx-echarts'; @@ -123,6 +123,7 @@ interface SegmentDef { imports: [ DecimalPipe, NgTemplateOutlet, + RouterLink, MatIconModule, NgxEchartsDirective, AuthorResearchProfileComponent, @@ -474,6 +475,11 @@ export class CompareAuthorsComponent implements OnInit { ); } + authorProfileId(authorId: string): string { + const parts = authorId.split('/'); + return parts[parts.length - 1]; + } + // colours the author names on the chart axes like the legend chips private authorAxisLabel(profiles: AuthorTopicProfile[]) { const rich: Record = {}; From 16d44a0b88658fd2633957313fd01bd193e87764 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 12:23:16 +0200 Subject: [PATCH 20/27] feat(publication-type-counts): implement API for counting works by publication type --- service/src/main/inse/ranking/logic.py | 79 +++++++++++ service/src/main/inse/ranking/model.py | 36 +++++ service/src/main/inse/ranking/router.py | 36 +++++ webapp/src/app/api/api/ranking.service.ts | 134 ++++++++++++++++++ webapp/src/app/api/model/models.ts | 2 + .../src/app/api/model/publicationTypeCount.ts | 22 +++ .../api/model/publicationTypeCountsRequest.ts | 34 +++++ .../persons-results.component.html | 6 +- .../persons-results.component.ts | 68 +++++---- 9 files changed, 384 insertions(+), 33 deletions(-) create mode 100644 webapp/src/app/api/model/publicationTypeCount.ts create mode 100644 webapp/src/app/api/model/publicationTypeCountsRequest.ts diff --git a/service/src/main/inse/ranking/logic.py b/service/src/main/inse/ranking/logic.py index e8aacfd5..8313217f 100644 --- a/service/src/main/inse/ranking/logic.py +++ b/service/src/main/inse/ranking/logic.py @@ -24,6 +24,7 @@ from .model import ( FilterType, KeywordOperator, PublicationType, + PublicationTypeCount, RankedAuthor, RankingWeights, SubfieldShare, @@ -788,6 +789,84 @@ def _build_query( } +def _build_publication_type_counts_query( + keywords: list[str], + operator: KeywordOperator, + author_ids: list[str], + timespan: Timespan | None, + config: MatchConfig = _KEYWORD_MATCH, +) -> dict: + """Builds the query that counts matching works per publication type. + + Mirrors _build_query's work filters but leaves out the publication_types + filter itself, since it aggregates over all types instead of one score. + """ + work_filters = [ + _build_keyword_query(keywords, operator, config), + _author_filter(author_ids), + ] + if timespan is not None: + work_filters.append(_timespan_filter(timespan)) + + return { + "size": 0, + "query": { + "bool": { + "filter": work_filters, + }, + }, + "aggs": { + "by_type": { + "terms": { + "field": "type", + "size": len(PublicationType), + }, + }, + }, + } + + +async def publication_type_counts_for_keywords( + keywords: list[str], + operator: KeywordOperator, + institution_id: str, + career_stages: list[CareerStage], + timespan: Timespan | None, + filter_type: FilterType = FilterType.KEYWORD, +) -> list[PublicationTypeCount]: + """Counts the university's matching works per publication type, largest first.""" + author_ids = await _get_author_ids_from_institution(institution_id) + + if not author_ids: + return [] + + if career_stages: + author_ids = await _filter_author_ids_by_career_stage(author_ids, career_stages) + + query_body = _build_publication_type_counts_query( + keywords, operator, author_ids, timespan, _match_config(filter_type), + ) + + response: dict[str, Any] = await elasticsearch.search( + index=config.settings.openalex_works_search_index, + body=query_body, + cluster=ESCluster.NES, + ) + + type_buckets = response.get("aggregations", {}).get("by_type", {}).get("buckets", []) + + counts = [] + for bucket in type_buckets: + try: + publication_type = PublicationType(bucket["key"]) + except ValueError: + continue + counts.append(PublicationTypeCount(type=publication_type, count=bucket["doc_count"])) + + counts.sort(key=lambda c: c.count, reverse=True) + return counts + + def _display_name_from_bucket(author_bucket: dict) -> str: """Reads the authors display name out of the name sub-aggregation.""" name_buckets = author_bucket.get("author_name", {}).get("buckets", []) diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index 75522114..f4de7b12 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -195,6 +195,42 @@ class AuthorMetricsRequest(BaseModel): ) +class PublicationTypeCountsRequest(BaseModel): + keywords: list[str] = Field( + min_length=1, + description="One or more keywords to match works against.", + ) + operator: KeywordOperator = Field( + default=KeywordOperator.AND, + description="How to combine the keywords: 'and' or 'or'. Defaults to 'and'.", + ) + filter_type: FilterType = Field( + default=FilterType.KEYWORD, + description="What the 'keywords' values match against: 'keyword' (OpenAlex " + "keyword display names) or 'topic' (OpenAlex topic display names). Defaults to 'keyword'.", + ) + career_stages: list[CareerStage] = Field( + default_factory=list, + description="Optional filter: only count works of authors in one of these career stages. Empty = no filter.", + ) + timespan: Timespan | None = Field( + default=None, + description="Optional filter: only count works whose publication_year is within [from, to].", + ) + + @field_validator("operator", "filter_type", mode="before") + @classmethod + def operator_case_insensitive(cls, value): + if isinstance(value, str): + return value.lower() + return value + + +class PublicationTypeCount(BaseModel): + type: PublicationType = Field(description="The OpenAlex work type.") + count: int = Field(description="Number of matching works of this type.") + + class AuthorTopicStats(BaseModel): """Section 1: combined stats over an author's works that match the topic filter.""" diff --git a/service/src/main/inse/ranking/router.py b/service/src/main/inse/ranking/router.py index cb645d5a..e0f0dd9b 100644 --- a/service/src/main/inse/ranking/router.py +++ b/service/src/main/inse/ranking/router.py @@ -14,6 +14,8 @@ from .model import ( AuthorTopicProfile, AuthorTopicStats, KeywordToAuthorRequest, + PublicationTypeCount, + PublicationTypeCountsRequest, RankedAuthor, SelectedAuthorsRequest, ) @@ -68,6 +70,40 @@ async def rank_author( filter_type=request.filter_type, ) +# Publication-type facet counts for the "Art der Work" filter +@router.post("/publication-type-counts", response_model=list[PublicationTypeCount]) +async def publication_type_counts( + request: PublicationTypeCountsRequest, + access_token_metadata: Annotated[ + AccessTokenMetadata, CurrentUserAccessTokenPayloadDep + ], +): + institution_id = access_token_metadata.effective_institution_id + if not institution_id: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="No OpenAlex institution is assigned to the current organization.", + ) + + logger.info( + "publication-type-counts keywords=%s operator=%s filter_type=%s institution_id=%s " + "career_stages=%s timespan=%s", + request.keywords, + request.operator, + request.filter_type, + institution_id, + request.career_stages, + request.timespan, + ) + return await logic.publication_type_counts_for_keywords( + keywords=request.keywords, + operator=request.operator, + institution_id=institution_id, + career_stages=request.career_stages, + timespan=request.timespan, + filter_type=request.filter_type, + ) + # Compare authors table 1 (topic stats) @router.post("/topic-stats", response_model=list[AuthorTopicStats]) async def topic_stats(request: SelectedAuthorsRequest): diff --git a/webapp/src/app/api/api/ranking.service.ts b/webapp/src/app/api/api/ranking.service.ts index a74696b6..3d3bbea6 100644 --- a/webapp/src/app/api/api/ranking.service.ts +++ b/webapp/src/app/api/api/ranking.service.ts @@ -39,6 +39,10 @@ import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore import { KeywordToAuthorRequest } from '../model/keywordToAuthorRequest'; // @ts-ignore +import { PublicationTypeCount } from '../model/publicationTypeCount'; +// @ts-ignore +import { PublicationTypeCountsRequest } from '../model/publicationTypeCountsRequest'; +// @ts-ignore import { RankedAuthor } from '../model/rankedAuthor'; // @ts-ignore import { SelectedAuthorsRequest } from '../model/selectedAuthorsRequest'; @@ -191,6 +195,136 @@ export class RankingService extends BaseService { ); } + /** + * Publication Type Counts + * @endpoint post /api/rank/publication-type-counts + * @param publicationTypeCountsRequest + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if ( + publicationTypeCountsRequest === null || + publicationTypeCountsRequest === undefined + ) { + throw new Error( + 'Required parameter publicationTypeCountsRequest was null or undefined when calling publicationTypeCountsApiRankPublicationTypeCountsPost.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + 'Authorization', + localVarHeaders, + 'Bearer ', + ); + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = + this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Content-Type', + httpContentTypeSelected, + ); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/rank/publication-type-counts`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>( + 'post', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: publicationTypeCountsRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + /** * Rank Author * @endpoint post /api/rank/rank-author diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index d6da3737..0a1a7530 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -202,6 +202,8 @@ export * from './projectsSortBy'; export * from './publicationDetailByFunder'; export * from './publicationIdsByAuthorPosition'; export * from './publicationType'; +export * from './publicationTypeCount'; +export * from './publicationTypeCountsRequest'; export * from './publicationsByAuthorResponse'; export * from './rankedAuthor'; export * from './rankingResponse'; diff --git a/webapp/src/app/api/model/publicationTypeCount.ts b/webapp/src/app/api/model/publicationTypeCount.ts new file mode 100644 index 00000000..693dab21 --- /dev/null +++ b/webapp/src/app/api/model/publicationTypeCount.ts @@ -0,0 +1,22 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { PublicationType } from './publicationType'; + +export interface PublicationTypeCount { + /** + * The OpenAlex work type. + */ + type: PublicationType; + /** + * Number of matching works of this type. + */ + count: number; +} +export namespace PublicationTypeCount {} diff --git a/webapp/src/app/api/model/publicationTypeCountsRequest.ts b/webapp/src/app/api/model/publicationTypeCountsRequest.ts new file mode 100644 index 00000000..fe24986b --- /dev/null +++ b/webapp/src/app/api/model/publicationTypeCountsRequest.ts @@ -0,0 +1,34 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { Timespan } from './timespan'; +import { FilterType } from './filterType'; +import { CareerStage } from './careerStage'; +import { KeywordOperator } from './keywordOperator'; + +export interface PublicationTypeCountsRequest { + /** + * One or more keywords to match works against. + */ + keywords: Array; + /** + * How to combine the keywords: \'and\' or \'or\'. Defaults to \'and\'. + */ + operator?: KeywordOperator; + /** + * What the \'keywords\' values match against: \'keyword\' (OpenAlex keyword display names) or \'topic\' (OpenAlex topic display names). Defaults to \'keyword\'. + */ + filter_type?: FilterType; + /** + * Optional filter: only count works of authors in one of these career stages. Empty = no filter. + */ + career_stages?: Array; + timespan?: Timespan | null; +} +export namespace PublicationTypeCountsRequest {} diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html index ae13af47..e1ff133b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html @@ -104,8 +104,10 @@ } - @for (pt of filteredPubTypes(); track pt) { - {{ pt }} + @for (pt of filteredPubTypes(); track pt.type) { + {{ pt.type }} ({{ pt.count }}) } diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index 3e3ab080..43a0103b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -25,6 +25,8 @@ import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slide import { CareerStage, KeywordToAuthorRequest, + PublicationTypeCount, + PublicationTypeCountsRequest, RankedAuthor, RankingService, } from '../../../../api'; @@ -177,33 +179,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit { ]; readonly companyStatus = signal<'all' | 'active' | 'deleted'>('all'); - // publication types - readonly ALL_PUBLICATION_TYPES = [ - 'article', - 'other', - 'dataset', - 'book-chapter', - 'book', - 'dissertation', - 'preprint', - 'paratext', - 'libguides', - 'review', - 'letter', - 'reference-entry', - 'editorial', - 'peer-review', - 'report', - 'standard', - 'erratum', - 'retraction', - 'supplementary-materials', - 'book-section', - 'database', - 'software', - 'report-component', - 'grant', - ]; + // publication types: counted from the index (count-by), largest first + readonly publicationTypeCounts = signal([]); readonly pubTypeSearchTerm = signal(''); @@ -216,10 +193,9 @@ export class KeywordsToPersonsResultsComponent implements OnInit { readonly filteredPubTypes = computed(() => { const term = this.pubTypeSearchTerm().toLowerCase(); - if (!term) return this.ALL_PUBLICATION_TYPES; - return this.ALL_PUBLICATION_TYPES.filter((pt) => - pt.toLowerCase().includes(term), - ); + const counts = this.publicationTypeCounts(); + if (!term) return counts; + return counts.filter((pt) => pt.type.toLowerCase().includes(term)); }); onPubTypesChange(selected: string[]) { @@ -256,6 +232,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { replaceUrl: true, }); this.loadAuthors(); + this.loadPublicationTypeCounts(); } readonly CAREER_STAGE_OPTIONS = [ @@ -317,6 +294,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit { if (operator === 'and' || operator === 'or') { this.keywordOperator.set(operator); } + + this.loadPublicationTypeCounts(); } // reads a year query param, clamped to the valid range; falls back on invalid input @@ -403,6 +382,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { } this.writeTimespanToUrl(); this.loadAuthors(); + this.loadPublicationTypeCounts(); } // the backend returns the full OpenAlex url; the profile route needs only the id @@ -497,4 +477,30 @@ export class KeywordsToPersonsResultsComponent implements OnInit { }, }); } + + // counts, by publication type, of the works matching the current keyword/ + // career-stage/timespan filters — drives the "Art der Work" filter options + private loadPublicationTypeCounts(): void { + const request: PublicationTypeCountsRequest = { + keywords: this.state.topicsList(), + operator: this.keywordOperator(), + filter_type: 'topic', + career_stages: + this.careerStages().length > 0 ? this.careerStages() : undefined, + timespan: { + from: this.timespanFrom(), + to: this.timespanTo(), + }, + }; + + this.rankingService + .publicationTypeCountsApiRankPublicationTypeCountsPost(request) + .subscribe({ + next: (counts) => this.publicationTypeCounts.set(counts), + error: (error) => { + console.error(error); + this.publicationTypeCounts.set([]); + }, + }); + } } From 87b283ccfb1b8766dc86105cbef02ba195352726 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 12:40:03 +0200 Subject: [PATCH 21/27] feat(search-results): enhance Fuzzy Search behavior and tooltip logic for improved user experience --- .../search-results.component.html | 13 +++++++---- .../search-results.component.ts | 23 ++++++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results.component.html b/webapp/src/app/modules/keywords-search/search-results/search-results.component.html index fcc5a94d..d242e9cd 100644 --- a/webapp/src/app/modules/keywords-search/search-results/search-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/search-results.component.html @@ -22,9 +22,14 @@ + [checked]="state.fuzzySearch()" + [disabled]="isPersonsTab()"> Fuzzy Search @@ -72,8 +77,8 @@ [active]="rla.isActive" [queryParams]="{ keywords: state.payload()?.keywords?.join(','), - fuzzy: state.payload()?.options?.fuzzy, - topics: state.payload()?.options?.fuzzy ? state.topicIds() : null, + fuzzy: tabFuzzyValue(route), + topics: tabFuzzyValue(route) ? state.topicIds() : null, topicId: null, }" queryParamsHandling="replace"> diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts index 76897874..d11c1216 100644 --- a/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts @@ -63,6 +63,8 @@ export class KeywordsSearchResultsComponent { { path: 'trends', label: 'Visualisierung', icon: 'bar_chart' }, ]; + private readonly lastUserFuzzy = signal(false); + readonly selectedKeywordCount = computed(() => this.state.keywords().length); readonly allKeywordEntries = computed(() => { const seen = new Set(); @@ -85,7 +87,12 @@ export class KeywordsSearchResultsComponent { // previous search never gets silently applied to a new one. this.route.queryParamMap.pipe(takeUntilDestroyed()).subscribe((params) => { const keywords = this.parseKeywordList(params.get('keywords')); - const fuzzySearch = params.get('fuzzy') === 'true'; + const onPersonsTab = this.isPersonsTab(); + const fuzzySearch = onPersonsTab || params.get('fuzzy') === 'true'; + + if (!onPersonsTab) { + this.lastUserFuzzy.set(params.get('fuzzy') === 'true'); + } const cached = this.readHandoffCache(); const cacheMatches = @@ -100,8 +107,22 @@ export class KeywordsSearchResultsComponent { ? cached!.patentKeywordEntries : undefined, }); + + if (onPersonsTab && params.get('fuzzy') !== 'true') { + this.updateQueryParams(true); + } }); } + + // the Fuzzy Search toggle is locked on while the Personen tab is active + isPersonsTab(): boolean { + return this.route.snapshot.firstChild?.routeConfig?.path === 'persons'; + } + + tabFuzzyValue(route: { path: string }): boolean { + if (route.path === 'persons') return true; + return this.lastUserFuzzy(); + } goBackToSearch(): void { void this.router.navigate(['/keywords'], { queryParamsHandling: 'merge', From d8041751c571630fa5a365d47e86bcc092901c7f Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Sat, 15 Aug 2026 12:44:00 +0200 Subject: [PATCH 22/27] feat(weights-sliders): improve layout of weight labels and icons for better responsiveness --- .../shared/ui/weights-sliders/weights-sliders.component.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss index bb6de978..39750a89 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss @@ -77,6 +77,7 @@ $touch-target: 44px; width: 14px; height: 14px; color: var(--sg-text-muted); + flex-shrink: 0; } span { @@ -84,6 +85,8 @@ $touch-target: 44px; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; + flex: 1; + min-width: 0; } } @@ -108,7 +111,7 @@ $touch-target: 44px; padding: 0 6px; } -::ng-deep .name-match-star { +::ng-deep .weight-label .icon-small.name-match-star { color: var(--sg-warning, #b8860b); } From 1369a2bf29a3fdd9a6aa48b3b27a0f3d8d65b3f9 Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Sat, 15 Aug 2026 20:43:52 +0200 Subject: [PATCH 23/27] refactor(patents, person-funding): reuse shared app-card-search/app-data-table component --- .../modules/patents/patents.component.html | 166 ++++++++---------- .../modules/patents/patents.component.scss | 2 - .../app/modules/patents/patents.component.ts | 102 ++++------- .../person-funding.component.html | 128 ++++---------- .../person-funding.component.scss | 74 +++----- .../person-funding.component.ts | 65 ++++++- 6 files changed, 234 insertions(+), 303 deletions(-) diff --git a/webapp/src/app/modules/patents/patents.component.html b/webapp/src/app/modules/patents/patents.component.html index 76bac5ac..a018cef8 100644 --- a/webapp/src/app/modules/patents/patents.component.html +++ b/webapp/src/app/modules/patents/patents.component.html @@ -3,42 +3,6 @@ -
- - Suche nach Titel oder Patent-Nr. - - search - - - -
- - EPO - USPTO - - - -
-
- - - @if (loading) { } - } @else if (patents.length === 0) { -
-

Keine Patente gefunden.

-
} @else { -
- @for ( - patent of patents; - track patent.patent_id + (patent.publication_date ?? '') - ) { - - - {{ - patent.title ?? patent.patent_id - }} - - {{ patent.source }} - - - - - - - - - - - - - - } -
+ + + +
+ + EPO + USPTO + + + +
+
+ + +
+

Keine Patente gefunden.

+
+
+ + + + + {{ + patent.title ?? patent.patent_id + }} + + {{ patent.source }} + + + + + + + + + + + + + + } - - - - diff --git a/webapp/src/app/modules/patents/patents.component.scss b/webapp/src/app/modules/patents/patents.component.scss index 67227c82..87fa2142 100644 --- a/webapp/src/app/modules/patents/patents.component.scss +++ b/webapp/src/app/modules/patents/patents.component.scss @@ -76,14 +76,12 @@ mat-paginator { padding: 0.5rem; background-color: var(--sg-card-bg); border: 1px solid var(--sg-border); - transition: transform 0.3s ease; display: flex; flex-direction: column; gap: 0.5rem; &:hover { cursor: pointer; - transform: scale(1.03); } mat-card-title { diff --git a/webapp/src/app/modules/patents/patents.component.ts b/webapp/src/app/modules/patents/patents.component.ts index abd3d722..07b7045f 100644 --- a/webapp/src/app/modules/patents/patents.component.ts +++ b/webapp/src/app/modules/patents/patents.component.ts @@ -1,16 +1,12 @@ -import { Component, OnInit, inject } from '@angular/core'; +import { Component, DestroyRef, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatInputModule } from '@angular/material/input'; -import { MatPaginatorModule, PageEvent } from '@angular/material/paginator'; import { MatChipListboxChange, MatChipsModule } from '@angular/material/chips'; import { MatDividerModule } from '@angular/material/divider'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { debounceTime, distinctUntilChanged, Subject } from 'rxjs'; import { PatentsService } from '../../api/api/patents.service'; import { PatentEntry } from '../../api/model/patentEntry'; import { IpcClassification } from '../../api'; @@ -22,6 +18,10 @@ import { classificationSectionColor, topicHierarchyColor, } from '../../resolvers/utils/topic-colors'; +import { + CardSearchComponent, + Page, +} from '../../shared/ui/card-search/card-search.component'; type PatentSource = 'EPO' | 'USPTO'; @@ -48,32 +48,30 @@ const MIN_YEAR = 1978; MatIconModule, MatButtonModule, MatCardModule, - MatFormFieldModule, - MatInputModule, - MatPaginatorModule, MatChipsModule, MatDividerModule, TopicChipComponent, LoadingComponent, YearRangeSliderComponent, + CardSearchComponent, ], templateUrl: './patents.component.html', styleUrl: './patents.component.scss', }) -export class PatentsComponent implements OnInit { +export class PatentsComponent { private router = inject(Router); private route = inject(ActivatedRoute); private patentsApi = inject(PatentsService); + private destroyRef = inject(DestroyRef); patents: PatentEntry[] = []; total = 0; - page = 0; + pageIndex = 0; pageSize = 10; loading = true; error = false; - searchTerm = ''; selectedSources: PatentSource[] = ['EPO', 'USPTO']; sortDirection: string = 'asc'; @@ -83,49 +81,45 @@ export class PatentsComponent implements OnInit { selectedStartYear = MIN_YEAR; selectedEndYear = new Date().getFullYear(); - private searchSubject = new Subject(); - showDetail = false; selectedPatent: PatentEntry | null = null; readonly expandedClassificationKeys = new Set(); constructor() { - this.searchSubject - .pipe(debounceTime(300), distinctUntilChanged(), takeUntilDestroyed()) - .subscribe((term) => { - this.searchTerm = term; - this.page = 0; - this.loadPatents(); - this.updateQueryParams(); + this.route.queryParams + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((qp) => { + this.pageIndex = parseInt(qp['page'] ?? '0', 10) || 0; + this.pageSize = parseInt(qp['size'] ?? '10', 10) || 10; + const sourcesParam = qp['sources']; + this.selectedSources = ((sourcesParam ?? 'EPO,USPTO') as string) + .split(',') + .filter((s): s is PatentSource => s === 'EPO' || s === 'USPTO'); + const d = qp['sort_direction']; + this.sortDirection = d === 'asc' || d === 'desc' ? d : 'asc'; + const sy = parseInt(qp['year_from'] ?? '', 10); + const ey = parseInt(qp['year_to'] ?? '', 10); + this.selectedStartYear = isNaN(sy) ? this.minYear : sy; + this.selectedEndYear = isNaN(ey) ? this.maxYear : ey; + + this.loadPatents(qp['search'] ?? ''); }); } - ngOnInit(): void { - const qp = this.route.snapshot.queryParamMap; - this.searchTerm = qp.get('search') ?? ''; - this.page = parseInt(qp.get('page') ?? '0', 10); - this.pageSize = parseInt(qp.get('size') ?? '10', 10); - const sourcesParam = qp.get('sources'); - this.selectedSources = (sourcesParam ?? 'EPO,USPTO') - .split(',') - .filter((s): s is PatentSource => s === 'EPO' || s === 'USPTO'); - const d = qp.get('sort_direction'); - if (d === 'asc' || d === 'desc') this.sortDirection = d; - const sy = parseInt(qp.get('year_from') ?? '', 10); - const ey = parseInt(qp.get('year_to') ?? '', 10); - if (!isNaN(sy)) this.selectedStartYear = sy; - if (!isNaN(ey)) this.selectedEndYear = ey; - - this.loadPatents(); + cardSearchPage(): Page { + return { + page: this.pageIndex, + size: this.pageSize, + total: this.total, + elements: this.patents, + }; } onYearRangeChange(): void { - this.page = 0; - this.loadPatents(); this.updateQueryParams(); } - private loadPatents(): void { + private loadPatents(searchTerm: string): void { if (this.selectedSources.length === 0) { this.patents = []; this.total = 0; @@ -141,9 +135,9 @@ export class PatentsComponent implements OnInit { this.patentsApi .getAllPatents( - this.page, + this.pageIndex, this.pageSize, - this.searchTerm || undefined, + searchTerm || undefined, source, 'date', this.sortDirection, @@ -163,37 +157,16 @@ export class PatentsComponent implements OnInit { }); } - onSearchInput(event: Event): void { - this.searchSubject.next((event.target as HTMLInputElement).value); - } - - clearSearch(): void { - this.searchTerm = ''; - this.page = 0; - this.loadPatents(); - this.updateQueryParams(); - } - handleSourceChipChange(change: MatChipListboxChange): void { const selected = change.value as PatentSource[]; // Deselecting every chip resets back to "all sources", mirroring the // project-type filter's behavior instead of showing an empty state. this.selectedSources = selected.length ? selected : ['EPO', 'USPTO']; - this.page = 0; - this.loadPatents(); this.updateQueryParams(); } setSortDirection(direction: string): void { this.sortDirection = direction; - this.loadPatents(); - this.updateQueryParams(); - } - - handlePageChange(event: PageEvent): void { - this.page = event.pageIndex; - this.pageSize = event.pageSize; - this.loadPatents(); this.updateQueryParams(); } @@ -217,8 +190,7 @@ export class PatentsComponent implements OnInit { this.router.navigate([], { relativeTo: this.route, queryParams: { - search: this.searchTerm || null, - page: this.page, + page: 0, size: this.pageSize, sources: this.selectedSources.length ? this.selectedSources.join(',') diff --git a/webapp/src/app/modules/person-funding/person-funding.component.html b/webapp/src/app/modules/person-funding/person-funding.component.html index 70bec121..4a1f7a3e 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.html +++ b/webapp/src/app/modules/person-funding/person-funding.component.html @@ -44,95 +44,45 @@ - - - - - - - - - - - - @for (funder of getPagedFunders(); track funder.funder_id) { - - - - - - - - } - -
- Förderer - @if (sortColumn === 'name') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Publikationen - @if (sortColumn === 'publications') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Erstautor - @if (sortColumn === 'first') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Mitautor - @if (sortColumn === 'middle') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } - - Letztautor - @if (sortColumn === 'last') { - {{ - sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' - }} - } -
{{ funder.funder_name }}{{ getPublicationCount(funder) }} - {{ funder.author_position_count.first || 0 }} - - {{ funder.author_position_count.middle || 0 }} - - {{ funder.author_position_count.last || 0 }} -
+ + + + + + + + {{ getPublicationCount(funder) }} + + + + {{ + funder.author_position_count.first || 0 + }} + + + + {{ + funder.author_position_count.middle || 0 + }} + + + + {{ + funder.author_position_count.last || 0 + }} + + >('nameTmp'); + countTmp = viewChild.required>('countTmp'); + firstTmp = viewChild.required>('firstTmp'); + middleTmp = viewChild.required>('middleTmp'); + lastTmp = viewChild.required>('lastTmp'); + + columns(): GenericColumn[] { + return [ + { + id: 'name', + header: 'Förderer', + type: 'accessor', + accessorKey: 'funder_name', + cellTemplate: this.nameTmp(), + }, + { + id: 'publications', + header: 'Publikationen', + type: 'accessor', + accessorKey: 'publication_count', + cellTemplate: this.countTmp(), + }, + { + id: 'first', + header: 'Erstautor', + type: 'display', + cellTemplate: this.firstTmp(), + }, + { + id: 'middle', + header: 'Mitautor', + type: 'display', + cellTemplate: this.middleTmp(), + }, + { + id: 'last', + header: 'Letztautor', + type: 'display', + cellTemplate: this.lastTmp(), + }, + ]; + } + + isSelectedFunder(funder: any): boolean { + return this.selectedFunder === funder; + } + + onSortChange(sort: Sort): void { + if (!sort.direction || !this.isValidSortColumn(sort.active)) { + return; + } + this.sortColumn = sort.active; + this.sortDirection = sort.direction; + this.applyFilter(); + this.updateQueryParams(); + } + ngOnInit(): void { this.route.parent?.paramMap.subscribe((params) => { const authorId = params.get('id') ?? ''; From e37f636236eb2293bb0ac772113d3976b6e22cf7 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sat, 15 Aug 2026 12:24:21 +0200 Subject: [PATCH 24/27] feat(news-keyword-search): expand rows to show article excerpt and highlight keyword in topic color. --- .../news-results/news-results.component.html | 53 +++++++- .../news-results/news-results.component.scss | 50 +++++-- .../news-results/news-results.component.ts | 73 ++++++++++ .../news-detail/news-detail.component.scss | 36 ----- .../news-detail/news-detail.component.ts | 57 ++------ .../app/resolvers/utils/keyword-highlight.ts | 126 ++++++++++++++++++ webapp/src/styles.scss | 41 ++++++ 7 files changed, 338 insertions(+), 98 deletions(-) create mode 100644 webapp/src/app/resolvers/utils/keyword-highlight.ts diff --git a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html index fa8728fe..b054c67b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html @@ -39,13 +39,47 @@ } + + @if (article.snippet) { + @let expanded = isSnippetExpanded(article); + + } + +
- + {{ article.maintitle || 'Kein Titel' }} - @if (article.snippet) { - +
+
+ + +
+ @if (snippetHtml().get(article.id); as snippet) { + Fundstelle im Artikel + + } @else { + + Für diesen Artikel liegt keine Textstelle zu den gesuchten Keywords + vor. + }
@@ -86,7 +120,10 @@ @let visibleTopics = topicsExpanded ? topics : topics.slice(0, topicPreviewCount); -
+
@for (topic of visibleTopics; track topic.id ?? topic.display_name) { + matTooltip="Details anzeigen" + (click)="$event.stopPropagation()"> open_in_new @@ -141,7 +179,10 @@
} @else {
- +
(); @@ -136,13 +143,22 @@ export class KeywordsToNewsResultsComponent { return baseTopicIds.length > 0 || this.selectedTopicIds().length > 0; }); + expandTmp = viewChild.required>('expandTmp'); titleTmp = viewChild.required>('titleTmp'); dateTmp = viewChild.required>('dateTmp'); relevanceTmp = viewChild.required>('relevanceTmp'); topicsTmp = viewChild.required>('topicsTmp'); actionsTmp = viewChild.required>('actionsTmp'); + private readonly dataTable = viewChild(DataTableComponent); + readonly columns = computed[]>(() => [ + { + id: 'expand', + header: '', + type: 'display', + cellTemplate: this.expandTmp(), + }, { id: 'maintitle', header: 'Titel', @@ -222,6 +238,63 @@ export class KeywordsToNewsResultsComponent { return !!topic.id && this.selectedTopicIds().includes(topic.id); } + isSnippetExpanded(article: NewsResult): boolean { + return this.dataTable()?.expandedElement() === article; + } + + readonly snippetHtml = computed(() => { + const byArticleId = new Map(); + + for (const article of this.elements()) { + const html = this.buildSnippetHtml(article); + if (html !== null) { + byArticleId.set( + article.id, + this.sanitizer.bypassSecurityTrustHtml(html), + ); + } + } + + return byArticleId; + }); + + private buildSnippetHtml(article: NewsResult): string | null { + const snippet = article.snippet; + if (!snippet) { + return null; + } + + const keywordColors = topicKeywordColors(article.topics); + const searchMatch = /([\s\S]*?)<\/em>/g; + + let html = ''; + let lastIndex = 0; + let match: RegExpExecArray | null; + + while ((match = searchMatch.exec(snippet)) !== null) { + html += escapeHtml( + this.decodeHtml(snippet.slice(lastIndex, match.index)), + ); + html += `${highlightKeywords( + this.decodeHtml(match[1]), + keywordColors, + )}`; + + lastIndex = searchMatch.lastIndex; + } + + return html + escapeHtml(this.decodeHtml(snippet.slice(lastIndex))); + } + + private decodeHtml(value: string): string { + return value + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/&#(?:39|x27);/g, "'") + .replace(/&/g, '&'); + } + isTopicsExpanded(article: NewsResult): boolean { return this.expandedTopicsIds().has(article.id); } diff --git a/webapp/src/app/modules/news-detail/news-detail.component.scss b/webapp/src/app/modules/news-detail/news-detail.component.scss index 1d31ab79..a3aaa6c7 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.scss +++ b/webapp/src/app/modules/news-detail/news-detail.component.scss @@ -586,39 +586,3 @@ main { --topic-bg: color-mix(in srgb, var(--sg-error) 8%, var(--sg-color-mix-base)); --topic-color: var(--sg-error); } - -// ── Keyword highlights in article text ─────────────────────────────────────── - -@keyframes kw-flash { - 0% { - background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); - } - 40% { - background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); - } - 100% { - background: transparent; - } -} - -:host ::ng-deep .kw-mark { - background: transparent; - color: var(--t); - text-decoration: underline; - text-decoration-color: var(--t); - text-decoration-style: solid; - text-decoration-thickness: 2px; - text-underline-offset: 2px; - font-weight: inherit; - border-radius: 2px; - padding: 0 1px; - transition: background 0.15s; - - &:hover { - background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); - } - - &.kw-flash { - animation: kw-flash 2.4s ease-out forwards; - } -} diff --git a/webapp/src/app/modules/news-detail/news-detail.component.ts b/webapp/src/app/modules/news-detail/news-detail.component.ts index fdbb74f9..039c7feb 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.ts +++ b/webapp/src/app/modules/news-detail/news-detail.component.ts @@ -16,6 +16,10 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { WorksService } from '../../api'; import { topicHierarchyColor } from '../../resolvers/utils/topic-colors'; +import { + highlightKeywords, + topicKeywordColors, +} from '../../resolvers/utils/keyword-highlight'; import { LoadingComponent } from '../../shared/ui/loading/loading.component'; interface MentionedPerson { @@ -187,53 +191,12 @@ export class NewsDetailComponent implements OnInit { private buildHighlightedContent(article: NewsArticleDetail): SafeHtml { const text = article.full_content; if (!text) return this.sanitizer.bypassSecurityTrustHtml(''); - const keywords = article.keywords ?? []; - const keywordColorMap = new Map(); - for (const topic of article.topics ?? []) { - if (topic.source_keyword) { - keywordColorMap.set( - topic.source_keyword.toLowerCase(), - this.getTopicColor(topic), - ); - } - } - - let html = this.escapeHtml(text); - [...keywords] - .sort((a, b) => b.length - a.length) - .forEach((kw) => { - const color = keywordColorMap.get(kw.toLowerCase()); - if (!color) return; - const kwHtml = this.escapeHtml(kw); - const escaped = this.escapeRegex(kwHtml); - const before = '(?$1`, - ); - }); - return this.sanitizer.bypassSecurityTrustHtml(html); - } - - private escapeHtml(text: string): string { - return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - - private escapeRegex(text: string): string { - return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + return this.sanitizer.bypassSecurityTrustHtml( + highlightKeywords( + text, + topicKeywordColors(article.topics, article.keywords), + ), + ); } } diff --git a/webapp/src/app/resolvers/utils/keyword-highlight.ts b/webapp/src/app/resolvers/utils/keyword-highlight.ts new file mode 100644 index 00000000..e261e496 --- /dev/null +++ b/webapp/src/app/resolvers/utils/keyword-highlight.ts @@ -0,0 +1,126 @@ +import { MatchedTopic } from '../../api'; +import { topicHierarchyColor } from './topic-colors'; + +/** A keyword together with the colour of the topic it resolved to. */ +export interface KeywordColor { + keyword: string; + color: string; +} + +/** Pairs every keyword that resolved to a topic with that topic's colour. */ +export function topicKeywordColors( + topics: readonly MatchedTopic[] | null | undefined, + keywords?: readonly string[] | null, +): KeywordColor[] { + const colorByKeyword = new Map(); + + for (const topic of topics ?? []) { + if (!topic.source_keyword) { + continue; + } + + colorByKeyword.set( + topic.source_keyword.toLowerCase(), + topicHierarchyColor({ + id: topic.id, + name: topic.display_name, + field_name: topic.field_name, + domain_name: topic.domain_name, + }), + ); + } + + const source = + keywords ?? + (topics ?? []) + .map((topic) => topic.source_keyword) + .filter((keyword): keyword is string => !!keyword); + + const seen = new Set(); + const result: KeywordColor[] = []; + + for (const keyword of source) { + const key = keyword.toLowerCase(); + const color = colorByKeyword.get(key); + if (!color || seen.has(key)) { + continue; + } + seen.add(key); + result.push({ keyword, color }); + } + + return result; +} + +const WORD_CHAR = '[\\w\\u00C0-\\u024F]'; + +/** + * Escapes `text` and wraps every occurrence of a keyword in a `` carrying + * the keyword's topic colour in `--t`. + */ +export function highlightKeywords( + text: string, + keywordColors: readonly KeywordColor[], +): string { + const sorted = [...keywordColors] + .filter(({ keyword }) => keyword.trim()) + .sort((a, b) => b.keyword.length - a.keyword.length); + + if (!sorted.length) { + return escapeHtml(text); + } + + // Acronyms are matched exactly, everything else may carry an inflection + // ("Gründung" also marks "Gründungen"). + const alternatives = sorted.map(({ keyword }) => + isAcronymLike(keyword) + ? `${escapeRegex(keyword)}(?!${WORD_CHAR})` + : `${escapeRegex(keyword)}${WORD_CHAR}*`, + ); + const pattern = new RegExp( + `(? + matched.toLowerCase().startsWith(keyword.toLowerCase()), + ); + if (!entry) { + continue; + } + + html += escapeHtml(text.slice(lastIndex, match.index)); + html += + `${escapeHtml(matched)}`; + + lastIndex = match.index + matched.length; + } + + return html + escapeHtml(text.slice(lastIndex)); +} + +export function escapeHtml(text: string): string { + return text + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); +} + +function escapeRegex(text: string): string { + return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +function isAcronymLike(keyword: string): boolean { + return ( + keyword.length <= 3 || + (keyword === keyword.toUpperCase() && keyword !== keyword.toLowerCase()) + ); +} diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index 6d39dd4b..1655ff86 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -627,3 +627,44 @@ html.dark-theme { flex-shrink: 0; transition: transform 0.3s ease; } + +/* Keyword highlight */ +@keyframes kw-flash { + 0% { + background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); + } + 40% { + background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); + } + 100% { + background: transparent; + } +} + +.kw-mark { + background: transparent; + color: var(--t); + text-decoration: underline; + text-decoration-color: var(--t); + text-decoration-style: solid; + text-decoration-thickness: 2px; + text-underline-offset: 2px; + font-weight: inherit; + border-radius: 2px; + padding: 0 1px; + transition: background 0.15s; + + &:hover { + background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); + } + + &.kw-flash { + animation: kw-flash 2.4s ease-out forwards; + } +} + +.search-mark { + background: transparent; + color: var(--sg-blue-highlight); + font-weight: 700; +} From bd581e60049ae73a30efacb654116bb5706c1b53 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sat, 15 Aug 2026 15:27:31 +0200 Subject: [PATCH 25/27] refactor(news-keyword-search): refactor keyword highlighting to show tooltips --- .../news-results/news-results.component.html | 19 +++- .../news-results/news-results.component.scss | 17 ++- .../news-results/news-results.component.ts | 73 ++++++++---- .../app/resolvers/utils/keyword-highlight.ts | 104 ++++++++++++++---- webapp/src/styles.scss | 7 +- 5 files changed, 166 insertions(+), 54 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html index b054c67b..c9c04f61 100644 --- a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.html @@ -72,9 +72,24 @@
- @if (snippetHtml().get(article.id); as snippet) { + @if (snippetSegments().get(article.id); as segments) { Fundstelle im Artikel - +

+ @for (segment of segments; track $index) { + @if (segment.isSearchMatch) { + {{ segment.text }} + } @else { + {{ segment.text }} + } + } +

} @else { Für diesen Artikel liegt keine Textstelle zu den gesuchten Keywords diff --git a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss index 1f618a6f..c21d48b3 100644 --- a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss @@ -151,14 +151,29 @@ text-transform: uppercase; } -/* .kw-mark / .search-mark inside are styled globally in styles.scss. */ .snippet { + margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--sg-text-secondary); overflow-wrap: anywhere; } +.snippet-mark { + background: transparent; + color: var(--sg-blue-highlight); + font-weight: 700; + cursor: help; + + &.has-topic { + color: var(--t); + text-decoration: underline; + text-decoration-color: var(--t); + text-decoration-thickness: 2px; + text-underline-offset: 2px; + } +} + .date-text { white-space: nowrap; } diff --git a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.ts index 27d1a15a..b3b84983 100644 --- a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.ts @@ -9,7 +9,6 @@ import { viewChild, } from '@angular/core'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; @@ -34,13 +33,20 @@ import { keywordsNewsQueryParamKeys } from '../../../../resolvers/keywords-news- import { SearchResultsStateService } from '../search-results-state.service'; import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component'; import { - escapeHtml, - highlightKeywords, + keywordTooltip, + splitByKeywords, topicKeywordColors, } from '../../../../resolvers/utils/keyword-highlight'; type NewsResult = NewsPage['results'][number]; +interface SnippetSegment { + text: string; + color: string | null; + tooltip: string | null; + isSearchMatch: boolean; +} + @Component({ selector: 'app-news-results', imports: [ @@ -66,7 +72,6 @@ export class KeywordsToNewsResultsComponent { private readonly route = inject(ActivatedRoute); private readonly router = inject(Router); private readonly destroyRef = inject(DestroyRef); - private readonly sanitizer = inject(DomSanitizer); newsPage = input.required(); @@ -242,48 +247,70 @@ export class KeywordsToNewsResultsComponent { return this.dataTable()?.expandedElement() === article; } - readonly snippetHtml = computed(() => { - const byArticleId = new Map(); + readonly snippetSegments = computed(() => { + const byArticleId = new Map(); for (const article of this.elements()) { - const html = this.buildSnippetHtml(article); - if (html !== null) { - byArticleId.set( - article.id, - this.sanitizer.bypassSecurityTrustHtml(html), - ); + const segments = this.buildSnippetSegments(article); + if (segments.length) { + byArticleId.set(article.id, segments); } } return byArticleId; }); - private buildSnippetHtml(article: NewsResult): string | null { + private buildSnippetSegments(article: NewsResult): SnippetSegment[] { const snippet = article.snippet; if (!snippet) { - return null; + return []; } const keywordColors = topicKeywordColors(article.topics); const searchMatch = /([\s\S]*?)<\/em>/g; - let html = ''; + const segments: SnippetSegment[] = []; let lastIndex = 0; let match: RegExpExecArray | null; + const pushPlain = (raw: string) => { + const text = this.decodeHtml(raw); + if (text) { + segments.push({ + text, + color: null, + tooltip: null, + isSearchMatch: false, + }); + } + }; + while ((match = searchMatch.exec(snippet)) !== null) { - html += escapeHtml( - this.decodeHtml(snippet.slice(lastIndex, match.index)), - ); - html += `${highlightKeywords( - this.decodeHtml(match[1]), - keywordColors, - )}`; + pushPlain(snippet.slice(lastIndex, match.index)); + + const term = this.decodeHtml(match[1]); + const parts = splitByKeywords(term, keywordColors); + const hasTopic = parts.some((part) => part.match); + + for (const part of parts) { + segments.push({ + text: part.text, + color: part.match?.color ?? null, + tooltip: part.match + ? keywordTooltip(part.match.keyword, part.match.topicNames) + : hasTopic + ? null + : keywordTooltip(term, []), + isSearchMatch: true, + }); + } lastIndex = searchMatch.lastIndex; } - return html + escapeHtml(this.decodeHtml(snippet.slice(lastIndex))); + pushPlain(snippet.slice(lastIndex)); + + return segments; } private decodeHtml(value: string): string { diff --git a/webapp/src/app/resolvers/utils/keyword-highlight.ts b/webapp/src/app/resolvers/utils/keyword-highlight.ts index e261e496..b22ec493 100644 --- a/webapp/src/app/resolvers/utils/keyword-highlight.ts +++ b/webapp/src/app/resolvers/utils/keyword-highlight.ts @@ -1,10 +1,11 @@ import { MatchedTopic } from '../../api'; import { topicHierarchyColor } from './topic-colors'; -/** A keyword together with the colour of the topic it resolved to. */ +/** A keyword together with the colour and names of the topics it resolved to. */ export interface KeywordColor { keyword: string; color: string; + topicNames: string[]; } /** Pairs every keyword that resolved to a topic with that topic's colour. */ @@ -12,22 +13,33 @@ export function topicKeywordColors( topics: readonly MatchedTopic[] | null | undefined, keywords?: readonly string[] | null, ): KeywordColor[] { - const colorByKeyword = new Map(); + const byKeyword = new Map>(); for (const topic of topics ?? []) { if (!topic.source_keyword) { continue; } - colorByKeyword.set( - topic.source_keyword.toLowerCase(), - topicHierarchyColor({ + const key = topic.source_keyword.toLowerCase(); + const topicName = topic.display_name?.trim(); + const existing = byKeyword.get(key); + + if (existing) { + if (topicName && !existing.topicNames.includes(topicName)) { + existing.topicNames.push(topicName); + } + continue; + } + + byKeyword.set(key, { + color: topicHierarchyColor({ id: topic.id, name: topic.display_name, field_name: topic.field_name, domain_name: topic.domain_name, }), - ); + topicNames: topicName ? [topicName] : [], + }); } const source = @@ -41,33 +53,52 @@ export function topicKeywordColors( for (const keyword of source) { const key = keyword.toLowerCase(); - const color = colorByKeyword.get(key); - if (!color || seen.has(key)) { + const entry = byKeyword.get(key); + if (!entry || seen.has(key)) { continue; } seen.add(key); - result.push({ keyword, color }); + result.push({ keyword, ...entry }); } return result; } +/** Explains, for a mark in the text, which topics its keyword is assigned to. */ +export function keywordTooltip( + keyword: string, + topicNames: readonly string[], +): string { + if (!topicNames.length) { + return `„${keyword}“ ist keinem der aufgelisteten Themen zugeordnet.`; + } + + if (topicNames.length === 1) { + return `„${keyword}“ ist dem Thema „${topicNames[0]}“ zugeordnet.`; + } + + const names = topicNames.map((name) => `„${name}“`).join(', '); + return `„${keyword}“ ist den Themen ${names} zugeordnet.`; +} + const WORD_CHAR = '[\\w\\u00C0-\\u024F]'; -/** - * Escapes `text` and wraps every occurrence of a keyword in a `` carrying - * the keyword's topic colour in `--t`. - */ -export function highlightKeywords( +export const KW_MARK_CLASS = 'kw-mark'; + +export interface KeywordSegment { + text: string; + match: KeywordColor | null; +} +export function splitByKeywords( text: string, keywordColors: readonly KeywordColor[], -): string { +): KeywordSegment[] { const sorted = [...keywordColors] .filter(({ keyword }) => keyword.trim()) .sort((a, b) => b.keyword.length - a.keyword.length); if (!sorted.length) { - return escapeHtml(text); + return text ? [{ text, match: null }] : []; } // Acronyms are matched exactly, everything else may carry an inflection @@ -82,10 +113,16 @@ export function highlightKeywords( 'gi', ); - let html = ''; + const segments: KeywordSegment[] = []; let lastIndex = 0; let match: RegExpExecArray | null; + const pushPlain = (value: string) => { + if (value) { + segments.push({ text: value, match: null }); + } + }; + while ((match = pattern.exec(text)) !== null) { const matched = match[0]; const entry = sorted.find(({ keyword }) => @@ -95,15 +132,38 @@ export function highlightKeywords( continue; } - html += escapeHtml(text.slice(lastIndex, match.index)); - html += - `${escapeHtml(matched)}`; + pushPlain(text.slice(lastIndex, match.index)); + segments.push({ text: matched, match: entry }); lastIndex = match.index + matched.length; } - return html + escapeHtml(text.slice(lastIndex)); + pushPlain(text.slice(lastIndex)); + + return segments; +} + +export function highlightKeywords( + text: string, + keywordColors: readonly KeywordColor[], +): string { + return splitByKeywords(text, keywordColors) + .map(({ text: value, match }) => { + if (!match) { + return escapeHtml(value); + } + + const tooltip = escapeHtml( + keywordTooltip(match.keyword, match.topicNames), + ); + + return ( + `` + + `${escapeHtml(value)}` + ); + }) + .join(''); } export function escapeHtml(text: string): string { diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index 1655ff86..05b08f35 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -652,6 +652,7 @@ html.dark-theme { font-weight: inherit; border-radius: 2px; padding: 0 1px; + cursor: help; transition: background 0.15s; &:hover { @@ -662,9 +663,3 @@ html.dark-theme { animation: kw-flash 2.4s ease-out forwards; } } - -.search-mark { - background: transparent; - color: var(--sg-blue-highlight); - font-weight: 700; -} From da9516331ef0572719f8f3f447cc3ee0dbc3cd58 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sat, 15 Aug 2026 20:05:54 +0200 Subject: [PATCH 26/27] feat(news-keyword-search): align table content to the left --- .../search-results/news-results/news-results.component.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss index c21d48b3..117b1e3a 100644 --- a/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss +++ b/webapp/src/app/modules/keywords-search/search-results/news-results/news-results.component.scss @@ -76,12 +76,6 @@ } ::ng-deep .table-wrap { - .mat-column-date, - .mat-column-relevant, - .mat-mdc-header-cell { - text-align: center; - } - .mat-column-topics { overflow: visible; } From ef2ea4688248135b3b786157cef8e83dca81dfa3 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sat, 15 Aug 2026 20:48:39 +0200 Subject: [PATCH 27/27] refactor(news): move keyword highlighting back to news details --- .../news-detail/news-detail.component.scss | 35 ++++++++++++++++++ webapp/src/styles.scss | 36 ------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/webapp/src/app/modules/news-detail/news-detail.component.scss b/webapp/src/app/modules/news-detail/news-detail.component.scss index a3aaa6c7..4b091f89 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.scss +++ b/webapp/src/app/modules/news-detail/news-detail.component.scss @@ -586,3 +586,38 @@ main { --topic-bg: color-mix(in srgb, var(--sg-error) 8%, var(--sg-color-mix-base)); --topic-color: var(--sg-error); } + +@keyframes kw-flash { + 0% { + background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); + } + 40% { + background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); + } + 100% { + background: transparent; + } +} + +:host ::ng-deep .kw-mark { + background: transparent; + color: var(--t); + text-decoration: underline; + text-decoration-color: var(--t); + text-decoration-style: solid; + text-decoration-thickness: 2px; + text-underline-offset: 2px; + font-weight: inherit; + border-radius: 2px; + padding: 0 1px; + cursor: help; + transition: background 0.15s; + + &:hover { + background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); + } + + &.kw-flash { + animation: kw-flash 2.4s ease-out forwards; + } +} diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index 05b08f35..6d39dd4b 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -627,39 +627,3 @@ html.dark-theme { flex-shrink: 0; transition: transform 0.3s ease; } - -/* Keyword highlight */ -@keyframes kw-flash { - 0% { - background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); - } - 40% { - background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); - } - 100% { - background: transparent; - } -} - -.kw-mark { - background: transparent; - color: var(--t); - text-decoration: underline; - text-decoration-color: var(--t); - text-decoration-style: solid; - text-decoration-thickness: 2px; - text-underline-offset: 2px; - font-weight: inherit; - border-radius: 2px; - padding: 0 1px; - cursor: help; - transition: background 0.15s; - - &:hover { - background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); - } - - &.kw-flash { - animation: kw-flash 2.4s ease-out forwards; - } -}