diff --git a/webapp/src/app/modules/person-list/person-list.component.html b/webapp/src/app/modules/person-list/person-list.component.html index 0b3fdf33..195737ef 100644 --- a/webapp/src/app/modules/person-list/person-list.component.html +++ b/webapp/src/app/modules/person-list/person-list.component.html @@ -1,65 +1,101 @@ -@let persons = state.persons(); -@let results = persons.results ?? []; -@if (!isPersonsLoading()) { - - -

{{ results.length }} Ergebnisse

-
-
- +
+ +
+ {{ resultRange() }} + + + filter_list + Ergebnisse filtern... + + @if (filterControl.value) { + + } + +
- @for (person of results; track person.id) { +
+
+ {{ total | number: "1.0-0" }} Personen gefunden + Sortiert nach Publikationen und Zitierungen +
- - @if (person.id){ - - -
+
\ No newline at end of file diff --git a/webapp/src/app/modules/person-list/person-list.component.scss b/webapp/src/app/modules/person-list/person-list.component.scss index 10174b2e..4b864b3b 100644 --- a/webapp/src/app/modules/person-list/person-list.component.scss +++ b/webapp/src/app/modules/person-list/person-list.component.scss @@ -1,78 +1,292 @@ +.person-list-page { + display: grid; + gap: 24px; + padding: 32px; + background: var(--sg-background); +} + +.page-header { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); + gap: 32px; + align-items: center; +} + +.eyebrow { + margin: 0 0 8px; + color: var(--sg-primary); + font-size: 12px; + font-weight: 700; + text-transform: uppercase; +} + +.page-header h1 { + margin: 0; + font-size: 28px; + line-height: 1.2; +} + +.page-header p:not(.eyebrow) { + max-width: 720px; + margin: 10px 0 0; + color: var(--sg-text-muted); +} + +.selection-summary { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 80px; + padding: 18px 20px; + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: var(--sg-surface); +} + +.selection-summary div { + display: grid; + gap: 5px; +} + +.selection-summary strong { + color: var(--sg-text); +} + +.selection-summary span { + color: var(--sg-text-muted); + font-size: 12px; +} + +.selection-summary mat-icon { + color: var(--sg-text-muted); +} + +.toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 20px; +} + +.toolbar mat-form-field { + width: min(100%, 520px); +} + .result-count { - margin: 0 0 12px; - font-size: 14px; - color: #666; + color: var(--sg-text-muted); + font-size: 13px; + white-space: nowrap; +} + +.results-panel { + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: var(--sg-surface); + overflow: hidden; +} + +.results-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 20px; + min-height: 64px; + padding: 0 22px; +} + +.results-head strong { + color: var(--sg-text); + font-size: 15px; +} + +.results-head span { + color: var(--sg-text-muted); + font-size: 13px; +} + +.person-grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 16px; + padding: 16px; } .person-card { - width: 100%; - height: 100%; - padding: 12px; - border-radius: 16px; + min-width: 0; + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: var(--sg-surface); + box-shadow: var(--sg-shadow-sm); + transition: + border-color 160ms ease, + box-shadow 160ms ease, + transform 160ms ease; } -.card-content { - display: flex; - align-items: center; - gap: 16px; - height: 100%; +.person-card:hover { + border-color: var(--sg-border-strong); + box-shadow: var(--sg-shadow-md); + transform: translateY(-1px); } -.avatar { - display: flex; - justify-content: center; - align-items: center; +.card-link { + display: grid; + grid-template-rows: 1fr auto; + gap: 18px; + min-height: 236px; + padding: 20px; + color: inherit; + text-decoration: none; } -.avatar-icon { - font-size: 48px; - width: 48px; - height: 48px; - color: #9e9e9e; -} - -.info { +.person-main { display: flex; + min-width: 0; flex-direction: column; - gap: 4px; + justify-content: space-between; + gap: 18px; } -.name { +.person-main h2 { + margin: 0 0 6px; + font-size: 17px; + line-height: 1.25; +} + +.person-main p { + display: -webkit-box; margin: 0; + overflow: hidden; + color: var(--sg-text-muted); + font-size: 13px; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; } -.person-id { +.person-main p.person-id { + color: var(--sg-text-soft); font-size: 11px; - color: #aaa; - margin: 0; + margin-top: 4px; + opacity: 0.8; } -.affiliation { - color: #666; - margin: 0; +.topic-row { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.topic-row span { + max-width: 100%; + padding: 5px 10px; + overflow: hidden; + border: 1px solid #bcd3ff; + border-radius: 6px; + background: #eff6ff; + color: #064fc4; + font-size: 12px; + font-weight: 600; + text-overflow: ellipsis; + white-space: nowrap; } .stats { - font-size: 12px; - color: #888; -} - -.topics { display: flex; - gap: 6px; - flex-wrap: wrap; -} - -.topic-chip { - font-size: 12px; -} -.loading { - display: flex; - justify-content: center; align-items: center; + justify-content: space-between; + gap: 12px; + padding-top: 14px; + border-top: 1px solid var(--sg-border); + color: var(--sg-text-muted); + font-size: 12px; +} - width: 100%; - min-height: 300px; +.stats span { + display: inline-flex; + align-items: center; + min-width: 0; + gap: 6px; +} - padding: 2rem; +.stats mat-icon { + width: 18px; + height: 18px; + font-size: 18px; +} + +.loading-state, +.empty-state { + display: grid; + min-height: 320px; + place-items: center; + padding: 32px; + text-align: center; +} + +.empty-state { + align-content: center; + gap: 8px; + color: var(--sg-text-muted); +} + +.empty-state mat-icon { + width: 42px; + height: 42px; + color: var(--sg-text-soft); + font-size: 42px; +} + +.empty-state h2 { + margin: 0; + font-size: 18px; +} + +.empty-state p { + margin: 0; +} + +mat-paginator { + border-top: 1px solid var(--sg-border); +} + +@media (max-width: 1280px) { + .person-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +@media (max-width: 860px) { + .person-list-page { + padding: 24px 16px; + } + + .page-header { + grid-template-columns: 1fr; + } + + .toolbar, + .results-head { + align-items: stretch; + flex-direction: column; + } + + .results-head { + justify-content: center; + padding: 16px; + } + + .result-count { + white-space: normal; + } + + .person-grid { + grid-template-columns: 1fr; + } +} + +@media (max-width: 560px) { + .stats { + align-items: flex-start; + flex-direction: column; + } } \ No newline at end of file diff --git a/webapp/src/app/modules/person-list/person-list.component.ts b/webapp/src/app/modules/person-list/person-list.component.ts index ad002537..ed21eecc 100644 --- a/webapp/src/app/modules/person-list/person-list.component.ts +++ b/webapp/src/app/modules/person-list/person-list.component.ts @@ -1,24 +1,34 @@ -import { Component, computed, inject, signal, DestroyRef } from '@angular/core'; -import { Router } from '@angular/router'; +import { Component, inject, signal, DestroyRef } from '@angular/core'; +import { Router, RouterLink } from '@angular/router'; +import { CommonModule } from '@angular/common'; import { toObservable } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { MatGridListModule } from '@angular/material/grid-list'; -import { MatCardModule } from '@angular/material/card'; +import { FormControl, ReactiveFormsModule } from '@angular/forms'; + import { MatIconModule } from '@angular/material/icon'; -import { MatChipsModule } from '@angular/material/chips'; -import { MatProgressSpinner } from '@angular/material/progress-spinner'; +import { MatPaginatorModule, PageEvent } from '@angular/material/paginator'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; +import { MatButtonModule } from '@angular/material/button'; + import { Author, AuthorsListResponse, PersonsService } from '../../api'; import { SharedStateService } from '../../shared/services/shared-state.service'; -import { distinctUntilChanged, switchMap, tap, finalize } from 'rxjs'; +import { PaginationService } from '../../shared/services/pagination.service'; +import { distinctUntilChanged, switchMap, tap, finalize, debounceTime } from 'rxjs'; @Component({ selector: 'app-person-list', imports: [ - MatCardModule, - MatChipsModule, - MatGridListModule, + CommonModule, + RouterLink, + ReactiveFormsModule, MatIconModule, - MatProgressSpinner, + MatPaginatorModule, + MatProgressSpinnerModule, + MatFormFieldModule, + MatInputModule, + MatButtonModule, ], templateUrl: './person-list.component.html', styleUrl: './person-list.component.scss', @@ -28,17 +38,36 @@ export class PersonListComponent { private readonly personsService = inject(PersonsService); private readonly destroyRef = inject(DestroyRef); public readonly state = inject(SharedStateService); + public readonly paginationService = inject(PaginationService); private readonly defaultIncludes = 'display_name,works_count,cited_by_count,topics,orcid'; private readonly defaultInstitutionName = 'University of Duisburg-Essen'; readonly isPersonsLoading = signal(false); + + pageIndex = signal(0); + filterControl = new FormControl('', { nonNullable: true }); + filterValue = signal(''); + constructor() { + this.filterControl.valueChanges + .pipe( + debounceTime(200), + distinctUntilChanged(), + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((val) => { + this.filterValue.set(val || ''); + this.pageIndex.set(0); + }); + toObservable(this.state.searchValue) .pipe( distinctUntilChanged(), tap(() => { + this.pageIndex.set(0); + this.filterControl.setValue(''); this.state.hasSearched.set(false); this.isPersonsLoading.set(true); }), @@ -75,7 +104,75 @@ export class PersonListComponent { }); } - // navigation + // Getters for design / pagination / filtering + get results(): Author[] { + const rawResults = this.state.persons().results ?? []; + const filter = this.filterValue().toLowerCase().trim(); + if (!filter) { + return rawResults; + } + return rawResults.filter((person) => { + const nameMatch = person.display_name?.toLowerCase().includes(filter); + const instMatch = person.affiliations?.some((aff) => + aff.institution?.display_name?.toLowerCase().includes(filter), + ); + const topicMatch = person.topics?.some((topic) => + topic.display_name?.toLowerCase().includes(filter), + ); + return !!(nameMatch || instMatch || topicMatch); + }); + } + + get total(): number { + return this.results.length; + } + + get persons(): Author[] { + const maxPage = Math.max(0, Math.ceil(this.total / this.paginationService.selection) - 1); + if (this.pageIndex() > maxPage) { + this.pageIndex.set(maxPage); + } + const start = this.pageIndex() * this.paginationService.selection; + const end = start + this.paginationService.selection; + return this.results.slice(start, end); + } + + get loading(): boolean { + return this.isPersonsLoading(); + } + + onPage(event: PageEvent): void { + this.paginationService.selection = event.pageSize; + this.pageIndex.set(event.pageIndex); + } + + clearSearch(): void { + this.state.searchValue.set(null); + } + + institution(person: Author): string { + return ( + person.affiliations?.[0]?.institution?.display_name || + 'Keine Institution angegeben' + ); + } + + topics(person: Author): string[] { + return (person.topics ?? []) + .map((t) => t.display_name) + .filter((name): name is string => !!name) + .slice(0, 3); + } + + resultRange(): string { + if (!this.total || !this.persons.length) return 'Keine Personen gefunden'; + + const start = this.pageIndex() * this.paginationService.selection + 1; + const end = start + this.persons.length - 1; + return `${start}-${end} von ${this.total} Personen`; + } + + // navigation (kept in case we need it, though template uses [routerLink]) navigateID(id: string): void { this.router.navigate(['/person', id]); }