Merge branch 'ts-136-patent-to-researchers-v2' of https://project.nes.uni-due.de/gitea/lbs/smartguide into feature/dfg-details

This commit is contained in:
2026-06-25 19:17:45 +02:00
13 changed files with 2278 additions and 815 deletions
+174 -148
View File
@@ -1,148 +1,174 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import {
HttpClient,
HttpHeaders,
HttpParams,
HttpResponse,
HttpEvent,
HttpParameterCodec,
HttpContext,
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { PatentsByAuthorResponse } from '../model/patentsByAuthorResponse';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root',
})
export class PatentsService extends BaseService {
constructor(
protected httpClient: HttpClient,
@Optional() @Inject(BASE_PATH) basePath: string | string[],
@Optional() configuration?: Configuration,
) {
super(basePath, configuration);
}
/**
* Get patents matched to an author by name.
* @endpoint get /api/inse-service/authors/{author_id}/patents
* @param authorId
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getPatentsByAuthor(
authorId: string,
observe?: 'body',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<PatentsByAuthorResponse>;
public getPatentsByAuthor(
authorId: string,
observe?: 'response',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpResponse<PatentsByAuthorResponse>>;
public getPatentsByAuthor(
authorId: string,
observe?: 'events',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpEvent<PatentsByAuthorResponse>>;
public getPatentsByAuthor(
authorId: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (authorId === null || authorId === undefined) {
throw new Error(
'Required parameter authorId was null or undefined when calling getPatentsByAuthor.',
);
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined =
options?.httpHeaderAccept ??
this.configuration.selectHeaderAccept(['application/json']);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set(
'Accept',
localVarHttpHeaderAcceptSelected,
);
}
const localVarHttpContext: HttpContext =
options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam({ name: 'authorId', value: authorId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}/patents`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<PatentsByAuthorResponse>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
}
/**
* Innovation Search Engine API
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import {
HttpClient,
HttpHeaders,
HttpParams,
HttpResponse,
HttpEvent,
HttpParameterCodec,
HttpContext,
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
export interface IpcClassification {
symbol: string;
section: string | null;
class: string | null;
subclass: string | null;
main_group: string | null;
subgroup: string | null;
}
export interface PatentEntry {
patent_id: string;
source: string;
title: string | null;
abstract: string | null;
publication_date: string | null;
publication_year: string | null;
application_number: string | null;
application_date: string | null;
kind: string | null;
application_type: string | null;
number_of_claims: number | null;
status: string | null;
inventors: string[];
assignees: string[];
ipc: string[];
ipc_descriptions: IpcClassification[];
cpc: string[];
cpc_descriptions: IpcClassification[];
country: string | null;
}
export interface PatentsByAuthorResponse {
author_id: string;
author_name: string | null;
patent_count: number;
patents: PatentEntry[];
}
type GetPatentsByAuthorOptions = {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
};
@Injectable({
providedIn: 'root',
})
export class PatentsService extends BaseService {
constructor(
protected httpClient: HttpClient,
@Optional() @Inject(BASE_PATH) basePath: string | string[],
@Optional() configuration?: Configuration,
) {
super(basePath, configuration);
}
/**
* Get patents by author.
* @endpoint get /api/inse-service/authors/{author_id}/patents
* @param authorId
* @param observe
* @param reportProgress
*/
public getPatentsByAuthor(
authorId: string,
observe?: 'body',
reportProgress?: boolean,
options?: GetPatentsByAuthorOptions,
): Observable<PatentsByAuthorResponse>;
public getPatentsByAuthor(
authorId: string,
observe?: 'response',
reportProgress?: boolean,
options?: GetPatentsByAuthorOptions,
): Observable<HttpResponse<PatentsByAuthorResponse>>;
public getPatentsByAuthor(
authorId: string,
observe?: 'events',
reportProgress?: boolean,
options?: GetPatentsByAuthorOptions,
): Observable<HttpEvent<PatentsByAuthorResponse>>;
public getPatentsByAuthor(
authorId: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: GetPatentsByAuthorOptions,
): Observable<any> {
if (authorId === null || authorId === undefined) {
throw new Error(
'Required parameter authorId was null or undefined when calling getPatentsByAuthor.',
);
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined =
options?.httpHeaderAccept ??
this.configuration.selectHeaderAccept(['application/json']);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set(
'Accept',
localVarHttpHeaderAcceptSelected,
);
}
const localVarHttpContext: HttpContext =
options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam({
name: 'authorId',
value: authorId,
in: 'path',
style: 'simple',
explode: false,
dataType: 'string',
dataFormat: undefined,
})}/patents`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<PatentsByAuthorResponse>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
}
@@ -1,179 +1,300 @@
@if (loading) {
<p class="message">Lade Patente...</p>
} @else if (error) {
<p class="message">Fehler beim Laden der Patente.</p>
} @else if (patents.length === 0) {
<p class="message">Keine Patente gefunden.</p>
} @else {
<div class="patents-container">
<div class="patents-summary">
<p class="summary-line">
<span class="summary-value">{{ filteredPatents.length }}</span>
<span class="summary-label"> Patente</span>
</p>
<p class="summary-line">
<span class="summary-value">{{ getEpoCount() }}</span>
<span class="summary-label"> EPO</span>
</p>
<p class="summary-line">
<span class="summary-value">{{ getUsptoCount() }}</span>
<span class="summary-label"> USPTO</span>
</p>
</div>
@if (showDetail && selectedPatent) {
<button class="back-btn" (click)="showDetail = false">
← Zurück zu den Patenten
</button>
}
<div class="patents-content">
@if (showDetail && selectedPatent) {
<div class="patent-full-detail">
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
@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 (hasAsignees(selectedPatent)) {
<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 (hasIpcs(selectedPatent)) {
<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>
}
</div>
}
<div class="patents-list" [class.hidden]="showDetail">
<div class="patents-list-toolbar">
<label class="sort-control">
<span>Filter nach Quelle:</span>
<select
[value]="activeFilter"
(change)="setFilter($any($event.target).value)">
<option value="all">Alle</option>
<option value="EPO">EPO</option>
<option value="USPTO">USPTO</option>
</select>
</label>
<label class="sort-control">
<span>Sortieren nach:</span>
<select
[value]="sortMode"
(change)="setSortMode($any($event.target).value)">
<option value="date">Datum</option>
<option value="title">Titel</option>
</select>
</label>
</div>
<table>
<thead>
<tr>
<th>Patent</th>
<th>Quelle</th>
<th>Jahr</th>
</tr>
</thead>
<tbody>
@for (patent of getPagedPatents(); track patent.patent_id) {
<tr
[class.selected]="selectedPatent === patent"
(click)="selectPatent(patent)">
<td class="patent-title">
{{ patent.title ?? patent.patent_id }}
</td>
<td>
<span
class="source-badge source-badge--{{
patent.source.toLowerCase()
}}">
{{ patent.source }}
</span>
</td>
<td>{{ patent.publication_year ?? '-' }}</td>
</tr>
}
</tbody>
</table>
@if (hasPagination()) {
<div class="pagination">
<button
[disabled]="selectedPage === 1"
(click)="setPage(selectedPage - 1)">
Zurück
</button>
<span>Seite {{ selectedPage }} von {{ getPageCount() }}</span>
<button
[disabled]="selectedPage === getPageCount()"
(click)="setPage(selectedPage + 1)">
Weiter
</button>
</div>
}
</div>
@if (selectedPatent) {
<div class="patent-detail">
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
<div class="detail-stats">
<div class="stat stat--clickable" (click)="openDetail()">
<span class="stat-label">Quelle</span>
<span class="stat-value">
<span
class="source-badge source-badge--{{
selectedPatent.source.toLowerCase()
}}">
{{ selectedPatent.source }}
</span>
</span>
</div>
<div class="stat">
<span class="stat-label">Patent-Nr.</span>
<span class="stat-value">{{ selectedPatent.patent_id }}</span>
</div>
<div class="stat">
<span class="stat-label">Datum</span>
<span class="stat-value">{{
formatDate(selectedPatent.publication_date || '')
}}</span>
</div>
</div>
</div>
} @else {
<div class="patent-detail empty">
<p>Klicke auf ein Patent für Details.</p>
</div>
}
</div>
</div>
}
@if (loading) {
<p class="message">Lade Patente...</p>
} @else if (error) {
<p class="message">Fehler beim Laden der Patente.</p>
} @else if (patents.length === 0) {
<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-toolbar">
<label class="sort-control">
<span>Filter nach Quelle:</span>
<select [value]="activeFilter" (change)="setFilter($any($event.target).value)">
<option value="all">Alle</option>
<option value="EPO">EPO</option>
<option value="USPTO">USPTO</option>
</select>
</label>
<label class="sort-control">
<span>Sortieren nach:</span>
<select [value]="sortMode" (change)="setSortMode($any($event.target).value)">
<option value="date">Datum</option>
<option value="title">Titel</option>
</select>
</label>
</div>
<table>
<thead>
<tr>
<th>Patent</th>
<th>Quelle</th>
<th>Jahr</th>
</tr>
</thead>
<tbody>
@for (patent of getPagedPatents(); track trackPatent($index, patent)) {
<tr
[class.selected]="selectedPatent === patent"
(click)="selectPatent(patent)">
<td class="patent-title">{{ patent.title ?? patent.patent_id }}</td>
<td>
<span class="source-badge source-badge--{{ patent.source.toLowerCase() }}">
{{ patent.source }}
</span>
</td>
<td>{{ patent.publication_year ?? '-' }}</td>
</tr>
}
</tbody>
</table>
@if (hasPagination()) {
<div class="pagination">
<button [disabled]="selectedPage === 1" (click)="setPage(selectedPage - 1)">Zurück</button>
<span>Seite {{ selectedPage }} von {{ getPageCount() }}</span>
<button [disabled]="selectedPage === getPageCount()" (click)="setPage(selectedPage + 1)">Weiter</button>
</div>
}
</div>
@if (selectedPatent && !showDetail) {
<div class="patent-detail">
<h3>{{ selectedPatent.title ?? selectedPatent.patent_id }}</h3>
<div class="detail-stats">
<div class="stat">
<span class="stat-label">Quelle</span>
<span class="stat-value">
<span class="source-badge source-badge--{{ selectedPatent.source.toLowerCase() }}">
{{ selectedPatent.source }}
</span>
</span>
</div>
<div class="stat">
<span class="stat-label">Patent-Nr.</span>
<span class="stat-value">{{ selectedPatent.patent_id }}</span>
</div>
<div class="stat">
<span class="stat-label">Datum</span>
<span class="stat-value">{{ formatDate(selectedPatent.publication_date) }}</span>
</div>
@if (getPublicationStageLabel(selectedPatent); as stageLabel) {
<div class="stat">
<span class="stat-label">Publikationsstufe</span>
<span class="stat-value">{{ stageLabel }}</span>
</div>
}
</div>
@if (getAbstractPreview(selectedPatent.abstract); as abstractPreview) {
<p class="patent-detail-preview">{{ abstractPreview }}</p>
}
<button type="button" class="patent-detail-action" (click)="openDetail()">
<span class="patent-detail-action__label">Patentdetails anzeigen</span>
<span class="material-icons" aria-hidden="true">chevron_right</span>
</button>
<p class="patent-detail-hint">
Abstract, Erfinder, Anmelder und IPC/CPC-Klassifikation
</p>
</div>
} @else {
<div class="patent-detail overview">
<p class="overview-title">Patentübersicht</p>
<p class="overview-subtitle">Alle Patente dieser Person im Überblick.</p>
<div class="overview-stats">
<div class="overview-stat">
<span class="overview-value">{{ patents.length }}</span>
<span class="overview-label">Patente</span>
</div>
<div class="overview-stat">
<span class="overview-value">{{ getEpoCount() }}</span>
<span class="overview-label">EPO</span>
</div>
<div class="overview-stat">
<span class="overview-value">{{ getUsptoCount() }}</span>
<span class="overview-label">USPTO</span>
</div>
</div>
<p class="overview-hint">Wähle links ein Patent aus, um Kurzinfos und Details zu sehen.</p>
</div>
}
</div>
</div>
}
@@ -1,306 +1,564 @@
.message {
padding: 16px;
color: #666;
}
.patents-container {
padding: 16px;
display: flex;
flex-direction: column;
gap: 16px;
}
.patents-summary {
margin-bottom: 8px;
display: flex;
gap: 24px;
.summary-line {
margin: 0;
font-size: 14px;
color: #333;
}
.summary-label {
color: #333;
}
.summary-value {
font-weight: 600;
color: #333;
}
}
.sort-control {
display: inline-flex;
align-items: center;
gap: 6px;
width: fit-content;
padding: 10px 14px;
border-radius: 20px;
background: #f2f2f2;
color: #333;
font-size: 14px;
span {
color: #555;
}
select {
border: 0;
background: transparent;
color: #111827;
font: inherit;
cursor: pointer;
outline: none;
}
}
.patents-content {
display: flex;
gap: 24px;
align-items: flex-start;
}
.patents-list {
flex: 1;
&.hidden {
display: none;
}
.patents-list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 18px;
flex-wrap: wrap;
}
table {
width: 100%;
border-collapse: collapse;
th {
text-align: left;
padding: 10px 12px;
border-bottom: 2px solid #e0e0e0;
font-weight: 600;
color: #333;
}
tr {
cursor: pointer;
&:hover {
background: #f5f5f5;
}
&.selected {
background: #f0f0f0;
}
}
td {
padding: 10px 12px;
border-bottom: 1px solid #f0f0f0;
}
.patent-title {
color: #333;
font-weight: 500;
max-width: 400px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
.source-badge {
display: inline-flex;
align-items: center;
padding: 3px 10px;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
&--epo {
background: #effaf3;
color: #24834f;
border: 1px solid #bdebcf;
}
&--uspto {
background: #f0f6ff;
color: #0b63ce;
border: 1px solid #bdd4ff;
}
}
.patent-detail {
width: 440px;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
background: #fafafa;
&.empty {
display: flex;
align-items: center;
justify-content: center;
color: #999;
min-height: 200px;
}
h3 {
margin: 0 0 16px 0;
font-size: 16px;
color: #333;
line-height: 1.4;
}
}
.detail-stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
.stat {
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 10px;
text-align: center;
.stat-label {
display: block;
font-size: 11px;
color: #666;
margin-bottom: 4px;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.stat-value {
display: block;
font-size: 15px;
font-weight: bold;
color: #333;
}
}
}
.stat--clickable {
cursor: pointer;
transition:
border-color 0.15s,
background 0.15s;
&:hover {
border-color: #0b63ce;
background: #f0f6ff;
}
}
.patent-full-detail {
flex: 1;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
background: #fafafa;
h3 {
margin: 0 0 16px 0;
font-size: 16px;
color: #333;
line-height: 1.4;
}
h4 {
margin: 16px 0 8px 0;
font-size: 14px;
color: #555;
font-weight: 600;
}
p {
font-size: 13px;
color: #444;
line-height: 1.6;
margin: 0;
}
}
.back-btn {
border: none;
background: none;
color: #333;
cursor: pointer;
font-size: 14px;
font-weight: 400;
padding: 0;
align-self: flex-start; // NEU
&:hover {
text-decoration: underline;
}
}
.detail-section {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid #eee;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 0;
padding: 0;
list-style: none;
&--compact .tag {
font-size: 0.75rem;
padding: 3px 8px;
}
}
.tag {
padding: 4px 10px;
border-radius: 999px;
background: #f0f6ff;
border: 1px solid #dbeafe;
color: #1e40af;
font-size: 0.8rem;
line-height: 1.3;
}
.pagination {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 12px;
button {
padding: 4px 10px;
border: 1px solid #d0d0d0;
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 12px;
&:disabled {
opacity: 0.5;
cursor: default;
}
}
span {
font-size: 12px;
color: #666;
}
}
.message {
padding: 16px;
color: #666;
}
.patents-container {
padding: 16px;
display: flex;
flex-direction: column;
gap: 16px;
}
.sort-control {
display: inline-flex;
align-items: center;
gap: 6px;
width: fit-content;
padding: 10px 14px;
border-radius: 20px;
background: #f2f2f2;
color: #333;
font-size: 14px;
span {
color: #555;
}
select {
border: 0;
background: transparent;
color: #111827;
font: inherit;
cursor: pointer;
outline: none;
}
}
.patents-content {
display: flex;
gap: 24px;
align-items: flex-start;
}
.patents-list {
flex: 1;
&.hidden {
display: none;
}
.patents-list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 18px;
flex-wrap: wrap;
}
table {
width: 100%;
border-collapse: collapse;
th {
text-align: left;
padding: 10px 12px;
border-bottom: 2px solid #e0e0e0;
font-weight: 600;
color: #333;
}
tr {
cursor: pointer;
&:hover {
background: #f5f5f5;
}
&.selected {
background: #f0f0f0;
}
}
td {
padding: 10px 12px;
border-bottom: 1px solid #f0f0f0;
}
.patent-title {
color: #333;
font-weight: 500;
max-width: 400px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
.source-badge {
display: inline-flex;
align-items: center;
padding: 3px 10px;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
&--epo {
background: #effaf3;
color: #24834f;
border: 1px solid #bdebcf;
}
&--uspto {
background: #f0f6ff;
color: #0b63ce;
border: 1px solid #bdd4ff;
}
}
.patent-detail {
width: 440px;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
background: #fafafa;
&.empty {
display: flex;
align-items: center;
justify-content: center;
color: #999;
min-height: 200px;
}
&.overview {
display: flex;
flex-direction: column;
gap: 12px;
.overview-title {
font-size: 15px;
font-weight: 600;
color: #333;
margin: 0;
}
.overview-subtitle {
font-size: 13px;
color: #888;
margin: 0;
}
.overview-stats {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 10px;
margin-top: 4px;
}
.overview-stat {
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 12px 8px;
text-align: center;
.overview-value {
display: block;
font-size: 22px;
font-weight: 700;
color: #333;
}
.overview-label {
display: block;
font-size: 12px;
color: #888;
margin-top: 4px;
}
}
.overview-hint {
font-size: 12px;
color: #aaa;
margin: 0;
}
}
h3 {
margin: 0 0 16px 0;
font-size: 16px;
color: #333;
line-height: 1.4;
}
}
.detail-stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
.stat {
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 10px;
text-align: center;
.stat-label {
display: block;
font-size: 11px;
color: #666;
margin-bottom: 4px;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.stat-value {
display: block;
font-size: 15px;
font-weight: bold;
color: #333;
}
}
}
.patent-detail-preview {
margin: 14px 0 0;
font-size: 13px;
line-height: 1.55;
color: #555;
}
.patent-detail-action {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
margin-top: 16px;
padding: 12px 14px;
border: 1px solid #bdd4ff;
border-radius: 10px;
background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
color: #0b63ce;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
&:hover {
border-color: #0b63ce;
background: #f0f6ff;
box-shadow: 0 2px 8px rgba(11, 99, 206, 0.12);
}
.material-icons {
font-size: 20px;
}
}
.patent-detail-hint {
margin: 8px 0 0;
font-size: 12px;
line-height: 1.4;
color: #888;
text-align: center;
}
.patent-full-detail {
flex: 1;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 20px;
background: #fafafa;
h3 {
margin: 0 0 4px 0;
font-size: 16px;
color: #333;
line-height: 1.4;
}
h4 {
margin: 16px 0 8px 0;
font-size: 14px;
color: #555;
font-weight: 600;
}
p {
font-size: 13px;
color: #444;
line-height: 1.6;
margin: 0;
}
}
.back-btn {
display: inline-flex;
align-items: center;
gap: 0.4rem;
width: auto;
margin-bottom: 1rem;
padding: 0.5rem 0.85rem;
border: 1px solid #d6e3f8;
border-radius: 999px;
background: #f8fbff;
color: #2563eb;
font-size: 0.9rem;
font-weight: 600;
cursor: pointer;
transition:
background-color 0.15s ease,
border-color 0.15s ease,
color 0.15s ease,
box-shadow 0.15s ease;
&:hover {
background: #eef5ff;
border-color: #bcd3f7;
color: #1d4ed8;
box-shadow: 0 1px 4px rgba(37, 99, 235, 0.12);
}
&:focus-visible {
outline: 2px solid #93c5fd;
outline-offset: 2px;
}
}
.detail-section {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid #eee;
}
.patent-meta {
&--inline {
margin: 12px 0 20px;
}
&__list {
margin: 0;
border: 1px solid #e2e8f4;
border-radius: 12px;
background: linear-gradient(180deg, #fff 0%, #f8faff 100%);
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
overflow: hidden;
}
&__row {
display: grid;
grid-template-columns: minmax(130px, 38%) 1fr;
gap: 12px 16px;
align-items: center;
padding: 11px 16px;
border-top: 1px solid #eef2f8;
&:first-child {
border-top: 0;
}
dt {
margin: 0;
font-size: 12px;
font-weight: 500;
color: #64748b;
line-height: 1.35;
}
dd {
margin: 0;
font-size: 14px;
font-weight: 600;
color: #1e293b;
line-height: 1.35;
word-break: break-word;
}
}
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 0;
padding: 0;
list-style: none;
&--compact .tag {
font-size: 0.75rem;
padding: 3px 8px;
}
}
.tag {
padding: 4px 10px;
border-radius: 999px;
background: #f0f6ff;
border: 1px solid #dbeafe;
color: #1e40af;
font-size: 0.8rem;
line-height: 1.3;
}
.classification-section {
&--ipc .classification-card {
background: #f0f6ff;
border-color: #bfdbfe;
}
&--ipc .classification-badge--system {
background: #dbeafe;
color: #1d4ed8;
}
&--cpc .classification-card {
background: #f0fdf4;
border-color: #bbf7d0;
}
&--cpc .classification-badge--system {
background: #dcfce7;
color: #15803d;
}
}
.classification-cards {
display: flex;
flex-direction: column;
gap: 10px;
}
.classification-card {
padding: 12px 14px;
border-radius: 10px;
border: 1px solid #dbeafe;
}
.classification-card__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.classification-card__codes {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.classification-card__badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.classification-code {
font-size: 0.9rem;
font-weight: 700;
color: #0f172a;
}
.classification-badge {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border-radius: 999px;
font-size: 0.68rem;
font-weight: 700;
letter-spacing: 0.02em;
text-transform: uppercase;
}
.classification-badge--level {
background: #e2e8f0;
color: #475569;
}
.classification-summary {
margin: 10px 0 0;
font-size: 0.84rem;
line-height: 1.5;
color: #334155;
}
.classification-toggle {
margin-top: 6px;
padding: 0;
border: 0;
background: none;
color: #2563eb;
font-size: 0.78rem;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
.classification-hierarchy {
margin: 10px 0 0;
padding-top: 10px;
border-top: 1px solid rgba(15, 23, 42, 0.08);
}
.classification-hierarchy__row {
display: grid;
grid-template-columns: 88px 1fr;
gap: 8px;
margin-bottom: 6px;
dt {
margin: 0;
font-size: 0.72rem;
font-weight: 700;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.03em;
}
dd {
margin: 0;
font-size: 0.8rem;
line-height: 1.45;
color: #334155;
}
}
.pagination {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 12px;
button {
padding: 4px 10px;
border: 1px solid #d0d0d0;
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 12px;
&:disabled {
opacity: 0.5;
cursor: default;
}
}
span {
font-size: 12px;
color: #666;
}
}
@@ -1,174 +1,405 @@
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 } from '../../api';
type SortMode = 'date' | 'title';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
@Component({
selector: 'app-person-patents',
imports: [CommonModule],
templateUrl: './person-patents.component.html',
styleUrl: './person-patents.component.scss',
})
export class PersonPatentsComponent implements OnInit {
private route = inject(ActivatedRoute);
private router = inject(Router);
private patentsApi = inject(PatentsService);
patents: PatentEntry[] = [];
filteredPatents: PatentEntry[] = [];
authorName: string | null = null;
selectedPatent: PatentEntry | null = null;
showDetail = false;
loading = true;
error = false;
activeFilter: SourceFilter = 'all';
sortMode: SortMode = 'date';
selectedPage = 1;
readonly pageSize = 10;
hasAsignees(selectedPatent: PatentEntry | null): boolean {
return !!selectedPatent?.assignees && selectedPatent.assignees.length > 0;
}
hasIpcs(selectedPatent: PatentEntry | null): boolean {
return !!selectedPatent?.ipc && selectedPatent.ipc.length > 0;
}
ngOnInit(): void {
this.route.parent?.paramMap.subscribe((params) => {
const authorId = params.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
}
if (authorId) {
this.patentsApi.getPatentsByAuthor(authorId, 'body').subscribe({
next: (result) => {
this.patents = result.patents ?? [];
this.authorName = result.author_name ?? null;
this.applyFilter();
this.loading = false;
},
error: () => {
this.error = true;
this.loading = false;
},
});
}
});
}
setFilter(filter: SourceFilter): void {
this.activeFilter = filter;
this.selectedPage = 1;
this.selectedPatent = null;
this.showDetail = false;
this.applyFilter();
this.updateQueryParams();
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
this.applyFilter();
this.updateQueryParams();
}
selectPatent(patent: PatentEntry): void {
this.selectedPatent = patent;
this.showDetail = false;
this.updateQueryParams();
}
openDetail(): void {
this.showDetail = true;
}
private applyFilter(): void {
let patents = this.patents;
if (this.activeFilter !== 'all') {
patents = patents.filter((p) => p.source === this.activeFilter);
}
this.filteredPatents = this.sortPatents(patents);
}
private sortPatents(patents: PatentEntry[]): PatentEntry[] {
return [...patents].sort((a, b) => {
if (this.sortMode === 'date') {
return (b.publication_date ?? '').localeCompare(
a.publication_date ?? '',
);
}
return (a.title ?? '').localeCompare(b.title ?? '', 'de', {
sensitivity: 'base',
});
});
}
private updateQueryParams(): void {
this.router.navigate([], {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
},
queryParamsHandling: 'merge',
replaceUrl: true,
});
}
private isValidFilter(value: string | null): value is SourceFilter {
return value === 'all' || value === 'EPO' || value === 'USPTO';
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'date' || value === 'title';
}
getPagedPatents(): PatentEntry[] {
const start = (this.selectedPage - 1) * this.pageSize;
return this.filteredPatents.slice(start, start + this.pageSize);
}
getPageCount(): number {
return Math.max(1, Math.ceil(this.filteredPatents.length / this.pageSize));
}
hasPagination(): boolean {
return this.getPageCount() > 1;
}
setPage(page: number): void {
this.selectedPage = Math.min(Math.max(page, 1), this.getPageCount());
this.updateQueryParams();
}
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));
}
getEpoCount(): number {
return this.patents.filter((p) => p.source === 'EPO').length;
}
getUsptoCount(): number {
return this.patents.filter((p) => p.source === 'USPTO').length;
}
}
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { PatentsService, PatentEntry, IpcClassification } from '../../api/api/patents.service';
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',
imports: [CommonModule],
templateUrl: './person-patents.component.html',
styleUrl: './person-patents.component.scss',
})
export class PersonPatentsComponent implements OnInit {
private route = inject(ActivatedRoute);
private router = inject(Router);
private patentsApi = inject(PatentsService);
patents: PatentEntry[] = [];
filteredPatents: PatentEntry[] = [];
authorName: string | null = null;
selectedPatent: PatentEntry | null = null;
showDetail = false;
loading = true;
error = false;
activeFilter: SourceFilter = 'all';
sortMode: SortMode = 'date';
selectedPage = 1;
readonly pageSize = 10;
private expandedClassificationKeys = new Set<string>();
ngOnInit(): void {
this.route.parent?.paramMap.subscribe((params) => {
const authorId = params.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
}
if (authorId) {
this.patentsApi.getPatentsByAuthor(authorId, 'body').subscribe({
next: (result) => {
this.patents = result.patents ?? [];
this.authorName = result.author_name ?? null;
this.applyFilter();
this.loading = false;
},
error: () => {
this.error = true;
this.loading = false;
},
});
}
});
}
setFilter(filter: SourceFilter): void {
this.activeFilter = filter;
this.selectedPage = 1;
this.selectedPatent = null;
this.showDetail = false;
this.applyFilter();
this.updateQueryParams();
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
this.applyFilter();
this.updateQueryParams();
}
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();
}
private applyFilter(): void {
let patents = this.patents;
if (this.activeFilter !== 'all') {
patents = patents.filter((p) => p.source === this.activeFilter);
}
this.filteredPatents = this.sortPatents(patents);
}
private sortPatents(patents: PatentEntry[]): PatentEntry[] {
return [...patents].sort((a, b) => {
if (this.sortMode === 'date') {
return (b.publication_date ?? '').localeCompare(a.publication_date ?? '');
}
return (a.title ?? '').localeCompare(b.title ?? '', 'de', { sensitivity: 'base' });
});
}
private updateQueryParams(): void {
this.router.navigate([], {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
},
queryParamsHandling: 'merge',
replaceUrl: true,
});
}
private isValidFilter(value: string | null): value is SourceFilter {
return value === 'all' || value === 'EPO' || value === 'USPTO';
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'date' || value === 'title';
}
getPagedPatents(): PatentEntry[] {
const start = (this.selectedPage - 1) * this.pageSize;
return this.filteredPatents.slice(start, start + this.pageSize);
}
getPageCount(): number {
return Math.max(1, Math.ceil(this.filteredPatents.length / this.pageSize));
}
hasPagination(): boolean {
return this.getPageCount() > 1;
}
setPage(page: number): void {
this.selectedPage = Math.min(Math.max(page, 1), this.getPageCount());
this.updateQueryParams();
}
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));
}
getEpoCount(): number {
return this.patents.filter((p) => p.source === 'EPO').length;
}
getUsptoCount(): number {
return this.patents.filter((p) => p.source === 'USPTO').length;
}
trackPatent(_index: number, patent: PatentEntry): string {
return [
patent.source,
patent.patent_id,
patent.publication_date ?? '',
patent.kind ?? patent.application_type ?? '',
].join('|');
}
getAbstractPreview(abstract: string | null | undefined): string | null {
if (!abstract?.trim()) {
return null;
}
const text = abstract.trim();
if (text.length <= 160) {
return text;
}
return `${text.slice(0, 160).trimEnd()}…`;
}
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();
}
}