Compare commits
44
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1a6c32e0c | ||
|
|
cf5a3e7d3d | ||
|
|
89f45082fb | ||
|
|
0ad6ac70ff | ||
|
|
e8e0decc6c | ||
|
|
57aaf77162 | ||
|
|
07ce24143b | ||
|
|
bf5e065520 | ||
|
|
08178e74d2 | ||
|
|
c66fcff906 | ||
|
|
b0dd0e509d | ||
|
|
719da6e921 | ||
|
|
e4b3d0a9a9 | ||
|
|
c0e231a32b | ||
|
|
af9f9a25da | ||
|
|
0a465bc7e1 | ||
|
|
aec735e09e | ||
|
|
9ce6d5f26e | ||
|
|
f4b4fb0562 | ||
|
|
aa22fad67d | ||
|
|
548bb4ce70 | ||
|
|
b6871b3618 | ||
|
|
fe5e816551 | ||
|
|
20d2a281b1 | ||
|
|
e2ae0c660a | ||
|
|
9e8ae16597 | ||
|
|
e5284a79c9 | ||
|
|
79dad5dfb0 | ||
|
|
a511c16fb1 | ||
|
|
98a1214a4d | ||
|
|
be459c45cf | ||
|
|
328ef2938c | ||
|
|
21f3f49078 | ||
|
|
882ad3b8cf | ||
|
|
d8b7d8bc2e | ||
|
|
c1692535a5 | ||
|
|
af0e326747 | ||
|
|
6cdaa9738a | ||
|
|
1e5d0c4517 | ||
|
|
127f5ca287 | ||
|
|
f51b775fd9 | ||
|
|
0015b92591 | ||
|
|
37e1f1811f | ||
|
|
daa4f79ea0 |
@@ -261,11 +261,10 @@ async def search(
|
||||
payload["sort"] = sort
|
||||
if aggs is not None:
|
||||
payload["aggs"] = aggs
|
||||
if track_total_hits:
|
||||
payload["track_total_hits"] = True
|
||||
if highlight is not None:
|
||||
payload["highlight"] = highlight
|
||||
|
||||
|
||||
payload["track_total_hits"] = True # always track total hits for accurate pagination and counts
|
||||
if len(payload) == 0:
|
||||
raise ValueError(
|
||||
"At least one of 'query', 'body', 'source', 'size', 'offset', 'sort', 'aggs' must be provided"
|
||||
|
||||
@@ -52,6 +52,9 @@ class ESIndex(StrEnum):
|
||||
OPENALEX_CONTINENTS = "openalex-continents"
|
||||
OPENALEX_TOPICS = "openalex-topics"
|
||||
OPENALEX_TOPIC_VECTORS = "topicvectors"
|
||||
OPENALEX_DOMAINS = "openalex-domains"
|
||||
OPENALEX_FIELDS = "openalex-fields"
|
||||
OPENALEX_SUBFIELDS = "openalex-subfields"
|
||||
|
||||
EPO_INDEX = "epo_index_1.0"
|
||||
USPTO_INDEX = "uspto_patents_3.0"
|
||||
|
||||
@@ -27,7 +27,6 @@ TOPIC_NUM_CANDIDATES = 100
|
||||
TOPIC_SIMILARITY = 0.5
|
||||
|
||||
TOPICS_INDEX = "aktuell_openalex_topics"
|
||||
TOPICS_INDEX_MAX_PAIRS = 100
|
||||
|
||||
_SESSION_TOPIC_CACHE: dict[str, list] = {}
|
||||
|
||||
@@ -48,6 +47,11 @@ RELATED_BLOCK_SIZE = 5
|
||||
RELATED_TOPIC_K = 1
|
||||
EXACT_ID_CAP = 1000
|
||||
|
||||
KEYWORD_SEARCH_FIELDS = ["maintitle^3", "intro_content^2", "tags^2", "full_content"]
|
||||
KEYWORD_SEARCH_SCAN_CAP = 50000
|
||||
KEYWORD_SEARCH_ID_CAP = 2000
|
||||
TOPIC_DOCS_PER_ARTICLE = 25
|
||||
|
||||
|
||||
async def get_news_page(
|
||||
page: int,
|
||||
@@ -127,6 +131,206 @@ async def search_news(
|
||||
return news_page
|
||||
|
||||
|
||||
async def search_news_by_keywords(
|
||||
keywords: list | None = None,
|
||||
topic_ids: list | None = None,
|
||||
filter_topic_ids: list | None = None,
|
||||
fuzzy: bool = False,
|
||||
page: int = 1,
|
||||
page_size: int = 10,
|
||||
year_from: int | None = None,
|
||||
year_to: int | None = None,
|
||||
relevance_values: list | None = None,
|
||||
sort_order: str | None = None,
|
||||
) -> NewsPage:
|
||||
"""Searches the news for the keywords of a keywords-search run.
|
||||
|
||||
`fuzzy` resolves the keywords to OpenAlex topics (via the aktuell_openalex_topics index),
|
||||
otherwise the raw keywords are matched as phrases against the article
|
||||
text. The individual keywords are OR-ed rather than AND-ed.
|
||||
An article carries at most KEYWORD_LIMIT keywords, so requiring all of them
|
||||
would leave every multi-keyword search empty.
|
||||
Articles matching more of them simply rank higher.
|
||||
|
||||
A fuzzy search without any resolved topic ids falls back to the raw
|
||||
keywords. Once there are topic ids the fallback is off: a topic search that matches no article
|
||||
stays empty instead of silently returning keyword hits.
|
||||
|
||||
By default results stay ranked by match strength (Elasticsearch's
|
||||
`_score`). Passing `sort_order` ('asc'/'desc') overrides that with a
|
||||
plain date sort, same as the plain news list.
|
||||
"""
|
||||
wanted_topic_ids: set = set()
|
||||
if fuzzy:
|
||||
wanted_topic_ids = {
|
||||
topic_id
|
||||
for topic_id in (topic_ids or []) + (filter_topic_ids or [])
|
||||
if topic_id
|
||||
}
|
||||
|
||||
if wanted_topic_ids:
|
||||
should = await _topic_id_should_clauses(wanted_topic_ids)
|
||||
else:
|
||||
should = _keyword_should_clauses(keywords)
|
||||
|
||||
if not should:
|
||||
return _empty_page(page, page_size)
|
||||
|
||||
clauses = await _filter_clauses(year_from, year_to, relevance_values)
|
||||
query = {
|
||||
"bool": {
|
||||
"should": should,
|
||||
"minimum_should_match": 1,
|
||||
"filter": clauses,
|
||||
}
|
||||
}
|
||||
|
||||
highlight = {
|
||||
"fields": {"full_content": {"fragment_size": 200, "number_of_fragments": 1}},
|
||||
"pre_tags": ["<em>"],
|
||||
"post_tags": ["</em>"],
|
||||
"encoder": "html",
|
||||
}
|
||||
|
||||
sort = [{"date_full": sort_order}] if sort_order in ("asc", "desc") else None
|
||||
|
||||
response = await _run_search(
|
||||
query=query,
|
||||
source=["date", "maintitle", "author", "url", "intro_content", "full_content"],
|
||||
size=page_size,
|
||||
offset=(page - 1) * page_size,
|
||||
sort=sort,
|
||||
highlight=None if wanted_topic_ids else highlight,
|
||||
)
|
||||
|
||||
news_page = await _build_page(response, page, page_size)
|
||||
await _attach_topics(news_page.results)
|
||||
|
||||
return news_page
|
||||
|
||||
|
||||
def _keyword_should_clauses(keywords: list | None) -> list:
|
||||
return [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword.strip(),
|
||||
"fields": KEYWORD_SEARCH_FIELDS,
|
||||
"type": "phrase",
|
||||
}
|
||||
}
|
||||
for keyword in (keywords or [])
|
||||
if keyword and keyword.strip()
|
||||
]
|
||||
|
||||
|
||||
async def _topic_id_should_clauses(topic_ids: set) -> list:
|
||||
"""Turns matched OpenAlex topics into id clauses, boosted by hit count.
|
||||
|
||||
Articles that match several of the searched topics get a higher boost, so
|
||||
Elasticsearch ranks them above articles that only match one.
|
||||
"""
|
||||
topics_per_article = await _news_ids_by_topic_ids(topic_ids)
|
||||
if not topics_per_article:
|
||||
return []
|
||||
|
||||
ranked = sorted(topics_per_article.items(), key=lambda item: -len(item[1]))
|
||||
ids_by_hit_count: dict[int, list] = {}
|
||||
for news_id, matched_topics in ranked[:KEYWORD_SEARCH_ID_CAP]:
|
||||
ids_by_hit_count.setdefault(len(matched_topics), []).append(news_id)
|
||||
|
||||
return [
|
||||
{"ids": {"values": news_ids, "boost": float(hit_count)}}
|
||||
for hit_count, news_ids in ids_by_hit_count.items()
|
||||
]
|
||||
|
||||
|
||||
async def _news_ids_by_topic_ids(topic_ids: set) -> dict:
|
||||
"""Returns news_id -> set of searched topic ids the article was mapped to."""
|
||||
query = {"terms": {"topic_matches.topic_id.keyword": sorted(topic_ids)}}
|
||||
|
||||
topics_per_article: dict[str, set] = {}
|
||||
scanned = 0
|
||||
try:
|
||||
async for hit in elasticsearch.scan(
|
||||
index=TOPICS_INDEX,
|
||||
query=query,
|
||||
source=["news_id", "topic_matches.topic_id"],
|
||||
cluster="inse",
|
||||
):
|
||||
scanned += 1
|
||||
source = hit.get("_source", {})
|
||||
news_id = source.get("news_id")
|
||||
if news_id:
|
||||
matched = topics_per_article.setdefault(news_id, set())
|
||||
for match in source.get("topic_matches") or []:
|
||||
topic_id = match.get("topic_id")
|
||||
if topic_id in topic_ids:
|
||||
matched.add(topic_id)
|
||||
if scanned >= KEYWORD_SEARCH_SCAN_CAP:
|
||||
logger.warning(
|
||||
f"Topic lookup hit the scan cap of {KEYWORD_SEARCH_SCAN_CAP} documents."
|
||||
)
|
||||
break
|
||||
except Exception:
|
||||
logger.exception("Topic lookup for the keyword news search failed.")
|
||||
return {}
|
||||
|
||||
return {news_id: matched for news_id, matched in topics_per_article.items() if matched}
|
||||
|
||||
|
||||
async def _attach_topics(articles: list) -> None:
|
||||
news_ids = [article.id for article in articles if article.id]
|
||||
if not news_ids:
|
||||
return
|
||||
|
||||
topics_per_article = await _topics_for_news_ids(news_ids)
|
||||
for article in articles:
|
||||
article.topics = topics_per_article.get(article.id, [])
|
||||
|
||||
|
||||
async def _topics_for_news_ids(news_ids: list) -> dict[str, list[MatchedTopic]]:
|
||||
"""Reads the indexed OpenAlex topic matches for the given articles."""
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=TOPICS_INDEX,
|
||||
query={"terms": {"news_id.keyword": news_ids}},
|
||||
source=["news_id", "keyword", "topic_matches"],
|
||||
size=min(len(news_ids) * TOPIC_DOCS_PER_ARTICLE, 10000),
|
||||
cluster="inse",
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Batched topic lookup for the news result page failed.")
|
||||
return {}
|
||||
|
||||
topics_per_article: dict[str, list[MatchedTopic]] = {}
|
||||
seen_per_article: dict[str, set] = {}
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
news_id = source.get("news_id")
|
||||
if not news_id:
|
||||
continue
|
||||
keyword = source.get("keyword")
|
||||
matched = topics_per_article.setdefault(news_id, [])
|
||||
seen_ids = seen_per_article.setdefault(news_id, set())
|
||||
for match in source.get("topic_matches") or []:
|
||||
topic_id = match.get("topic_id")
|
||||
if not topic_id or topic_id in seen_ids:
|
||||
continue
|
||||
seen_ids.add(topic_id)
|
||||
matched.append(
|
||||
MatchedTopic(
|
||||
id=topic_id,
|
||||
display_name=match.get("topic_display_name"),
|
||||
subfield_name=match.get("subfield"),
|
||||
field_name=match.get("field"),
|
||||
domain_name=match.get("domain"),
|
||||
source_keyword=keyword,
|
||||
)
|
||||
)
|
||||
|
||||
return topics_per_article
|
||||
|
||||
|
||||
async def get_news_by_author(
|
||||
author_id: str,
|
||||
page: int = 1,
|
||||
@@ -321,7 +525,7 @@ async def _get_article_keywords(
|
||||
|
||||
|
||||
async def _get_article_topics(news_id: str, keywords: list) -> list:
|
||||
indexed = await get_article_topics_from_index(news_id)
|
||||
indexed = (await _topics_for_news_ids([news_id])).get(news_id, [])
|
||||
if indexed:
|
||||
return indexed
|
||||
|
||||
@@ -336,42 +540,6 @@ async def _get_article_topics(news_id: str, keywords: list) -> list:
|
||||
return topics
|
||||
|
||||
|
||||
async def get_article_topics_from_index(news_id: str) -> list:
|
||||
try:
|
||||
response = await elasticsearch.search(
|
||||
index=TOPICS_INDEX,
|
||||
query={"term": {"news_id.keyword": news_id}},
|
||||
source=["keyword", "topic_matches"],
|
||||
size=TOPICS_INDEX_MAX_PAIRS,
|
||||
cluster="inse",
|
||||
)
|
||||
except Exception:
|
||||
logger.exception(f"Topic-index lookup for {news_id} failed.")
|
||||
return []
|
||||
|
||||
matched = []
|
||||
seen_ids = set()
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
keyword = source.get("keyword")
|
||||
for match in source.get("topic_matches") or []:
|
||||
topic_id = match.get("topic_id")
|
||||
if not topic_id or topic_id in seen_ids:
|
||||
continue
|
||||
seen_ids.add(topic_id)
|
||||
matched.append(
|
||||
MatchedTopic(
|
||||
id=topic_id,
|
||||
display_name=match.get("topic_display_name"),
|
||||
subfield_name=match.get("subfield"),
|
||||
field_name=match.get("field"),
|
||||
domain_name=match.get("domain"),
|
||||
source_keyword=keyword,
|
||||
)
|
||||
)
|
||||
return matched
|
||||
|
||||
|
||||
def _normalize_keywords(candidates: list) -> list:
|
||||
"""Trims, dedups (case-insensitive) and caps the keywords from the LLM."""
|
||||
seen = set()
|
||||
@@ -516,7 +684,7 @@ async def _get_postproc_labels(news_id: str) -> tuple[bool | None, list, list, s
|
||||
return relevant, authors, keywords, hit.get("_id")
|
||||
|
||||
|
||||
async def _run_search(query: dict, source: list, size: int, offset: int, sort, highlight: dict = None) -> dict:
|
||||
async def _run_search(query: dict, source: list, size: int, offset: int, sort, highlight: dict | None = None) -> dict:
|
||||
try:
|
||||
return await elasticsearch.search(
|
||||
index="aktuell",
|
||||
|
||||
@@ -8,17 +8,6 @@ class NewsKeywords(BaseModel):
|
||||
keywords: list[str] = Field(description="The extracted keywords from the article.")
|
||||
|
||||
|
||||
class NewsArticle(BaseModel):
|
||||
id: str
|
||||
date: str | None = None
|
||||
maintitle: str | None = None
|
||||
author: str | None = None
|
||||
url: str | None = None
|
||||
relevant: bool | None = None
|
||||
snippet: str | None = None
|
||||
related: bool | None = None
|
||||
|
||||
|
||||
class MentionedPerson(BaseModel):
|
||||
name: str
|
||||
is_ude: bool = False
|
||||
@@ -34,6 +23,18 @@ class MatchedTopic(BaseModel):
|
||||
source_keyword: str | None = None
|
||||
|
||||
|
||||
class NewsArticle(BaseModel):
|
||||
id: str
|
||||
date: str | None = None
|
||||
maintitle: str | None = None
|
||||
author: str | None = None
|
||||
url: str | None = None
|
||||
relevant: bool | None = None
|
||||
snippet: str | None = None
|
||||
related: bool | None = None
|
||||
topics: list[MatchedTopic] | None = None
|
||||
|
||||
|
||||
class NewsArticleDetail(NewsArticle):
|
||||
full_content: str | None = None
|
||||
relevant: bool | None = None
|
||||
|
||||
@@ -100,6 +100,68 @@ async def search_news(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/keyword/search",
|
||||
operation_id="getNewsByKeywords",
|
||||
response_model=NewsPage,
|
||||
response_model_exclude_none=True,
|
||||
summary="Searches news articles by the keywords or matched topics of a keywords search.",
|
||||
tags=[Tags.NEWS],
|
||||
)
|
||||
async def search_news_by_keywords(
|
||||
keywords: Annotated[
|
||||
list[str] | None, Query(description="Raw keywords to match against title/content.")
|
||||
] = None,
|
||||
topic_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(alias="topicIds", description="OpenAlex topic ids the keywords resolved to."),
|
||||
] = None,
|
||||
filter_topic_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(alias="filterTopicIds", description="Additional topic ids to narrow the results by."),
|
||||
] = None,
|
||||
fuzzy: Annotated[
|
||||
bool,
|
||||
Query(description="Search by resolved topics if True, otherwise by raw keywords."),
|
||||
] = False,
|
||||
page: Annotated[
|
||||
int, Query(description="Page number (1-based).", ge=1)
|
||||
] = 1,
|
||||
page_size: Annotated[
|
||||
int, Query(alias="pageSize", description="Articles per page.", ge=1, le=100)
|
||||
] = 10,
|
||||
relevance: Annotated[
|
||||
str | None, Query(description="Comma-separated relevance filter: 'relevant', 'not_relevant'.")
|
||||
] = None,
|
||||
year_from: Annotated[
|
||||
int | None, Query(alias="yearFrom", description="Earliest publication year (inclusive).", ge=0)
|
||||
] = None,
|
||||
year_to: Annotated[
|
||||
int | None, Query(alias="yearTo", description="Latest publication year (inclusive).", ge=0)
|
||||
] = None,
|
||||
sort_order: Annotated[
|
||||
str | None,
|
||||
Query(
|
||||
alias="sortOrder",
|
||||
description="Overrides relevance ranking with a date sort: 'desc' (newest first) or 'asc' (oldest first).",
|
||||
pattern="^(asc|desc)$",
|
||||
),
|
||||
] = None,
|
||||
):
|
||||
return await logic.search_news_by_keywords(
|
||||
keywords=keywords or [],
|
||||
topic_ids=topic_ids or [],
|
||||
filter_topic_ids=filter_topic_ids or [],
|
||||
fuzzy=fuzzy,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
sort_order=sort_order,
|
||||
year_from=year_from,
|
||||
year_to=year_to,
|
||||
relevance_values=_parse_relevance(relevance),
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/by-author",
|
||||
operation_id="getNewsByAuthor",
|
||||
|
||||
@@ -9,41 +9,6 @@ from inse.projects.model import EuCordisProjectType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def is_projects_access_forbidden(
|
||||
access_token_metadata: AccessTokenMetadata,
|
||||
raw_oa_institution_id: str | None,
|
||||
raw_oa_author_id: str | None,
|
||||
) -> bool:
|
||||
"""
|
||||
Determines if access to projects is forbidden based on the provided access token metadata
|
||||
and the raw OpenAlex institution and author IDs.
|
||||
|
||||
Args:
|
||||
access_token_metadata (AccessTokenMetadata): Metadata from the access token.
|
||||
raw_oa_institution_id (str | None): The raw OpenAlex institution ID.
|
||||
raw_oa_author_id (str | None): The raw OpenAlex author ID.
|
||||
|
||||
Returns:
|
||||
bool: True if access is forbidden, False otherwise.
|
||||
"""
|
||||
effective_institution_id = access_token_metadata.effective_institution_id
|
||||
|
||||
if raw_oa_institution_id and effective_institution_id != raw_oa_institution_id:
|
||||
return True
|
||||
|
||||
if raw_oa_author_id:
|
||||
authors_profile = await author_service.get_author_by_id(raw_oa_author_id)
|
||||
if not authors_profile:
|
||||
return True # Author not found, access forbidden
|
||||
|
||||
authors_last_known_institution_ids = [inst.id.split("/")[-1] for inst in authors_profile.last_known_institutions]
|
||||
print(f"Author's last known institution IDs: {authors_last_known_institution_ids}")
|
||||
if effective_institution_id not in authors_last_known_institution_ids:
|
||||
return True # Effective institution ID does not match any of the author's last known institutions
|
||||
|
||||
return False
|
||||
|
||||
async def get_dfg_author_names_by_ids(author_ids: list[int]) -> list[str] | None:
|
||||
try:
|
||||
body = {
|
||||
|
||||
@@ -648,7 +648,7 @@ async def search_dfg_projects(
|
||||
# person["institute_name_en"] = institute.get("institute_name_en")
|
||||
# person["address_country_de"] = institute.get("address_country_de")
|
||||
# person["address_country_en"] = institute.get("address_country_en")
|
||||
print("ENRIECHED",source.get("institutions", []))
|
||||
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
def _complete_response_to_dfg_project_page(
|
||||
@@ -1151,11 +1151,13 @@ async def search_all_projects(
|
||||
page = projects_filtering_properties.page
|
||||
offset = page * size
|
||||
response = await elasticsearch.search(
|
||||
|
||||
index=index,
|
||||
size=size,
|
||||
offset=offset,
|
||||
query=query,
|
||||
sort=sort,
|
||||
track_total_hits=True,
|
||||
)
|
||||
return _response_to_funding_project_page(response=response, page=page, size=size)
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@ from inse.auth.service import CurrentUserAccessTokenPayloadDep
|
||||
from inse.institutions.institutions_search_client import (
|
||||
InstitutionsSearchClient,
|
||||
)
|
||||
from inse.projects.logic import (
|
||||
is_projects_access_forbidden
|
||||
)
|
||||
from inse.institutions.router import get_institutions_search_client
|
||||
from inse.models.bund_project_details import BundProjectDetails
|
||||
from inse.models.dfg_project_details import DfgProjectDetails
|
||||
@@ -33,6 +30,7 @@ from inse.projects.model import (
|
||||
SortDirection,
|
||||
)
|
||||
from inse.tags import Tags
|
||||
from inse.auth.service import can_fetch_gdpr_relevant_data
|
||||
from fastapi import HTTPException as HttpException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -146,12 +144,13 @@ async def get_dfg_projects(
|
||||
sort_direction,
|
||||
fuzzy,
|
||||
)
|
||||
is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, author_id)
|
||||
if is_forbidden:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
if (author_id or raw_oa_institution_id):
|
||||
is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = author_id, raw_oa_institution_id = raw_oa_institution_id)
|
||||
if not is_allowed:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
return await projects_service.get_dfg_projects(
|
||||
institutions_search_client=institutions_search_client,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
@@ -266,14 +265,14 @@ async def search_bund_projects(
|
||||
Query(description="Use OpenAlex topic-id resolution if true, otherwise raw keyword search."),
|
||||
] = False,
|
||||
) -> BundProjectPage:
|
||||
is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, None)
|
||||
if is_forbidden:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
if (raw_oa_institution_id):
|
||||
is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = None, raw_oa_institution_id = raw_oa_institution_id)
|
||||
if not is_allowed:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
return await projects_service.search_bund_projects_with_filters(
|
||||
access_token_metadata=access_token_metadata,
|
||||
institutions_search_client=institutions_search_client,
|
||||
executing_agency=executing_agency,
|
||||
funding_arts=funding_arts,
|
||||
@@ -451,12 +450,13 @@ async def search_eu_cordis_projects_endpoint(
|
||||
sort_direction,
|
||||
fuzzy,
|
||||
)
|
||||
is_forbidden = await is_projects_access_forbidden(access_token_metadata, raw_oa_institution_id, author_id)
|
||||
if is_forbidden:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
if (author_id or raw_oa_institution_id):
|
||||
is_allowed = await can_fetch_gdpr_relevant_data(access_token = access_token_metadata, raw_oa_author_id = author_id, raw_oa_institution_id = raw_oa_institution_id)
|
||||
if not is_allowed:
|
||||
raise HttpException(
|
||||
status_code=403,
|
||||
detail="Access denied for the provided author ID or institution ID",
|
||||
)
|
||||
return await search_eu_cordis_projects(
|
||||
institutions_search_client=institutions_search_client,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
|
||||
@@ -4,6 +4,9 @@ from typing import Annotated
|
||||
import inse.topics.v2.service as topics_service
|
||||
from fastapi import APIRouter, Path, Query
|
||||
from inse.model import SortDirection
|
||||
from inse.models.openalex.domain import Domain
|
||||
from inse.models.openalex.model_field import ModelField
|
||||
from inse.models.openalex.subfield import Subfield
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.router_prefixes import RouterPrefixes
|
||||
from inse.tags import Tags
|
||||
@@ -78,6 +81,48 @@ async def get_topic_by_id(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/domains/single/{domain_id}",
|
||||
operation_id="getDomainById",
|
||||
summary="Returns a domain for a given domain ID.",
|
||||
)
|
||||
async def get_domain_by_id(
|
||||
domain_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the domain to retrieve."),
|
||||
],
|
||||
) -> Domain:
|
||||
return await topics_service.get_domain_by_id_or_raise(domain_id=domain_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/fields/single/{field_id}",
|
||||
operation_id="getFieldById",
|
||||
summary="Returns a field for a given field ID.",
|
||||
)
|
||||
async def get_field_by_id(
|
||||
field_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the field to retrieve."),
|
||||
],
|
||||
) -> ModelField:
|
||||
return await topics_service.get_field_by_id_or_raise(field_id=field_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/subfields/single/{subfield_id}",
|
||||
operation_id="getSubfieldById",
|
||||
summary="Returns a subfield for a given subfield ID.",
|
||||
)
|
||||
async def get_subfield_by_id(
|
||||
subfield_id: Annotated[
|
||||
str,
|
||||
Path(description="The ID of the subfield to retrieve."),
|
||||
],
|
||||
) -> Subfield:
|
||||
return await topics_service.get_subfield_by_id_or_raise(subfield_id=subfield_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/topics/id",
|
||||
operation_id="getTopicsByIds",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex, SortDirection
|
||||
from inse.models.openalex.domain import Domain
|
||||
from inse.models.openalex.model_field import ModelField
|
||||
from inse.models.openalex.subfield import Subfield
|
||||
from inse.models.openalex.topic import Topic
|
||||
from inse.topics.v2.model import TopicPageV2, TopicSortBy
|
||||
|
||||
@@ -184,6 +187,117 @@ async def get_topic_by_id_or_raise(raw_oa_topic_id: str) -> Topic:
|
||||
return topic
|
||||
|
||||
|
||||
async def get_domain_by_id(domain_id: str) -> Domain | None:
|
||||
"""Retrieves a domain based on its ID.
|
||||
|
||||
Args:
|
||||
domain_id (str): The numeric OpenAlex ID of the domain to retrieve (e.g. "4").
|
||||
|
||||
Returns:
|
||||
Domain | None: The domain matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_DOMAINS,
|
||||
doc_id=domain_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return Domain.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_domain_by_id_or_raise(domain_id: str) -> Domain:
|
||||
"""Retrieves a domain based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
domain_id (str): The ID of the domain to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the domain with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
Domain: The domain matching the provided ID.
|
||||
"""
|
||||
domain = await get_domain_by_id(domain_id)
|
||||
if domain is None:
|
||||
raise NotFoundException(f"Domain with ID {domain_id} not found.")
|
||||
return domain
|
||||
|
||||
|
||||
async def get_field_by_id(field_id: str) -> ModelField | None:
|
||||
"""Retrieves a field based on its ID.
|
||||
|
||||
Args:
|
||||
field_id (str): The numeric OpenAlex ID of the field to retrieve (e.g. "27").
|
||||
|
||||
Returns:
|
||||
ModelField | None: The field matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_FIELDS,
|
||||
doc_id=field_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return ModelField.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_field_by_id_or_raise(field_id: str) -> ModelField:
|
||||
"""Retrieves a field based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
field_id (str): The ID of the field to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the field with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
ModelField: The field matching the provided ID.
|
||||
"""
|
||||
field = await get_field_by_id(field_id)
|
||||
if field is None:
|
||||
raise NotFoundException(f"Field with ID {field_id} not found.")
|
||||
return field
|
||||
|
||||
|
||||
async def get_subfield_by_id(subfield_id: str) -> Subfield | None:
|
||||
"""Retrieves a subfield based on its ID.
|
||||
|
||||
Args:
|
||||
subfield_id (str): The numeric OpenAlex ID of the subfield to retrieve (e.g. "2743").
|
||||
|
||||
Returns:
|
||||
Subfield | None: The subfield matching the provided ID, or None if not found.
|
||||
"""
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_SUBFIELDS,
|
||||
doc_id=subfield_id,
|
||||
source=["id", "display_name", "description"],
|
||||
)
|
||||
if response.get("found"):
|
||||
return Subfield.from_dict(response.get("_source", {}))
|
||||
return None
|
||||
|
||||
|
||||
async def get_subfield_by_id_or_raise(subfield_id: str) -> Subfield:
|
||||
"""Retrieves a subfield based on its ID, raising an exception if not found.
|
||||
|
||||
Args:
|
||||
subfield_id (str): The ID of the subfield to retrieve.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If the subfield with the specified ID is not found.
|
||||
|
||||
Returns:
|
||||
Subfield: The subfield matching the provided ID.
|
||||
"""
|
||||
subfield = await get_subfield_by_id(subfield_id)
|
||||
if subfield is None:
|
||||
raise NotFoundException(f"Subfield with ID {subfield_id} not found.")
|
||||
return subfield
|
||||
|
||||
|
||||
async def get_topics_by_ids(topic_ids: list[str]) -> TopicPageV2:
|
||||
"""Retrieves topics based on a list of topic IDs.
|
||||
|
||||
|
||||
+1529
-527
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -19,4 +19,3 @@ export interface DfgProjectTopic {
|
||||
project_count: number;
|
||||
keywords: Array<DfgProjectKeyword>;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
|
||||
/**
|
||||
* Top-level category in the topic hierarchy (4 total)
|
||||
*/
|
||||
export interface Domain {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
fields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DomainFieldsInner
|
||||
*/
|
||||
export interface DomainFieldsInner {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* External identifiers:
|
||||
*/
|
||||
export interface DomainIds {
|
||||
openalex?: string | null;
|
||||
wikidata?: string | null;
|
||||
wikipedia?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { WorkTopicDomain } from './workTopicDomain';
|
||||
|
||||
/**
|
||||
* Second-level category in the topic hierarchy (26 total)
|
||||
*/
|
||||
export interface ModelField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
domain?: WorkTopicDomain | null;
|
||||
subfields?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -78,6 +78,9 @@ export * from './dfgProjectSummary';
|
||||
export * from './dfgProjectTopic';
|
||||
export * from './dfgProjectTopics';
|
||||
export * from './dockerHealth';
|
||||
export * from './domain';
|
||||
export * from './domainFieldsInner';
|
||||
export * from './domainIds';
|
||||
export * from './edge';
|
||||
export * from './euCordisEurosciVocSummary';
|
||||
export * from './euCordisOrganizationSelectorPage';
|
||||
@@ -172,6 +175,7 @@ export * from './matchedTopic';
|
||||
export * from './mentionedPerson';
|
||||
export * from './meta';
|
||||
export * from './model2YrMeanCitedness';
|
||||
export * from './modelField';
|
||||
export * from './newsArticle';
|
||||
export * from './newsArticleDetail';
|
||||
export * from './newsPage';
|
||||
@@ -206,6 +210,9 @@ export * from './score';
|
||||
export * from './selectedAuthorsRequest';
|
||||
export * from './sortDirection';
|
||||
export * from './startCollaborationGraphResponse';
|
||||
export * from './subfield';
|
||||
export * from './subfieldDomain';
|
||||
export * from './subfieldField';
|
||||
export * from './subfieldShare';
|
||||
export * from './timespan';
|
||||
export * from './tokenType';
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { MatchedTopic } from './matchedTopic';
|
||||
|
||||
|
||||
export interface NewsArticle {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
related?: boolean | null;
|
||||
export interface NewsArticle {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
related?: boolean | null;
|
||||
topics?: Array<MatchedTopic> | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -10,19 +10,17 @@
|
||||
import { MatchedTopic } from './matchedTopic';
|
||||
import { MentionedPerson } from './mentionedPerson';
|
||||
|
||||
|
||||
export interface NewsArticleDetail {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
related?: boolean | null;
|
||||
full_content?: string | null;
|
||||
authors?: Array<MentionedPerson>;
|
||||
keywords?: Array<string>;
|
||||
topics?: Array<MatchedTopic>;
|
||||
export interface NewsArticleDetail {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
related?: boolean | null;
|
||||
topics?: Array<MatchedTopic>;
|
||||
full_content?: string | null;
|
||||
authors?: Array<MentionedPerson>;
|
||||
keywords?: Array<string>;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DomainFieldsInner } from './domainFieldsInner';
|
||||
import { DomainIds } from './domainIds';
|
||||
import { SubfieldDomain } from './subfieldDomain';
|
||||
import { SubfieldField } from './subfieldField';
|
||||
|
||||
/**
|
||||
* Third-level category in the topic hierarchy (254 total)
|
||||
*/
|
||||
export interface Subfield {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
description?: string | null;
|
||||
display_name_alternatives?: Array<string> | null;
|
||||
field?: SubfieldField | null;
|
||||
domain?: SubfieldDomain | null;
|
||||
topics?: Array<DomainFieldsInner> | null;
|
||||
siblings?: Array<DomainFieldsInner> | null;
|
||||
ids?: DomainIds | null;
|
||||
works_count?: number | null;
|
||||
cited_by_count?: number | null;
|
||||
works_api_url?: string | null;
|
||||
created_date?: string | null;
|
||||
updated_date?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The domain containing this subfield (top level of hierarchy).
|
||||
*/
|
||||
export interface SubfieldDomain {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The field containing this subfield (parent level).
|
||||
*/
|
||||
export interface SubfieldField {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
workPageResolver,
|
||||
workQueryParamKeys,
|
||||
} from './resolvers/work-page.resolver';
|
||||
import { keywordsNewsPageResolver } from './resolvers/keywords-news-page.resolver';
|
||||
import { selectedTopicsResolver } from './resolvers/selected-topics.resolver';
|
||||
import { selectedInstitutionsResolver } from './resolvers/selected-institutions.resolver';
|
||||
import { selectedBundInstitutionsResolver } from './resolvers/selected-bund-institutions.resolver';
|
||||
@@ -273,7 +274,14 @@ export const routes: Routes = [
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.KEYWORDS_SEARCH,
|
||||
},
|
||||
},
|
||||
{ path: 'news', component: KeywordsToNewsResultsComponent },
|
||||
{
|
||||
path: 'news',
|
||||
component: KeywordsToNewsResultsComponent,
|
||||
runGuardsAndResolvers: 'always',
|
||||
resolve: {
|
||||
newsPage: keywordsNewsPageResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'trends',
|
||||
component: UniTrendParentComponent,
|
||||
|
||||
@@ -1,76 +1,80 @@
|
||||
import {
|
||||
Directive,
|
||||
OnChanges,
|
||||
Input,
|
||||
ElementRef,
|
||||
Input,
|
||||
OnChanges,
|
||||
Renderer2,
|
||||
SimpleChanges,
|
||||
effect,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { SimpleChanges } from '@angular/core';
|
||||
@Directive({ selector: '[skText]', standalone: true })
|
||||
import { ResolverStateService } from '../../app/shared/services/resolver-state.service';
|
||||
|
||||
@Directive({
|
||||
selector: 'span, [skText]',
|
||||
standalone: true,
|
||||
})
|
||||
export class SkTextDirective implements OnChanges {
|
||||
@Input() skText = false;
|
||||
|
||||
private originalText = '';
|
||||
private originalColor = '';
|
||||
private readonly el = inject(ElementRef<HTMLElement>);
|
||||
private readonly renderer = inject(Renderer2);
|
||||
private readonly resolverStateService = inject(ResolverStateService);
|
||||
|
||||
constructor(
|
||||
private el: ElementRef,
|
||||
private renderer: Renderer2,
|
||||
) {}
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const loading = this.skText || this.resolverStateService.isResolving();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
const change = changes['skText'];
|
||||
|
||||
// skip if value didn't actually change, or is undefined
|
||||
if (!change) return;
|
||||
|
||||
this.skText ? this.showSkeleton() : this.hideSkeleton();
|
||||
if (loading) {
|
||||
this.showSkeleton();
|
||||
} else {
|
||||
this.hideSkeleton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private showSkeleton() {
|
||||
const el: HTMLElement = this.el.nativeElement;
|
||||
this.originalText = el.textContent ?? '';
|
||||
this.originalColor = el.style.color;
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (!changes['skText']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// measure natural width before blanking text
|
||||
const width = Math.min(Math.max(this.originalText.length * 7.5, 48), 60);
|
||||
const height = 20;
|
||||
this.renderer.addClass(el, 'sk-text-loading');
|
||||
this.renderer.setStyle(el, 'color', 'transparent');
|
||||
this.renderer.setStyle(
|
||||
el,
|
||||
'background',
|
||||
'linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%)',
|
||||
);
|
||||
this.renderer.setStyle(el, 'background-size', '600px 100%');
|
||||
this.renderer.setStyle(el, 'animation', 'sk-shimmer 1.6s infinite linear');
|
||||
this.renderer.setStyle(el, 'border-radius', '4px');
|
||||
this.renderer.setStyle(el, 'min-width', `${width}px`);
|
||||
this.renderer.setStyle(el, 'max-height', `${height}px`);
|
||||
this.renderer.setStyle(el, 'display', 'inline-block');
|
||||
this.renderer.setStyle(el, 'overflow', 'hidden');
|
||||
this.renderer.setStyle(el, 'pointer-events', 'none');
|
||||
if (this.skText || this.resolverStateService.isResolving()) {
|
||||
this.showSkeleton();
|
||||
} else {
|
||||
this.hideSkeleton();
|
||||
}
|
||||
}
|
||||
|
||||
Array.from(el.children).forEach((child) => {
|
||||
private showSkeleton(): void {
|
||||
const element = this.el.nativeElement;
|
||||
|
||||
if (element.classList.contains('sk-text-loading')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const text = element.textContent?.trim() ?? '';
|
||||
|
||||
// For ordinary text elements only. Table cells use CSS width naturally.
|
||||
if (element.tagName.toLowerCase() !== 'td') {
|
||||
this.renderer.setStyle(element, 'min-width', `${20}px`);
|
||||
this.renderer.setStyle(element, 'height', '20px');
|
||||
}
|
||||
|
||||
this.renderer.addClass(element, 'sk-text-loading');
|
||||
|
||||
Array.from(element.children).forEach((child) => {
|
||||
this.renderer.setStyle(child, 'visibility', 'hidden');
|
||||
});
|
||||
}
|
||||
|
||||
private hideSkeleton() {
|
||||
const el: HTMLElement = this.el.nativeElement;
|
||||
this.renderer.removeClass(el, 'sk-text-loading');
|
||||
this.renderer.removeStyle(el, 'color');
|
||||
this.renderer.removeStyle(el, 'background');
|
||||
this.renderer.removeStyle(el, 'background-size');
|
||||
this.renderer.removeStyle(el, 'animation');
|
||||
this.renderer.removeStyle(el, 'border-radius');
|
||||
this.renderer.removeStyle(el, 'min-width');
|
||||
this.renderer.removeStyle(el, 'max-height');
|
||||
this.renderer.removeStyle(el, 'display');
|
||||
this.renderer.removeStyle(el, 'overflow');
|
||||
this.renderer.removeStyle(el, 'pointer-events');
|
||||
private hideSkeleton(): void {
|
||||
const element = this.el.nativeElement;
|
||||
|
||||
Array.from(el.children).forEach((child) => {
|
||||
this.renderer.removeClass(element, 'sk-text-loading');
|
||||
this.renderer.removeStyle(element, 'min-width');
|
||||
this.renderer.removeStyle(element, 'height');
|
||||
|
||||
Array.from(element.children).forEach((child) => {
|
||||
this.renderer.removeStyle(child, 'visibility');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,12 +130,14 @@ export class ComponentTooltipDirective<T extends object> implements OnDestroy {
|
||||
.flexibleConnectedTo(this.elementRef)
|
||||
.withPositions(positions)
|
||||
.withFlexibleDimensions(false)
|
||||
.withViewportMargin(12)
|
||||
.withPush(true);
|
||||
|
||||
this.overlayRef = this.overlay.create({
|
||||
positionStrategy,
|
||||
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
||||
panelClass: 'app-tooltip-panel',
|
||||
maxWidth: this.tooltipMaxWidth() ?? 'calc(100vw - 24px)',
|
||||
});
|
||||
|
||||
const portal = new ComponentPortal(this.component(), null, this.injector);
|
||||
|
||||
@@ -179,6 +179,8 @@
|
||||
<div class="keyword-chip-stack">
|
||||
@for (keyword of keywords; track keyword.llm_keyword.keyword) {
|
||||
<app-topic-chip
|
||||
[topic]="keyword.topic_mapping?.topic"
|
||||
[topicId]="keyword.topic_mapping?.topic?.id"
|
||||
[label]="getChipLabel(keyword)"
|
||||
[count]="
|
||||
keywordView() === 'topic' ? getChipCount(keyword) : null
|
||||
@@ -209,6 +211,8 @@
|
||||
) {
|
||||
<div class="manual-chip-row">
|
||||
<app-topic-chip
|
||||
[topic]="keyword.topic_mapping?.topic"
|
||||
[topicId]="keyword.topic_mapping?.topic?.id"
|
||||
[label]="getChipLabel(keyword)"
|
||||
[count]="
|
||||
keywordView() === 'topic' ? getChipCount(keyword) : null
|
||||
|
||||
+150
-29
@@ -1,31 +1,152 @@
|
||||
<div class="result-layout">
|
||||
<mat-card class="results-card">
|
||||
<mat-card-content class="results-placeholder">
|
||||
<mat-icon>groups</mat-icon>
|
||||
<h2>Newsliste</h2>
|
||||
<p>
|
||||
Die aktuelle Gewichtung ist unter <code>normalized</code> verfügbar.
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<div class="content">
|
||||
<div class="filters">
|
||||
<app-filter-card>
|
||||
<app-query-param-selector
|
||||
class="relevance-field"
|
||||
[options]="relevanceOptions"
|
||||
[queryParamKey]="keywordsNewsQueryParamKeys.relevance"
|
||||
label="Relevanz"
|
||||
icon="check_circle"
|
||||
[multiple]="true" />
|
||||
|
||||
<mat-card class="weights-card">
|
||||
<mat-card-content>
|
||||
<app-weights-sliders
|
||||
[options]="weightOptions"
|
||||
[initialWeights]="defaultWeights"
|
||||
title="News-Gewichtung"
|
||||
description="Werte zwischen 0 und 1. Summe wird normalisiert zu 1."
|
||||
resetLabel="Ausgewogen"
|
||||
applyLabel="Neu gewichten"
|
||||
normalizedTitle="Normalisiert"
|
||||
queryParamPrefix="newsW_"
|
||||
[persistInQueryParams]="true"
|
||||
[showApplyButton]="true"
|
||||
[showResetButton]="true"
|
||||
[showNormalizedPreview]="true"
|
||||
(weightsChange)="onWeightsChange($event)"
|
||||
(applyWeights)="onApplyWeights($event)" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<app-query-param-selector
|
||||
class="sort-order-field"
|
||||
[options]="sortOrderOptions"
|
||||
[queryParamKey]="keywordsNewsQueryParamKeys.sortOrder"
|
||||
label="Sortierung"
|
||||
icon="sort" />
|
||||
</app-filter-card>
|
||||
|
||||
<app-year-range-slider
|
||||
[minYear]="minYear"
|
||||
[maxYear]="maxYear"
|
||||
[(startYear)]="yearFrom"
|
||||
[(endYear)]="yearTo"
|
||||
(startYearChange)="applyYearFilter()"
|
||||
(endYearChange)="applyYearFilter()">
|
||||
</app-year-range-slider>
|
||||
|
||||
@if (hasActiveFilters()) {
|
||||
<button
|
||||
class="reset-filter-btn"
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
(click)="resetFilters()"
|
||||
aria-label="Filter zurücksetzen">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
<span>Zurücksetzen</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ng-template #titleTmp let-article>
|
||||
<div class="title-cell">
|
||||
<a class="title" [routerLink]="['/news', article.id]">
|
||||
{{ article.maintitle || 'Kein Titel' }}
|
||||
</a>
|
||||
@if (article.snippet) {
|
||||
<span class="snippet" [innerHTML]="article.snippet"></span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #dateTmp let-article>
|
||||
@if (article.date) {
|
||||
<span class="date-text">{{ article.date }}</span>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #relevanceTmp let-article>
|
||||
@if (article.relevant === true) {
|
||||
<span class="relevance-badge is-relevant">
|
||||
<mat-icon>check_circle</mat-icon>
|
||||
Relevant
|
||||
</span>
|
||||
} @else if (article.relevant === false) {
|
||||
<span class="relevance-badge not-relevant">
|
||||
<mat-icon>cancel</mat-icon>
|
||||
Nicht relevant
|
||||
</span>
|
||||
} @else {
|
||||
<span
|
||||
class="relevance-badge undetermined"
|
||||
[matTooltip]="relevanceHelp"
|
||||
matTooltipPosition="above">
|
||||
<mat-icon>help</mat-icon>
|
||||
Nicht bestimmt
|
||||
</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-article>
|
||||
@let topics = article.topics ?? [];
|
||||
@let topicsExpanded = isTopicsExpanded(article);
|
||||
@let visibleTopics =
|
||||
topicsExpanded ? topics : topics.slice(0, topicPreviewCount);
|
||||
|
||||
<div class="topic-chips" aria-label="Themen">
|
||||
@for (topic of visibleTopics; track topic.id ?? topic.display_name) {
|
||||
<app-topic-chip-2
|
||||
size="mini"
|
||||
[topic]="toTopic(topic)"
|
||||
[showIcon]="false"
|
||||
[isSelected]="isTopicActive(topic)"
|
||||
[isClickable]="fuzzySearch()"
|
||||
(handleChipClick)="toggleTopicFilter($event)" />
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
|
||||
@if (topics.length > topicPreviewCount) {
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="topicsExpanded"
|
||||
[hiddenCount]="topics.length - topicPreviewCount"
|
||||
(toggle)="toggleTopicsExpansion(article)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-article>
|
||||
<a
|
||||
mat-icon-button
|
||||
color="primary"
|
||||
[routerLink]="['/news', article.id]"
|
||||
matTooltip="Details anzeigen">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
@if (!hasSearchInput()) {
|
||||
<div class="no-results">
|
||||
<span>Keine Keywords ausgewählt.</span>
|
||||
</div>
|
||||
} @else if (total() === 0) {
|
||||
<div class="no-results">
|
||||
@if (hasNarrowingFilters()) {
|
||||
<span>Keine Nachrichten für die aktuellen Filter.</span>
|
||||
<span class="no-results__hint">
|
||||
Setzen Sie die Filter zurück, um mehr Ergebnisse zu sehen.
|
||||
</span>
|
||||
} @else if (searchedByTopics()) {
|
||||
<span>Zu diesen Themen gibt es keine Nachrichten.</span>
|
||||
<span class="no-results__hint">
|
||||
Campus Aktuell deckt nicht jedes Forschungsthema ab. Schalten Sie die
|
||||
Fuzzy Search aus, um direkt nach den Keywords zu suchen.
|
||||
</span>
|
||||
} @else {
|
||||
<span>Keine Nachrichten zu diesen Keywords gefunden.</span>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="table-wrap">
|
||||
<app-data-table [columns]="columns()" [data]="elements()" />
|
||||
</div>
|
||||
|
||||
<app-query-param-paginator
|
||||
[total]="total()"
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size" />
|
||||
}
|
||||
</div>
|
||||
|
||||
+190
-20
@@ -1,29 +1,199 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
RESULT LAYOUT
|
||||
FILTERS
|
||||
============================================================ */
|
||||
.result-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(300px, 420px) 1fr;
|
||||
grid-template-areas: 'summary results';
|
||||
.filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
gap: 0.75rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.search-summary-card {
|
||||
grid-area: summary;
|
||||
}
|
||||
.relevance-field,
|
||||
.sort-order-field {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.results-card {
|
||||
grid-area: results;
|
||||
}
|
||||
app-year-range-slider {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.search-summary-card,
|
||||
.results-card {
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
box-shadow: none;
|
||||
::ng-deep app-year-range-slider .year-filter {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.mat-mdc-card-content {
|
||||
padding: 0.75rem;
|
||||
::ng-deep .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-form-field-icon-prefix {
|
||||
padding: 0 4px 0 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.reset-filter-btn {
|
||||
display: flex;
|
||||
align-self: center;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
TABLE
|
||||
============================================================ */
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
::ng-deep .table-wrap table {
|
||||
width: 100%;
|
||||
min-width: 960px;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 10px;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::ng-deep .table-wrap .mat-mdc-header-cell {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
::ng-deep .table-wrap .mat-mdc-row {
|
||||
height: 86px;
|
||||
}
|
||||
|
||||
::ng-deep .table-wrap .mat-mdc-cell {
|
||||
color: var(--sg-text);
|
||||
border-bottom-color: var(--sg-border);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
::ng-deep .table-wrap {
|
||||
.mat-column-date,
|
||||
.mat-column-relevant,
|
||||
.mat-mdc-header-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mat-column-topics {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
TABLE CELLS
|
||||
============================================================ */
|
||||
.title-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding: 0.5rem 0;
|
||||
max-width: 32rem;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: inline-block;
|
||||
max-width: 520px;
|
||||
line-height: 1.35;
|
||||
color: var(--sg-text);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.snippet {
|
||||
font-size: 12.5px;
|
||||
line-height: 1.5;
|
||||
color: var(--sg-text-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
::ng-deep em {
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
color: var(--sg-blue-highlight);
|
||||
}
|
||||
}
|
||||
|
||||
.date-text {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.relevance-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 12px;
|
||||
border-radius: 999px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
&.is-relevant {
|
||||
background: var(--sg-success-soft);
|
||||
border: 1px solid var(--sg-success);
|
||||
color: var(--sg-success);
|
||||
}
|
||||
|
||||
&.not-relevant {
|
||||
background: var(--sg-surface-muted);
|
||||
border: 1px solid var(--sg-border);
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
&.undetermined {
|
||||
background: var(--sg-warning-soft);
|
||||
border: 1px solid var(--sg-warning);
|
||||
color: var(--sg-warning);
|
||||
cursor: help;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem;
|
||||
align-items: flex-start;
|
||||
padding: 0.5rem 0;
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
.no-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 2rem;
|
||||
color: var(--sg-text-muted);
|
||||
text-align: center;
|
||||
|
||||
&__hint {
|
||||
max-width: 34rem;
|
||||
color: var(--sg-text-soft);
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
+256
-87
@@ -1,115 +1,284 @@
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
import {
|
||||
WeightMap,
|
||||
WeightSliderOption,
|
||||
WeightsSlidersComponent,
|
||||
WeightsSlidersValue,
|
||||
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
|
||||
Component,
|
||||
DestroyRef,
|
||||
computed,
|
||||
inject,
|
||||
input,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
|
||||
import { MatchedTopic, NewsPage, Topic } from '../../../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../../../shared/ui/data-table/data-table.component';
|
||||
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import { AppTopicChipComponent } from '../../../../shared/ui/app-topic-chip/app-topic-chip.component';
|
||||
import { ChipOverflowToggleComponent } from '../../../../shared/ui/chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
import { FilterCardComponent } from '../../../../shared/ui/filter-card/filter-card.component';
|
||||
import {
|
||||
QueryParamSelectorComponent,
|
||||
SelectorOption,
|
||||
} from '../../../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { NEWS_MIN_YEAR } from '../../../../shared/ui/news-card/news-card.component';
|
||||
import { keywordsNewsQueryParamKeys } from '../../../../resolvers/keywords-news-page.resolver';
|
||||
import { SearchResultsStateService } from '../search-results-state.service';
|
||||
import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
|
||||
type NewsResult = NewsPage['results'][number];
|
||||
|
||||
@Component({
|
||||
selector: 'app-news-results',
|
||||
imports: [MatCardModule, MatIconModule, WeightsSlidersComponent],
|
||||
imports: [
|
||||
RouterModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatTooltipModule,
|
||||
DataTableComponent,
|
||||
AppTopicChipComponent,
|
||||
ChipOverflowToggleComponent,
|
||||
FilterCardComponent,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamSelectorComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './news-results.component.html',
|
||||
styleUrl: './news-results.component.scss',
|
||||
})
|
||||
export class KeywordsToNewsResultsComponent {
|
||||
// injects the state set by the parent route — no duplicate parsing here
|
||||
protected readonly keywordsNewsQueryParamKeys = keywordsNewsQueryParamKeys;
|
||||
|
||||
private readonly state = inject(SearchResultsStateService);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly defaultWeights: WeightMap = {
|
||||
param1: 0.33,
|
||||
param2: 0.33,
|
||||
param3: 0.34,
|
||||
};
|
||||
newsPage = input.required<NewsPage>();
|
||||
|
||||
readonly weightOptions: WeightSliderOption[] = [
|
||||
{
|
||||
key: 'param1',
|
||||
label: 'Parameter 1',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 1.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam1',
|
||||
},
|
||||
{
|
||||
key: 'param2',
|
||||
label: 'Parameter 2',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 2.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam2',
|
||||
},
|
||||
{
|
||||
key: 'param3',
|
||||
label: 'Parameter 3',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 3.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam3',
|
||||
},
|
||||
readonly minYear = NEWS_MIN_YEAR;
|
||||
readonly maxYear = new Date().getFullYear();
|
||||
|
||||
readonly relevanceHelp =
|
||||
'Ein Artikel gilt als relevant, wenn er für Gründungsforschende interessante Inhalte enthält.';
|
||||
|
||||
readonly sortOrderOptions: SelectorOption[] = [
|
||||
{ value: 'desc', display_name: 'Neueste zuerst' },
|
||||
{ value: 'asc', display_name: 'Älteste zuerst' },
|
||||
];
|
||||
|
||||
readonly currentWeights = signal<WeightsSlidersValue>({
|
||||
raw: this.defaultWeights,
|
||||
normalized: {
|
||||
param1: 0.33,
|
||||
param2: 0.33,
|
||||
param3: 0.34,
|
||||
},
|
||||
rawSum: 2.5,
|
||||
normalizedSum: 1,
|
||||
valid: true,
|
||||
readonly relevanceOptions: SelectorOption[] = [
|
||||
{ value: 'relevant', display_name: 'Relevant' },
|
||||
{ value: 'not_relevant', display_name: 'Nicht relevant' },
|
||||
];
|
||||
|
||||
readonly yearFrom = signal<number>(this.minYear);
|
||||
readonly yearTo = signal<number>(this.maxYear);
|
||||
|
||||
protected readonly topicPreviewCount = 3;
|
||||
private readonly expandedTopicsIds = signal<ReadonlySet<string>>(new Set());
|
||||
|
||||
private readonly queryParamMap = toSignal(this.route.queryParamMap, {
|
||||
initialValue: this.route.snapshot.queryParamMap,
|
||||
});
|
||||
|
||||
readonly projects = signal<unknown[]>([]); // placeholder until the results service lands
|
||||
readonly total = computed(() => this.newsPage().total ?? 0);
|
||||
readonly elements = computed(() => this.newsPage().results ?? []);
|
||||
readonly fuzzySearch = computed(
|
||||
() => this.queryParamMap().get('fuzzy') === 'true',
|
||||
);
|
||||
|
||||
private hasLoadedInitial = false;
|
||||
constructor() {
|
||||
console.log('check', this.state.payload());
|
||||
}
|
||||
onWeightsChange(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
readonly hasSearchInput = computed(() =>
|
||||
this.fuzzySearch()
|
||||
? this.state.topicIds().length > 0 || this.state.keywords().length > 0
|
||||
: this.state.keywords().length > 0,
|
||||
);
|
||||
|
||||
// fires once with the query-param-aware initial state — use it to load
|
||||
if (!this.hasLoadedInitial) {
|
||||
this.hasLoadedInitial = true;
|
||||
this.loadprojects();
|
||||
readonly selectedTopicIds = computed(() =>
|
||||
this.queryParamMap().getAll(keywordsNewsQueryParamKeys.topicId),
|
||||
);
|
||||
|
||||
readonly hasActiveFilters = computed(() => {
|
||||
const params = this.queryParamMap();
|
||||
return (
|
||||
!!params.get(keywordsNewsQueryParamKeys.relevance) ||
|
||||
!!params.get(keywordsNewsQueryParamKeys.yearFrom) ||
|
||||
!!params.get(keywordsNewsQueryParamKeys.yearTo) ||
|
||||
!!params.get(keywordsNewsQueryParamKeys.sortOrder) ||
|
||||
this.selectedTopicIds().length > 0
|
||||
);
|
||||
});
|
||||
|
||||
readonly hasNarrowingFilters = computed(() => {
|
||||
const params = this.queryParamMap();
|
||||
return (
|
||||
!!params.get(keywordsNewsQueryParamKeys.relevance) ||
|
||||
!!params.get(keywordsNewsQueryParamKeys.yearFrom) ||
|
||||
!!params.get(keywordsNewsQueryParamKeys.yearTo) ||
|
||||
this.selectedTopicIds().length > 0
|
||||
);
|
||||
});
|
||||
|
||||
readonly searchedByTopics = computed(() => {
|
||||
if (!this.fuzzySearch()) {
|
||||
return false;
|
||||
}
|
||||
const baseTopicIds = (this.queryParamMap().get('topics') ?? '')
|
||||
.split(',')
|
||||
.filter((value) => value.trim());
|
||||
return baseTopicIds.length > 0 || this.selectedTopicIds().length > 0;
|
||||
});
|
||||
|
||||
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
|
||||
dateTmp = viewChild.required<TemplateRef<any>>('dateTmp');
|
||||
relevanceTmp = viewChild.required<TemplateRef<any>>('relevanceTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
|
||||
readonly columns = computed<GenericColumn<NewsResult>[]>(() => [
|
||||
{
|
||||
id: 'maintitle',
|
||||
header: 'Titel',
|
||||
type: 'display',
|
||||
cellTemplate: this.titleTmp(),
|
||||
},
|
||||
{
|
||||
id: 'date',
|
||||
header: 'Datum',
|
||||
type: 'display',
|
||||
cellTemplate: this.dateTmp(),
|
||||
},
|
||||
{
|
||||
id: 'relevant',
|
||||
header: 'Relevanz',
|
||||
type: 'display',
|
||||
cellTemplate: this.relevanceTmp(),
|
||||
},
|
||||
{
|
||||
id: 'topics',
|
||||
header: 'Themen',
|
||||
type: 'display',
|
||||
cellTemplate: this.topicsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: 'Aktionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.actionsTmp(),
|
||||
},
|
||||
]);
|
||||
|
||||
constructor() {
|
||||
this.route.queryParamMap
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((params) => {
|
||||
this.yearFrom.set(
|
||||
this.parseYear(params.get(keywordsNewsQueryParamKeys.yearFrom)) ??
|
||||
this.minYear,
|
||||
);
|
||||
this.yearTo.set(
|
||||
this.parseYear(params.get(keywordsNewsQueryParamKeys.yearTo)) ??
|
||||
this.maxYear,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onApplyWeights(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
this.loadprojects();
|
||||
}
|
||||
|
||||
private loadprojects(): void {
|
||||
const weights = this.currentWeights();
|
||||
|
||||
const requestPayload = {
|
||||
manualKeywords: this.state.manualKeywords(),
|
||||
extractedKeywords: this.state.extractedKeywords(),
|
||||
keywords: this.state.keywords(),
|
||||
fuzzy: this.state.fuzzySearch(),
|
||||
weights: {
|
||||
raw: weights.raw,
|
||||
normalized: weights.normalized,
|
||||
applyYearFilter(): void {
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
[keywordsNewsQueryParamKeys.yearFrom]:
|
||||
this.yearFrom() > this.minYear ? this.yearFrom() : null,
|
||||
[keywordsNewsQueryParamKeys.yearTo]:
|
||||
this.yearTo() < this.maxYear ? this.yearTo() : null,
|
||||
[keywordsNewsQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
toTopic(matched: MatchedTopic): Topic {
|
||||
return {
|
||||
id: matched.id,
|
||||
display_name: matched.display_name,
|
||||
subfield: matched.subfield_name
|
||||
? { display_name: matched.subfield_name }
|
||||
: null,
|
||||
field: matched.field_name ? { display_name: matched.field_name } : null,
|
||||
domain: matched.domain_name
|
||||
? { display_name: matched.domain_name }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
console.log(requestPayload);
|
||||
isTopicActive(topic: MatchedTopic): boolean {
|
||||
return !!topic.id && this.selectedTopicIds().includes(topic.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* this.projectsService.searchprojects(requestPayload).subscribe({
|
||||
* next: results => this.projects.set(results),
|
||||
* error: error => console.error(error),
|
||||
* });
|
||||
*/
|
||||
isTopicsExpanded(article: NewsResult): boolean {
|
||||
return this.expandedTopicsIds().has(article.id);
|
||||
}
|
||||
|
||||
toggleTopicsExpansion(article: NewsResult): void {
|
||||
if (!article.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.expandedTopicsIds.update((ids) => {
|
||||
const next = new Set(ids);
|
||||
if (next.has(article.id)) {
|
||||
next.delete(article.id);
|
||||
} else {
|
||||
next.add(article.id);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
toggleTopicFilter(topic: Topic): void {
|
||||
if (!topic.id || !this.fuzzySearch()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selected = this.selectedTopicIds();
|
||||
const next = selected.includes(topic.id)
|
||||
? selected.filter((id) => id !== topic.id)
|
||||
: [...selected, topic.id];
|
||||
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
[keywordsNewsQueryParamKeys.topicId]: next.length ? next : null,
|
||||
[keywordsNewsQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
resetFilters(): void {
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
[keywordsNewsQueryParamKeys.relevance]: null,
|
||||
[keywordsNewsQueryParamKeys.yearFrom]: null,
|
||||
[keywordsNewsQueryParamKeys.yearTo]: null,
|
||||
[keywordsNewsQueryParamKeys.topicId]: null,
|
||||
[keywordsNewsQueryParamKeys.sortOrder]: null,
|
||||
[keywordsNewsQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
private parseYear(raw: string | null): number | null {
|
||||
const year = Number.parseInt(raw ?? '', 10);
|
||||
return Number.isNaN(year) ? null : year;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
track getEntryTrack(entry)
|
||||
) {
|
||||
<app-topic-chip
|
||||
[topic]="entry.topic_mapping?.topic"
|
||||
[topicId]="entry.topic_mapping?.topic?.id"
|
||||
[label]="getChipLabel(entry)"
|
||||
[count]="getChipCount(entry)"
|
||||
[description]="getChipDescription(entry)"
|
||||
|
||||
@@ -230,8 +230,8 @@
|
||||
»{{ topic.source_keyword }}«
|
||||
</button>
|
||||
<p class="kw-hint">
|
||||
Im Artikel hervorgehoben · klicken zum Suche zu
|
||||
öffnen
|
||||
Im Artikel hervorgehoben - klicken, um zum
|
||||
ersten Vorkommen zu springen.
|
||||
</p>
|
||||
} @else {
|
||||
<p class="placeholder">
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
ViewChild,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -66,7 +65,6 @@ export class NewsDetailComponent implements OnInit {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly httpClient = inject(HttpClient);
|
||||
private readonly worksService = inject(WorksService);
|
||||
private readonly location = inject(Location);
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
|
||||
article: NewsArticleDetail | null = null;
|
||||
@@ -150,7 +148,7 @@ export class NewsDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
navigateBack(): void {
|
||||
this.location.back();
|
||||
this.router.navigate(['/news']);
|
||||
}
|
||||
|
||||
formatDate(dateStr?: string | null): string {
|
||||
@@ -200,36 +198,30 @@ export class NewsDetailComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
}
|
||||
const orphanColors = [
|
||||
'var(--sg-primary)',
|
||||
'var(--sg-blue-highlight)',
|
||||
'var(--sg-success)',
|
||||
'var(--sg-warning)',
|
||||
'var(--sg-error)',
|
||||
];
|
||||
let orphanIdx = 0;
|
||||
|
||||
let html = this.escapeHtml(text);
|
||||
if (keywords.length) {
|
||||
[...keywords]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.forEach((kw) => {
|
||||
let color = keywordColorMap.get(kw.toLowerCase());
|
||||
if (!color) {
|
||||
color = orphanColors[orphanIdx % orphanColors.length];
|
||||
orphanIdx++;
|
||||
}
|
||||
const kwHtml = this.escapeHtml(kw);
|
||||
const re = new RegExp(
|
||||
`(${this.escapeRegex(kwHtml)}[\\w\\u00C0-\\u024F]*)`,
|
||||
'gi',
|
||||
);
|
||||
html = html.replace(
|
||||
re,
|
||||
`<mark class="kw-mark" style="--t:${color}" data-kw="${kwHtml}">$1</mark>`,
|
||||
);
|
||||
});
|
||||
}
|
||||
[...keywords]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.forEach((kw) => {
|
||||
const color = keywordColorMap.get(kw.toLowerCase());
|
||||
if (!color) return;
|
||||
const kwHtml = this.escapeHtml(kw);
|
||||
const escaped = this.escapeRegex(kwHtml);
|
||||
const before = '(?<![\\w\\u00C0-\\u024F])';
|
||||
const acronymLike =
|
||||
kw.length <= 3 ||
|
||||
(kw === kw.toUpperCase() && kw !== kw.toLowerCase());
|
||||
const re = new RegExp(
|
||||
acronymLike
|
||||
? `${before}(${escaped})(?![\\w\\u00C0-\\u024F])`
|
||||
: `${before}(${escaped}[\\w\\u00C0-\\u024F]*)`,
|
||||
'gi',
|
||||
);
|
||||
html = html.replace(
|
||||
re,
|
||||
`<mark class="kw-mark" style="--t:${color}" data-kw="${kwHtml}">$1</mark>`,
|
||||
);
|
||||
});
|
||||
return this.sanitizer.bypassSecurityTrustHtml(html);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,18 +18,24 @@
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
<div class="additional-filters">
|
||||
<mat-form-field
|
||||
appearance="outline"
|
||||
subscriptSizing="dynamic"
|
||||
class="relevance-field">
|
||||
<mat-select
|
||||
[formControl]="relevanceFilter"
|
||||
placeholder="Relevanz"
|
||||
multiple>
|
||||
<mat-option value="relevant">Relevant</mat-option>
|
||||
<mat-option value="not_relevant">Nicht relevant</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<app-filter-card>
|
||||
<app-query-param-selector
|
||||
class="relevance-field"
|
||||
[options]="relevanceOptions"
|
||||
queryParamKey="relevance"
|
||||
label="Relevanz"
|
||||
icon="check_circle"
|
||||
[multiple]="true" />
|
||||
|
||||
@if (!isSearching()) {
|
||||
<app-query-param-selector
|
||||
class="sort-order-field"
|
||||
[options]="sortingDirectionOptionsAll"
|
||||
queryParamKey="sorting_order"
|
||||
label="Sortierung"
|
||||
icon="sort" />
|
||||
}
|
||||
</app-filter-card>
|
||||
|
||||
<app-year-range-slider
|
||||
class="year-field"
|
||||
@@ -59,7 +65,5 @@
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
[noResultsTmp]="noResultsTmp"
|
||||
[cardMinWidth]="380"
|
||||
[sortingDirectionOptions]="sortingDirectionOptions()"
|
||||
sortingDirectionLabel="Sortierung"
|
||||
searchLabel="Nachrichten durchsuchen" />
|
||||
</div>
|
||||
|
||||
@@ -44,20 +44,36 @@
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
$card-min-width: 380px;
|
||||
|
||||
.additional-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 40px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax($card-min-width, 1fr));
|
||||
align-items: stretch;
|
||||
gap: 1.5rem;
|
||||
padding: 0 1rem 1rem;
|
||||
|
||||
app-year-range-slider {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
::ng-deep app-year-range-slider .year-filter {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-form-field-icon-prefix {
|
||||
padding: 0 4px 0 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.relevance-field {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.year-field {
|
||||
min-width: 280px;
|
||||
.relevance-field,
|
||||
.sort-order-field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
|
||||
@@ -7,12 +7,10 @@ import {
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { debounceTime, merge } from 'rxjs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
|
||||
import { WorksService } from '../../api';
|
||||
import {
|
||||
@@ -24,7 +22,11 @@ import {
|
||||
NewsCardComponent,
|
||||
NEWS_MIN_YEAR,
|
||||
} from '../../shared/ui/news-card/news-card.component';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import {
|
||||
QueryParamSelectorComponent,
|
||||
SelectorOption,
|
||||
} from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component';
|
||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
|
||||
interface NewsArticle extends NewsArticleBase {
|
||||
@@ -44,11 +46,10 @@ type SortOrder = 'desc' | 'asc';
|
||||
@Component({
|
||||
selector: 'app-news',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
MatFormFieldModule,
|
||||
MatSelectModule,
|
||||
CardSearchComponent,
|
||||
NewsCardComponent,
|
||||
FilterCardComponent,
|
||||
QueryParamSelectorComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './news.component.html',
|
||||
@@ -64,11 +65,16 @@ export class NewsComponent implements OnInit {
|
||||
readonly minYear = NEWS_MIN_YEAR;
|
||||
readonly maxYear = new Date().getFullYear();
|
||||
|
||||
private readonly sortingDirectionOptionsAll: SelectorOption[] = [
|
||||
readonly sortingDirectionOptionsAll: SelectorOption[] = [
|
||||
{ value: 'desc', display_name: 'Neueste zuerst' },
|
||||
{ value: 'asc', display_name: 'Älteste zuerst' },
|
||||
];
|
||||
|
||||
readonly relevanceOptions: SelectorOption[] = [
|
||||
{ value: 'relevant', display_name: 'Relevant' },
|
||||
{ value: 'not_relevant', display_name: 'Nicht relevant' },
|
||||
];
|
||||
|
||||
readonly relevanceFilter = new FormControl<string[]>([], {
|
||||
nonNullable: true,
|
||||
});
|
||||
@@ -85,9 +91,6 @@ export class NewsComponent implements OnInit {
|
||||
readonly searchQuery = signal('');
|
||||
|
||||
readonly isSearching = computed(() => this.searchQuery().trim().length > 0);
|
||||
readonly sortingDirectionOptions = computed<SelectorOption[]>(() =>
|
||||
this.isSearching() ? [] : this.sortingDirectionOptionsAll,
|
||||
);
|
||||
|
||||
readonly page = computed<Page>(() => ({
|
||||
page: this.currentPage,
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
track topic.topic_id ?? topic.topic_display_name
|
||||
) {
|
||||
<app-topic-chip
|
||||
[topicId]="topic.topic_id"
|
||||
[label]="topic.topic_display_name"
|
||||
[fieldName]="topic.field_name"
|
||||
[domainName]="topic.domain_name"
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
track topic.topic_id ?? topic.topic_display_name
|
||||
) {
|
||||
<app-topic-chip
|
||||
[topicId]="topic.topic_id"
|
||||
[label]="topic.topic_display_name"
|
||||
[fieldName]="topic.field_name"
|
||||
[domainName]="topic.domain_name"
|
||||
|
||||
@@ -106,6 +106,8 @@
|
||||
[skText]="loading()"
|
||||
class="person-topic-chip"
|
||||
size="mini"
|
||||
[topic]="topic"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.display_name || ''"
|
||||
[description]="topic.description"
|
||||
[subfieldName]="topic.subfield?.display_name"
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
} @else if (tags().length > 0) {
|
||||
@for (tag of tags(); track tag.label) {
|
||||
<app-topic-chip
|
||||
[topicId]="tag.id"
|
||||
[label]="tag.label"
|
||||
[count]="tag.count"
|
||||
[description]="tag.description"
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
<span
|
||||
class="filter-topic-chip"
|
||||
[style.--topic-color]="getFilterTopicColor(filter.value)"
|
||||
[matTooltip]="getFilterTopicTooltip(filter.value)"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="!getFilterTopicTooltip(filter.value)">
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="getFilterTopicInputs(filter.value)"
|
||||
[tooltipMaxWidth]="'500px'">
|
||||
<mat-icon class="filter-topic-chip__icon">label</mat-icon>
|
||||
<span class="filter-topic-chip__label">{{
|
||||
filter.value
|
||||
|
||||
@@ -46,6 +46,9 @@ import {
|
||||
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
|
||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||
|
||||
import { ComponentTooltipDirective } from '../../directives/component-tooltip.directive';
|
||||
import { AppTopicTooltipComponent } from '../../shared/ui/app-topic-tooltip/app-topic-tooltip.component';
|
||||
|
||||
type InstitutionYearFilterMode = 'in' | 'from' | 'between';
|
||||
|
||||
@Component({
|
||||
@@ -62,17 +65,19 @@ type InstitutionYearFilterMode = 'in' | 'from' | 'between';
|
||||
MatCheckboxModule,
|
||||
MatRadioModule,
|
||||
MatTooltipModule,
|
||||
MatAutocompleteModule,
|
||||
TopicHierarchyComponent,
|
||||
PersonCardComponent,
|
||||
SkTextDirective,
|
||||
MatAutocompleteModule,
|
||||
CountryFlagComponent,
|
||||
SkTextDirective,
|
||||
ComponentTooltipDirective,
|
||||
],
|
||||
templateUrl: './person-list.component.html',
|
||||
styleUrl: './person-list.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class PersonListComponent {
|
||||
readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly personsService = inject(PersonsService);
|
||||
@@ -477,6 +482,28 @@ export class PersonListComponent {
|
||||
});
|
||||
}
|
||||
|
||||
getFilterTopicInputs(topicName: string): { topicId?: string; topic?: any } {
|
||||
const topic = this.findPersonTopic(topicName);
|
||||
if (topic?.id) {
|
||||
return { topicId: topic.id };
|
||||
}
|
||||
return {
|
||||
topic: {
|
||||
display_name: topicName,
|
||||
description: this.getFilterTopicDescription(topicName) ?? undefined,
|
||||
subfield: this.getFilterTopicSubfieldName(topicName)
|
||||
? { display_name: this.getFilterTopicSubfieldName(topicName)! }
|
||||
: undefined,
|
||||
field: this.getFilterTopicFieldName(topicName)
|
||||
? { display_name: this.getFilterTopicFieldName(topicName)! }
|
||||
: undefined,
|
||||
domain: this.getFilterTopicDomainName(topicName)
|
||||
? { display_name: this.getFilterTopicDomainName(topicName)! }
|
||||
: undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
clearAllFilters(): void {
|
||||
this.selectedTopics.set(new Set<string>());
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
|
||||
+9
-10
@@ -171,11 +171,9 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!getMainTopicItem(item)?.id"
|
||||
[matTooltip]="getTopicTooltip(getMainTopicItem(item))"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="
|
||||
!hasTopicTooltip(getMainTopicItem(item))
|
||||
"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="{ topicId: getMainTopicItem(item)?.id }"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(click)="
|
||||
selectTopic(getMainTopicItem(item), [item.year])
|
||||
">
|
||||
@@ -208,6 +206,7 @@
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="timeline-topic-chip"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
@@ -289,11 +288,9 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!phase.primaryTopic.id"
|
||||
[matTooltip]="getTopicTooltip(phase.primaryTopic)"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="
|
||||
!hasTopicTooltip(phase.primaryTopic)
|
||||
"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="{ topicId: phase.primaryTopic.id }"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(click)="
|
||||
selectTopic(phase.primaryTopic, getPhaseYears(phase))
|
||||
">
|
||||
@@ -309,6 +306,7 @@
|
||||
<app-topic-chip
|
||||
*ngFor="let topic of phase.topics; trackBy: trackByTopic"
|
||||
class="phase-topic-chip"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
@@ -387,6 +385,7 @@
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
size="mini"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
|
||||
+4
@@ -15,6 +15,8 @@ import {
|
||||
import { TopicChipComponent } from '../../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { TopicLegendComponent } from '../../../../shared/ui/topic-legend/topic-legend.component';
|
||||
import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import { ComponentTooltipDirective } from '../../../../directives/component-tooltip.directive';
|
||||
import { AppTopicTooltipComponent } from '../../../../shared/ui/app-topic-tooltip/app-topic-tooltip.component';
|
||||
import { topicHierarchyColor } from '../../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
buildTopicLegendGroups,
|
||||
@@ -99,11 +101,13 @@ interface TimelineScrollAnchor {
|
||||
TopicChipComponent,
|
||||
TopicLegendComponent,
|
||||
YearRangeSliderComponent,
|
||||
ComponentTooltipDirective,
|
||||
],
|
||||
templateUrl: './research-timeline.component.html',
|
||||
styleUrl: './research-timeline.component.scss',
|
||||
})
|
||||
export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
|
||||
@ViewChild('timelineWrapper')
|
||||
private readonly timelineWrapper?: ElementRef<HTMLDivElement>;
|
||||
@Input() elements: TopicTimelineElement[] = [];
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
@if (loading) {
|
||||
<div class="word-cloud-state">Forschungsthemen werden geladen ...</div>
|
||||
} @else if (loadFailed) {
|
||||
<div class="word-cloud-state">
|
||||
Forschungsthemen konnten nicht geladen werden.
|
||||
</div>
|
||||
} @else if (words.length) {
|
||||
<div class="word-cloud-chart">
|
||||
@for (word of words; track word.name) {
|
||||
<button
|
||||
type="button"
|
||||
class="word-cloud-word"
|
||||
[style.color]="word.color"
|
||||
[style.fontSize.px]="word.fontSize"
|
||||
[style.fontWeight]="word.fontWeight"
|
||||
[disabled]="!word.topicId"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="{ topicId: word.rawTopicId }"
|
||||
[tooltipDisabled]="!word.rawTopicId"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(click)="selectWord(word)">
|
||||
{{ word.name }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<p class="word-cloud-state">Keine Forschungsthemen gefunden.</p>
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
:host {
|
||||
display: block;
|
||||
min-height: 420px;
|
||||
}
|
||||
|
||||
.word-cloud-chart {
|
||||
width: 100%;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
align-items: baseline;
|
||||
justify-content: center;
|
||||
gap: 0.35em 1em;
|
||||
padding: 1.5rem 1rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.word-cloud-word {
|
||||
appearance: none;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: 'Open Sans', Arial, sans-serif;
|
||||
line-height: 1.1;
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled),
|
||||
&:focus-visible {
|
||||
transform: scale(1.08);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.word-cloud-state {
|
||||
margin: 0;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
|
||||
import { ComponentTooltipDirective } from '../../../../directives/component-tooltip.directive';
|
||||
import { AppTopicTooltipComponent } from '../../../../shared/ui/app-topic-tooltip/app-topic-tooltip.component';
|
||||
import { topicHierarchyColor } from '../../../../resolvers/utils/topic-colors';
|
||||
import { TopicLegendTopic } from '../../../../resolvers/utils/topic-legend';
|
||||
|
||||
export interface WordCloudTopicOccurrence {
|
||||
name: string;
|
||||
topicId: string;
|
||||
year: number | undefined;
|
||||
fieldId: string | undefined;
|
||||
fieldName: string | undefined;
|
||||
domainId: string | undefined;
|
||||
domainName: string | undefined;
|
||||
subfieldId: string | undefined;
|
||||
subfieldName: string | undefined;
|
||||
}
|
||||
|
||||
export interface WordCloudWord {
|
||||
name: string;
|
||||
topicId: string;
|
||||
rawTopicId: string;
|
||||
color: string;
|
||||
fontSize: number;
|
||||
fontWeight: number;
|
||||
}
|
||||
|
||||
export interface ResearchWordcloud {
|
||||
words: WordCloudWord[];
|
||||
legendTopics: TopicLegendTopic[];
|
||||
}
|
||||
|
||||
const displayedWordLimit = 30;
|
||||
const minimumFontSize = 12;
|
||||
const maximumFontSize = 32;
|
||||
|
||||
export function buildResearchWordcloud(
|
||||
occurrences: WordCloudTopicOccurrence[],
|
||||
startYear: number | undefined,
|
||||
endYear: number | undefined,
|
||||
): ResearchWordcloud {
|
||||
const counts = new Map<string, number>();
|
||||
const legendTopicsByName = new Map<string, TopicLegendTopic>();
|
||||
|
||||
for (const occurrence of occurrences) {
|
||||
if (!isWithinYearRange(occurrence.year, startYear, endYear)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
counts.set(occurrence.name, (counts.get(occurrence.name) ?? 0) + 1);
|
||||
|
||||
if (!legendTopicsByName.has(occurrence.name)) {
|
||||
legendTopicsByName.set(occurrence.name, {
|
||||
id: occurrence.topicId,
|
||||
name: occurrence.name,
|
||||
field_id: occurrence.fieldId,
|
||||
field_name: occurrence.fieldName,
|
||||
domain_id: occurrence.domainId,
|
||||
domain_name: occurrence.domainName,
|
||||
subfield_id: occurrence.subfieldId,
|
||||
subfield_name: occurrence.subfieldName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (counts.size === 0) {
|
||||
return { words: [], legendTopics: [] };
|
||||
}
|
||||
|
||||
const values = Array.from(counts.values());
|
||||
const minimumValue = Math.min(...values);
|
||||
const maximumValue = Math.max(...values);
|
||||
const intensity = (value: number): number =>
|
||||
maximumValue === minimumValue
|
||||
? 1
|
||||
: (value - minimumValue) / (maximumValue - minimumValue);
|
||||
|
||||
const displayed = Array.from(counts.entries())
|
||||
.sort((left, right) => right[1] - left[1])
|
||||
.slice(0, displayedWordLimit);
|
||||
|
||||
const legendTopics = displayed
|
||||
.map(([name]) => legendTopicsByName.get(name))
|
||||
.filter((topic): topic is TopicLegendTopic => Boolean(topic));
|
||||
|
||||
const words = displayed.map(([name, value]): WordCloudWord => {
|
||||
const legendTopic = legendTopicsByName.get(name);
|
||||
const scale = intensity(value);
|
||||
|
||||
return {
|
||||
name,
|
||||
topicId: legendTopic?.id ?? '',
|
||||
rawTopicId: stripOpenAlexId(legendTopic?.id),
|
||||
color: topicHierarchyColor(legendTopic),
|
||||
fontSize: Math.round(
|
||||
minimumFontSize + scale * (maximumFontSize - minimumFontSize),
|
||||
),
|
||||
fontWeight: scale > 0.66 ? 800 : scale > 0.33 ? 600 : 400,
|
||||
};
|
||||
});
|
||||
|
||||
return { words: centreWords(words), legendTopics };
|
||||
}
|
||||
|
||||
function isWithinYearRange(
|
||||
year: number | undefined,
|
||||
startYear: number | undefined,
|
||||
endYear: number | undefined,
|
||||
): boolean {
|
||||
if (startYear !== undefined && (year === undefined || year < startYear)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (endYear !== undefined && (year === undefined || year > endYear)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function centreWords(words: WordCloudWord[]): WordCloudWord[] {
|
||||
const centred: WordCloudWord[] = [];
|
||||
|
||||
words.forEach((word, index) => {
|
||||
if (index % 2 === 0) {
|
||||
centred.push(word);
|
||||
return;
|
||||
}
|
||||
|
||||
centred.unshift(word);
|
||||
});
|
||||
|
||||
return centred;
|
||||
}
|
||||
|
||||
function stripOpenAlexId(id: string | null | undefined): string {
|
||||
return (id ?? '').replace('https://openalex.org/', '');
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-research-wordcloud',
|
||||
standalone: true,
|
||||
imports: [ComponentTooltipDirective],
|
||||
templateUrl: './research-wordcloud.component.html',
|
||||
styleUrl: './research-wordcloud.component.scss',
|
||||
})
|
||||
export class ResearchWordcloudComponent {
|
||||
readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
|
||||
|
||||
@Input() words: WordCloudWord[] = [];
|
||||
@Input() loading = false;
|
||||
@Input() loadFailed = false;
|
||||
|
||||
@Output() wordSelect = new EventEmitter<WordCloudWord>();
|
||||
|
||||
selectWord(word: WordCloudWord): void {
|
||||
if (!word.topicId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.wordSelect.emit(word);
|
||||
}
|
||||
}
|
||||
@@ -19,30 +19,11 @@
|
||||
(topicSelect)="onTimelineTopicSelect($event)"
|
||||
(yearSelect)="onTimelineYearSelect($event)"
|
||||
(loadEarlierYears)="onTimelineLoadEarlierYears()">
|
||||
<div timeline-wordcloud-content class="word-cloud-view">
|
||||
@if (loadingWordCloud) {
|
||||
<div class="word-cloud-state">Forschungsthemen werden geladen ...</div>
|
||||
} @else if (wordCloudWords.length) {
|
||||
<div class="word-cloud-chart">
|
||||
@for (word of wordCloudWords; track word.name) {
|
||||
<button
|
||||
type="button"
|
||||
class="word-cloud-word"
|
||||
[style.color]="word.color"
|
||||
[style.fontSize.px]="word.fontSize"
|
||||
[style.fontWeight]="word.fontWeight"
|
||||
[disabled]="!word.topicId"
|
||||
[matTooltip]="word.tooltip"
|
||||
[matTooltipDisabled]="!word.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
(click)="onWordClick(word)">
|
||||
{{ word.name }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
} @else if (wordCloudEmpty) {
|
||||
<p class="word-cloud-empty">Keine Forschungsthemen gefunden.</p>
|
||||
}
|
||||
</div>
|
||||
<app-research-wordcloud
|
||||
timeline-wordcloud-content
|
||||
[words]="wordCloudWords"
|
||||
[loading]="loadingWordCloud"
|
||||
[loadFailed]="wordCloudLoadFailed"
|
||||
(wordSelect)="onWordClick($event)" />
|
||||
</app-research-timeline>
|
||||
</section>
|
||||
|
||||
@@ -3,54 +3,3 @@
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.word-cloud-view {
|
||||
min-height: 420px;
|
||||
}
|
||||
|
||||
.word-cloud-chart {
|
||||
width: 100%;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
align-items: baseline;
|
||||
justify-content: center;
|
||||
gap: 0.35em 1em;
|
||||
padding: 1.5rem 1rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.word-cloud-word {
|
||||
appearance: none;
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: 'Open Sans', Arial, sans-serif;
|
||||
line-height: 1.1;
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled),
|
||||
&:focus-visible {
|
||||
transform: scale(1.08);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.word-cloud-state,
|
||||
.word-cloud-empty {
|
||||
margin: 0;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
|
||||
|
||||
import { TopicCount, TopicsByYear, WorksService } from '../../api';
|
||||
@@ -14,27 +12,19 @@ import {
|
||||
TopicTimelineElement,
|
||||
TopicTimelineTopic,
|
||||
} from './components/research-timeline/research-timeline.component';
|
||||
import {
|
||||
buildResearchWordcloud,
|
||||
ResearchWordcloudComponent,
|
||||
WordCloudTopicOccurrence,
|
||||
WordCloudWord,
|
||||
} from './components/research-wordcloud/research-wordcloud.component';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import { TopicLegendTopic } from '../../resolvers/utils/topic-legend';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip';
|
||||
|
||||
export interface WordCloudWord {
|
||||
name: string;
|
||||
value: number;
|
||||
topicId: string | undefined;
|
||||
fieldName: string | undefined;
|
||||
domainName: string | undefined;
|
||||
color: string;
|
||||
fontSize: number;
|
||||
fontWeight: number;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-overview',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ResearchTimelineComponent, MatTooltipModule],
|
||||
imports: [ResearchTimelineComponent, ResearchWordcloudComponent],
|
||||
templateUrl: './person-overview.component.html',
|
||||
styleUrl: './person-overview.component.scss',
|
||||
})
|
||||
@@ -73,19 +63,9 @@ export class PersonOverviewComponent implements OnInit {
|
||||
wordCloudWords: WordCloudWord[] = [];
|
||||
wordCloudLegendTopics: TopicLegendTopic[] = [];
|
||||
loadingWordCloud = false;
|
||||
wordCloudEmpty = false;
|
||||
wordCloudLoadFailed = false;
|
||||
|
||||
private rawTopicOccurrences: Array<{
|
||||
name: string;
|
||||
topicId: string;
|
||||
year: number | undefined;
|
||||
fieldId: string | undefined;
|
||||
fieldName: string | undefined;
|
||||
domainId: string | undefined;
|
||||
domainName: string | undefined;
|
||||
subfieldId: string | undefined;
|
||||
subfieldName: string | undefined;
|
||||
}> = [];
|
||||
private rawTopicOccurrences: WordCloudTopicOccurrence[] = [];
|
||||
|
||||
ngOnInit(): void {
|
||||
combineLatest(this.route.pathFromRoot.map((route) => route.paramMap))
|
||||
@@ -351,14 +331,14 @@ export class PersonOverviewComponent implements OnInit {
|
||||
if (!authorId || authorId === '0') {
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = false;
|
||||
this.wordCloudLoadFailed = false;
|
||||
this.loadingWordCloud = false;
|
||||
this.rawTopicOccurrences = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadingWordCloud = true;
|
||||
this.wordCloudEmpty = false;
|
||||
this.wordCloudLoadFailed = false;
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
|
||||
@@ -389,104 +369,27 @@ export class PersonOverviewComponent implements OnInit {
|
||||
|
||||
this.loadingWordCloud = false;
|
||||
|
||||
if (this.rawTopicOccurrences.length === 0) {
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => this.rebuildWordCloud());
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Word cloud could not be loaded.', error);
|
||||
this.loadingWordCloud = false;
|
||||
this.rawTopicOccurrences = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
this.wordCloudLoadFailed = true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private rebuildWordCloud(): void {
|
||||
const start = this.timelineStartYear;
|
||||
const end = this.timelineEndYear;
|
||||
const counts = new Map<string, number>();
|
||||
const nameToId = new Map<string, string>();
|
||||
const nameToColorInput = new Map<string, TopicLegendTopic>();
|
||||
const wordCloud = buildResearchWordcloud(
|
||||
this.rawTopicOccurrences,
|
||||
this.timelineStartYear,
|
||||
this.timelineEndYear,
|
||||
);
|
||||
|
||||
for (const occ of this.rawTopicOccurrences) {
|
||||
if (start !== undefined && (occ.year === undefined || occ.year < start))
|
||||
continue;
|
||||
if (end !== undefined && (occ.year === undefined || occ.year > end))
|
||||
continue;
|
||||
counts.set(occ.name, (counts.get(occ.name) ?? 0) + 1);
|
||||
if (!nameToId.has(occ.name)) {
|
||||
nameToId.set(occ.name, occ.topicId);
|
||||
nameToColorInput.set(occ.name, {
|
||||
id: occ.topicId,
|
||||
name: occ.name,
|
||||
field_id: occ.fieldId,
|
||||
field_name: occ.fieldName,
|
||||
domain_id: occ.domainId,
|
||||
domain_name: occ.domainName,
|
||||
subfield_id: occ.subfieldId,
|
||||
subfield_name: occ.subfieldName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (counts.size === 0) {
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.wordCloudEmpty = false;
|
||||
|
||||
const allValues = Array.from(counts.values());
|
||||
const minVal = Math.min(...allValues);
|
||||
const maxVal = Math.max(...allValues);
|
||||
const intensity = (v: number): number =>
|
||||
maxVal === minVal ? 1 : (v - minVal) / (maxVal - minVal);
|
||||
|
||||
const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]);
|
||||
const topNames = sorted.slice(0, 30).map(([name]) => name);
|
||||
|
||||
this.wordCloudLegendTopics = topNames
|
||||
.map((name) => nameToColorInput.get(name))
|
||||
.filter((topic): topic is TopicLegendTopic => Boolean(topic));
|
||||
|
||||
const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => {
|
||||
const t = intensity(value);
|
||||
const colorInput = nameToColorInput.get(name);
|
||||
return {
|
||||
name,
|
||||
value,
|
||||
topicId: nameToId.get(name),
|
||||
fieldName: colorInput?.field_name ?? undefined,
|
||||
domainName: colorInput?.domain_name ?? undefined,
|
||||
color: topicHierarchyColor(colorInput),
|
||||
fontSize: Math.round(12 + t * (32 - 12)),
|
||||
fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400,
|
||||
tooltip: buildTopicHierarchyTooltip({
|
||||
topicName: name,
|
||||
subfieldName: colorInput?.subfield_name,
|
||||
fieldName: colorInput?.field_name,
|
||||
domainName: colorInput?.domain_name,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
const centred: WordCloudWord[] = [];
|
||||
words.forEach((word, i) => {
|
||||
if (i % 2 === 0) {
|
||||
centred.push(word);
|
||||
} else {
|
||||
centred.unshift(word);
|
||||
}
|
||||
});
|
||||
|
||||
this.wordCloudWords = centred;
|
||||
this.wordCloudWords = wordCloud.words;
|
||||
this.wordCloudLegendTopics = wordCloud.legendTopics;
|
||||
}
|
||||
|
||||
private mapTimelineElements(
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
<mat-icon>circle</mat-icon>
|
||||
<span>{{ getStatusDisplay(dfgProject.funding_end) }}</span>
|
||||
</div>
|
||||
@if (dfgProject.link) {
|
||||
<a [href]="dfgProject.link" target="_blank" class="primary-action">
|
||||
@if (dfgProject.page_url) {
|
||||
<a
|
||||
[href]="dfgProject.page_url"
|
||||
target="_blank"
|
||||
class="primary-action">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
<span>Zum Projekt</span>
|
||||
</a>
|
||||
@@ -218,10 +221,7 @@
|
||||
</div>
|
||||
@if (getInstitutionsList().length > 0) {
|
||||
<div class="institution-grid">
|
||||
@for (
|
||||
institution of getInstitutionsList();
|
||||
track institution.institute_id + (institution.role_key || '')
|
||||
) {
|
||||
@for (institution of getInstitutionsList(); track $index) {
|
||||
<div
|
||||
(click)="
|
||||
searchForInstitutionName(getInstitutionName(institution))
|
||||
|
||||
@@ -245,6 +245,7 @@
|
||||
track keyword.id || keyword.label
|
||||
) {
|
||||
<app-topic-chip
|
||||
[topicId]="keyword.id"
|
||||
[label]="keyword.label"
|
||||
[count]="keyword.count"
|
||||
[subfieldName]="keyword.subfieldName"
|
||||
|
||||
+4
-7
@@ -40,13 +40,10 @@
|
||||
}
|
||||
|
||||
@if (authorList.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isExpanded"
|
||||
(click)="togglePublicationAuthorsExpansion(pub)">
|
||||
{{ isExpanded ? 'weniger' : '+' + (authorList.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isExpanded"
|
||||
[hiddenCount]="authorList.length - 3"
|
||||
(toggle)="togglePublicationAuthorsExpansion(pub)" />
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
|
||||
-23
@@ -6,29 +6,6 @@
|
||||
background: var(--sg-card-bg);
|
||||
border: 1px solid var(--sg-border);
|
||||
}
|
||||
.publication-institution-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
+2
@@ -20,10 +20,12 @@ import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../../../shared/ui/data-table/data-table.component';
|
||||
import { ChipOverflowToggleComponent } from '../../../../shared/ui/chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publications-table',
|
||||
imports: [
|
||||
ChipOverflowToggleComponent,
|
||||
CommonModule,
|
||||
MatIcon,
|
||||
MatCard,
|
||||
|
||||
@@ -230,6 +230,8 @@
|
||||
<div class="tags">
|
||||
@for (topic of publication.topics; track topic.id) {
|
||||
<app-topic-chip
|
||||
[topic]="topic"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.display_name || ''"
|
||||
[description]="topic.description"
|
||||
[subfieldName]="topic.subfield?.display_name"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Injectable, inject, signal } from '@angular/core';
|
||||
import { Subject, of } from 'rxjs';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
import {
|
||||
UniversityRankingsService,
|
||||
PersonsService,
|
||||
@@ -42,6 +44,124 @@ export class TrendDataService {
|
||||
|
||||
private readonly cacheMap = new Map<string, TrendResponse>();
|
||||
|
||||
// RxJS Subjects for cancellation of pending requests
|
||||
private readonly topTopicsSubject = new Subject<{
|
||||
cleanId: string;
|
||||
entityType: string;
|
||||
startYear: number;
|
||||
endYear: number;
|
||||
searchType: string;
|
||||
}>();
|
||||
|
||||
private readonly instSuggestionsSubject = new Subject<{
|
||||
topic: string;
|
||||
countryFilter?: string;
|
||||
regionFilter?: string;
|
||||
}>();
|
||||
|
||||
private readonly recAuthorsSubject = new Subject<{
|
||||
topic: string;
|
||||
primaryInstId: string;
|
||||
}>();
|
||||
|
||||
constructor() {
|
||||
this.topTopicsSubject
|
||||
.pipe(
|
||||
switchMap((params) => {
|
||||
if (!params.cleanId || params.searchType === 'all') {
|
||||
this.isTopTopicsLoading.set(false);
|
||||
this.topTopicsData.set([]);
|
||||
return of([]);
|
||||
}
|
||||
return this.apiService
|
||||
.getTopTopicsApiInseServiceUniversityRankingsTopTopicsGet(
|
||||
params.cleanId,
|
||||
params.entityType,
|
||||
params.startYear,
|
||||
params.endYear,
|
||||
params.searchType,
|
||||
)
|
||||
.pipe(
|
||||
map((res) =>
|
||||
(res.items || []).map((item) => ({
|
||||
value: item.count,
|
||||
name: item.name,
|
||||
})),
|
||||
),
|
||||
catchError((err) => {
|
||||
console.error('Failed to load top topics:', err);
|
||||
this.topTopicsError.set(true);
|
||||
return of([]);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
)
|
||||
.subscribe((data) => {
|
||||
this.topTopicsData.set(data);
|
||||
this.isTopTopicsLoading.set(false);
|
||||
});
|
||||
|
||||
this.instSuggestionsSubject
|
||||
.pipe(
|
||||
switchMap((params) =>
|
||||
this.apiService
|
||||
.getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
|
||||
params.topic,
|
||||
params.regionFilter,
|
||||
params.countryFilter,
|
||||
6,
|
||||
)
|
||||
.pipe(catchError(() => of([]))),
|
||||
),
|
||||
)
|
||||
.subscribe((data: any) => {
|
||||
this.topSuggestions.set(data || []);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
});
|
||||
|
||||
this.recAuthorsSubject
|
||||
.pipe(
|
||||
switchMap((params) => {
|
||||
const cleanInst = cleanEntityId(params.primaryInstId) || 'I62318514';
|
||||
return this.personsApiService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
cleanInst,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[params.topic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.pipe(
|
||||
switchMap((res) => {
|
||||
if (res.results && res.results.length > 0) {
|
||||
return of(res.results);
|
||||
}
|
||||
return this.personsApiService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
undefined,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[params.topic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.pipe(map((gRes) => gRes.results || []));
|
||||
}),
|
||||
catchError(() => of([])),
|
||||
);
|
||||
}),
|
||||
)
|
||||
.subscribe((authors) => {
|
||||
this.recommendedAuthors.set(authors);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
private getCacheKey(params: TrendRequestParams): string {
|
||||
return JSON.stringify({
|
||||
searchType: params.searchType,
|
||||
@@ -93,38 +213,19 @@ export class TrendDataService {
|
||||
): void {
|
||||
if (!entityId || searchType === 'all') {
|
||||
this.topTopicsData.set([]);
|
||||
this.isTopTopicsLoading.set(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.isTopTopicsLoading.set(true);
|
||||
this.topTopicsError.set(false);
|
||||
|
||||
const cleanId = cleanEntityId(entityId);
|
||||
|
||||
this.apiService
|
||||
.getTopTopicsApiInseServiceUniversityRankingsTopTopicsGet(
|
||||
cleanId,
|
||||
entityType,
|
||||
startYear,
|
||||
endYear,
|
||||
searchType,
|
||||
)
|
||||
.subscribe({
|
||||
next: (res) => {
|
||||
const mapped = (res.items || []).map((item) => ({
|
||||
value: item.count,
|
||||
name: item.name,
|
||||
}));
|
||||
this.topTopicsData.set(mapped);
|
||||
this.isTopTopicsLoading.set(false);
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Failed to load top topics:', err);
|
||||
this.topTopicsError.set(true);
|
||||
this.isTopTopicsLoading.set(false);
|
||||
this.topTopicsData.set([]);
|
||||
},
|
||||
});
|
||||
this.topTopicsSubject.next({
|
||||
cleanId: cleanEntityId(entityId),
|
||||
entityType,
|
||||
startYear,
|
||||
endYear,
|
||||
searchType,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,24 +237,7 @@ export class TrendDataService {
|
||||
regionFilter?: string,
|
||||
): void {
|
||||
this.isSuggestionsLoading.set(true);
|
||||
|
||||
this.apiService
|
||||
.getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
|
||||
topic,
|
||||
regionFilter,
|
||||
countryFilter,
|
||||
6,
|
||||
)
|
||||
.subscribe({
|
||||
next: (res: any) => {
|
||||
this.topSuggestions.set(res || []);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.topSuggestions.set([]);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
},
|
||||
});
|
||||
this.instSuggestionsSubject.next({ topic, countryFilter, regionFilter });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,53 +245,6 @@ export class TrendDataService {
|
||||
*/
|
||||
loadRecommendedAuthors(topic: string, primaryInstId: string): void {
|
||||
this.isSuggestionsLoading.set(true);
|
||||
const cleanInst = cleanEntityId(primaryInstId) || 'I62318514';
|
||||
|
||||
this.personsApiService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
cleanInst,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[topic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.subscribe({
|
||||
next: (res) => {
|
||||
if (res.results && res.results.length > 0) {
|
||||
this.recommendedAuthors.set(res.results);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
} else {
|
||||
// Global fallback search across all institutions
|
||||
this.personsApiService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
undefined,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[topic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.subscribe({
|
||||
next: (globalRes) => {
|
||||
this.recommendedAuthors.set(globalRes.results || []);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this.recommendedAuthors.set([]);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
this.recommendedAuthors.set([]);
|
||||
this.isSuggestionsLoading.set(false);
|
||||
},
|
||||
});
|
||||
this.recAuthorsSubject.next({ topic, primaryInstId });
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -188,9 +188,9 @@
|
||||
<div class="cc-news-hint">
|
||||
<mat-icon>info_outline</mat-icon>
|
||||
<span>
|
||||
Der CC-News-Vergleich (hinterlegte Fläche, ab 2017) ist aktuell nur bei
|
||||
deaktivierter Fuzzy-Suche verfügbar, da für Web-Nachrichten kein
|
||||
Themen-Mapping existiert.
|
||||
Der CC-News-Vergleich (hinterlegte Fläche, ab 2017) ist aktuell
|
||||
nur bei deaktivierter Fuzzy-Suche verfügbar, da für
|
||||
Web-Nachrichten kein Themen-Mapping existiert.
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
@@ -198,11 +198,11 @@
|
||||
<div class="chart-topic-tabs">
|
||||
@for (topic of selectedTrendTopics(); track $index) {
|
||||
<app-topic-chip
|
||||
[topicId]="topic"
|
||||
[label]="getMappedTopic(topic)"
|
||||
[active]="activeChartTopic() === topic"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="isTopicEmpty(topic)"
|
||||
[matTooltip]="getMappedTopic(topic)"
|
||||
(chipClick)="updateActiveChartTopic(topic)">
|
||||
</app-topic-chip>
|
||||
}
|
||||
|
||||
+23
-34
@@ -557,49 +557,33 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
|
||||
isTopicEmpty(topic: string): boolean {
|
||||
const allSeries = this.rawTrendResponse()?.series || [];
|
||||
const allSeries =
|
||||
this.trendResponse()?.series || this.rawTrendResponse()?.series || [];
|
||||
if (allSeries.length === 0) return true;
|
||||
const series =
|
||||
this.selectedSearchType() === 'news'
|
||||
? allSeries.filter((s) => this.seriesTopicName(s.entity_id) === topic)
|
||||
: allSeries;
|
||||
if (series.length === 0) return true;
|
||||
|
||||
const mapped = this.getMappedTopic(topic);
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
const cId = cleanEntityId(topic);
|
||||
|
||||
for (const s of series) {
|
||||
if (!s.topic_data) continue;
|
||||
const keys = [
|
||||
topic,
|
||||
mapped,
|
||||
cId ? `https://openalex.org/${cId}` : '',
|
||||
cId,
|
||||
].filter(Boolean);
|
||||
|
||||
for (const k of keys) {
|
||||
const topicItems = s.topic_data[k];
|
||||
if (topicItems && topicItems.length > 0) {
|
||||
const sumRaw = topicItems
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((acc, curr) => acc + (curr.raw || 0), 0);
|
||||
if (sumRaw > 0) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return isTopicEmptyForSeries(
|
||||
topic,
|
||||
series,
|
||||
this.startYear(),
|
||||
this.endYear(),
|
||||
(t) => this.getMappedTopic(t),
|
||||
);
|
||||
}
|
||||
|
||||
findFirstNonEmptyTopic(topics: string[]): string {
|
||||
const allSeries =
|
||||
this.trendResponse()?.series || this.rawTrendResponse()?.series || [];
|
||||
if (!topics || topics.length === 0) return '';
|
||||
for (const t of topics) {
|
||||
if (!this.isTopicEmpty(t)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return topics[0];
|
||||
return findFirstNonEmptyTopic(
|
||||
topics,
|
||||
allSeries,
|
||||
this.startYear(),
|
||||
this.endYear(),
|
||||
(t) => this.getMappedTopic(t),
|
||||
);
|
||||
}
|
||||
|
||||
isVisible(id: string): boolean {
|
||||
@@ -903,6 +887,11 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
if (resolved.authors && resolved.authors.length > 0) {
|
||||
this.comparisonAuthors.set(resolved.authors);
|
||||
const currentUrlAuthors =
|
||||
this.route.snapshot.queryParamMap.getAll('authors');
|
||||
if (currentUrlAuthors.length === 0 && type === 'authors') {
|
||||
this.updateUrlParams();
|
||||
}
|
||||
}
|
||||
|
||||
if (resolved.treemapNode !== undefined) {
|
||||
|
||||
@@ -26,15 +26,42 @@ export function isTopicEmptyForSeries(
|
||||
seriesList: TrendSeries[],
|
||||
startYr: number,
|
||||
endYr: number,
|
||||
getMappedTopicFn?: (topic: string) => string,
|
||||
): boolean {
|
||||
if (!seriesList || seriesList.length === 0) return true;
|
||||
const mapped = getMappedTopicFn ? getMappedTopicFn(topicName) : topicName;
|
||||
const cleanId = cleanEntityId(topicName);
|
||||
const cleanMappedId = cleanEntityId(mapped);
|
||||
const topicLower = topicName.toLowerCase().trim();
|
||||
const mappedLower = mapped.toLowerCase().trim();
|
||||
|
||||
for (const s of seriesList) {
|
||||
const topicItems = s.topic_data?.[topicName] || [];
|
||||
const filtered = topicItems.filter(
|
||||
(y) => y.year >= startYr && y.year <= endYr,
|
||||
);
|
||||
const sumRaw = filtered.reduce((acc, curr) => acc + (curr.raw || 0), 0);
|
||||
if (sumRaw > 0) return false;
|
||||
if (!s.topic_data) continue;
|
||||
const entries = Object.entries(s.topic_data);
|
||||
|
||||
for (const [key, topicItems] of entries) {
|
||||
if (!topicItems || topicItems.length === 0) continue;
|
||||
|
||||
const keyLower = key.toLowerCase().trim();
|
||||
const keyClean = cleanEntityId(key);
|
||||
const revMapped = getMappedTopicFn
|
||||
? getMappedTopicFn(key).toLowerCase().trim()
|
||||
: '';
|
||||
|
||||
const isMatch =
|
||||
keyLower === topicLower ||
|
||||
keyLower === mappedLower ||
|
||||
(cleanId && keyClean === cleanId) ||
|
||||
(cleanMappedId && keyClean === cleanMappedId) ||
|
||||
(revMapped && (revMapped === topicLower || revMapped === mappedLower));
|
||||
|
||||
if (isMatch) {
|
||||
const sumRaw = topicItems
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((acc, curr) => acc + (curr.raw || 0), 0);
|
||||
if (sumRaw > 0) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -47,10 +74,13 @@ export function findFirstNonEmptyTopic(
|
||||
seriesList: TrendSeries[],
|
||||
startYr: number,
|
||||
endYr: number,
|
||||
getMappedTopicFn?: (topic: string) => string,
|
||||
): string {
|
||||
if (!topics || topics.length === 0) return '';
|
||||
for (const t of topics) {
|
||||
if (!isTopicEmptyForSeries(t, seriesList, startYr, endYr)) {
|
||||
if (
|
||||
!isTopicEmptyForSeries(t, seriesList, startYr, endYr, getMappedTopicFn)
|
||||
) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { inject } from '@angular/core';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { NewsPage, NewsService } from '../api';
|
||||
|
||||
export const keywordsNewsQueryParamKeys = {
|
||||
page: 'page',
|
||||
size: 'size',
|
||||
relevance: 'relevance',
|
||||
yearFrom: 'yearFrom',
|
||||
yearTo: 'yearTo',
|
||||
topicId: 'topicId',
|
||||
sortOrder: 'sorting_order',
|
||||
} as const;
|
||||
|
||||
const emptyPage = (page: number, pageSize: number): NewsPage => ({
|
||||
total: 0,
|
||||
page,
|
||||
page_size: pageSize,
|
||||
results: [],
|
||||
});
|
||||
|
||||
export const keywordsNewsPageResolver: ResolveFn<NewsPage> = (route) => {
|
||||
const params = route.queryParamMap;
|
||||
|
||||
const page = Number(params.get(keywordsNewsQueryParamKeys.page)) || 0;
|
||||
const size = Number(params.get(keywordsNewsQueryParamKeys.size)) || 10;
|
||||
|
||||
const keywords = splitList(params.get('keywords'));
|
||||
const topicIds = splitList(params.get('topics'));
|
||||
const filterTopicIds = params.getAll(keywordsNewsQueryParamKeys.topicId);
|
||||
const fuzzy = params.get('fuzzy') === 'true';
|
||||
|
||||
const canSearch = fuzzy
|
||||
? topicIds.length > 0 || keywords.length > 0
|
||||
: keywords.length > 0;
|
||||
|
||||
if (!canSearch) {
|
||||
return of(emptyPage(page + 1, size));
|
||||
}
|
||||
|
||||
const relevance =
|
||||
params.get(keywordsNewsQueryParamKeys.relevance) || undefined;
|
||||
const yearFrom = parseYear(params.get(keywordsNewsQueryParamKeys.yearFrom));
|
||||
const yearTo = parseYear(params.get(keywordsNewsQueryParamKeys.yearTo));
|
||||
const sortOrder = parseSortOrder(
|
||||
params.get(keywordsNewsQueryParamKeys.sortOrder),
|
||||
);
|
||||
|
||||
return inject(NewsService).getNewsByKeywords(
|
||||
keywords,
|
||||
topicIds,
|
||||
filterTopicIds,
|
||||
fuzzy,
|
||||
page + 1,
|
||||
size,
|
||||
relevance,
|
||||
yearFrom,
|
||||
yearTo,
|
||||
sortOrder,
|
||||
);
|
||||
};
|
||||
|
||||
function splitList(raw: string | null): string[] {
|
||||
if (!raw) return [];
|
||||
return raw
|
||||
.split(',')
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function parseYear(raw: string | null): number | undefined {
|
||||
const year = Number.parseInt(raw ?? '', 10);
|
||||
return Number.isNaN(year) ? undefined : year;
|
||||
}
|
||||
|
||||
function parseSortOrder(raw: string | null): string | undefined {
|
||||
return raw === 'asc' || raw === 'desc' ? raw : undefined;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { catchError, of, Observable, map, forkJoin } from 'rxjs';
|
||||
import { catchError, of, Observable, map, forkJoin, switchMap } from 'rxjs';
|
||||
import {
|
||||
TrendResponse,
|
||||
UniversityRankingsService,
|
||||
@@ -142,13 +142,6 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
return { id: cleanId, name: parts[1] || parts[0] };
|
||||
});
|
||||
|
||||
const instIds =
|
||||
parsedInstitutions.length > 0
|
||||
? parsedInstitutions.map((i) => i.id)
|
||||
: [primaryInstId];
|
||||
const countryIds = parsedCountries.map((c) => c.id);
|
||||
const regionIds = parsedRegions.map((r) => r.id);
|
||||
const authorIds = parsedAuthors.map((a) => a.id);
|
||||
const apiService = inject(UniversityRankingsService);
|
||||
const errorService = inject(ErrorService);
|
||||
const personsService = inject(PersonsService, { optional: true });
|
||||
@@ -159,148 +152,179 @@ export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
const regionFilter =
|
||||
parsedRegions.length > 0 ? parsedRegions[0].id : undefined;
|
||||
|
||||
const currentParams: TrendRequestParams = {
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions: instIds,
|
||||
countries: countryIds,
|
||||
regions: regionIds,
|
||||
authors: authorIds,
|
||||
searchType,
|
||||
const fetchTrendAndSuggestions = (
|
||||
authors: CompareItem[],
|
||||
): Observable<UniTrendResolvedData> => {
|
||||
const instIds =
|
||||
parsedInstitutions.length > 0
|
||||
? parsedInstitutions.map((i) => i.id)
|
||||
: [primaryInstId];
|
||||
const countryIds = parsedCountries.map((c) => c.id);
|
||||
const regionIds = parsedRegions.map((r) => r.id);
|
||||
const authorIds = authors.map((a) => a.id);
|
||||
|
||||
const currentParams: TrendRequestParams = {
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions: instIds,
|
||||
countries: countryIds,
|
||||
regions: regionIds,
|
||||
authors: authorIds,
|
||||
searchType,
|
||||
};
|
||||
|
||||
let trendObs$: Observable<TrendResponse | null>;
|
||||
if (trendDataService.canReuseCache(currentParams)) {
|
||||
trendObs$ = of(trendDataService.getCachedResponse(currentParams));
|
||||
} else {
|
||||
trendObs$ = apiService
|
||||
.getTrendApiInseServiceUniversityRankingsTrendGet(
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
instIds,
|
||||
countryIds,
|
||||
regionIds,
|
||||
authorIds,
|
||||
searchType as any,
|
||||
)
|
||||
.pipe(
|
||||
map((res) => {
|
||||
trendDataService.updateCache(res, currentParams);
|
||||
return res;
|
||||
}),
|
||||
catchError((err) => {
|
||||
errorService.setError({
|
||||
statusCode: err?.status || 500,
|
||||
title: 'Visualisierungs-Fehler',
|
||||
message: 'Trenddaten konnten nicht geladen werden.',
|
||||
errorDetails: err?.message || String(err),
|
||||
});
|
||||
return 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 }) => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
trendResponse,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions: parsedInstitutions,
|
||||
countries: parsedCountries,
|
||||
regions: parsedRegions,
|
||||
authors,
|
||||
initialActiveTopic,
|
||||
topSuggestions: topSuggestions as any[],
|
||||
recommendedAuthors: recommendedAuthors as any[],
|
||||
treemapNode,
|
||||
};
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
// Check exact parameter keyed cache
|
||||
let trendObs$: Observable<TrendResponse | null>;
|
||||
if (trendDataService.canReuseCache(currentParams)) {
|
||||
trendObs$ = of(trendDataService.getCachedResponse(currentParams));
|
||||
} else {
|
||||
trendObs$ = apiService
|
||||
.getTrendApiInseServiceUniversityRankingsTrendGet(
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
instIds,
|
||||
countryIds,
|
||||
regionIds,
|
||||
authorIds,
|
||||
searchType as any,
|
||||
if (
|
||||
searchType === 'authors' &&
|
||||
parsedAuthors.length === 0 &&
|
||||
personsService
|
||||
) {
|
||||
return personsService
|
||||
.searchPersonsList(
|
||||
undefined,
|
||||
primaryInstId,
|
||||
'cited_by_count',
|
||||
'desc',
|
||||
[primaryTopic],
|
||||
1,
|
||||
6,
|
||||
undefined,
|
||||
)
|
||||
.pipe(
|
||||
map((res) => {
|
||||
trendDataService.updateCache(res, currentParams);
|
||||
return res;
|
||||
}),
|
||||
catchError((err) => {
|
||||
errorService.setError({
|
||||
statusCode: err?.status || 500,
|
||||
title: 'Visualisierungs-Fehler',
|
||||
message: 'Trenddaten konnten nicht geladen werden.',
|
||||
errorDetails: err?.message || String(err),
|
||||
});
|
||||
return of(null);
|
||||
map((res: any) => res.results || []),
|
||||
catchError(() => of([])),
|
||||
switchMap((recAuthors) => {
|
||||
const defaultAuthors: CompareItem[] = recAuthors
|
||||
.slice(0, 3)
|
||||
.map((author: any) => ({
|
||||
id: cleanEntityId(author.id),
|
||||
name: author.display_name || 'Unbekannt',
|
||||
}));
|
||||
return fetchTrendAndSuggestions(defaultAuthors);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
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 }) => {
|
||||
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 (
|
||||
searchType === 'authors' &&
|
||||
parsedAuthors.length === 0 &&
|
||||
recommendedAuthors?.length
|
||||
) {
|
||||
recommendedAuthors.slice(0, 3).forEach((author: any) => {
|
||||
parsedAuthors.push({
|
||||
id: cleanEntityId(author.id),
|
||||
name: author.display_name || 'Unbekannt',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
trendResponse,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions: parsedInstitutions,
|
||||
countries: parsedCountries,
|
||||
regions: parsedRegions,
|
||||
authors: parsedAuthors,
|
||||
initialActiveTopic,
|
||||
topSuggestions: topSuggestions as any[],
|
||||
recommendedAuthors: recommendedAuthors as any[],
|
||||
treemapNode,
|
||||
};
|
||||
}),
|
||||
);
|
||||
return fetchTrendAndSuggestions(parsedAuthors);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<mat-chip
|
||||
class="author-chip"
|
||||
[appComponentTooltip]="AuthorTooltipComponent"
|
||||
[tooltipInputs]="{ authorId: rawOaAuthorId() }"
|
||||
[tooltipInputs]="{ author: _author(), authorId: rawOaAuthorId() }"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
|
||||
@@ -12,7 +12,7 @@ import { AppAuthorTooltipComponent } from '../app-author-tooltip/app-author-tool
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--border-width]': 'isSelected() ? "2px" : "1px"',
|
||||
@@ -22,7 +22,12 @@ import { MatChipsModule } from '@angular/material/chips';
|
||||
'[class.is-mini-size]': 'isMiniSize()',
|
||||
},
|
||||
selector: 'app-author-chip',
|
||||
imports: [MatIconModule, MatChipsModule, ComponentTooltipDirective],
|
||||
imports: [
|
||||
MatIconModule,
|
||||
MatChipsModule,
|
||||
ComponentTooltipDirective,
|
||||
SkTextDirective,
|
||||
],
|
||||
templateUrl: './app-author-chip.component.html',
|
||||
styleUrl: './app-author-chip.component.scss',
|
||||
})
|
||||
|
||||
@@ -23,7 +23,8 @@ import { AppAuthorCardComponent } from '../app-author-card/app-author-card.compo
|
||||
export class AppAuthorTooltipComponent {
|
||||
private readonly authorsService = inject(AuthorsV2Service);
|
||||
|
||||
authorId = input.required<string>();
|
||||
authorId = input<string | null | undefined>(undefined);
|
||||
author = input<Author | null | undefined>(undefined);
|
||||
|
||||
_author = signal<Author | undefined>(undefined);
|
||||
|
||||
@@ -31,15 +32,33 @@ export class AppAuthorTooltipComponent {
|
||||
|
||||
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);
|
||||
const authorObj = this.author();
|
||||
const authorId = this.authorId() ?? authorObj?.id;
|
||||
|
||||
if (authorObj) {
|
||||
this._author.set(authorObj);
|
||||
this._isLoading.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
if (authorId) {
|
||||
const cleanId = authorId.replace('https://openalex.org/', '');
|
||||
this._isLoading.set(true);
|
||||
this.authorsService.getAuthorById(cleanId).subscribe({
|
||||
next: (fetchedAuthor) => {
|
||||
this._author.set({
|
||||
...authorObj,
|
||||
...fetchedAuthor,
|
||||
});
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
});
|
||||
} else if (!authorObj) {
|
||||
this._author.set(undefined);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<mat-chip
|
||||
class="institution-chip"
|
||||
[appComponentTooltip]="AppInstitutionTooltipComponent"
|
||||
[tooltipInputs]="{ institutionId: rawOaInstitutionId() }"
|
||||
[tooltipInputs]="{
|
||||
institution: _institution(),
|
||||
institutionId: rawOaInstitutionId(),
|
||||
}"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
|
||||
+27
-10
@@ -11,7 +11,8 @@ import { AppInstitutionCardComponent } from '../app-institution-card/app-institu
|
||||
export class AppInstitutionTooltipComponent {
|
||||
private readonly institutionsService = inject(InstitutionsV2Service);
|
||||
|
||||
institutionId = input.required<string>();
|
||||
institutionId = input<string | null | undefined>(undefined);
|
||||
institution = input<Institution | null | undefined>(undefined);
|
||||
|
||||
_institution = signal<Institution | undefined>(undefined);
|
||||
|
||||
@@ -19,17 +20,33 @@ export class AppInstitutionTooltipComponent {
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const institutionId = this.institutionId();
|
||||
if (!institutionId) {
|
||||
this._institution.set(undefined);
|
||||
const institutionObj = this.institution();
|
||||
const institutionId = this.institutionId() ?? institutionObj?.id;
|
||||
|
||||
if (institutionObj) {
|
||||
this._institution.set(institutionObj);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.institutionsService
|
||||
.getInstitutionById2(institutionId)
|
||||
.subscribe((institution) => {
|
||||
this._institution.set(institution);
|
||||
this._isLoading.set(false);
|
||||
|
||||
if (institutionId) {
|
||||
const cleanId = institutionId.replace('https://openalex.org/', '');
|
||||
this._isLoading.set(true);
|
||||
this.institutionsService.getInstitutionById2(cleanId).subscribe({
|
||||
next: (fetchedInst) => {
|
||||
this._institution.set({
|
||||
...institutionObj,
|
||||
...fetchedInst,
|
||||
});
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
});
|
||||
} else if (!institutionObj) {
|
||||
this._institution.set(undefined);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export class AppMenuComponent {
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'News',
|
||||
label: 'Nachrichten',
|
||||
icon: NEWS_ICON,
|
||||
route: '/news',
|
||||
disabled: false,
|
||||
|
||||
@@ -35,18 +35,20 @@
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
<mat-divider />
|
||||
@if (topic.id) {
|
||||
<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-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>
|
||||
|
||||
@@ -35,7 +35,13 @@ export class AppTopicCardComponent {
|
||||
}
|
||||
|
||||
subtitle = computed(() => {
|
||||
return `${this.topic().subfield?.display_name} - ${this.topic().field?.display_name} - ${this.topic().domain?.display_name}`;
|
||||
return [
|
||||
this.topic().subfield?.display_name,
|
||||
this.topic().field?.display_name,
|
||||
this.topic().domain?.display_name,
|
||||
]
|
||||
.filter((part) => Boolean(part))
|
||||
.join(' - ');
|
||||
});
|
||||
|
||||
description = computed(() => {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ComponentTooltipDirective } from '../../../directives/component-tooltip
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { AppTopicTooltipComponent } from '../app-topic-tooltip/app-topic-tooltip.component';
|
||||
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--topic-color]': 'color()',
|
||||
@@ -23,7 +23,12 @@ import { AppTopicTooltipComponent } from '../app-topic-tooltip/app-topic-tooltip
|
||||
'[class.is-mini-size]': 'isMiniSize()',
|
||||
},
|
||||
selector: 'app-topic-chip-2',
|
||||
imports: [MatChipsModule, ComponentTooltipDirective, MatIconModule],
|
||||
imports: [
|
||||
MatChipsModule,
|
||||
ComponentTooltipDirective,
|
||||
MatIconModule,
|
||||
SkTextDirective,
|
||||
],
|
||||
templateUrl: './app-topic-chip.component.html',
|
||||
styleUrl: './app-topic-chip.component.scss',
|
||||
})
|
||||
|
||||
@@ -11,22 +11,55 @@ import { AppTopicCardComponent } from '../app-topic-card/app-topic-card.componen
|
||||
export class AppTopicTooltipComponent {
|
||||
private readonly topicsService = inject(TopicsV2Service);
|
||||
|
||||
topicId = input.required<string>();
|
||||
topicId = input<string | null | undefined>(undefined);
|
||||
topic = input<Topic | null | undefined>(undefined);
|
||||
|
||||
_topic = signal<Topic | undefined>(undefined);
|
||||
|
||||
_isLoading = signal<boolean>(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const topicId = this.topicId();
|
||||
if (!topicId) {
|
||||
this._topic.set(undefined);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.topicsService.getTopicById(topicId).subscribe((topic) => {
|
||||
this._topic.set(topic);
|
||||
const topicObj = this.topic();
|
||||
const topicId = this.topicId() ?? topicObj?.id;
|
||||
|
||||
const hasCompleteMetrics = Boolean(
|
||||
topicObj &&
|
||||
topicObj.description &&
|
||||
topicObj.works_count !== undefined &&
|
||||
topicObj.cited_by_count !== undefined &&
|
||||
topicObj.subfield &&
|
||||
topicObj.field &&
|
||||
topicObj.domain,
|
||||
);
|
||||
|
||||
if (hasCompleteMetrics && topicObj) {
|
||||
this._topic.set(topicObj);
|
||||
this._isLoading.set(false);
|
||||
});
|
||||
} else if (topicId) {
|
||||
const cleanId = topicId.replace('https://openalex.org/', '');
|
||||
if (topicObj) {
|
||||
this._topic.set(topicObj);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.topicsService.getTopicById(cleanId).subscribe({
|
||||
next: (fetchedTopic) => {
|
||||
this._topic.set({
|
||||
...topicObj,
|
||||
...fetchedTopic,
|
||||
});
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
});
|
||||
} else if (topicObj) {
|
||||
this._topic.set(topicObj);
|
||||
this._isLoading.set(false);
|
||||
} else {
|
||||
this._topic.set(undefined);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,23 @@
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
|
||||
<ng-template #fundingStartTmp let-element>
|
||||
{{ getStartDate(element) | date: 'dd.MM.yyyy' }}
|
||||
<span>
|
||||
{{ getStartDate(element) | date: 'dd.MM.yyyy' }}
|
||||
</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{ getEndDate(element) | date: 'dd.MM.yyyy' }}
|
||||
<span>
|
||||
{{ getEndDate(element) | date: 'dd.MM.yyyy' }}
|
||||
</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingAmountTmp let-element>
|
||||
{{ getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
||||
<span>
|
||||
{{
|
||||
getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}
|
||||
</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-element>
|
||||
@@ -31,20 +39,6 @@
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
<ng-template #detailRowTmp let-element>
|
||||
<div class="classification-container">
|
||||
@for (classification of element.subject_classifications; track $index) {
|
||||
<p>
|
||||
{{ classification.wissenschaftsbereich || '-' }}
|
||||
→ {{ classification.fachkollegium || '-' }} →
|
||||
{{ classification.fachgebiet || '-' }} →
|
||||
{{ classification.fach || '-' }}
|
||||
</p>
|
||||
} @empty {
|
||||
<span>-</span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #institutionsTmp let-project>
|
||||
@let institutions = getProjectInstitutions(project);
|
||||
@@ -79,7 +73,7 @@
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleFundingTypeFilter(project.funding_type)">
|
||||
<app-chip [color]="getFundingTypeColor(project.funding_type)">
|
||||
{{ project.funding_type }}
|
||||
<span>{{ project.funding_type }}</span>
|
||||
</app-chip>
|
||||
</button>
|
||||
} @else {
|
||||
@@ -105,13 +99,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (projectTopics.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isTopicsExpanded"
|
||||
(click)="toggleProjectTopicsExpansion(project)">
|
||||
{{ isTopicsExpanded ? 'weniger' : '+' + (projectTopics.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isTopicsExpanded"
|
||||
[hiddenCount]="projectTopics.length - 3"
|
||||
(toggle)="toggleProjectTopicsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -121,30 +121,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.publication-institution-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Containers for chips
|
||||
// ------------------------
|
||||
|
||||
@@ -25,9 +25,12 @@ import { ChipComponent } from '../chip/chip.component';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver';
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
@Component({
|
||||
selector: 'app-bund-project-table',
|
||||
imports: [
|
||||
ChipOverflowToggleComponent,
|
||||
DataTableComponent,
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
@@ -38,6 +41,7 @@ import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.reso
|
||||
DatePipe,
|
||||
ChipComponent,
|
||||
AppTopicChipComponent,
|
||||
SkTextDirective,
|
||||
],
|
||||
templateUrl: './bund-project-table.component.html',
|
||||
styleUrl: './bund-project-table.component.scss',
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="chip-overflow-toggle"
|
||||
[attr.aria-expanded]="expanded()"
|
||||
(click)="toggle.emit()">
|
||||
{{ expanded() ? 'weniger' : '+' + hiddenCount() }}
|
||||
</button>
|
||||
@@ -0,0 +1,27 @@
|
||||
:host {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.chip-overflow-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Component, input, output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-chip-overflow-toggle',
|
||||
standalone: true,
|
||||
templateUrl: './chip-overflow-toggle.component.html',
|
||||
styleUrl: './chip-overflow-toggle.component.scss',
|
||||
})
|
||||
export class ChipOverflowToggleComponent {
|
||||
expanded = input<boolean>(false);
|
||||
hiddenCount = input<number>(0);
|
||||
|
||||
toggle = output<void>();
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
context: { $implicit: row }
|
||||
"></ng-container>
|
||||
} @else if (col.type === 'accessor') {
|
||||
{{ row[col.accessorKey] }}
|
||||
<span>{{ row[col.accessorKey] }}</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from '@angular/material/sort';
|
||||
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
export interface BaseColumn<T> {
|
||||
id: string;
|
||||
header: string;
|
||||
@@ -43,7 +43,7 @@ export type GenericColumn<T> = AccessorColumn<T> | DisplayColumn<T>;
|
||||
@Component({
|
||||
selector: 'app-data-table',
|
||||
standalone: true,
|
||||
imports: [MatTableModule, NgTemplateOutlet, MatSortModule],
|
||||
imports: [MatTableModule, NgTemplateOutlet, MatSortModule, SkTextDirective],
|
||||
templateUrl: './data-table.component.html',
|
||||
styleUrl: './data-table.component.scss',
|
||||
})
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{
|
||||
element.funding_end == '2999' || element.funding_end == null
|
||||
? 'laufend'
|
||||
: element.funding_end
|
||||
}}
|
||||
<span>
|
||||
{{
|
||||
element.funding_end == '2999' || element.funding_end == null
|
||||
? 'laufend'
|
||||
: element.funding_end
|
||||
}}</span
|
||||
>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-element>
|
||||
@@ -51,17 +53,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (classifications.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isClassificationsExpanded"
|
||||
(click)="toggleProjectClassificationsExpansion(project)">
|
||||
{{
|
||||
isClassificationsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (classifications.length - 3)
|
||||
}}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isClassificationsExpanded"
|
||||
[hiddenCount]="classifications.length - 3"
|
||||
(toggle)="toggleProjectClassificationsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -88,17 +83,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (projectAuthors.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isProjectAuthorsExpanded"
|
||||
(click)="toggleProjectAuthorsExpansion(project)">
|
||||
{{
|
||||
isProjectAuthorsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (projectAuthors.length - 3)
|
||||
}}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isProjectAuthorsExpanded"
|
||||
[hiddenCount]="projectAuthors.length - 3"
|
||||
(toggle)="toggleProjectAuthorsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -133,16 +121,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (institutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
(click)="toggleProjectInstitutionsExpansion(project)">
|
||||
@if (isProjectInstitutionsExpanded(project)) {
|
||||
Weniger anzeigen
|
||||
} @else {
|
||||
+{{ institutions.length - 3 }} weitere
|
||||
}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isProjectInstitutionsExpanded(project)"
|
||||
[hiddenCount]="institutions.length - 3"
|
||||
(toggle)="toggleProjectInstitutionsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -165,13 +147,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (projectTopics.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isTopicsExpanded"
|
||||
(click)="toggleProjectTopicsExpansion(project)">
|
||||
{{ isTopicsExpanded ? 'weniger' : '+' + (projectTopics.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isTopicsExpanded"
|
||||
[hiddenCount]="projectTopics.length - 3"
|
||||
(toggle)="toggleProjectTopicsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -100,30 +100,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.publication-institution-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Containers for chips
|
||||
// ------------------------
|
||||
|
||||
@@ -23,9 +23,12 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DfgPersonSummary } from '../../../api/model/dfgPersonSummary';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
@Component({
|
||||
selector: 'app-dfg-project-table',
|
||||
imports: [
|
||||
ChipOverflowToggleComponent,
|
||||
DataTableComponent,
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
@@ -33,6 +36,7 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
QueryParamPaginatorComponent,
|
||||
MatTooltip,
|
||||
AppTopicChipComponent,
|
||||
SkTextDirective,
|
||||
],
|
||||
templateUrl: './dfg-project-table.component.html',
|
||||
styleUrl: './dfg-project-table.component.scss',
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleTypeFilter(project.project_type)">
|
||||
<app-chip [color]="getProjectTypeColor(project.project_type)">
|
||||
{{ getProjectTypeLabel(project) }}
|
||||
<span>{{ getProjectTypeLabel(project) }}</span>
|
||||
</app-chip>
|
||||
</button>
|
||||
} @else {
|
||||
@@ -29,15 +29,17 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingStartTmp let-element>
|
||||
{{ getStartDate(element) | date: 'dd.MM.yyyy' }}
|
||||
<span>{{ getStartDate(element) | date: 'dd.MM.yyyy' }}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{ getEndDate(element) | date: 'dd.MM.yyyy' }}
|
||||
<span>{{ getEndDate(element) | date: 'dd.MM.yyyy' }}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingAmountTmp let-element>
|
||||
{{ getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
||||
<span>{{
|
||||
getFundingAmount(element) | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTmp let-project>
|
||||
@@ -60,13 +62,10 @@
|
||||
}
|
||||
|
||||
@if (projectAuthors.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isExpanded"
|
||||
(click)="toggleProjectAuthorsExpansion(project)">
|
||||
{{ isExpanded ? 'weniger' : '+' + (projectAuthors.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isExpanded"
|
||||
[hiddenCount]="projectAuthors.length - 3"
|
||||
(toggle)="toggleProjectAuthorsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -103,13 +102,10 @@
|
||||
}
|
||||
|
||||
@if (organizations.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isExpanded"
|
||||
(click)="toggleProjectOrganizationsExpansion(project)">
|
||||
{{ isExpanded ? 'weniger' : '+' + (organizations.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isExpanded"
|
||||
[hiddenCount]="organizations.length - 3"
|
||||
(toggle)="toggleProjectOrganizationsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -133,13 +129,10 @@
|
||||
}
|
||||
|
||||
@if (projectTopics.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isExpanded"
|
||||
(click)="toggleProjectTopicsExpansion(project)">
|
||||
{{ isExpanded ? 'weniger' : '+' + (projectTopics.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="isExpanded"
|
||||
[hiddenCount]="projectTopics.length - 3"
|
||||
(toggle)="toggleProjectTopicsExpansion(project)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -100,30 +100,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.publication-institution-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Containers for chips
|
||||
// ------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { CurrencyPipe, DatePipe } from '@angular/common';
|
||||
|
||||
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
@@ -32,9 +32,11 @@ import { euProjectQueryParamKeys } from '../../../resolvers/eu-cordis-projects.r
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { ChipComponent } from '../chip/chip.component';
|
||||
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
|
||||
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
@Component({
|
||||
selector: 'app-eu-project-table',
|
||||
imports: [
|
||||
ChipOverflowToggleComponent,
|
||||
DataTableComponent,
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
@@ -46,6 +48,7 @@ import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.compo
|
||||
AppTopicChipComponent,
|
||||
ChipComponent,
|
||||
AppAuthorChipComponent,
|
||||
SkTextDirective,
|
||||
],
|
||||
templateUrl: './eu-project-table.component.html',
|
||||
styleUrl: './eu-project-table.component.scss',
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<ng-content />
|
||||
@@ -0,0 +1,10 @@
|
||||
:host {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-filter-card',
|
||||
standalone: true,
|
||||
templateUrl: './filter-card.component.html',
|
||||
styleUrl: './filter-card.component.scss',
|
||||
})
|
||||
export class FilterCardComponent {}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="legend-tooltip-card">
|
||||
<div class="legend-tooltip-title">{{ name() }}</div>
|
||||
@if (hierarchy()) {
|
||||
<div class="legend-tooltip-hierarchy">{{ hierarchy() }}</div>
|
||||
}
|
||||
@if (_description()) {
|
||||
<hr class="legend-tooltip-divider" />
|
||||
<p class="legend-tooltip-description">{{ _description() }}</p>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,46 @@
|
||||
:host {
|
||||
--topic-border: color-mix(
|
||||
in srgb,
|
||||
hsl(var(--topic-color)) 72%,
|
||||
var(--sg-color-mix-base)
|
||||
);
|
||||
--topic-background: color-mix(
|
||||
in srgb,
|
||||
hsl(var(--topic-color)) 8%,
|
||||
var(--sg-color-mix-base)
|
||||
);
|
||||
}
|
||||
|
||||
.legend-tooltip-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background-color: var(--topic-background);
|
||||
border: 1px solid var(--topic-border);
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.legend-tooltip-title {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.legend-tooltip-hierarchy {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.legend-tooltip-divider {
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-top: 1px solid var(--topic-border);
|
||||
}
|
||||
|
||||
.legend-tooltip-description {
|
||||
margin: 0;
|
||||
color: var(--sg-text);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { TopicsV2Service } from '../../../api';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
'[style.--topic-color]': 'topicColorVar()',
|
||||
},
|
||||
selector: 'app-legend-tooltip',
|
||||
standalone: true,
|
||||
templateUrl: './legend-tooltip.component.html',
|
||||
styleUrl: './legend-tooltip.component.scss',
|
||||
})
|
||||
export class LegendTooltipComponent {
|
||||
private readonly topicsService = inject(TopicsV2Service);
|
||||
|
||||
readonly name = input.required<string>();
|
||||
readonly hierarchy = input<string | null | undefined>(null);
|
||||
readonly description = input<string | null | undefined>(null);
|
||||
readonly fieldId = input<string | null | undefined>(null);
|
||||
readonly subfieldId = input<string | null | undefined>(null);
|
||||
readonly color = input<string | null | undefined>(null);
|
||||
|
||||
readonly _description = signal<string | null | undefined>(undefined);
|
||||
|
||||
readonly topicColorVar = computed(() => {
|
||||
const color = this.color();
|
||||
if (!color) return '';
|
||||
return color.replace('hsl(', '').replace(')', '');
|
||||
});
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const description = this.description();
|
||||
if (description) {
|
||||
this._description.set(description);
|
||||
return;
|
||||
}
|
||||
|
||||
const rawSubfieldId = this.extractOpenAlexShortId(this.subfieldId());
|
||||
if (rawSubfieldId) {
|
||||
this.topicsService.getSubfieldById(rawSubfieldId).subscribe({
|
||||
next: (subfield) => this._description.set(subfield.description),
|
||||
error: () => this._description.set(undefined),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const rawFieldId = this.extractOpenAlexShortId(this.fieldId());
|
||||
if (rawFieldId) {
|
||||
this.topicsService.getFieldById(rawFieldId).subscribe({
|
||||
next: (field) => this._description.set(field.description),
|
||||
error: () => this._description.set(undefined),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this._description.set(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
private extractOpenAlexShortId(
|
||||
id: string | null | undefined,
|
||||
): string | undefined {
|
||||
if (!id || !id.includes('openalex.org')) {
|
||||
return undefined;
|
||||
}
|
||||
return id.split('/').pop() || undefined;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
<div class="keyword-stack">
|
||||
@for (topic of getUniqueOATopics(); track $index) {
|
||||
<app-topic-chip
|
||||
[topic]="topic"
|
||||
[topicId]="topic.id"
|
||||
[label]="topic.display_name || ''"
|
||||
[subfieldName]="topic.subfield?.display_name || ''"
|
||||
[fieldName]="topic.field?.display_name || ''"
|
||||
|
||||
@@ -94,17 +94,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (publicationInstitutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="institutionsExpanded"
|
||||
(click)="toggleWorkInstitutionsExpansion(work)">
|
||||
{{
|
||||
institutionsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (publicationInstitutions.length - 3)
|
||||
}}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="institutionsExpanded"
|
||||
[hiddenCount]="publicationInstitutions.length - 3"
|
||||
(toggle)="toggleWorkInstitutionsExpansion(work)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -130,13 +123,10 @@
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (workAuthors.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="workAuthorsExpanded"
|
||||
(click)="toggleWorkAuthorsExpansion(work)">
|
||||
{{ workAuthorsExpanded ? 'weniger' : '+' + (workAuthors.length - 3) }}
|
||||
</button>
|
||||
<app-chip-overflow-toggle
|
||||
[expanded]="workAuthorsExpanded"
|
||||
[hiddenCount]="workAuthors.length - 3"
|
||||
(toggle)="toggleWorkAuthorsExpansion(work)" />
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
@@ -444,35 +444,6 @@ table.is-hidden {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.publication-institution-more,
|
||||
.publication-topic-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.publication-topic-more {
|
||||
max-width: 180px;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-header-cell {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
|
||||
@@ -36,10 +36,12 @@ import { TopicTooltipComponent } from '../topic-tooltip/topic-tooltip.component'
|
||||
import { AppTopicChipComponent } from '../app-topic-chip/app-topic-chip.component';
|
||||
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
|
||||
import { AppInstitutionChipComponent } from '../app-institution-chip/app-institution-chip.component';
|
||||
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-table',
|
||||
imports: [
|
||||
ChipOverflowToggleComponent,
|
||||
MatIconModule,
|
||||
MatTooltipModule,
|
||||
MatButtonModule,
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
@if (label()) {
|
||||
<mat-label>{{ label() }}</mat-label>
|
||||
}
|
||||
@if (icon()) {
|
||||
<mat-icon matPrefix [fontIcon]="icon()"></mat-icon>
|
||||
}
|
||||
<mat-select
|
||||
(selectionChange)="_handleSelectionChange($event)"
|
||||
[value]="_urlValue()">
|
||||
(openedChange)="_handleOpenedChange($event)"
|
||||
[multiple]="multiple()"
|
||||
[value]="_value()">
|
||||
@for (option of _options(); track $index) {
|
||||
<mat-option [value]="option.value">{{ option.display_name }}</mat-option>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSelectChange, MatSelectModule } from '@angular/material/select';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@@ -11,7 +19,7 @@ export type SelectorOption = {
|
||||
|
||||
@Component({
|
||||
selector: 'app-query-param-selector',
|
||||
imports: [FormsModule, MatSelectModule],
|
||||
imports: [FormsModule, MatIconModule, MatSelectModule],
|
||||
templateUrl: './query-param-selector.component.html',
|
||||
styleUrl: './query-param-selector.component.scss',
|
||||
})
|
||||
@@ -21,6 +29,13 @@ export class QueryParamSelectorComponent {
|
||||
handleSelectionChange = output<MatSelectChange>();
|
||||
allowEmptyValue = input<boolean>(false);
|
||||
label = input<string>('');
|
||||
icon = input<string>('');
|
||||
|
||||
multiple = input<boolean>(false);
|
||||
|
||||
pageQueryParamKey = input<string | null>('page');
|
||||
|
||||
private readonly pendingValues = signal<string[] | null>(null);
|
||||
|
||||
_options = computed<SelectorOption[]>(() => {
|
||||
const options = this.options();
|
||||
@@ -50,14 +65,54 @@ export class QueryParamSelectorComponent {
|
||||
return params && key ? params[key] || '' : '';
|
||||
});
|
||||
|
||||
_urlValues = computed<string[]>(() => {
|
||||
const raw = this._urlValue();
|
||||
return raw
|
||||
? raw
|
||||
.split(',')
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
});
|
||||
|
||||
_value = computed<string | string[]>(() =>
|
||||
this.multiple()
|
||||
? (this.pendingValues() ?? this._urlValues())
|
||||
: this._urlValue(),
|
||||
);
|
||||
|
||||
_handleSelectionChange(event: MatSelectChange): void {
|
||||
const newValue = event.value;
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: { [this.queryParamKey()]: newValue },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
if (this.multiple()) {
|
||||
this.pendingValues.set(event.value ?? []);
|
||||
return;
|
||||
}
|
||||
|
||||
this.commit(event.value || null);
|
||||
this.handleSelectionChange.emit(event);
|
||||
}
|
||||
|
||||
_handleOpenedChange(opened: boolean): void {
|
||||
if (opened || !this.multiple()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pending = this.pendingValues();
|
||||
this.pendingValues.set(null);
|
||||
|
||||
if (pending !== null) {
|
||||
this.commit(pending.length > 0 ? pending.join(',') : null);
|
||||
}
|
||||
}
|
||||
|
||||
private commit(value: string | null): void {
|
||||
const pageKey = this.pageQueryParamKey();
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKey()]: value,
|
||||
...(pageKey ? { [pageKey]: 0 } : {}),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip__button"
|
||||
[class.topic-chip__button--without-count]="!hasCount"
|
||||
[disabled]="disabled"
|
||||
[attr.aria-pressed]="active ? 'true' : null"
|
||||
[matTooltip]="buttonTooltip"
|
||||
[matTooltipDisabled]="!buttonTooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[class.topic-chip__button--without-count]="!hasCount()"
|
||||
[disabled]="disabled()"
|
||||
[attr.aria-pressed]="active() ? 'true' : null"
|
||||
[appComponentTooltip]="AppTopicTooltipComponent"
|
||||
[tooltipInputs]="tooltipInputs()"
|
||||
[tooltipMaxWidth]="'500px'"
|
||||
(click)="handleClick()">
|
||||
<span
|
||||
class="topic-chip__label"
|
||||
[matTooltip]="labelTooltip"
|
||||
[matTooltipDisabled]="!labelTooltip"
|
||||
matTooltipClass="topic-chip-tooltip">
|
||||
{{ label }}
|
||||
<span class="topic-chip__label">
|
||||
{{ label() }}
|
||||
</span>
|
||||
|
||||
@if (hasCount) {
|
||||
@if (hasCount()) {
|
||||
<span
|
||||
class="topic-chip__count"
|
||||
[matTooltip]="normalizedCountTooltip"
|
||||
[matTooltipDisabled]="!normalizedCountTooltip">
|
||||
{{ count }}
|
||||
@if (countIconName) {
|
||||
<mat-icon class="topic-chip__count-icon">{{ countIconName }}</mat-icon>
|
||||
[matTooltip]="normalizedCountTooltip()"
|
||||
[matTooltipDisabled]="!normalizedCountTooltip()">
|
||||
{{ count() }}
|
||||
@if (countIconName()) {
|
||||
<mat-icon class="topic-chip__count-icon">{{
|
||||
countIconName()
|
||||
}}</mat-icon>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Component, computed, input, output } from '@angular/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { buildTopicHierarchyTooltip } from '../../../resolvers/utils/topic-tooltip';
|
||||
import { Topic } from '../../../api';
|
||||
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
|
||||
import { AppTopicTooltipComponent } from '../app-topic-tooltip/app-topic-tooltip.component';
|
||||
|
||||
export const TOPIC_CHIP_PALETTE = [
|
||||
'purple',
|
||||
@@ -65,138 +67,139 @@ export const topicChipColorTokens = (
|
||||
|
||||
@Component({
|
||||
selector: 'app-topic-chip',
|
||||
imports: [MatIconModule, MatTooltipModule],
|
||||
imports: [MatIconModule, MatTooltipModule, ComponentTooltipDirective],
|
||||
templateUrl: './topic-chip.component.html',
|
||||
styleUrl: './topic-chip.component.scss',
|
||||
standalone: true,
|
||||
host: {
|
||||
'[class.topic-chip--normal]': 'normalSize',
|
||||
'[class.topic-chip--mini]': 'miniSize',
|
||||
'[class.topic-chip--active]': 'activeState',
|
||||
'[style.--topic-border]': 'topicBorder',
|
||||
'[style.--topic-bg]': 'topicBackground',
|
||||
'[style.--topic-active-bg]': 'topicActiveBackground',
|
||||
'[style.--topic-color]': 'topicColor',
|
||||
'[style.--topic-text]': 'topicText',
|
||||
'[style.--topic-count-bg]': 'topicCountBackground',
|
||||
'[style.--topic-count-text]': 'topicCountText',
|
||||
'[class.topic-chip--normal]': 'normalSize()',
|
||||
'[class.topic-chip--mini]': 'miniSize()',
|
||||
'[class.topic-chip--active]': 'activeState()',
|
||||
'[style.--topic-border]': 'topicBorder()',
|
||||
'[style.--topic-bg]': 'topicBackground()',
|
||||
'[style.--topic-active-bg]': 'topicActiveBackground()',
|
||||
'[style.--topic-color]': 'topicColor()',
|
||||
'[style.--topic-text]': 'topicText()',
|
||||
'[style.--topic-count-bg]': 'topicCountBackground()',
|
||||
'[style.--topic-count-text]': 'topicCountText()',
|
||||
},
|
||||
})
|
||||
export class TopicChipComponent {
|
||||
@Input() label = '';
|
||||
@Input() count: number | string | null | undefined;
|
||||
@Input() description: string | null | undefined = '';
|
||||
@Input() subfieldName: string | null | undefined = '';
|
||||
@Input() fieldName: string | null | undefined = '';
|
||||
@Input() domainName: string | null | undefined = '';
|
||||
@Input() countTooltip: string | null | undefined = '';
|
||||
@Input() countIcon: string | null | undefined;
|
||||
@Input() color: TopicChipColor = 'purple';
|
||||
@Input() size: TopicChipSize = 'normal';
|
||||
@Input() disabled = false;
|
||||
@Input() active = false;
|
||||
@Input() descriptionTooltipTarget: TopicChipTooltipTarget = 'label';
|
||||
readonly AppTopicTooltipComponent = AppTopicTooltipComponent;
|
||||
|
||||
@Output() chipClick = new EventEmitter<void>();
|
||||
label = input<string>('');
|
||||
count = input<number | string | null | undefined>(undefined);
|
||||
description = input<string | null | undefined>('');
|
||||
subfieldName = input<string | null | undefined>('');
|
||||
fieldName = input<string | null | undefined>('');
|
||||
domainName = input<string | null | undefined>('');
|
||||
countTooltip = input<string | null | undefined>('');
|
||||
countIcon = input<string | null | undefined>(undefined);
|
||||
color = input<TopicChipColor>('purple');
|
||||
size = input<TopicChipSize>('normal');
|
||||
disabled = input<boolean>(false);
|
||||
active = input<boolean>(false);
|
||||
descriptionTooltipTarget = input<TopicChipTooltipTarget>('label');
|
||||
topicId = input<string | null | undefined>(undefined);
|
||||
topic = input<Topic | null | undefined>(undefined);
|
||||
|
||||
get normalSize(): boolean {
|
||||
return this.size === 'normal';
|
||||
}
|
||||
chipClick = output<void>();
|
||||
|
||||
get miniSize(): boolean {
|
||||
return this.size === 'mini';
|
||||
}
|
||||
normalSize = computed(() => this.size() === 'normal');
|
||||
miniSize = computed(() => this.size() === 'mini');
|
||||
activeState = computed(() => this.active());
|
||||
|
||||
get activeState(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
get topicBorder(): string {
|
||||
topicBorder = computed(() => {
|
||||
return (
|
||||
this.colorTokens?.border ??
|
||||
`color-mix(in srgb, ${this.topicColor} 72%, var(--sg-color-mix-base))`
|
||||
this.colorTokens()?.border ??
|
||||
`color-mix(in srgb, ${this.topicColor()} 72%, var(--sg-color-mix-base))`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
get topicBackground(): string {
|
||||
topicBackground = computed(() => {
|
||||
return (
|
||||
this.colorTokens?.background ??
|
||||
`color-mix(in srgb, ${this.topicColor} 17%, var(--sg-color-mix-base))`
|
||||
this.colorTokens()?.background ??
|
||||
`color-mix(in srgb, ${this.topicColor()} 17%, var(--sg-color-mix-base))`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
get topicActiveBackground(): string {
|
||||
topicActiveBackground = computed(() => {
|
||||
return (
|
||||
this.colorTokens?.activeBackground ??
|
||||
`color-mix(in srgb, ${this.topicColor} 27%, var(--sg-color-mix-base))`
|
||||
this.colorTokens()?.activeBackground ??
|
||||
`color-mix(in srgb, ${this.topicColor()} 27%, var(--sg-color-mix-base))`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
get topicColor(): string {
|
||||
return this.colorTokens?.color ?? this.color;
|
||||
}
|
||||
topicColor = computed(() => {
|
||||
return this.colorTokens()?.color ?? this.color();
|
||||
});
|
||||
|
||||
get topicText(): string {
|
||||
return this.colorTokens?.color
|
||||
? this.colorTokens.color
|
||||
: `color-mix(in srgb, ${this.topicColor} 45%, var(--sg-text))`;
|
||||
}
|
||||
topicText = computed(() => {
|
||||
return this.colorTokens()?.color
|
||||
? this.colorTokens()!.color
|
||||
: `color-mix(in srgb, ${this.topicColor()} 45%, var(--sg-text))`;
|
||||
});
|
||||
|
||||
get topicCountBackground(): string {
|
||||
return this.colorTokens?.background ?? 'var(--sg-surface)';
|
||||
}
|
||||
topicCountBackground = computed(() => {
|
||||
return this.colorTokens()?.background ?? 'var(--sg-surface)';
|
||||
});
|
||||
|
||||
get topicCountText(): string {
|
||||
return this.colorTokens?.color
|
||||
? this.colorTokens.color
|
||||
: `color-mix(in srgb, ${this.topicColor} 48%, var(--sg-text))`;
|
||||
}
|
||||
topicCountText = computed(() => {
|
||||
return this.colorTokens()?.color
|
||||
? this.colorTokens()!.color
|
||||
: `color-mix(in srgb, ${this.topicColor()} 48%, var(--sg-text))`;
|
||||
});
|
||||
|
||||
get hasCount(): boolean {
|
||||
return (
|
||||
this.count !== undefined && this.count !== null && `${this.count}` !== ''
|
||||
);
|
||||
}
|
||||
hasCount = computed(() => {
|
||||
const c = this.count();
|
||||
return c !== undefined && c !== null && `${c}` !== '';
|
||||
});
|
||||
|
||||
get labelTooltip(): string {
|
||||
return this.descriptionTooltipTarget === 'label' ? this.topicTooltip : '';
|
||||
}
|
||||
normalizedCountTooltip = computed(() => {
|
||||
return (this.countTooltip() ?? '').trim();
|
||||
});
|
||||
|
||||
get buttonTooltip(): string {
|
||||
return this.descriptionTooltipTarget === 'button' ? this.topicTooltip : '';
|
||||
}
|
||||
countIconName = computed(() => {
|
||||
return (this.countIcon() ?? '').trim();
|
||||
});
|
||||
|
||||
get normalizedCountTooltip(): string {
|
||||
return (this.countTooltip ?? '').trim();
|
||||
}
|
||||
readonly topicObject = computed<Topic>(() => {
|
||||
const t = this.topic();
|
||||
if (t) {
|
||||
return t;
|
||||
}
|
||||
return {
|
||||
id: this.topicId() ?? undefined,
|
||||
display_name: this.label(),
|
||||
description: this.description() ?? undefined,
|
||||
subfield: this.subfieldName()
|
||||
? { display_name: this.subfieldName() ?? undefined }
|
||||
: undefined,
|
||||
field: this.fieldName()
|
||||
? { display_name: this.fieldName() ?? undefined }
|
||||
: undefined,
|
||||
domain: this.domainName()
|
||||
? { display_name: this.domainName() ?? undefined }
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
|
||||
get countIconName(): string {
|
||||
return (this.countIcon ?? '').trim();
|
||||
}
|
||||
tooltipInputs = computed(() => {
|
||||
return {
|
||||
topic: this.topicObject(),
|
||||
topicId: this.topicId() ?? this.topic()?.id ?? undefined,
|
||||
};
|
||||
});
|
||||
|
||||
handleClick(): void {
|
||||
if (this.disabled) {
|
||||
if (this.disabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.chipClick.emit();
|
||||
}
|
||||
|
||||
private get normalizedDescription(): string {
|
||||
return (this.description ?? '').trim();
|
||||
}
|
||||
|
||||
private get topicTooltip(): string {
|
||||
return buildTopicHierarchyTooltip({
|
||||
topicName: this.label,
|
||||
description: this.description,
|
||||
subfieldName: this.subfieldName,
|
||||
fieldName: this.fieldName,
|
||||
domainName: this.domainName,
|
||||
});
|
||||
}
|
||||
|
||||
private get colorTokens(): TopicChipColorTokens | undefined {
|
||||
return TOPIC_CHIP_COLORS[this.color as TopicChipPaletteColor];
|
||||
}
|
||||
private colorTokens = computed<TopicChipColorTokens | undefined>(() => {
|
||||
return TOPIC_CHIP_COLORS[this.color() as TopicChipPaletteColor];
|
||||
});
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user