Add centralized patent detail page with backend lookup by ID
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit

Introduce /patent/:patentId and a dedicated detail view modeled after
publications, backed by GET /api/inse-service/patents/{patent_id}.
Route patent overview and detail actions from list, person, and
institution views to the shared page instead of inline detail panels.
This commit is contained in:
2026-06-27 18:53:55 +02:00
parent 6fc491fd87
commit f5991ef660
15 changed files with 1259 additions and 1170 deletions
+54 -1
View File
@@ -3,6 +3,7 @@ import asyncio
import httpx
from fastapi import HTTPException
from starlette.status import HTTP_404_NOT_FOUND
from starlette.status import HTTP_502_BAD_GATEWAY
from starlette.status import HTTP_503_SERVICE_UNAVAILABLE
@@ -82,4 +83,56 @@ async def get_all_patents(
page=page,
size=size,
patents=patents,
)
)
def _parse_patent_id(patent_id: str) -> tuple[str, str]:
normalized = patent_id.strip().upper()
if normalized.startswith("EP"):
return "EPO", normalized.removeprefix("EP")
if normalized.startswith("US"):
return "USPTO", normalized.removeprefix("US")
raise HTTPException(
status_code=HTTP_404_NOT_FOUND,
detail="Patent not found.",
)
async def get_patent_by_id(
patent_id: str,
ipc_client: IpcSearchClient | None = None,
) -> model.PatentEntry:
source, number = _parse_patent_id(patent_id)
all_patents_client = AllPatentsSearchClient()
ipc_search_client = ipc_client or IpcSearchClient()
try:
if source == "EPO":
data = await all_patents_client.search_epo(
all_patents_client.epo_detail_query(number)
)
patents = parse_epo_hits(data)
else:
data = await all_patents_client.search_uspto(
all_patents_client.uspto_detail_query(number)
)
patents = parse_uspto_hits(data)
except MissingApiKeyError as exc:
raise HTTPException(
status_code=HTTP_503_SERVICE_UNAVAILABLE,
detail="Patent search is not configured.",
) from exc
except httpx.HTTPError as exc:
raise HTTPException(
status_code=HTTP_502_BAD_GATEWAY,
detail="Patent search request failed.",
) from exc
if not patents:
raise HTTPException(
status_code=HTTP_404_NOT_FOUND,
detail="Patent not found.",
)
await enrich_patents_classifications(patents, ipc_search_client)
return patents[0]
+11 -1
View File
@@ -32,4 +32,14 @@ async def get_all_patents(
sort_direction=sort_direction,
year_from=year_from,
year_to=year_to,
)
)
@router.get(
"/patents/{patent_id}",
operation_id="getPatentById",
response_model=model.PatentEntry,
summary="Get a single patent by its identifier.",
)
async def get_patent_by_id(patent_id: str):
return await logic.get_patent_by_id(patent_id)
@@ -154,6 +154,30 @@ class AllPatentsSearchClient:
"query": query,
}
def epo_detail_query(self, doc_number: str) -> dict[str, Any]:
return {
"size": 1,
"_source": [
"doc_number", "country", "kind", "date_publication",
"date_publication_year", "application_number",
"application_filing_date", "title_en", "title_de",
"abstract", "inventors_name", "applicants_name", "ipc", "cpc",
],
"query": {"term": {"doc_number": doc_number}},
}
def uspto_detail_query(self, publication_number: str) -> dict[str, Any]:
return {
"size": 1,
"_source": [
"publication_number", "country", "publication_date",
"publication_year", "application_number", "application_date",
"application_type", "title", "abstract", "inventors_names",
"assignees_orgs", "ipcr", "cpc", "number_of_claims", "status",
],
"query": {"term": {"publication_number": publication_number}},
}
async def search_epo(self, payload: dict[str, Any]) -> dict[str, Any]:
return await self._search(EPO_INDEX, payload)
+21
View File
@@ -257,4 +257,25 @@ export class PatentsService extends BaseService {
},
);
}
public getPatentById(patentId: string): Observable<PatentEntry> {
const localVarHeaders = this.defaultHeaders;
const { basePath, withCredentials } = this.configuration;
const localVarPath = `/api/inse-service/patents/${this.configuration.encodeParam(
{
name: 'patentId',
value: patentId,
in: 'path',
style: 'simple',
explode: false,
dataType: 'string',
dataFormat: undefined,
},
)}`;
return this.httpClient.get<PatentEntry>(`${basePath}${localVarPath}`, {
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
});
}
}
+8
View File
@@ -77,6 +77,14 @@ export const routes: Routes = [
(mod) => mod.PublicationDetailComponent,
),
},
{
path: 'patent/:patentId',
canActivate: [userGuard],
loadComponent: () =>
import('./modules/patent-detail/patent-detail.component').then(
(mod) => mod.PatentDetailComponent,
),
},
{
path: 'projects/dfg/:id',
canActivate: [userGuard],
@@ -6,182 +6,8 @@
<p class="message">Keine Patente gefunden.</p>
} @else {
<div class="patents-container">
<div class="patents-content">
@if (showDetail && selectedPatent) {
<div class="patent-full-detail">
<button type="button" class="back-btn" (click)="closeDetail()">
← Zurück zu den Patenten
</button>
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
@if (hasPatentMetadata(selectedPatent)) {
<div class="patent-meta patent-meta--inline">
<dl class="patent-meta__list">
@for (row of getPatentMetadataRows(selectedPatent); track row.label) {
<div class="patent-meta__row">
<dt>{{ row.label }}</dt>
<dd>
@if (row.variant === 'source') {
<span class="source-badge source-badge--{{ row.value.toLowerCase() }}">
{{ row.value }}
</span>
} @else {
{{ row.value }}
}
</dd>
</div>
}
</dl>
</div>
}
@if (selectedPatent.abstract) {
<div class="detail-section">
<h4>Abstract</h4>
<p>{{ selectedPatent.abstract }}</p>
</div>
}
<div class="detail-section">
<h4>Erfinder</h4>
<ul class="tag-list">
@for (inventor of selectedPatent.inventors; track inventor) {
<li class="tag">{{ inventor }}</li>
}
</ul>
</div>
@if (selectedPatent.assignees.length > 0) {
<div class="detail-section">
<h4>Anmelder</h4>
<ul class="tag-list">
@for (assignee of selectedPatent.assignees; track assignee) {
<li class="tag">{{ assignee }}</li>
}
</ul>
</div>
}
@if (selectedPatent.ipc_descriptions.length > 0) {
<div class="detail-section classification-section classification-section--ipc">
<h4>Klassifikation (IPC)</h4>
<div class="classification-cards">
@for (card of getClassificationCards(selectedPatent.ipc_descriptions, 'IPC'); track card.key) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">{{ card.system }}</span>
<span class="classification-badge classification-badge--level">{{ card.levelLabel }}</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{ isClassificationExpanded(card.key) ? 'Weniger anzeigen' : 'Mehr anzeigen' }}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.ipc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (IPC)</h4>
<ul class="tag-list tag-list--compact">
@for (ipc of selectedPatent.ipc; track ipc) {
<li class="tag">{{ ipc }}</li>
}
</ul>
</div>
}
@if (selectedPatent.cpc_descriptions.length > 0) {
<div class="detail-section classification-section classification-section--cpc">
<h4>Klassifikation (CPC)</h4>
<div class="classification-cards">
@for (card of getClassificationCards(selectedPatent.cpc_descriptions, 'CPC'); track card.key) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">{{ card.system }}</span>
<span class="classification-badge classification-badge--level">{{ card.levelLabel }}</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{ isClassificationExpanded(card.key) ? 'Weniger anzeigen' : 'Mehr anzeigen' }}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.cpc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (CPC)</h4>
<ul class="tag-list tag-list--compact">
@for (cpc of selectedPatent.cpc; track cpc) {
<li class="tag">{{ cpc }}</li>
}
</ul>
</div>
}
</div>
}
<div class="patents-list" [class.hidden]="showDetail">
<div class="patents-list">
<div class="patents-list-toolbar">
<label class="sort-control">
<span>Filter nach Quelle:</span>
@@ -234,7 +60,7 @@
}
</div>
@if (selectedPatent && !showDetail) {
@if (selectedPatent) {
<div class="patent-detail">
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
<div class="detail-stats">
@@ -2,28 +2,14 @@ import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { PatentsService } from '../../api/api/patents.service';
import { PatentEntry, IpcClassification } from '../../api/model/patentEntry';
import { PatentEntry } from '../../api/model/patentEntry';
import {
formatPatentDate,
getPublicationStageLabel,
} from '../patent-detail/patent-detail.utils';
type SortMode = 'date' | 'title';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type ClassificationSystem = 'IPC' | 'CPC';
interface ClassificationCard {
key: string;
symbols: string[];
system: ClassificationSystem;
levelLabel: string;
primaryDescription: string | null;
hierarchy: { label: string; value: string }[];
}
interface PatentMetadataRow {
label: string;
value: string;
variant?: 'source';
}
const DESCRIPTION_PREVIEW_LENGTH = 140;
@Component({
selector: 'app-institution-patents',
@@ -40,7 +26,6 @@ export class InstitutionPatentsComponent implements OnInit {
filteredPatents: PatentEntry[] = [];
institutionName: string | null = null;
selectedPatent: PatentEntry | null = null;
showDetail = false;
loading = true;
error = false;
@@ -50,7 +35,6 @@ export class InstitutionPatentsComponent implements OnInit {
selectedPage = 1;
readonly pageSize = 10;
private expandedClassificationKeys = new Set<string>();
ngOnInit(): void {
this.route.parent?.paramMap.subscribe((params) => {
@@ -89,7 +73,6 @@ export class InstitutionPatentsComponent implements OnInit {
this.activeFilter = filter;
this.selectedPage = 1;
this.selectedPatent = null;
this.showDetail = false;
this.applyFilter();
this.updateQueryParams();
}
@@ -102,19 +85,12 @@ export class InstitutionPatentsComponent implements OnInit {
selectPatent(patent: PatentEntry): void {
this.selectedPatent = patent;
this.showDetail = false;
this.expandedClassificationKeys.clear();
this.updateQueryParams();
}
openDetail(): void {
this.showDetail = true;
this.expandedClassificationKeys.clear();
}
closeDetail(): void {
this.showDetail = false;
this.expandedClassificationKeys.clear();
if (!this.selectedPatent) return;
this.router.navigate(['/patent', this.selectedPatent.patent_id]);
}
private applyFilter(): void {
@@ -175,9 +151,7 @@ export class InstitutionPatentsComponent implements OnInit {
}
formatDate(date: string | null): string {
if (!date) return '-';
const d = date.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3');
return new Intl.DateTimeFormat('de-DE').format(new Date(d));
return formatPatentDate(date);
}
getEpoCount(): number {
@@ -209,200 +183,6 @@ export class InstitutionPatentsComponent implements OnInit {
}
getPublicationStageLabel(patent: PatentEntry): string | null {
if (patent.kind) {
return patent.kind;
}
if (patent.application_type) {
return patent.application_type;
}
return null;
}
hasPatentMetadata(_patent: PatentEntry): boolean {
return true;
}
getPatentMetadataRows(patent: PatentEntry): PatentMetadataRow[] {
const rows: PatentMetadataRow[] = [];
rows.push({ label: 'Quelle', value: patent.source, variant: 'source' });
rows.push({ label: 'Patent-Nr.', value: patent.patent_id });
if (patent.publication_date) {
rows.push({
label: 'Veröffentlichungsdatum',
value: this.formatDate(patent.publication_date),
});
}
if (patent.application_number) {
rows.push({ label: 'Anmeldungsnummer', value: patent.application_number });
}
if (patent.application_date) {
rows.push({ label: 'Anmeldedatum', value: this.formatDate(patent.application_date) });
}
const stageLabel = this.getPublicationStageLabel(patent);
if (stageLabel) {
rows.push({
label: patent.kind ? 'Publikationsstufe' : 'Anmeldungstyp',
value: patent.kind ? stageLabel : this.formatMetadataLabel(stageLabel),
});
}
if (patent.number_of_claims != null) {
rows.push({ label: 'Ansprüche', value: String(patent.number_of_claims) });
}
if (patent.status) {
rows.push({ label: 'Status', value: this.formatMetadataLabel(patent.status) });
}
return rows;
}
private formatMetadataLabel(value: string): string {
return value
.replace(/_/g, ' ')
.toLowerCase()
.replace(/\b\w/g, (char) => char.toUpperCase());
}
getClassificationCards(
entries: IpcClassification[] | undefined,
system: ClassificationSystem,
): ClassificationCard[] {
if (!entries?.length) {
return [];
}
const merged = new Map<string, ClassificationCard>();
for (const entry of entries) {
const card = this.buildClassificationCard(entry, system);
const mergeKey =
card.primaryDescription?.toLocaleLowerCase('en') ?? card.symbols[0] ?? card.key;
const existing = merged.get(mergeKey);
if (existing) {
for (const symbol of card.symbols) {
if (!existing.symbols.includes(symbol)) {
existing.symbols.push(symbol);
}
}
continue;
}
merged.set(mergeKey, card);
}
return [...merged.values()];
}
toggleClassificationExpanded(key: string): void {
if (this.expandedClassificationKeys.has(key)) {
this.expandedClassificationKeys.delete(key);
return;
}
this.expandedClassificationKeys.add(key);
}
isClassificationExpanded(key: string): boolean {
return this.expandedClassificationKeys.has(key);
}
isLongDescription(text: string | null): boolean {
return !!text && text.length > DESCRIPTION_PREVIEW_LENGTH;
}
getDescriptionPreview(text: string | null): string {
if (!text) {
return '';
}
if (text.length <= DESCRIPTION_PREVIEW_LENGTH) {
return text;
}
return `${text.slice(0, DESCRIPTION_PREVIEW_LENGTH).trimEnd()}…`;
}
private buildClassificationCard(
entry: IpcClassification,
system: ClassificationSystem,
): ClassificationCard {
const level = this.getClassificationLevel(entry);
const primaryDescription = this.extractDescriptionText(entry[level.field]);
return {
key: `${system}-${entry.symbol}`,
symbols: [entry.symbol],
system,
levelLabel: level.label,
primaryDescription,
hierarchy: this.buildHierarchyRows(entry, primaryDescription),
};
}
private getClassificationLevel(entry: IpcClassification): {
label: string;
field: keyof IpcClassification;
} {
if (entry.subgroup) {
return { label: 'Untergruppe', field: 'subgroup' };
}
if (entry.main_group) {
return { label: 'Hauptgruppe', field: 'main_group' };
}
if (entry.subclass) {
return { label: 'Unterklasse', field: 'subclass' };
}
if (entry.section) {
return { label: 'Sektion', field: 'section' };
}
return { label: 'Code', field: 'symbol' };
}
private buildHierarchyRows(
entry: IpcClassification,
primaryDescription: string | null,
): { label: string; value: string }[] {
const rows: { label: string; value: string }[] = [];
const seen = new Set<string>();
const addRow = (label: string, raw: string | null) => {
const value = this.extractDescriptionText(raw);
if (!value) {
return;
}
const normalized = value.toLocaleLowerCase('en');
if (seen.has(normalized) || normalized === primaryDescription?.toLocaleLowerCase('en')) {
return;
}
seen.add(normalized);
rows.push({ label, value });
};
addRow('Sektion', entry.section);
addRow('Klasse', entry.class);
addRow('Unterklasse', entry.subclass);
return rows;
}
private extractDescriptionText(value: string | null | undefined): string | null {
if (!value?.trim()) {
return null;
}
const text = value.includes(' - ') ? value.split(' - ').slice(1).join(' - ').trim() : value.trim();
if (!text) {
return null;
}
const firstSentence = text.split(/[;|]/)[0]?.trim() ?? text;
return this.normalizeDescriptionCase(firstSentence);
}
private normalizeDescriptionCase(text: string): string {
if (text !== text.toUpperCase()) {
return text;
}
return text.charAt(0) + text.slice(1).toLowerCase();
return getPublicationStageLabel(patent);
}
}
@@ -0,0 +1,319 @@
<div class="detail-page">
<button
type="button"
class="back-link"
(click)="navigateBack()"
aria-label="Zurück zu den Patenten">
<mat-icon>arrow_back</mat-icon>
Alle Patente
</button>
@if (loading) {
<div class="state">
<mat-spinner diameter="42"></mat-spinner>
<p>Patent wird geladen...</p>
</div>
} @else if (notFound || !patent) {
<div class="state error-state">
<mat-icon>search_off</mat-icon>
<h2>Patent nicht gefunden</h2>
<p>Das Patent konnte nicht geladen werden.</p>
<a mat-stroked-button routerLink="/patents"> Zur Patentübersicht </a>
</div>
} @else {
<header class="hero">
<div class="hero-copy">
<div class="eyebrow">
<span class="source-badge source-badge--{{ patent.source.toLowerCase() }}">
{{ patent.source }}
</span>
@if (patent.publication_year) {
<span>{{ patent.publication_year }}</span>
}
@if (stageLabel(); as stage) {
<span>{{ stage }}</span>
}
</div>
<h1>{{ patent.title || patent.patent_id || 'Ohne Titel' }}</h1>
<p class="meta-line">
<span>{{ patent.patent_id }}</span>
@if (patent.publication_date) {
<span>· {{ formatDate(patent.publication_date) }}</span>
}
</p>
<div class="hero-actions">
@for (link of externalLinks(); track link.url; let first = $first) {
<a
[class.primary-action]="first"
[attr.mat-flat-button]="first ? '' : null"
[attr.mat-stroked-button]="first ? null : ''"
[href]="link.url"
target="_blank"
rel="noopener">
{{ link.label }}
<mat-icon>open_in_new</mat-icon>
</a>
}
</div>
</div>
<div class="metrics" aria-label="Patentkennzahlen">
<div>
<mat-icon>groups</mat-icon>
<strong>{{ patent.inventors.length }}</strong>
<span>Erfinder</span>
</div>
<div>
<mat-icon>business</mat-icon>
<strong>{{ patent.assignees.length }}</strong>
<span>Anmelder</span>
</div>
<div>
<mat-icon>category</mat-icon>
<strong>{{ patent.ipc.length + patent.cpc.length }}</strong>
<span>Klassifikationen</span>
</div>
</div>
</header>
<div class="content-grid">
<main>
@if (patent.abstract) {
<section class="card abstract-card">
<div class="section-title">
<mat-icon>subject</mat-icon>
<h2>Abstract</h2>
</div>
<p>{{ patent.abstract }}</p>
</section>
}
<section class="card">
<div class="section-title">
<mat-icon>engineering</mat-icon>
<h2>Erfinder</h2>
<span>{{ patent.inventors.length }}</span>
</div>
<div class="tags">
@for (inventor of patent.inventors; track inventor) {
<span>{{ inventor }}</span>
} @empty {
<p class="empty">Keine Angaben vorhanden.</p>
}
</div>
</section>
@if (patent.assignees.length > 0) {
<section class="card">
<div class="section-title">
<mat-icon>account_balance</mat-icon>
<h2>Anmelder</h2>
<span>{{ patent.assignees.length }}</span>
</div>
<div class="compact-list">
@for (assignee of patent.assignees; track assignee) {
<div>
<strong>{{ assignee }}</strong>
</div>
}
</div>
</section>
}
@if (patent.ipc_descriptions.length > 0) {
<section class="card classification-card-section classification-card-section--ipc">
<div class="section-title">
<mat-icon>label</mat-icon>
<h2>Klassifikation (IPC)</h2>
</div>
<div class="classification-cards">
@for (
card of classificationCards(patent.ipc_descriptions, 'IPC');
track card.key
) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">
{{ card.system }}
</span>
<span class="classification-badge classification-badge--level">
{{ card.levelLabel }}
</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{
isClassificationExpanded(card.key)
? card.primaryDescription
: getDescriptionPreview(card.primaryDescription)
}}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{
isClassificationExpanded(card.key)
? 'Weniger anzeigen'
: 'Mehr anzeigen'
}}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</section>
} @else if (patent.ipc.length > 0) {
<section class="card">
<div class="section-title">
<mat-icon>label</mat-icon>
<h2>Klassifikation (IPC)</h2>
</div>
<div class="tags">
@for (ipc of patent.ipc; track ipc) {
<span>{{ ipc }}</span>
}
</div>
</section>
}
@if (patent.cpc_descriptions.length > 0) {
<section class="card classification-card-section classification-card-section--cpc">
<div class="section-title">
<mat-icon>label</mat-icon>
<h2>Klassifikation (CPC)</h2>
</div>
<div class="classification-cards">
@for (
card of classificationCards(patent.cpc_descriptions, 'CPC');
track card.key
) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">
{{ card.system }}
</span>
<span class="classification-badge classification-badge--level">
{{ card.levelLabel }}
</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{
isClassificationExpanded(card.key)
? card.primaryDescription
: getDescriptionPreview(card.primaryDescription)
}}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{
isClassificationExpanded(card.key)
? 'Weniger anzeigen'
: 'Mehr anzeigen'
}}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</section>
} @else if (patent.cpc.length > 0) {
<section class="card">
<div class="section-title">
<mat-icon>label</mat-icon>
<h2>Klassifikation (CPC)</h2>
</div>
<div class="tags">
@for (cpc of patent.cpc; track cpc) {
<span>{{ cpc }}</span>
}
</div>
</section>
}
</main>
<aside>
<section class="card facts-card">
<div class="section-title">
<mat-icon>info</mat-icon>
<h2>Patentdaten</h2>
</div>
<dl>
@for (row of metadataRows(); track row.label) {
<div>
<dt>{{ row.label }}</dt>
<dd>
@if (row.variant === 'source') {
<span class="source-badge source-badge--{{ row.value.toLowerCase() }}">
{{ row.value }}
</span>
} @else {
{{ row.value }}
}
</dd>
</div>
}
</dl>
</section>
@if (externalLinks().length) {
<section class="card">
<div class="section-title">
<mat-icon>link</mat-icon>
<h2>Externe Links</h2>
</div>
<div class="link-list">
@for (link of externalLinks(); track link.url) {
<a [href]="link.url" target="_blank" rel="noopener">
<span>{{ link.label }}</span>
<mat-icon>north_east</mat-icon>
</a>
}
</div>
</section>
}
</aside>
</div>
}
</div>
@@ -0,0 +1,462 @@
:host {
display: block;
background: var(--sg-background);
}
.detail-page {
max-width: 1500px;
margin: 0 auto;
padding: 26px 32px 56px;
}
.back-link {
display: inline-flex;
align-items: center;
gap: 7px;
margin-bottom: 22px;
padding: 0;
border: 0;
background: transparent;
color: var(--sg-text-muted);
font-size: 13px;
font-weight: 600;
text-decoration: none;
cursor: pointer;
}
.back-link mat-icon {
width: 18px;
height: 18px;
font-size: 18px;
}
.hero {
display: grid;
grid-template-columns: minmax(0, 1fr) 420px;
gap: 42px;
padding: 38px 42px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-lg);
background:
radial-gradient(
circle at 90% 10%,
rgba(200, 217, 255, 0.75),
transparent 35%
),
linear-gradient(140deg, #fff 0%, #f8faff 100%);
box-shadow: var(--sg-shadow-sm);
}
.eyebrow,
.tags,
.hero-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.eyebrow span {
padding: 5px 10px;
border: 1px solid var(--sg-border);
border-radius: 999px;
background: rgba(255, 255, 255, 0.85);
color: var(--sg-text-muted);
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
}
h1 {
max-width: 920px;
margin: 20px 0 13px;
font-size: clamp(27px, 3vw, 42px);
line-height: 1.13;
}
.meta-line {
max-width: 900px;
margin: 0;
color: var(--sg-text-muted);
font-size: 14px;
line-height: 1.7;
}
.hero-actions {
margin-top: 26px;
}
.hero-actions a {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 42px;
padding: 9px 16px;
border: 1px solid var(--sg-border-strong);
border-radius: var(--sg-radius-sm);
background: #fff;
color: var(--sg-text);
font-weight: 700;
text-decoration: none;
}
.hero-actions a.primary-action {
border-color: var(--sg-primary);
background: var(--sg-primary);
color: #fff;
}
.hero-actions mat-icon {
width: 17px;
height: 17px;
font-size: 17px;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
align-self: center;
overflow: hidden;
border: 1px solid rgba(199, 211, 232, 0.8);
border-radius: var(--sg-radius-md);
background: rgba(255, 255, 255, 0.8);
}
.metrics div {
display: flex;
align-items: center;
flex-direction: column;
gap: 5px;
padding: 22px 10px;
text-align: center;
}
.metrics div + div {
border-left: 1px solid var(--sg-border);
}
.metrics mat-icon {
color: var(--sg-text-soft);
}
.metrics strong {
color: var(--sg-text);
font-family: 'Montserrat', 'Open Sans', sans-serif;
font-size: 22px;
}
.metrics span {
color: var(--sg-text-muted);
font-size: 11px;
}
.content-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
gap: 24px;
margin-top: 24px;
}
main,
aside {
display: flex;
flex-direction: column;
gap: 24px;
}
.card {
padding: 26px 28px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-md);
background: var(--sg-surface);
box-shadow: var(--sg-shadow-sm);
}
.section-title {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
}
.section-title mat-icon {
color: var(--sg-text-muted);
}
.section-title h2 {
margin: 0;
font-size: 16px;
}
.section-title span {
margin-left: auto;
color: var(--sg-text-muted);
font-size: 12px;
}
.abstract-card p {
margin: 0;
color: var(--sg-text);
font-size: 14px;
line-height: 1.8;
}
.tags span {
padding: 7px 10px;
border: 1px solid var(--sg-border);
border-radius: 999px;
color: var(--sg-text-muted);
font-size: 11px;
}
.compact-list,
.link-list {
display: grid;
gap: 10px;
}
.compact-list div {
display: flex;
align-items: flex-start;
flex-direction: column;
gap: 3px;
padding: 13px 0;
border-bottom: 1px solid var(--sg-border);
}
.compact-list div:last-child {
border-bottom: 0;
}
.compact-list strong {
font-size: 12px;
}
dl {
margin: 0;
}
dl div {
display: grid;
grid-template-columns: 115px minmax(0, 1fr);
gap: 12px;
padding: 10px 0;
border-bottom: 1px solid var(--sg-border);
}
dl div:last-child {
border-bottom: 0;
}
dt {
color: var(--sg-text-muted);
font-size: 12px;
}
dd {
margin: 0;
overflow-wrap: anywhere;
color: var(--sg-text);
font-size: 12px;
font-weight: 600;
text-align: right;
}
.link-list a {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid var(--sg-border);
color: var(--sg-text);
font-size: 12px;
font-weight: 700;
text-decoration: none;
}
.link-list a:last-child {
border-bottom: 0;
}
.link-list mat-icon {
width: 16px;
height: 16px;
color: var(--sg-text-muted);
font-size: 16px;
}
.state {
display: grid;
place-items: center;
min-height: 380px;
color: var(--sg-text-muted);
text-align: center;
}
.error-state mat-icon {
width: 46px;
height: 46px;
font-size: 46px;
}
.empty {
color: var(--sg-text-muted);
}
.source-badge {
display: inline-flex;
align-items: center;
padding: 4px 10px;
border-radius: 999px;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
}
.source-badge--epo {
background: #e8f7ee;
color: #1f7a43;
}
.source-badge--uspto {
background: #eef3ff;
color: #1f4fbf;
}
.classification-cards {
display: grid;
gap: 12px;
}
.classification-card {
padding: 16px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: var(--sg-surface-muted);
}
.classification-card-section--ipc .classification-card {
background: #f4f8ff;
}
.classification-card-section--cpc .classification-card {
background: #f3fbf5;
}
.classification-card__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.classification-card__codes {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.classification-code {
padding: 4px 8px;
border-radius: 6px;
background: #fff;
color: var(--sg-text);
font-size: 12px;
font-weight: 700;
}
.classification-card__badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.classification-badge {
padding: 3px 8px;
border-radius: 999px;
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
}
.classification-badge--system {
background: #e8eef8;
color: #35507a;
}
.classification-badge--level {
background: #fff;
color: var(--sg-text-muted);
}
.classification-summary {
margin: 0 0 8px;
color: var(--sg-text);
font-size: 13px;
line-height: 1.6;
}
.classification-toggle {
padding: 0;
border: 0;
background: transparent;
color: var(--sg-primary);
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
.classification-hierarchy {
margin: 12px 0 0;
}
.classification-hierarchy__row {
display: grid;
grid-template-columns: 90px minmax(0, 1fr);
gap: 10px;
padding: 6px 0;
border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.classification-hierarchy__row dt {
color: var(--sg-text-muted);
font-size: 11px;
}
.classification-hierarchy__row dd {
margin: 0;
color: var(--sg-text);
font-size: 12px;
text-align: left;
}
@media (max-width: 1150px) {
.hero,
.content-grid {
grid-template-columns: 1fr;
}
.metrics {
width: 100%;
}
}
@media (max-width: 700px) {
.detail-page {
padding: 18px 16px 40px;
}
.hero,
.card {
padding: 22px 20px;
}
.metrics {
grid-template-columns: 1fr;
}
.metrics div + div {
border-top: 1px solid var(--sg-border);
border-left: 0;
}
}
@@ -0,0 +1,127 @@
import { Location } from '@angular/common';
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { finalize } from 'rxjs';
import { PatentsService } from '../../api/api/patents.service';
import { PatentEntry } from '../../api/model/patentEntry';
import {
ClassificationCard,
ClassificationSystem,
formatPatentDate,
getClassificationCards,
getDescriptionPreview,
getPatentMetadataRows,
getPublicationStageLabel,
isLongDescription,
patentExternalLinks,
} from './patent-detail.utils';
@Component({
selector: 'app-patent-detail',
imports: [
MatButtonModule,
MatIconModule,
MatProgressSpinnerModule,
RouterLink,
],
templateUrl: './patent-detail.component.html',
styleUrl: './patent-detail.component.scss',
})
export class PatentDetailComponent implements OnInit {
private readonly destroyRef = inject(DestroyRef);
private readonly route = inject(ActivatedRoute);
private readonly patentsService = inject(PatentsService);
private readonly location = inject(Location);
patent: PatentEntry | null = null;
loading = true;
notFound = false;
private expandedClassificationKeys = new Set<string>();
ngOnInit(): void {
this.route.paramMap
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
const patentId = params.get('patentId');
if (!patentId) {
this.loading = false;
this.notFound = true;
return;
}
this.loadPatent(patentId);
});
}
navigateBack(): void {
this.location.back();
}
formatDate(date: string | null | undefined): string {
return formatPatentDate(date);
}
metadataRows() {
return this.patent ? getPatentMetadataRows(this.patent) : [];
}
stageLabel(): string | null {
return this.patent ? getPublicationStageLabel(this.patent) : null;
}
externalLinks() {
return this.patent ? patentExternalLinks(this.patent) : [];
}
classificationCards(
entries: PatentEntry['ipc_descriptions'],
system: ClassificationSystem,
): ClassificationCard[] {
return getClassificationCards(entries, system);
}
toggleClassificationExpanded(key: string): void {
if (this.expandedClassificationKeys.has(key)) {
this.expandedClassificationKeys.delete(key);
return;
}
this.expandedClassificationKeys.add(key);
}
isClassificationExpanded(key: string): boolean {
return this.expandedClassificationKeys.has(key);
}
isLongDescription(text: string | null): boolean {
return isLongDescription(text);
}
getDescriptionPreview(text: string | null): string {
return getDescriptionPreview(text);
}
private loadPatent(patentId: string): void {
this.loading = true;
this.notFound = false;
this.patent = null;
this.expandedClassificationKeys.clear();
this.patentsService
.getPatentById(patentId)
.pipe(finalize(() => (this.loading = false)))
.subscribe({
next: (patent) => {
this.patent = patent;
},
error: () => {
this.notFound = true;
},
});
}
}
@@ -0,0 +1,205 @@
import { IpcClassification, PatentEntry } from '../../api/model/patentEntry';
export type ClassificationSystem = 'IPC' | 'CPC';
export interface ClassificationCard {
key: string;
symbols: string[];
system: ClassificationSystem;
levelLabel: string;
primaryDescription: string | null;
hierarchy: { label: string; value: string }[];
}
export interface PatentMetadataRow {
label: string;
value: string;
variant?: 'source';
}
const DESCRIPTION_PREVIEW_LENGTH = 140;
export function formatPatentDate(date: string | null | undefined): string {
if (!date) return '-';
const normalized = date.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3');
const parsed = new Date(normalized);
if (isNaN(parsed.getTime())) return date;
return new Intl.DateTimeFormat('de-DE').format(parsed);
}
export function formatMetadataLabel(value: string): string {
return value
.replace(/_/g, ' ')
.toLowerCase()
.replace(/\b\w/g, (char) => char.toUpperCase());
}
export function getPublicationStageLabel(patent: PatentEntry): string | null {
return patent.kind ?? patent.application_type ?? null;
}
export function getPatentMetadataRows(patent: PatentEntry): PatentMetadataRow[] {
const rows: PatentMetadataRow[] = [
{ label: 'Quelle', value: patent.source, variant: 'source' },
{ label: 'Patent-Nr.', value: patent.patent_id },
];
if (patent.publication_date) {
rows.push({
label: 'Veröffentlichungsdatum',
value: formatPatentDate(patent.publication_date),
});
}
if (patent.application_number) {
rows.push({ label: 'Anmeldungsnummer', value: patent.application_number });
}
if (patent.application_date) {
rows.push({
label: 'Anmeldedatum',
value: formatPatentDate(patent.application_date),
});
}
const stageLabel = getPublicationStageLabel(patent);
if (stageLabel) {
rows.push({
label: patent.kind ? 'Publikationsstufe' : 'Anmeldungstyp',
value: patent.kind ? stageLabel : formatMetadataLabel(stageLabel),
});
}
if (patent.number_of_claims != null) {
rows.push({ label: 'Ansprüche', value: String(patent.number_of_claims) });
}
if (patent.status) {
rows.push({ label: 'Status', value: formatMetadataLabel(patent.status) });
}
return rows;
}
export function getClassificationCards(
entries: IpcClassification[] | undefined,
system: ClassificationSystem,
): ClassificationCard[] {
if (!entries?.length) return [];
const merged = new Map<string, ClassificationCard>();
for (const entry of entries) {
const card = buildClassificationCard(entry, system);
const mergeKey =
card.primaryDescription?.toLocaleLowerCase('en') ??
card.symbols[0] ??
card.key;
const existing = merged.get(mergeKey);
if (existing) {
for (const symbol of card.symbols) {
if (!existing.symbols.includes(symbol)) {
existing.symbols.push(symbol);
}
}
continue;
}
merged.set(mergeKey, card);
}
return [...merged.values()];
}
export function isLongDescription(text: string | null): boolean {
return !!text && text.length > DESCRIPTION_PREVIEW_LENGTH;
}
export function getDescriptionPreview(text: string | null): string {
if (!text) return '';
if (text.length <= DESCRIPTION_PREVIEW_LENGTH) return text;
return `${text.slice(0, DESCRIPTION_PREVIEW_LENGTH).trimEnd()}…`;
}
export function patentExternalLinks(patent: PatentEntry): { label: string; url: string }[] {
const links: { label: string; url: string }[] = [];
const encodedId = encodeURIComponent(patent.patent_id);
if (patent.source === 'EPO') {
links.push({
label: 'Espacenet',
url: `https://worldwide.espacenet.com/patent/search?q=pn%3D${encodedId}`,
});
}
if (patent.source === 'USPTO') {
links.push({
label: 'Google Patents',
url: `https://patents.google.com/patent/${encodedId}`,
});
}
return links;
}
function buildClassificationCard(
entry: IpcClassification,
system: ClassificationSystem,
): ClassificationCard {
const level = getClassificationLevel(entry);
const primaryDescription = extractDescriptionText(entry[level.field]);
return {
key: `${system}-${entry.symbol}`,
symbols: [entry.symbol],
system,
levelLabel: level.label,
primaryDescription,
hierarchy: buildHierarchyRows(entry, primaryDescription),
};
}
function getClassificationLevel(entry: IpcClassification): {
label: string;
field: keyof IpcClassification;
} {
if (entry.subgroup) return { label: 'Untergruppe', field: 'subgroup' };
if (entry.main_group) return { label: 'Hauptgruppe', field: 'main_group' };
if (entry.subclass) return { label: 'Unterklasse', field: 'subclass' };
if (entry.section) return { label: 'Sektion', field: 'section' };
return { label: 'Code', field: 'symbol' };
}
function buildHierarchyRows(
entry: IpcClassification,
primaryDescription: string | null,
): { label: string; value: string }[] {
const rows: { label: string; value: string }[] = [];
const seen = new Set<string>();
const addRow = (label: string, raw: string | null) => {
const value = extractDescriptionText(raw);
if (!value) return;
const normalized = value.toLocaleLowerCase('en');
if (seen.has(normalized) || normalized === primaryDescription?.toLocaleLowerCase('en')) {
return;
}
seen.add(normalized);
rows.push({ label, value });
};
addRow('Sektion', entry.section);
addRow('Klasse', entry.class);
addRow('Unterklasse', entry.subclass);
return rows;
}
function extractDescriptionText(value: string | null | undefined): string | null {
if (!value?.trim()) return null;
const text = value.includes(' - ')
? value.split(' - ').slice(1).join(' - ').trim()
: value.trim();
if (!text) return null;
const firstSentence = text.split(/[;|]/)[0]?.trim() ?? text;
if (firstSentence !== firstSentence.toUpperCase()) return firstSentence;
return firstSentence.charAt(0) + firstSentence.slice(1).toLowerCase();
}
@@ -85,213 +85,6 @@
</div>
} @else if (error) {
<p class="state-message error">Fehler beim Laden der Patente.</p>
} @else if (showDetail && selectedPatent) {
<div class="detail-view">
<button type="button" class="back-btn" (click)="closeDetail()">
← Zurück zu den Patenten
</button>
<h2>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h2>
<div class="patent-meta__list">
@for (row of getPatentMetadataRows(selectedPatent); track row.label) {
<div class="patent-meta__row">
<dt>{{ row.label }}</dt>
<dd>
@if (row.variant === 'source') {
<span
class="source-badge source-badge--{{
row.value.toLowerCase()
}}"
>{{ row.value }}</span
>
} @else {
{{ row.value }}
}
</dd>
</div>
}
</div>
@if (selectedPatent.abstract) {
<div class="detail-section">
<h4>Abstract</h4>
<p>{{ selectedPatent.abstract }}</p>
</div>
}
<div class="detail-section">
<h4>Erfinder</h4>
<ul class="tag-list">
@for (inv of selectedPatent.inventors; track inv) {
<li class="tag">{{ inv }}</li>
}
</ul>
</div>
@if (selectedPatent.assignees.length > 0) {
<div class="detail-section">
<h4>Anmelder</h4>
<ul class="tag-list">
@for (a of selectedPatent.assignees; track a) {
<li class="tag">{{ a }}</li>
}
</ul>
</div>
}
@if (selectedPatent.ipc_descriptions.length > 0) {
<div
class="detail-section classification-section classification-section--ipc">
<h4>Klassifikation (IPC)</h4>
<div class="classification-cards">
@for (
card of getClassificationCards(
selectedPatent.ipc_descriptions,
'IPC'
);
track card.key
) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (sym of card.symbols; track sym) {
<span class="classification-code">{{ sym }}</span>
}
</div>
<div class="classification-card__badges">
<span
class="classification-badge classification-badge--system"
>{{ card.system }}</span
>
<span
class="classification-badge classification-badge--level"
>{{ card.levelLabel }}</span
>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{
isClassificationExpanded(card.key)
? card.primaryDescription
: getDescriptionPreview(card.primaryDescription)
}}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{
isClassificationExpanded(card.key)
? 'Weniger anzeigen'
: 'Mehr anzeigen'
}}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.ipc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (IPC)</h4>
<ul class="tag-list tag-list--compact">
@for (ipc of selectedPatent.ipc; track ipc) {
<li class="tag">{{ ipc }}</li>
}
</ul>
</div>
}
@if (selectedPatent.cpc_descriptions.length > 0) {
<div
class="detail-section classification-section classification-section--cpc">
<h4>Klassifikation (CPC)</h4>
<div class="classification-cards">
@for (
card of getClassificationCards(
selectedPatent.cpc_descriptions,
'CPC'
);
track card.key
) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (sym of card.symbols; track sym) {
<span class="classification-code">{{ sym }}</span>
}
</div>
<div class="classification-card__badges">
<span
class="classification-badge classification-badge--system"
>{{ card.system }}</span
>
<span
class="classification-badge classification-badge--level"
>{{ card.levelLabel }}</span
>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{
isClassificationExpanded(card.key)
? card.primaryDescription
: getDescriptionPreview(card.primaryDescription)
}}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{
isClassificationExpanded(card.key)
? 'Weniger anzeigen'
: 'Mehr anzeigen'
}}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.cpc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (CPC)</h4>
<ul class="tag-list tag-list--compact">
@for (cpc of selectedPatent.cpc; track cpc) {
<li class="tag">{{ cpc }}</li>
}
</ul>
</div>
}
</div>
} @else if (patents.length === 0) {
<div class="no-results">
<p>Keine Patente gefunden.</p>
@@ -305,7 +98,7 @@
<mat-card
class="card"
appearance="outlined"
(click)="selectPatent(patent)">
(click)="openPatent(patent)">
<mat-card-header>
<mat-card-title>{{
patent.title ?? patent.patent_id
@@ -331,7 +124,7 @@
<mat-card-actions>
<button
mat-button
(click)="selectPatent(patent); $event.stopPropagation()">
(click)="openPatent(patent); $event.stopPropagation()">
<mat-icon>info</mat-icon>
Übersicht
</button>
@@ -344,12 +137,10 @@
<mat-divider />
@if (!showDetail) {
<mat-paginator
<mat-paginator
[length]="total"
[pageSize]="pageSize"
[pageIndex]="page"
[pageSizeOptions]="[10, 25, 50]"
(page)="handlePageChange($event)" />
}
</div>
@@ -13,21 +13,10 @@ 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, IpcClassification } from '../../api/model/patentEntry';
import { PatentEntry } from '../../api/model/patentEntry';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type ClassificationSystem = 'IPC' | 'CPC';
interface ClassificationCard {
key: string;
symbols: string[];
system: ClassificationSystem;
levelLabel: string;
primaryDescription: string | null;
hierarchy: { label: string; value: string }[];
}
const DESCRIPTION_PREVIEW_LENGTH = 140;
const MIN_YEAR = 1978;
@Component({
@@ -71,9 +60,6 @@ export class PatentsComponent implements OnInit {
selectedStartYear = MIN_YEAR;
selectedEndYear = new Date().getFullYear();
selectedPatent: PatentEntry | null = null;
showDetail = false;
private expandedClassificationKeys = new Set<string>();
private searchSubject = new Subject<string>();
constructor() {
@@ -82,8 +68,6 @@ export class PatentsComponent implements OnInit {
.subscribe((term) => {
this.searchTerm = term;
this.page = 0;
this.selectedPatent = null;
this.showDetail = false;
this.loadPatents();
this.updateQueryParams();
});
@@ -180,8 +164,6 @@ export class PatentsComponent implements OnInit {
clearSearch(): void {
this.searchTerm = '';
this.page = 0;
this.selectedPatent = null;
this.showDetail = false;
this.loadPatents();
this.updateQueryParams();
}
@@ -190,8 +172,6 @@ export class PatentsComponent implements OnInit {
const val = event.value;
this.activeFilter = val === 'EPO' || val === 'USPTO' ? val : 'all';
this.page = 0;
this.selectedPatent = null;
this.showDetail = false;
this.loadPatents();
this.updateQueryParams();
}
@@ -205,22 +185,12 @@ export class PatentsComponent implements OnInit {
handlePageChange(event: PageEvent): void {
this.page = event.pageIndex;
this.pageSize = event.pageSize;
this.selectedPatent = null;
this.showDetail = false;
this.loadPatents();
this.updateQueryParams();
}
selectPatent(patent: PatentEntry): void {
this.selectedPatent = patent;
this.showDetail = true;
this.expandedClassificationKeys.clear();
}
closeDetail(): void {
this.showDetail = false;
this.selectedPatent = null;
this.expandedClassificationKeys.clear();
openPatent(patent: PatentEntry): void {
this.router.navigate(['/patent', patent.patent_id]);
}
private updateQueryParams(): void {
@@ -247,117 +217,4 @@ export class PatentsComponent implements OnInit {
if (isNaN(parsed.getTime())) return date;
return new Intl.DateTimeFormat('de-DE').format(parsed);
}
getPublicationStageLabel(patent: PatentEntry): string | null {
return patent.kind ?? patent.application_type ?? null;
}
getPatentMetadataRows(patent: PatentEntry) {
const rows: { label: string; value: string; variant?: 'source' }[] = [];
rows.push({ label: 'Quelle', value: patent.source, variant: 'source' });
rows.push({ label: 'Patent-Nr.', value: patent.patent_id });
if (patent.publication_date)
rows.push({ label: 'Veröffentlichungsdatum', value: this.formatDate(patent.publication_date) });
if (patent.application_number)
rows.push({ label: 'Anmeldungsnummer', value: patent.application_number });
if (patent.application_date)
rows.push({ label: 'Anmeldedatum', value: this.formatDate(patent.application_date) });
const stage = this.getPublicationStageLabel(patent);
if (stage)
rows.push({ label: patent.kind ? 'Publikationsstufe' : 'Anmeldungstyp', value: this.formatMetadataLabel(stage) });
if (patent.number_of_claims != null)
rows.push({ label: 'Ansprüche', value: String(patent.number_of_claims) });
if (patent.status)
rows.push({ label: 'Status', value: this.formatMetadataLabel(patent.status) });
return rows;
}
private formatMetadataLabel(value: string): string {
return value.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, (c) => c.toUpperCase());
}
getClassificationCards(entries: IpcClassification[] | undefined, system: ClassificationSystem): ClassificationCard[] {
if (!entries?.length) return [];
const merged = new Map<string, ClassificationCard>();
for (const entry of entries) {
const card = this.buildClassificationCard(entry, system);
const mergeKey = card.primaryDescription?.toLocaleLowerCase('en') ?? card.symbols[0] ?? card.key;
const existing = merged.get(mergeKey);
if (existing) {
for (const s of card.symbols) {
if (!existing.symbols.includes(s)) existing.symbols.push(s);
}
continue;
}
merged.set(mergeKey, card);
}
return [...merged.values()];
}
toggleClassificationExpanded(key: string): void {
this.expandedClassificationKeys.has(key)
? this.expandedClassificationKeys.delete(key)
: this.expandedClassificationKeys.add(key);
}
isClassificationExpanded(key: string): boolean {
return this.expandedClassificationKeys.has(key);
}
isLongDescription(text: string | null): boolean {
return !!text && text.length > DESCRIPTION_PREVIEW_LENGTH;
}
getDescriptionPreview(text: string | null): string {
if (!text) return '';
return text.length <= DESCRIPTION_PREVIEW_LENGTH
? text
: `${text.slice(0, DESCRIPTION_PREVIEW_LENGTH).trimEnd()}…`;
}
private buildClassificationCard(entry: IpcClassification, system: ClassificationSystem): ClassificationCard {
const level = this.getClassificationLevel(entry);
const primaryDescription = this.extractDescriptionText(entry[level.field]);
return {
key: `${system}-${entry.symbol}`,
symbols: [entry.symbol],
system,
levelLabel: level.label,
primaryDescription,
hierarchy: this.buildHierarchyRows(entry, primaryDescription),
};
}
private getClassificationLevel(entry: IpcClassification): { label: string; field: keyof IpcClassification } {
if (entry.subgroup) return { label: 'Untergruppe', field: 'subgroup' };
if (entry.main_group) return { label: 'Hauptgruppe', field: 'main_group' };
if (entry.subclass) return { label: 'Unterklasse', field: 'subclass' };
if (entry.section) return { label: 'Sektion', field: 'section' };
return { label: 'Code', field: 'symbol' };
}
private buildHierarchyRows(entry: IpcClassification, primaryDescription: string | null) {
const rows: { label: string; value: string }[] = [];
const seen = new Set<string>();
const addRow = (label: string, raw: string | null) => {
const value = this.extractDescriptionText(raw);
if (!value) return;
const norm = value.toLocaleLowerCase('en');
if (seen.has(norm) || norm === primaryDescription?.toLocaleLowerCase('en')) return;
seen.add(norm);
rows.push({ label, value });
};
addRow('Sektion', entry.section);
addRow('Klasse', entry.class);
addRow('Unterklasse', entry.subclass);
return rows;
}
private extractDescriptionText(value: string | null | undefined): string | null {
if (!value?.trim()) return null;
const text = value.includes(' - ') ? value.split(' - ').slice(1).join(' - ').trim() : value.trim();
if (!text) return null;
const first = text.split(/[;|]/)[0]?.trim() ?? text;
return first === first.toUpperCase() ? first.charAt(0) + first.slice(1).toLowerCase() : first;
}
}
@@ -6,182 +6,8 @@
<p class="message">Keine Patente gefunden.</p>
} @else {
<div class="patents-container">
<div class="patents-content">
@if (showDetail && selectedPatent) {
<div class="patent-full-detail">
<button type="button" class="back-btn" (click)="closeDetail()">
← Zurück zu den Patenten
</button>
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
@if (hasPatentMetadata(selectedPatent)) {
<div class="patent-meta patent-meta--inline">
<dl class="patent-meta__list">
@for (row of getPatentMetadataRows(selectedPatent); track row.label) {
<div class="patent-meta__row">
<dt>{{ row.label }}</dt>
<dd>
@if (row.variant === 'source') {
<span class="source-badge source-badge--{{ row.value.toLowerCase() }}">
{{ row.value }}
</span>
} @else {
{{ row.value }}
}
</dd>
</div>
}
</dl>
</div>
}
@if (selectedPatent.abstract) {
<div class="detail-section">
<h4>Abstract</h4>
<p>{{ selectedPatent.abstract }}</p>
</div>
}
<div class="detail-section">
<h4>Erfinder</h4>
<ul class="tag-list">
@for (inventor of selectedPatent.inventors; track inventor) {
<li class="tag">{{ inventor }}</li>
}
</ul>
</div>
@if (selectedPatent.assignees.length > 0) {
<div class="detail-section">
<h4>Anmelder</h4>
<ul class="tag-list">
@for (assignee of selectedPatent.assignees; track assignee) {
<li class="tag">{{ assignee }}</li>
}
</ul>
</div>
}
@if (selectedPatent.ipc_descriptions.length > 0) {
<div class="detail-section classification-section classification-section--ipc">
<h4>Klassifikation (IPC)</h4>
<div class="classification-cards">
@for (card of getClassificationCards(selectedPatent.ipc_descriptions, 'IPC'); track card.key) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">{{ card.system }}</span>
<span class="classification-badge classification-badge--level">{{ card.levelLabel }}</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{ isClassificationExpanded(card.key) ? 'Weniger anzeigen' : 'Mehr anzeigen' }}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.ipc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (IPC)</h4>
<ul class="tag-list tag-list--compact">
@for (ipc of selectedPatent.ipc; track ipc) {
<li class="tag">{{ ipc }}</li>
}
</ul>
</div>
}
@if (selectedPatent.cpc_descriptions.length > 0) {
<div class="detail-section classification-section classification-section--cpc">
<h4>Klassifikation (CPC)</h4>
<div class="classification-cards">
@for (card of getClassificationCards(selectedPatent.cpc_descriptions, 'CPC'); track card.key) {
<article class="classification-card">
<header class="classification-card__header">
<div class="classification-card__codes">
@for (symbol of card.symbols; track symbol) {
<span class="classification-code">{{ symbol }}</span>
}
</div>
<div class="classification-card__badges">
<span class="classification-badge classification-badge--system">{{ card.system }}</span>
<span class="classification-badge classification-badge--level">{{ card.levelLabel }}</span>
</div>
</header>
@if (card.primaryDescription) {
<p class="classification-summary">
{{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }}
</p>
@if (isLongDescription(card.primaryDescription)) {
<button
type="button"
class="classification-toggle"
(click)="toggleClassificationExpanded(card.key)">
{{ isClassificationExpanded(card.key) ? 'Weniger anzeigen' : 'Mehr anzeigen' }}
</button>
}
}
@if (card.hierarchy.length > 0) {
<dl class="classification-hierarchy">
@for (row of card.hierarchy; track row.label) {
<div class="classification-hierarchy__row">
<dt>{{ row.label }}</dt>
<dd>{{ row.value }}</dd>
</div>
}
</dl>
}
</article>
}
</div>
</div>
} @else if (selectedPatent.cpc.length > 0) {
<div class="detail-section">
<h4>Klassifikation (CPC)</h4>
<ul class="tag-list tag-list--compact">
@for (cpc of selectedPatent.cpc; track cpc) {
<li class="tag">{{ cpc }}</li>
}
</ul>
</div>
}
</div>
}
<div class="patents-list" [class.hidden]="showDetail">
<div class="patents-list">
<div class="patents-list-toolbar">
<label class="sort-control">
<span>Filter nach Quelle:</span>
@@ -234,7 +60,7 @@
}
</div>
@if (selectedPatent && !showDetail) {
@if (selectedPatent) {
<div class="patent-detail">
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
<div class="detail-stats">
@@ -2,28 +2,14 @@ import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { PatentsService } from '../../api/api/patents.service';
import { PatentEntry, IpcClassification } from '../../api/model/patentEntry';
import { PatentEntry } from '../../api/model/patentEntry';
import {
formatPatentDate,
getPublicationStageLabel,
} from '../patent-detail/patent-detail.utils';
type SortMode = 'date' | 'title';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type ClassificationSystem = 'IPC' | 'CPC';
interface ClassificationCard {
key: string;
symbols: string[];
system: ClassificationSystem;
levelLabel: string;
primaryDescription: string | null;
hierarchy: { label: string; value: string }[];
}
interface PatentMetadataRow {
label: string;
value: string;
variant?: 'source';
}
const DESCRIPTION_PREVIEW_LENGTH = 140;
@Component({
selector: 'app-person-patents',
@@ -40,7 +26,6 @@ export class PersonPatentsComponent implements OnInit {
filteredPatents: PatentEntry[] = [];
authorName: string | null = null;
selectedPatent: PatentEntry | null = null;
showDetail = false;
loading = true;
error = false;
@@ -50,7 +35,6 @@ export class PersonPatentsComponent implements OnInit {
selectedPage = 1;
readonly pageSize = 10;
private expandedClassificationKeys = new Set<string>();
ngOnInit(): void {
this.route.parent?.paramMap.subscribe((params) => {
@@ -87,7 +71,6 @@ export class PersonPatentsComponent implements OnInit {
this.activeFilter = filter;
this.selectedPage = 1;
this.selectedPatent = null;
this.showDetail = false;
this.applyFilter();
this.updateQueryParams();
}
@@ -100,19 +83,12 @@ export class PersonPatentsComponent implements OnInit {
selectPatent(patent: PatentEntry): void {
this.selectedPatent = patent;
this.showDetail = false;
this.expandedClassificationKeys.clear();
this.updateQueryParams();
}
openDetail(): void {
this.showDetail = true;
this.expandedClassificationKeys.clear();
}
closeDetail(): void {
this.showDetail = false;
this.expandedClassificationKeys.clear();
if (!this.selectedPatent) return;
this.router.navigate(['/patent', this.selectedPatent.patent_id]);
}
private applyFilter(): void {
@@ -173,9 +149,7 @@ export class PersonPatentsComponent implements OnInit {
}
formatDate(date: string | null): string {
if (!date) return '-';
const d = date.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3');
return new Intl.DateTimeFormat('de-DE').format(new Date(d));
return formatPatentDate(date);
}
getEpoCount(): number {
@@ -207,200 +181,6 @@ export class PersonPatentsComponent implements OnInit {
}
getPublicationStageLabel(patent: PatentEntry): string | null {
if (patent.kind) {
return patent.kind;
}
if (patent.application_type) {
return patent.application_type;
}
return null;
}
hasPatentMetadata(_patent: PatentEntry): boolean {
return true;
}
getPatentMetadataRows(patent: PatentEntry): PatentMetadataRow[] {
const rows: PatentMetadataRow[] = [];
rows.push({ label: 'Quelle', value: patent.source, variant: 'source' });
rows.push({ label: 'Patent-Nr.', value: patent.patent_id });
if (patent.publication_date) {
rows.push({
label: 'Veröffentlichungsdatum',
value: this.formatDate(patent.publication_date),
});
}
if (patent.application_number) {
rows.push({ label: 'Anmeldungsnummer', value: patent.application_number });
}
if (patent.application_date) {
rows.push({ label: 'Anmeldedatum', value: this.formatDate(patent.application_date) });
}
const stageLabel = this.getPublicationStageLabel(patent);
if (stageLabel) {
rows.push({
label: patent.kind ? 'Publikationsstufe' : 'Anmeldungstyp',
value: patent.kind ? stageLabel : this.formatMetadataLabel(stageLabel),
});
}
if (patent.number_of_claims != null) {
rows.push({ label: 'Ansprüche', value: String(patent.number_of_claims) });
}
if (patent.status) {
rows.push({ label: 'Status', value: this.formatMetadataLabel(patent.status) });
}
return rows;
}
private formatMetadataLabel(value: string): string {
return value
.replace(/_/g, ' ')
.toLowerCase()
.replace(/\b\w/g, (char) => char.toUpperCase());
}
getClassificationCards(
entries: IpcClassification[] | undefined,
system: ClassificationSystem,
): ClassificationCard[] {
if (!entries?.length) {
return [];
}
const merged = new Map<string, ClassificationCard>();
for (const entry of entries) {
const card = this.buildClassificationCard(entry, system);
const mergeKey =
card.primaryDescription?.toLocaleLowerCase('en') ?? card.symbols[0] ?? card.key;
const existing = merged.get(mergeKey);
if (existing) {
for (const symbol of card.symbols) {
if (!existing.symbols.includes(symbol)) {
existing.symbols.push(symbol);
}
}
continue;
}
merged.set(mergeKey, card);
}
return [...merged.values()];
}
toggleClassificationExpanded(key: string): void {
if (this.expandedClassificationKeys.has(key)) {
this.expandedClassificationKeys.delete(key);
return;
}
this.expandedClassificationKeys.add(key);
}
isClassificationExpanded(key: string): boolean {
return this.expandedClassificationKeys.has(key);
}
isLongDescription(text: string | null): boolean {
return !!text && text.length > DESCRIPTION_PREVIEW_LENGTH;
}
getDescriptionPreview(text: string | null): string {
if (!text) {
return '';
}
if (text.length <= DESCRIPTION_PREVIEW_LENGTH) {
return text;
}
return `${text.slice(0, DESCRIPTION_PREVIEW_LENGTH).trimEnd()}…`;
}
private buildClassificationCard(
entry: IpcClassification,
system: ClassificationSystem,
): ClassificationCard {
const level = this.getClassificationLevel(entry);
const primaryDescription = this.extractDescriptionText(entry[level.field]);
return {
key: `${system}-${entry.symbol}`,
symbols: [entry.symbol],
system,
levelLabel: level.label,
primaryDescription,
hierarchy: this.buildHierarchyRows(entry, primaryDescription),
};
}
private getClassificationLevel(entry: IpcClassification): {
label: string;
field: keyof IpcClassification;
} {
if (entry.subgroup) {
return { label: 'Untergruppe', field: 'subgroup' };
}
if (entry.main_group) {
return { label: 'Hauptgruppe', field: 'main_group' };
}
if (entry.subclass) {
return { label: 'Unterklasse', field: 'subclass' };
}
if (entry.section) {
return { label: 'Sektion', field: 'section' };
}
return { label: 'Code', field: 'symbol' };
}
private buildHierarchyRows(
entry: IpcClassification,
primaryDescription: string | null,
): { label: string; value: string }[] {
const rows: { label: string; value: string }[] = [];
const seen = new Set<string>();
const addRow = (label: string, raw: string | null) => {
const value = this.extractDescriptionText(raw);
if (!value) {
return;
}
const normalized = value.toLocaleLowerCase('en');
if (seen.has(normalized) || normalized === primaryDescription?.toLocaleLowerCase('en')) {
return;
}
seen.add(normalized);
rows.push({ label, value });
};
addRow('Sektion', entry.section);
addRow('Klasse', entry.class);
addRow('Unterklasse', entry.subclass);
return rows;
}
private extractDescriptionText(value: string | null | undefined): string | null {
if (!value?.trim()) {
return null;
}
const text = value.includes(' - ') ? value.split(' - ').slice(1).join(' - ').trim() : value.trim();
if (!text) {
return null;
}
const firstSentence = text.split(/[;|]/)[0]?.trim() ?? text;
return this.normalizeDescriptionCase(firstSentence);
}
private normalizeDescriptionCase(text: string): string {
if (text !== text.toUpperCase()) {
return text;
}
return text.charAt(0) + text.slice(1).toLowerCase();
return getPublicationStageLabel(patent);
}
}