diff --git a/service/src/main/inse/patents/all/logic.py b/service/src/main/inse/patents/all/logic.py index 7206fe8a..9cebaa9a 100644 --- a/service/src/main/inse/patents/all/logic.py +++ b/service/src/main/inse/patents/all/logic.py @@ -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, - ) \ No newline at end of file + ) + + +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] \ No newline at end of file diff --git a/service/src/main/inse/patents/all/service.py b/service/src/main/inse/patents/all/service.py index 0d38bb5f..002cc94c 100644 --- a/service/src/main/inse/patents/all/service.py +++ b/service/src/main/inse/patents/all/service.py @@ -32,4 +32,14 @@ async def get_all_patents( sort_direction=sort_direction, year_from=year_from, year_to=year_to, - ) \ No newline at end of file + ) + + +@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) \ No newline at end of file diff --git a/service/src/main/inse/patents/elastic_search_all_patents_client.py b/service/src/main/inse/patents/elastic_search_all_patents_client.py index fa67de96..85585ba4 100644 --- a/service/src/main/inse/patents/elastic_search_all_patents_client.py +++ b/service/src/main/inse/patents/elastic_search_all_patents_client.py @@ -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) diff --git a/webapp/src/app/api/api/patents.service.ts b/webapp/src/app/api/api/patents.service.ts index 9bcab67c..73593583 100644 --- a/webapp/src/app/api/api/patents.service.ts +++ b/webapp/src/app/api/api/patents.service.ts @@ -257,4 +257,25 @@ export class PatentsService extends BaseService { }, ); } + + public getPatentById(patentId: string): Observable { + 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(`${basePath}${localVarPath}`, { + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + }); + } } diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts index b5cf097a..fd4ad62e 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -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], 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 d7a0d223..335eca55 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.html +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.html @@ -6,182 +6,8 @@

Keine Patente gefunden.

} @else {
-
- @if (showDetail && selectedPatent) { -
- - -

{{ selectedPatent.title ?? selectedPatent.patent_id }}

- - @if (hasPatentMetadata(selectedPatent)) { -
-
- @for (row of getPatentMetadataRows(selectedPatent); track row.label) { -
-
{{ row.label }}
-
- @if (row.variant === 'source') { - - {{ row.value }} - - } @else { - {{ row.value }} - } -
-
- } -
-
- } - - @if (selectedPatent.abstract) { -
-

Abstract

-

{{ selectedPatent.abstract }}

-
- } - -
-

Erfinder

-
    - @for (inventor of selectedPatent.inventors; track inventor) { -
  • {{ inventor }}
  • - } -
-
- - @if (selectedPatent.assignees.length > 0) { -
-

Anmelder

-
    - @for (assignee of selectedPatent.assignees; track assignee) { -
  • {{ assignee }}
  • - } -
-
- } - - @if (selectedPatent.ipc_descriptions.length > 0) { -
-

Klassifikation (IPC)

-
- @for (card of getClassificationCards(selectedPatent.ipc_descriptions, 'IPC'); track card.key) { -
-
-
- @for (symbol of card.symbols; track symbol) { - {{ symbol }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- - @if (card.primaryDescription) { -

- {{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.ipc.length > 0) { -
-

Klassifikation (IPC)

-
    - @for (ipc of selectedPatent.ipc; track ipc) { -
  • {{ ipc }}
  • - } -
-
- } - - @if (selectedPatent.cpc_descriptions.length > 0) { -
-

Klassifikation (CPC)

-
- @for (card of getClassificationCards(selectedPatent.cpc_descriptions, 'CPC'); track card.key) { -
-
-
- @for (symbol of card.symbols; track symbol) { - {{ symbol }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- - @if (card.primaryDescription) { -

- {{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.cpc.length > 0) { -
-

Klassifikation (CPC)

-
    - @for (cpc of selectedPatent.cpc; track cpc) { -
  • {{ cpc }}
  • - } -
-
- } - -
- } - -
+
- @if (selectedPatent && !showDetail) { + @if (selectedPatent) {

{{ selectedPatent.title ?? selectedPatent.patent_id }}

diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.ts b/webapp/src/app/modules/institution-patents/institution-patents.component.ts index 68e813d0..93b91ac3 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.ts +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.ts @@ -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(); 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(); - - 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(); - - 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); } } diff --git a/webapp/src/app/modules/patent-detail/patent-detail.component.html b/webapp/src/app/modules/patent-detail/patent-detail.component.html new file mode 100644 index 00000000..ff86b654 --- /dev/null +++ b/webapp/src/app/modules/patent-detail/patent-detail.component.html @@ -0,0 +1,319 @@ +
+ + + @if (loading) { +
+ +

Patent wird geladen...

+
+ } @else if (notFound || !patent) { +
+ search_off +

Patent nicht gefunden

+

Das Patent konnte nicht geladen werden.

+ Zur Patentübersicht +
+ } @else { +
+
+
+ + {{ patent.source }} + + @if (patent.publication_year) { + {{ patent.publication_year }} + } + @if (stageLabel(); as stage) { + {{ stage }} + } +
+

{{ patent.title || patent.patent_id || 'Ohne Titel' }}

+

+ {{ patent.patent_id }} + @if (patent.publication_date) { + · {{ formatDate(patent.publication_date) }} + } +

+
+ @for (link of externalLinks(); track link.url; let first = $first) { + + {{ link.label }} + open_in_new + + } +
+
+ +
+
+ groups + {{ patent.inventors.length }} + Erfinder +
+
+ business + {{ patent.assignees.length }} + Anmelder +
+
+ category + {{ patent.ipc.length + patent.cpc.length }} + Klassifikationen +
+
+
+ +
+
+ @if (patent.abstract) { +
+
+ subject +

Abstract

+
+

{{ patent.abstract }}

+
+ } + +
+
+ engineering +

Erfinder

+ {{ patent.inventors.length }} +
+
+ @for (inventor of patent.inventors; track inventor) { + {{ inventor }} + } @empty { +

Keine Angaben vorhanden.

+ } +
+
+ + @if (patent.assignees.length > 0) { +
+
+ account_balance +

Anmelder

+ {{ patent.assignees.length }} +
+
+ @for (assignee of patent.assignees; track assignee) { +
+ {{ assignee }} +
+ } +
+
+ } + + @if (patent.ipc_descriptions.length > 0) { +
+
+ label +

Klassifikation (IPC)

+
+
+ @for ( + card of classificationCards(patent.ipc_descriptions, 'IPC'); + track card.key + ) { +
+
+
+ @for (symbol of card.symbols; track symbol) { + {{ symbol }} + } +
+
+ + {{ card.system }} + + + {{ card.levelLabel }} + +
+
+ @if (card.primaryDescription) { +

+ {{ + isClassificationExpanded(card.key) + ? card.primaryDescription + : getDescriptionPreview(card.primaryDescription) + }} +

+ @if (isLongDescription(card.primaryDescription)) { + + } + } + @if (card.hierarchy.length > 0) { +
+ @for (row of card.hierarchy; track row.label) { +
+
{{ row.label }}
+
{{ row.value }}
+
+ } +
+ } +
+ } +
+
+ } @else if (patent.ipc.length > 0) { +
+
+ label +

Klassifikation (IPC)

+
+
+ @for (ipc of patent.ipc; track ipc) { + {{ ipc }} + } +
+
+ } + + @if (patent.cpc_descriptions.length > 0) { +
+
+ label +

Klassifikation (CPC)

+
+
+ @for ( + card of classificationCards(patent.cpc_descriptions, 'CPC'); + track card.key + ) { +
+
+
+ @for (symbol of card.symbols; track symbol) { + {{ symbol }} + } +
+
+ + {{ card.system }} + + + {{ card.levelLabel }} + +
+
+ @if (card.primaryDescription) { +

+ {{ + isClassificationExpanded(card.key) + ? card.primaryDescription + : getDescriptionPreview(card.primaryDescription) + }} +

+ @if (isLongDescription(card.primaryDescription)) { + + } + } + @if (card.hierarchy.length > 0) { +
+ @for (row of card.hierarchy; track row.label) { +
+
{{ row.label }}
+
{{ row.value }}
+
+ } +
+ } +
+ } +
+
+ } @else if (patent.cpc.length > 0) { +
+
+ label +

Klassifikation (CPC)

+
+
+ @for (cpc of patent.cpc; track cpc) { + {{ cpc }} + } +
+
+ } +
+ + +
+ } +
diff --git a/webapp/src/app/modules/patent-detail/patent-detail.component.scss b/webapp/src/app/modules/patent-detail/patent-detail.component.scss new file mode 100644 index 00000000..6e9a4afc --- /dev/null +++ b/webapp/src/app/modules/patent-detail/patent-detail.component.scss @@ -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; + } +} diff --git a/webapp/src/app/modules/patent-detail/patent-detail.component.ts b/webapp/src/app/modules/patent-detail/patent-detail.component.ts new file mode 100644 index 00000000..53b4dfc7 --- /dev/null +++ b/webapp/src/app/modules/patent-detail/patent-detail.component.ts @@ -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(); + + 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; + }, + }); + } +} diff --git a/webapp/src/app/modules/patent-detail/patent-detail.utils.ts b/webapp/src/app/modules/patent-detail/patent-detail.utils.ts new file mode 100644 index 00000000..f98338a5 --- /dev/null +++ b/webapp/src/app/modules/patent-detail/patent-detail.utils.ts @@ -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(); + + 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(); + + 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(); +} diff --git a/webapp/src/app/modules/patents/patents.component.html b/webapp/src/app/modules/patents/patents.component.html index 6ffe47bd..3e3a64c6 100644 --- a/webapp/src/app/modules/patents/patents.component.html +++ b/webapp/src/app/modules/patents/patents.component.html @@ -85,213 +85,6 @@
} @else if (error) {

Fehler beim Laden der Patente.

- } @else if (showDetail && selectedPatent) { -
- - -

{{ selectedPatent.title ?? selectedPatent.patent_id }}

- -
- @for (row of getPatentMetadataRows(selectedPatent); track row.label) { -
-
{{ row.label }}
-
- @if (row.variant === 'source') { - {{ row.value }} - } @else { - {{ row.value }} - } -
-
- } -
- - @if (selectedPatent.abstract) { -
-

Abstract

-

{{ selectedPatent.abstract }}

-
- } - -
-

Erfinder

-
    - @for (inv of selectedPatent.inventors; track inv) { -
  • {{ inv }}
  • - } -
-
- - @if (selectedPatent.assignees.length > 0) { -
-

Anmelder

-
    - @for (a of selectedPatent.assignees; track a) { -
  • {{ a }}
  • - } -
-
- } - - @if (selectedPatent.ipc_descriptions.length > 0) { -
-

Klassifikation (IPC)

-
- @for ( - card of getClassificationCards( - selectedPatent.ipc_descriptions, - 'IPC' - ); - track card.key - ) { -
-
-
- @for (sym of card.symbols; track sym) { - {{ sym }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- @if (card.primaryDescription) { -

- {{ - isClassificationExpanded(card.key) - ? card.primaryDescription - : getDescriptionPreview(card.primaryDescription) - }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.ipc.length > 0) { -
-

Klassifikation (IPC)

-
    - @for (ipc of selectedPatent.ipc; track ipc) { -
  • {{ ipc }}
  • - } -
-
- } - - @if (selectedPatent.cpc_descriptions.length > 0) { -
-

Klassifikation (CPC)

-
- @for ( - card of getClassificationCards( - selectedPatent.cpc_descriptions, - 'CPC' - ); - track card.key - ) { -
-
-
- @for (sym of card.symbols; track sym) { - {{ sym }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- @if (card.primaryDescription) { -

- {{ - isClassificationExpanded(card.key) - ? card.primaryDescription - : getDescriptionPreview(card.primaryDescription) - }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.cpc.length > 0) { -
-

Klassifikation (CPC)

-
    - @for (cpc of selectedPatent.cpc; track cpc) { -
  • {{ cpc }}
  • - } -
-
- } -
} @else if (patents.length === 0) {

Keine Patente gefunden.

@@ -305,7 +98,7 @@ + (click)="openPatent(patent)"> {{ patent.title ?? patent.patent_id @@ -331,7 +124,7 @@ @@ -344,12 +137,10 @@ - @if (!showDetail) { - - }
diff --git a/webapp/src/app/modules/patents/patents.component.ts b/webapp/src/app/modules/patents/patents.component.ts index c0d056f0..42a04222 100644 --- a/webapp/src/app/modules/patents/patents.component.ts +++ b/webapp/src/app/modules/patents/patents.component.ts @@ -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(); private searchSubject = new Subject(); 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(); - 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(); - 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; - } } 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 b8389633..085a9c9b 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.html +++ b/webapp/src/app/modules/person-patents/person-patents.component.html @@ -6,182 +6,8 @@

Keine Patente gefunden.

} @else {
-
- @if (showDetail && selectedPatent) { -
- - -

{{ selectedPatent.title ?? selectedPatent.patent_id }}

- - @if (hasPatentMetadata(selectedPatent)) { -
-
- @for (row of getPatentMetadataRows(selectedPatent); track row.label) { -
-
{{ row.label }}
-
- @if (row.variant === 'source') { - - {{ row.value }} - - } @else { - {{ row.value }} - } -
-
- } -
-
- } - - @if (selectedPatent.abstract) { -
-

Abstract

-

{{ selectedPatent.abstract }}

-
- } - -
-

Erfinder

-
    - @for (inventor of selectedPatent.inventors; track inventor) { -
  • {{ inventor }}
  • - } -
-
- - @if (selectedPatent.assignees.length > 0) { -
-

Anmelder

-
    - @for (assignee of selectedPatent.assignees; track assignee) { -
  • {{ assignee }}
  • - } -
-
- } - - @if (selectedPatent.ipc_descriptions.length > 0) { -
-

Klassifikation (IPC)

-
- @for (card of getClassificationCards(selectedPatent.ipc_descriptions, 'IPC'); track card.key) { -
-
-
- @for (symbol of card.symbols; track symbol) { - {{ symbol }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- - @if (card.primaryDescription) { -

- {{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.ipc.length > 0) { -
-

Klassifikation (IPC)

-
    - @for (ipc of selectedPatent.ipc; track ipc) { -
  • {{ ipc }}
  • - } -
-
- } - - @if (selectedPatent.cpc_descriptions.length > 0) { -
-

Klassifikation (CPC)

-
- @for (card of getClassificationCards(selectedPatent.cpc_descriptions, 'CPC'); track card.key) { -
-
-
- @for (symbol of card.symbols; track symbol) { - {{ symbol }} - } -
-
- {{ card.system }} - {{ card.levelLabel }} -
-
- - @if (card.primaryDescription) { -

- {{ isClassificationExpanded(card.key) ? card.primaryDescription : getDescriptionPreview(card.primaryDescription) }} -

- @if (isLongDescription(card.primaryDescription)) { - - } - } - - @if (card.hierarchy.length > 0) { -
- @for (row of card.hierarchy; track row.label) { -
-
{{ row.label }}
-
{{ row.value }}
-
- } -
- } -
- } -
-
- } @else if (selectedPatent.cpc.length > 0) { -
-

Klassifikation (CPC)

-
    - @for (cpc of selectedPatent.cpc; track cpc) { -
  • {{ cpc }}
  • - } -
-
- } - -
- } - -
+
- @if (selectedPatent && !showDetail) { + @if (selectedPatent) {

{{ selectedPatent.title ?? selectedPatent.patent_id }}

diff --git a/webapp/src/app/modules/person-patents/person-patents.component.ts b/webapp/src/app/modules/person-patents/person-patents.component.ts index a28131fa..121d09f6 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.ts +++ b/webapp/src/app/modules/person-patents/person-patents.component.ts @@ -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(); 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(); - - 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(); - - 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); } }