From fac08044a8682677f02ee8098734bbfcc01aa67e Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Mon, 1 Jun 2026 14:02:25 +0200 Subject: [PATCH] Add Person funding View and API integration --- webapp/src/app/api/api/persons.service.ts | 26 ++- .../person-funding.component.html | 94 ++++++++- .../person-funding.component.scss | 197 ++++++++++++++++++ .../person-funding.component.ts | 81 ++++++- 4 files changed, 392 insertions(+), 6 deletions(-) diff --git a/webapp/src/app/api/api/persons.service.ts b/webapp/src/app/api/api/persons.service.ts index cd7c95f2..5d72133b 100644 --- a/webapp/src/app/api/api/persons.service.ts +++ b/webapp/src/app/api/api/persons.service.ts @@ -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 { + 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('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: 'json', + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); +} + } diff --git a/webapp/src/app/modules/person-funding/person-funding.component.html b/webapp/src/app/modules/person-funding/person-funding.component.html index 364b6d5b..56eef4cb 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.html +++ b/webapp/src/app/modules/person-funding/person-funding.component.html @@ -1 +1,93 @@ -

person-funding!

+@if (loading) { +

Lade Förderungen...

+} @else if (error) { +

Fehler beim Laden der Förderungen.

+} @else if (funders.length === 0) { +

Keine Förderungen gefunden.

+} @else { +
+ Einzigartige Publikationen: + {{ getUniquePublicationCount() }} +
+
+
+ Förderer: + {{ funders.length }} +
+
+ + +
+ + +
+ Filter nach Position: + + + + +
+ +
+ + +
+ + + + + + + + + @for (funder of filteredFunders; track funder.funder_id) { + + + + + } + +
FördererPublikationen
{{ funder.funder_name }}{{ funder.publication_count }}
+
+ + + @if (selectedFunder) { +
+

{{ selectedFunder.funder_name }}

+ +
+
+ Erstautor + {{ selectedFunder.author_position_count.first }} +
+
+ Mitautor + {{ selectedFunder.author_position_count.middle }} +
+
+ Letztautor + {{ selectedFunder.author_position_count.last }} +
+
+ +

Publikationen

+
    + @for (id of getPublicationIds(selectedFunder); track id) { +
  • + {{ id }} +
  • + } +
+
+ } @else { +
+

Klicke auf einen Förderer für Details.

+
+ } + +
+
+} diff --git a/webapp/src/app/modules/person-funding/person-funding.component.scss b/webapp/src/app/modules/person-funding/person-funding.component.scss index e69de29b..f9337e9d 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.scss +++ b/webapp/src/app/modules/person-funding/person-funding.component.scss @@ -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; + } + } +} +} diff --git a/webapp/src/app/modules/person-funding/person-funding.component.ts b/webapp/src/app/modules/person-funding/person-funding.component.ts index db6f9dc1..59213f28 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.ts +++ b/webapp/src/app/modules/person-funding/person-funding.component.ts @@ -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 = { + first: 'Erstautor', + middle: 'Mitautor', + last: 'Letztautor', + unknown: 'Unbekannt' + }; + return labels[position] ?? position; + } + getUniquePublicationCount(): number { + const allIds = new Set(); + 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; +} }