Add Person funding View and API integration
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-01 14:02:25 +02:00
parent ce4ccbf154
commit fac08044a8
4 changed files with 392 additions and 6 deletions
+24 -2
View File
@@ -1,7 +1,7 @@
/**
* My App Service
*
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
@@ -11,7 +11,7 @@
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
@@ -165,4 +165,26 @@ export class PersonsOpenApiService extends BaseService implements PersonsOpenApi
);
}
public getFundersByAuthor(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 getFundersByAuthor.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
let localVarPath = `/authors/${encodeURIComponent(authorId)}/funders`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<any>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: 'json',
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
}
@@ -1 +1,93 @@
<p>person-funding!</p>
@if (loading) {
<p class="message">Lade Förderungen...</p>
} @else if (error) {
<p class="message">Fehler beim Laden der Förderungen.</p>
} @else if (funders.length === 0) {
<p class="message">Keine Förderungen gefunden.</p>
} @else {
<div class="summary-card">
<span class="summary-label">Einzigartige Publikationen: </span>
<span class="summary-value">{{ getUniquePublicationCount() }}</span>
</div>
<div class="funding-summary">
<div class="summary-card">
<span class="summary-label">Förderer: </span>
<span class="summary-value">{{ funders.length }}</span>
</div>
</div>
<div class="funding-container">
<!-- Filter Buttons -->
<div class="filter-bar">
<span>Filter nach Position:</span>
<button [class.active]="activeFilter === 'all'" (click)="setFilter('all')">Alle</button>
<button [class.active]="activeFilter === 'first'" (click)="setFilter('first')">Erstautor</button>
<button [class.active]="activeFilter === 'middle'" (click)="setFilter('middle')">Mitautor</button>
<button [class.active]="activeFilter === 'last'" (click)="setFilter('last')">Letztautor</button>
</div>
<div class="funding-content">
<!-- Linke Seite: Tabelle -->
<div class="funding-list">
<table>
<thead>
<tr>
<th>Förderer</th>
<th>Publikationen</th>
</tr>
</thead>
<tbody>
@for (funder of filteredFunders; track funder.funder_id) {
<tr
[class.selected]="selectedFunder === funder"
(click)="selectFunder(funder)"
>
<td class="funder-name">{{ funder.funder_name }}</td>
<td>{{ funder.publication_count }}</td>
</tr>
}
</tbody>
</table>
</div>
<!-- Rechte Seite: Details -->
@if (selectedFunder) {
<div class="funding-detail">
<h3>{{ selectedFunder.funder_name }}</h3>
<div class="position-stats">
<div class="stat">
<span class="stat-label">Erstautor</span>
<span class="stat-value">{{ selectedFunder.author_position_count.first }}</span>
</div>
<div class="stat">
<span class="stat-label">Mitautor</span>
<span class="stat-value">{{ selectedFunder.author_position_count.middle }}</span>
</div>
<div class="stat">
<span class="stat-label">Letztautor</span>
<span class="stat-value">{{ selectedFunder.author_position_count.last }}</span>
</div>
</div>
<h4>Publikationen</h4>
<ul class="publication-list">
@for (id of getPublicationIds(selectedFunder); track id) {
<li>
<a [href]="id" target="_blank" rel="noopener">{{ id }}</a>
</li>
}
</ul>
</div>
} @else {
<div class="funding-detail empty">
<p>Klicke auf einen Förderer für Details.</p>
</div>
}
</div>
</div>
}
@@ -0,0 +1,197 @@
.message {
padding: 16px;
color: #666;
}
.funding-container {
padding: 16px;
display: flex;
flex-direction: column;
gap: 16px;
}
.filter-bar {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
span {
font-weight: 500;
color: #555;
}
button {
padding: 6px 14px;
border: 1px solid #ccc;
border-radius: 20px;
background: white;
cursor: pointer;
font-size: 14px;
transition: all 0.2s;
&:hover {
background: #f0f0f0;
}
&.active {
background: #3f51b5;
color: white;
border-color: #3f51b5;
}
}
}
.funding-content {
display: flex;
gap: 24px;
align-items: flex-start;
}
.funding-list {
flex: 1;
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;
transition: background 0.15s;
&:hover {
background: #f5f5f5;
}
&.selected {
background: #e8eaf6;
}
}
td {
padding: 10px 12px;
border-bottom: 1px solid #f0f0f0;
}
.funder-name {
color: #3f51b5;
font-weight: 500;
}
}
}
.funding-detail {
width: 340px;
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;
}
h4 {
margin: 16px 0 8px 0;
font-size: 14px;
color: #555;
}
}
.position-stats {
display: flex;
gap: 12px;
margin-bottom: 16px;
.stat {
flex: 1;
text-align: center;
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 10px;
.stat-label {
display: block;
font-size: 12px;
color: #666;
margin-bottom: 4px;
}
.stat-value {
display: block;
font-size: 22px;
font-weight: bold;
color: #3f51b5;
}
}
}
.publication-list {
list-style: none;
padding: 0;
margin: 0;
max-height: 300px;
overflow-y: auto;
li {
padding: 6px 0;
border-bottom: 1px solid #f0f0f0;
font-size: 13px;
a {
color: #3f51b5;
text-decoration: none;
word-break: break-all;
&:hover {
text-decoration: underline;
}
}
}
.funding-summary {
display: flex;
gap: 16px;
margin-bottom: 16px;
.summary-card {
background: #e8eaf6;
border-radius: 8px;
padding: 16px 24px;
text-align: center;
min-width: 150px;
.summary-value {
display: block;
font-size: 32px;
font-weight: bold;
color: #3f51b5;
}
.summary-label {
display: block;
font-size: 14px;
color: #555;
margin-top: 4px;
}
}
}
}
@@ -1,11 +1,86 @@
import { Component } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import { PersonsOpenApiService } from '../../api';
@Component({
selector: 'app-person-funding',
imports: [],
imports: [CommonModule],
templateUrl: './person-funding.component.html',
styleUrl: './person-funding.component.scss',
})
export class PersonFundingComponent {
export class PersonFundingComponent implements OnInit {
private route = inject(ActivatedRoute);
private personsApi = inject(PersonsOpenApiService);
funders: any[] = [];
filteredFunders: any[] = [];
selectedFunder: any = null;
activeFilter: string = 'all';
loading = true;
error = false;
ngOnInit(): void {
const authorId = this.route.parent?.snapshot.paramMap.get('id') ?? '';
if (authorId) {
this.personsApi.getFundersByAuthor(authorId).subscribe({
next: (result) => {
this.funders = result.funders ?? [];
this.filteredFunders = this.funders;
this.loading = false;
},
error: () => {
this.error = true;
this.loading = false;
}
});
}
}
selectFunder(funder: any): void {
this.selectedFunder = funder;
}
setFilter(filter: string): void {
this.activeFilter = filter;
this.selectedFunder = null;
if (filter === 'all') {
this.filteredFunders = this.funders;
} else {
this.filteredFunders = this.funders.filter(
f => f.author_position_count[filter] > 0
);
}
}
getPublicationIds(funder: any): string[] {
if (this.activeFilter === 'all') {
return [
...funder.publication_ids.first,
...funder.publication_ids.middle,
...funder.publication_ids.last,
...funder.publication_ids.unknown
];
}
return funder.publication_ids[this.activeFilter] ?? [];
}
getPositionLabel(position: string): string {
const labels: Record<string, string> = {
first: 'Erstautor',
middle: 'Mitautor',
last: 'Letztautor',
unknown: 'Unbekannt'
};
return labels[position] ?? position;
}
getUniquePublicationCount(): number {
const allIds = new Set<string>();
for (const funder of this.funders) {
for (const ids of Object.values(funder.publication_ids) as string[][]) {
ids.forEach(id => allIds.add(id));
}
}
return allIds.size;
}
}