Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bca6648bd | ||
|
|
af00bc4635 | ||
|
|
def210b4b9 | ||
|
|
89bdab0a26 | ||
|
|
448922d907 | ||
|
|
3ef8c28191 | ||
|
|
e57875d2a5 | ||
|
|
28726cf4c7 | ||
|
|
b0e4ad639e | ||
|
|
1810918e43 | ||
|
|
a736539851 | ||
|
|
591233e255 | ||
|
|
c2a2a31fb9 | ||
|
|
d4a4bfa2c7 | ||
|
|
3a127450e3 | ||
|
|
c2f9a6381a | ||
|
|
7adf12912f | ||
|
|
0b2b05ae85 | ||
|
|
127c32dce7 | ||
|
|
652ff8db15 | ||
|
|
f25c5cd222 | ||
|
|
0b5c6bed37 | ||
|
|
2d485263d1 | ||
|
|
3d78ec900e | ||
|
|
fc134dad8e | ||
|
|
59a1f765d0 |
@@ -12,6 +12,11 @@ ELASTICSEARCH_API_KEY=am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ
|
||||
ELASTICSEARCH_INSE_URL=https://inse.nes.uni-due.de/elastic
|
||||
ELASTICSEARCH_INSE_API_KEY=bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
|
||||
# Debugging: Log every outgoing Elasticsearch query (index + payload)
|
||||
PRINT_ES_QUERIES=false
|
||||
# Debugging: Log the duration of every Elasticsearch request
|
||||
PRINT_ES_TIMINGS=true
|
||||
|
||||
# Sentence Transformers Configuration
|
||||
SENTENCE_TRANSFORMERS_MODEL_NAME=intfloat/multilingual-e5-base
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from inse.authors.v2.model import (
|
||||
StartCollaborationGraphResponse,
|
||||
)
|
||||
from inse.database import SessionDep
|
||||
from inse.models.openalex.author import Author
|
||||
from inse.router_prefixes import RouterPrefixes
|
||||
from inse.tags import Tags
|
||||
|
||||
@@ -18,6 +19,22 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix=RouterPrefixes.AUTHORS_V2, tags=[Tags.AUTHORS_V2])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{raw_oa_author_id}",
|
||||
operation_id="getAuthorById",
|
||||
summary="Returns an author for a given author ID.",
|
||||
)
|
||||
async def get_author_by_id(
|
||||
raw_oa_author_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the author to retrieve."),
|
||||
],
|
||||
) -> Author:
|
||||
return await authors_service.get_author_by_id_strict_or_raise(
|
||||
raw_oa_author_id=raw_oa_author_id
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/authors/id",
|
||||
operation_id="getAuthorsByIds",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@ from inse.authors.v2.model import (
|
||||
StartCollaborationGraphResponse,
|
||||
WorkNode,
|
||||
)
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex
|
||||
from inse.models.openalex.author import Author
|
||||
@@ -68,21 +69,41 @@ async def search_authors(
|
||||
return AuthorPage(elements=authors, total=len(authors), page=page, size=size)
|
||||
|
||||
|
||||
async def get_author_by_id(author_id: str) -> Author | None:
|
||||
async def get_author_by_id(raw_oa_author_id: str) -> Author | None:
|
||||
"""Retrieves an author from the OpenAlex Elasticsearch index based on the provided author ID.
|
||||
|
||||
Args:
|
||||
author_id (str): The ID of the author to retrieve.
|
||||
raw_oa_author_id (str): The raw OpenAlex author ID of the author to retrieve.
|
||||
|
||||
Returns:
|
||||
Optional[Author]: The retrieved author, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(index=ESIndex.OPENALEX_AUTHORS, doc_id=author_id)
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_AUTHORS, doc_id=raw_oa_author_id
|
||||
)
|
||||
if not response.get("found"):
|
||||
return None
|
||||
return Author.from_dict(response.get("_source", {})) # type: ignore
|
||||
|
||||
|
||||
async def get_author_by_id_strict_or_raise(raw_oa_author_id: str) -> Author:
|
||||
"""Retrieves an author from the OpenAlex Elasticsearch index based on the provided author ID.
|
||||
|
||||
Args:
|
||||
raw_oa_author_id (str): The raw OpenAlex author ID of the author to retrieve.
|
||||
|
||||
Returns:
|
||||
Author: The retrieved author.
|
||||
|
||||
Raises:
|
||||
ValueError: If the author is not found.
|
||||
"""
|
||||
author = await get_author_by_id(raw_oa_author_id=raw_oa_author_id)
|
||||
if not author:
|
||||
raise NotFoundException(f"Author with ID {raw_oa_author_id} not found.")
|
||||
return author
|
||||
|
||||
|
||||
async def autocomplete_authors_for_selector(query: str) -> AuthorPage:
|
||||
"""Autocompletes authors based on a search term for use in a selector component.
|
||||
|
||||
@@ -367,7 +388,7 @@ async def _build_collaboration_graph(
|
||||
f"Searching works for collaboration graph of author {raw_oa_author_id} with query: {query}"
|
||||
)
|
||||
|
||||
work_page: WorkPageV2 = await works_service.search_works(
|
||||
work_page: WorkPageV2 = await works_service._search_works(
|
||||
query=query,
|
||||
source=COLLABORATION_GRAPH_SOURCE_FIELDS,
|
||||
page=0,
|
||||
|
||||
@@ -69,6 +69,8 @@ class Settings(BaseSettings):
|
||||
elasticsearch_api_key: Optional[str] = None
|
||||
elasticsearch_inse_url: Optional[str] = None
|
||||
elasticsearch_inse_api_key: Optional[str] = None
|
||||
print_es_queries: bool = False
|
||||
print_es_timings: bool = False
|
||||
|
||||
model_config = SettingsConfigDict(env_file=str(ENV_FILE))
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class TopAuthor(BaseModel):
|
||||
class TopAuthorStatistics(BaseModel):
|
||||
institution_id: str
|
||||
works: list[TopAuthor]
|
||||
projects: list[TopAuthor]
|
||||
eu_projects: list[TopAuthor]
|
||||
patents: list[TopAuthor]
|
||||
news: list[TopAuthor]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime
|
||||
from typing import Any, Literal
|
||||
|
||||
@@ -12,6 +13,8 @@ from inse.integrations import elasticsearch
|
||||
from inse.institutions.institutions_search_client import InstitutionsSearchClient
|
||||
from inse.model import ESCluster, ESIndex
|
||||
from inse.patents.org.elastic_search_client import OrgPatentsSearchClient
|
||||
from inse.projects.dfg_institutions.service import autocomplete_institutions_for_selector
|
||||
from inse.projects.logic import get_person_ids_by_institution_ids
|
||||
|
||||
from .institute_helper import get_openalex_institution
|
||||
from .model import (
|
||||
@@ -41,6 +44,41 @@ TOPIC_HEATMAP_YEARS = 5
|
||||
WorksPeriod = Literal["all_time", "last_5_years"]
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
ACADEMIC_TITLE_RE = re.compile(
|
||||
r"^(?:(?:professor(?:in)?|prof|dr)(?:\.-[a-z]+)?\.?|rer\.|nat\.|med\.|ing\.)\s+",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def _normalize_person_name(name: str) -> str:
|
||||
normalized = " ".join(name.strip().casefold().split())
|
||||
while True:
|
||||
without_title = ACADEMIC_TITLE_RE.sub("", normalized).strip()
|
||||
if without_title == normalized:
|
||||
return without_title
|
||||
normalized = without_title
|
||||
|
||||
|
||||
def _is_initial_surname_match(full_name: str, initial_name: str) -> bool:
|
||||
full_parts = _normalize_person_name(full_name).split()
|
||||
initial_parts = _normalize_person_name(initial_name).replace(".", "").split()
|
||||
if len(full_parts) < 2 or len(initial_parts) < 2:
|
||||
return False
|
||||
return (
|
||||
len(initial_parts[0]) == 1
|
||||
and full_parts[0].startswith(initial_parts[0])
|
||||
and full_parts[-1] == initial_parts[-1]
|
||||
)
|
||||
|
||||
|
||||
def _is_supported_name_variant(full_name: str, candidate_name: str) -> bool:
|
||||
return (
|
||||
_normalize_person_name(full_name) == _normalize_person_name(candidate_name)
|
||||
or _is_initial_surname_match(full_name, candidate_name)
|
||||
)
|
||||
|
||||
|
||||
def _total(response: dict[str, Any]) -> int:
|
||||
total = response.get("hits", {}).get("total", 0)
|
||||
if isinstance(total, dict):
|
||||
@@ -625,6 +663,13 @@ async def get_top_authors(
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
authors = await _safe_institution_authors(normalized_id)
|
||||
works = _top_work_authors(authors, works_period)
|
||||
projects = await _safe_top_authors(
|
||||
"projects",
|
||||
_top_project_authors(
|
||||
authors=authors,
|
||||
organization_name=organization_name,
|
||||
),
|
||||
)
|
||||
eu_projects = await _safe_top_authors(
|
||||
"eu_projects",
|
||||
_top_eu_project_publication_authors(),
|
||||
@@ -640,6 +685,7 @@ async def get_top_authors(
|
||||
return TopAuthorStatistics(
|
||||
institution_id=normalized_id,
|
||||
works=works,
|
||||
projects=projects,
|
||||
eu_projects=eu_projects,
|
||||
patents=patents,
|
||||
news=news,
|
||||
@@ -1102,6 +1148,463 @@ async def _institution_authors(institution_id: str) -> list[dict[str, Any]]:
|
||||
]
|
||||
|
||||
|
||||
async def _top_project_authors(
|
||||
authors: list[dict[str, Any]],
|
||||
organization_name: str,
|
||||
) -> list[TopAuthor]:
|
||||
institution_ids = await _dfg_institution_ids_for_organization(
|
||||
organization_name=organization_name,
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"DFG institution IDs for %s: %s",
|
||||
organization_name,
|
||||
institution_ids,
|
||||
)
|
||||
|
||||
if not institution_ids:
|
||||
logger.warning(
|
||||
"No DFG institution IDs found for organization %s.",
|
||||
organization_name,
|
||||
)
|
||||
return []
|
||||
|
||||
selected_person_ids = set(
|
||||
await get_person_ids_by_institution_ids(institution_ids=institution_ids)
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Found %s DFG persons for organization %s.",
|
||||
len(selected_person_ids),
|
||||
organization_name,
|
||||
)
|
||||
|
||||
if not selected_person_ids:
|
||||
return []
|
||||
|
||||
project_ids_by_person: dict[int, set[str]] = {}
|
||||
names: dict[int, str] = {}
|
||||
|
||||
page = 0
|
||||
size = 10000
|
||||
processed = 0
|
||||
|
||||
while True:
|
||||
project_hits, total = await _dfg_project_author_hits(
|
||||
page=page,
|
||||
size=size,
|
||||
person_ids=selected_person_ids,
|
||||
)
|
||||
|
||||
if not project_hits:
|
||||
break
|
||||
|
||||
for project in project_hits:
|
||||
project_id = _dfg_project_id(project)
|
||||
if not project_id:
|
||||
continue
|
||||
|
||||
persons = project.get("persons", [])
|
||||
if not isinstance(persons, list):
|
||||
continue
|
||||
|
||||
for person in persons:
|
||||
if not isinstance(person, dict):
|
||||
continue
|
||||
|
||||
person_id = person.get("person_id")
|
||||
full_name = person.get("full_name")
|
||||
if person_id is None or not full_name:
|
||||
continue
|
||||
|
||||
try:
|
||||
normalized_person_id = int(person_id)
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
|
||||
if normalized_person_id not in selected_person_ids:
|
||||
continue
|
||||
|
||||
project_ids_by_person.setdefault(normalized_person_id, set()).add(
|
||||
project_id
|
||||
)
|
||||
names[normalized_person_id] = str(full_name).strip()
|
||||
|
||||
processed += len(project_hits)
|
||||
if processed >= total:
|
||||
break
|
||||
|
||||
page += 1
|
||||
|
||||
institution_authors: dict[str, list[dict[str, Any]]] = {}
|
||||
for author in authors:
|
||||
if author.get("name"):
|
||||
institution_authors.setdefault(
|
||||
_normalize_person_name(author["name"]),
|
||||
[],
|
||||
).append(author)
|
||||
|
||||
ranked = sorted(
|
||||
(
|
||||
(person_id, project_ids)
|
||||
for person_id, project_ids in project_ids_by_person.items()
|
||||
if project_ids and names.get(person_id)
|
||||
),
|
||||
key=lambda item: (
|
||||
-len(item[1]),
|
||||
names[item[0]].casefold(),
|
||||
),
|
||||
)
|
||||
|
||||
ranked_person_ids = [person_id for person_id, _ in ranked[:TOP_AUTHOR_LIMIT]]
|
||||
dfg_orcids = await _dfg_person_orcids(ranked_person_ids)
|
||||
|
||||
result: list[TopAuthor] = []
|
||||
|
||||
for person_id, project_ids in ranked[:TOP_AUTHOR_LIMIT]:
|
||||
dfg_name = names[person_id]
|
||||
matched_author = _single_author_match(
|
||||
institution_authors.get(_normalize_person_name(dfg_name), [])
|
||||
)
|
||||
|
||||
if matched_author is None and (orcid := dfg_orcids.get(person_id)):
|
||||
matched_author = await _openalex_author_by_orcid(orcid)
|
||||
|
||||
if matched_author is None:
|
||||
matched_author = await _openalex_author_by_dfg_publication_evidence(
|
||||
dfg_name=dfg_name,
|
||||
project_ids=project_ids,
|
||||
)
|
||||
|
||||
if matched_author is None:
|
||||
logger.info(
|
||||
"No exact OpenAlex match for DFG author '%s' (person_id=%s).",
|
||||
dfg_name,
|
||||
person_id,
|
||||
)
|
||||
|
||||
result.append(
|
||||
TopAuthor(
|
||||
id=(
|
||||
_short_author_id(matched_author["id"])
|
||||
if matched_author
|
||||
else None
|
||||
),
|
||||
name=matched_author["name"] if matched_author else dfg_name,
|
||||
count=len(project_ids),
|
||||
)
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"DFG top authors for %s: %s",
|
||||
organization_name,
|
||||
[
|
||||
{
|
||||
"name": author.name,
|
||||
"count": author.count,
|
||||
"id": author.id,
|
||||
}
|
||||
for author in result
|
||||
],
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def _single_author_match(authors: list[dict[str, Any]]) -> dict[str, Any] | None:
|
||||
return authors[0] if len(authors) == 1 else None
|
||||
|
||||
|
||||
async def _dfg_person_orcids(person_ids: list[int]) -> dict[int, str]:
|
||||
if not person_ids:
|
||||
return {}
|
||||
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PERSONS,
|
||||
body={
|
||||
"size": len(person_ids),
|
||||
"_source": ["person_id", "orcid_id"],
|
||||
"query": {"terms": {"person_id": person_ids}},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Could not load DFG ORCIDs for top project authors.")
|
||||
return {}
|
||||
|
||||
result: dict[int, str] = {}
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
person_id = source.get("person_id")
|
||||
orcid = source.get("orcid_id")
|
||||
if person_id is None or not orcid:
|
||||
continue
|
||||
try:
|
||||
result[int(person_id)] = str(orcid)
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
return result
|
||||
|
||||
|
||||
async def _openalex_author_by_orcid(orcid: str) -> dict[str, Any] | None:
|
||||
normalized_orcid = orcid.replace("https://orcid.org/", "").strip()
|
||||
if not normalized_orcid:
|
||||
return None
|
||||
|
||||
prefixed_orcid = f"https://orcid.org/{normalized_orcid}"
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.OPENALEX_AUTHORS,
|
||||
body={
|
||||
"size": 2,
|
||||
"_source": ["id", "display_name"],
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"term": {"orcid.keyword": normalized_orcid}},
|
||||
{"term": {"orcid.keyword": prefixed_orcid}},
|
||||
{"term": {"ids.orcid.keyword": normalized_orcid}},
|
||||
{"term": {"ids.orcid.keyword": prefixed_orcid}},
|
||||
{"term": {"orcid": normalized_orcid}},
|
||||
{"term": {"orcid": prefixed_orcid}},
|
||||
{"term": {"ids.orcid": normalized_orcid}},
|
||||
{"term": {"ids.orcid": prefixed_orcid}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
},
|
||||
cluster=ESCluster.NES,
|
||||
track_total_hits=True,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Could not resolve OpenAlex author by ORCID %s.", orcid)
|
||||
return None
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
if len(hits) != 1:
|
||||
logger.info(
|
||||
"OpenAlex ORCID lookup for %s returned %s hits.",
|
||||
orcid,
|
||||
len(hits),
|
||||
)
|
||||
return None
|
||||
|
||||
source = hits[0].get("_source", {})
|
||||
if not source.get("id") or not source.get("display_name"):
|
||||
return None
|
||||
return {
|
||||
"id": str(source["id"]),
|
||||
"name": str(source["display_name"]),
|
||||
}
|
||||
|
||||
|
||||
async def _openalex_author_by_dfg_publication_evidence(
|
||||
dfg_name: str,
|
||||
project_ids: set[str],
|
||||
) -> dict[str, Any] | None:
|
||||
dois = await _dfg_project_publication_dois(project_ids)
|
||||
if not dois:
|
||||
return None
|
||||
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=config.settings.openalex_works_search_index,
|
||||
body={
|
||||
"size": 10000,
|
||||
"_source": [
|
||||
"doi",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
],
|
||||
"query": {"terms": {"doi": sorted(_doi_variants(dois))}},
|
||||
},
|
||||
cluster=ESCluster.NES,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Could not resolve OpenAlex author from DFG publication DOIs for %s.",
|
||||
dfg_name,
|
||||
)
|
||||
return None
|
||||
|
||||
candidates: dict[str, dict[str, Any]] = {}
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
doi = source.get("doi")
|
||||
if not doi:
|
||||
continue
|
||||
for authorship in source.get("authorships", []) or []:
|
||||
author = authorship.get("author", {}) if isinstance(authorship, dict) else {}
|
||||
author_id = author.get("id")
|
||||
display_name = author.get("display_name")
|
||||
if not author_id or not display_name:
|
||||
continue
|
||||
if not _is_supported_name_variant(dfg_name, str(display_name)):
|
||||
continue
|
||||
candidate = candidates.setdefault(
|
||||
str(author_id),
|
||||
{
|
||||
"id": str(author_id),
|
||||
"name": str(display_name),
|
||||
"dois": set(),
|
||||
},
|
||||
)
|
||||
candidate["dois"].add(str(doi))
|
||||
|
||||
supported_candidates = [
|
||||
candidate
|
||||
for candidate in candidates.values()
|
||||
if len(candidate["dois"]) >= 2
|
||||
]
|
||||
if len(supported_candidates) != 1:
|
||||
if supported_candidates:
|
||||
logger.info(
|
||||
"DFG publication DOI lookup for %s returned %s candidates.",
|
||||
dfg_name,
|
||||
len(supported_candidates),
|
||||
)
|
||||
return None
|
||||
|
||||
candidate = supported_candidates[0]
|
||||
return {
|
||||
"id": candidate["id"],
|
||||
"name": candidate["name"],
|
||||
}
|
||||
|
||||
|
||||
async def _dfg_project_publication_dois(project_ids: set[str]) -> set[str]:
|
||||
if not project_ids:
|
||||
return set()
|
||||
|
||||
numeric_project_ids = [
|
||||
int(project_id)
|
||||
for project_id in project_ids
|
||||
if str(project_id).isdigit()
|
||||
]
|
||||
if not numeric_project_ids:
|
||||
return set()
|
||||
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PROJECTS,
|
||||
body={
|
||||
"size": len(numeric_project_ids),
|
||||
"_source": ["publications.doi"],
|
||||
"query": {"terms": {"id": numeric_project_ids}},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Could not load DFG publication DOIs.")
|
||||
return set()
|
||||
|
||||
dois: set[str] = set()
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
for publication in hit.get("_source", {}).get("publications", []) or []:
|
||||
doi = publication.get("doi") if isinstance(publication, dict) else None
|
||||
if doi:
|
||||
dois.add(str(doi).strip())
|
||||
return {doi for doi in dois if doi}
|
||||
|
||||
|
||||
def _doi_variants(dois: set[str]) -> set[str]:
|
||||
variants: set[str] = set()
|
||||
for doi in dois:
|
||||
normalized = doi.strip()
|
||||
if not normalized:
|
||||
continue
|
||||
raw = normalized
|
||||
for prefix in ("https://doi.org/", "http://dx.doi.org/"):
|
||||
if raw.casefold().startswith(prefix):
|
||||
raw = raw[len(prefix):]
|
||||
break
|
||||
variants.update(
|
||||
{
|
||||
normalized,
|
||||
normalized.lower(),
|
||||
f"https://doi.org/{raw}",
|
||||
f"https://doi.org/{raw.lower()}",
|
||||
}
|
||||
)
|
||||
return variants
|
||||
|
||||
|
||||
async def _dfg_institution_ids_for_organization(organization_name: str) -> list[int]:
|
||||
page = await autocomplete_institutions_for_selector(
|
||||
query=organization_name,
|
||||
page=0,
|
||||
size=10000,
|
||||
)
|
||||
return [institution.id for institution in page.elements if institution.id is not None]
|
||||
|
||||
|
||||
async def _dfg_project_author_hits(
|
||||
page: int,
|
||||
size: int,
|
||||
person_ids: set[int],
|
||||
) -> tuple[list[dict[str, Any]], int]:
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PROJECTS,
|
||||
body={
|
||||
"size": size,
|
||||
"from": page * size,
|
||||
"_source": [
|
||||
"id",
|
||||
"project_id",
|
||||
"persons",
|
||||
],
|
||||
"query": {
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {"terms": {"persons.person_id": sorted(person_ids)}},
|
||||
},
|
||||
},
|
||||
"sort": [
|
||||
{
|
||||
"id": {
|
||||
"order": "asc",
|
||||
"missing": "_last",
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
track_total_hits=True,
|
||||
)
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
total_value = hits_block.get("total", 0)
|
||||
|
||||
if isinstance(total_value, dict):
|
||||
total = int(total_value.get("value", 0))
|
||||
else:
|
||||
total = int(total_value or 0)
|
||||
|
||||
hits = [
|
||||
hit.get("_source", {})
|
||||
for hit in hits_block.get("hits", [])
|
||||
if isinstance(hit.get("_source"), dict)
|
||||
]
|
||||
|
||||
logger.info(
|
||||
"Loaded %s of %s matching DFG projects on page %s.",
|
||||
len(hits),
|
||||
total,
|
||||
page,
|
||||
)
|
||||
|
||||
return hits, total
|
||||
|
||||
|
||||
def _dfg_project_id(project: dict[str, Any]) -> str | None:
|
||||
project_id = project.get("id")
|
||||
if project_id is None:
|
||||
project_id = project.get("project_id")
|
||||
return str(project_id) if project_id is not None else None
|
||||
|
||||
|
||||
async def _top_patent_authors(institution_id: str) -> list[TopAuthor]:
|
||||
client = OrgPatentsSearchClient()
|
||||
authors = await client.top_authors_by_institution(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from datetime import datetime
|
||||
|
||||
@@ -383,7 +384,7 @@ async def test_dashboard_dfg_topics_returns_deduplicated_topics():
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_top_authors_maps_works_patents_and_news_without_project_queries():
|
||||
async def test_top_authors_maps_works_patents_eu_dfg_and_news():
|
||||
async def search(**kwargs):
|
||||
if kwargs["index"] == ESIndex.OPENALEX_AUTHORS:
|
||||
return {
|
||||
@@ -427,6 +428,37 @@ async def test_top_authors_maps_works_patents_and_news_without_project_queries()
|
||||
}
|
||||
}
|
||||
}
|
||||
if kwargs["index"] == ESIndex.DFG_PROJECTS:
|
||||
return {
|
||||
"hits": {
|
||||
"total": {"value": 2},
|
||||
"hits": [
|
||||
{
|
||||
"_source": {
|
||||
"id": "P1",
|
||||
"persons": [
|
||||
{"person_id": 2, "full_name": "Grace Example"},
|
||||
{
|
||||
"person_id": 99,
|
||||
"full_name": "Outside Collaborator",
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"_source": {
|
||||
"id": "P2",
|
||||
"persons": [
|
||||
{"person_id": 2, "full_name": "Grace Example"},
|
||||
{"person_id": 2, "full_name": "Grace Example"},
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
if kwargs["index"] == ESIndex.DFG_PERSONS:
|
||||
return {"hits": {"hits": []}}
|
||||
return {"aggregations": {"people": {"buckets": []}}}
|
||||
|
||||
with patch(
|
||||
@@ -439,6 +471,12 @@ async def test_top_authors_maps_works_patents_and_news_without_project_queries()
|
||||
{"id": "A1", "name": "Ada Example", "count": 4},
|
||||
]
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.autocomplete_institutions_for_selector",
|
||||
new=AsyncMock(return_value=SimpleNamespace(elements=[SimpleNamespace(id=101)])),
|
||||
), patch(
|
||||
"inse.dashboard.service.get_person_ids_by_institution_ids",
|
||||
new=AsyncMock(return_value=[2]),
|
||||
):
|
||||
result = await get_top_authors(ORG_INSTITUTION_ID, "Example Org")
|
||||
|
||||
@@ -456,6 +494,11 @@ async def test_top_authors_maps_works_patents_and_news_without_project_queries()
|
||||
{"id": None, "name": "Grace Example", "count": 8},
|
||||
{"id": None, "name": "Ada Example", "count": 5},
|
||||
]
|
||||
assert result.projects[0].model_dump() == {
|
||||
"id": "A2",
|
||||
"name": "Grace Example",
|
||||
"count": 2,
|
||||
}
|
||||
assert result.news[0].model_dump() == {
|
||||
"id": "A1",
|
||||
"name": "Ada Example",
|
||||
@@ -464,10 +507,15 @@ async def test_top_authors_maps_works_patents_and_news_without_project_queries()
|
||||
project_calls = [
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"]
|
||||
in {ESIndex.DFG_PROJECTS_V2, ESIndex.PROJECTS_BUND_V1}
|
||||
if call.kwargs["index"] == ESIndex.DFG_PROJECTS
|
||||
]
|
||||
assert project_calls == []
|
||||
assert len(project_calls) == 1
|
||||
assert project_calls[0].kwargs["body"]["query"] == {
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {"terms": {"persons.person_id": [2]}},
|
||||
},
|
||||
}
|
||||
eu_calls = [
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
@@ -505,10 +553,14 @@ async def test_top_authors_returns_partial_response_when_one_source_fails():
|
||||
), patch(
|
||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||
new=AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"inse.dashboard.service.autocomplete_institutions_for_selector",
|
||||
new=AsyncMock(return_value=SimpleNamespace(elements=[])),
|
||||
):
|
||||
result = await get_top_authors(ORG_INSTITUTION_ID, "Example Org")
|
||||
|
||||
assert result.works[0].name == "Ada Example"
|
||||
assert result.projects == []
|
||||
assert result.eu_projects == []
|
||||
assert result.patents == []
|
||||
assert result.news == []
|
||||
@@ -559,6 +611,9 @@ async def test_top_authors_can_rank_works_by_last_five_years():
|
||||
), patch(
|
||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||
new=AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"inse.dashboard.service.autocomplete_institutions_for_selector",
|
||||
new=AsyncMock(return_value=SimpleNamespace(elements=[])),
|
||||
):
|
||||
result = await get_top_authors(
|
||||
ORG_INSTITUTION_ID,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import logging
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Query
|
||||
import inse.institutions.v2.service as institutions_service
|
||||
from fastapi import APIRouter, Path, Query
|
||||
from inse.institutions.v2.model import InstitutionPageV2
|
||||
from inse.models.openalex.institution import Institution
|
||||
from inse.router_prefixes import RouterPrefixes
|
||||
from inse.tags import Tags
|
||||
|
||||
@@ -13,7 +15,32 @@ router = APIRouter(prefix=RouterPrefixes.INSTITUTIONS_V2, tags=[Tags.INSTITUTION
|
||||
|
||||
|
||||
@router.get(
|
||||
"/ids",
|
||||
"/single/{institution_id}",
|
||||
operation_id="getInstitutionById2",
|
||||
summary="Returns an institution based on its ID.",
|
||||
)
|
||||
async def get_institution_by_id(
|
||||
institution_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the institution to retrieve."),
|
||||
],
|
||||
) -> Institution:
|
||||
return await institutions_service.get_institution_by_id_or_raise(
|
||||
raw_oa_institution_id=institution_id,
|
||||
source=[
|
||||
"id",
|
||||
"display_name",
|
||||
"display_name_alternatives",
|
||||
"works_count",
|
||||
"cited_by_count",
|
||||
"geo",
|
||||
"summary_stats",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/multiple/ids",
|
||||
operation_id="getInstitutionsByIds",
|
||||
summary="Returns a list of institutions based on their IDs.",
|
||||
)
|
||||
@@ -23,9 +50,9 @@ async def get_institutions_by_ids(
|
||||
Query(description="A list of institution IDs to retrieve."),
|
||||
] = None,
|
||||
) -> InstitutionPageV2:
|
||||
from inse.institutions.v2.service import get_institutions_by_ids
|
||||
|
||||
return await get_institutions_by_ids(institution_ids=institution_ids or [])
|
||||
return await institutions_service.get_institutions_by_ids(
|
||||
institution_ids=institution_ids or []
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
@@ -41,6 +68,6 @@ async def get_institution_autocomplete(
|
||||
),
|
||||
] = "",
|
||||
) -> InstitutionPageV2:
|
||||
from inse.institutions.v2.service import autocomplete_institutions_for_selector
|
||||
|
||||
return await autocomplete_institutions_for_selector(query=query)
|
||||
return await institutions_service.autocomplete_institutions_for_selector(
|
||||
query=query
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.institutions.v2.model import InstitutionPageV2
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex
|
||||
@@ -8,6 +9,51 @@ from inse.models.openalex.institution import Institution
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def get_institution_by_id(
|
||||
raw_oa_institution_id: str, source: list[str] | None = None
|
||||
) -> Institution | None:
|
||||
"""Retrieves an institution by its ID from the OpenAlex Elasticsearch index.
|
||||
|
||||
Args:
|
||||
raw_oa_institution_id (str): The raw OpenAlex ID of the institution to retrieve.
|
||||
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
|
||||
|
||||
Returns:
|
||||
Institution | None: The institution object if found, otherwise None.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_INSTITUTIONS, doc_id=raw_oa_institution_id, source=source
|
||||
)
|
||||
if not response.get("found"):
|
||||
return None
|
||||
return Institution.from_dict(response.get("_source", {})) # type: ignore
|
||||
|
||||
|
||||
async def get_institution_by_id_or_raise(
|
||||
raw_oa_institution_id: str, source: list[str] | None = None
|
||||
) -> Institution:
|
||||
"""Retrieves an institution by its ID from the OpenAlex Elasticsearch index, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
raw_oa_institution_id (str): The raw OpenAlex ID of the institution to retrieve.
|
||||
source (Optional[List[str]], optional): A list of fields to include in the response. Defaults to None.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the institution is not found.
|
||||
|
||||
Returns:
|
||||
Institution: The institution object if found.
|
||||
"""
|
||||
institution = await get_institution_by_id(
|
||||
raw_oa_institution_id=raw_oa_institution_id, source=source
|
||||
)
|
||||
if institution is None:
|
||||
raise NotFoundException(
|
||||
f"Institution with ID {raw_oa_institution_id} not found."
|
||||
)
|
||||
return institution
|
||||
|
||||
|
||||
async def search_institutions(
|
||||
page: int = 0,
|
||||
size: int = 10,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, Dict, AsyncIterator, List, Optional, Tuple
|
||||
|
||||
import httpx
|
||||
@@ -110,6 +111,10 @@ def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]:
|
||||
return None
|
||||
|
||||
|
||||
def _headers(api_key: str, content_type: str = "application/json") -> Dict[str, str]:
|
||||
return {"Authorization": f"ApiKey {api_key}", "Content-Type": content_type}
|
||||
|
||||
|
||||
def _wrap_exception(e: Exception) -> Exception:
|
||||
logger.exception(f"Elasticsearch raised an exception: {e}")
|
||||
if isinstance(e, httpx.HTTPStatusError):
|
||||
@@ -125,6 +130,63 @@ def _wrap_exception(e: Exception) -> Exception:
|
||||
return ElasticsearchException(f"Unexpected Elasticsearch error: {e}")
|
||||
|
||||
|
||||
async def _request(
|
||||
method: str,
|
||||
cluster: ESCluster,
|
||||
path: str,
|
||||
*,
|
||||
json_body: Optional[Any] = None,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
content: Optional[bytes] = None,
|
||||
content_type: str = "application/json",
|
||||
) -> httpx.Response:
|
||||
"""Sends an authenticated request to cluster and returns the raw response.
|
||||
|
||||
Args:
|
||||
method: The HTTP method (e.g. "GET", "POST", "PUT", "DELETE").
|
||||
cluster: The Elasticsearch cluster to send the request to.
|
||||
path: The path appended to the cluster URL (without leading slash).
|
||||
json_body: Optional JSON-serialisable request body.
|
||||
params: Optional query parameters.
|
||||
content: Optional raw request body (e.g. ndjson); mutually exclusive with json_body.
|
||||
content_type: The Content-Type header value.
|
||||
|
||||
Returns:
|
||||
httpx.Response: The successful response (status already checked).
|
||||
"""
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
client = get_client()
|
||||
|
||||
start = time.perf_counter()
|
||||
try:
|
||||
response = await client.request(
|
||||
method,
|
||||
f"{elasticsearch_url}/{path}",
|
||||
json=json_body,
|
||||
params=params,
|
||||
content=content,
|
||||
headers=_headers(api_key, content_type=content_type),
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
if config.settings.print_es_timings:
|
||||
elapsed_ms = (time.perf_counter() - start) * 1000
|
||||
logger.debug(
|
||||
f"Elasticsearch request {method} {path} on cluster '{cluster}' took {elapsed_ms:.1f} ms"
|
||||
)
|
||||
|
||||
return response
|
||||
except Exception as exc:
|
||||
if config.settings.print_es_timings:
|
||||
elapsed_ms = (time.perf_counter() - start) * 1000
|
||||
logger.debug(
|
||||
f"Elasticsearch request {method} {path} on cluster '{cluster}' failed after {elapsed_ms:.1f} ms"
|
||||
)
|
||||
raise _wrap_exception(exc) from exc
|
||||
|
||||
|
||||
async def search(
|
||||
index: ESIndex | List[ESIndex] | str | List[str],
|
||||
query: Optional[Dict] = None,
|
||||
@@ -175,10 +237,6 @@ async def search(
|
||||
elif len(clusters) == 1:
|
||||
cluster = clusters.pop()
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
payload: Dict[str, Any] = {}
|
||||
|
||||
if body is not None:
|
||||
@@ -210,61 +268,34 @@ async def search(
|
||||
"At least one of 'query', 'body', 'source', 'size', 'offset', 'sort', 'aggs' must be provided"
|
||||
)
|
||||
|
||||
client = get_client()
|
||||
logger.debug(
|
||||
f"Sending search request to Elasticsearch cluster '{cluster}' at {elasticsearch_url} for {index} with payload: {json.dumps(payload)}"
|
||||
)
|
||||
if config.settings.print_es_queries:
|
||||
logger.debug(
|
||||
f"Sending search request to Elasticsearch cluster '{cluster}' for {index} with payload: {json.dumps(payload)}"
|
||||
)
|
||||
|
||||
if isinstance(index, list):
|
||||
index_str = ",".join(str(idx) for idx in index)
|
||||
else:
|
||||
index_str = str(index)
|
||||
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/{index_str}/_search", json=payload, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
response = await _request("POST", cluster, f"{index_str}/_search", json_body=payload)
|
||||
|
||||
return response.json()
|
||||
|
||||
|
||||
async def open_point_in_time(
|
||||
index: str, keep_alive: str = "1m", cluster: str = "nes"
|
||||
) -> str:
|
||||
"""Opens a point-in-time on the given index and returns its id."""
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
response = await _request("POST", cluster, f"{index}/_pit", params={"keep_alive": keep_alive})
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/{index}/_pit",
|
||||
params={"keep_alive": keep_alive},
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()["id"]
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
return response.json()["id"]
|
||||
|
||||
|
||||
async def close_point_in_time(pit_id: str, cluster: str = "nes") -> None:
|
||||
"""Closes a previously opened point-in-time."""
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.request(
|
||||
"DELETE",
|
||||
f"{elasticsearch_url}/_pit",
|
||||
json={"id": pit_id},
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
await _request("DELETE", cluster, "_pit", json_body={"id": pit_id})
|
||||
|
||||
|
||||
async def scan(
|
||||
@@ -280,13 +311,9 @@ async def scan(
|
||||
Unlike ``from``/``size`` pagination, this is not bounded by
|
||||
``index.max_result_window``, so it can stream result sets larger than 10k.
|
||||
"""
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
pit_id = await open_point_in_time(index, keep_alive=keep_alive, cluster=cluster)
|
||||
search_after: Optional[List] = None
|
||||
try:
|
||||
client = get_client()
|
||||
while True:
|
||||
payload: Dict[str, Any] = {
|
||||
"size": page_size,
|
||||
@@ -299,14 +326,7 @@ async def scan(
|
||||
if search_after is not None:
|
||||
payload["search_after"] = search_after
|
||||
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/_search", json=payload, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
|
||||
response = await _request("POST", cluster, "_search", json_body=payload)
|
||||
result = response.json()
|
||||
|
||||
hits = result.get("hits", {}).get("hits", [])
|
||||
@@ -338,23 +358,13 @@ async def get(
|
||||
if isinstance(index, ESIndex):
|
||||
cluster = _index_to_cluster(index) or cluster
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
params = {}
|
||||
if source is not None:
|
||||
params["_source_includes"] = ",".join(source)
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.get(
|
||||
f"{elasticsearch_url}/{index}/_doc/{doc_id}", params=params, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
response = await _request("GET", cluster, f"{index}/_doc/{doc_id}", params=params)
|
||||
|
||||
return response.json()
|
||||
|
||||
|
||||
async def update(
|
||||
@@ -363,20 +373,11 @@ async def update(
|
||||
doc: Dict[str, Any],
|
||||
cluster: ESCluster = ESCluster.NES,
|
||||
) -> Dict[str, Any]:
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
response = await _request(
|
||||
"POST", cluster, f"{index}/_update/{doc_id}", json_body={"doc": doc}
|
||||
)
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/{index}/_update/{doc_id}",
|
||||
json={"doc": doc},
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
return response.json()
|
||||
|
||||
|
||||
async def index_doc(
|
||||
@@ -385,20 +386,11 @@ async def index_doc(
|
||||
document: Dict[str, Any],
|
||||
cluster: ESCluster = ESCluster.NES,
|
||||
) -> Dict[str, Any]:
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
response = await _request(
|
||||
"PUT", cluster, f"{index}/_doc/{doc_id}", json_body=document
|
||||
)
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.put(
|
||||
f"{elasticsearch_url}/{index}/_doc/{doc_id}",
|
||||
json=document,
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
return response.json()
|
||||
|
||||
|
||||
async def count(
|
||||
@@ -431,24 +423,15 @@ async def count(
|
||||
if len(clusters) == 1:
|
||||
cluster = clusters.pop()
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
if isinstance(index, list):
|
||||
index_str = ",".join(str(idx) for idx in index)
|
||||
else:
|
||||
index_str = str(index)
|
||||
|
||||
payload = {"query": query} if query else {}
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/{index_str}/_count", json=payload, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json().get("count", 0)
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
response = await _request("POST", cluster, f"{index_str}/_count", json_body=payload)
|
||||
|
||||
return response.json().get("count", 0)
|
||||
|
||||
|
||||
async def msearch(
|
||||
@@ -473,9 +456,6 @@ async def msearch(
|
||||
if c is not None:
|
||||
cluster = c
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/x-ndjson"}
|
||||
|
||||
lines = []
|
||||
for idx, body in searches:
|
||||
if isinstance(idx, list):
|
||||
@@ -488,16 +468,13 @@ async def msearch(
|
||||
|
||||
ndjson_payload = "\n".join(lines) + "\n"
|
||||
|
||||
client = get_client()
|
||||
try:
|
||||
response = await client.post(
|
||||
f"{elasticsearch_url}/_msearch",
|
||||
content=ndjson_payload.encode("utf-8"),
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
res_json = response.json()
|
||||
return res_json.get("responses", [])
|
||||
except Exception as exc:
|
||||
raise _wrap_exception(exc) from exc
|
||||
response = await _request(
|
||||
"POST",
|
||||
cluster,
|
||||
"_msearch",
|
||||
content=ndjson_payload.encode("utf-8"),
|
||||
content_type="application/x-ndjson",
|
||||
)
|
||||
|
||||
return response.json().get("responses", [])
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class ESIndex(StrEnum):
|
||||
|
||||
AKTUELLES = "aktuell"
|
||||
AKTUELLES_POSTPROC = "aktuell_postproc"
|
||||
AKTUELLES_OPENALEX_TOPICS = "aktuell_openalex_topics"
|
||||
|
||||
|
||||
CORDIS_EU_ORGANIZATIONS_WILDCARD = "cordis_eu_*_organizations"
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from enum import StrEnum
|
||||
|
||||
from inse.model import Page
|
||||
from inse.models.openalex.topic import Topic
|
||||
|
||||
|
||||
class TopicSortBy(StrEnum):
|
||||
DISPLAY_NAME = "display_name"
|
||||
WORKS_COUNT = "works_count"
|
||||
CITED_BY_COUNT = "cited_by_count"
|
||||
|
||||
|
||||
class TopicPageV2(Page[Topic]):
|
||||
pass
|
||||
|
||||
@@ -2,10 +2,12 @@ import logging
|
||||
from typing import Annotated
|
||||
|
||||
import inse.topics.v2.service as topics_service
|
||||
from fastapi import APIRouter, Query
|
||||
from fastapi import APIRouter, Path, Query
|
||||
from inse.model import SortDirection
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.router_prefixes import RouterPrefixes
|
||||
from inse.tags import Tags
|
||||
from inse.topics.v2.model import TopicPageV2
|
||||
from inse.topics.v2.model import TopicPageV2, TopicSortBy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,6 +15,69 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix=RouterPrefixes.TOPICS_V2, tags=[Tags.TOPICS_V2])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/search",
|
||||
operation_id="searchTopics",
|
||||
summary="Searches for topics based on the provided criteria.",
|
||||
)
|
||||
async def search_topics(
|
||||
search_term: Annotated[
|
||||
str | None,
|
||||
Query(description="The term to search for in topic display names."),
|
||||
] = None,
|
||||
page: Annotated[
|
||||
int,
|
||||
Query(
|
||||
description="The page number to retrieve.",
|
||||
ge=0,
|
||||
),
|
||||
] = 0,
|
||||
size: Annotated[
|
||||
int,
|
||||
Query(
|
||||
description="The number of topics to retrieve per page.",
|
||||
ge=1,
|
||||
le=100,
|
||||
),
|
||||
] = 10,
|
||||
sort_by: Annotated[
|
||||
TopicSortBy,
|
||||
Query(
|
||||
description="The field to sort by.",
|
||||
),
|
||||
] = TopicSortBy.WORKS_COUNT,
|
||||
sort_direction: Annotated[
|
||||
SortDirection,
|
||||
Query(
|
||||
description="The direction to sort.",
|
||||
),
|
||||
] = SortDirection.DESCENDING,
|
||||
) -> TopicPageV2:
|
||||
return await topics_service.search_topics(
|
||||
search_term=search_term,
|
||||
page=page,
|
||||
size=size,
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/single/{raw_oa_topic_id}",
|
||||
operation_id="getTopicById",
|
||||
summary="Returns a topic for a given topic ID.",
|
||||
)
|
||||
async def get_topic_by_id(
|
||||
raw_oa_topic_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the topic to retrieve."),
|
||||
],
|
||||
) -> Topic:
|
||||
return await topics_service.get_topic_by_id_or_raise(
|
||||
raw_oa_topic_id=raw_oa_topic_id
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/topics/id",
|
||||
operation_id="getTopicsByIds",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex
|
||||
from inse.model import ESIndex, SortDirection
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.topics.v2.model import TopicPageV2
|
||||
from inse.topics.v2.model import TopicPageV2, TopicSortBy
|
||||
|
||||
|
||||
async def search_topics(
|
||||
async def _search_topics(
|
||||
page: int = 0,
|
||||
size: int = 10,
|
||||
query: dict | None = None,
|
||||
@@ -38,11 +38,60 @@ async def search_topics(
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
hits = hits_block.get("hits", [])
|
||||
total_hits = hits_block.get("total", {}).get("value", 0)
|
||||
topics: list[Topic] = []
|
||||
for hit in hits:
|
||||
_source = hit.get("_source", {})
|
||||
topics.append(Topic.from_dict(_source)) # type: ignore
|
||||
return TopicPageV2(elements=topics, total=len(topics), page=page, size=size)
|
||||
return TopicPageV2(elements=topics, total=total_hits, page=page, size=size)
|
||||
|
||||
|
||||
async def search_topics(
|
||||
search_term: str | None = None,
|
||||
page: int = 0,
|
||||
size: int = 10,
|
||||
sort_by: TopicSortBy = TopicSortBy.WORKS_COUNT,
|
||||
sort_direction: SortDirection = SortDirection.DESCENDING,
|
||||
) -> TopicPageV2:
|
||||
"""Searches for topics based on a search term.
|
||||
|
||||
Args:
|
||||
search_term (str | None): The term to search for in topic display names. Defaults to None.
|
||||
page (int, optional): The page number to retrieve. Defaults to 0.
|
||||
size (int, optional): The number of topics to retrieve per page. Defaults to 10.
|
||||
sort_by (TopicSortBy, optional): The field to sort by. Defaults to TopicSortBy.WORKS_COUNT.
|
||||
sort_direction (SortDirection, optional): The direction to sort. Defaults to SortDirection.DESCENDING.
|
||||
|
||||
Returns:
|
||||
TopicPageV2: A page of topics matching the search term.
|
||||
"""
|
||||
|
||||
sort = None
|
||||
if sort_by in [TopicSortBy.DISPLAY_NAME]:
|
||||
sort = [{f"{sort_by.value}.keyword": {"order": sort_direction.value}}]
|
||||
else:
|
||||
sort = [{sort_by.value: {"order": sort_direction.value}}]
|
||||
|
||||
query = None
|
||||
if search_term:
|
||||
query = {"match_phrase_prefix": {"display_name": search_term}}
|
||||
|
||||
return await _search_topics(
|
||||
page=page,
|
||||
size=size,
|
||||
query=query,
|
||||
source=[
|
||||
"id",
|
||||
"display_name",
|
||||
"description",
|
||||
"subfield",
|
||||
"field",
|
||||
"domain",
|
||||
"works_count",
|
||||
"cited_by_count",
|
||||
],
|
||||
sort=sort,
|
||||
)
|
||||
|
||||
|
||||
async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
|
||||
@@ -54,7 +103,7 @@ async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
|
||||
Returns:
|
||||
TopicPageV2: A page of topics matching the autocomplete criteria.
|
||||
"""
|
||||
return await search_topics(
|
||||
return await _search_topics(
|
||||
page=0,
|
||||
size=10,
|
||||
query={"match_phrase_prefix": {"display_name": query}},
|
||||
@@ -68,6 +117,53 @@ async def autocomplete_topics_for_selector(query: str) -> TopicPageV2:
|
||||
)
|
||||
|
||||
|
||||
async def get_topic_by_id(raw_oa_topic_id: str) -> Topic | None:
|
||||
"""Retrieves a topic based on its ID.
|
||||
|
||||
Args:
|
||||
raw_oa_topic_id (str): The ID of the topic to retrieve.
|
||||
|
||||
Returns:
|
||||
Topic | None: The topic matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_TOPICS,
|
||||
doc_id=raw_oa_topic_id,
|
||||
source=[
|
||||
"id",
|
||||
"display_name",
|
||||
"description",
|
||||
"subfield",
|
||||
"field",
|
||||
"domain",
|
||||
"works_count",
|
||||
"cited_by_count",
|
||||
],
|
||||
)
|
||||
if response.get("found"):
|
||||
_source = response.get("_source", {})
|
||||
return Topic.from_dict(_source) # type: ignore
|
||||
return None
|
||||
|
||||
|
||||
async def get_topic_by_id_or_raise(raw_oa_topic_id: str) -> Topic:
|
||||
"""Retrieves a topic based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
raw_oa_topic_id (str): The ID of the topic to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the topic with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
Topic: The topic matching the provided ID.
|
||||
"""
|
||||
topic = await get_topic_by_id(raw_oa_topic_id)
|
||||
if topic is None:
|
||||
raise NotFoundException(f"Topic with ID {raw_oa_topic_id} not found.")
|
||||
return topic
|
||||
|
||||
|
||||
async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
|
||||
"""Retrieves topics based on a list of topic IDs.
|
||||
|
||||
@@ -80,7 +176,7 @@ async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
|
||||
if not topic_ids:
|
||||
return TopicPageV2(elements=[], total=0, page=0, size=0)
|
||||
|
||||
return await search_topics(
|
||||
return await _search_topics(
|
||||
page=0,
|
||||
size=len(topic_ids),
|
||||
query={"terms": {"id": topic_ids}},
|
||||
|
||||
@@ -170,6 +170,19 @@ async def test_get_top_topics_for_entity_projects():
|
||||
assert "items" in res
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_get_top_topics_for_entity_news():
|
||||
res = await get_top_topics_for_entity(
|
||||
entity_id="UDE",
|
||||
entity_type="institution",
|
||||
start_year=2018,
|
||||
end_year=2024,
|
||||
search_type="news",
|
||||
)
|
||||
assert isinstance(res, dict)
|
||||
assert "items" in res
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_get_trend_data_delegation():
|
||||
res = await get_trend_data(
|
||||
|
||||
@@ -456,31 +456,99 @@ async def get_top_topics_for_entity(
|
||||
|
||||
if search_type == "news":
|
||||
try:
|
||||
res = await elasticsearch.search(
|
||||
index=ESIndex.AKTUELLES_POSTPROC.value,
|
||||
body={
|
||||
"query": {"match_all": {}},
|
||||
"size": 0,
|
||||
"_source": False,
|
||||
"aggs": {
|
||||
"top_topics": {
|
||||
"terms": {
|
||||
"field": "topics.display_name.keyword",
|
||||
"size": DEFAULT_TOP_TOPICS_SIZE,
|
||||
date_filter = TrendQueryBuilder.build_date_range_filter("date_year", start_year, end_year)
|
||||
news_ids = []
|
||||
try:
|
||||
async for hit in elasticsearch.scan(
|
||||
index=ESIndex.AKTUELLES.value,
|
||||
query={"bool": {"filter": [date_filter]}},
|
||||
source=["news_id"],
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
nid = hit.get("_id") or hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.append(str(nid))
|
||||
except Exception as e:
|
||||
logger.warning("Failed scanning aktuell for news IDs in date range: %s", e)
|
||||
|
||||
topic_counts: Dict[str, int] = {}
|
||||
if news_ids:
|
||||
msearch_queries = []
|
||||
for i in range(0, len(news_ids), 2000):
|
||||
chunk = news_ids[i : i + 2000]
|
||||
payload = {
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"ids": {"values": chunk}},
|
||||
{"terms": {"news_id.keyword": chunk}},
|
||||
{"terms": {"news_id": chunk}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
buckets = res.get("aggregations", {}).get("top_topics", {}).get("buckets", [])
|
||||
items = [{"name": b["key"], "count": b["doc_count"]} for b in buckets]
|
||||
total_hits = res.get("hits", {}).get("total", {})
|
||||
total_val = total_hits.get("value", 0) if isinstance(total_hits, dict) else int(total_hits or 0)
|
||||
sum_top = sum(b["count"] for b in items)
|
||||
other_count = max(0, total_val - sum_top)
|
||||
},
|
||||
"size": 0,
|
||||
"_source": False,
|
||||
"aggs": {
|
||||
"top_topics": {
|
||||
"terms": {
|
||||
"field": "topic_matches.topic_display_name.keyword",
|
||||
"size": 100,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
msearch_queries.append((ESIndex.AKTUELLES_OPENALEX_TOPICS.value, payload))
|
||||
|
||||
if msearch_queries:
|
||||
try:
|
||||
responses = await elasticsearch.msearch(msearch_queries, cluster=ESCluster.INSE)
|
||||
for res in responses:
|
||||
buckets = res.get("aggregations", {}).get("top_topics", {}).get("buckets", [])
|
||||
for b in buckets:
|
||||
t_name = b["key"]
|
||||
cnt = b["doc_count"]
|
||||
topic_counts[t_name] = topic_counts.get(t_name, 0) + cnt
|
||||
except Exception as e:
|
||||
logger.warning("Failed to aggregate news top topics via msearch: %s", e)
|
||||
else:
|
||||
# If no year filter bounds active or scan returned no IDs, aggregate all topics directly from openalex_topics
|
||||
try:
|
||||
res = await elasticsearch.search(
|
||||
index=ESIndex.AKTUELLES_OPENALEX_TOPICS.value,
|
||||
body={
|
||||
"query": {"match_all": {}},
|
||||
"size": 0,
|
||||
"_source": False,
|
||||
"aggs": {
|
||||
"top_topics": {
|
||||
"terms": {
|
||||
"field": "topic_matches.topic_display_name.keyword",
|
||||
"size": 100,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
buckets = res.get("aggregations", {}).get("top_topics", {}).get("buckets", [])
|
||||
for b in buckets:
|
||||
t_name = b["key"]
|
||||
cnt = b["doc_count"]
|
||||
topic_counts[t_name] = topic_counts.get(t_name, 0) + cnt
|
||||
except Exception as e:
|
||||
logger.warning("Failed to fallback query news top topics: %s", e)
|
||||
|
||||
sorted_topics = sorted(topic_counts.items(), key=lambda x: x[1], reverse=True)
|
||||
top_slice = sorted_topics[:DEFAULT_TOP_TOPICS_SIZE]
|
||||
items = [{"name": name, "count": count} for name, count in top_slice]
|
||||
|
||||
sum_top = sum(count for name, count in top_slice)
|
||||
total_topics = sum(topic_counts.values())
|
||||
other_count = max(0, total_topics - sum_top)
|
||||
if other_count > 0:
|
||||
items.append({"name": "Andere Themen", "count": other_count})
|
||||
|
||||
return {"items": items}
|
||||
except Exception as e:
|
||||
logger.error("Failed to query top news topics for entity: %s", e)
|
||||
|
||||
@@ -1066,11 +1066,24 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
|
||||
STOP_WORDS = {"in", "and", "or", "und", "oder", "der", "die", "das", "von", "mit", "zu", "at", "by", "on", "for", "to", "a", "an", "the"}
|
||||
|
||||
# Scan UDE news postprocessed index to get matching news IDs without size limit cutoffs
|
||||
# Scan UDE news OpenAlex topics index to get matching news IDs without size limit cutoffs
|
||||
async def fetch_news_ids_for_term(idx: int, t_name: str) -> List[str]:
|
||||
news_ids: Set[str] = set()
|
||||
if fuzzy:
|
||||
term = t_name
|
||||
es_query = {"match": {"topics.display_name": term}}
|
||||
es_query = {"term": {"topic_matches.topic_display_name.keyword": term}}
|
||||
try:
|
||||
async for hit in elasticsearch.scan(
|
||||
index=ESIndex.AKTUELLES_OPENALEX_TOPICS.value,
|
||||
query=es_query,
|
||||
source=["news_id"],
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
nid = hit.get("_source", {}).get("news_id") or hit.get("_id")
|
||||
if nid:
|
||||
news_ids.add(str(nid))
|
||||
except Exception as e:
|
||||
logger.warning("Failed to scan UDE news OpenAlex topics index %s: %s", ESIndex.AKTUELLES_OPENALEX_TOPICS.value, e)
|
||||
else:
|
||||
if keywords and idx < len(keywords) and keywords[idx]:
|
||||
raw_kw = keywords[idx]
|
||||
@@ -1079,43 +1092,28 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
term = t_name
|
||||
else:
|
||||
term = t_name
|
||||
es_query = {"match": {"keywords": term}}
|
||||
|
||||
news_ids: Set[str] = set()
|
||||
try:
|
||||
async for hit in elasticsearch.scan(
|
||||
index=ESIndex.AKTUELLES_POSTPROC.value,
|
||||
query=es_query,
|
||||
source=["news_id"],
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
nid = hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.add(nid)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to scan UDE news postproc: %s", e)
|
||||
|
||||
# If non-fuzzy keyword search, also search article content fields in 'aktuell' index
|
||||
if not fuzzy and term and term.lower() not in STOP_WORDS and len(term.strip()) > 1:
|
||||
try:
|
||||
content_query = {
|
||||
"query_string": {
|
||||
"query": term,
|
||||
"fields": AKTUELLES_SEARCH_FIELDS,
|
||||
"default_operator": "AND",
|
||||
# If non-fuzzy keyword search, search article content fields in 'aktuell' index
|
||||
if term and term.lower() not in STOP_WORDS and len(term.strip()) > 1:
|
||||
try:
|
||||
content_query = {
|
||||
"query_string": {
|
||||
"query": term,
|
||||
"fields": AKTUELLES_SEARCH_FIELDS,
|
||||
"default_operator": "AND",
|
||||
}
|
||||
}
|
||||
}
|
||||
async for hit in elasticsearch.scan(
|
||||
index=ESIndex.AKTUELLES.value,
|
||||
query=content_query,
|
||||
source=["news_id"],
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
nid = hit.get("_id") or hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.add(nid)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to scan UDE news content in aktuell: %s", e)
|
||||
async for hit in elasticsearch.scan(
|
||||
index=ESIndex.AKTUELLES.value,
|
||||
query=content_query,
|
||||
source=["news_id"],
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
nid = hit.get("_id") or hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.add(str(nid))
|
||||
except Exception as e:
|
||||
logger.warning("Failed to scan UDE news content in aktuell: %s", e)
|
||||
|
||||
return list(news_ids)
|
||||
|
||||
@@ -1134,7 +1132,16 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"ids": {"values": chunk}},
|
||||
{
|
||||
"bool": {
|
||||
"should": [
|
||||
{"ids": {"values": chunk}},
|
||||
{"terms": {"news_id.keyword": chunk}},
|
||||
{"terms": {"news_id": chunk}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
TrendQueryBuilder.build_date_range_filter("date_year", start_year, end_year),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -22,6 +22,68 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix=RouterPrefixes.WORKS_V2, tags=[Tags.WORKS_V2])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/search",
|
||||
operation_id="searchWorks",
|
||||
summary="Search works with filters.",
|
||||
)
|
||||
async def search_works(
|
||||
page: Annotated[
|
||||
int, Query(description="The page number to retrieve. (0-based)", ge=0)
|
||||
] = 0,
|
||||
size: Annotated[
|
||||
int,
|
||||
Query(description="The number of works to retrieve per page.", ge=1, le=100),
|
||||
] = 10,
|
||||
title: Annotated[
|
||||
str, Query(description="A title to filter by (partial matches allowed).")
|
||||
] = "",
|
||||
publication_years: Annotated[
|
||||
list[int] | None,
|
||||
Query(description="A list of publication years to filter by."),
|
||||
] = None,
|
||||
publication_types: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of publication types to filter by."),
|
||||
] = None,
|
||||
author_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of author IDs to filter by."),
|
||||
] = None,
|
||||
institution_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of institution IDs to filter by."),
|
||||
] = None,
|
||||
topic_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of topic IDs to filter by."),
|
||||
] = None,
|
||||
language_codes: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of language codes to filter by."),
|
||||
] = None,
|
||||
sort_by: Annotated[
|
||||
WorkSortBy, Query(description="The field to sort by.")
|
||||
] = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: Annotated[
|
||||
SortDirection, Query(description="The order to sort by.")
|
||||
] = SortDirection.DESCENDING,
|
||||
) -> WorkPageV2:
|
||||
return await works_service.search_works(
|
||||
page=page,
|
||||
size=size,
|
||||
title=title,
|
||||
publication_years=publication_years or [],
|
||||
publication_types=publication_types or [],
|
||||
author_ids=author_ids or [],
|
||||
institution_ids=institution_ids or [],
|
||||
topic_ids=topic_ids or [],
|
||||
language_codes=language_codes or [],
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/author/{raw_oa_author_id}",
|
||||
operation_id="getAuthorWorkPage",
|
||||
@@ -218,6 +280,65 @@ async def get_institution_works(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/topic/{raw_oa_topic_id}",
|
||||
operation_id="getTopicWorkPage",
|
||||
summary="Returns a paginated list of works for a given topic based on its ID.",
|
||||
)
|
||||
async def get_topic_works(
|
||||
raw_oa_topic_id: Annotated[str, Path(description="The raw OpenAlex topic id.")],
|
||||
page: Annotated[
|
||||
int, Query(description="The page number to retrieve. (0-based)", ge=0)
|
||||
] = 0,
|
||||
size: Annotated[
|
||||
int,
|
||||
Query(description="The number of works to retrieve per page.", ge=1, le=100),
|
||||
] = 10,
|
||||
title: Annotated[
|
||||
str, Query(description="A title to filter by (partial matches allowed).")
|
||||
] = "",
|
||||
publication_years: Annotated[
|
||||
list[int] | None,
|
||||
Query(description="A list of publication years to filter by."),
|
||||
] = None,
|
||||
publication_types: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of publication types to filter by."),
|
||||
] = None,
|
||||
author_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of author IDs to filter by."),
|
||||
] = None,
|
||||
institution_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of institution IDs to filter by."),
|
||||
] = None,
|
||||
language_codes: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="A list of language codes to filter by."),
|
||||
] = None,
|
||||
sort_by: Annotated[
|
||||
WorkSortBy, Query(description="The field to sort by.")
|
||||
] = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: Annotated[
|
||||
SortDirection, Query(description="The order to sort by.")
|
||||
] = SortDirection.DESCENDING,
|
||||
) -> WorkPageV2:
|
||||
return await works_service.get_topic_works(
|
||||
raw_oa_topic_id=raw_oa_topic_id,
|
||||
page=page,
|
||||
size=size,
|
||||
title=title,
|
||||
publication_years=publication_years or [],
|
||||
publication_types=publication_types or [],
|
||||
author_ids=author_ids or [],
|
||||
institution_ids=institution_ids or [],
|
||||
language_codes=language_codes or [],
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/classification/work/{raw_oa_work_id}",
|
||||
operation_id="getWorkClassificationByWorkId",
|
||||
|
||||
@@ -60,6 +60,19 @@ def _institutions_nested_query(institution_ids: list[str]) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _topics_nested_query(topic_ids: list[str]) -> dict:
|
||||
"""Returns a nested query for filtering works by a list of topic IDs.
|
||||
|
||||
Args:
|
||||
topic_ids (list[str]): A list of topic IDs to filter by.
|
||||
|
||||
Returns:
|
||||
dict: A nested query for filtering works by the specified topic IDs.
|
||||
"""
|
||||
prefixed = [_prefix_id(tid) for tid in topic_ids]
|
||||
return {"nested": {"path": "topics", "query": {"terms": {"topics.id": prefixed}}}}
|
||||
|
||||
|
||||
def _title_query(title: str) -> dict:
|
||||
"""Returns a query for filtering works by title using a multi-match query.
|
||||
|
||||
@@ -87,7 +100,6 @@ def _apply_common_filters(
|
||||
publication_years: list[int] | None,
|
||||
publication_types: list[str] | None,
|
||||
language_codes: list[str] | None,
|
||||
topic_ids: list[str] | None,
|
||||
title: str | None = None,
|
||||
) -> None:
|
||||
"""Applies common filters to the provided list of must conditions for filtering works.
|
||||
@@ -106,10 +118,6 @@ def _apply_common_filters(
|
||||
must.append({"terms": {"type": publication_types}})
|
||||
if language_codes:
|
||||
must.append({"terms": {"language": language_codes}})
|
||||
if topic_ids:
|
||||
must.append(
|
||||
{"nested": {"path": "topics", "query": {"terms": {"topics.id": topic_ids}}}}
|
||||
)
|
||||
if title and len(title.strip()) > 0:
|
||||
must.append(_title_query(title))
|
||||
|
||||
@@ -148,7 +156,7 @@ async def _execute_works_search(
|
||||
Returns:
|
||||
WorkPageV2: The page of works matching the search criteria.
|
||||
"""
|
||||
return await search_works(
|
||||
return await _search_works(
|
||||
source=[
|
||||
"id",
|
||||
"title",
|
||||
@@ -172,8 +180,6 @@ async def _execute_works_search(
|
||||
async def get_works(
|
||||
page: int,
|
||||
size: int,
|
||||
raw_oa_author_id: str | None = None,
|
||||
raw_oa_institution_id: str | None = None,
|
||||
title: str | None = None,
|
||||
author_ids: list[str] | None = None,
|
||||
institution_ids: list[str] | None = None,
|
||||
@@ -189,8 +195,6 @@ async def get_works(
|
||||
Args:
|
||||
page (int): The page number for pagination.
|
||||
size (int): The number of results per page.
|
||||
raw_oa_author_id (Optional[str], optional): The ID of the author to filter by. Defaults to None.
|
||||
raw_oa_institution_id (Optional[str], optional): The ID of the institution to filter by. Defaults to None.
|
||||
title (Optional[str], optional): The title of the works to filter by. Defaults to None.
|
||||
author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None.
|
||||
institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None.
|
||||
@@ -201,34 +205,31 @@ async def get_works(
|
||||
sort_by (WorkSortBy, optional): The field to sort by. Defaults to WorkSortBy.PUBLICATION_YEAR.
|
||||
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
|
||||
|
||||
Raises:
|
||||
ValueError: If neither raw_oa_author_id nor raw_oa_institution_id is provided.
|
||||
|
||||
Returns:
|
||||
WorkPageV2: The page of works matching the criteria.
|
||||
"""
|
||||
if not raw_oa_author_id and not raw_oa_institution_id:
|
||||
raise ValueError(
|
||||
"get_works requires at least one of raw_oa_author_id or raw_oa_institution_id"
|
||||
)
|
||||
|
||||
must: list = []
|
||||
|
||||
if raw_oa_author_id:
|
||||
must.append(_authors_nested_query([raw_oa_author_id]))
|
||||
elif author_ids:
|
||||
must.append(_authors_nested_query(author_ids))
|
||||
if author_ids:
|
||||
must.append(_authors_nested_query(author_ids=author_ids))
|
||||
|
||||
if raw_oa_institution_id:
|
||||
must.append(_institutions_nested_query([raw_oa_institution_id]))
|
||||
elif institution_ids:
|
||||
must.append(_institutions_nested_query(institution_ids))
|
||||
if institution_ids:
|
||||
must.append(_institutions_nested_query(institution_ids=institution_ids))
|
||||
|
||||
if topic_ids:
|
||||
must.append(_topics_nested_query(topic_ids=topic_ids))
|
||||
|
||||
_apply_common_filters(
|
||||
must, publication_years, publication_types, language_codes, topic_ids, title
|
||||
must=must,
|
||||
publication_years=publication_years,
|
||||
publication_types=publication_types,
|
||||
language_codes=language_codes,
|
||||
title=title,
|
||||
)
|
||||
|
||||
return await _execute_works_search(must, page, size, sort_by, sort_order)
|
||||
return await _execute_works_search(
|
||||
must=must, page=page, size=size, sort_by=sort_by, sort_order=sort_order
|
||||
)
|
||||
|
||||
|
||||
async def get_works_by_keywords(
|
||||
@@ -427,7 +428,7 @@ async def get_author_works(
|
||||
return await get_works(
|
||||
page=page,
|
||||
size=size,
|
||||
raw_oa_author_id=raw_oa_author_id,
|
||||
author_ids=[raw_oa_author_id],
|
||||
title=title,
|
||||
institution_ids=institution_ids,
|
||||
publication_years=publication_years,
|
||||
@@ -474,7 +475,7 @@ async def get_institution_works(
|
||||
return await get_works(
|
||||
page=page,
|
||||
size=size,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
institution_ids=[raw_oa_institution_id],
|
||||
author_ids=author_ids,
|
||||
title=title,
|
||||
publication_years=publication_years,
|
||||
@@ -486,6 +487,100 @@ async def get_institution_works(
|
||||
)
|
||||
|
||||
|
||||
async def get_topic_works(
|
||||
raw_oa_topic_id: str,
|
||||
page: int,
|
||||
size: int,
|
||||
title: str = "",
|
||||
publication_years: list[int] | None = None,
|
||||
publication_types: list[str] | None = None,
|
||||
institution_ids: list[str] | None = None,
|
||||
author_ids: list[str] | None = None,
|
||||
language_codes: list[str] | None = None,
|
||||
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: SortDirection = SortDirection.DESCENDING,
|
||||
) -> WorkPageV2:
|
||||
"""Retrieves works for a specific topic based on the provided criteria.
|
||||
|
||||
Args:
|
||||
raw_oa_topic_id (str): The ID of the topic for whom to retrieve works.
|
||||
page (int): The page number of the results to retrieve.
|
||||
size (int): The number of results per page.
|
||||
title (str, optional): The title of the works to filter by. Defaults to "".
|
||||
publication_years (Optional[List[int]], optional): A list of publication years to filter by. Defaults to None.
|
||||
publication_types (Optional[List[str]], optional): A list of publication types to filter by. Defaults to None.
|
||||
institution_ids (Optional[List[str]], optional): A list of institution IDs to filter by. Defaults to None.
|
||||
author_ids (Optional[List[str]], optional): A list of author IDs to filter by. Defaults to None.
|
||||
language_codes (Optional[List[str]], optional): A list of language codes to filter by. Defaults to None.
|
||||
sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR.
|
||||
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
|
||||
|
||||
Returns:
|
||||
WorkPageV2: The page of works matching the criteria.
|
||||
"""
|
||||
|
||||
return await get_works(
|
||||
page=page,
|
||||
size=size,
|
||||
topic_ids=[raw_oa_topic_id],
|
||||
title=title,
|
||||
institution_ids=institution_ids,
|
||||
author_ids=author_ids,
|
||||
publication_years=publication_years,
|
||||
publication_types=publication_types,
|
||||
language_codes=language_codes,
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
|
||||
async def search_works(
|
||||
page: int,
|
||||
size: int,
|
||||
title: str | None = None,
|
||||
author_ids: list[str] | None = None,
|
||||
institution_ids: list[str] | None = None,
|
||||
publication_years: list[int] | None = None,
|
||||
publication_types: list[str] | None = None,
|
||||
topic_ids: list[str] | None = None,
|
||||
language_codes: list[str] | None = None,
|
||||
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: SortDirection = SortDirection.DESCENDING,
|
||||
) -> WorkPageV2:
|
||||
"""Searches for works based on the provided criteria.
|
||||
|
||||
Args:
|
||||
page (int): The page number of the results to retrieve.
|
||||
size (int): The number of results per page.
|
||||
title (str | None, optional): The title of the works to filter by. Defaults to None.
|
||||
author_ids (list[str] | None, optional): A list of author IDs to filter by. Defaults to None.
|
||||
institution_ids (list[str] | None, optional): A list of institution IDs to filter by. Defaults to None.
|
||||
publication_years (list[int] | None, optional): A list of publication years to filter by. Defaults to None.
|
||||
publication_types (list[str] | None, optional): A list of publication types to filter by. Defaults to None.
|
||||
topic_ids (list[str] | None, optional): A list of topic IDs to filter by. Defaults to None.
|
||||
language_codes (list[str] | None, optional): A list of language codes to filter by. Defaults to None.
|
||||
sort_by (WorkSortBy, optional): The field by which to sort the results. Defaults to WorkSortBy.PUBLICATION_YEAR.
|
||||
sort_order (SortDirection, optional): The direction to sort in. Defaults to SortDirection.DESCENDING.
|
||||
|
||||
Returns:
|
||||
WorkPageV2: The page of works matching the criteria.
|
||||
"""
|
||||
|
||||
return await get_works(
|
||||
page=page,
|
||||
size=size,
|
||||
title=title,
|
||||
author_ids=author_ids,
|
||||
institution_ids=institution_ids,
|
||||
publication_years=publication_years,
|
||||
publication_types=publication_types,
|
||||
topic_ids=topic_ids,
|
||||
language_codes=language_codes,
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
|
||||
async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work | None:
|
||||
"""Retrieves a work based on its OpenAlex ID.
|
||||
|
||||
@@ -498,7 +593,7 @@ async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work
|
||||
"""
|
||||
|
||||
# search instead of get, because multiple indices are used for works
|
||||
work_page = await search_works(
|
||||
work_page = await _search_works(
|
||||
query={"term": {"id": _prefix_id(raw_oa_work_id)}},
|
||||
source=source,
|
||||
page=0,
|
||||
@@ -510,7 +605,7 @@ async def get_work(raw_oa_work_id: str, source: list[str] | None = None) -> Work
|
||||
return None
|
||||
|
||||
|
||||
async def search_works(
|
||||
async def _search_works(
|
||||
query: dict | None = None,
|
||||
source: list[str] | None = None,
|
||||
page: int = 0,
|
||||
@@ -568,7 +663,7 @@ async def _get_works_by_work_ids_and_institution_id(
|
||||
prefixed_work_ids = [_prefix_id(wid) for wid in work_ids]
|
||||
prefixed_institution_id = _prefix_id(raw_oa_institution_id)
|
||||
|
||||
return await search_works(
|
||||
return await _search_works(
|
||||
query={
|
||||
"bool": {
|
||||
"must": [
|
||||
|
||||
@@ -249,6 +249,7 @@ model/topicHeatmapTopic.ts
|
||||
model/topicHeatmapValue.ts
|
||||
model/topicIds.ts
|
||||
model/topicPageV2.ts
|
||||
model/topicSortBy.ts
|
||||
model/topicSubfield.ts
|
||||
model/topicWordCloud.ts
|
||||
model/topicWordCloudWord.ts
|
||||
|
||||
@@ -16,6 +16,8 @@ import { HttpClient, HttpHeaders, HttpParams,
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { Author } from '../model/author';
|
||||
// @ts-ignore
|
||||
import { AuthorPage } from '../model/authorPage';
|
||||
// @ts-ignore
|
||||
@@ -98,6 +100,61 @@ export class AuthorsV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an author for a given author ID.
|
||||
* @endpoint get /api/authors/v2/{raw_oa_author_id}
|
||||
* @param rawOaAuthorId The ID of the author to retrieve.
|
||||
* @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 getAuthorById(rawOaAuthorId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Author>;
|
||||
public getAuthorById(rawOaAuthorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Author>>;
|
||||
public getAuthorById(rawOaAuthorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Author>>;
|
||||
public getAuthorById(rawOaAuthorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
|
||||
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorById.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/authors/v2/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<Author>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a paginated list of authors for a given list of author IDs.
|
||||
* @endpoint get /api/authors/v2/authors/id
|
||||
|
||||
@@ -19,6 +19,8 @@ import { Observable } from 'rxjs';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { Institution } from '../model/institution';
|
||||
// @ts-ignore
|
||||
import { InstitutionPageV2 } from '../model/institutionPageV2';
|
||||
|
||||
// @ts-ignore
|
||||
@@ -94,9 +96,64 @@ export class InstitutionsV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an institution based on its ID.
|
||||
* @endpoint get /api/institutions/v2/single/{institution_id}
|
||||
* @param institutionId The ID of the institution to retrieve.
|
||||
* @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 getInstitutionById2(institutionId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Institution>;
|
||||
public getInstitutionById2(institutionId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Institution>>;
|
||||
public getInstitutionById2(institutionId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Institution>>;
|
||||
public getInstitutionById2(institutionId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (institutionId === null || institutionId === undefined) {
|
||||
throw new Error('Required parameter institutionId was null or undefined when calling getInstitutionById2.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/institutions/v2/single/${this.configuration.encodeParam({name: "institutionId", value: institutionId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<Institution>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of institutions based on their IDs.
|
||||
* @endpoint get /api/institutions/v2/ids
|
||||
* @endpoint get /api/institutions/v2/multiple/ids
|
||||
* @param institutionIds A list of institution IDs to retrieve.
|
||||
* @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.
|
||||
@@ -139,7 +196,7 @@ export class InstitutionsV2Service extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/institutions/v2/ids`;
|
||||
let localVarPath = `/api/institutions/v2/multiple/ids`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<InstitutionPageV2>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
|
||||
@@ -19,7 +19,13 @@ import { Observable } from 'rxjs';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { SortDirection } from '../model/sortDirection';
|
||||
// @ts-ignore
|
||||
import { Topic } from '../model/topic';
|
||||
// @ts-ignore
|
||||
import { TopicPageV2 } from '../model/topicPageV2';
|
||||
// @ts-ignore
|
||||
import { TopicSortBy } from '../model/topicSortBy';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
@@ -94,6 +100,61 @@ export class TopicsV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a topic for a given topic ID.
|
||||
* @endpoint get /api/topics/v2/single/{raw_oa_topic_id}
|
||||
* @param rawOaTopicId The ID of the topic to retrieve.
|
||||
* @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 getTopicById(rawOaTopicId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Topic>;
|
||||
public getTopicById(rawOaTopicId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Topic>>;
|
||||
public getTopicById(rawOaTopicId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Topic>>;
|
||||
public getTopicById(rawOaTopicId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaTopicId === null || rawOaTopicId === undefined) {
|
||||
throw new Error('Required parameter rawOaTopicId was null or undefined when calling getTopicById.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/topics/v2/single/${this.configuration.encodeParam({name: "rawOaTopicId", value: rawOaTopicId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<Topic>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a paginated list of topics for a given list of topic IDs.
|
||||
* @endpoint get /api/topics/v2/topics/id
|
||||
@@ -155,4 +216,73 @@ export class TopicsV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for topics based on the provided criteria.
|
||||
* @endpoint get /api/topics/v2/search
|
||||
* @param searchTerm The term to search for in topic display names.
|
||||
* @param page The page number to retrieve.
|
||||
* @param size The number of topics to retrieve per page.
|
||||
* @param sortBy The field to sort by.
|
||||
* @param sortDirection The direction to sort.
|
||||
* @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 searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TopicPageV2>;
|
||||
public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TopicPageV2>>;
|
||||
public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TopicPageV2>>;
|
||||
public searchTopics(searchTerm?: string, page?: number, size?: number, sortBy?: TopicSortBy, sortDirection?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>searchTerm, 'search_term');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortBy, 'sort_by');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortDirection, 'sort_direction');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/topics/v2/search`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<TopicPageV2>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -399,6 +399,114 @@ export class WorksV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a paginated list of works for a given topic based on its ID.
|
||||
* @endpoint get /api/works/v2/topic/{raw_oa_topic_id}
|
||||
* @param rawOaTopicId The raw OpenAlex topic id.
|
||||
* @param page The page number to retrieve. (0-based)
|
||||
* @param size The number of works to retrieve per page.
|
||||
* @param title A title to filter by (partial matches allowed).
|
||||
* @param publicationYears A list of publication years to filter by.
|
||||
* @param publicationTypes A list of publication types to filter by.
|
||||
* @param authorIds A list of author IDs to filter by.
|
||||
* @param institutionIds A list of institution IDs to filter by.
|
||||
* @param languageCodes A list of language codes to filter by.
|
||||
* @param sortBy The field to sort by.
|
||||
* @param sortOrder The order to sort by.
|
||||
* @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 getTopicWorkPage(rawOaTopicId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPageV2>;
|
||||
public getTopicWorkPage(rawOaTopicId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPageV2>>;
|
||||
public getTopicWorkPage(rawOaTopicId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPageV2>>;
|
||||
public getTopicWorkPage(rawOaTopicId: string, page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaTopicId === null || rawOaTopicId === undefined) {
|
||||
throw new Error('Required parameter rawOaTopicId was null or undefined when calling getTopicWorkPage.');
|
||||
}
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>title, 'title');
|
||||
if (publicationYears) {
|
||||
publicationYears.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_years');
|
||||
})
|
||||
}
|
||||
if (publicationTypes) {
|
||||
publicationTypes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_types');
|
||||
})
|
||||
}
|
||||
if (authorIds) {
|
||||
authorIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'author_ids');
|
||||
})
|
||||
}
|
||||
if (institutionIds) {
|
||||
institutionIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'institution_ids');
|
||||
})
|
||||
}
|
||||
if (languageCodes) {
|
||||
languageCodes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'language_codes');
|
||||
})
|
||||
}
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortBy, 'sort_by');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortOrder, 'sort_order');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/v2/topic/${this.configuration.encodeParam({name: "rawOaTopicId", value: rawOaTopicId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkPageV2>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classifications of a work based on its ID.
|
||||
* @endpoint get /api/works/v2/classification/work/{raw_oa_work_id}
|
||||
@@ -670,4 +778,115 @@ export class WorksV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search works with filters.
|
||||
* @endpoint get /api/works/v2/search
|
||||
* @param page The page number to retrieve. (0-based)
|
||||
* @param size The number of works to retrieve per page.
|
||||
* @param title A title to filter by (partial matches allowed).
|
||||
* @param publicationYears A list of publication years to filter by.
|
||||
* @param publicationTypes A list of publication types to filter by.
|
||||
* @param authorIds A list of author IDs to filter by.
|
||||
* @param institutionIds A list of institution IDs to filter by.
|
||||
* @param topicIds A list of topic IDs to filter by.
|
||||
* @param languageCodes A list of language codes to filter by.
|
||||
* @param sortBy The field to sort by.
|
||||
* @param sortOrder The order to sort by.
|
||||
* @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 searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPageV2>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPageV2>>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPageV2>>;
|
||||
public searchWorks(page?: number, size?: number, title?: string, publicationYears?: Array<number>, publicationTypes?: Array<string>, authorIds?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>title, 'title');
|
||||
if (publicationYears) {
|
||||
publicationYears.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_years');
|
||||
})
|
||||
}
|
||||
if (publicationTypes) {
|
||||
publicationTypes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'publication_types');
|
||||
})
|
||||
}
|
||||
if (authorIds) {
|
||||
authorIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'author_ids');
|
||||
})
|
||||
}
|
||||
if (institutionIds) {
|
||||
institutionIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'institution_ids');
|
||||
})
|
||||
}
|
||||
if (topicIds) {
|
||||
topicIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'topic_ids');
|
||||
})
|
||||
}
|
||||
if (languageCodes) {
|
||||
languageCodes.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'language_codes');
|
||||
})
|
||||
}
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortBy, 'sort_by');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>sortOrder, 'sort_order');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/v2/search`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkPageV2>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ export * from './topicHeatmapTopic';
|
||||
export * from './topicHeatmapValue';
|
||||
export * from './topicIds';
|
||||
export * from './topicPageV2';
|
||||
export * from './topicSortBy';
|
||||
export * from './topicSubfield';
|
||||
export * from './topicWordCloud';
|
||||
export * from './topicWordCloudWord';
|
||||
|
||||
@@ -13,6 +13,7 @@ import { TopAuthor } from './topAuthor';
|
||||
export interface TopAuthorStatistics {
|
||||
institution_id: string;
|
||||
works: Array<TopAuthor>;
|
||||
projects: Array<TopAuthor>;
|
||||
eu_projects: Array<TopAuthor>;
|
||||
patents: Array<TopAuthor>;
|
||||
news: Array<TopAuthor>;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 const TopicSortBy = {
|
||||
DisplayName: 'display_name',
|
||||
WorksCount: 'works_count',
|
||||
CitedByCount: 'cited_by_count'
|
||||
} as const;
|
||||
export type TopicSortBy = typeof TopicSortBy[keyof typeof TopicSortBy];
|
||||
|
||||
@@ -35,6 +35,7 @@ import { UniTrendParentComponent } from './modules/university-ranking/uni-trend-
|
||||
import {
|
||||
RESOLVING_WORK_PAGE_FOR,
|
||||
workPageResolver,
|
||||
workQueryParamKeys,
|
||||
} from './resolvers/work-page.resolver';
|
||||
import { selectedTopicsResolver } from './resolvers/selected-topics.resolver';
|
||||
import { selectedInstitutionsResolver } from './resolvers/selected-institutions.resolver';
|
||||
@@ -58,6 +59,11 @@ import {
|
||||
collaborationGraphQueryParamKeys,
|
||||
collaborationGraphResolver,
|
||||
} from './resolvers/collaboration-graph.resolver';
|
||||
import {
|
||||
topicPageResolver,
|
||||
topicQueryParamKeys,
|
||||
} from './resolvers/topic-page.resolver';
|
||||
import { topicResolver } from './resolvers/topic.resolver';
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -704,6 +710,104 @@ export const routes: Routes = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'publications',
|
||||
canActivate: [
|
||||
roleGuard([
|
||||
UserRole.User,
|
||||
UserRole.Manager,
|
||||
UserRole.Admin,
|
||||
UserRole.SuperAdmin,
|
||||
]),
|
||||
],
|
||||
loadComponent: () =>
|
||||
import('./modules/publications/publications.component').then(
|
||||
(mod) => mod.PublicationsComponent,
|
||||
),
|
||||
resolve: {
|
||||
workPage: workPageResolver,
|
||||
selectedAuthorsPage: selectedAuthorsResolver,
|
||||
selectedInstitutionsPage: selectedInstitutionsResolver,
|
||||
selectedTopicsPage: selectedTopicsResolver,
|
||||
},
|
||||
data: {
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.PUBLICATION_SEARCH,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
return Object.values(workQueryParamKeys).some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'topics',
|
||||
canActivate: [
|
||||
roleGuard([
|
||||
UserRole.User,
|
||||
UserRole.Manager,
|
||||
UserRole.Admin,
|
||||
UserRole.SuperAdmin,
|
||||
]),
|
||||
],
|
||||
loadComponent: () =>
|
||||
import('./modules/topics/topics.component').then(
|
||||
(mod) => mod.TopicsComponent,
|
||||
),
|
||||
resolve: {
|
||||
topicPage: topicPageResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
return Object.values(topicQueryParamKeys).some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'topic/:topicId',
|
||||
canActivate: [
|
||||
roleGuard([
|
||||
UserRole.User,
|
||||
UserRole.Manager,
|
||||
UserRole.Admin,
|
||||
UserRole.SuperAdmin,
|
||||
]),
|
||||
],
|
||||
loadComponent: () =>
|
||||
import('./modules/topic/topic.component').then(
|
||||
(mod) => mod.TopicComponent,
|
||||
),
|
||||
resolve: {
|
||||
topic: topicResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'paramsChange',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
pathMatch: 'full',
|
||||
redirectTo: 'publications',
|
||||
},
|
||||
{
|
||||
path: 'publications',
|
||||
loadComponent: () =>
|
||||
import('./modules/topic-publications/topic-publications.component').then(
|
||||
(mod) => mod.TopicPublicationsComponent,
|
||||
),
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
return Object.values(workQueryParamKeys).some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
},
|
||||
resolve: {
|
||||
workPage: workPageResolver,
|
||||
selectedAuthorsPage: selectedAuthorsResolver,
|
||||
selectedInstitutionsPage: selectedInstitutionsResolver,
|
||||
},
|
||||
data: {
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.TOPIC,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'projects',
|
||||
canActivate: [
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
OnDestroy,
|
||||
Injector,
|
||||
ComponentRef,
|
||||
HostListener,
|
||||
input,
|
||||
inject,
|
||||
effect,
|
||||
InputSignal,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
Overlay,
|
||||
OverlayRef,
|
||||
OverlayPositionBuilder,
|
||||
ConnectedPosition,
|
||||
} from '@angular/cdk/overlay';
|
||||
import { ComponentPortal, ComponentType } from '@angular/cdk/portal';
|
||||
|
||||
type UnwrapInputSignals<T> = {
|
||||
[K in keyof T]: T[K] extends InputSignal<infer V> ? V : T[K];
|
||||
};
|
||||
|
||||
@Directive({
|
||||
selector: '[appComponentTooltip]',
|
||||
standalone: true,
|
||||
})
|
||||
export class ComponentTooltipDirective<T extends object> implements OnDestroy {
|
||||
readonly component = input.required<ComponentType<T>>({
|
||||
alias: 'appComponentTooltip',
|
||||
});
|
||||
readonly tooltipInputs = input<Partial<UnwrapInputSignals<T>> | null>(null);
|
||||
readonly tooltipShowDelay = input(150);
|
||||
readonly tooltipHideDelay = input(100);
|
||||
readonly tooltipDisabled = input(false);
|
||||
readonly tooltipMaxWidth = input<string | number | null>(null);
|
||||
|
||||
private readonly elementRef = inject(ElementRef);
|
||||
private readonly overlay = inject(Overlay);
|
||||
private readonly overlayPositionBuilder = inject(OverlayPositionBuilder);
|
||||
private readonly injector = inject(Injector);
|
||||
|
||||
private overlayRef: OverlayRef | null = null;
|
||||
private componentRef: ComponentRef<T> | null = null;
|
||||
private showTimeout?: ReturnType<typeof setTimeout>;
|
||||
private hideTimeout?: ReturnType<typeof setTimeout>;
|
||||
|
||||
private isOverHost = false;
|
||||
private isOverOverlay = false;
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const inputs = this.tooltipInputs();
|
||||
if (this.componentRef && inputs) {
|
||||
for (const [key, value] of Object.entries(inputs)) {
|
||||
this.componentRef.setInput(key, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const maxWidth = this.tooltipMaxWidth();
|
||||
if (this.overlayRef?.hasAttached()) {
|
||||
this.applyMaxWidth(this.overlayRef.overlayElement, maxWidth);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('mouseenter')
|
||||
@HostListener('focus')
|
||||
onEnter(): void {
|
||||
if (this.tooltipDisabled()) return;
|
||||
this.isOverHost = true;
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.showTimeout = setTimeout(() => this.show(), this.tooltipShowDelay());
|
||||
}
|
||||
|
||||
@HostListener('mouseleave')
|
||||
@HostListener('blur')
|
||||
onLeave(): void {
|
||||
this.isOverHost = false;
|
||||
clearTimeout(this.showTimeout);
|
||||
this.scheduleHide();
|
||||
}
|
||||
|
||||
private scheduleHide(): void {
|
||||
this.hideTimeout = setTimeout(() => {
|
||||
if (!this.isOverHost && !this.isOverOverlay) {
|
||||
this.hide();
|
||||
}
|
||||
}, this.tooltipHideDelay());
|
||||
}
|
||||
|
||||
private show(): void {
|
||||
if (this.overlayRef?.hasAttached()) return;
|
||||
|
||||
const positions: ConnectedPosition[] = [
|
||||
{
|
||||
originX: 'center',
|
||||
originY: 'top',
|
||||
overlayX: 'center',
|
||||
overlayY: 'bottom',
|
||||
offsetY: -8,
|
||||
},
|
||||
{
|
||||
originX: 'center',
|
||||
originY: 'bottom',
|
||||
overlayX: 'center',
|
||||
overlayY: 'top',
|
||||
offsetY: 8,
|
||||
},
|
||||
{
|
||||
originX: 'end',
|
||||
originY: 'center',
|
||||
overlayX: 'start',
|
||||
overlayY: 'center',
|
||||
offsetX: 8,
|
||||
},
|
||||
{
|
||||
originX: 'start',
|
||||
originY: 'center',
|
||||
overlayX: 'end',
|
||||
overlayY: 'center',
|
||||
offsetX: -8,
|
||||
},
|
||||
];
|
||||
|
||||
const positionStrategy = this.overlayPositionBuilder
|
||||
.flexibleConnectedTo(this.elementRef)
|
||||
.withPositions(positions)
|
||||
.withFlexibleDimensions(false)
|
||||
.withPush(true);
|
||||
|
||||
this.overlayRef = this.overlay.create({
|
||||
positionStrategy,
|
||||
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
||||
panelClass: 'app-tooltip-panel',
|
||||
});
|
||||
|
||||
const portal = new ComponentPortal(this.component(), null, this.injector);
|
||||
this.componentRef = this.overlayRef.attach(portal);
|
||||
|
||||
const inputs = this.tooltipInputs();
|
||||
if (inputs) {
|
||||
for (const [key, value] of Object.entries(inputs)) {
|
||||
this.componentRef!.setInput(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
const overlayElement = this.overlayRef.overlayElement;
|
||||
this.applyMaxWidth(overlayElement, this.tooltipMaxWidth());
|
||||
|
||||
overlayElement.addEventListener('mouseenter', this.onOverlayEnter);
|
||||
overlayElement.addEventListener('mouseleave', this.onOverlayLeave);
|
||||
}
|
||||
|
||||
private applyMaxWidth(
|
||||
element: HTMLElement,
|
||||
maxWidth: string | number | null,
|
||||
): void {
|
||||
if (maxWidth === null) {
|
||||
element.style.maxWidth = '';
|
||||
return;
|
||||
}
|
||||
element.style.maxWidth =
|
||||
typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth;
|
||||
}
|
||||
|
||||
private readonly onOverlayEnter = (): void => {
|
||||
this.isOverOverlay = true;
|
||||
clearTimeout(this.hideTimeout);
|
||||
};
|
||||
|
||||
private readonly onOverlayLeave = (): void => {
|
||||
this.isOverOverlay = false;
|
||||
this.scheduleHide();
|
||||
};
|
||||
|
||||
private hide(): void {
|
||||
if (this.overlayRef) {
|
||||
const overlayElement = this.overlayRef.overlayElement;
|
||||
overlayElement.removeEventListener('mouseenter', this.onOverlayEnter);
|
||||
overlayElement.removeEventListener('mouseleave', this.onOverlayLeave);
|
||||
this.overlayRef.detach();
|
||||
}
|
||||
this.componentRef = null;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
clearTimeout(this.showTimeout);
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.overlayRef?.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import {
|
||||
ConnectedPosition,
|
||||
Overlay,
|
||||
OverlayPositionBuilder,
|
||||
OverlayRef,
|
||||
} from '@angular/cdk/overlay';
|
||||
import { TemplatePortal } from '@angular/cdk/portal';
|
||||
import {
|
||||
Directive,
|
||||
effect,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
inject,
|
||||
input,
|
||||
OnDestroy,
|
||||
TemplateRef,
|
||||
ViewContainerRef,
|
||||
} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[appTooltip]',
|
||||
standalone: true,
|
||||
})
|
||||
export class TooltipDirective<T> implements OnDestroy {
|
||||
readonly template = input.required<TemplateRef<T>>({ alias: 'appTooltip' });
|
||||
|
||||
readonly tooltipContext = input<T | null>(null);
|
||||
|
||||
readonly tooltipShowDelay = input<number>(150);
|
||||
|
||||
readonly tooltipHideDelay = input<number>(150);
|
||||
|
||||
readonly tooltipDisabled = input<boolean>(false);
|
||||
|
||||
private readonly elementRef = inject(ElementRef);
|
||||
private readonly overlay = inject(Overlay);
|
||||
private readonly overlayPositionBuilder = inject(OverlayPositionBuilder);
|
||||
private readonly viewContainerRef = inject(ViewContainerRef);
|
||||
|
||||
private overlayRef: OverlayRef | null = null;
|
||||
private portal: TemplatePortal<T> | null = null;
|
||||
private showTimeout?: ReturnType<typeof setTimeout>;
|
||||
private hideTimeout?: ReturnType<typeof setTimeout>;
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const context = this.tooltipContext();
|
||||
if (this.portal?.isAttached) {
|
||||
Object.assign(this.portal.context as object, context ?? {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('mouseenter')
|
||||
@HostListener('focus')
|
||||
onEnter(): void {
|
||||
if (this.tooltipDisabled()) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.showTimeout = setTimeout(() => this.show(), this.tooltipShowDelay());
|
||||
}
|
||||
|
||||
@HostListener('mouseleave')
|
||||
@HostListener('blur')
|
||||
onLeave(): void {
|
||||
clearTimeout(this.showTimeout);
|
||||
this.hideTimeout = setTimeout(() => this.hide(), this.tooltipHideDelay());
|
||||
}
|
||||
|
||||
private show(): void {
|
||||
if (this.overlayRef?.hasAttached()) return;
|
||||
|
||||
const positions: ConnectedPosition[] = [
|
||||
{
|
||||
originX: 'center',
|
||||
originY: 'top',
|
||||
overlayX: 'center',
|
||||
overlayY: 'bottom',
|
||||
offsetY: -8,
|
||||
},
|
||||
{
|
||||
originX: 'center',
|
||||
originY: 'bottom',
|
||||
overlayX: 'center',
|
||||
overlayY: 'top',
|
||||
offsetY: 8,
|
||||
},
|
||||
{
|
||||
originX: 'end',
|
||||
originY: 'center',
|
||||
overlayX: 'start',
|
||||
overlayY: 'center',
|
||||
offsetX: 8,
|
||||
},
|
||||
{
|
||||
originX: 'start',
|
||||
originY: 'center',
|
||||
overlayX: 'end',
|
||||
overlayY: 'center',
|
||||
offsetX: -8,
|
||||
},
|
||||
];
|
||||
|
||||
const positionStrategy = this.overlayPositionBuilder
|
||||
.flexibleConnectedTo(this.elementRef)
|
||||
.withPositions(positions)
|
||||
.withFlexibleDimensions(false)
|
||||
.withPush(true);
|
||||
|
||||
this.overlayRef = this.overlay.create({
|
||||
positionStrategy,
|
||||
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
||||
panelClass: 'app-tooltip-panel',
|
||||
});
|
||||
|
||||
this.portal = new TemplatePortal(
|
||||
this.template(),
|
||||
this.viewContainerRef,
|
||||
(this.tooltipContext() ?? {}) as T,
|
||||
);
|
||||
|
||||
this.overlayRef.attach(this.portal);
|
||||
}
|
||||
|
||||
private hide(): void {
|
||||
this.overlayRef?.detach();
|
||||
this.portal = null;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
clearTimeout(this.showTimeout);
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.overlayRef?.dispose();
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ export interface TopAuthor {
|
||||
export interface TopAuthorStatistics {
|
||||
institution_id: string;
|
||||
works: TopAuthor[];
|
||||
projects: TopAuthor[];
|
||||
eu_projects: TopAuthor[];
|
||||
patents: TopAuthor[];
|
||||
news: TopAuthor[];
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
<header class="top-authors-header">
|
||||
<div>
|
||||
<h2>Top 10 Personen aller Zeiten</h2>
|
||||
<p>Nach Anzahl der Works, Patente und News Ihrer Organisation.</p>
|
||||
<p>Nach Anzahl der Works, DFG-Projekte, Patente und News Ihrer Organisation.</p>
|
||||
</div>
|
||||
<div class="top-authors-period-toggle" aria-label="Works-Zeitraum">
|
||||
<button
|
||||
@@ -312,13 +312,18 @@
|
||||
<div class="author-bar-label">
|
||||
@if (entry.id) {
|
||||
<a
|
||||
class="author-link"
|
||||
[routerLink]="['/person', entry.id, 'overview']"
|
||||
[title]="entry.name">
|
||||
{{ entry.name }}
|
||||
class="author-name author-link"
|
||||
[routerLink]="authorLink(dataset, entry)"
|
||||
[queryParams]="authorQueryParams(dataset, entry)"
|
||||
[title]="authorDisplayName(dataset, entry)">
|
||||
{{ authorDisplayName(dataset, entry) }}
|
||||
</a>
|
||||
} @else {
|
||||
<span [title]="entry.name">{{ entry.name }}</span>
|
||||
<span
|
||||
class="author-name"
|
||||
[title]="authorDisplayName(dataset, entry)">
|
||||
{{ authorDisplayName(dataset, entry) }}
|
||||
</span>
|
||||
}
|
||||
<strong>{{ entry.count | number }}</strong>
|
||||
</div>
|
||||
|
||||
@@ -281,8 +281,10 @@
|
||||
margin-bottom: 0.25rem;
|
||||
font-size: 0.85rem;
|
||||
|
||||
span {
|
||||
.author-name {
|
||||
overflow: hidden;
|
||||
color: #1d4ed8;
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -290,8 +292,6 @@
|
||||
|
||||
.author-link {
|
||||
overflow: hidden;
|
||||
color: #1d4ed8;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -39,6 +39,12 @@ type DashboardStatisticKey =
|
||||
| 'eu_projects'
|
||||
| 'bmbf_projects'
|
||||
| 'dfg_projects';
|
||||
type TopAuthorDataset = {
|
||||
title: string;
|
||||
icon: string;
|
||||
entries: TopAuthor[];
|
||||
stripAuthorTitle?: boolean;
|
||||
};
|
||||
@Component({
|
||||
selector: 'dashboard',
|
||||
imports: [
|
||||
@@ -142,11 +148,7 @@ export class DashboardComponent implements OnInit {
|
||||
return this.statisticLoading[key];
|
||||
}
|
||||
|
||||
topAuthorDatasets(): Array<{
|
||||
title: string;
|
||||
icon: string;
|
||||
entries: TopAuthor[];
|
||||
}> {
|
||||
topAuthorDatasets(): TopAuthorDataset[] {
|
||||
return [
|
||||
{
|
||||
title: 'Publikationen',
|
||||
@@ -163,15 +165,17 @@ export class DashboardComponent implements OnInit {
|
||||
icon: 'description',
|
||||
entries: this.topAuthors?.patents ?? [],
|
||||
},
|
||||
{
|
||||
title: 'DFG Projekte',
|
||||
icon: 'account_tree',
|
||||
entries: this.topAuthors?.projects ?? [],
|
||||
stripAuthorTitle: true,
|
||||
},
|
||||
{ title: 'News', icon: 'article', entries: this.topAuthors?.news ?? [] },
|
||||
];
|
||||
}
|
||||
|
||||
visibleTopAuthorDatasets(): Array<{
|
||||
title: string;
|
||||
icon: string;
|
||||
entries: TopAuthor[];
|
||||
}> {
|
||||
visibleTopAuthorDatasets(): TopAuthorDataset[] {
|
||||
const datasets = this.topAuthorDatasets();
|
||||
return this.topAuthorsLoading
|
||||
? datasets
|
||||
@@ -206,6 +210,30 @@ export class DashboardComponent implements OnInit {
|
||||
return (count / maximum) * 100;
|
||||
}
|
||||
|
||||
authorDisplayName(dataset: TopAuthorDataset, entry: TopAuthor): string {
|
||||
if (!dataset.stripAuthorTitle) return entry.name;
|
||||
|
||||
return (
|
||||
entry.name
|
||||
.replace(
|
||||
/^(?:(?:(?:apl\.\s*)?prof(?:essor)?\.?|priv\.-doz\.?|pd|dr\.?)\s+)+/i,
|
||||
'',
|
||||
)
|
||||
.trim() || entry.name
|
||||
);
|
||||
}
|
||||
|
||||
authorLink(_dataset: TopAuthorDataset, entry: TopAuthor): string[] {
|
||||
return ['/person', entry.id!, 'overview'];
|
||||
}
|
||||
|
||||
authorQueryParams(
|
||||
_dataset: TopAuthorDataset,
|
||||
_entry: TopAuthor,
|
||||
): Record<string, string | number> | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
organizationName(): string {
|
||||
return this.statistics?.organization_name ?? 'Ihre Organisation';
|
||||
}
|
||||
|
||||
@@ -15,80 +15,5 @@
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-institution>
|
||||
<mat-card
|
||||
class="card"
|
||||
appearance="outlined"
|
||||
[routerLink]="
|
||||
institution.id
|
||||
? ['/institution', institution.id.split('/').pop() ?? '']
|
||||
: null
|
||||
">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ getDisplayName(institution) }}</mat-card-title>
|
||||
<mat-card-subtitle
|
||||
>{{ institution.geo?.city }},
|
||||
{{ institution.geo?.country }}</mat-card-subtitle
|
||||
>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-card-content class="card-content">
|
||||
<mat-divider />
|
||||
<div class="card-metadata">
|
||||
<span>Publikationen: {{ institution.works_count }}</span>
|
||||
<span>Zitationen: {{ institution.cited_by_count }}</span>
|
||||
</div>
|
||||
<mat-divider />
|
||||
</mat-card-content>
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions>
|
||||
<a
|
||||
mat-button
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
extractInstitutionId(institution),
|
||||
'overview',
|
||||
]"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>info</mat-icon>
|
||||
Übersicht
|
||||
</a>
|
||||
<a
|
||||
mat-button
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
extractInstitutionId(institution),
|
||||
'publications',
|
||||
]"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>article</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
<a
|
||||
mat-button
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
extractInstitutionId(institution),
|
||||
'projects',
|
||||
]"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>work</mat-icon>
|
||||
Projekte
|
||||
</a>
|
||||
@if (hasPatents(institution)) {
|
||||
<a
|
||||
mat-button
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
extractInstitutionId(institution),
|
||||
'patents',
|
||||
]"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>verified</mat-icon>
|
||||
Patente
|
||||
</a>
|
||||
}
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
<app-institution-card [institution]="institution" />
|
||||
</ng-template>
|
||||
|
||||
@@ -3,54 +3,4 @@
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(550px, 1fr));
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 0.5rem;
|
||||
background-color: var(--sg-background);
|
||||
transition: transform 0.3s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
cursor: pointer;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.card-metadata {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
font-size: 0.9rem;
|
||||
color: var(--sg-text-secondary);
|
||||
}
|
||||
|
||||
mat-card-actions {
|
||||
padding-top: 0.5rem;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
mat-card-actions a {
|
||||
width: 100%;
|
||||
text-decoration: none;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Component, computed, effect, inject, input } from '@angular/core';
|
||||
import { Institution, InstitutionPage } from '../../api';
|
||||
import { PatentsService } from '../../api/api/patents.service';
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { InstitutionPage } from '../../api';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { RouterModule } from '@angular/router';
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
CardSearchComponent,
|
||||
} from '../../shared/ui/card-search/card-search.component';
|
||||
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
|
||||
import { AppInstitutionCardComponent } from '../../shared/ui/app-institution-card/app-institution-card.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institutions',
|
||||
@@ -23,13 +23,12 @@ import { FilterObserver } from '../../shared/ui/selected-filters/selected-filter
|
||||
MatDividerModule,
|
||||
RouterModule,
|
||||
CardSearchComponent,
|
||||
AppInstitutionCardComponent,
|
||||
],
|
||||
templateUrl: './institutions.component.html',
|
||||
styleUrl: './institutions.component.scss',
|
||||
})
|
||||
export class InstitutionsComponent {
|
||||
private readonly patentsApi = inject(PatentsService);
|
||||
|
||||
institutionPage = input.required<InstitutionPage>();
|
||||
|
||||
observers: FilterObserver[] = [
|
||||
@@ -47,35 +46,6 @@ export class InstitutionsComponent {
|
||||
elements: this.institutionPage().elements || [],
|
||||
}));
|
||||
|
||||
// The "Patente" action only makes sense once org_patents has been indexed
|
||||
// for that institution (currently a manual, per-institution process), so
|
||||
// it's hidden by default and only shown once a cheap count check confirms
|
||||
// there is actually data behind it.
|
||||
private readonly patentsAvailable = new Map<string, boolean>();
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
for (const institution of this.page().elements) {
|
||||
const id = this.extractInstitutionId(institution);
|
||||
if (!id || this.patentsAvailable.has(id)) continue;
|
||||
this.patentsAvailable.set(id, false);
|
||||
this.patentsApi
|
||||
.getOrgPatentsByInstitution(id, undefined, 0, 0)
|
||||
.subscribe({
|
||||
next: (result) => {
|
||||
this.patentsAvailable.set(id, (result.patent_count ?? 0) > 0);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
hasPatents(institution: Institution): boolean {
|
||||
return (
|
||||
this.patentsAvailable.get(this.extractInstitutionId(institution)) ?? false
|
||||
);
|
||||
}
|
||||
|
||||
sortingOptions: SelectorOption[] = [
|
||||
{ value: 'relevance', display_name: 'Relevanz' },
|
||||
{ value: 'name', display_name: 'Name' },
|
||||
@@ -86,18 +56,4 @@ export class InstitutionsComponent {
|
||||
{ value: 'asc', display_name: 'Aufsteigend' },
|
||||
{ value: 'desc', display_name: 'Absteigend' },
|
||||
];
|
||||
|
||||
extractInstitutionId(institution: Institution): string {
|
||||
return institution.id?.split('/').pop() ?? '';
|
||||
}
|
||||
|
||||
getDisplayName(institution: Institution): string {
|
||||
const primary = institution.display_name?.trim();
|
||||
if (primary && primary.length > 0) return primary;
|
||||
|
||||
const alt = institution.display_name_alternatives?.[0]?.trim();
|
||||
if (alt && alt.length > 0) return alt;
|
||||
|
||||
return 'Unbekannte Institution';
|
||||
}
|
||||
}
|
||||
|
||||
+18
-8
@@ -132,14 +132,24 @@ export class SearchResultsStateService {
|
||||
// without a resolvable keyword are skipped when building the lookup map
|
||||
// so they can never collide on an `undefined` key and shadow a real one.
|
||||
readonly topicsList = computed(() => {
|
||||
const list = this.keywords().map((kw) => {
|
||||
const entry = this.selectedKeywordEntries().find(
|
||||
(e) =>
|
||||
e.llm_keyword?.keyword?.trim().toLowerCase() ===
|
||||
kw.trim().toLowerCase(),
|
||||
);
|
||||
return entry?.topic_mapping?.topic?.display_name ?? kw;
|
||||
});
|
||||
const list = this.keywords()
|
||||
.map((kw) => {
|
||||
const normalized = kw.trim().toLowerCase();
|
||||
const entry = this.selectedKeywordEntries().find(
|
||||
(e) =>
|
||||
e.llm_keyword?.keyword?.trim().toLowerCase() === normalized ||
|
||||
e.topic_mapping?.topic?.id?.trim().toLowerCase() === normalized,
|
||||
);
|
||||
const displayName = entry?.topic_mapping?.topic?.display_name;
|
||||
if (displayName && !displayName.startsWith('http')) {
|
||||
return displayName;
|
||||
}
|
||||
if (kw.startsWith('http') || kw.includes('openalex.org/topics')) {
|
||||
return '';
|
||||
}
|
||||
return kw;
|
||||
})
|
||||
.filter((t) => t.length > 0);
|
||||
return Array.from(new Set(list));
|
||||
});
|
||||
|
||||
|
||||
@@ -1,117 +1,110 @@
|
||||
<div class="content">
|
||||
<div class="description-container">
|
||||
<h5 style="font-weight: bold">Netzwerk</h5>
|
||||
<p>Zusammenarbeit und Verbindungen im wissenschaftlichen Netzwerk.</p>
|
||||
</div>
|
||||
@if (this.isPending()) {
|
||||
<app-loading
|
||||
text="Das Netzwerk wird gebaut, kleinen Moment..."
|
||||
icon="graph_3"
|
||||
[size]="150"
|
||||
[diameter]="150" />
|
||||
} @else if (this.isFailed()) {
|
||||
<div class="error">
|
||||
<mat-icon>error</mat-icon>
|
||||
<span class="error-message">{{
|
||||
this.collaborationGraphError()
|
||||
? this.collaborationGraphError()
|
||||
: 'Fehler beim Laden des Netzwerks. Bitte versuchen Sie es später erneut.'
|
||||
}}</span>
|
||||
|
||||
@if (this.isPending()) {
|
||||
<app-loading
|
||||
text="Das Netzwerk wird gebaut, kleinen Moment..."
|
||||
icon="graph_3"
|
||||
[size]="150"
|
||||
[diameter]="150" />
|
||||
} @else if (this.isFailed()) {
|
||||
<div class="error">
|
||||
<mat-icon>error</mat-icon>
|
||||
<span class="error-message">{{
|
||||
this.collaborationGraphError()
|
||||
? this.collaborationGraphError()
|
||||
: 'Fehler beim Laden des Netzwerks. Bitte versuchen Sie es später erneut.'
|
||||
}}</span>
|
||||
<app-selected-filters [observers]="observers" />
|
||||
<button matButton="outlined" type="button" (click)="openFilterDialog()">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
Filter
|
||||
</button>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="grid">
|
||||
<div class="cell">
|
||||
<mat-card appearance="outlined" style="height: 100%">
|
||||
<mat-card-content>
|
||||
<app-collaboration-graph
|
||||
[collaborationGraph]="collaborationGraph()!"
|
||||
(handleNodeClick)="handleNodeClick($event)" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="cell">
|
||||
<div class="toggle-group">
|
||||
<mat-button-toggle-group
|
||||
class="mat-button-toggle-group"
|
||||
aria-label="Select view"
|
||||
(change)="onToggleChange($event)"
|
||||
[value]="displayedTable()"
|
||||
style="width: 100%">
|
||||
<mat-button-toggle value="collaborator">
|
||||
Kollaborierende
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle value="publication"
|
||||
>Publikationen</mat-button-toggle
|
||||
>
|
||||
<mat-button-toggle value="institution">
|
||||
Institutionen
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
<button
|
||||
class="filter-button"
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
(click)="openFilterDialog()">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
Filter
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<app-query-param-input
|
||||
style="width: 100%"
|
||||
queryParamKey="search_term"
|
||||
[label]="this.searchTermLabel()" />
|
||||
|
||||
<app-selected-filters [observers]="observers" />
|
||||
<button matButton="outlined" type="button" (click)="openFilterDialog()">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
Filter
|
||||
</button>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="grid">
|
||||
<div class="cell">
|
||||
<mat-card appearance="outlined" style="height: 100%">
|
||||
<mat-card-content>
|
||||
<app-collaboration-graph
|
||||
[collaborationGraph]="collaborationGraph()!"
|
||||
(handleNodeClick)="handleNodeClick($event)" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="cell">
|
||||
<div class="toggle-group">
|
||||
<mat-button-toggle-group
|
||||
class="mat-button-toggle-group"
|
||||
aria-label="Select view"
|
||||
(change)="onToggleChange($event)"
|
||||
[value]="displayedTable()"
|
||||
style="width: 100%">
|
||||
<mat-button-toggle value="collaborator">
|
||||
Kollaborierende
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle value="publication"
|
||||
>Publikationen</mat-button-toggle
|
||||
>
|
||||
<mat-button-toggle value="institution">
|
||||
Institutionen
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
<button
|
||||
class="filter-button"
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
(click)="openFilterDialog()">
|
||||
<mat-icon>filter_alt</mat-icon>
|
||||
Filter
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<app-query-param-input
|
||||
style="width: 100%"
|
||||
queryParamKey="search_term"
|
||||
[label]="this.searchTermLabel()" />
|
||||
|
||||
<app-selected-filters [observers]="observers" />
|
||||
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content class="scroll-viewport-container">
|
||||
@if (this.displayedTable() === 'collaborator') {
|
||||
<app-data-table
|
||||
[columns]="collaboratorsColumns"
|
||||
[data]="collaboratorsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="collaboratorsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
} @else if (this.displayedTable() === 'publication') {
|
||||
<app-data-table
|
||||
[columns]="publicationsColumns"
|
||||
[data]="publicationsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="publicationsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
} @else if (this.displayedTable() === 'institution') {
|
||||
<app-data-table
|
||||
[columns]="institutionsColumns"
|
||||
[data]="institutionsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="institutionsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
<div class="cell full-width">
|
||||
<div class="summary-container">
|
||||
@for (summary of this.summaryCards(); track $index) {
|
||||
<app-info-card
|
||||
[icon]="summary.icon"
|
||||
[value]="summary.value.toString()"
|
||||
[description]="summary.description" />
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content class="scroll-viewport-container">
|
||||
@if (this.displayedTable() === 'collaborator') {
|
||||
<app-data-table
|
||||
[columns]="collaboratorsColumns"
|
||||
[data]="collaboratorsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="collaboratorsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
} @else if (this.displayedTable() === 'publication') {
|
||||
<app-data-table
|
||||
[columns]="publicationsColumns"
|
||||
[data]="publicationsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="publicationsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
} @else if (this.displayedTable() === 'institution') {
|
||||
<app-data-table
|
||||
[columns]="institutionsColumns"
|
||||
[data]="institutionsData()"
|
||||
[filterTerm]="searchTerm()"
|
||||
[detailTemplate]="institutionsDetailRow"
|
||||
[maxHeight]="'100%'" />
|
||||
}
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
<div class="cell full-width">
|
||||
<div class="summary-container">
|
||||
@for (summary of this.summaryCards(); track $index) {
|
||||
<app-info-card
|
||||
[icon]="summary.icon"
|
||||
[value]="summary.value.toString()"
|
||||
[description]="summary.description" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<ng-template #collaboratorsActionTmp let-element>
|
||||
<a
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
<div class="page">
|
||||
<div>
|
||||
<h6>Nachrichten</h6>
|
||||
<p>Aktuelle Nachrichten zu dieser Person.</p>
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-article>
|
||||
<app-news-card [article]="article" />
|
||||
</ng-template>
|
||||
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[loading]="loading"
|
||||
@@ -17,3 +8,7 @@
|
||||
sortingDirectionLabel="Sortierung"
|
||||
searchLabel="Nachrichten durchsuchen" />
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-article>
|
||||
<app-news-card [article]="article" />
|
||||
</ng-template>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
.page {
|
||||
padding: 28px 32px 42px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.person-overview {
|
||||
width: 100%;
|
||||
display: block;
|
||||
padding: 1.5rem 1.5rem 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
<div class="person-projects">
|
||||
<div class="description-container">
|
||||
<h5 style="font-weight: bold">Projekte</h5>
|
||||
<p>Übersicht der durchgeführten Projekte.</p>
|
||||
</div>
|
||||
|
||||
<nav mat-tab-nav-bar [tabPanel]="resultTabPanel" class="result-nav">
|
||||
@for (route of childRoutes; track route.path) {
|
||||
<a
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
.person-projects {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.description-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
mat-card,
|
||||
mat-paginator {
|
||||
background-color: var(--sg-background);
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
<div class="page">
|
||||
<div>
|
||||
<h6>Publikationen</h6>
|
||||
<p>Übersicht der wissenschaftlichen Veröffentlichungen.</p>
|
||||
</div>
|
||||
@if (canViewClassificationChart()) {
|
||||
<mat-accordion multi>
|
||||
<mat-expansion-panel class="mat-elevation-z1">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Forschungszwecke</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<app-primary-category-year-aggregation-chart
|
||||
[page]="primaryCategoryYearAggregationPage()" />
|
||||
</mat-expansion-panel>
|
||||
@if (canViewClassificationChart()) {
|
||||
<mat-accordion multi>
|
||||
<mat-expansion-panel class="mat-elevation-z1">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Forschungszwecke</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<app-primary-category-year-aggregation-chart
|
||||
[page]="primaryCategoryYearAggregationPage()" />
|
||||
</mat-expansion-panel>
|
||||
|
||||
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Publikationsliste</mat-panel-title>
|
||||
<mat-panel-description
|
||||
>{{ total() >= 10000 ? 'mehr als' : '' }}
|
||||
{{ total() }} Publikationen</mat-panel-description
|
||||
>
|
||||
</mat-expansion-panel-header>
|
||||
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
} @else {
|
||||
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
||||
}
|
||||
</div>
|
||||
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Publikationsliste</mat-panel-title>
|
||||
<mat-panel-description
|
||||
>{{ total() >= 10000 ? 'mehr als' : '' }}
|
||||
{{ total() }} Publikationen</mat-panel-description
|
||||
>
|
||||
</mat-expansion-panel-header>
|
||||
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
} @else {
|
||||
<ng-container *ngTemplateOutlet="filterTableAndPaginator" />
|
||||
}
|
||||
|
||||
<ng-template #filterTableAndPaginator>
|
||||
<app-publication-filter
|
||||
@@ -38,6 +32,7 @@
|
||||
<app-publication-table
|
||||
[page]="authorWorkPage()"
|
||||
[institutionFilterEnabled]="true"
|
||||
[topicFilterEnabled]="true"
|
||||
[rawOaAuthorId]="rawOaAuthorId()" />
|
||||
|
||||
<app-query-param-paginator
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
.page {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
mat-expansion-panel {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, inject, input, OnInit } from '@angular/core';
|
||||
import { Component, computed, inject, input } from '@angular/core';
|
||||
|
||||
import {
|
||||
WorkPageV2,
|
||||
|
||||
@@ -170,5 +170,18 @@
|
||||
[diameter]="150"></app-loading>
|
||||
}
|
||||
<mat-tab-nav-panel #tabPanel class="person-panel">
|
||||
<router-outlet></router-outlet>
|
||||
@let activeLink = this.activeLink();
|
||||
@if (activeLink) {
|
||||
<div class="description-container">
|
||||
@if (activeLink.label) {
|
||||
<h5>{{ activeLink.label }}</h5>
|
||||
}
|
||||
@if (activeLink.description) {
|
||||
<span class="description">{{ activeLink.description }}</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="content">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</mat-tab-nav-panel>
|
||||
|
||||
@@ -372,3 +372,24 @@
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.description-container {
|
||||
margin: 3rem 3rem 2rem 3rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
h5 {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin: 1rem 4rem;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,14 @@ import { PersonDataResolved } from '../../resolvers/person.resolver';
|
||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||
import { collaborationGraphQueryParamKeys } from '../../resolvers/collaboration-graph.resolver';
|
||||
|
||||
type PersonLink = {
|
||||
label: string;
|
||||
description?: string;
|
||||
path: string;
|
||||
queryParams?: Record<string, any>;
|
||||
disabled: boolean;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-person',
|
||||
imports: [
|
||||
@@ -57,7 +65,9 @@ export class PersonComponent {
|
||||
readonly params = toSignal(this.activatedRoute.paramMap);
|
||||
readonly routerEvents = toSignal(this.router.events);
|
||||
|
||||
readonly currentUrl = computed(() => this.router.url);
|
||||
readonly currentUrl = toSignal(
|
||||
this.router.events.pipe(switchMap(() => of(this.router.url))),
|
||||
);
|
||||
|
||||
// derive authorID directly from route
|
||||
private readonly authorId = toSignal(
|
||||
@@ -233,10 +243,16 @@ export class PersonComponent {
|
||||
{ initialValue: [] },
|
||||
);
|
||||
|
||||
readonly links = computed(() => [
|
||||
{ label: 'Übersicht', path: 'overview', disabled: false },
|
||||
readonly links = computed<PersonLink[]>(() => [
|
||||
{
|
||||
label: 'Übersicht',
|
||||
description: 'Übersicht über die Person',
|
||||
path: 'overview',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Projekte',
|
||||
description: 'Übersicht der durchgeführten Projekte der Person',
|
||||
path: 'projects',
|
||||
queryParams: {
|
||||
page: 0,
|
||||
@@ -247,9 +263,15 @@ export class PersonComponent {
|
||||
},
|
||||
disabled: false,
|
||||
},
|
||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
||||
{
|
||||
label: 'Publikationen',
|
||||
description: 'Übersicht der Publikationen der Person',
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Netzwerk',
|
||||
description: 'Kooperationsnetzwerk der Person',
|
||||
path: 'network',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
@@ -263,16 +285,52 @@ export class PersonComponent {
|
||||
? [
|
||||
{
|
||||
label: 'Unternehmen',
|
||||
description: 'Unternehmen, mit denen die Person verbunden ist',
|
||||
path: 'company-connections',
|
||||
disabled: false,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ label: 'Förderungen', path: 'funding', disabled: false },
|
||||
{ label: 'Nachrichten', path: 'news', disabled: false },
|
||||
{ label: 'Patente', path: 'patents', disabled: false },
|
||||
{
|
||||
label: 'Förderungen',
|
||||
description: 'Übersicht der Förderungen der Person',
|
||||
path: 'funding',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Nachrichten',
|
||||
description: 'Nachrichten über die Person',
|
||||
path: 'news',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Patente',
|
||||
description: 'Patente der Person',
|
||||
path: 'patents',
|
||||
disabled: false,
|
||||
},
|
||||
]);
|
||||
|
||||
readonly activeLink = computed<PersonLink | null>(() => {
|
||||
const currentUrl = this.currentUrl();
|
||||
if (!currentUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const link of this.links()) {
|
||||
const linkUrl = this.router
|
||||
.createUrlTree([link.path], {
|
||||
relativeTo: this.activatedRoute,
|
||||
})
|
||||
.toString();
|
||||
|
||||
if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) {
|
||||
return link;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
onInterestingTagClick(selection: {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<div class="content">
|
||||
<h1>Passende Publikationen finden</h1>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[cardMinWidth]="500"
|
||||
[cardTmp]="cardTmp"
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
searchLabel="Suche nach Titel"
|
||||
[sortingOptions]="sortingOptions"
|
||||
searchQueryParamKey="title"
|
||||
[sortingDirectionOptions]="sortingDirectionOptions"
|
||||
sortingDirectionQueryParamKey="sort_direction" />
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-work>
|
||||
<app-publication-card [work]="work" />
|
||||
</ng-template>
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
<div class="additional-filters">
|
||||
<app-publication-filter
|
||||
[selectedAuthorsPage]="selectedAuthorsPage()"
|
||||
[selectedTopicsPage]="selectedTopicsPage()"
|
||||
[selectedInstitutionsPage]="selectedInstitutionsPage()"
|
||||
[showTitleFilter]="false" />
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -0,0 +1,10 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.additional-filters {
|
||||
margin: 0rem 1rem;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import {
|
||||
AuthorPage,
|
||||
InstitutionPageV2,
|
||||
SortDirection,
|
||||
TopicPageV2,
|
||||
WorkPageV2,
|
||||
WorkSortBy,
|
||||
} from '../../api';
|
||||
import {
|
||||
Page,
|
||||
CardSearchComponent,
|
||||
} from '../../shared/ui/card-search/card-search.component';
|
||||
import { MatDivider } from '@angular/material/divider';
|
||||
import { AppPublicationCardComponent } from '../../shared/ui/app-publication-card/app-publication-card.component';
|
||||
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publications',
|
||||
imports: [
|
||||
MatDivider,
|
||||
CardSearchComponent,
|
||||
AppPublicationCardComponent,
|
||||
PublicationFilterComponent,
|
||||
],
|
||||
templateUrl: './publications.component.html',
|
||||
styleUrl: './publications.component.scss',
|
||||
})
|
||||
export class PublicationsComponent {
|
||||
workPage = input.required<WorkPageV2>();
|
||||
selectedAuthorsPage = input.required<AuthorPage>();
|
||||
selectedInstitutionsPage = input.required<InstitutionPageV2>();
|
||||
selectedTopicsPage = input.required<TopicPageV2>();
|
||||
|
||||
page = computed<Page>(() => ({
|
||||
page: this.workPage().page || 0,
|
||||
size: this.workPage().size || 10,
|
||||
total: this.workPage().total || 0,
|
||||
elements: this.workPage().elements || [],
|
||||
}));
|
||||
|
||||
sortingOptions: SelectorOption[] = [
|
||||
{ value: WorkSortBy.Title, display_name: 'Titel' },
|
||||
{ value: WorkSortBy.CitedByCount, display_name: 'Anzahl Zitationen' },
|
||||
];
|
||||
sortingDirectionOptions: SelectorOption[] = [
|
||||
{ value: SortDirection.Asc, display_name: 'Aufsteigend' },
|
||||
{ value: SortDirection.Desc, display_name: 'Absteigend' },
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<app-publication-filter
|
||||
[selectedAuthorsPage]="selectedAuthorsPage()"
|
||||
[selectedInstitutionsPage]="selectedInstitutionsPage()"
|
||||
[showTopicFilter]="false" />
|
||||
|
||||
<app-publication-table
|
||||
[page]="workPage()"
|
||||
[authorFilterEnabled]="true"
|
||||
[institutionFilterEnabled]="true" />
|
||||
|
||||
<app-query-param-paginator
|
||||
[total]="total()"
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size"
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { AuthorPage, InstitutionPageV2, WorkPageV2 } from '../../api';
|
||||
import { PublicationFilterComponent } from "../../shared/ui/publication-filters/publication-filters.component";
|
||||
import { PublicationTableComponent } from "../../shared/ui/publication-table/publication-table.component";
|
||||
import { QueryParamPaginatorComponent } from "../../shared/ui/query-param-paginator/query-param-paginator.component";
|
||||
|
||||
@Component({
|
||||
selector: 'app-topic-publications',
|
||||
imports: [PublicationFilterComponent, PublicationTableComponent, QueryParamPaginatorComponent],
|
||||
templateUrl: './topic-publications.component.html',
|
||||
styleUrl: './topic-publications.component.scss',
|
||||
})
|
||||
export class TopicPublicationsComponent {
|
||||
workPage = input.required<WorkPageV2>();
|
||||
|
||||
selectedAuthorsPage = input.required<AuthorPage>();
|
||||
selectedInstitutionsPage = input.required<InstitutionPageV2>();
|
||||
|
||||
total = computed<number>(() => this.workPage().total ?? 0);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<div class="content">
|
||||
@if (topic(); as topic) {
|
||||
<div>
|
||||
<h2>{{ topic.display_name }}</h2>
|
||||
<span class="subtitle">{{ subtitle() }}</span>
|
||||
</div>
|
||||
<mat-divider />
|
||||
<p style="width: 50%">{{ description() }}</p>
|
||||
<mat-divider />
|
||||
<div class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
topic.works_count | number: undefined : 'de'
|
||||
}}
|
||||
Publikationen</span
|
||||
>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
topic.cited_by_count | number: undefined : 'de'
|
||||
}}
|
||||
Zitationen</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<mat-divider />
|
||||
<mat-tab-nav-panel #tabPanel>
|
||||
<nav mat-tab-nav-bar [tabPanel]="tabPanel">
|
||||
@for (link of links; track link.path) {
|
||||
<a
|
||||
mat-tab-link
|
||||
[routerLink]="link.path"
|
||||
[queryParams]="link.queryParams"
|
||||
routerLinkActive
|
||||
#rla="routerLinkActive"
|
||||
[active]="rla.isActive"
|
||||
[disabled]="link.disabled">
|
||||
{{ link.label }}
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
<div class="outlet-container">
|
||||
<router-outlet />
|
||||
</div>
|
||||
</mat-tab-nav-panel>
|
||||
@@ -0,0 +1,36 @@
|
||||
.content {
|
||||
--topic-border: color-mix(in srgb, hsl(var(--topic-color)) 72%, #ffffff);
|
||||
--topic-background: color-mix(in srgb, hsl(var(--topic-color)) 8%, #ffffff);
|
||||
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
background-color: var(--topic-background);
|
||||
--mat-divider-color: var(--topic-border);
|
||||
}
|
||||
|
||||
.outlet-container {
|
||||
margin: 2rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Topic } from '../../api';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--topic-color]': 'color()',
|
||||
},
|
||||
selector: 'app-topic',
|
||||
imports: [
|
||||
MatTabsModule,
|
||||
RouterModule,
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
DecimalPipe,
|
||||
],
|
||||
templateUrl: './topic.component.html',
|
||||
styleUrl: './topic.component.scss',
|
||||
})
|
||||
export class TopicComponent {
|
||||
topic = input.required<Topic>();
|
||||
|
||||
links = [
|
||||
{
|
||||
label: 'Publikationen',
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
title: '',
|
||||
sort_by: 'title',
|
||||
sort_direction: 'asc',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
subtitle = computed(() => {
|
||||
return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`;
|
||||
});
|
||||
|
||||
description = computed(() => {
|
||||
return this.topic().description || 'Keine Beschreibung verfügbar';
|
||||
});
|
||||
|
||||
color = computed<string>(() => {
|
||||
const topic = this.topic();
|
||||
return topicHierarchyColor({
|
||||
id: topic.id ?? undefined,
|
||||
name: topic.display_name ?? undefined,
|
||||
field_id: topic.field?.id ?? undefined,
|
||||
field_name: topic.field?.display_name ?? undefined,
|
||||
domain_id: topic.domain?.id ?? undefined,
|
||||
domain_name: topic.domain?.display_name ?? undefined,
|
||||
})
|
||||
.replace('hsl(', '')
|
||||
.replace(')', '');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<div class="content">
|
||||
<h1>Passende Themen finden</h1>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[cardMinWidth]="300"
|
||||
[cardTmp]="cardTmp"
|
||||
[observers]="observers"
|
||||
[cardMinWidth]="550"
|
||||
searchLabel="Suche nach Namen"
|
||||
[searchQueryParamKey]="topicSearchQueryParamKey"
|
||||
[sortingOptions]="sortingOptions"
|
||||
[sortByQueryParamKey]="topicSortByQueryParamKey"
|
||||
[sortingDirectionOptions]="sortingDirectionOptions"
|
||||
[sortingDirectionQueryParamKey]="topicSortingDirectionQueryParamKey" />
|
||||
</div>
|
||||
|
||||
<ng-template #cardTmp let-topic>
|
||||
<app-topic-card [topic]="topic" />
|
||||
</ng-template>
|
||||
@@ -0,0 +1,6 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import {
|
||||
CardSearchComponent,
|
||||
Page,
|
||||
} from '../../shared/ui/card-search/card-search.component';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { AppTopicCardComponent } from '../../shared/ui/app-topic-card/app-topic-card.component';
|
||||
import { SortDirection, TopicPageV2, TopicSortBy } from '../../api';
|
||||
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
|
||||
import { topicQueryParamKeys } from '../../resolvers/topic-page.resolver';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topics',
|
||||
imports: [CardSearchComponent, MatDividerModule, AppTopicCardComponent],
|
||||
templateUrl: './topics.component.html',
|
||||
styleUrl: './topics.component.scss',
|
||||
})
|
||||
export class TopicsComponent {
|
||||
topicPage = input.required<TopicPageV2>();
|
||||
|
||||
observers: FilterObserver[] = [
|
||||
{
|
||||
id: 'query',
|
||||
queryParamKey: topicQueryParamKeys.query,
|
||||
icon: 'search',
|
||||
},
|
||||
];
|
||||
|
||||
readonly topicSearchQueryParamKey = topicQueryParamKeys.query;
|
||||
readonly topicSortByQueryParamKey = topicQueryParamKeys.sortBy;
|
||||
readonly topicSortingDirectionQueryParamKey =
|
||||
topicQueryParamKeys.sortDirection;
|
||||
|
||||
page = computed<Page>(() => ({
|
||||
page: this.topicPage().page || 0,
|
||||
size: this.topicPage().size || 10,
|
||||
total: this.topicPage().total || 0,
|
||||
elements: this.topicPage().elements || [],
|
||||
}));
|
||||
|
||||
sortingOptions: SelectorOption[] = [
|
||||
{ value: TopicSortBy.DisplayName, display_name: 'Name' },
|
||||
{ value: TopicSortBy.WorksCount, display_name: 'Anzahl Publikationen' },
|
||||
{ value: TopicSortBy.CitedByCount, display_name: 'Anzahl Zitationen' },
|
||||
];
|
||||
|
||||
sortingDirectionOptions: SelectorOption[] = [
|
||||
{ value: SortDirection.Asc, display_name: 'Aufsteigend' },
|
||||
{ value: SortDirection.Desc, display_name: 'Absteigend' },
|
||||
];
|
||||
}
|
||||
+40
-17
@@ -8,7 +8,10 @@ import { CommonModule } from '@angular/common';
|
||||
import { EChartsOption } from 'echarts';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
import { TrendResponse } from '../../../api';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
topicHierarchyColor,
|
||||
TopicColorVariant,
|
||||
} from '../../../resolvers/utils/topic-colors';
|
||||
|
||||
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
||||
|
||||
@@ -25,7 +28,8 @@ export class UniPieChartComponent {
|
||||
readonly entityName = input<string | null>(null);
|
||||
readonly startYear = input<number>(2010);
|
||||
readonly endYear = input<number>(2025);
|
||||
readonly getTopicColor = input<(topic: string) => string>();
|
||||
readonly getTopicColor =
|
||||
input<(topic: string, variant?: TopicColorVariant) => string>();
|
||||
|
||||
// Inputs for direct rendering (useful for overall top 10 topics chart)
|
||||
readonly titleText = input<string | null>(null);
|
||||
@@ -33,15 +37,18 @@ export class UniPieChartComponent {
|
||||
readonly loading = input<boolean>(false);
|
||||
readonly error = input<boolean>(false);
|
||||
|
||||
private resolveTopicColor(topic: string): string {
|
||||
private resolveTopicColorTokens(topic: string) {
|
||||
if (topic === 'Andere Themen') {
|
||||
return '#9ca3af'; // gray for "Other" topics
|
||||
return { color: 'hsl(214, 20%, 93%)', border: 'hsl(214, 20%, 80%)' };
|
||||
}
|
||||
const customResolver = this.getTopicColor();
|
||||
if (customResolver) {
|
||||
return customResolver(topic);
|
||||
}
|
||||
return topicHierarchyColor({ name: topic });
|
||||
const bgColor = customResolver
|
||||
? customResolver(topic, 'bg')
|
||||
: topicHierarchyColor({ name: topic }, 'bg');
|
||||
const border = customResolver
|
||||
? customResolver(topic, 'border')
|
||||
: topicHierarchyColor({ name: topic }, 'border');
|
||||
return { color: bgColor, border };
|
||||
}
|
||||
|
||||
readonly chartOptions = computed<EChartsOption>(() => {
|
||||
@@ -79,13 +86,19 @@ export class UniPieChartComponent {
|
||||
// 3. If direct pieData input is provided, use it
|
||||
const directData = this.pieData();
|
||||
if (directData !== null) {
|
||||
pieDataList = directData.map((item) => ({
|
||||
value: item.value,
|
||||
name: item.name,
|
||||
itemStyle: {
|
||||
color: this.resolveTopicColor(item.name),
|
||||
},
|
||||
}));
|
||||
pieDataList = directData.map((item) => {
|
||||
const tokens = this.resolveTopicColorTokens(item.name);
|
||||
return {
|
||||
value: item.value,
|
||||
name: item.name,
|
||||
itemStyle: {
|
||||
color: tokens.color,
|
||||
opacity: 0.95,
|
||||
borderColor: tokens.border,
|
||||
borderWidth: 1.5,
|
||||
},
|
||||
};
|
||||
});
|
||||
title = this.titleText() ?? 'Themenverteilung';
|
||||
} else {
|
||||
// Otherwise, filter and extract from TrendResponse
|
||||
@@ -125,11 +138,15 @@ export class UniPieChartComponent {
|
||||
const totalRaw = filtered.reduce((sum, item) => sum + item.raw, 0);
|
||||
|
||||
if (totalRaw > 0) {
|
||||
const tokens = this.resolveTopicColorTokens(topicName);
|
||||
pieDataList.push({
|
||||
value: totalRaw,
|
||||
name: topicName,
|
||||
itemStyle: {
|
||||
color: this.resolveTopicColor(topicName),
|
||||
color: tokens.color,
|
||||
opacity: 0.95,
|
||||
borderColor: tokens.border,
|
||||
borderWidth: 1.5,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -199,11 +216,17 @@ export class UniPieChartComponent {
|
||||
smooth: true,
|
||||
},
|
||||
emphasis: {
|
||||
scale: true,
|
||||
scaleSize: 6,
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.2)',
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
fontSize: 10,
|
||||
fontWeight: 'bold',
|
||||
formatter: '{b}\n{c} ({d}%)',
|
||||
},
|
||||
},
|
||||
data: pieDataList,
|
||||
|
||||
+12
-7
@@ -79,9 +79,13 @@ export class UniTrendChartComponent {
|
||||
|
||||
// Build series: Line in top grid, growth volume bars and S-Curve in bottom grid
|
||||
trendData.series.forEach((entity, entityIdx) => {
|
||||
const color = getFn
|
||||
const rawColor = getFn
|
||||
? getFn(entity.entity_id)
|
||||
: entityColors[entityIdx % entityColors.length];
|
||||
const color = rawColor.replace(
|
||||
/hsl\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)%\s+([+-]?\d+(?:\.\d+)?)%\s*\)/gi,
|
||||
'hsl($1, $2%, $3%)',
|
||||
);
|
||||
if ((entity as any).visible === false) {
|
||||
return;
|
||||
}
|
||||
@@ -97,16 +101,13 @@ export class UniTrendChartComponent {
|
||||
return currentMode === 'normalized' ? yrData.normalized : yrData.raw;
|
||||
});
|
||||
|
||||
const isStacked = currentMode === 'total' || currentMode === 'cumulative';
|
||||
|
||||
series.push({
|
||||
name: `${entity.entity_name}`,
|
||||
type: 'line',
|
||||
xAxisIndex: 0,
|
||||
yAxisIndex: 0,
|
||||
stack: isStacked ? 'Total' : undefined,
|
||||
areaStyle: {
|
||||
opacity: isStacked ? 0.3 : 0.12,
|
||||
opacity: 0.12,
|
||||
},
|
||||
data: lineData,
|
||||
smooth: true,
|
||||
@@ -142,7 +143,7 @@ export class UniTrendChartComponent {
|
||||
yAxisIndex: 1,
|
||||
data: bars,
|
||||
itemStyle: {
|
||||
color: color, // Takes the color of the institution!
|
||||
color: color,
|
||||
},
|
||||
markLine:
|
||||
entityIdx === 0
|
||||
@@ -202,9 +203,13 @@ export class UniTrendChartComponent {
|
||||
res += `<div style="max-height: 280px; overflow-y: auto; padding-right: 6px;">`;
|
||||
|
||||
trendData.series.forEach((entity: TrendSeries, entityIdx: number) => {
|
||||
const color = getFn
|
||||
const rawColor = getFn
|
||||
? getFn(entity.entity_id)
|
||||
: entityColors[entityIdx % entityColors.length];
|
||||
const color = rawColor.replace(
|
||||
/hsl\(\s*([+-]?\d+(?:\.\d+)?)\s+([+-]?\d+(?:\.\d+)?)%\s+([+-]?\d+(?:\.\d+)?)%\s*\)/gi,
|
||||
'hsl($1, $2%, $3%)',
|
||||
);
|
||||
if ((entity as any).visible === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
+7
-7
@@ -175,15 +175,15 @@
|
||||
|
||||
<!-- Main Full-Width Content Area -->
|
||||
<main class="trend-main-fullwidth">
|
||||
@if (isPageResolving() || (isTrendLoading() && !rawTrendResponse())) {
|
||||
<app-loading
|
||||
text="Trenddaten werden geladen..."
|
||||
icon="trending_up"
|
||||
[size]="200"
|
||||
[diameter]="200"></app-loading>
|
||||
} @else if (rawTrendResponse()) {
|
||||
@if (rawTrendResponse()) {
|
||||
<!-- Chart Holder Card (100% Full Width) -->
|
||||
<div class="chart-holder-card">
|
||||
@if (isTrendLoading() || isPageResolving()) {
|
||||
<div class="loader-overlay">
|
||||
<mat-spinner diameter="40"></mat-spinner>
|
||||
<p>Daten werden geladen...</p>
|
||||
</div>
|
||||
}
|
||||
@if (selectedTrendTopics().length > 0) {
|
||||
<div class="chart-topic-tabs">
|
||||
@for (topic of selectedTrendTopics(); track topic) {
|
||||
|
||||
+127
-40
@@ -18,9 +18,6 @@ import {
|
||||
ResolveEnd,
|
||||
} from '@angular/router';
|
||||
import { forkJoin } from 'rxjs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import {
|
||||
@@ -29,7 +26,6 @@ import {
|
||||
} from '@angular/material/button-toggle';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { UniTrendChartComponent } from '../uni-trend-chart/uni-trend-chart.component';
|
||||
import { UniPieChartComponent } from '../uni-pie-chart/uni-pie-chart.component';
|
||||
@@ -48,14 +44,16 @@ import {
|
||||
} from '../../../api';
|
||||
import { CredentialService } from '../../../shared/services/credential.service';
|
||||
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
topicHierarchyColor,
|
||||
TopicColorVariant,
|
||||
} from '../../../resolvers/utils/topic-colors';
|
||||
import { YearRangeSliderComponent } from '../../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import { LocationSelectorComponent } from '../../../shared/ui/location-selector/location-selector.component';
|
||||
import { InstitutionSelectorComponent } from '../../../shared/ui/institution-selector/institution-selector.component';
|
||||
import { AuthorSelectorComponent } from '../../../shared/ui/author-selector/author-selector.component';
|
||||
import { AuthorInstitutionSelectorComponent } from '../../../shared/ui/author-institution-selector/author-institution-selector.component';
|
||||
import { SearchResultsStateService } from '../../keywords-search/search-results/search-results-state.service';
|
||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
||||
import { TopicTreemapComponent } from '../../../shared/ui/topic-treemap/topic-treemap.component';
|
||||
import {
|
||||
TopicTreemapData,
|
||||
@@ -145,7 +143,6 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
|
||||
InstitutionSelectorComponent,
|
||||
AuthorSelectorComponent,
|
||||
AuthorInstitutionSelectorComponent,
|
||||
LoadingComponent,
|
||||
TopicTreemapComponent,
|
||||
],
|
||||
templateUrl: './uni-trend-parent.component.html',
|
||||
@@ -260,36 +257,61 @@ export class UniTrendParentComponent implements OnInit {
|
||||
return topicOrKeyword;
|
||||
}
|
||||
|
||||
getTopicColor(topic: string): string {
|
||||
getTopicColor(topic: string, variant: TopicColorVariant = 'base'): string {
|
||||
const mapped = this.getMappedTopic(topic);
|
||||
const entries = this.state?.selectedKeywordEntries() ?? [];
|
||||
const ext = this.state?.extractedKeywords() ?? [];
|
||||
const man = this.state?.manualKeywords() ?? [];
|
||||
const topicsList = this.state?.topics() ?? [];
|
||||
const all = [...entries, ...ext, ...man];
|
||||
|
||||
const targetLower = topic.toLowerCase().trim();
|
||||
const mappedLower = mapped.toLowerCase().trim();
|
||||
|
||||
const topicObj = topicsList.find(
|
||||
(t) =>
|
||||
t.display_name?.toLowerCase().trim() === mappedLower ||
|
||||
t.display_name?.toLowerCase().trim() === targetLower ||
|
||||
t.id?.toLowerCase().trim() === targetLower,
|
||||
);
|
||||
if (topicObj) {
|
||||
return topicHierarchyColor(
|
||||
{
|
||||
name: topicObj.display_name,
|
||||
field_name: topicObj.field?.display_name,
|
||||
domain_name: topicObj.domain?.display_name,
|
||||
field_id: topicObj.field?.id,
|
||||
domain_id: topicObj.domain?.id,
|
||||
id: topicObj.id,
|
||||
},
|
||||
variant,
|
||||
);
|
||||
}
|
||||
|
||||
const match = all.find(
|
||||
(e) =>
|
||||
e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
|
||||
mappedLower ||
|
||||
e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
|
||||
targetLower ||
|
||||
e.llm_keyword?.keyword?.toLowerCase().trim() === targetLower,
|
||||
e.llm_keyword?.keyword?.toLowerCase().trim() === targetLower ||
|
||||
e.llm_keyword?.keyword?.toLowerCase().trim() === mappedLower,
|
||||
);
|
||||
|
||||
if (match && match.topic_mapping?.topic) {
|
||||
return topicHierarchyColor({
|
||||
name: match.topic_mapping.topic.display_name,
|
||||
field_name: match.topic_mapping.topic.field?.display_name,
|
||||
domain_name: match.topic_mapping.topic.domain?.display_name,
|
||||
field_id: match.topic_mapping.topic.field?.id,
|
||||
domain_id: match.topic_mapping.topic.domain?.id,
|
||||
id: match.topic_mapping.topic.id,
|
||||
});
|
||||
return topicHierarchyColor(
|
||||
{
|
||||
name: match.topic_mapping.topic.display_name,
|
||||
field_name: match.topic_mapping.topic.field?.display_name,
|
||||
domain_name: match.topic_mapping.topic.domain?.display_name,
|
||||
field_id: match.topic_mapping.topic.field?.id,
|
||||
domain_id: match.topic_mapping.topic.domain?.id,
|
||||
id: match.topic_mapping.topic.id,
|
||||
},
|
||||
variant,
|
||||
);
|
||||
}
|
||||
return topicHierarchyColor({ name: mapped });
|
||||
return topicHierarchyColor({ name: mapped }, variant);
|
||||
}
|
||||
|
||||
readonly boundGetTopicColor = this.getTopicColor.bind(this);
|
||||
@@ -530,14 +552,23 @@ export class UniTrendParentComponent implements OnInit {
|
||||
if (!res || !res.series || res.series.length === 0) return false;
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
const mapped = this.getMappedTopic(topic).toLowerCase().trim();
|
||||
const topicLower = topic.toLowerCase().trim();
|
||||
const mappedLower = this.getMappedTopic(topic).toLowerCase().trim();
|
||||
|
||||
return !res.series.some((s) => {
|
||||
const yearlyList =
|
||||
s.topic_data?.[topic] ||
|
||||
s.topic_data?.[mapped] ||
|
||||
Object.values(s.topic_data || {})[0];
|
||||
if (!yearlyList) return false;
|
||||
if (!s.topic_data) return false;
|
||||
const matchingKey = Object.keys(s.topic_data).find((key) => {
|
||||
const kLower = key.toLowerCase().trim();
|
||||
return (
|
||||
kLower === topicLower ||
|
||||
kLower === mappedLower ||
|
||||
(kLower.startsWith('news_topic_') &&
|
||||
kLower.slice('news_topic_'.length) === topicLower)
|
||||
);
|
||||
});
|
||||
if (!matchingKey) return false;
|
||||
const yearlyList = s.topic_data[matchingKey];
|
||||
if (!yearlyList || !Array.isArray(yearlyList)) return false;
|
||||
const total = yearlyList
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((sum, item) => sum + (item.raw || 0), 0);
|
||||
@@ -545,6 +576,12 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
findFirstNonEmptyTopic(topics: string[]): string {
|
||||
if (!topics || topics.length === 0) return '';
|
||||
const nonEmpties = topics.filter((t) => !this.isTopicEmpty(t));
|
||||
return nonEmpties.length > 0 ? nonEmpties[0] : topics[0] || '';
|
||||
}
|
||||
|
||||
isVisible(id: string): boolean {
|
||||
return this.entityVisibilityMap().get(id) !== false;
|
||||
}
|
||||
@@ -666,6 +703,25 @@ export class UniTrendParentComponent implements OnInit {
|
||||
);
|
||||
|
||||
const resolveEntityName = (s: TrendSeries): string => {
|
||||
let rawName = s.entity_name || '';
|
||||
if (rawName.startsWith('news_topic_')) {
|
||||
rawName = rawName.slice('news_topic_'.length);
|
||||
}
|
||||
if (
|
||||
rawName.startsWith('http://') ||
|
||||
rawName.startsWith('https://') ||
|
||||
rawName.includes('openalex.org/topics/')
|
||||
) {
|
||||
const mapped = this.getMappedTopic(rawName);
|
||||
if (mapped && !mapped.startsWith('http')) {
|
||||
return mapped;
|
||||
}
|
||||
const match = this.state?.topics()?.find((t) => t.id === rawName);
|
||||
if (match?.display_name) {
|
||||
return match.display_name;
|
||||
}
|
||||
}
|
||||
|
||||
const cId = cleanId(s.entity_id);
|
||||
|
||||
if (s.entity_type === 'institution') {
|
||||
@@ -754,8 +810,16 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
// Preserve existing keys as well
|
||||
Object.assign(newTopicData, s.topic_data);
|
||||
// Preserve extra keys only if they are not raw URIs
|
||||
Object.entries(s.topic_data).forEach(([rk, val]) => {
|
||||
if (
|
||||
!rk.startsWith('http://') &&
|
||||
!rk.startsWith('https://') &&
|
||||
!newTopicData[rk]
|
||||
) {
|
||||
newTopicData[rk] = val;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...s,
|
||||
@@ -873,10 +937,10 @@ export class UniTrendParentComponent implements OnInit {
|
||||
if (resolved.topics && resolved.topics.length > 0) {
|
||||
this.selectedTrendTopics.set(resolved.topics);
|
||||
this.fetchedTopics.set([...resolved.topics]);
|
||||
const firstNonEmpty = resolved.topics.find(
|
||||
(t: string) => !this.isTopicEmpty(t),
|
||||
);
|
||||
const targetTopic = firstNonEmpty || resolved.topics[0];
|
||||
const targetTopic =
|
||||
resolved.initialActiveTopic ||
|
||||
resolved.topics.find((t: string) => !this.isTopicEmpty(t)) ||
|
||||
resolved.topics[0];
|
||||
this.activeChartTopic.set(targetTopic);
|
||||
} else {
|
||||
this.fetchedTopics.set([...this.selectedTrendTopics()]);
|
||||
@@ -910,6 +974,14 @@ export class UniTrendParentComponent implements OnInit {
|
||||
this.fetchedAuthors.set([...this.comparisonAuthors()]);
|
||||
}
|
||||
|
||||
if (resolved.topSuggestions) {
|
||||
this.topSuggestions.set(resolved.topSuggestions);
|
||||
}
|
||||
|
||||
if (resolved.recommendedAuthors) {
|
||||
this.recommendedAuthors.set(resolved.recommendedAuthors);
|
||||
}
|
||||
|
||||
if (resolved.treemapData) {
|
||||
this.topicTreemap.set(resolved.treemapData);
|
||||
}
|
||||
@@ -953,11 +1025,20 @@ export class UniTrendParentComponent implements OnInit {
|
||||
this.selectedTrendTopics.set(topics);
|
||||
}
|
||||
|
||||
// Initialize active chart topic to the first selected topic if empty or invalid
|
||||
// Initialize active chart topic to a valid non-empty topic
|
||||
const active = currentActive;
|
||||
const updatedSelections = untracked(() => this.selectedTrendTopics());
|
||||
if (!active || !updatedSelections.includes(active)) {
|
||||
this.activeChartTopic.set(updatedSelections[0] || '');
|
||||
const mappedActive = this.getMappedTopic(active);
|
||||
if (
|
||||
mappedActive &&
|
||||
updatedSelections.includes(mappedActive) &&
|
||||
!this.isTopicEmpty(mappedActive)
|
||||
) {
|
||||
this.activeChartTopic.set(mappedActive);
|
||||
} else {
|
||||
this.activeChartTopic.set(
|
||||
this.findFirstNonEmptyTopic(updatedSelections),
|
||||
);
|
||||
}
|
||||
|
||||
// If comparison list is empty, initialize default institutions/authors dynamically
|
||||
@@ -1029,7 +1110,11 @@ export class UniTrendParentComponent implements OnInit {
|
||||
: a.id.toLowerCase();
|
||||
return rawSeriesCleanIds.has(cleanA);
|
||||
});
|
||||
} else if (searchType === 'news' || searchType === 'all') {
|
||||
} else if (
|
||||
searchType === 'news' ||
|
||||
searchType === 'all' ||
|
||||
searchType === 'patents'
|
||||
) {
|
||||
allEntitiesFetched = true;
|
||||
} else {
|
||||
// publications, patents, projects
|
||||
@@ -1380,7 +1465,11 @@ export class UniTrendParentComponent implements OnInit {
|
||||
if (kws.length === 0) return;
|
||||
|
||||
const topics = this.state?.topicsList() ?? kws;
|
||||
const topic = topics[0] || kws[0] || 'Artificial Intelligence';
|
||||
const topic =
|
||||
this.findFirstNonEmptyTopic(topics) ||
|
||||
topics[0] ||
|
||||
kws[0] ||
|
||||
'Artificial Intelligence';
|
||||
|
||||
this.personsApiService
|
||||
.searchPersonsList(
|
||||
@@ -1576,7 +1665,6 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
this.isTrendLoading.set(false);
|
||||
this.updateUrlParams();
|
||||
},
|
||||
error: () => {
|
||||
this.isTrendLoading.set(false);
|
||||
@@ -1676,8 +1764,8 @@ export class UniTrendParentComponent implements OnInit {
|
||||
this.selectedTrendTopics.set(updated);
|
||||
|
||||
const active = this.activeChartTopic();
|
||||
if (!updated.includes(active)) {
|
||||
this.activeChartTopic.set(updated[0] || '');
|
||||
if (!updated.includes(active) || this.isTopicEmpty(active)) {
|
||||
this.activeChartTopic.set(this.findFirstNonEmptyTopic(updated));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1852,13 +1940,12 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
// Topic tab toggle (data reuses instantly)
|
||||
// Topic tab toggle (data reuses instantly, no router navigation to prevent chart flickering)
|
||||
updateActiveChartTopic(topic: string) {
|
||||
if (this.isTopicEmpty(topic)) {
|
||||
return;
|
||||
}
|
||||
this.activeChartTopic.set(topic);
|
||||
this.updateUrlParams();
|
||||
}
|
||||
|
||||
// Autocomplete query changes for institutions
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import {
|
||||
SortDirection,
|
||||
TopicPageV2,
|
||||
TopicSortBy,
|
||||
TopicsV2Service,
|
||||
} from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const topicQueryParamKeys = {
|
||||
query: 'query',
|
||||
page: 'page',
|
||||
size: 'size',
|
||||
sortBy: 'sortBy',
|
||||
sortDirection: 'sortDirection',
|
||||
} as const;
|
||||
|
||||
export const topicPageResolver: ResolveFn<TopicPageV2> = (route, state) => {
|
||||
const query = route.queryParamMap.get(topicQueryParamKeys.query) || undefined;
|
||||
const page = Number(route.queryParamMap.get(topicQueryParamKeys.page) ?? '0');
|
||||
const size = Number(
|
||||
route.queryParamMap.get(topicQueryParamKeys.size) ?? '10',
|
||||
);
|
||||
const sortBy: TopicSortBy =
|
||||
(route.queryParamMap.get(topicQueryParamKeys.sortBy) as TopicSortBy) ??
|
||||
TopicSortBy.WorksCount;
|
||||
const sortDirection =
|
||||
(route.queryParamMap.get(
|
||||
topicQueryParamKeys.sortDirection,
|
||||
) as SortDirection) ?? SortDirection.Desc;
|
||||
|
||||
return inject(TopicsV2Service).searchTopics(
|
||||
query,
|
||||
page,
|
||||
size,
|
||||
sortBy,
|
||||
sortDirection,
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { Topic, TopicsV2Service } from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const topicResolver: ResolveFn<Topic> = (route, state) => {
|
||||
const topicId = route.paramMap.get('topicId');
|
||||
if (!topicId) {
|
||||
throw new Error('Topic ID is required');
|
||||
}
|
||||
|
||||
return inject(TopicsV2Service).getTopicById(topicId);
|
||||
};
|
||||
@@ -1,8 +1,13 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { catchError, of, Observable, map } from 'rxjs';
|
||||
import { TrendResponse, UniversityRankingsService } from '../api';
|
||||
import { catchError, of, Observable, map, forkJoin } from 'rxjs';
|
||||
import {
|
||||
TrendResponse,
|
||||
UniversityRankingsService,
|
||||
PersonsService,
|
||||
} from '../api';
|
||||
import { SearchResultsStateService } from '../modules/keywords-search/search-results/search-results-state.service';
|
||||
import { CredentialService } from '../shared/services/credential.service';
|
||||
|
||||
export interface CompareItem {
|
||||
id: string;
|
||||
@@ -19,6 +24,9 @@ export interface UniTrendResolvedData {
|
||||
countries: CompareItem[];
|
||||
regions: CompareItem[];
|
||||
authors: CompareItem[];
|
||||
initialActiveTopic?: string;
|
||||
topSuggestions?: any[];
|
||||
recommendedAuthors?: any[];
|
||||
treemapNode?: string | null;
|
||||
}
|
||||
|
||||
@@ -28,11 +36,18 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
): Observable<UniTrendResolvedData> => {
|
||||
const params = route.queryParamMap;
|
||||
const searchState = inject(SearchResultsStateService, { optional: true });
|
||||
const credentialService = inject(CredentialService, { optional: true });
|
||||
|
||||
const searchType = params.get('search_type') || 'publications';
|
||||
const fuzzy = params.get('fuzzy') !== 'false';
|
||||
const treemapNode = params.get('treemapNode');
|
||||
|
||||
// Primary institution from user token / credential service
|
||||
const primaryInstId =
|
||||
credentialService?.effectiveInstitutionId() || 'I62318514';
|
||||
const primaryInstName =
|
||||
credentialService?.organizationName() || 'Universität Duisburg-Essen';
|
||||
|
||||
// Extract keywords & topics
|
||||
let keywords = params.getAll('keyword');
|
||||
if (keywords.length === 0) {
|
||||
@@ -79,9 +94,17 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
const cleanId = parts[0].includes('/')
|
||||
? parts[0].split('/').pop() || parts[0]
|
||||
: parts[0];
|
||||
return { id: cleanId, name: parts[1] || cleanId };
|
||||
const isPrimary =
|
||||
cleanId.toLowerCase() === primaryInstId.toLowerCase() ||
|
||||
primaryInstId.toLowerCase().includes(cleanId.toLowerCase());
|
||||
const name = parts[1] || (isPrimary ? primaryInstName : parts[0]);
|
||||
return { id: cleanId, name };
|
||||
});
|
||||
|
||||
if (parsedInstitutions.length === 0 && searchType !== 'authors') {
|
||||
parsedInstitutions.push({ id: primaryInstId, name: primaryInstName });
|
||||
}
|
||||
|
||||
const countryParams = params.getAll('countries');
|
||||
const parsedCountries: CompareItem[] = countryParams.map((c) => {
|
||||
const parts = c.split('|');
|
||||
@@ -103,15 +126,22 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
const instIds =
|
||||
parsedInstitutions.length > 0
|
||||
? parsedInstitutions.map((i) => i.id)
|
||||
: ['I62318514'];
|
||||
: [primaryInstId];
|
||||
const countryIds =
|
||||
parsedCountries.length > 0 ? parsedCountries.map((c) => c.id) : ['DE'];
|
||||
const regionIds = parsedRegions.map((r) => r.id);
|
||||
const authorIds = parsedAuthors.map((a) => a.id);
|
||||
|
||||
const apiService = inject(UniversityRankingsService);
|
||||
const personsService = inject(PersonsService, { optional: true });
|
||||
|
||||
return apiService
|
||||
const primaryTopic = topics[0] || 'Artificial Intelligence';
|
||||
const countryFilter =
|
||||
parsedCountries.length > 0 ? parsedCountries[0].id : undefined;
|
||||
const regionFilter =
|
||||
parsedRegions.length > 0 ? parsedRegions[0].id : undefined;
|
||||
|
||||
const trendObs$ = apiService
|
||||
.getTrendApiInseServiceUniversityRankingsTrendGet(
|
||||
topics,
|
||||
keywords,
|
||||
@@ -122,9 +152,94 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
authorIds,
|
||||
searchType as any,
|
||||
)
|
||||
.pipe(
|
||||
catchError(() => of(null)),
|
||||
map((trendResponse) => ({
|
||||
.pipe(catchError(() => of(null)));
|
||||
|
||||
const topInstObs$ =
|
||||
searchType !== 'authors'
|
||||
? apiService
|
||||
.getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
|
||||
primaryTopic,
|
||||
regionFilter,
|
||||
countryFilter,
|
||||
6,
|
||||
)
|
||||
.pipe(catchError(() => of([])))
|
||||
: of([]);
|
||||
|
||||
const recAuthorsObs$ =
|
||||
searchType === 'authors' && personsService
|
||||
? personsService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
primaryInstId,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[primaryTopic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.pipe(
|
||||
map((res: any) => res.results || []),
|
||||
catchError(() => of([])),
|
||||
)
|
||||
: of([]);
|
||||
|
||||
return forkJoin({
|
||||
trendResponse: trendObs$,
|
||||
topSuggestions: topInstObs$,
|
||||
recommendedAuthors: recAuthorsObs$,
|
||||
}).pipe(
|
||||
map(({ trendResponse, topSuggestions, recommendedAuthors }) => {
|
||||
// Find the first topic with non-zero publication data
|
||||
let initialActiveTopic = primaryTopic;
|
||||
if (
|
||||
trendResponse?.series &&
|
||||
trendResponse.series.length > 0 &&
|
||||
topics.length > 0
|
||||
) {
|
||||
const nonEmptyTopic = topics.find((t) =>
|
||||
trendResponse.series.some((s) => {
|
||||
if (!s.topic_data) return false;
|
||||
const tLower = t.toLowerCase().trim();
|
||||
const matchingKey = Object.keys(s.topic_data).find((key) => {
|
||||
const kLower = key.toLowerCase().trim();
|
||||
return (
|
||||
kLower === tLower ||
|
||||
(kLower.startsWith('news_topic_') &&
|
||||
kLower.slice('news_topic_'.length) === tLower)
|
||||
);
|
||||
});
|
||||
if (!matchingKey) return false;
|
||||
const yearlyList = s.topic_data[matchingKey];
|
||||
if (!yearlyList || !Array.isArray(yearlyList)) return false;
|
||||
const total = yearlyList.reduce(
|
||||
(sum, item) => sum + (item.raw || 0),
|
||||
0,
|
||||
);
|
||||
return total > 0;
|
||||
}),
|
||||
);
|
||||
if (nonEmptyTopic) {
|
||||
initialActiveTopic = nonEmptyTopic;
|
||||
}
|
||||
}
|
||||
|
||||
// If in author mode and no explicit authors were passed in URL, populate default top authors
|
||||
if (
|
||||
searchType === 'authors' &&
|
||||
parsedAuthors.length === 0 &&
|
||||
recommendedAuthors?.length
|
||||
) {
|
||||
recommendedAuthors.slice(0, 3).forEach((author: any) => {
|
||||
parsedAuthors.push({
|
||||
id: author.id,
|
||||
name: author.display_name || 'Unbekannt',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
trendResponse,
|
||||
searchType,
|
||||
topics,
|
||||
@@ -134,7 +249,11 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
countries: parsedCountries,
|
||||
regions: parsedRegions,
|
||||
authors: parsedAuthors,
|
||||
initialActiveTopic,
|
||||
topSuggestions: topSuggestions as any[],
|
||||
recommendedAuthors: recommendedAuthors as any[],
|
||||
treemapNode,
|
||||
})),
|
||||
);
|
||||
};
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -78,10 +78,15 @@ export function classificationSectionColor(
|
||||
return `hsl(${normalizeHue(hue)} ${FIELD_COLOR_SATURATION}% ${FIELD_COLOR_LIGHTNESS}%)`;
|
||||
}
|
||||
|
||||
export type TopicColorVariant = 'base' | 'bg' | 'border';
|
||||
|
||||
export function topicHierarchyColor(
|
||||
topic: TopicHierarchyColorInput | undefined | null,
|
||||
variant: TopicColorVariant = 'base',
|
||||
): string {
|
||||
if (!topic) {
|
||||
if (variant === 'bg') return 'hsl(214, 80%, 95%)';
|
||||
if (variant === 'border') return 'hsl(214, 60%, 85%)';
|
||||
return 'hsl(214 82% 42%)';
|
||||
}
|
||||
|
||||
@@ -102,7 +107,14 @@ export function topicHierarchyColor(
|
||||
stableHue(fallbackIdentity);
|
||||
const hue = normalizeHue(baseHue);
|
||||
|
||||
return `hsl(${hue} ${FIELD_COLOR_SATURATION}% ${FIELD_COLOR_LIGHTNESS}%)`;
|
||||
if (variant === 'bg') {
|
||||
return `hsl(${hue}, 75%, 80%)`;
|
||||
}
|
||||
if (variant === 'border') {
|
||||
return `hsl(${hue}, 60%, 65%)`;
|
||||
}
|
||||
|
||||
return `hsl(${hue}, ${FIELD_COLOR_SATURATION}%, ${FIELD_COLOR_LIGHTNESS}%)`;
|
||||
}
|
||||
|
||||
function normalizeColorKey(
|
||||
|
||||
@@ -10,6 +10,8 @@ const RESOLVING_WORK_PAGE_FOR_KEY = 'resolvingFor';
|
||||
export const RESOLVING_WORK_PAGE_FOR = {
|
||||
PERSON: 'PERSON',
|
||||
INSTITUTION: 'INSTITUTION',
|
||||
TOPIC: 'TOPIC',
|
||||
PUBLICATION_SEARCH: 'PUBLICATION_SEARCH',
|
||||
KEYWORDS_SEARCH: 'KEYWORDS_SEARCH',
|
||||
} as const;
|
||||
|
||||
@@ -151,6 +153,48 @@ export const workPageResolver: ResolveFn<WorkPageV2> = (
|
||||
sortBy,
|
||||
sortDirection,
|
||||
);
|
||||
} else if (resolvingFor === RESOLVING_WORK_PAGE_FOR.TOPIC) {
|
||||
const topicId =
|
||||
route.parent?.paramMap.get('topicId') || route.paramMap.get('topicId');
|
||||
if (!topicId) {
|
||||
throw new Error('Topic ID is required to resolve topic works.');
|
||||
}
|
||||
const authorIds = route.queryParamMap.getAll(workQueryParamKeys.authorId);
|
||||
const institutionIds = route.queryParamMap.getAll(
|
||||
workQueryParamKeys.institutionId,
|
||||
);
|
||||
return inject(WorksV2Service).getTopicWorkPage(
|
||||
topicId,
|
||||
page,
|
||||
size,
|
||||
title,
|
||||
publicationYears,
|
||||
publicationTypes,
|
||||
authorIds,
|
||||
institutionIds,
|
||||
languages,
|
||||
sortBy,
|
||||
sortDirection,
|
||||
);
|
||||
} else if (resolvingFor === RESOLVING_WORK_PAGE_FOR.PUBLICATION_SEARCH) {
|
||||
const authorIds = route.queryParamMap.getAll(workQueryParamKeys.authorId);
|
||||
const institutionIds = route.queryParamMap.getAll(
|
||||
workQueryParamKeys.institutionId,
|
||||
);
|
||||
const topicIds = route.queryParamMap.getAll(workQueryParamKeys.topicId);
|
||||
return inject(WorksV2Service).searchWorks(
|
||||
page,
|
||||
size,
|
||||
title,
|
||||
publicationYears,
|
||||
publicationTypes,
|
||||
authorIds,
|
||||
institutionIds,
|
||||
topicIds,
|
||||
languages,
|
||||
WorkSortBy.CitedByCount,
|
||||
sortDirection,
|
||||
);
|
||||
} else {
|
||||
throw new Error(`Unknown resolvingFor value: ${resolvingFor}`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
@let author = this.author();
|
||||
|
||||
<mat-card appearance="outlined" class="card-content">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ author.display_name }}</mat-card-title>
|
||||
@if (author.last_known_institutions?.[0]?.display_name) {
|
||||
<mat-card-subtitle class="institution">
|
||||
<span>{{ author.last_known_institutions?.[0]?.display_name }}</span>
|
||||
</mat-card-subtitle>
|
||||
}
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content class="metrics">
|
||||
@if (author.works_count) {
|
||||
<div class="metric-item">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
<span>{{ author.works_count }} Publikationen</span>
|
||||
</div>
|
||||
}
|
||||
@if (author.cited_by_count) {
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span>{{ author.cited_by_count }} Zitationen</span>
|
||||
</div>
|
||||
}
|
||||
@if (author.summary_stats?.h_index) {
|
||||
<div class="metric-item">
|
||||
<mat-icon>trending_up</mat-icon>
|
||||
<span>h-Index: {{ author.summary_stats?.h_index }}</span>
|
||||
</div>
|
||||
}
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/person', stripOpenAlexId(author.id)]"
|
||||
matButton="outlined">
|
||||
<mat-icon>info</mat-icon>
|
||||
Übersicht
|
||||
</a>
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/person', stripOpenAlexId(author.id), 'publications']"
|
||||
matButton="outlined">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/person', stripOpenAlexId(author.id), 'projects']"
|
||||
matButton="outlined">
|
||||
<mat-icon>work</mat-icon>
|
||||
Projekte
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,34 @@
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.institution {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-action {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { Author } from '../../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'app-author-card',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatDividerModule,
|
||||
RouterModule,
|
||||
MatButtonModule,
|
||||
],
|
||||
templateUrl: './app-author-card.component.html',
|
||||
styleUrl: './app-author-card.component.scss',
|
||||
})
|
||||
export class AppAuthorCardComponent {
|
||||
author = input.required<Author>();
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<mat-chip
|
||||
class="author-chip"
|
||||
[appComponentTooltip]="AuthorTooltipComponent"
|
||||
[tooltipInputs]="{ authorId: rawOaAuthorId() }"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
@if (showIcon()) {
|
||||
<mat-icon class="author-icon">{{ icon() }}</mat-icon>
|
||||
}
|
||||
{{ _author()?.display_name }}
|
||||
</span>
|
||||
</mat-chip>
|
||||
@@ -0,0 +1,56 @@
|
||||
.author-chip {
|
||||
font-weight: 500;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background-color: var(--sg-surface-soft);
|
||||
border: var(--border-width) solid var(--border-color);
|
||||
}
|
||||
|
||||
:host ::ng-deep .author-chip .mat-mdc-chip-action,
|
||||
:host ::ng-deep .author-chip .mdc-evolution-chip__action {
|
||||
background-color: var(--sg-surface-soft);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
.author-icon {
|
||||
--icon-size: 1rem;
|
||||
|
||||
font-size: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
width: var(--icon-size);
|
||||
}
|
||||
|
||||
:host.is-clickable {
|
||||
::ng-deep .mdc-evolution-chip__action {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.chip-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
:host.is-mini-size {
|
||||
::ng-deep .mat-mdc-chip {
|
||||
height: 1.5rem;
|
||||
}
|
||||
|
||||
.chip-content {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 0.75rem;
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-icon {
|
||||
--icon-size: 1rem;
|
||||
|
||||
font-size: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
width: var(--icon-size);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { Author, AuthorsV2Service } from '../../../api';
|
||||
import { AppAuthorTooltipComponent } from '../app-author-tooltip/app-author-tooltip.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--border-width]': 'isSelected() ? "2px" : "1px"',
|
||||
'[style.--border-color]':
|
||||
'isSelected() ? "var(--sg-primary)" : "var(--sg-border)"',
|
||||
'[class.is-clickable]': 'isClickable()',
|
||||
'[class.is-mini-size]': 'isMiniSize()',
|
||||
},
|
||||
selector: 'app-author-chip',
|
||||
imports: [MatIconModule, MatChipsModule, ComponentTooltipDirective],
|
||||
templateUrl: './app-author-chip.component.html',
|
||||
styleUrl: './app-author-chip.component.scss',
|
||||
})
|
||||
export class AppAuthorChipComponent {
|
||||
readonly AuthorTooltipComponent = AppAuthorTooltipComponent;
|
||||
private readonly authorsService = inject(AuthorsV2Service);
|
||||
|
||||
isSelected = input<boolean>(false);
|
||||
|
||||
isClickable = input<boolean>(false);
|
||||
handleChipClick = output<Author>();
|
||||
|
||||
showIcon = input<boolean>(false);
|
||||
icon = input<string>('person');
|
||||
|
||||
author = input<Author | undefined>(undefined);
|
||||
rawOaAuthorId = computed(() => {
|
||||
return this.stripOpenAlexId(this.author()?.id);
|
||||
});
|
||||
authorId = input<string | undefined>(undefined);
|
||||
|
||||
_author = signal<Author | undefined>(undefined);
|
||||
|
||||
size = input<'normal' | 'mini'>('normal');
|
||||
isMiniSize = computed(() => this.size() === 'mini');
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const author = this.author();
|
||||
const authorId = this.authorId();
|
||||
if (!author && !authorId) {
|
||||
this._author.set(undefined);
|
||||
}
|
||||
|
||||
if (author) {
|
||||
this._author.set(author);
|
||||
} else if (authorId) {
|
||||
this.authorsService.getAuthorById(authorId).subscribe((author) => {
|
||||
this._author.set(author);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_onChipClick(event: MouseEvent | KeyboardEvent) {
|
||||
const author = this._author();
|
||||
if (this.handleChipClick && author) {
|
||||
this.handleChipClick.emit(author);
|
||||
}
|
||||
|
||||
console.log('Chip clicked:', event);
|
||||
}
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@let author = this._author();
|
||||
|
||||
@if (author) {
|
||||
<app-author-card [author]="author"/>
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Component, effect, inject, input, signal } from '@angular/core';
|
||||
import { Author, AuthorsV2Service } from '../../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { AppAuthorCardComponent } from '../app-author-card/app-author-card.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-author-tooltip',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
RouterModule,
|
||||
MatDividerModule,
|
||||
AppAuthorCardComponent,
|
||||
],
|
||||
templateUrl: './app-author-tooltip.component.html',
|
||||
styleUrl: './app-author-tooltip.component.scss',
|
||||
})
|
||||
export class AppAuthorTooltipComponent {
|
||||
private readonly authorsService = inject(AuthorsV2Service);
|
||||
|
||||
authorId = input.required<string>();
|
||||
|
||||
_author = signal<Author | undefined>(undefined);
|
||||
|
||||
_isLoading = signal<boolean>(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const authorId = this.authorId();
|
||||
if (!authorId) {
|
||||
this._author.set(undefined);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.authorsService.getAuthorById(authorId).subscribe((author) => {
|
||||
this._author.set(author);
|
||||
this._isLoading.set(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<mat-card
|
||||
class="card-content"
|
||||
appearance="outlined"
|
||||
[routerLink]="
|
||||
institution().id
|
||||
? ['/institution', stripOpenAlexId(institution().id)]
|
||||
: null
|
||||
">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ displayName() }}</mat-card-title>
|
||||
<mat-card-subtitle class="city-country"
|
||||
>{{ institution().geo?.city }},
|
||||
{{ institution().geo?.country }}</mat-card-subtitle
|
||||
>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
institution().works_count | number: undefined : 'de'
|
||||
}}
|
||||
Publikationen</span
|
||||
>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
institution().cited_by_count | number: undefined : 'de'
|
||||
}}
|
||||
Zitationen</span
|
||||
>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
stripOpenAlexId(institution().id),
|
||||
'overview',
|
||||
]"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>info</mat-icon>
|
||||
Übersicht
|
||||
</a>
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
stripOpenAlexId(institution().id),
|
||||
'publications',
|
||||
]"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
stripOpenAlexId(institution().id),
|
||||
'projects',
|
||||
]"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>work</mat-icon>
|
||||
Projekte
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,35 @@
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.city-country {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-action {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Institution } from '../../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution-card',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
RouterModule,
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
DecimalPipe
|
||||
],
|
||||
templateUrl: './app-institution-card.component.html',
|
||||
styleUrl: './app-institution-card.component.scss',
|
||||
})
|
||||
export class AppInstitutionCardComponent {
|
||||
institution = input.required<Institution>();
|
||||
|
||||
displayName = computed(() => {
|
||||
const primary = this.institution().display_name?.trim();
|
||||
if (primary && primary.length > 0) return primary;
|
||||
|
||||
const alt = this.institution().display_name_alternatives?.[0]?.trim();
|
||||
if (alt && alt.length > 0) return alt;
|
||||
|
||||
return 'Unbekannte Institution';
|
||||
});
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<mat-chip
|
||||
class="institution-chip"
|
||||
[appComponentTooltip]="AppInstitutionTooltipComponent"
|
||||
[tooltipInputs]="{ institutionId: rawOaInstitutionId() }"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
@if (showIcon()) {
|
||||
<mat-icon class="institution-icon">{{ icon() }}</mat-icon>
|
||||
}
|
||||
{{ _institution()?.display_name }}
|
||||
</span>
|
||||
</mat-chip>
|
||||
@@ -0,0 +1,48 @@
|
||||
.institution-chip {
|
||||
font-weight: 500;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background-color: var(--sg-surface-soft);
|
||||
border: var(--border-width) solid var(--border-color);
|
||||
}
|
||||
|
||||
:host ::ng-deep .institution-chip .mat-mdc-chip-action,
|
||||
:host ::ng-deep .institution-chip .mdc-evolution-chip__action {
|
||||
background-color: var(--sg-surface-soft);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
.institution-icon {
|
||||
--icon-size: 1rem;
|
||||
|
||||
font-size: var(--icon-size);
|
||||
height: var(--icon-size);
|
||||
width: var(--icon-size);
|
||||
}
|
||||
|
||||
:host.is-clickable {
|
||||
::ng-deep .mdc-evolution-chip__action {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.chip-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
:host.is-mini-size {
|
||||
::ng-deep .mat-mdc-chip {
|
||||
height: 1.5rem;
|
||||
}
|
||||
|
||||
.chip-content {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 0.75rem;
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { Institution, InstitutionsV2Service } from '../../../api';
|
||||
import { AppInstitutionTooltipComponent } from '../app-institution-tooltip/app-institution-tooltip.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--border-width]': 'isSelected() ? "2px" : "1px"',
|
||||
'[style.--border-color]':
|
||||
'isSelected() ? "var(--sg-primary)" : "var(--sg-border)"',
|
||||
'[class.is-clickable]': 'isClickable()',
|
||||
'[class.is-mini-size]': 'isMiniSize()',
|
||||
},
|
||||
selector: 'app-institution-chip',
|
||||
imports: [MatIconModule, MatChipsModule, ComponentTooltipDirective],
|
||||
templateUrl: './app-institution-chip.component.html',
|
||||
styleUrl: './app-institution-chip.component.scss',
|
||||
})
|
||||
export class AppInstitutionChipComponent {
|
||||
readonly AppInstitutionTooltipComponent = AppInstitutionTooltipComponent;
|
||||
private readonly institutionsService = inject(InstitutionsV2Service);
|
||||
|
||||
isSelected = input<boolean>(false);
|
||||
|
||||
isClickable = input<boolean>(false);
|
||||
handleChipClick = output<Institution>();
|
||||
|
||||
showIcon = input<boolean>(false);
|
||||
icon = input<string>('apartment');
|
||||
|
||||
institution = input<Institution | undefined>(undefined);
|
||||
rawOaInstitutionId = computed(() => {
|
||||
return this.stripOpenAlexId(this.institution()?.id);
|
||||
});
|
||||
institutionId = input<string | undefined>(undefined);
|
||||
|
||||
_institution = signal<Institution | undefined>(undefined);
|
||||
|
||||
size = input<'normal' | 'mini'>('normal');
|
||||
isMiniSize = computed(() => this.size() === 'mini');
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const institution = this.institution();
|
||||
const institutionId = this.institutionId();
|
||||
if (!institution && !institutionId) {
|
||||
this._institution.set(undefined);
|
||||
}
|
||||
|
||||
if (institution) {
|
||||
this._institution.set(institution);
|
||||
} else if (institutionId) {
|
||||
this.institutionsService
|
||||
.getInstitutionById2(institutionId)
|
||||
.subscribe((institution) => {
|
||||
this._institution.set(institution);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_onChipClick(event: MouseEvent | KeyboardEvent) {
|
||||
const institution = this._institution();
|
||||
if (this.isClickable() && this.handleChipClick && institution) {
|
||||
this.handleChipClick.emit(institution);
|
||||
}
|
||||
}
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
@let institution = this._institution();
|
||||
|
||||
@if (institution) {
|
||||
<app-institution-card [institution]="institution" />
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Component, effect, inject, input, signal } from '@angular/core';
|
||||
import { Institution, InstitutionsV2Service } from '../../../api';
|
||||
import { AppInstitutionCardComponent } from '../app-institution-card/app-institution-card.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution-tooltip',
|
||||
imports: [AppInstitutionCardComponent],
|
||||
templateUrl: './app-institution-tooltip.component.html',
|
||||
styleUrl: './app-institution-tooltip.component.scss',
|
||||
})
|
||||
export class AppInstitutionTooltipComponent {
|
||||
private readonly institutionsService = inject(InstitutionsV2Service);
|
||||
|
||||
institutionId = input.required<string>();
|
||||
|
||||
_institution = signal<Institution | undefined>(undefined);
|
||||
|
||||
_isLoading = signal<boolean>(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const institutionId = this.institutionId();
|
||||
if (!institutionId) {
|
||||
this._institution.set(undefined);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.institutionsService
|
||||
.getInstitutionById2(institutionId)
|
||||
.subscribe((institution) => {
|
||||
this._institution.set(institution);
|
||||
this._isLoading.set(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation
|
||||
import { MatCardContent, MatCardModule } from '@angular/material/card';
|
||||
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
||||
import { activeInstitutionPersonListQueryParams } from '../../person-list-query-params';
|
||||
import { topicQueryParamKeys } from '../../../resolvers/topic-page.resolver';
|
||||
import { SortDirection, TopicSortBy, WorkSortBy } from '../../../api';
|
||||
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
|
||||
type NavItem = {
|
||||
label: string;
|
||||
@@ -101,7 +104,33 @@ export class AppMenuComponent {
|
||||
page: 0,
|
||||
size: 10,
|
||||
sort_by: 'works_count',
|
||||
sorting_order: 'desc',
|
||||
sorting_order: SortDirection.Desc,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Publikationen',
|
||||
icon: 'menu_book',
|
||||
route: '/publications',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
[workQueryParamKeys.title]: '',
|
||||
[workQueryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.size]: 10,
|
||||
[workQueryParamKeys.sortBy]: WorkSortBy.CitedByCount,
|
||||
[workQueryParamKeys.sortDirection]: SortDirection.Desc,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Themen',
|
||||
icon: 'topic',
|
||||
route: '/topics',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
[topicQueryParamKeys.query]: '',
|
||||
[topicQueryParamKeys.page]: 0,
|
||||
[topicQueryParamKeys.size]: 10,
|
||||
[topicQueryParamKeys.sortBy]: TopicSortBy.CitedByCount,
|
||||
[topicQueryParamKeys.sortDirection]: SortDirection.Desc,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
@let work = this.work();
|
||||
|
||||
<mat-card
|
||||
class="card-content"
|
||||
appearance="outlined"
|
||||
[routerLink]="work.id ? ['/topic', stripOpenAlexId(work.id)] : null">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ work.title }}</mat-card-title>
|
||||
<mat-card-subtitle class="subtitle">
|
||||
{{ work.publication_year }} - {{ work.type | workType }} -
|
||||
{{ work.language | languageCode }}</mat-card-subtitle
|
||||
>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content class="mat-card-content">
|
||||
<div class="chips">
|
||||
@for (topic of topics(); track topic.id) {
|
||||
<app-topic-chip-2 [topic]="topic" />
|
||||
}
|
||||
@for (author of authors(); track author.id) {
|
||||
<app-author-chip [author]="author" />
|
||||
}
|
||||
</div>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<div class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span
|
||||
>{{ work.cited_by_count | number: undefined : 'de' }} Zitationen</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/publication', stripOpenAlexId(work.id)]"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
Öffnen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,50 @@
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-action {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.mat-card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { DehydratedAuthor, Work } from '../../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { WorkTypePipe } from '../../pipes/work-type.pipe';
|
||||
import { LanguageCodePipe } from '../../pipes/language-code.pipe';
|
||||
import { AppTopicChipComponent } from '../app-topic-chip/app-topic-chip.component';
|
||||
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-card',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
RouterModule,
|
||||
MatDividerModule,
|
||||
DecimalPipe,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
AppTopicChipComponent,
|
||||
AppAuthorChipComponent,
|
||||
],
|
||||
templateUrl: './app-publication-card.component.html',
|
||||
styleUrl: './app-publication-card.component.scss',
|
||||
})
|
||||
export class AppPublicationCardComponent {
|
||||
work = input.required<Work>();
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
|
||||
topics = computed(() => {
|
||||
const work = this.work();
|
||||
if (!work?.topics) {
|
||||
return [];
|
||||
}
|
||||
return work.topics;
|
||||
});
|
||||
|
||||
authors = computed<DehydratedAuthor[]>(() => {
|
||||
const work = this.work();
|
||||
if (!work?.authorships) {
|
||||
return [];
|
||||
}
|
||||
return work.authorships
|
||||
.map((authorship) => authorship.author)
|
||||
.filter((author): author is DehydratedAuthor => !!author);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
@let topic = this.topic();
|
||||
|
||||
<mat-card
|
||||
class="card-content"
|
||||
appearance="outlined"
|
||||
[routerLink]="topic.id ? ['/topic', stripOpenAlexId(topic.id)] : null">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ topic.display_name }}</mat-card-title>
|
||||
<mat-card-subtitle class="subtitle">{{ subtitle() }}</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-content>
|
||||
<p>{{ description() }}</p>
|
||||
<div class="metrics">
|
||||
<div class="metric-item">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
topic.works_count | number: undefined : 'de'
|
||||
}}
|
||||
Publikationen</span
|
||||
>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<mat-icon>format_quote</mat-icon>
|
||||
<span
|
||||
>{{
|
||||
topic.cited_by_count | number: undefined : 'de'
|
||||
}}
|
||||
Zitationen</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-card-footer>
|
||||
<mat-card-actions class="card-actions">
|
||||
<a
|
||||
class="card-action"
|
||||
[routerLink]="['/topic', stripOpenAlexId(topic.id), 'publications']"
|
||||
matButton="outlined"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
Publikationen
|
||||
</a>
|
||||
</mat-card-actions>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,49 @@
|
||||
:host {
|
||||
--topic-border: color-mix(in srgb, hsl(var(--topic-color)) 72%, #ffffff);
|
||||
--topic-background: color-mix(in srgb, hsl(var(--topic-color)) 8%, #ffffff);
|
||||
|
||||
--mat-divider-color: var(--topic-border);
|
||||
|
||||
::ng-deep .mdc-button--outlined {
|
||||
border-color: var(--topic-border) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
|
||||
background-color: var(--topic-background);
|
||||
border: 1px solid var(--topic-border);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card-action {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Topic } from '../../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--topic-color]': 'color()',
|
||||
},
|
||||
selector: 'app-topic-card',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
RouterModule,
|
||||
DecimalPipe,
|
||||
],
|
||||
templateUrl: './app-topic-card.component.html',
|
||||
styleUrl: './app-topic-card.component.scss',
|
||||
})
|
||||
export class AppTopicCardComponent {
|
||||
topic = input.required<Topic>();
|
||||
|
||||
stripOpenAlexId(id: string | null | undefined): string | undefined {
|
||||
if (!id) {
|
||||
return undefined;
|
||||
}
|
||||
return id.replace('https://openalex.org/', '');
|
||||
}
|
||||
|
||||
subtitle = computed(() => {
|
||||
return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`;
|
||||
});
|
||||
|
||||
description = computed(() => {
|
||||
return this.topic().description || 'Keine Beschreibung verfügbar';
|
||||
});
|
||||
|
||||
color = computed<string>(() => {
|
||||
const topic = this.topic();
|
||||
return topicHierarchyColor({
|
||||
id: topic.id ?? undefined,
|
||||
name: topic.display_name ?? undefined,
|
||||
field_id: topic.field?.id ?? undefined,
|
||||
field_name: topic.field?.display_name ?? undefined,
|
||||
domain_id: topic.domain?.id ?? undefined,
|
||||
domain_name: topic.domain?.display_name ?? undefined,
|
||||
})
|
||||
.replace('hsl(', '')
|
||||
.replace(')', '');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<mat-chip
|
||||
class="topic-chip"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="{ topicId: rawOaTopicId() }"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
@if (showIcon()) {
|
||||
<mat-icon>{{ icon() }}</mat-icon>
|
||||
}
|
||||
{{ topic().display_name }}
|
||||
</span>
|
||||
</mat-chip>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user