changing person search list
This commit is contained in:
@@ -1,65 +1,101 @@
|
||||
@let persons = state.persons();
|
||||
@let results = persons.results ?? [];
|
||||
@if (!isPersonsLoading()) {
|
||||
<mat-grid-list cols="1" rowHeight="65px" gutterSize="16px">
|
||||
<mat-grid-tile>
|
||||
<p class="result-count">{{ results.length }} Ergebnisse</p>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
<mat-grid-list cols="1" rowHeight="220px" gutterSize="16px">
|
||||
<section class="person-list-page">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1>Passende Personen finden</h1>
|
||||
<p>
|
||||
Durchsuchen Sie OpenAlex-Autorinnen und -Autoren nach Namen, Themen oder
|
||||
Kennungen.
|
||||
</p>
|
||||
</div>
|
||||
@if (state.searchValue()) {
|
||||
<div class="selection-summary">
|
||||
<div>
|
||||
<strong>Aktive Suche</strong>
|
||||
<span>„{{ state.searchValue() }}“</span>
|
||||
</div>
|
||||
<button mat-icon-button (click)="clearSearch()" matTooltip="Suche zurücksetzen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</header>
|
||||
|
||||
<div class="toolbar">
|
||||
<span class="result-count">{{ resultRange() }}</span>
|
||||
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-icon matPrefix>filter_list</mat-icon>
|
||||
<mat-label>Ergebnisse filtern...</mat-label>
|
||||
<input matInput [formControl]="filterControl" placeholder="Name, Institution oder Thema..." />
|
||||
@if (filterControl.value) {
|
||||
<button matSuffix mat-icon-button aria-label="Clear" (click)="filterControl.setValue('')">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
@for (person of results; track person.id) {
|
||||
<section class="results-panel">
|
||||
<div class="results-head">
|
||||
<strong>{{ total | number: "1.0-0" }} Personen gefunden</strong>
|
||||
<span>Sortiert nach Publikationen und Zitierungen</span>
|
||||
</div>
|
||||
|
||||
<mat-grid-tile>
|
||||
@if (person.id){
|
||||
<mat-card (click)="navigateID(person.id)" class="person-card">
|
||||
|
||||
<div class="card-content">
|
||||
|
||||
<div class="avatar">
|
||||
<mat-icon class="avatar-icon">person</mat-icon>
|
||||
@if (loading) {
|
||||
<div class="loading-state">
|
||||
<mat-spinner diameter="40"></mat-spinner>
|
||||
</div>
|
||||
} @else if (persons.length) {
|
||||
<div class="person-grid">
|
||||
@for (person of persons; track person.id) {
|
||||
<article class="person-card">
|
||||
<a
|
||||
class="card-link"
|
||||
[routerLink]="['/person', person.id, 'overview']"
|
||||
>
|
||||
<div class="person-main">
|
||||
<div>
|
||||
<h2>{{ person.display_name }}</h2>
|
||||
<p class="institution">{{ institution(person) }}</p>
|
||||
<p class="person-id">{{ getDistinguishingId(person) }}</p>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
<h3 class="name">{{ person.display_name }}</h3>
|
||||
<p class="person-id">{{ getDistinguishingId(person) }}</p>
|
||||
@if (person.affiliations!=undefined){
|
||||
<p class="affiliation">
|
||||
{{ person.affiliations[0]?.institution?.display_name }}
|
||||
</p>
|
||||
}
|
||||
|
||||
|
||||
<p class="stats">
|
||||
Works: {{ person.works_count }} ·
|
||||
Citations: {{ person.cited_by_count }}
|
||||
</p>
|
||||
|
||||
<div class="topics">
|
||||
@for (t of person.topics; track t) {
|
||||
<mat-chip class="topic-chip">{{ t.display_name }}</mat-chip>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="topic-row">
|
||||
@for (topic of topics(person); track topic) {
|
||||
<span>{{ topic }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</mat-card>
|
||||
<div class="stats">
|
||||
<span>
|
||||
<mat-icon>article</mat-icon>
|
||||
{{ person.works_count | number: "1.0-0" }} Publikationen
|
||||
</span>
|
||||
<span>
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
{{ person.cited_by_count | number: "1.0-0" }} Zitierungen
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
}
|
||||
</mat-grid-tile>
|
||||
|
||||
</div>
|
||||
} @else {
|
||||
<div class="empty-state">
|
||||
<mat-icon>person_search</mat-icon>
|
||||
<h2>Keine Personen gefunden</h2>
|
||||
<p>Versuchen Sie einen anderen Suchbegriff.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
</mat-grid-list>
|
||||
} @else {
|
||||
<mat-grid-list cols="1" rowHeight="220px" gutterSize="16px">
|
||||
<mat-grid-tile>
|
||||
<div class="loading">
|
||||
<mat-spinner diameter="40"></mat-spinner>
|
||||
</div>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
}
|
||||
<mat-paginator
|
||||
[length]="total"
|
||||
[pageIndex]="pageIndex()"
|
||||
[pageSize]="paginationService.selection"
|
||||
[pageSizeOptions]="paginationService.options"
|
||||
(page)="onPage($event)"
|
||||
aria-label="Personen Seitensteuerung"
|
||||
></mat-paginator>
|
||||
</section>
|
||||
</section>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<boolean>(false);
|
||||
|
||||
pageIndex = signal<number>(0);
|
||||
filterControl = new FormControl('', { nonNullable: true });
|
||||
filterValue = signal<string>('');
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user