Compare commits

..
Author SHA1 Message Date
Louis 4d9a3f24fa Make compact timeline details scrollable
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev Build started...
2026-06-04 20:16:13 +02:00
Louis 14b9ee0e50 Add URL state for research timeline view
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-06-04 18:51:41 +02:00
tischer c30925e2ac Merge pull request 'fix(frontend/person): replace wrong orcid link prefix in profile component' (#106) from fix/replace_wrong_orcid_link_in_profile into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good
Reviewed-on: #106
2026-06-04 17:05:38 +02:00
Louis 8201913738 Fix research timeline API integration
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-06-04 16:46:42 +02:00
Louis 97db19f042 load research timeline via generated works API
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-06-04 15:42:36 +02:00
Steven Tischer d37140866b fix(frontend/person): replace wrong orcid link prefix in profile component
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-06-04 13:57:30 +02:00
Louis 9dd47f4373 Merge remote-tracking branch 'origin/dev' into ts-85-topics-by-time-author 2026-06-04 13:18:45 +02:00
tischer e7c17d1fa7 Merge pull request 'ts-82-author-overview-and-description' (#105) from ts-82-author-overview-and-description into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good
Reviewed-on: #105
2026-06-04 10:04:40 +02:00
Steven Tischer e0015c3ea9 fix(backend/person_search): search failing due to unsupported search parameters
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-06-04 09:55:54 +02:00
Steven Tischer 547a82336e fix: add missing comma in elasticsearch search body parameter 2026-06-04 09:37:18 +02:00
Steven Tischer c409c1860d fix unsolved merge conflicts 2026-06-04 09:33:31 +02:00
Steven Tischer acee290e7f Merge branch 'dev' into ts-82-author-overview-and-description 2026-06-04 09:27:25 +02:00
Louis 3b08118abe Merge dev into ts-85-topics-by-time-author 2026-06-03 20:43:06 +02:00
genja b27e960e0a elastic client updated
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-06-02 11:08:01 +02:00
Louis 24ee9df743 Add compact research timeline view
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit
2026-06-01 20:56:45 +02:00
Louis 9a06211a0a Add year range filter to research timeline 2026-06-01 20:12:10 +02:00
Louis 0a32a2c191 Integrate primary topics into research timeline 2026-06-01 19:56:20 +02:00
spsaefan 0a86a3f5bc Add primary topics to topic timeline
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-06-01 10:32:29 +02:00
Louis de571d47bd Connect research timeline to topics by time in backend
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-06-01 00:44:21 +02:00
Louis 644b111280 Keep research timeline legend centered 2026-06-01 00:25:05 +02:00
Louis aaead76390 Adapt research timeline to topic timeline data 2026-06-01 00:18:05 +02:00
Louis 96b3355f46 Add research timeline with dummy data 2026-06-01 00:01:01 +02:00
spsaefan 404386e153 Fix topic timeline response models
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-05-31 23:07:25 +02:00
spsaefan 355361558e Adapt topics by time to refactored models
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit
2026-05-31 22:22:41 +02:00
spsaefan 32cb67df72 Add topics by time endpoint
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit
2026-05-29 12:15:05 +02:00
spsaefan f2bca2f646 Add topic aggregation by year 2026-05-29 12:14:56 +02:00
spsaefan 3caa759e4f Add topic timeline response models 2026-05-29 12:14:38 +02:00
31 changed files with 2160 additions and 675 deletions
@@ -5,9 +5,13 @@ from .. import config
def search(
index: str,
query_field: Optional[str] = None,
query_value: Optional[str] = None,
payload: Optional[dict[str, Any]] = None,
query_field: str = None,
query_value: str = None,
query: dict = None,
source = None,
size: int = None,
sort: list = None,
body: dict = None,
) -> dict[str, Any]:
headers = {
@@ -15,7 +19,17 @@ def search(
"Content-Type": "application/json"
}
if payload is None:
if body is not None:
payload = body
elif query is not None:
payload = {"query": query}
if source is not None:
payload["_source"] = source
if size is not None:
payload["size"] = size
if sort is not None:
payload["sort"] = sort
else:
payload = {
"query": {
"query_string": {
@@ -27,9 +41,33 @@ def search(
with httpx.Client() as client:
response = client.post(
f"{config.settings.elasticsearch_url.rstrip('/')}/{index}/_search",
f"{config.settings.elasticsearch_url}/{index}/_search",
json=payload,
headers=headers
)
response.raise_for_status()
return response.json()
def get(
index: str,
doc_id:str,
body: dict = None,
) -> dict[str, Any]:
headers = {
"Authorization": f"ApiKey {config.settings.elasticsearch_api_key}",
"Content-Type": "application/json"
}
payload = body
# get document directly
with httpx.Client() as client:
response = client.get(
f"{config.settings.elasticsearch_url}/{index}/_doc/{doc_id}",
json=payload,
headers=headers
)
response.raise_for_status()
return response.json()
+20 -71
View File
@@ -55,9 +55,8 @@ es_client = _init_es_client()
topic_cache_filename: str = "topic_hierarchy_cache.json"
S = TypeVar("S", bound=schema.Base)
M = TypeVar("M", bound=model.BaseModel)
S = TypeVar('S', bound=schema.Base)
M = TypeVar('M', bound=model.BaseModel)
def filter_none():
return True
@@ -255,62 +254,6 @@ def count_topic_hierarchy(topic_names: List[str]) -> dict:
### persons
def list_persons(
page_offset: int = 0,
page_size: int = 20,
query: Optional[str] = None,
include: Optional[set[str]] = None,
) -> AuthorsListResponse:
payload = _author_list_query(page_offset, page_size, query)
data = elasticsearch.search(index="openalex-authors", payload=payload)
hits = data.get("hits", {}).get("hits", [])
persons = [util.get_persons_data(hit) for hit in hits]
total = _extract_total_hits(data)
return AuthorsListResponse(
results=persons,
meta=Meta(
count=total,
page=page_offset // page_size + 1 if page_size > 0 else 1,
per_page=page_size,
),
)
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 search_persons(
author_id: Optional[str] = None,
query: Optional[str] = None,
@@ -402,17 +345,17 @@ def generate_person_bio(author_id: str, include: Optional[set[str]] = None) -> s
return bio
def get_person_by_id(author_id: str, include: Optional[str] = None) -> AuthorsListResponse:
body = {
"_source":include.split(",") if include else True,
}
def get_person_by_id(
author_id: str, include: Optional[str] = None
) -> AuthorsListResponse:
try:
hit = es_client.get(
hit = elasticsearch.get(
index="openalex-authors",
id=author_id,
source=include.split(",") if include else True,
body=body,
doc_id=author_id
)
except NotFoundError:
raise HTTPException(
status_code=404, detail=f"Person with id {author_id} not found"
@@ -440,13 +383,20 @@ def search_persons_by_name(
"display_name": {"query": author_name, "boost": 3}
}
},
{"match": {"display_name": {"query": author_name, "fuzziness": 1}}},
# {
# "match": {
# "display_name": {
# "query": author_name,
# "fuzziness": 1
# }
# }
# }
],
"minimum_should_match": 1,
}
}
try:
response = es_client.search(
response = elasticsearch.search(
index="openalex-authors",
query=search_query,
source=include.split(",") if include else True,
@@ -482,12 +432,11 @@ def search_persons_by_institution(
},
}
}
print(include, institution_name)
try:
response = es_client.search(
response = elasticsearch.search(
index="openalex-authors",
source=include.split(",") if include else True,
query=search_query,
source=include.split(",") if include else True,
size=limit,
sort=[{"works_count": {"order": "desc"}}],
)
+3
View File
@@ -38,3 +38,6 @@ class ItemPage(Page[Item]):
class PersonBio(BaseModel):
bio: str = Field(description="The generated biography.")
@@ -0,0 +1,6 @@
from pydantic import BaseModel, Field
class TopicCount(BaseModel):
name: str = Field(description="The topic display name.")
count: int = Field(default=0, description="The number of occurrences.")
@@ -0,0 +1,10 @@
from typing import List
from pydantic import BaseModel, Field
from inse.models.topics_by_year import TopicsByYear
class TopicsByTime(BaseModel):
elements: List[TopicsByYear] = Field(default_factory=list, description="Topics grouped by year.")
total: int = Field(default=0, description="The number of years.")
@@ -0,0 +1,12 @@
from typing import List
from pydantic import BaseModel, Field
from inse.models.topic_count import TopicCount
class TopicsByYear(BaseModel):
year: int = Field(description="The publication year.")
publication_count: int = Field(default=0, description="The number of works in this year.")
topics: List[TopicCount] = Field(default_factory=list, description="The topics in this year.")
primary_topics: List[TopicCount] = Field(default_factory=list, description="The primary topics in this year.")
+10 -14
View File
@@ -215,23 +215,21 @@ def count_topic_hierarchy(
### persons
@router.get(
"/persons",
operation_id="getPersons",
"/persons/search",
operation_id="searchPersons",
response_model=AuthorsListResponse,
summary="Returns a page of OpenAlex authors.",
summary="Searches for persons by ID or name.",
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,
def search_persons(
author_id: Annotated[
str, Query(description="OpenAlex author ID (e.g., A5093075883)")
] = None,
query: Annotated[
Optional[str], Query(description="Optional author search query.")
str, Query(description="Search query (e.g., Arman AND Arzani)")
] = None,
include: Annotated[
Optional[str],
@@ -250,9 +248,7 @@ def get_persons(
if include
else None
)
return logic.list_persons(
page_offset=page_offset, page_size=page_size, query=query, include=include_set
)
return logic.search_persons(author_id, query, include_set)
@router.get(
-108
View File
@@ -1,108 +0,0 @@
from fastapi.testclient import TestClient
from inse import logic
from inse import model
from inse.main import app
from inse.models.authors_list_response import AuthorsListResponse
from inse.models.meta import Meta
from inse.models.author import Author
from inse.models.author_ids import AuthorIds
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.meta.count == 1
assert page.results[0].id == "A5023888391"
assert page.results[0].display_name == "Ada Lovelace"
assert page.results[0].topics[0].display_name == "Computer Science"
assert page.results[0].affiliations[0].institution.display_name == "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.results == []
assert page.meta.count == 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 AuthorsListResponse(
meta=Meta(
count=1,
page=1,
per_page=10
),
results=[
Author(
id="A5023888391",
display_name="Ada Lovelace",
works_count=42,
cited_by_count=1234,
affiliations=[],
topics=[],
ids=AuthorIds(openalex="https://openalex.org/A5023888391"),
)
],
)
monkeypatch.setattr(logic, "list_persons", fake_list_persons)
response = client.get("/api/inse-service/persons?pageOffset=5&pageSize=10&query=Ada&include=ids")
assert response.status_code == 200
data = response.json()
assert data["meta"]["count"] == 1
assert data["results"][0]["display_name"] == "Ada Lovelace"
assert data["results"][0]["ids"]["openalex"] == "https://openalex.org/A5023888391"
+84
View File
@@ -17,6 +17,9 @@ from inse.models.work import Work
from inse.models.work_page import WorkPage
from inse.models.works_list_response import WorksListResponse
from inse.models.meta import Meta
from inse.models.topic_count import TopicCount
from inse.models.topics_by_year import TopicsByYear
from inse.models.topics_by_time import TopicsByTime
from .search_client import MissingApiKeyError
from .search_client import OpenAlexWorksSearchClient
@@ -87,6 +90,87 @@ async def get_all_author_works(
)
async def get_topics_by_time_by_author(
author_id: str,
max_topics_per_year: int = 3,
client: OpenAlexWorksSearchClient | None = None,
) -> TopicsByTime:
works = await get_all_author_works(author_id, client=client)
years = {}
for work in works.results or []:
if work.publication_year is None:
continue
year = work.publication_year
if year not in years:
years[year] = {
"publication_count": 0,
"topics": {},
"primary_topics": {},
}
years[year]["publication_count"] += 1
for topic in work.topics or []:
if topic.display_name:
topic_name = topic.display_name
if topic_name not in years[year]["topics"]:
years[year]["topics"][topic_name] = 0
years[year]["topics"][topic_name] += 1
primary_topic = work.primary_topic
if primary_topic and primary_topic.display_name:
primary_topic_name = primary_topic.display_name
if primary_topic_name not in years[year]["primary_topics"]:
years[year]["primary_topics"][primary_topic_name] = 0
years[year]["primary_topics"][primary_topic_name] += 1
elements = []
for year in sorted(years.keys()):
topic_items = list(years[year]["topics"].items())
topic_items.sort(key=lambda item: item[1], reverse=True)
topics = []
for topic_name, count in topic_items[:max_topics_per_year]:
topics.append(TopicCount(
name=topic_name,
count=count,
))
primary_topic_items = list(years[year]["primary_topics"].items())
primary_topic_items.sort(key=lambda item: item[1], reverse=True)
primary_topics = []
for topic_name, count in primary_topic_items[:max_topics_per_year]:
primary_topics.append(TopicCount(
name=topic_name,
count=count,
))
elements.append(TopicsByYear(
year=year,
publication_count=years[year]["publication_count"],
topics=topics,
primary_topics=primary_topics,
))
return TopicsByTime(
elements=elements,
total=len(elements),
)
async def _search_author_works_data(
search_client: OpenAlexWorksSearchClient,
author_id: str,
+16
View File
@@ -17,6 +17,7 @@ from .. import security
from . import logic
from inse.models.work_page import WorkPage
from inse.models.works_list_response import WorksListResponse
from inse.models.topics_by_time import TopicsByTime
router = APIRouter(prefix="/api/works", tags=[Tags.WORKS])
@@ -68,3 +69,18 @@ async def get_all_author_works(
principal: security.Principal = Depends(security.roles_allowed(["SUPER_ADMIN", "UNI_ADMIN"])),
):
return await logic.get_all_author_works(author_id)
@router.get("/{author_id}/topics-by-time",
operation_id="getTopicsByTimeByAuthor",
response_model=TopicsByTime,
summary="Returns topics grouped by publication year for an author.")
async def get_topics_by_time_by_author(
author_id: Annotated[str, Path(description="The author id, for example A5023888391.")],
max_topics_per_year: Annotated[int, Query(description="The maximum number of topics per year.", ge=1, le=20)] = 3,
principal: security.Principal = Depends(security.roles_allowed(["SUPER_ADMIN", "UNI_ADMIN"])),
):
return await logic.get_topics_by_time_by_author(
author_id,
max_topics_per_year=max_topics_per_year,
)
@@ -53,6 +53,9 @@ model/models.ts
model/openAccess.ts
model/personBio.ts
model/score.ts
model/topicCount.ts
model/topicsByTime.ts
model/topicsByYear.ts
model/validationError.ts
model/validationErrorLocInner.ts
model/value.ts
+66
View File
@@ -19,6 +19,8 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { TopicsByTime } from '../model/topicsByTime';
// @ts-ignore
import { WorkPage } from '../model/workPage';
// @ts-ignore
import { WorksListResponse } from '../model/worksListResponse';
@@ -185,4 +187,68 @@ export class WorksService extends BaseService {
);
}
/**
* Returns topics grouped by publication year for an author.
* @endpoint get /api/works/{author_id}/topics-by-time
* @param authorId The author id, for example A5023888391.
* @param maxTopicsPerYear The maximum number of topics per year.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TopicsByTime>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TopicsByTime>>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TopicsByTime>>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, 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 getTopicsByTimeByAuthor.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>maxTopicsPerYear, 'max_topics_per_year');
let localVarHeaders = this.defaultHeaders;
// authentication (bearer) required
localVarHeaders = this.configuration.addCredentialToHeaders('bearer', 'Authorization', localVarHeaders, 'Bearer ');
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/works/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/topics-by-time`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<TopicsByTime>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
+3
View File
@@ -35,6 +35,9 @@ export * from './model2YrMeanCitedness';
export * from './openAccess';
export * from './personBio';
export * from './score';
export * from './topicCount';
export * from './topicsByTime';
export * from './topicsByYear';
export * from './validationError';
export * from './validationErrorLocInner';
export * from './value';
+22
View File
@@ -0,0 +1,22 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface TopicCount {
/**
* The topic display name.
*/
name: string;
/**
* The number of occurrences.
*/
count?: number;
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { TopicsByYear } from './topicsByYear';
export interface TopicsByTime {
/**
* Topics grouped by year.
*/
elements?: Array<TopicsByYear>;
/**
* The number of years.
*/
total?: number;
}
+31
View File
@@ -0,0 +1,31 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { TopicCount } from './topicCount';
export interface TopicsByYear {
/**
* The publication year.
*/
year: number;
/**
* The number of works in this year.
*/
publication_count?: number;
/**
* The topics in this year.
*/
topics?: Array<TopicCount>;
/**
* The primary topics in this year.
*/
primary_topics?: Array<TopicCount>;
}
@@ -5,10 +5,7 @@
justify-content: center;
width: 100%;
height: 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%);
background: linear-gradient(160deg, #f4f6fb 0%, #e8ecf7 100%);
}
.form {
@@ -18,7 +15,7 @@
background: white;
border: none;
border-radius: 12px;
box-shadow: 0 2px 12px rgba(23, 32, 51, 0.10), 0 1px 4px rgba(0,0,0,0.06);
box-shadow: 0 2px 12px rgba(26, 58, 110, 0.10), 0 1px 4px rgba(0,0,0,0.06);
gap: 20px;
padding: 36px 32px 28px;
}
@@ -26,7 +23,7 @@
.form h3 {
margin: 0 0 4px;
font-weight: 600;
color: var(--sg-primary-strong);
color: #1a3a6e;
}
.button {
@@ -47,9 +44,9 @@
height: 2em;
text-align: center;
font-size: small;
color: var(--sg-text-muted);
color: #585f71;
}
.error {
color: var(--sg-danger);
color: #ba1a1a;
}
@@ -1,78 +1,65 @@
<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>
@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">
<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>
@for (person of results; track person.id) {
@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>{{ institution(person) }}</p>
<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>
</div>
<div class="topic-row">
@for (topic of topics(person); track topic) {
<span>{{ topic }}</span>
}
</div>
</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>
}
<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>
<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>
</div>
</mat-card>
}
</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-tile>
}
<mat-paginator
[length]="total"
[pageIndex]="pageIndex"
[pageSize]="paginationService.selection"
[pageSizeOptions]="paginationService.options"
(page)="onPage($event)"
aria-label="Personen Seitensteuerung"
></mat-paginator>
</section>
</section>
</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>
}
@@ -1,285 +1,78 @@
.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;
margin: 0 0 12px;
font-size: 14px;
color: #666;
}
.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;
width: 100%;
height: 100%;
padding: 12px;
border-radius: 16px;
}
.person-card:hover {
border-color: var(--sg-border-strong);
box-shadow: var(--sg-shadow-md);
transform: translateY(-1px);
.card-content {
display: flex;
align-items: center;
gap: 16px;
height: 100%;
}
.card-link {
display: grid;
grid-template-rows: 1fr auto;
gap: 18px;
min-height: 236px;
padding: 20px;
color: inherit;
text-decoration: none;
.avatar {
display: flex;
justify-content: center;
align-items: center;
}
.person-main {
.avatar-icon {
font-size: 48px;
width: 48px;
height: 48px;
color: #9e9e9e;
}
.info {
display: flex;
min-width: 0;
flex-direction: column;
justify-content: space-between;
gap: 18px;
gap: 4px;
}
.person-main h2 {
margin: 0 0 6px;
font-size: 17px;
line-height: 1.25;
}
.person-main p {
display: -webkit-box;
.name {
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;
.person-id {
font-size: 11px;
color: #aaa;
margin: 0;
}
.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;
.affiliation {
color: #666;
margin: 0;
}
.stats {
font-size: 12px;
color: #888;
}
.topics {
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);
gap: 6px;
flex-wrap: wrap;
}
.topic-chip {
font-size: 12px;
}
.stats span {
display: inline-flex;
.loading {
display: flex;
justify-content: center;
align-items: center;
min-width: 0;
gap: 6px;
}
.stats mat-icon {
width: 18px;
height: 18px;
font-size: 18px;
}
width: 100%;
min-height: 300px;
.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;
}
}
padding: 2rem;
}
@@ -1,113 +1,135 @@
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 { Component, computed, inject, signal, DestroyRef } from '@angular/core';
import { Router } from '@angular/router';
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 { 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 { Author, WorkTopic } from '../../api';
import { PaginationService } from '../../shared/services/pagination.service';
import { PersonsService } from '../../shared/services/persons.service';
import { createLoadError } from '../../shared/utils/errorHandler';
import { MatChipsModule } from '@angular/material/chips';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { Author, AuthorsListResponse, PersonsService } from '../../api';
import { SharedStateService } from '../../shared/services/shared-state.service';
import { distinctUntilChanged, switchMap, tap, finalize } from 'rxjs';
@Component({
selector: 'app-person-list',
imports: [
CommonModule,
MatButtonModule,
MatFormFieldModule,
MatCardModule,
MatChipsModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatPaginatorModule,
MatProgressSpinnerModule,
MatSnackBarModule,
ReactiveFormsModule,
RouterLink,
MatProgressSpinner,
],
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>();
export class PersonListComponent {
private readonly router = inject(Router);
private readonly personsService = inject(PersonsService);
private readonly destroyRef = inject(DestroyRef);
public readonly state = inject(SharedStateService);
public paginationService = inject(PaginationService);
private readonly defaultIncludes =
'display_name,works_count,cited_by_count,topics,orcid';
private readonly defaultInstitutionName = 'University of Duisburg-Essen';
persons: Author[] = [];
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)
readonly isPersonsLoading = signal<boolean>(false);
constructor() {
toObservable(this.state.searchValue)
.pipe(
distinctUntilChanged(),
tap(() => {
this.state.hasSearched.set(false);
this.isPersonsLoading.set(true);
}),
switchMap((value) =>
value
? this.personsService
.searchPersonsByName(value, this.defaultIncludes)
.pipe(
tap((result) => {
this.state.persons.set(this.sortByRanking(result));
this.state.hasSearched.set(true);
}),
)
: this.personsService
.searchPersonsByInstitution(
this.defaultInstitutionName,
this.defaultIncludes,
)
.pipe(
tap((result) => {
this.state.persons.set(this.sortByRanking(result));
}),
),
),
finalize(() => this.isPersonsLoading.set(false)),
takeUntilDestroyed(this.destroyRef),
)
.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);
next: () => this.isPersonsLoading.set(false),
error: (err) => {
console.error('Error loading persons:', err);
this.isPersonsLoading.set(false);
},
});
}
onPage(event: PageEvent): void {
this.paginationService.selection = event.pageSize;
this.pageIndex = event.pageIndex;
this.load(event.pageIndex, event.pageSize);
// navigation
navigateID(id: string): void {
this.router.navigate(['/person', id]);
}
institution(person: Author): string {
return (
person.last_known_institutions?.[0]?.display_name ??
person.affiliations?.[0]?.institution?.display_name ??
'Keine Institution angegeben'
);
// sorting logic
sortByRanking(response: AuthorsListResponse): AuthorsListResponse {
if (!response.results) return response;
return {
...response,
results: [...response.results].sort((personA, personB) => {
const rankDiff = this.getSortRank(personA) - this.getSortRank(personB);
if (rankDiff !== 0) {
return rankDiff;
}
return this.getWorksCount(personB) - this.getWorksCount(personA);
}),
};
}
topics(person: Author): string[] {
return (person.topics ?? [])
.map((topic: WorkTopic) => topic.display_name ?? '')
.filter((topic): topic is string => Boolean(topic))
.slice(0, 3);
getWorksCount(person: Author): number {
return person.works_count ?? 0;
}
resultRange(): string {
if (!this.total || !this.persons.length) return 'Keine Personen gefunden';
getSortRank(person: Author): number {
if (this.hasInstitution(person) && this.hasOrcid(person)) return 0;
if (this.hasInstitution(person)) return 1;
if (this.hasOrcid(person)) return 2;
return 3;
}
const start = this.pageIndex * this.paginationService.selection + 1;
const end = start + this.persons.length - 1;
return `${start}-${end} von ${this.total} Personen`;
hasInstitution(person: Author): boolean {
if (!person.affiliations) {
return false;
}
for (const affiliation of person.affiliations) {
if (affiliation.institution) {
return true;
}
}
return false;
}
hasOrcid(person: Author): boolean {
const ids = person.ids as { orcid?: string } | null | undefined;
return !!ids?.orcid;
}
getDistinguishingId(person: Author): string {
const ids = person.ids as { orcid?: string } | null | undefined;
const orcid = ids?.orcid;
return orcid
? 'ORCID: ' + orcid.replace('https://orcid.org/', '')
: 'OpenAlexID: ' + person.id;
}
}
@@ -0,0 +1,249 @@
<section class="research-timeline-card">
<div class="timeline-header">
<div class="timeline-title">
<h2>Forschungstimeline</h2>
<p>
Entwicklung der Forschungsthemen im Zeitverlauf
<span>(basierend auf Publikationen)</span>
</p>
</div>
<div class="view-toggle" aria-label="Ansicht wechseln">
<button
type="button"
[class.active]="timelineViewMode === 'years'"
(click)="setTimelineViewMode('years')"
>
Jahre
</button>
<button
type="button"
[class.active]="timelineViewMode === 'compact'"
(click)="setTimelineViewMode('compact')"
>
Kompakt
</button>
</div>
<div *ngIf="hasYearRange" class="year-filter" aria-label="Zeitraum eingrenzen">
<div class="year-filter-top">
<span class="year-filter-label">Zeitraum</span>
<button
type="button"
class="reset-range-button"
[disabled]="!canResetYearRange"
(click)="resetYearRange()"
>
Zurücksetzen
</button>
</div>
<div class="year-filter-values">
<span>{{ selectedStartYear }}</span>
<span>bis</span>
<span>{{ selectedEndYear }}</span>
</div>
<div
class="year-range-slider"
[style.--range-start]="rangeStartPercent"
[style.--range-end]="rangeEndPercent"
>
<div class="range-track"></div>
<input
class="range-input range-input-start"
type="range"
[min]="minYear"
[max]="maxYear"
[value]="selectedStartYear"
(input)="onStartYearInput($event)"
aria-label="Startjahr"
/>
<input
class="range-input range-input-end"
type="range"
[min]="minYear"
[max]="maxYear"
[value]="selectedEndYear"
(input)="onEndYearInput($event)"
aria-label="Endjahr"
/>
</div>
<div class="year-filter-bounds">
<span>{{ minYear }}</span>
<span>{{ maxYear }}</span>
</div>
</div>
</div>
<div *ngIf="loading" class="timeline-state">
Forschungstimeline wird geladen ...
</div>
<div *ngIf="!loading && loadFailed" class="timeline-state timeline-state-error">
Forschungstimeline konnte nicht geladen werden.
</div>
<ng-container *ngIf="!loading && !loadFailed">
<ng-container *ngIf="timelineItems.length > 0; else emptyTimeline">
<ng-container *ngIf="timelineViewMode === 'years'; else compactTimeline">
<div class="timeline-wrapper">
<div class="timeline-inner" [style.min-width.px]="timelineMinWidth">
<div class="timeline-axis" aria-hidden="true"></div>
<div class="timeline-points" [style.grid-template-columns]="gridTemplateColumns">
<div
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
class="timeline-point"
[ngClass]="getColorClass(index)"
>
<span class="year">{{ item.year }}</span>
<span class="dot"></span>
</div>
</div>
<div class="timeline-content" [style.grid-template-columns]="gridTemplateColumns">
<article
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
class="timeline-item"
>
<h3>{{ getMainTopic(item) }}</h3>
<span class="publication-count">
{{ item.publication_count }}
{{ item.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
</span>
<div class="topic-list">
<ng-container *ngIf="getDisplayedTopics(item).length > 0; else noTopicsForYear">
<span
*ngFor="let topic of getDisplayedTopics(item); trackBy: trackByTopic"
class="topic-chip"
[ngClass]="getColorClass(index)"
>
<span class="topic-name">{{ topic.name }}</span>
<span class="topic-count">{{ topic.count }}</span>
</span>
</ng-container>
<ng-template #noTopicsForYear>
<span class="no-topics">
Keine weiteren Topics
</span>
</ng-template>
</div>
</article>
</div>
</div>
</div>
</ng-container>
<ng-template #compactTimeline>
<div class="compact-phase-list">
<article
*ngFor="let phase of compactPhases; let index = index; trackBy: trackByPhase"
class="phase-card"
[ngClass]="getColorClass(index)"
>
<div class="phase-card-header">
<span class="phase-marker"></span>
<div class="phase-title-block">
<span class="phase-years">{{ getPhaseYearLabel(phase) }}</span>
<h3>{{ phase.primaryTopicName }}</h3>
<span class="phase-publications">
{{ phase.publication_count }}
{{ phase.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
</span>
</div>
</div>
<div class="phase-topics">
<ng-container *ngIf="phase.topics.length > 0; else noPhaseTopics">
<span
*ngFor="let topic of phase.topics; trackBy: trackByTopic"
class="topic-chip"
[ngClass]="getColorClass(index)"
>
<span class="topic-name">{{ topic.name }}</span>
<span class="topic-count">{{ topic.count }}</span>
</span>
</ng-container>
<ng-template #noPhaseTopics>
<span class="no-topics">
Keine weiteren Topics
</span>
</ng-template>
</div>
<button
type="button"
class="phase-toggle"
[attr.aria-expanded]="isPhaseExpanded(phase)"
(click)="togglePhase(phase)"
>
{{ isPhaseExpanded(phase) ? 'Details ausblenden' : 'Details anzeigen' }}
</button>
<div *ngIf="isPhaseExpanded(phase)" class="phase-year-details">
<div *ngFor="let year of phase.years; trackBy: trackByYear" class="phase-year-row">
<div class="phase-year-meta">
<strong>{{ year.year }}</strong>
<span>
{{ year.publication_count }}
{{ year.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
</span>
</div>
<div class="phase-year-topics">
<ng-container
*ngIf="
getDisplayedTopicsForPrimaryTopic(year, phase.primaryTopicName).length > 0;
else noPhaseYearTopics
"
>
<span
*ngFor="
let topic of getDisplayedTopicsForPrimaryTopic(year, phase.primaryTopicName);
trackBy: trackByTopic
"
class="mini-topic-chip"
>
<span>{{ topic.name }}</span>
<strong>{{ topic.count }}</strong>
</span>
</ng-container>
<ng-template #noPhaseYearTopics>
<span class="no-topics">
Keine weiteren Topics
</span>
</ng-template>
</div>
</div>
</div>
</article>
</div>
</ng-template>
<div class="timeline-note">
<span class="note-dot"></span>
<span>
Hauptforschungsschwerpunkte im jeweiligen Zeitraum
</span>
</div>
</ng-container>
</ng-container>
<ng-template #emptyTimeline>
<div class="timeline-state">
Keine Timeline-Daten vorhanden.
</div>
</ng-template>
</section>
@@ -0,0 +1,689 @@
.research-timeline-card {
width: 100%;
padding: 24px 28px;
border: 1px solid #d7e4ff;
border-radius: 16px;
background: #ffffff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
box-sizing: border-box;
}
.timeline-header {
display: grid;
grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
align-items: flex-start;
gap: 24px;
margin-bottom: 28px;
}
.timeline-title {
min-width: 0;
h2 {
margin: 0 0 6px;
color: #07163d;
font-size: 20px;
font-weight: 700;
line-height: 1.25;
}
p {
margin: 0;
color: #64718f;
font-size: 14px;
line-height: 1.4;
span {
color: #74809b;
}
}
}
.year-filter {
justify-self: end;
width: min(285px, 100%);
padding: 8px 10px;
border: 1px solid #dbe5f6;
border-radius: 10px;
background: #fbfdff;
}
.year-filter-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 4px;
}
.year-filter-label {
color: #07163d;
font-size: 12px;
font-weight: 700;
}
.reset-range-button {
border: none;
background: transparent;
color: #0057ff;
font-size: 11px;
cursor: pointer;
padding: 0;
&:disabled {
color: #9aa5bc;
cursor: default;
}
}
.year-filter-values {
display: flex;
align-items: center;
justify-content: center;
gap: 7px;
margin-bottom: 5px;
color: #40506f;
font-size: 12px;
font-weight: 600;
}
.year-range-slider {
--range-start: 0%;
--range-end: 100%;
position: relative;
height: 22px;
margin: 0;
}
.range-track {
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 5px;
transform: translateY(-50%);
border-radius: 999px;
background:
linear-gradient(
to right,
#d8e2f4 0%,
#d8e2f4 var(--range-start),
#0057ff var(--range-start),
#0057ff var(--range-end),
#d8e2f4 var(--range-end),
#d8e2f4 100%
);
}
.range-input {
position: absolute;
top: 0;
left: 0;
width: 100%;
margin: 0;
height: 22px;
appearance: none;
background: transparent;
pointer-events: none;
}
.range-input::-webkit-slider-runnable-track {
height: 5px;
background: transparent;
border: none;
}
.range-input::-moz-range-track {
height: 5px;
background: transparent;
border: none;
}
.range-input::-webkit-slider-thumb {
appearance: none;
width: 15px;
height: 15px;
margin-top: -5px;
border: 2px solid #ffffff;
border-radius: 50%;
background: #0057ff;
box-shadow: 0 0 0 1px #9ab7ff, 0 2px 6px rgba(0, 87, 255, 0.22);
cursor: pointer;
pointer-events: auto;
}
.range-input::-moz-range-thumb {
width: 15px;
height: 15px;
border: 2px solid #ffffff;
border-radius: 50%;
background: #0057ff;
box-shadow: 0 0 0 1px #9ab7ff, 0 2px 6px rgba(0, 87, 255, 0.22);
cursor: pointer;
pointer-events: auto;
}
.range-input:focus-visible::-webkit-slider-thumb {
outline: 2px solid #07163d;
outline-offset: 2px;
}
.range-input:focus-visible::-moz-range-thumb {
outline: 2px solid #07163d;
outline-offset: 2px;
}
.range-input-start {
z-index: 2;
}
.range-input-end {
z-index: 3;
}
.year-filter-bounds {
display: flex;
justify-content: space-between;
margin-top: 1px;
color: #7c88a3;
font-size: 10px;
}
.view-toggle {
justify-self: center;
display: flex;
gap: 4px;
padding: 4px;
border: 1px solid #dbe5f6;
border-radius: 10px;
background: #ffffff;
button {
border: none;
border-radius: 8px;
padding: 9px 18px;
background: transparent;
color: #3f4b66;
font-size: 14px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
background: #f2f6ff;
}
&.active {
background: #eef4ff;
color: #0057ff;
box-shadow: inset 0 0 0 1px #3d7cff;
}
}
}
.timeline-wrapper {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
padding: 4px 0 8px;
}
.timeline-inner {
position: relative;
padding: 0 34px 8px;
}
.timeline-axis {
position: absolute;
top: 34px;
left: 34px;
right: 34px;
height: 2px;
background: #23395d;
}
.timeline-axis::after {
content: "";
position: absolute;
top: -5px;
right: -10px;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 12px solid #23395d;
}
.timeline-points {
position: relative;
z-index: 1;
display: grid;
align-items: start;
min-height: 58px;
}
.timeline-point {
display: flex;
flex-direction: column;
align-items: center;
min-width: 0;
.year {
margin-bottom: 9px;
color: #15213f;
font-size: 14px;
font-weight: 700;
line-height: 18px;
white-space: nowrap;
}
.dot {
width: 13px;
height: 13px;
border: 3px solid #ffffff;
border-radius: 50%;
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16);
}
}
.timeline-content {
display: grid;
gap: 0;
margin-top: 8px;
}
.timeline-item {
min-width: 0;
padding: 0 16px;
text-align: center;
h3 {
min-height: 42px;
margin: 0 0 8px;
color: #07163d;
font-size: 15px;
font-weight: 700;
line-height: 1.35;
overflow-wrap: anywhere;
}
}
.publication-count {
display: block;
margin-bottom: 14px;
color: #68748f;
font-size: 12px;
}
.topic-list {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
}
.topic-chip {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 7px;
width: fit-content;
max-width: 210px;
min-height: 34px;
padding: 6px 10px;
border-radius: 8px;
font-size: 12px;
font-weight: 500;
line-height: 1.25;
}
.topic-name {
min-width: 0;
overflow-wrap: anywhere;
}
.topic-count {
display: inline-flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.78);
color: inherit;
font-size: 11px;
font-weight: 700;
}
.no-topics {
color: #9aa5bc;
font-size: 12px;
}
.compact-phase-list {
display: flex;
flex-wrap: wrap;
align-items: stretch;
gap: 14px;
}
.phase-card {
flex: 0 1 calc((100% - 28px) / 3);
max-width: 520px;
min-width: 300px;
box-sizing: border-box;
padding: 15px 16px;
border: 1px solid #dbe5f6;
border-left-width: 4px;
border-radius: 14px;
background: #fbfdff;
}
.phase-card-header {
display: flex;
align-items: flex-start;
gap: 10px;
}
.phase-marker {
flex: 0 0 auto;
width: 11px;
height: 11px;
margin-top: 5px;
border: 3px solid #ffffff;
border-radius: 50%;
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
}
.phase-title-block {
min-width: 0;
h3 {
margin: 3px 0 4px;
color: #07163d;
font-size: 15px;
font-weight: 700;
line-height: 1.35;
}
}
.phase-years {
display: inline-flex;
width: fit-content;
padding: 2px 8px;
border-radius: 999px;
background: #eef4ff;
color: #0057ff;
font-size: 12px;
font-weight: 700;
}
.phase-publications {
color: #68748f;
font-size: 12px;
}
.phase-topics {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 14px;
}
.phase-toggle {
margin-top: 13px;
border: none;
background: transparent;
color: #0057ff;
font-size: 12px;
font-weight: 700;
cursor: pointer;
padding: 0;
}
.phase-year-details {
display: flex;
flex-direction: column;
margin-top: 13px;
padding-top: 4px;
padding-right: 6px;
border-top: 1px solid #dbe5f6;
max-height: 320px;
overflow-y: auto;
overflow-x: hidden;
scrollbar-gutter: stable;
overscroll-behavior: contain;
}
.phase-year-details::-webkit-scrollbar {
width: 8px;
}
.phase-year-details::-webkit-scrollbar-thumb {
border-radius: 999px;
background: #c8d4e8;
}
.phase-year-details::-webkit-scrollbar-track {
background: transparent;
}
.phase-year-row {
display: grid;
grid-template-columns: 72px 1fr;
gap: 10px;
align-items: start;
padding: 10px 0;
}
.phase-year-row + .phase-year-row {
border-top: 1px solid #e4ebf7;
}
.phase-year-meta {
display: flex;
flex-direction: column;
gap: 2px;
strong {
color: #07163d;
font-size: 13px;
}
span {
color: #68748f;
font-size: 11px;
}
}
.phase-year-topics {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.mini-topic-chip {
display: inline-flex;
align-items: center;
gap: 5px;
max-width: 100%;
padding: 4px 7px;
border-radius: 7px;
background: #f2f6ff;
color: #40506f;
font-size: 11px;
line-height: 1.25;
span {
overflow-wrap: anywhere;
}
strong {
color: #0057ff;
font-size: 10px;
}
}
.purple {
.dot,
.phase-marker {
background: #7255d9;
}
}
.blue {
.dot,
.phase-marker {
background: #2678e8;
}
}
.green {
.dot,
.phase-marker {
background: #39a96b;
}
}
.orange {
.dot,
.phase-marker {
background: #f59e0b;
}
}
.pink {
.dot,
.phase-marker {
background: #e0527c;
}
}
.phase-card.purple {
border-left-color: #7255d9;
}
.phase-card.blue {
border-left-color: #2678e8;
}
.phase-card.green {
border-left-color: #39a96b;
}
.phase-card.orange {
border-left-color: #f59e0b;
}
.phase-card.pink {
border-left-color: #e0527c;
}
.topic-chip.purple {
border: 1px solid #d8cafe;
background: #f6f0ff;
color: #7255d9;
}
.topic-chip.blue {
border: 1px solid #bdd4ff;
background: #f0f6ff;
color: #0b63ce;
}
.topic-chip.green {
border: 1px solid #bdebcf;
background: #effaf3;
color: #24834f;
}
.topic-chip.orange {
border: 1px solid #ffd796;
background: #fff7e8;
color: #c67500;
}
.topic-chip.pink {
border: 1px solid #ffc7d7;
background: #fff1f5;
color: #d12f61;
}
.timeline-note {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 18px;
color: #68748f;
font-size: 13px;
text-align: center;
}
.note-dot {
width: 10px;
height: 10px;
border: 3px solid #dce5f5;
border-radius: 50%;
background: #52627f;
}
.timeline-state {
display: flex;
min-height: 140px;
align-items: center;
justify-content: center;
padding: 20px;
color: #68748f;
font-size: 14px;
text-align: center;
}
.timeline-state-error {
color: #b42318;
}
@media (max-width: 1100px) {
.timeline-header {
grid-template-columns: 1fr;
}
.view-toggle {
justify-self: start;
}
.year-filter {
justify-self: stretch;
width: 100%;
}
.phase-card {
flex-basis: calc((100% - 14px) / 2);
max-width: none;
}
}
@media (max-width: 700px) {
.research-timeline-card {
padding: 20px;
}
.view-toggle {
width: 100%;
button {
flex: 1;
}
}
.phase-card {
flex-basis: 100%;
min-width: 0;
}
.phase-year-row {
grid-template-columns: 1fr;
}
}
@@ -0,0 +1,446 @@
import { CommonModule } from '@angular/common';
import {
Component,
EventEmitter,
Input,
OnChanges,
Output,
SimpleChanges,
} from '@angular/core';
export interface TopicTimelineTopic {
name: string;
count: number;
}
export interface TopicTimelineElement {
year: number;
publication_count: number;
topics: TopicTimelineTopic[];
primary_topics?: TopicTimelineTopic[];
}
export type TimelineViewMode = 'years' | 'compact';
export interface TimelineYearRange {
startYear: number;
endYear: number;
}
interface ResearchTimelinePhase {
id: string;
startYear: number;
endYear: number;
publication_count: number;
primaryTopicName: string;
years: TopicTimelineElement[];
topics: TopicTimelineTopic[];
}
interface WorkingResearchTimelinePhase {
startYear: number;
endYear: number;
publication_count: number;
primaryTopicName: string;
years: TopicTimelineElement[];
}
@Component({
selector: 'app-research-timeline',
standalone: true,
imports: [CommonModule],
templateUrl: './research-timeline.component.html',
styleUrl: './research-timeline.component.scss',
})
export class ResearchTimelineComponent implements OnChanges {
@Input() elements: TopicTimelineElement[] = [];
@Input() loading = false;
@Input() loadFailed = false;
@Input() viewMode: TimelineViewMode = 'years';
@Input() startYear: number | undefined;
@Input() endYear: number | undefined;
@Output() viewModeChange = new EventEmitter<TimelineViewMode>();
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
timelineViewMode: TimelineViewMode = 'years';
minYear = 0;
maxYear = 0;
selectedStartYear = 0;
selectedEndYear = 0;
private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink'];
private readonly columnWidth = 240;
private readonly displayedTopicLimit = 3;
private readonly displayedPhaseTopicLimit = 4;
private readonly expandedPhaseIds = new Set<string>();
ngOnChanges(changes: SimpleChanges): void {
if (changes['viewMode']) {
this.timelineViewMode = this.isTimelineViewMode(this.viewMode)
? this.viewMode
: 'years';
}
if (changes['elements']) {
this.initializeYearBounds();
}
if (changes['elements'] || changes['startYear'] || changes['endYear']) {
this.applyInputYearRange();
}
}
get timelineItems(): TopicTimelineElement[] {
return this.sortedElements.filter((item) => {
return item.year >= this.selectedStartYear && item.year <= this.selectedEndYear;
});
}
get compactPhases(): ResearchTimelinePhase[] {
return this.buildCompactPhases(this.timelineItems);
}
get hasYearRange(): boolean {
return this.minYear > 0 && this.maxYear > 0 && this.minYear < this.maxYear;
}
get canResetYearRange(): boolean {
return this.selectedStartYear !== this.minYear || this.selectedEndYear !== this.maxYear;
}
get rangeStartPercent(): string {
return `${this.calculateRangePercent(this.selectedStartYear)}%`;
}
get rangeEndPercent(): string {
return `${this.calculateRangePercent(this.selectedEndYear)}%`;
}
get gridTemplateColumns(): string {
const count = Math.max(this.timelineItems.length, 1);
return `repeat(${count}, minmax(${this.columnWidth}px, 1fr))`;
}
get timelineMinWidth(): number {
const count = Math.max(this.timelineItems.length, 1);
return Math.max(count * this.columnWidth, 1000);
}
setTimelineViewMode(mode: TimelineViewMode): void {
if (this.timelineViewMode === mode) {
return;
}
this.timelineViewMode = mode;
this.viewModeChange.emit(mode);
}
onStartYearInput(event: Event): void {
const nextStartYear = this.parseYearInput(event);
this.selectedStartYear = this.clampYear(nextStartYear);
if (this.selectedStartYear > this.selectedEndYear) {
this.selectedEndYear = this.selectedStartYear;
}
this.emitYearRangeChange();
}
onEndYearInput(event: Event): void {
const nextEndYear = this.parseYearInput(event);
this.selectedEndYear = this.clampYear(nextEndYear);
if (this.selectedEndYear < this.selectedStartYear) {
this.selectedStartYear = this.selectedEndYear;
}
this.emitYearRangeChange();
}
resetYearRange(): void {
this.selectedStartYear = this.minYear;
this.selectedEndYear = this.maxYear;
this.emitYearRangeChange();
}
getPrimaryTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined {
return (item.primary_topics ?? [])[0];
}
getMainTopic(item: TopicTimelineElement): string {
return this.getPrimaryTopic(item)?.name ?? this.getFirstTopic(item)?.name ?? 'Keine Topics';
}
getDisplayedTopics(item: TopicTimelineElement): TopicTimelineTopic[] {
const primaryTopicName = this.getPrimaryTopic(item)?.name;
return this.getDisplayedTopicsForPrimaryTopic(item, primaryTopicName);
}
getDisplayedTopicsForPrimaryTopic(
item: TopicTimelineElement,
primaryTopicName: string | undefined,
): TopicTimelineTopic[] {
return (item.topics ?? [])
.filter((topic) => !this.isSameTopic(topic.name, primaryTopicName))
.slice(0, this.displayedTopicLimit);
}
getPhaseYearLabel(phase: ResearchTimelinePhase): string {
if (phase.startYear === phase.endYear) {
return `${phase.startYear}`;
}
return `${phase.startYear}–${phase.endYear}`;
}
togglePhase(phase: ResearchTimelinePhase): void {
if (this.expandedPhaseIds.has(phase.id)) {
this.expandedPhaseIds.delete(phase.id);
return;
}
this.expandedPhaseIds.add(phase.id);
}
isPhaseExpanded(phase: ResearchTimelinePhase): boolean {
return this.expandedPhaseIds.has(phase.id);
}
getColorClass(index: number): string {
return this.colors[index % this.colors.length];
}
trackByYear(_: number, item: TopicTimelineElement): number {
return item.year;
}
trackByTopic(_: number, topic: TopicTimelineTopic): string {
return topic.name;
}
trackByPhase(_: number, phase: ResearchTimelinePhase): string {
return phase.id;
}
private get sortedElements(): TopicTimelineElement[] {
return [...(this.elements ?? [])].sort((left, right) => left.year - right.year);
}
private initializeYearBounds(): void {
const years = this.sortedElements
.map((item) => item.year)
.filter((year) => Number.isFinite(year));
if (years.length === 0) {
this.minYear = 0;
this.maxYear = 0;
this.selectedStartYear = 0;
this.selectedEndYear = 0;
return;
}
this.minYear = Math.min(...years);
this.maxYear = Math.max(...years);
}
private applyInputYearRange(): void {
if (this.minYear === 0 || this.maxYear === 0) {
return;
}
const requestedStartYear = this.isValidYear(this.startYear)
? this.startYear
: this.minYear;
const requestedEndYear = this.isValidYear(this.endYear)
? this.endYear
: this.maxYear;
const clampedStartYear = this.clampYear(requestedStartYear);
const clampedEndYear = this.clampYear(requestedEndYear);
this.selectedStartYear = Math.min(clampedStartYear, clampedEndYear);
this.selectedEndYear = Math.max(clampedStartYear, clampedEndYear);
}
private buildCompactPhases(items: TopicTimelineElement[]): ResearchTimelinePhase[] {
const phases: ResearchTimelinePhase[] = [];
let currentPhase: WorkingResearchTimelinePhase | undefined;
for (const item of items) {
const candidates = this.getDominantPrimaryTopicCandidates(item);
if (candidates.length === 0) {
this.pushWorkingPhase(phases, currentPhase);
currentPhase = this.createWorkingPhase(item, this.getMainTopic(item));
continue;
}
const matchingCandidate = currentPhase
? candidates.find((candidate) =>
this.isSameTopic(candidate.name, currentPhase?.primaryTopicName),
)
: undefined;
const canExtendCurrentPhase =
Boolean(currentPhase) &&
Boolean(matchingCandidate) &&
item.year === currentPhase!.endYear + 1;
if (currentPhase && canExtendCurrentPhase) {
currentPhase.endYear = item.year;
currentPhase.publication_count += item.publication_count;
currentPhase.years.push(item);
continue;
}
this.pushWorkingPhase(phases, currentPhase);
currentPhase = this.createWorkingPhase(item, candidates[0].name);
}
this.pushWorkingPhase(phases, currentPhase);
return phases;
}
private createWorkingPhase(
item: TopicTimelineElement,
primaryTopicName: string,
): WorkingResearchTimelinePhase {
return {
startYear: item.year,
endYear: item.year,
publication_count: item.publication_count,
primaryTopicName,
years: [item],
};
}
private pushWorkingPhase(
phases: ResearchTimelinePhase[],
workingPhase: WorkingResearchTimelinePhase | undefined,
): void {
if (!workingPhase) {
return;
}
phases.push({
...workingPhase,
id: `${workingPhase.startYear}-${workingPhase.endYear}-${this.normalizeTopicName(
workingPhase.primaryTopicName,
)}`,
topics: this.aggregatePhaseTopics(workingPhase.years, workingPhase.primaryTopicName),
});
}
private aggregatePhaseTopics(
years: TopicTimelineElement[],
primaryTopicName: string,
): TopicTimelineTopic[] {
const counts = new Map<string, number>();
const originalNames = new Map<string, string>();
for (const year of years) {
for (const topic of year.topics ?? []) {
if (this.isSameTopic(topic.name, primaryTopicName)) {
continue;
}
const normalizedName = this.normalizeTopicName(topic.name);
originalNames.set(normalizedName, topic.name);
counts.set(normalizedName, (counts.get(normalizedName) ?? 0) + topic.count);
}
}
return Array.from(counts.entries())
.map(([normalizedName, count]) => ({
name: originalNames.get(normalizedName) ?? normalizedName,
count,
}))
.sort((left, right) => {
if (right.count !== left.count) {
return right.count - left.count;
}
return left.name.localeCompare(right.name);
})
.slice(0, this.displayedPhaseTopicLimit);
}
private getDominantPrimaryTopicCandidates(item: TopicTimelineElement): TopicTimelineTopic[] {
const primaryTopics = item.primary_topics ?? [];
if (primaryTopics.length === 0) {
return [];
}
const maxCount = Math.max(...primaryTopics.map((topic) => topic.count));
return primaryTopics.filter((topic) => topic.count === maxCount);
}
private getFirstTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined {
return (item.topics ?? [])[0];
}
private isSameTopic(topicName: string, primaryTopicName: string | undefined): boolean {
if (!primaryTopicName) {
return false;
}
return this.normalizeTopicName(topicName) === this.normalizeTopicName(primaryTopicName);
}
private normalizeTopicName(topicName: string): string {
return topicName.trim().toLowerCase();
}
private parseYearInput(event: Event): number {
const input = event.target as HTMLInputElement | null;
const value = Number(input?.value ?? this.minYear);
if (!Number.isFinite(value)) {
return this.minYear;
}
return value;
}
private clampYear(year: number): number {
return Math.min(Math.max(year, this.minYear), this.maxYear);
}
private calculateRangePercent(year: number): number {
if (!this.hasYearRange) {
return 0;
}
const totalRange = this.maxYear - this.minYear;
if (totalRange <= 0) {
return 0;
}
return ((year - this.minYear) / totalRange) * 100;
}
private isTimelineViewMode(value: string): value is TimelineViewMode {
return value === 'years' || value === 'compact';
}
private isValidYear(value: number | undefined): value is number {
return typeof value === 'number' && Number.isFinite(value);
}
private emitYearRangeChange(): void {
this.yearRangeChange.emit({
startYear: this.selectedStartYear,
endYear: this.selectedEndYear,
});
}
}
@@ -1 +1,12 @@
Dummy
<section class="person-overview">
<app-research-timeline
[elements]="topicTimelineElements"
[loading]="loadingTimeline"
[loadFailed]="timelineLoadFailed"
[viewMode]="timelineViewMode"
[startYear]="timelineStartYear"
[endYear]="timelineEndYear"
(viewModeChange)="onTimelineViewModeChange($event)"
(yearRangeChange)="onTimelineYearRangeChange($event)"
></app-research-timeline>
</section>
@@ -0,0 +1,4 @@
.person-overview {
width: 100%;
display: block;
}
@@ -1,11 +1,177 @@
import { Component } from '@angular/core';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { CommonModule } from '@angular/common';
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
import { TopicCount, TopicsByYear, WorksService } from '../../api';
import {
ResearchTimelineComponent,
TimelineViewMode,
TimelineYearRange,
TopicTimelineElement,
TopicTimelineTopic,
} from './components/research-timeline/research-timeline.component';
@Component({
selector: 'app-person-overview',
imports: [],
standalone: true,
imports: [CommonModule, ResearchTimelineComponent],
templateUrl: './person-overview.component.html',
styleUrl: './person-overview.component.scss',
})
export class PersonOverviewComponent {
export class PersonOverviewComponent implements OnInit {
private static readonly timelineViewQueryParam = 'timeline_view';
private static readonly timelineStartYearQueryParam = 'timeline_start_year';
private static readonly timelineEndYearQueryParam = 'timeline_end_year';
}
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly worksService = inject(WorksService);
private readonly destroyRef = inject(DestroyRef);
topicTimelineElements: TopicTimelineElement[] = [];
loadingTimeline = false;
timelineLoadFailed = false;
timelineViewMode: TimelineViewMode = 'years';
timelineStartYear: number | undefined;
timelineEndYear: number | undefined;
ngOnInit(): void {
combineLatest(this.route.pathFromRoot.map((route) => route.paramMap))
.pipe(
map((paramMaps) => this.findAuthorId(paramMaps)),
distinctUntilChanged(),
takeUntilDestroyed(this.destroyRef),
)
.subscribe((authorId) => {
this.loadTopicTimeline(authorId);
});
this.route.queryParamMap
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((queryParams) => {
this.timelineViewMode = this.parseTimelineViewMode(
queryParams.get(PersonOverviewComponent.timelineViewQueryParam),
);
this.timelineStartYear = this.parseOptionalYear(
queryParams.get(PersonOverviewComponent.timelineStartYearQueryParam),
);
this.timelineEndYear = this.parseOptionalYear(
queryParams.get(PersonOverviewComponent.timelineEndYearQueryParam),
);
});
}
onTimelineViewModeChange(viewMode: TimelineViewMode): void {
this.timelineViewMode = viewMode;
this.updateTimelineQueryParams(
{
[PersonOverviewComponent.timelineViewQueryParam]: viewMode,
},
false,
);
}
onTimelineYearRangeChange(range: TimelineYearRange): void {
this.timelineStartYear = range.startYear;
this.timelineEndYear = range.endYear;
this.updateTimelineQueryParams(
{
[PersonOverviewComponent.timelineStartYearQueryParam]: range.startYear,
[PersonOverviewComponent.timelineEndYearQueryParam]: range.endYear,
},
true,
);
}
private findAuthorId(paramMaps: readonly ParamMap[]): string {
return (
paramMaps
.map((paramMap) => paramMap.get('id'))
.find((id): id is string => Boolean(id)) ?? ''
);
}
private loadTopicTimeline(authorId: string): void {
if (!authorId || authorId === '0') {
this.topicTimelineElements = [];
this.loadingTimeline = false;
this.timelineLoadFailed = false;
return;
}
this.loadingTimeline = true;
this.timelineLoadFailed = false;
const topicCountLimit = 4;
this.worksService
.getTopicsByTimeByAuthor(authorId, topicCountLimit)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (response) => {
this.topicTimelineElements = this.mapTimelineElements(response.elements);
this.loadingTimeline = false;
this.timelineLoadFailed = false;
},
error: (error) => {
console.error('Topic timeline could not be loaded.', error);
this.topicTimelineElements = [];
this.loadingTimeline = false;
this.timelineLoadFailed = true;
},
});
}
private mapTimelineElements(
elements: TopicsByYear[] | undefined,
): TopicTimelineElement[] {
return (elements ?? []).map((element) => ({
year: element.year,
publication_count: element.publication_count ?? 0,
topics: this.mapTopicCounts(element.topics),
primary_topics: this.mapTopicCounts(element.primary_topics),
}));
}
private mapTopicCounts(topics: TopicCount[] | undefined): TopicTimelineTopic[] {
return (topics ?? []).map((topic) => ({
name: topic.name,
count: topic.count ?? 0,
}));
}
private parseTimelineViewMode(value: string | null): TimelineViewMode {
return value === 'compact' ? 'compact' : 'years';
}
private parseOptionalYear(value: string | null): number | undefined {
if (!value) {
return undefined;
}
const year = Number(value);
if (!Number.isInteger(year)) {
return undefined;
}
return year;
}
private updateTimelineQueryParams(
queryParams: Record<string, string | number>,
replaceUrl: boolean,
): void {
void this.router.navigate([], {
relativeTo: this.route,
queryParams,
queryParamsHandling: 'merge',
replaceUrl,
});
}
}
@@ -89,7 +89,7 @@
}
.profile-contact .orcid {
color: var(--sg-success);
color: #6cc24a;
}
.profile-contact a {
@@ -138,7 +138,7 @@
.interest-tags span {
padding: 9px 16px;
border: 1px solid var(--sg-border-strong);
border: 1px solid #a8c0ff;
border-radius: 7px;
background: #ffffff;
color: var(--sg-primary);
@@ -181,7 +181,11 @@
}
.profile-card {
grid-template-columns: minmax(240px, 1fr) minmax(260px, 360px);
grid-template-columns: 112px 1fr;
}
.profile-contact {
grid-column: 2;
}
.sidebar {
@@ -101,7 +101,13 @@ readonly personBio = toSignal(
);
readonly worksCount = computed(() => this.person()?.works_count ?? null);
readonly citedByCount = computed(() => this.person()?.cited_by_count ?? null);
readonly orcid = computed(() => this.getId('orcid'));
readonly orcid = computed(() => {
const rawOrcid = this.getId('orcid');
if (!rawOrcid) {
return null;
}
return rawOrcid.replace('https://orcid.org/', '');
});
readonly orcidUrl = computed(() =>
this.orcid() ? `https://orcid.org/${this.orcid()}` : null,
);
@@ -1,43 +0,0 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Inject, Injectable, Optional } from '@angular/core';
import { Observable } from 'rxjs';
import { Author } from '../../api';
import { BASE_PATH } from '../../api/variables';
export interface AuthorPage {
elements?: Author[];
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 ?? 'http://localhost:8000';
}
getPersons(
pageOffset: number = 0,
pageSize: number = 24,
query?: string,
): Observable<AuthorPage> {
let params = new HttpParams()
.set('pageOffset', pageOffset)
.set('pageSize', pageSize);
if (query?.trim()) {
params = params.set('query', query.trim());
}
return this.http.get<AuthorPage>(`${this.basePath}/api/inse-service/persons`, { params });
}
}
@@ -31,7 +31,7 @@
content: '';
position: absolute;
inset: 10px 8px;
border: 2px solid color-mix(in srgb, var(--sg-primary) 22%, transparent);
border: 2px solid rgba(0, 87, 255, 0.22);
border-radius: 50%;
}
@@ -129,7 +129,7 @@
width: 40px;
height: 40px;
border-radius: 50%;
background: linear-gradient(135deg, var(--sg-primary-soft), #ffffff);
background: linear-gradient(135deg, #dce8ff, #ffffff);
color: var(--sg-primary);
font-weight: 700;
}
+1 -1
View File
@@ -9,4 +9,4 @@
"secure": false,
"changeOrigin": true
}
}
}