Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da8d9085d |
@@ -5,8 +5,9 @@ from .. import config
|
|||||||
|
|
||||||
def search(
|
def search(
|
||||||
index: str,
|
index: str,
|
||||||
query_field: str,
|
query_field: Optional[str] = None,
|
||||||
query_value: str
|
query_value: Optional[str] = None,
|
||||||
|
payload: Optional[dict[str, Any]] = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -14,18 +15,19 @@ def search(
|
|||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
payload = {
|
if payload is None:
|
||||||
"query": {
|
payload = {
|
||||||
"query_string": {
|
"query": {
|
||||||
"default_field": query_field,
|
"query_string": {
|
||||||
"query": query_value
|
"default_field": query_field,
|
||||||
|
"query": query_value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
with httpx.Client() as client:
|
with httpx.Client() as client:
|
||||||
response = client.post(
|
response = client.post(
|
||||||
f"{config.settings.elasticsearch_url}/{index}/_search",
|
f"{config.settings.elasticsearch_url.rstrip('/')}/{index}/_search",
|
||||||
json=payload,
|
json=payload,
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -200,6 +200,19 @@ def count_topic_hierarchy(topic_names: List[str]) -> dict:
|
|||||||
|
|
||||||
### persons
|
### persons
|
||||||
|
|
||||||
|
def list_persons(page_offset: int = 0, page_size: int = 20, query: Optional[str] = None,
|
||||||
|
include: Optional[set[str]] = None) -> model.PersonPage:
|
||||||
|
payload = _author_list_query(page_offset, page_size, query)
|
||||||
|
data = elasticsearch.search(index="openalex-authors", payload=payload)
|
||||||
|
persons = _parse_person_hits(data, include)
|
||||||
|
total = _extract_total_hits(data)
|
||||||
|
return model.PersonPage(
|
||||||
|
elements=persons,
|
||||||
|
offset=page_offset,
|
||||||
|
size=page_size,
|
||||||
|
total=total
|
||||||
|
)
|
||||||
|
|
||||||
def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
||||||
include: Optional[set[str]] = None) -> model.PersonSearchResult:
|
include: Optional[set[str]] = None) -> model.PersonSearchResult:
|
||||||
if author_id:
|
if author_id:
|
||||||
@@ -217,6 +230,36 @@ def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
|||||||
query_value=query_value
|
query_value=query_value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
persons = _parse_person_hits(data, include)
|
||||||
|
return model.PersonSearchResult(persons=persons)
|
||||||
|
|
||||||
|
def _author_list_query(page_offset: int, page_size: int, query: Optional[str] = None) -> dict:
|
||||||
|
search_query = {"match_all": {}}
|
||||||
|
if query:
|
||||||
|
search_query = {
|
||||||
|
"query_string": {
|
||||||
|
"fields": ["display_name^3", "display_name_alternatives", "_id", "ids.orcid"],
|
||||||
|
"query": query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"from": page_offset,
|
||||||
|
"size": page_size,
|
||||||
|
"query": search_query,
|
||||||
|
"sort": [
|
||||||
|
{"works_count": {"order": "desc", "missing": "_last"}},
|
||||||
|
{"cited_by_count": {"order": "desc", "missing": "_last"}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def _extract_total_hits(data: dict) -> int:
|
||||||
|
total = data.get("hits", {}).get("total", 0)
|
||||||
|
if isinstance(total, dict):
|
||||||
|
return total.get("value", 0)
|
||||||
|
return total
|
||||||
|
|
||||||
|
def _parse_person_hits(data: dict, include: Optional[set[str]] = None) -> List[model.Person]:
|
||||||
include_set = {tag.strip().lower() for tag in include} if include else set()
|
include_set = {tag.strip().lower() for tag in include} if include else set()
|
||||||
persons = []
|
persons = []
|
||||||
for hit in data.get("hits", {}).get("hits", []):
|
for hit in data.get("hits", {}).get("hits", []):
|
||||||
@@ -268,7 +311,7 @@ def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
|||||||
|
|
||||||
persons.append(model.Person(**person_data))
|
persons.append(model.Person(**person_data))
|
||||||
|
|
||||||
return model.PersonSearchResult(persons=persons)
|
return persons
|
||||||
|
|
||||||
def generate_person_bio(author_id: str) -> str:
|
def generate_person_bio(author_id: str) -> str:
|
||||||
search_result = search_persons(author_id=author_id)
|
search_result = search_persons(author_id=author_id)
|
||||||
@@ -285,4 +328,3 @@ def generate_person_bio(author_id: str) -> str:
|
|||||||
|
|
||||||
return llm.call(system_prompt=system_prompt, user_prompt=user_prompt)
|
return llm.call(system_prompt=system_prompt, user_prompt=user_prompt)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,4 +72,5 @@ class Person(BaseModel):
|
|||||||
class PersonSearchResult(BaseModel):
|
class PersonSearchResult(BaseModel):
|
||||||
persons: List[Person] = Field(default=[], description="List of found persons.")
|
persons: List[Person] = Field(default=[], description="List of found persons.")
|
||||||
|
|
||||||
|
class PersonPage(Page[Person]):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -39,81 +39,7 @@ app.include_router(works_service.router)
|
|||||||
async def show_api():
|
async def show_api():
|
||||||
return RedirectResponse("api")
|
return RedirectResponse("api")
|
||||||
|
|
||||||
### items
|
|
||||||
|
|
||||||
@app.get('/items',
|
|
||||||
operation_id='getItems',
|
|
||||||
response_model=model.ItemPage,
|
|
||||||
summary='Returns a page of items.',
|
|
||||||
tags=[ 'Items' ])
|
|
||||||
def get_items(page_offset: Annotated[int, Query(alias='pageOffset', description='The page offset.', ge=0)] = 0,
|
|
||||||
page_size: Annotated[int, Query(alias='pageSize', description='The page size.', ge=0, le=1000)] = 100,
|
|
||||||
db: Session = Depends(database.get),
|
|
||||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
|
||||||
return logic.get_page(db, schema.Item, model.Item, page_offset, page_size)
|
|
||||||
|
|
||||||
@app.get('/items/{id}',
|
|
||||||
operation_id='getItem',
|
|
||||||
response_model=model.Item,
|
|
||||||
summary='Returns the item with the id.',
|
|
||||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
|
||||||
tags=[ 'Items' ])
|
|
||||||
def get_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
|
||||||
db: Session = Depends(database.get),
|
|
||||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
|
||||||
return util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
|
||||||
|
|
||||||
@app.post('/items',
|
|
||||||
operation_id='addItem',
|
|
||||||
response_model=model.Item,
|
|
||||||
summary='Adds a new item.',
|
|
||||||
tags=[ 'Items' ])
|
|
||||||
def add_item(item: Annotated[model.ItemCreate, Body(description='The item to add.')],
|
|
||||||
db: Session = Depends(database.get),
|
|
||||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
|
||||||
i = schema.Item()
|
|
||||||
i.name = item.name
|
|
||||||
i.description = item.description
|
|
||||||
try:
|
|
||||||
return logic.insert_element(db, i)
|
|
||||||
finally:
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
@app.put('/items/{id}',
|
|
||||||
operation_id='updateItem',
|
|
||||||
response_model=model.Item,
|
|
||||||
summary='Updates the item with the id.',
|
|
||||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
|
||||||
tags=[ 'Items' ])
|
|
||||||
def update_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
|
||||||
item: Annotated[model.ItemCreate, Body(description='The item data to update.')],
|
|
||||||
db: Session = Depends(database.get),
|
|
||||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
|
||||||
i = util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
|
||||||
i.name = item.name
|
|
||||||
i.description = item.description
|
|
||||||
db.flush()
|
|
||||||
db.refresh(i)
|
|
||||||
try:
|
|
||||||
return i
|
|
||||||
finally:
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
@app.delete('/items/{id}',
|
|
||||||
operation_id='deleteItem',
|
|
||||||
summary='Deletes the item with the id.',
|
|
||||||
response_model=None,
|
|
||||||
responses={ HTTP_404_NOT_FOUND: { 'model' : None }},
|
|
||||||
tags=[ 'Items' ])
|
|
||||||
def delete_item(id: Annotated[int, Path(description='The item id.', ge=0)],
|
|
||||||
db: Session = Depends(database.get),
|
|
||||||
principal: security.Principal = Depends(security.roles_allowed(['SUPER_ADMIN', 'UNI_ADMIN']))):
|
|
||||||
util.raise_not_found_if_none(logic.get_element(db, schema.Item, id))
|
|
||||||
try:
|
|
||||||
logic.delete_element(db, schema.Item, id)
|
|
||||||
return Response(status_code=HTTP_200_OK)
|
|
||||||
finally:
|
|
||||||
db.commit()
|
|
||||||
### topics
|
### topics
|
||||||
# hierarchy cache (temporaray => should be called by a scheduled job, with new openalex data indexing)
|
# hierarchy cache (temporaray => should be called by a scheduled job, with new openalex data indexing)
|
||||||
@app.get('/topics/cache',
|
@app.get('/topics/cache',
|
||||||
@@ -152,6 +78,26 @@ def count_topic_hierarchy(
|
|||||||
|
|
||||||
### persons
|
### persons
|
||||||
|
|
||||||
|
@app.get('/persons',
|
||||||
|
operation_id='getPersons',
|
||||||
|
response_model=model.PersonPage,
|
||||||
|
summary='Returns a page of OpenAlex authors.',
|
||||||
|
response_model_exclude_none=True,
|
||||||
|
tags=[ 'Persons' ])
|
||||||
|
def get_persons(page_offset: Annotated[int, Query(alias='pageOffset', description='The page offset.', ge=0)] = 0,
|
||||||
|
page_size: Annotated[int, Query(alias='pageSize', description='The page size.', ge=1, le=100)] = 20,
|
||||||
|
query: Annotated[Optional[str], Query(description="Optional author search query.")] = None,
|
||||||
|
include: Annotated[Optional[str], Query(
|
||||||
|
description=(
|
||||||
|
"Comma-separated include tags: topics_full, topic_share, summary_stats, ids, "
|
||||||
|
"last_known_institutions, sources, counts_by_year, works_api_url, dates, "
|
||||||
|
"cited_by_count_boost"
|
||||||
|
),
|
||||||
|
example="topics_full,topic_share"
|
||||||
|
)] = None):
|
||||||
|
include_set = {tag.strip().lower() for tag in include.split(",") if tag.strip()} if include else None
|
||||||
|
return logic.list_persons(page_offset=page_offset, page_size=page_size, query=query, include=include_set)
|
||||||
|
|
||||||
@app.get('/persons/search',
|
@app.get('/persons/search',
|
||||||
operation_id='searchPersons',
|
operation_id='searchPersons',
|
||||||
response_model=model.PersonSearchResult,
|
response_model=model.PersonSearchResult,
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
from inse import logic
|
||||||
|
from inse import model
|
||||||
|
from inse.main import app
|
||||||
|
|
||||||
|
client = TestClient(app)
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_persons_searches_openalex_authors(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_search(index, payload=None, **_):
|
||||||
|
captured["index"] = index
|
||||||
|
captured["payload"] = payload
|
||||||
|
return {
|
||||||
|
"hits": {
|
||||||
|
"total": {"value": 1},
|
||||||
|
"hits": [
|
||||||
|
{
|
||||||
|
"_id": "A5023888391",
|
||||||
|
"_source": {
|
||||||
|
"display_name": "Ada Lovelace",
|
||||||
|
"works_count": 42,
|
||||||
|
"cited_by_count": 1234,
|
||||||
|
"topics": [{"display_name": "Computer Science"}],
|
||||||
|
"affiliations": [
|
||||||
|
{
|
||||||
|
"institution": {
|
||||||
|
"display_name": "University of Example",
|
||||||
|
"country_code": "DE",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
monkeypatch.setattr(logic.elasticsearch, "search", fake_search)
|
||||||
|
|
||||||
|
page = logic.list_persons(page_offset=20, page_size=10, query="Ada")
|
||||||
|
|
||||||
|
assert captured["index"] == "openalex-authors"
|
||||||
|
assert captured["payload"]["from"] == 20
|
||||||
|
assert captured["payload"]["size"] == 10
|
||||||
|
assert captured["payload"]["query"]["query_string"]["query"] == "Ada"
|
||||||
|
assert page.total == 1
|
||||||
|
assert page.elements[0].id == "A5023888391"
|
||||||
|
assert page.elements[0].name == "Ada Lovelace"
|
||||||
|
assert page.elements[0].topics == ["Computer Science"]
|
||||||
|
assert page.elements[0].affiliations[0].institution == "University of Example"
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_persons_uses_match_all_without_query(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_search(index, payload=None, **_):
|
||||||
|
captured["payload"] = payload
|
||||||
|
return {"hits": {"total": 0, "hits": []}}
|
||||||
|
|
||||||
|
monkeypatch.setattr(logic.elasticsearch, "search", fake_search)
|
||||||
|
|
||||||
|
page = logic.list_persons(page_offset=0, page_size=20)
|
||||||
|
|
||||||
|
assert captured["payload"]["query"] == {"match_all": {}}
|
||||||
|
assert page.elements == []
|
||||||
|
assert page.total == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_persons_endpoint_returns_page(monkeypatch):
|
||||||
|
def fake_list_persons(page_offset=0, page_size=20, query=None, include=None):
|
||||||
|
assert page_offset == 5
|
||||||
|
assert page_size == 10
|
||||||
|
assert query == "Ada"
|
||||||
|
assert include == {"ids"}
|
||||||
|
return model.PersonPage(
|
||||||
|
offset=5,
|
||||||
|
size=10,
|
||||||
|
total=1,
|
||||||
|
elements=[
|
||||||
|
model.Person(
|
||||||
|
id="A5023888391",
|
||||||
|
name="Ada Lovelace",
|
||||||
|
works_count=42,
|
||||||
|
cited_by_count=1234,
|
||||||
|
affiliations=[],
|
||||||
|
topics=[],
|
||||||
|
ids={"openalex": "https://openalex.org/A5023888391"},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr(logic, "list_persons", fake_list_persons)
|
||||||
|
|
||||||
|
response = client.get("/inse-service/persons?pageOffset=5&pageSize=10&query=Ada&include=ids")
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["offset"] == 5
|
||||||
|
assert data["size"] == 10
|
||||||
|
assert data["total"] == 1
|
||||||
|
assert data["elements"][0]["name"] == "Ada Lovelace"
|
||||||
|
assert data["elements"][0]["ids"]["openalex"] == "https://openalex.org/A5023888391"
|
||||||
@@ -17,6 +17,14 @@ export const routes: Routes = [
|
|||||||
(mod) => mod.DashboardComponent,
|
(mod) => mod.DashboardComponent,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'persons',
|
||||||
|
canActivate: [userGuard],
|
||||||
|
loadComponent: () =>
|
||||||
|
import('./modules/person-list/person-list.component').then(
|
||||||
|
(mod) => mod.PersonListComponent,
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'person/:id',
|
path: 'person/:id',
|
||||||
canActivate: [userGuard],
|
canActivate: [userGuard],
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: linear-gradient(160deg, #f4f6fb 0%, #e8ecf7 100%);
|
background:
|
||||||
|
radial-gradient(circle at 18% 18%, var(--sg-cyan-soft), transparent 34%),
|
||||||
|
radial-gradient(circle at 82% 76%, var(--sg-coral-soft), transparent 32%),
|
||||||
|
linear-gradient(160deg, #f8faff 0%, #eef4ff 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
@@ -15,7 +18,7 @@
|
|||||||
background: white;
|
background: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0 2px 12px rgba(26, 58, 110, 0.10), 0 1px 4px rgba(0,0,0,0.06);
|
box-shadow: 0 2px 12px rgba(23, 32, 51, 0.10), 0 1px 4px rgba(0,0,0,0.06);
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
padding: 36px 32px 28px;
|
padding: 36px 32px 28px;
|
||||||
}
|
}
|
||||||
@@ -23,7 +26,7 @@
|
|||||||
.form h3 {
|
.form h3 {
|
||||||
margin: 0 0 4px;
|
margin: 0 0 4px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #1a3a6e;
|
color: var(--sg-primary-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
@@ -44,9 +47,9 @@
|
|||||||
height: 2em;
|
height: 2em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
color: #585f71;
|
color: var(--sg-text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
color: #ba1a1a;
|
color: var(--sg-danger);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<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>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="toolbar">
|
||||||
|
<span class="result-count">{{ resultRange() }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
@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.name }}</h2>
|
||||||
|
<p>{{ institution(person) }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="topic-row">
|
||||||
|
@for (topic of topics(person); track topic) {
|
||||||
|
<span>{{ topic }}</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
}
|
||||||
|
</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-paginator
|
||||||
|
[length]="total"
|
||||||
|
[pageIndex]="pageIndex"
|
||||||
|
[pageSize]="paginationService.selection"
|
||||||
|
[pageSizeOptions]="paginationService.options"
|
||||||
|
(page)="onPage($event)"
|
||||||
|
aria-label="Personen Seitensteuerung"
|
||||||
|
></mat-paginator>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,285 @@
|
|||||||
|
.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 {
|
||||||
|
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 {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.person-card:hover {
|
||||||
|
border-color: var(--sg-border-strong);
|
||||||
|
box-shadow: var(--sg-shadow-md);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-link {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 1fr auto;
|
||||||
|
gap: 18px;
|
||||||
|
min-height: 236px;
|
||||||
|
padding: 20px;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.person-main {
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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 {
|
||||||
|
display: flex;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats span {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { RouterLink } from '@angular/router';
|
||||||
|
import { Subject, debounceTime, distinctUntilChanged, takeUntil } from 'rxjs';
|
||||||
|
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||||
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||||
|
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
|
|
||||||
|
import { Person } from '../../api';
|
||||||
|
import { PaginationService } from '../../shared/services/pagination.service';
|
||||||
|
import { PersonsService } from '../../shared/services/persons.service';
|
||||||
|
import { createLoadError } from '../../shared/utils/errorHandler';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-person-list',
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatPaginatorModule,
|
||||||
|
MatProgressSpinnerModule,
|
||||||
|
MatSnackBarModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
RouterLink,
|
||||||
|
],
|
||||||
|
templateUrl: './person-list.component.html',
|
||||||
|
styleUrl: './person-list.component.scss',
|
||||||
|
standalone: true,
|
||||||
|
})
|
||||||
|
export class PersonListComponent implements OnInit, OnDestroy {
|
||||||
|
private personsService = inject(PersonsService);
|
||||||
|
private snackBar = inject(MatSnackBar);
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
public paginationService = inject(PaginationService);
|
||||||
|
|
||||||
|
persons: Person[] = [];
|
||||||
|
loading = false;
|
||||||
|
total = 0;
|
||||||
|
pageIndex = 0;
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
load(
|
||||||
|
pageIndex = this.pageIndex,
|
||||||
|
pageSize = this.paginationService.selection,
|
||||||
|
): void {
|
||||||
|
this.loading = true;
|
||||||
|
const pageOffset = pageIndex * pageSize;
|
||||||
|
|
||||||
|
this.personsService
|
||||||
|
.getPersons(pageOffset, pageSize)
|
||||||
|
.subscribe({
|
||||||
|
next: (page) => {
|
||||||
|
this.persons = page.elements ?? [];
|
||||||
|
this.total = page.total ?? 0;
|
||||||
|
this.loading = false;
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
this.loading = false;
|
||||||
|
createLoadError(
|
||||||
|
this.snackBar,
|
||||||
|
() => this.load(pageIndex, pageSize),
|
||||||
|
'Personen konnten nicht geladen werden',
|
||||||
|
)(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onPage(event: PageEvent): void {
|
||||||
|
this.paginationService.selection = event.pageSize;
|
||||||
|
this.pageIndex = event.pageIndex;
|
||||||
|
this.load(event.pageIndex, event.pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
institution(person: Person): string {
|
||||||
|
return person.affiliations?.[0]?.institution || 'Keine Institution angegeben';
|
||||||
|
}
|
||||||
|
|
||||||
|
topics(person: Person): string[] {
|
||||||
|
return (person.topics ?? []).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`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.profile-contact .orcid {
|
.profile-contact .orcid {
|
||||||
color: #6cc24a;
|
color: var(--sg-success);
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-contact a {
|
.profile-contact a {
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
|
|
||||||
.interest-tags span {
|
.interest-tags span {
|
||||||
padding: 9px 16px;
|
padding: 9px 16px;
|
||||||
border: 1px solid #a8c0ff;
|
border: 1px solid var(--sg-border-strong);
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
color: var(--sg-primary);
|
color: var(--sg-primary);
|
||||||
@@ -162,11 +162,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.profile-card {
|
.profile-card {
|
||||||
grid-template-columns: 112px 1fr;
|
grid-template-columns: minmax(240px, 1fr) minmax(260px, 360px);
|
||||||
}
|
|
||||||
|
|
||||||
.profile-contact {
|
|
||||||
grid-column: 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
|
import { Inject, Injectable, Optional } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
import { Person } from '../../api';
|
||||||
|
import { BASE_PATH } from '../../api/variables';
|
||||||
|
|
||||||
|
export interface PersonPage {
|
||||||
|
elements?: Person[];
|
||||||
|
offset?: number;
|
||||||
|
total?: number;
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PersonsService {
|
||||||
|
private readonly basePath: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private http: HttpClient,
|
||||||
|
@Optional() @Inject(BASE_PATH) basePath: string | null,
|
||||||
|
) {
|
||||||
|
this.basePath = basePath ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
getPersons(
|
||||||
|
pageOffset: number = 0,
|
||||||
|
pageSize: number = 24,
|
||||||
|
query?: string,
|
||||||
|
): Observable<PersonPage> {
|
||||||
|
let params = new HttpParams()
|
||||||
|
.set('pageOffset', pageOffset)
|
||||||
|
.set('pageSize', pageSize);
|
||||||
|
|
||||||
|
if (query?.trim()) {
|
||||||
|
params = params.set('query', query.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.http.get<PersonPage>(`${this.basePath}/persons`, { params });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 10px 8px;
|
inset: 10px 8px;
|
||||||
border: 2px solid rgba(0, 87, 255, 0.22);
|
border: 2px solid color-mix(in srgb, var(--sg-primary) 22%, transparent);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: linear-gradient(135deg, #dce8ff, #ffffff);
|
background: linear-gradient(135deg, var(--sg-primary-soft), #ffffff);
|
||||||
color: var(--sg-primary);
|
color: var(--sg-primary);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { CredentialService } from '../../services/credential.service';
|
|||||||
export class AppMenuComponent {
|
export class AppMenuComponent {
|
||||||
navItems = [
|
navItems = [
|
||||||
{ label: 'Dashboard', icon: 'dashboard', route: '/items', disabled: false },
|
{ label: 'Dashboard', icon: 'dashboard', route: '/items', disabled: false },
|
||||||
{ label: 'Personen', icon: 'groups', route: '/person/0', disabled: false },
|
{ label: 'Personen', icon: 'groups', route: '/persons', disabled: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(public credentialService: CredentialService) {}
|
constructor(public credentialService: CredentialService) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user