refactor: clean up patents module
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -20,29 +20,23 @@
|
||||
<span class="summary-value">{{ getUsptoCount() }}</span>
|
||||
<span class="summary-label"> USPTO</span>
|
||||
</p>
|
||||
<button
|
||||
class="rebuild-button"
|
||||
type="button"
|
||||
[disabled]="rebuilding"
|
||||
(click)="rebuildPatents()">
|
||||
{{ rebuilding ? 'Aktualisiere...' : 'Neu zuordnen' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="patents-content">
|
||||
|
||||
<div class="patents-list">
|
||||
<div class="patents-list-toolbar">
|
||||
<div class="filter-bar">
|
||||
<label class="sort-control">
|
||||
<span>Filter nach Quelle:</span>
|
||||
<button [class.active]="activeFilter === 'all'" (click)="setFilter('all')">Alle</button>
|
||||
<button [class.active]="activeFilter === 'EPO'" (click)="setFilter('EPO')">EPO</button>
|
||||
<button [class.active]="activeFilter === 'USPTO'" (click)="setFilter('USPTO')">USPTO</button>
|
||||
</div>
|
||||
<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="score">Relevanz</option>
|
||||
<option value="date">Datum</option>
|
||||
<option value="title">Titel</option>
|
||||
</select>
|
||||
@@ -55,7 +49,6 @@
|
||||
<th>Patent</th>
|
||||
<th>Quelle</th>
|
||||
<th>Jahr</th>
|
||||
<th>Score</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -70,7 +63,6 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ patent.publication_year ?? '-' }}</td>
|
||||
<td>{{ patent.confidence_score }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -102,23 +94,8 @@
|
||||
<span class="stat-label">Datum</span>
|
||||
<span class="stat-value">{{ formatDate(selectedPatent.publication_date) }}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Relevanz</span>
|
||||
<span class="stat-value">{{ selectedPatent.confidence_score }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (selectedPatent.match_signals?.length) {
|
||||
<div class="detail-section">
|
||||
<h4>Zuordnungs-Signale</h4>
|
||||
<ul class="tag-list tag-list--compact">
|
||||
@for (signal of selectedPatent.match_signals; track signal) {
|
||||
<li class="tag tag--signal">{{ formatSignal(signal) }}</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (selectedPatent.abstract) {
|
||||
<div class="detail-section">
|
||||
<h4>Abstract</h4>
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.summary-line {
|
||||
margin: 0;
|
||||
@@ -23,22 +21,6 @@
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.rebuild-button {
|
||||
margin-left: auto;
|
||||
padding: 8px 14px;
|
||||
border: 1px solid #bdd4ff;
|
||||
border-radius: 20px;
|
||||
background: #f0f6ff;
|
||||
color: #0b63ce;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
color: #333;
|
||||
}
|
||||
@@ -50,33 +32,35 @@
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
width: fit-content;
|
||||
padding: 10px 14px;
|
||||
border-radius: 20px;
|
||||
background: #f2f2f2;
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
|
||||
span {
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 6px 14px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 20px;
|
||||
background: white;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #111827;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
|
||||
&:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
outline: none;
|
||||
|
||||
&.active {
|
||||
background: #f0f6ff;
|
||||
color: #0b63ce;
|
||||
border-color: #bdd4ff;
|
||||
font-weight: 600;
|
||||
color: #0b63ce;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,12 +265,6 @@
|
||||
color: #1e40af;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.3;
|
||||
|
||||
&--signal {
|
||||
background: #eef7ee;
|
||||
border-color: #cfe6cf;
|
||||
color: #2f6b2f;
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import {
|
||||
PatentsService,
|
||||
PatentEntry,
|
||||
PatentSearchMeta,
|
||||
} from '../../api/api/patents.service';
|
||||
import { PatentsService, PatentEntry } from '../../api/api/patents.service';
|
||||
|
||||
type SortMode = 'score' | 'date' | 'title';
|
||||
type SortMode = 'date' | 'title';
|
||||
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
||||
|
||||
const SIGNAL_LABELS: Record<string, string> = {
|
||||
full_name_match: 'Vollständiger Name',
|
||||
last_name_match: 'Nachname',
|
||||
first_name_match: 'Vorname',
|
||||
institution_match: 'Institution',
|
||||
topic_match: 'Forschungsthema',
|
||||
coauthor_match: 'Ko-Autor',
|
||||
publication_topic_match: 'Publikations-Thema',
|
||||
manual_include: 'Manuell hinzugefügt',
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-patents',
|
||||
imports: [CommonModule],
|
||||
@@ -36,22 +21,19 @@ export class PersonPatentsComponent implements OnInit {
|
||||
filteredPatents: PatentEntry[] = [];
|
||||
authorName: string | null = null;
|
||||
selectedPatent: PatentEntry | null = null;
|
||||
searchMeta: PatentSearchMeta | null = null;
|
||||
|
||||
loading = true;
|
||||
rebuilding = false;
|
||||
error = false;
|
||||
authorId = '';
|
||||
|
||||
activeFilter: SourceFilter = 'all';
|
||||
sortMode: SortMode = 'score';
|
||||
sortMode: SortMode = 'date';
|
||||
|
||||
selectedPage = 1;
|
||||
readonly pageSize = 10;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.parent?.paramMap.subscribe((params) => {
|
||||
this.authorId = params.get('id') ?? '';
|
||||
const authorId = params.get('id') ?? '';
|
||||
|
||||
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
|
||||
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
|
||||
@@ -63,51 +45,23 @@ export class PersonPatentsComponent implements OnInit {
|
||||
this.sortMode = sortFromUrl;
|
||||
}
|
||||
|
||||
if (this.authorId) {
|
||||
this.loadPatents();
|
||||
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;
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadPatents(refresh = false): void {
|
||||
this.loading = true;
|
||||
this.error = false;
|
||||
|
||||
this.patentsApi
|
||||
.getPatentsByAuthor(this.authorId, 'body', false, {
|
||||
refresh,
|
||||
transferCache: false,
|
||||
})
|
||||
.subscribe({
|
||||
next: (result) => this.applyResult(result),
|
||||
error: () => {
|
||||
this.error = true;
|
||||
this.loading = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
rebuildPatents(): void {
|
||||
if (!this.authorId || this.rebuilding) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.rebuilding = true;
|
||||
this.error = false;
|
||||
|
||||
this.patentsApi.rebuildPatentsByAuthor(this.authorId).subscribe({
|
||||
next: (result) => {
|
||||
this.applyResult(result);
|
||||
this.rebuilding = false;
|
||||
},
|
||||
error: () => {
|
||||
this.error = true;
|
||||
this.rebuilding = false;
|
||||
this.loading = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
setFilter(filter: SourceFilter): void {
|
||||
this.activeFilter = filter;
|
||||
this.selectedPage = 1;
|
||||
@@ -127,22 +81,6 @@ export class PersonPatentsComponent implements OnInit {
|
||||
this.updateQueryParams();
|
||||
}
|
||||
|
||||
formatSignal(signal: string): string {
|
||||
return SIGNAL_LABELS[signal] ?? signal;
|
||||
}
|
||||
|
||||
private applyResult(result: {
|
||||
patents?: PatentEntry[];
|
||||
author_name?: string | null;
|
||||
search_meta?: PatentSearchMeta | null;
|
||||
}): void {
|
||||
this.patents = result.patents ?? [];
|
||||
this.authorName = result.author_name ?? null;
|
||||
this.searchMeta = result.search_meta ?? null;
|
||||
this.applyFilter();
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
private applyFilter(): void {
|
||||
let patents = this.patents;
|
||||
|
||||
@@ -155,13 +93,14 @@ export class PersonPatentsComponent implements OnInit {
|
||||
|
||||
private sortPatents(patents: PatentEntry[]): PatentEntry[] {
|
||||
return [...patents].sort((a, b) => {
|
||||
if (this.sortMode === 'score') {
|
||||
return b.confidence_score - a.confidence_score;
|
||||
}
|
||||
if (this.sortMode === 'date') {
|
||||
return (b.publication_date ?? '').localeCompare(a.publication_date ?? '');
|
||||
return (b.publication_date ?? '').localeCompare(
|
||||
a.publication_date ?? '',
|
||||
);
|
||||
}
|
||||
return (a.title ?? '').localeCompare(b.title ?? '', 'de', { sensitivity: 'base' });
|
||||
return (a.title ?? '').localeCompare(b.title ?? '', 'de', {
|
||||
sensitivity: 'base',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -182,7 +121,7 @@ export class PersonPatentsComponent implements OnInit {
|
||||
}
|
||||
|
||||
private isValidSortMode(value: string | null): value is SortMode {
|
||||
return value === 'score' || value === 'date' || value === 'title';
|
||||
return value === 'date' || value === 'title';
|
||||
}
|
||||
|
||||
getPagedPatents(): PatentEntry[] {
|
||||
|
||||
Reference in New Issue
Block a user