Merge branch 'dev' into feat/add_site_news
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -49,7 +49,7 @@ task exportOpenApiSpec(type: Exec) {
|
||||
commandLine 'docker', 'run', '--rm',
|
||||
'--platform', "${targetPlatform}",
|
||||
'-w', '/home',
|
||||
'-v', "${projectDir}/src/main:/home",
|
||||
//'-v', "${projectDir}/src/main:/home", the source code is already baked into the image at build time
|
||||
'-v', "${openApiDir}:/mnt/openapi",
|
||||
'-e', "DOCKER_DEFAULT_PLATFORM='${targetPlatform}'",
|
||||
'--name', "${imageName}-service-openapi",
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
One-time script to fetch all topics from 'openalex-topics',
|
||||
vectorize display names and chunked descriptions using the sentence-transformers model,
|
||||
and push them to the 'topicvectors' index with multi-vector hybrid mapping.
|
||||
Script to fetch all topics from 'openalex-topics',
|
||||
vectorize display names, full descriptions, and individual keywords using the sentence-transformers model,
|
||||
and push them to the 'topicvectors' index with multi-vector mapping.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import base64
|
||||
import re
|
||||
from pathlib import Path
|
||||
import httpx
|
||||
import numpy as np
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Add service/src/main to python path to load settings
|
||||
@@ -24,8 +20,10 @@ sys.path.append(str(project_root / "service" / "src" / "main"))
|
||||
from inse.config import settings
|
||||
|
||||
ELASTIC_URL = settings.elasticsearch_url
|
||||
if ELASTIC_URL and not ELASTIC_URL.endswith("/"):
|
||||
ELASTIC_URL += "/"
|
||||
API_KEY = settings.elasticsearch_api_key
|
||||
MODEL_NAME = "paraphrase-multilingual-mpnet-base-v2"
|
||||
MODEL_NAME = settings.sentence_transformers_model_name
|
||||
|
||||
# Import sentence-transformers
|
||||
from sentence_transformers import SentenceTransformer
|
||||
@@ -35,20 +33,12 @@ headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
def split_into_sentences(text):
|
||||
if not text:
|
||||
return []
|
||||
# Split on period, exclamation, or question mark followed by whitespace
|
||||
sentences = re.split(r'(?<=[.!?])\s+', text.strip())
|
||||
# Filter out empty or extremely short sentences
|
||||
return [s for s in sentences if len(s.strip()) > 3]
|
||||
|
||||
def fetch_all_topics():
|
||||
print("Fetching topics from 'openalex-topics'...")
|
||||
topics = []
|
||||
size = 1000
|
||||
offset = 0
|
||||
|
||||
|
||||
with httpx.Client(timeout=60.0) as client:
|
||||
while True:
|
||||
payload = {
|
||||
@@ -71,42 +61,104 @@ def fetch_all_topics():
|
||||
print(f"Fetched {len(topics)} topics so far...")
|
||||
if len(hits) < size:
|
||||
break
|
||||
|
||||
|
||||
print(f"Total topics fetched: {len(topics)}")
|
||||
return topics
|
||||
|
||||
def bulk_index_topics(topics, display_name_vectors, nested_description_vectors):
|
||||
def update_mappings():
|
||||
print("Checking/updating mappings for 'topicvectors'...")
|
||||
mapping_payload = {
|
||||
"properties": {
|
||||
"display_name_vector": {
|
||||
"type": "dense_vector",
|
||||
"dims": 768,
|
||||
"index": True,
|
||||
"similarity": "cosine",
|
||||
"index_options": {
|
||||
"type": "int8_hnsw",
|
||||
"m": 16,
|
||||
"ef_construction": 100
|
||||
}
|
||||
},
|
||||
"description_vector": {
|
||||
"type": "dense_vector",
|
||||
"dims": 768,
|
||||
"index": True,
|
||||
"similarity": "cosine",
|
||||
"index_options": {
|
||||
"type": "int8_hnsw",
|
||||
"m": 16,
|
||||
"ef_construction": 100
|
||||
}
|
||||
},
|
||||
"keyword_vectors": {
|
||||
"type": "nested",
|
||||
"properties": {
|
||||
"vector": {
|
||||
"type": "dense_vector",
|
||||
"dims": 768,
|
||||
"index": True,
|
||||
"similarity": "cosine",
|
||||
"index_options": {
|
||||
"type": "int8_hnsw",
|
||||
"m": 16,
|
||||
"ef_construction": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
# Check if index exists
|
||||
check_resp = client.get(f"{ELASTIC_URL}topicvectors", headers=headers)
|
||||
if check_resp.status_code == 404:
|
||||
print("Index 'topicvectors' does not exist. Creating it...")
|
||||
create_payload = {
|
||||
"mappings": mapping_payload
|
||||
}
|
||||
resp = client.put(f"{ELASTIC_URL}topicvectors", json=create_payload, headers=headers)
|
||||
resp.raise_for_status()
|
||||
else:
|
||||
print("Index 'topicvectors' exists. Updating mappings...")
|
||||
resp = client.put(f"{ELASTIC_URL}topicvectors/_mapping", json=mapping_payload, headers=headers)
|
||||
resp.raise_for_status()
|
||||
print("Mappings update process completed.")
|
||||
|
||||
def bulk_index_topics(topics, display_name_vectors, description_vectors, keyword_vectors_list):
|
||||
print("Bulk indexing vectorized topics into 'topicvectors'...")
|
||||
batch_size = 500
|
||||
|
||||
|
||||
with httpx.Client(timeout=60.0) as client:
|
||||
for i in range(0, len(topics), batch_size):
|
||||
batch_topics = topics[i:i+batch_size]
|
||||
batch_name_vecs = display_name_vectors[i:i+batch_size]
|
||||
batch_desc_vecs_list = nested_description_vectors[i:i+batch_size]
|
||||
|
||||
batch_desc_vecs = description_vectors[i:i+batch_size]
|
||||
batch_kw_vecs_list = keyword_vectors_list[i:i+batch_size]
|
||||
|
||||
bulk_lines = []
|
||||
for t, name_vec, desc_vecs in zip(batch_topics, batch_name_vecs, batch_desc_vecs_list):
|
||||
for t, name_vec, desc_vec, kw_vecs in zip(batch_topics, batch_name_vecs, batch_desc_vecs, batch_kw_vecs_list):
|
||||
source = t["_source"]
|
||||
|
||||
# Remove deprecated single vector if present
|
||||
if "vector" in source:
|
||||
del source["vector"]
|
||||
|
||||
|
||||
source.pop("siblings", None) # drop siblings field when making the copy
|
||||
|
||||
# Assign name vector as a standard float list
|
||||
source["display_name_vector"] = name_vec.tolist()
|
||||
|
||||
# Assign nested description vectors as standard float lists
|
||||
source["description_vectors"] = [
|
||||
{"vector": vec.tolist()} for vec in desc_vecs
|
||||
|
||||
# Assign description vector
|
||||
source["description_vector"] = desc_vec.tolist()
|
||||
|
||||
# Assign nested keyword vectors
|
||||
source["keyword_vectors"] = [
|
||||
{"vector": vec.tolist()} for vec in kw_vecs
|
||||
]
|
||||
|
||||
|
||||
# Meta line
|
||||
meta = {"index": {"_index": "topicvectors", "_id": t["_id"]}}
|
||||
bulk_lines.append(json.dumps(meta))
|
||||
# Document line
|
||||
bulk_lines.append(json.dumps(source))
|
||||
|
||||
|
||||
payload = "\n".join(bulk_lines) + "\n"
|
||||
resp = client.post(
|
||||
f"{ELASTIC_URL}_bulk",
|
||||
@@ -124,53 +176,61 @@ def bulk_index_topics(topics, display_name_vectors, nested_description_vectors):
|
||||
print(f"Indexed batch {i} to {i + len(batch_topics)}")
|
||||
|
||||
def main():
|
||||
update_mappings()
|
||||
|
||||
topics = fetch_all_topics()
|
||||
if not topics:
|
||||
print("No topics found. Exiting.")
|
||||
return
|
||||
|
||||
|
||||
print(f"Initializing SentenceTransformer model '{MODEL_NAME}'...")
|
||||
model = SentenceTransformer(MODEL_NAME)
|
||||
|
||||
|
||||
# 1. Gather all texts to embed
|
||||
display_names = []
|
||||
description_sentences_by_topic = []
|
||||
keywords_by_topic = []
|
||||
all_texts_to_embed = []
|
||||
|
||||
|
||||
for t in topics:
|
||||
source = t["_source"]
|
||||
|
||||
name = source.get("display_name") or ""
|
||||
display_names.append(name)
|
||||
all_texts_to_embed.append(name)
|
||||
|
||||
|
||||
desc = source.get("description") or ""
|
||||
sentences = split_into_sentences(desc)
|
||||
description_sentences_by_topic.append(sentences)
|
||||
all_texts_to_embed.extend(sentences)
|
||||
|
||||
print(f"Embedding {len(all_texts_to_embed)} texts (display names and description passages)...")
|
||||
all_texts_to_embed.append(desc)
|
||||
|
||||
kws = source.get("keywords") or []
|
||||
if not isinstance(kws, list):
|
||||
kws = [kws] if kws else []
|
||||
keywords_by_topic.append(kws)
|
||||
all_texts_to_embed.extend(kws)
|
||||
|
||||
print(f"Embedding {len(all_texts_to_embed)} texts (display names, descriptions, and keywords)...")
|
||||
all_vectors = model.encode(all_texts_to_embed, show_progress_bar=True, batch_size=32)
|
||||
|
||||
|
||||
# 2. Map embeddings back to topics
|
||||
display_name_vectors = []
|
||||
nested_description_vectors = []
|
||||
|
||||
description_vectors = []
|
||||
keyword_vectors_list = []
|
||||
|
||||
vector_idx = 0
|
||||
for idx, t in enumerate(topics):
|
||||
# First vector is the display name
|
||||
|
||||
display_name_vectors.append(all_vectors[vector_idx])
|
||||
vector_idx += 1
|
||||
|
||||
# Next N vectors are the description chunks
|
||||
sentences = description_sentences_by_topic[idx]
|
||||
topic_desc_vecs = []
|
||||
for _ in range(len(sentences)):
|
||||
topic_desc_vecs.append(all_vectors[vector_idx])
|
||||
|
||||
description_vectors.append(all_vectors[vector_idx])
|
||||
vector_idx += 1
|
||||
|
||||
kws = keywords_by_topic[idx]
|
||||
topic_kw_vecs = []
|
||||
for _ in range(len(kws)):
|
||||
topic_kw_vecs.append(all_vectors[vector_idx])
|
||||
vector_idx += 1
|
||||
nested_description_vectors.append(topic_desc_vecs)
|
||||
|
||||
keyword_vectors_list.append(topic_kw_vecs)
|
||||
|
||||
# Bulk index
|
||||
bulk_index_topics(topics, display_name_vectors, nested_description_vectors)
|
||||
bulk_index_topics(topics, display_name_vectors, description_vectors, keyword_vectors_list)
|
||||
print("Done!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
{
|
||||
"query": "localization",
|
||||
"max_score": 23.237041,
|
||||
"results": [
|
||||
{
|
||||
"topic_name": "Indoor and Outdoor Localization Technologies",
|
||||
"score": 23.237041
|
||||
},
|
||||
{
|
||||
"topic_name": "Robotics and Sensor-Based Localization",
|
||||
"score": 21.511477
|
||||
},
|
||||
{
|
||||
"topic_name": "Spectral Theory in Mathematical Physics",
|
||||
"score": 14.039959
|
||||
},
|
||||
{
|
||||
"topic_name": "Socioeconomic Development in MENA",
|
||||
"score": 11.518878
|
||||
},
|
||||
{
|
||||
"topic_name": "Electrical Fault Detection and Protection",
|
||||
"score": 10.770052
|
||||
},
|
||||
{
|
||||
"topic_name": "Machine Learning in Bioinformatics",
|
||||
"score": 10.322677
|
||||
},
|
||||
{
|
||||
"topic_name": "Software System Performance and Reliability",
|
||||
"score": 10.112644
|
||||
},
|
||||
{
|
||||
"topic_name": "Quantum many-body systems",
|
||||
"score": 10.112644
|
||||
},
|
||||
{
|
||||
"topic_name": "Random lasers and scattering media",
|
||||
"score": 10.112644
|
||||
},
|
||||
{
|
||||
"topic_name": "Insect Pheromone Research and Control",
|
||||
"score": 9.910988
|
||||
},
|
||||
{
|
||||
"topic_name": "Tactile and Sensory Interactions",
|
||||
"score": 9.910988
|
||||
},
|
||||
{
|
||||
"topic_name": "Handwritten Text Recognition Techniques",
|
||||
"score": 9.910988
|
||||
},
|
||||
{
|
||||
"topic_name": "Integrated Circuits and Semiconductor Failure Analysis",
|
||||
"score": 9.910988
|
||||
},
|
||||
{
|
||||
"topic_name": "Medical Imaging and Analysis",
|
||||
"score": 9.7172165
|
||||
},
|
||||
{
|
||||
"topic_name": "Microwave Imaging and Scattering Analysis",
|
||||
"score": 9.7172165
|
||||
},
|
||||
{
|
||||
"topic_name": "Neurology and Historical Studies",
|
||||
"score": 9.7172165
|
||||
},
|
||||
{
|
||||
"topic_name": "High-Velocity Impact and Material Behavior",
|
||||
"score": 9.7172165
|
||||
},
|
||||
{
|
||||
"topic_name": "Software Engineering Research",
|
||||
"score": 9.530875
|
||||
},
|
||||
{
|
||||
"topic_name": "Software Testing and Debugging Techniques",
|
||||
"score": 9.530875
|
||||
},
|
||||
{
|
||||
"topic_name": "Digital Media Forensic Detection",
|
||||
"score": 9.530875
|
||||
},
|
||||
{
|
||||
"topic_name": "Infrared Thermography in Medicine",
|
||||
"score": 9.351548
|
||||
},
|
||||
{
|
||||
"topic_name": "Explainable Artificial Intelligence (XAI)",
|
||||
"score": 9.351548
|
||||
},
|
||||
{
|
||||
"topic_name": "Underwater Vehicles and Communication Systems",
|
||||
"score": 9.351548
|
||||
},
|
||||
{
|
||||
"topic_name": "Diffusion and Search Dynamics",
|
||||
"score": 8.8518915
|
||||
},
|
||||
{
|
||||
"topic_name": "Direction-of-Arrival Estimation Techniques",
|
||||
"score": 5.968384
|
||||
},
|
||||
{
|
||||
"topic_name": "Retinal Imaging and Analysis",
|
||||
"score": 5.6107
|
||||
},
|
||||
{
|
||||
"topic_name": "Radar Systems and Signal Processing",
|
||||
"score": 4.721418
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -17,3 +17,6 @@ ELASTICSEARCH_INSE_API_KEY=bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FM
|
||||
LLM_API_URL=https://project.nes.uni-due.de/llm2/v1/
|
||||
LLM_API_KEY=c2d5e7ccf7a4760dd3d19bed2caed9d85ff7437400e0ea82a6d6f912ebc2f212
|
||||
LLM_MODEL=gemma4-e4b
|
||||
|
||||
# Sentence Transformers Configuration
|
||||
SENTENCE_TRANSFORMERS_MODEL_NAME=paraphrase-multilingual-mpnet-base-v2
|
||||
|
||||
@@ -22,14 +22,13 @@ class CompanyConnectionsSearchClient:
|
||||
self.base_url = (
|
||||
base_url
|
||||
or config.settings.elasticsearch_url
|
||||
or config.settings.openalex_works_search_base_url
|
||||
or ""
|
||||
).rstrip("/")
|
||||
self.api_key = (
|
||||
api_key
|
||||
if api_key is not None
|
||||
else config.settings.elasticsearch_api_key
|
||||
or config.settings.openalex_works_api_key
|
||||
)
|
||||
)
|
||||
self.openalex_index = openalex_index
|
||||
self.handelsregister_index = handelsregister_index
|
||||
self.timeout = timeout
|
||||
|
||||
@@ -26,22 +26,18 @@ class Settings(BaseSettings):
|
||||
auth_disabled: bool = False
|
||||
auth_standalone: bool = True
|
||||
auth_secret: str = "change-me-to-a-secure-secret-key"
|
||||
# OpenAlex works search config
|
||||
openalex_works_search_base_url: str = "https://project.nes.uni-due.de/elastic"
|
||||
# IMPORTANT: wildcard * needed to query all work indices
|
||||
openalex_works_search_index: str = "openalex-works*"
|
||||
openalex_works_api_key: str = (
|
||||
"am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ=="
|
||||
)
|
||||
openalex_works_search_timeout_seconds: float = 30.0
|
||||
# OpenAlex public API config
|
||||
openalex_api_base_url: str = "https://api.openalex.org"
|
||||
openalex_api_key: Optional[str] = None
|
||||
openalex_api_timeout_seconds: float = 30.0
|
||||
|
||||
# Patent elasticsearch config
|
||||
|
||||
# Patent Elasticsearch config
|
||||
patent_elasticsearch_url: str = "https://inse.nes.uni-due.de/elastic"
|
||||
patent_elasticsearch_api_key: str = ""
|
||||
patent_elasticsearch_api_key: Optional[str] = None
|
||||
|
||||
|
||||
# LLM config
|
||||
@@ -49,8 +45,11 @@ class Settings(BaseSettings):
|
||||
llm_api_key: Optional[str] = None
|
||||
llm_model: Optional[str] = None
|
||||
|
||||
# elasticsearch config
|
||||
elasticsearch_url: Optional[str] = None
|
||||
# Sentence Transformers config
|
||||
sentence_transformers_model_name: str = "paraphrase-multilingual-mpnet-base-v2"
|
||||
|
||||
# Elasticsearch config
|
||||
elasticsearch_url: str = "https://project.nes.uni-due.de/elastic"
|
||||
elasticsearch_api_key: Optional[str] = None
|
||||
elasticsearch_inse_url: Optional[str] = None
|
||||
elasticsearch_inse_api_key: Optional[str] = None
|
||||
@@ -63,9 +62,6 @@ class Settings(BaseSettings):
|
||||
{"url": "http://localhost:8000", "description": "Local development server"},
|
||||
]
|
||||
|
||||
elasticsearch_inse_url: Optional[str] = None
|
||||
elasticsearch_inse_api_key: Optional[str] = None
|
||||
|
||||
logging_level: str = "DEBUG"
|
||||
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ class FundedPublicationsSearchClient:
|
||||
timeout: float | None = None,
|
||||
transport: httpx.AsyncBaseTransport | None = None,
|
||||
):
|
||||
self.base_url = (base_url or config.settings.openalex_works_search_base_url).rstrip("/")
|
||||
self.base_url = (base_url or config.settings.elasticsearch_url or "").rstrip("/")
|
||||
self.index = index or config.settings.openalex_works_search_index
|
||||
self.api_key = api_key if api_key is not None else config.settings.openalex_works_api_key
|
||||
self.api_key = api_key if api_key is not None else config.settings.elasticsearch_api_key
|
||||
self.timeout = timeout if timeout is not None else config.settings.openalex_works_search_timeout_seconds
|
||||
self.transport = transport
|
||||
|
||||
|
||||
@@ -20,13 +20,21 @@ class InstitutionsSearchClient:
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_institution_by_id(self, raw_institution_id: str) -> Institution:
|
||||
"""
|
||||
Retrieves a single institution by its OpenAlex ID from the local Elasticsearch cluster.
|
||||
def get_institution_by_id(self, raw_oa_institution_id: str) -> Institution:
|
||||
"""Retrieves an institution by its raw OpenAlex institution ID.
|
||||
|
||||
Args:
|
||||
raw_oa_institution_id (str): The raw OpenAlex institution ID to search for.
|
||||
|
||||
Raises:
|
||||
NotFoundException: If no institution is found with the given ID or if the institution data cannot be parsed.
|
||||
|
||||
Returns:
|
||||
Institution: The institution corresponding to the given raw OpenAlex institution ID.
|
||||
"""
|
||||
query = {
|
||||
"match": {
|
||||
"id": f"https://openalex.org/{raw_institution_id.upper()}",
|
||||
"id": f"https://openalex.org/{raw_oa_institution_id.upper()}",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +43,13 @@ class InstitutionsSearchClient:
|
||||
hits = res.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
raise NotFoundException(
|
||||
f"Institution with ID '{raw_institution_id}' not found."
|
||||
f"Institution with ID '{raw_oa_institution_id}' not found."
|
||||
)
|
||||
|
||||
institution = self._convert_hit_to_institution(hits[0])
|
||||
if not institution:
|
||||
raise NotFoundException(
|
||||
f"Institution with ID '{raw_institution_id}' could not be parsed."
|
||||
f"Institution with ID '{raw_oa_institution_id}' could not be parsed."
|
||||
)
|
||||
|
||||
return institution
|
||||
@@ -208,37 +216,39 @@ class InstitutionsSearchClient:
|
||||
if query_text:
|
||||
stripped = query_text.strip()
|
||||
|
||||
must.append({
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_alternatives.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_acronyms.keyword": {
|
||||
"value": f"*{stripped.upper()}*",
|
||||
"boost": 10
|
||||
}
|
||||
}
|
||||
must.append(
|
||||
{
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_alternatives.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"boost": 2,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"wildcard": {
|
||||
"display_name_acronyms.keyword": {
|
||||
"value": f"*{stripped.upper()}*",
|
||||
"boost": 10,
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
],
|
||||
"minimum_should_match": 1
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
filter_queries = []
|
||||
|
||||
@@ -278,35 +288,41 @@ class InstitutionsSearchClient:
|
||||
|
||||
return [Institution.from_dict(hit["_source"]) for hit in hits]
|
||||
|
||||
def get_institution_aliases_by_id(self, raw_institution_id: str) -> List[str]:
|
||||
def get_institution_aliases_by_oa_institution_id(
|
||||
self, raw_oa_institution_id: str
|
||||
) -> List[str]:
|
||||
"""Get a list of institution aliases for a given institution ID, including both display name alternatives and predefined aliases.
|
||||
|
||||
Args:
|
||||
raw_institution_id (str): The raw institution ID for which to retrieve aliases.
|
||||
raw_oa_institution_id (str): The raw OpenAlex institution ID for which to retrieve aliases.
|
||||
|
||||
Returns:
|
||||
List[str]: A list of aliases for the given institution ID.
|
||||
"""
|
||||
institution = self.get_institution_by_id(raw_institution_id)
|
||||
institution = self.get_institution_by_id(raw_oa_institution_id)
|
||||
aliases = list(
|
||||
self.augment_aliases(set(institution.display_name_alternatives or []))
|
||||
| self.get_predefined_institution_aliases(raw_institution_id)
|
||||
| self.get_predefined_institution_aliases(raw_oa_institution_id)
|
||||
)
|
||||
logger.debug(
|
||||
"Retrieved aliases for institution_id=%s: %s", raw_institution_id, aliases
|
||||
"Retrieved aliases for institution_id=%s: %s",
|
||||
raw_oa_institution_id,
|
||||
aliases,
|
||||
)
|
||||
return aliases
|
||||
|
||||
def get_predefined_institution_aliases(self, raw_institution_id: str) -> Set[str]:
|
||||
def get_predefined_institution_aliases(
|
||||
self, raw_oa_institution_id: str
|
||||
) -> Set[str]:
|
||||
"""Get predefined aliases for a given institution ID.
|
||||
|
||||
Args:
|
||||
raw_institution_id (str): The raw institution ID for which to retrieve predefined aliases.
|
||||
raw_oa_institution_id (str): The raw OpenAlex institution ID for which to retrieve predefined aliases.
|
||||
|
||||
Returns:
|
||||
Set[str]: A set of predefined aliases for the given institution ID.
|
||||
"""
|
||||
raw_institution_id = raw_institution_id.upper()
|
||||
raw_oa_institution_id = raw_oa_institution_id.upper()
|
||||
predefined_aliases = {
|
||||
"I62318514": [
|
||||
"universität duisburg-essen",
|
||||
@@ -317,7 +333,9 @@ class InstitutionsSearchClient:
|
||||
],
|
||||
}
|
||||
|
||||
return self.augment_aliases(set(predefined_aliases.get(raw_institution_id, [])))
|
||||
return self.augment_aliases(
|
||||
set(predefined_aliases.get(raw_oa_institution_id, []))
|
||||
)
|
||||
|
||||
def augment_aliases(self, aliases: Set[str]) -> Set[str]:
|
||||
"""Augment a set of aliases by applying the augment_alias function to each alias.
|
||||
@@ -407,3 +425,80 @@ class InstitutionsSearchClient:
|
||||
"Failed to validate institution hit ID %s: %s", hit.get("_id"), e
|
||||
)
|
||||
return None
|
||||
|
||||
def get_cordis_eu_organisation_ids_by_oa_institution_id(
|
||||
self, raw_oa_institution_id: str
|
||||
) -> Optional[List[str]]:
|
||||
"""Retrieves the corresponding EU organisation IDs for a given OpenAlex institution ID by searching for institution aliases and matching them against the Cordis EU organisations indices.
|
||||
|
||||
Args:
|
||||
raw_oa_institution_id (str): The raw OpenAlex institution ID for which to retrieve the corresponding EU organisation IDs.
|
||||
|
||||
Returns:
|
||||
Optional[List[str]]: A list of corresponding EU organisation IDs or None if the search fails.
|
||||
"""
|
||||
|
||||
institution_aliases = set(
|
||||
self.get_institution_aliases_by_oa_institution_id(
|
||||
raw_oa_institution_id=raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
|
||||
body = {
|
||||
"size": 0,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"terms": {
|
||||
"name.keyword": [
|
||||
institution_alias.upper()
|
||||
for institution_alias in institution_aliases
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"aggs": {
|
||||
"organisation_ids": {
|
||||
"terms": {"field": "organisationID", "size": 10000}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
"Searching for EU organisation IDs for raw_oa_institution_id=%s with aliases=%s and query: %s",
|
||||
raw_oa_institution_id,
|
||||
institution_aliases,
|
||||
body,
|
||||
)
|
||||
|
||||
try:
|
||||
# IMPORTANT: The indices are named organizations and not organisations. + 15 Minutes debugging why the search returns 0 results
|
||||
response = elasticsearch.search(
|
||||
index="cordis_eu_*_organizations", body=body, cluster="inse"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception("Error while searching for EU organisation IDs: %s", e)
|
||||
return None
|
||||
|
||||
logger.debug(
|
||||
"Received response for EU organisation ID search for raw_oa_institution_id=%s: %s",
|
||||
raw_oa_institution_id,
|
||||
response,
|
||||
)
|
||||
|
||||
aggregations = response.get("aggregations", {})
|
||||
organisation_ids_buckets = aggregations.get("organisation_ids", {}).get(
|
||||
"buckets", []
|
||||
)
|
||||
organisation_ids = [bucket.get("key") for bucket in organisation_ids_buckets]
|
||||
|
||||
logger.debug(
|
||||
"Extracted EU organisation IDs for raw_oa_institution_id=%s: %s",
|
||||
raw_oa_institution_id,
|
||||
organisation_ids,
|
||||
)
|
||||
|
||||
return organisation_ids
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple
|
||||
import httpx
|
||||
|
||||
from inse.model import ESCluster, ESIndex
|
||||
from .. import config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _cluster_credentials(cluster: str) -> Tuple[str, str]:
|
||||
def _cluster_credentials(cluster: ESCluster) -> Tuple[str, str]:
|
||||
"""Retrieves the Elasticsearch URL and API key for the specified cluster from the configuration.
|
||||
|
||||
Args:
|
||||
cluster (str): The cluster for which to retrieve credentials. Allowed values are "nes" and "inse".
|
||||
cluster (ElasticsearchCluster): The cluster for which to retrieve credentials. Allowed values are "nes" and "inse".
|
||||
|
||||
Raises:
|
||||
ValueError: If the cluster is unknown or the credentials are not set in the configuration.
|
||||
@@ -19,7 +22,7 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]:
|
||||
Tuple[str, str]: The Elasticsearch URL and API key for the specified cluster.
|
||||
"""
|
||||
|
||||
if cluster == "nes":
|
||||
if cluster == ESCluster.NES:
|
||||
if (
|
||||
not config.settings.elasticsearch_url
|
||||
or not config.settings.elasticsearch_api_key
|
||||
@@ -28,7 +31,7 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]:
|
||||
"Elasticsearch URL and API key must be set in the configuration for cluster 'nes'"
|
||||
)
|
||||
return config.settings.elasticsearch_url, config.settings.elasticsearch_api_key
|
||||
elif cluster == "inse":
|
||||
elif cluster == ESCluster.INSE:
|
||||
if (
|
||||
not config.settings.elasticsearch_inse_url
|
||||
or not config.settings.elasticsearch_inse_api_key
|
||||
@@ -45,10 +48,40 @@ def _cluster_credentials(cluster: str) -> Tuple[str, str]:
|
||||
raise ValueError(f"Unknown cluster: {cluster!r} (allowed: 'nes', 'inse')")
|
||||
|
||||
|
||||
def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]:
|
||||
"""Determines the Elasticsearch cluster to use based on the specified index.
|
||||
|
||||
Args:
|
||||
index (ESIndex): The Elasticsearch index for which to determine the cluster. Allowed values are defined in the ESIndex enum.
|
||||
|
||||
Raises:
|
||||
ValueError: If the index is unknown.
|
||||
|
||||
Returns:
|
||||
ESCluster: The Elasticsearch cluster to use for the specified index.
|
||||
"""
|
||||
|
||||
if index in {
|
||||
ESIndex.OPENALEX_WORKS,
|
||||
ESIndex.OPENALEX_AUTHORS,
|
||||
ESIndex.OPENALEX_INSTITUTIONS,
|
||||
ESIndex.OPENALEX_PUBLICATIONS,
|
||||
}:
|
||||
return ESCluster.NES
|
||||
elif index in {
|
||||
ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD,
|
||||
ESIndex.CORDIS_EU_PROJECTS_WILDCARD,
|
||||
ESIndex.CORDIS_EU_PUBLICATIONS_WILDCARD,
|
||||
ESIndex.PROJECTS_BUND_V1,
|
||||
ESIndex.PROJECTS_DFG_ALL,
|
||||
}:
|
||||
return ESCluster.INSE
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def search(
|
||||
index: str,
|
||||
query_field: Optional[str] = None,
|
||||
query_value: Optional[str] = None,
|
||||
index: ESIndex | List[ESIndex],
|
||||
query: Optional[Dict] = None,
|
||||
source: Optional[List] = None,
|
||||
size: Optional[int] = None,
|
||||
@@ -57,14 +90,12 @@ def search(
|
||||
body: Optional[Dict] = None,
|
||||
track_total_hits=False,
|
||||
highlight: Optional[Dict] = None,
|
||||
cluster: str = "nes",
|
||||
cluster: ESCluster = ESCluster.NES,
|
||||
) -> Dict[str, Any]:
|
||||
"""Searches the specified Elasticsearch index using either a simple query string or a full query body.
|
||||
|
||||
Args:
|
||||
index (str): The name of the Elasticsearch index to search.
|
||||
query_field (Optional[str], optional): The field to search in. Defaults to None.
|
||||
query_value (Optional[str], optional): The value to search for. Defaults to None.
|
||||
index (ElasticsearchIndex): The Elasticsearch index to search.
|
||||
query (Optional[Dict], optional): The full query body. Defaults to None.
|
||||
source (Optional[List], optional): The fields to include in the response. Defaults to None.
|
||||
size (Optional[int], optional): The maximum number of results to return. Defaults to None.
|
||||
@@ -72,22 +103,41 @@ def search(
|
||||
sort (Optional[List], optional): The fields to sort by. Defaults to None.
|
||||
body (Optional[Dict], optional): The full query body. Defaults to None.
|
||||
track_total_hits (bool, optional): Whether to track the total number of hits. Defaults to False.
|
||||
cluster (str, optional): The Elasticsearch cluster to search. Defaults to "nes".
|
||||
cluster (ElasticsearchCluster, optional): The Elasticsearch cluster to search. Defaults to ElasticsearchCluster.NES.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: The search results.
|
||||
"""
|
||||
|
||||
clusters = set()
|
||||
if isinstance(index, list):
|
||||
for idx in index:
|
||||
cluster_for_index = _index_to_cluster(idx)
|
||||
if cluster_for_index is not None:
|
||||
clusters.add(cluster_for_index)
|
||||
else:
|
||||
cluster_for_index = _index_to_cluster(index)
|
||||
if cluster_for_index is not None:
|
||||
clusters.add(cluster_for_index)
|
||||
|
||||
if len(clusters) > 1:
|
||||
raise ValueError(
|
||||
f"All indices in the search request must belong to the same cluster, but found clusters: {clusters}"
|
||||
)
|
||||
elif len(clusters) == 1:
|
||||
cluster = clusters.pop()
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
|
||||
headers = {"Authorization": f"ApiKey {api_key}", "Content-Type": "application/json"}
|
||||
|
||||
payload: Dict[str, Any]
|
||||
payload: Dict[str, Any] = {}
|
||||
|
||||
if body is not None:
|
||||
payload = body
|
||||
elif query is not None:
|
||||
payload = {"query": query}
|
||||
else:
|
||||
if query is not None:
|
||||
payload["query"] = query
|
||||
if source is not None:
|
||||
payload["_source"] = source
|
||||
if size is not None:
|
||||
@@ -100,19 +150,23 @@ def search(
|
||||
payload["track_total_hits"] = True
|
||||
if highlight is not None:
|
||||
payload["highlight"] = highlight
|
||||
else:
|
||||
payload = {
|
||||
"query": {
|
||||
"query_string": {"default_field": query_field, "query": query_value}
|
||||
}
|
||||
}
|
||||
|
||||
if len(payload) == 0:
|
||||
raise ValueError(
|
||||
"At least one of 'query', 'body', 'source', 'size', 'offset', 'sort' must be provided"
|
||||
)
|
||||
|
||||
with httpx.Client(timeout=httpx.Timeout(30.0)) as client:
|
||||
logger.debug(
|
||||
f"Sending search request to Elasticsearch cluster '{cluster}' at {elasticsearch_url} with payload: {payload}"
|
||||
f"Sending search request to Elasticsearch cluster '{cluster}' at {elasticsearch_url} for {index} with payload: {json.dumps(payload)}"
|
||||
)
|
||||
if isinstance(index, list):
|
||||
index_str = ",".join(index)
|
||||
else:
|
||||
index_str = index
|
||||
|
||||
response = client.post(
|
||||
f"{elasticsearch_url}/{index}/_search", json=payload, headers=headers
|
||||
f"{elasticsearch_url}/{index_str}/_search", json=payload, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
@@ -206,10 +260,10 @@ def scan(
|
||||
|
||||
|
||||
def get(
|
||||
index: str,
|
||||
index: ESIndex,
|
||||
doc_id: str,
|
||||
source: Optional[list] = None,
|
||||
cluster: str = "nes",
|
||||
cluster: ESCluster = ESCluster.NES,
|
||||
) -> dict[str, Any]:
|
||||
|
||||
elasticsearch_url, api_key = _cluster_credentials(cluster)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module defines the model classes returned from
|
||||
our api using pydantic.
|
||||
This module defines the model classes returned from
|
||||
our api using pydantic.
|
||||
"""
|
||||
|
||||
from enum import StrEnum
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import ConfigDict
|
||||
from pydantic import Field
|
||||
@@ -13,28 +16,49 @@ from typing import Generic
|
||||
from typing import Optional
|
||||
|
||||
|
||||
T = TypeVar('T', bound=BaseModel)
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
class Entity(BaseModel):
|
||||
id: int = Field(description="The id of the entity.")
|
||||
|
||||
|
||||
class Item(Entity):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
name: str = Field(description="The name of the item.")
|
||||
description: str = Field(description="The description of the item.")
|
||||
|
||||
|
||||
class ItemCreate(BaseModel):
|
||||
name: str = Field(description="The name of the item.")
|
||||
description: str = Field(description="The description of the item.")
|
||||
|
||||
|
||||
class Page(BaseModel, Generic[T]):
|
||||
elements: List[T] = Field(default=[], description="The elements of the page.")
|
||||
offset: int = Field(default=0, description="The page offset in elements.")
|
||||
total: int = Field(default=0, description="The total number of elements.")
|
||||
size: int = Field(default=20, description="The page size in elements.")
|
||||
|
||||
|
||||
class ItemPage(Page[Item]):
|
||||
pass
|
||||
|
||||
|
||||
class ESCluster(StrEnum):
|
||||
NES = "nes"
|
||||
INSE = "inse"
|
||||
|
||||
|
||||
class ESIndex(StrEnum):
|
||||
OPENALEX_WORKS = "openalex-works"
|
||||
OPENALEX_AUTHORS = "openalex-authors"
|
||||
OPENALEX_INSTITUTIONS = "openalex-institutions"
|
||||
OPENALEX_PUBLICATIONS = "openalex-publications"
|
||||
|
||||
CORDIS_EU_ORGANIZATIONS_WILDCARD = "cordis_eu_*_organizations"
|
||||
CORDIS_EU_PROJECTS_WILDCARD = "cordis_eu_*_projects"
|
||||
CORDIS_EU_PUBLICATIONS_WILDCARD = "cordis_eu_*_publications"
|
||||
|
||||
PROJECTS_BUND_V1 = "projects_bund_v1"
|
||||
PROJECTS_DFG_ALL = "projects_dfg_all"
|
||||
@@ -8,3 +8,39 @@ class TopicCount(BaseModel):
|
||||
name: str = Field(description="The topic display name.")
|
||||
count: int = Field(default=0, description="The number of occurrences.")
|
||||
description: Optional[str] = Field(default=None, description="The topic description.")
|
||||
subfield_id: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic subfield id.",
|
||||
)
|
||||
subfield_name: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic subfield display name.",
|
||||
)
|
||||
subfield_description: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic subfield description.",
|
||||
)
|
||||
field_id: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic field id.",
|
||||
)
|
||||
field_name: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic field display name.",
|
||||
)
|
||||
field_description: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic field description.",
|
||||
)
|
||||
domain_id: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic domain id.",
|
||||
)
|
||||
domain_name: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic domain display name.",
|
||||
)
|
||||
domain_description: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The topic domain description.",
|
||||
)
|
||||
|
||||
@@ -220,7 +220,7 @@ def _build_mentioned_persons(author_names: list) -> list:
|
||||
|
||||
ude_persons = []
|
||||
other_persons = []
|
||||
|
||||
|
||||
for name in author_names:
|
||||
match = find_ude_author_by_name(name)
|
||||
if match:
|
||||
|
||||
@@ -13,6 +13,8 @@ from elasticsearch import ApiError, NotFoundError
|
||||
import hashlib
|
||||
import httpx
|
||||
from fastapi import HTTPException
|
||||
|
||||
from inse.model import ESIndex
|
||||
from .. import config
|
||||
from .. import util
|
||||
from ..integrations import llm
|
||||
@@ -28,6 +30,7 @@ from inse.persons.model import (
|
||||
PersonSearchRequest,
|
||||
CareerMetrics,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
INDEX_NAME = "openalex-authors"
|
||||
UDE_INSTITUTION_ID = "https://openalex.org/I62318514" # Universität Duisburg-Essen
|
||||
@@ -79,7 +82,7 @@ def find_ude_author_by_name(display_name: str) -> Optional[dict]:
|
||||
return None
|
||||
|
||||
hit = exact_matches[0]
|
||||
|
||||
|
||||
return {
|
||||
"id": hit.get("_id"),
|
||||
"display_name": hit.get("_source", {}).get("display_name"),
|
||||
@@ -109,20 +112,26 @@ def get_author_name_by_id(author_id: str) -> Optional[str]:
|
||||
def search_persons(
|
||||
author_id: Optional[str] = None,
|
||||
query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None,
|
||||
) -> AuthorsListResponse:
|
||||
if author_id:
|
||||
query_field = "_id"
|
||||
query_value = author_id
|
||||
query_ = {
|
||||
"query_string": {
|
||||
"default_field": "_id",
|
||||
"query": author_id,
|
||||
}
|
||||
}
|
||||
|
||||
elif query:
|
||||
query_field = "display_name"
|
||||
query_value = query
|
||||
query_ = {
|
||||
"query_string": {
|
||||
"default_field": "display_name",
|
||||
"query": query,
|
||||
}
|
||||
}
|
||||
else:
|
||||
return AuthorsListResponse(results=[], meta=Meta(count=0))
|
||||
|
||||
data = elasticsearch.search(
|
||||
index="openalex-authors", query_field=query_field, query_value=query_value
|
||||
)
|
||||
data = elasticsearch.search(index=ESIndex.OPENALEX_AUTHORS, query=query_)
|
||||
|
||||
authors = []
|
||||
for hit in data.get("hits", {}).get("hits", []):
|
||||
@@ -275,9 +284,7 @@ def _get_publication_years_for_author(author_id: str) -> list[int]:
|
||||
)
|
||||
|
||||
buckets = (
|
||||
response.get("aggregations", {})
|
||||
.get("publication_years", {})
|
||||
.get("buckets", [])
|
||||
response.get("aggregations", {}).get("publication_years", {}).get("buckets", [])
|
||||
)
|
||||
|
||||
publication_years: list[int] = []
|
||||
@@ -291,20 +298,21 @@ def _get_publication_years_for_author(author_id: str) -> list[int]:
|
||||
|
||||
return publication_years
|
||||
|
||||
|
||||
def _classify_career_stage(active_years: int) -> str:
|
||||
if active_years <= 0:
|
||||
return "unknown"
|
||||
|
||||
if active_years <= 4:
|
||||
return "Early Researcher"
|
||||
return "Early"
|
||||
|
||||
if active_years <= 10:
|
||||
return "Emerging Researcher"
|
||||
if active_years <= 9:
|
||||
return "Emerging"
|
||||
|
||||
if active_years <= 20:
|
||||
return "Established Researcher"
|
||||
if active_years <= 14:
|
||||
return "Established"
|
||||
|
||||
return "Senior Researcher"
|
||||
return "Senior"
|
||||
|
||||
|
||||
def _compute_career_metrics(publication_years: list[int]) -> CareerMetrics:
|
||||
@@ -425,15 +433,13 @@ def generate_person_bio(author_id: str, include: Optional[set[str]] = None) -> s
|
||||
def get_person_by_id(
|
||||
author_id: str, include: Optional[str] = None
|
||||
) -> CustomAuthorsListResponse:
|
||||
body = {
|
||||
"_source": include.split(",") if include else True,
|
||||
}
|
||||
source = include.split(",") if include else None
|
||||
|
||||
try:
|
||||
hit = elasticsearch.get(
|
||||
index="openalex-authors",
|
||||
body=body,
|
||||
doc_id=author_id,
|
||||
source=source,
|
||||
)
|
||||
except NotFoundError:
|
||||
raise HTTPException(
|
||||
@@ -443,7 +449,13 @@ def get_person_by_id(
|
||||
raise HTTPException(status_code=500, detail=f"Elasticsearch error: {str(e)}")
|
||||
|
||||
author = util.get_persons_data(hit)
|
||||
start_time = time.time()
|
||||
career_metrics = get_career_metrics_for_author(author_id)
|
||||
elapsed_time = time.time() - start_time
|
||||
|
||||
logger.info(
|
||||
f"Career metrics calculation for author {author_id} took {elapsed_time:.2f} seconds"
|
||||
)
|
||||
|
||||
custom_author = CustomAuthor(
|
||||
**author.model_dump(),
|
||||
@@ -453,7 +465,6 @@ def get_person_by_id(
|
||||
return CustomAuthorsListResponse(results=[custom_author])
|
||||
|
||||
|
||||
|
||||
def search_persons_by_name(
|
||||
author_name: str,
|
||||
limit: Optional[int] = 10,
|
||||
@@ -730,11 +741,22 @@ def advanced_search_persons(
|
||||
hits = response_dict.get("hits", {}).get("hits", [])
|
||||
total_count = response_dict.get("hits", {}).get("total", {}).get("value", 0)
|
||||
|
||||
include_career_metrics = include is None or "career_metrics" in include
|
||||
results = []
|
||||
for hit in hits:
|
||||
raw_data = util.get_persons_data(hit)
|
||||
custom_author = _enrich_author_data(raw_data)
|
||||
if custom_author:
|
||||
if include_career_metrics:
|
||||
start_time = time.time()
|
||||
custom_author.career_metrics = get_career_metrics_for_author(
|
||||
custom_author.id
|
||||
)
|
||||
elapsed_time = time.time() - start_time
|
||||
logger.info(
|
||||
f"Career metrics calculation for author {custom_author.id} took "
|
||||
f"{elapsed_time:.2f} seconds"
|
||||
)
|
||||
results.append(custom_author)
|
||||
|
||||
return CustomAuthorsListResponse(
|
||||
|
||||
@@ -53,7 +53,7 @@ def search_persons(
|
||||
if include
|
||||
else None
|
||||
)
|
||||
return logic.search_persons(author_id, query, include_set)
|
||||
return logic.search_persons(author_id, query)
|
||||
|
||||
|
||||
@router.get(
|
||||
|
||||
@@ -8,6 +8,7 @@ from pydantic import BaseModel, Field, field_validator
|
||||
from inse.models.bund_project import BundProject
|
||||
from inse.models.eu_project import EuProject
|
||||
from inse.models.cordis_eu_project import CordisEuProject
|
||||
from inse.model import ESIndex
|
||||
|
||||
|
||||
class ProjectType(StrEnum):
|
||||
@@ -15,6 +16,17 @@ class ProjectType(StrEnum):
|
||||
EU = "eu"
|
||||
DFG = "dfg"
|
||||
|
||||
def to_es_index(self) -> ESIndex:
|
||||
mapping = {
|
||||
self.BUND: ESIndex.PROJECTS_BUND_V1,
|
||||
self.EU: ESIndex.CORDIS_EU_PROJECTS_WILDCARD,
|
||||
self.DFG: ESIndex.PROJECTS_DFG_ALL,
|
||||
}
|
||||
index = mapping.get(self)
|
||||
if index is None:
|
||||
raise ValueError(f"Unsupported project type: {self}")
|
||||
return index
|
||||
|
||||
|
||||
class ProjectsSortBy(StrEnum):
|
||||
TITLE = "title"
|
||||
@@ -22,6 +34,24 @@ class ProjectsSortBy(StrEnum):
|
||||
FUNDING_END = "funding_end"
|
||||
FUNDING_AMOUNT = "funding_amount"
|
||||
|
||||
def to_cordis_eu_project_sort_field(self) -> str:
|
||||
mapping = {
|
||||
self.TITLE: "title.keyword",
|
||||
self.FUNDING_START: "startDate",
|
||||
self.FUNDING_END: "endDate",
|
||||
self.FUNDING_AMOUNT: "ecMaxContribution",
|
||||
}
|
||||
return mapping.get(self, "title.keyword")
|
||||
|
||||
def to_bund_project_sort_field(self) -> str:
|
||||
mapping = {
|
||||
self.TITLE: "Thema.keyword",
|
||||
self.FUNDING_START: "funding_start",
|
||||
self.FUNDING_END: "funding_end",
|
||||
self.FUNDING_AMOUNT: "Fördersumme",
|
||||
}
|
||||
return mapping.get(self, "Thema.keyword")
|
||||
|
||||
|
||||
class SortDirection(StrEnum):
|
||||
ASC = "asc"
|
||||
@@ -142,6 +172,9 @@ class FundingProject(BaseModel):
|
||||
)
|
||||
id: str = Field(description="The unique identifier of the project.")
|
||||
title: Optional[str] = Field(default=None, description="The title of the project.")
|
||||
acronym: Optional[str] = Field(
|
||||
default=None, description="The acronym of the project (if available)."
|
||||
)
|
||||
start_date: Optional[date] = Field(
|
||||
default=None, description="The funding start date of the project."
|
||||
)
|
||||
@@ -184,7 +217,7 @@ class FundingProject(BaseModel):
|
||||
title=source.get("title"),
|
||||
start_date=source.get("startDate"),
|
||||
end_date=source.get("endDate"),
|
||||
funding_amount=source.get("ecMacContribution"),
|
||||
funding_amount=source.get("ecMaxContribution"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -218,6 +251,7 @@ class FundingProject(BaseModel):
|
||||
title=source.get("title"),
|
||||
start_date=source.get("funding_start"),
|
||||
end_date=source.get("funding_end"),
|
||||
acronym=source.get("acronym"),
|
||||
)
|
||||
|
||||
|
||||
@@ -225,3 +259,58 @@ class FundingProjectPage(Page):
|
||||
elements: List[FundingProject] = Field(
|
||||
default_factory=list, description="The funding projects on this page."
|
||||
)
|
||||
|
||||
|
||||
class EuOrganizationShort(BaseModel):
|
||||
project_id: str = Field(description="The unique identifier of the project.")
|
||||
organization_id: str = Field(
|
||||
description="The unique identifier of the organization."
|
||||
)
|
||||
ec_contribution: Optional[float] = Field(
|
||||
default=None,
|
||||
description="The EC contribution amount for the organization in the project.",
|
||||
)
|
||||
|
||||
|
||||
class EuProjectShort(BaseModel):
|
||||
id: str = Field(description="The unique identifier of the EU project.")
|
||||
title: Optional[str] = Field(
|
||||
default=None, description="The title of the EU project."
|
||||
)
|
||||
start_date: Optional[date] = Field(
|
||||
default=None, description="The funding start date of the EU project."
|
||||
)
|
||||
end_date: Optional[date] = Field(
|
||||
default=None, description="The funding end date of the EU project."
|
||||
)
|
||||
acronym: Optional[str] = Field(
|
||||
default=None, description="The acronym of the EU project."
|
||||
)
|
||||
|
||||
|
||||
class EuOrganizationProjectSummary(BaseModel):
|
||||
organization_id: str = Field(
|
||||
description="The unique identifier of the organization."
|
||||
)
|
||||
project_id: str = Field(description="The unique identifier of the project.")
|
||||
title: Optional[str] = Field(default=None, description="The title of the project.")
|
||||
start_date: Optional[date] = Field(
|
||||
default=None, description="The funding start date of the project."
|
||||
)
|
||||
end_date: Optional[date] = Field(
|
||||
default=None, description="The funding end date of the project."
|
||||
)
|
||||
acronym: Optional[str] = Field(
|
||||
default=None, description="The acronym of the project."
|
||||
)
|
||||
ec_contribution: Optional[float] = Field(
|
||||
default=None,
|
||||
description="The EC contribution amount for the organization in the project.",
|
||||
)
|
||||
|
||||
|
||||
class EuOrganizationProjectSummaryPage(Page):
|
||||
elements: List[EuOrganizationProjectSummary] = Field(
|
||||
default_factory=list,
|
||||
description="The organization project summaries on this page.",
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ from inse.projects.model import (
|
||||
BundProjectPage,
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
EuOrganizationProjectSummaryPage,
|
||||
FundingProjectPage,
|
||||
InstitutionFunderSummary,
|
||||
ProjectType,
|
||||
@@ -19,12 +20,7 @@ from inse.models.dfg_project_details import DfgProjectDetails
|
||||
from inse.models.bund_project_details import BundProjectDetails
|
||||
from inse.tags import Tags
|
||||
from inse.projects import service as projects_service
|
||||
from inse.projects.projects_search_client import (
|
||||
BundProjectsSearchClient,
|
||||
CompleteProjectsSearchClient,
|
||||
DfgProjectsSearchClient,
|
||||
EuProjectsSearchClient,
|
||||
)
|
||||
|
||||
from inse.institutions.institutions_search_client import (
|
||||
InstitutionsSearchClient,
|
||||
)
|
||||
@@ -35,24 +31,29 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix="/api/projects", tags=[Tags.PROJECTS])
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_bund_search_client() -> BundProjectsSearchClient:
|
||||
return BundProjectsSearchClient()
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_eu_search_client() -> EuProjectsSearchClient:
|
||||
return EuProjectsSearchClient()
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_dfg_search_client() -> DfgProjectsSearchClient:
|
||||
return DfgProjectsSearchClient()
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_complete_projects_search_client() -> CompleteProjectsSearchClient:
|
||||
return CompleteProjectsSearchClient()
|
||||
@router.get(
|
||||
"/author/{raw_oa_author_id}/eu",
|
||||
summary="Get EU projects for an author.",
|
||||
description="Returns a list of EU projects associated with the specified author ID.",
|
||||
operation_id="getEuProjectsForAuthor",
|
||||
responses={
|
||||
status.HTTP_200_OK: {
|
||||
"description": "Successful Response",
|
||||
"model": CordisEuProjectPage,
|
||||
},
|
||||
status.HTTP_404_NOT_FOUND: {"description": "Author not found"},
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
def get_eu_projects_for_author(
|
||||
raw_oa_author_id: Annotated[str, Path(description="The author ID to filter by.")],
|
||||
) -> CordisEuProjectPage:
|
||||
logger.debug(
|
||||
f"Received request to get EU projects for author_id={raw_oa_author_id}"
|
||||
)
|
||||
return projects_service.search_cordis_eu_projects_for_author_id(
|
||||
raw_oa_author_id=raw_oa_author_id,
|
||||
)
|
||||
|
||||
|
||||
@router.post(
|
||||
@@ -70,9 +71,6 @@ def get_complete_projects_search_client() -> CompleteProjectsSearchClient:
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def search_bund_projects(
|
||||
bund_search_client: Annotated[
|
||||
BundProjectsSearchClient, Depends(get_bund_search_client)
|
||||
],
|
||||
institutions_search_client: Annotated[
|
||||
InstitutionsSearchClient, Depends(get_institutions_search_client)
|
||||
],
|
||||
@@ -81,8 +79,7 @@ async def search_bund_projects(
|
||||
Body(description="The filtering properties for the projects search."),
|
||||
],
|
||||
) -> BundProjectPage:
|
||||
return await projects_service.search_bund_projects(
|
||||
bund_search_client=bund_search_client,
|
||||
return projects_service.search_bund_projects(
|
||||
institutions_search_client=institutions_search_client,
|
||||
filtering_properties=filtering_properties,
|
||||
)
|
||||
@@ -102,15 +99,11 @@ async def search_bund_projects(
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_single_dfg_project(
|
||||
dfg_search_client: Annotated[
|
||||
DfgProjectsSearchClient, Depends(get_dfg_search_client)
|
||||
],
|
||||
def get_single_dfg_project(
|
||||
id: Annotated[str, Path(description="The ID of the DFG project to retrieve.")],
|
||||
) -> DfgProjectDetails:
|
||||
logger.debug(f"Received request to get single DFG project for id={id}")
|
||||
return await projects_service.get_single_dfg_project(
|
||||
dfg_search_client=dfg_search_client,
|
||||
return projects_service.get_single_dfg_project(
|
||||
project_id=id,
|
||||
)
|
||||
|
||||
@@ -129,15 +122,11 @@ async def get_single_dfg_project(
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_single_bund_project(
|
||||
bund_search_client: Annotated[
|
||||
BundProjectsSearchClient, Depends(get_bund_search_client)
|
||||
],
|
||||
def get_single_bund_project(
|
||||
id: Annotated[str, Path(description="The ID of the BUND project to retrieve.")],
|
||||
) -> BundProjectDetails:
|
||||
logger.debug(f"Received request to get single BUND project for id={id}")
|
||||
return await projects_service.get_single_bund_project(
|
||||
bund_search_client=bund_search_client,
|
||||
return projects_service.get_single_bund_project(
|
||||
project_id=id,
|
||||
)
|
||||
|
||||
@@ -156,10 +145,7 @@ async def get_single_bund_project(
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_institution_bund_projects_funding_over_time(
|
||||
bund_search_client: Annotated[
|
||||
BundProjectsSearchClient, Depends(get_bund_search_client)
|
||||
],
|
||||
def get_institution_bund_projects_funding_over_time(
|
||||
institutions_search_client: Annotated[
|
||||
InstitutionsSearchClient, Depends(get_institutions_search_client)
|
||||
],
|
||||
@@ -167,8 +153,7 @@ async def get_institution_bund_projects_funding_over_time(
|
||||
str, Query(description="The institution ID to filter by.")
|
||||
],
|
||||
) -> InstitutionFunderSummary:
|
||||
return await projects_service.get_institution_bund_projects_funding_over_time(
|
||||
bund_search_client=bund_search_client,
|
||||
return projects_service.get_institution_bund_projects_funding_over_time(
|
||||
institutions_search_client=institutions_search_client,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
)
|
||||
@@ -182,14 +167,13 @@ async def get_institution_bund_projects_funding_over_time(
|
||||
responses={
|
||||
status.HTTP_200_OK: {
|
||||
"description": "Successful Response",
|
||||
"model": CordisEuProjectPage,
|
||||
"model": EuOrganizationProjectSummaryPage,
|
||||
},
|
||||
status.HTTP_404_NOT_FOUND: {"description": "Institution not found"},
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def search_cordis_eu_projects(
|
||||
eu_search_client: Annotated[EuProjectsSearchClient, Depends(get_eu_search_client)],
|
||||
institutions_search_client: Annotated[
|
||||
InstitutionsSearchClient, Depends(get_institutions_search_client)
|
||||
],
|
||||
@@ -197,9 +181,8 @@ async def search_cordis_eu_projects(
|
||||
ProjectsFilteringProperties,
|
||||
Body(description="The filtering properties for the projects search."),
|
||||
],
|
||||
) -> CordisEuProjectPage:
|
||||
return await projects_service.search_cordis_eu_projects(
|
||||
eu_search_client=eu_search_client,
|
||||
) -> EuOrganizationProjectSummaryPage:
|
||||
return projects_service.search_cordis_eu_projects(
|
||||
institutions_search_client=institutions_search_client,
|
||||
projects_filtering_properties=projects_filtering_properties,
|
||||
)
|
||||
@@ -220,7 +203,6 @@ async def search_cordis_eu_projects(
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
eu_search_client: Annotated[EuProjectsSearchClient, Depends(get_eu_search_client)],
|
||||
institutions_search_client: Annotated[
|
||||
InstitutionsSearchClient, Depends(get_institutions_search_client)
|
||||
],
|
||||
@@ -229,7 +211,6 @@ async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
],
|
||||
) -> InstitutionFunderSummary:
|
||||
return await projects_service.get_institution_cordis_eu_projects_funding_over_time(
|
||||
eu_search_client=eu_search_client,
|
||||
institutions_search_client=institutions_search_client,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
)
|
||||
@@ -250,9 +231,6 @@ async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_dfg_projects(
|
||||
dfg_search_client: Annotated[
|
||||
DfgProjectsSearchClient, Depends(get_dfg_search_client)
|
||||
],
|
||||
author_id: Annotated[str, Query(description="The author ID to filter by.")],
|
||||
topic: Annotated[
|
||||
Optional[str], Query(description="The topic to filter by.")
|
||||
@@ -274,7 +252,6 @@ async def get_dfg_projects(
|
||||
sort_direction,
|
||||
)
|
||||
return await projects_service.get_dfg_projects_by_author_id(
|
||||
dfg_search_client=dfg_search_client,
|
||||
author_id=author_id,
|
||||
topic=topic,
|
||||
page=page,
|
||||
@@ -297,10 +274,7 @@ async def get_dfg_projects(
|
||||
},
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def search_projects(
|
||||
complete_projects_search_client: Annotated[
|
||||
CompleteProjectsSearchClient, Depends(get_complete_projects_search_client)
|
||||
],
|
||||
def search_projects(
|
||||
page: Annotated[int, Query(description="The page number.", ge=0)] = 0,
|
||||
size: Annotated[int, Query(description="The page size.", ge=1)] = 10,
|
||||
selected_project_types: Annotated[
|
||||
@@ -319,8 +293,7 @@ async def search_projects(
|
||||
SortDirection, Query(description="The sort direction (asc or desc).")
|
||||
] = SortDirection.ASC,
|
||||
) -> FundingProjectPage:
|
||||
return await projects_service.search_projects(
|
||||
projects_search_client=complete_projects_search_client,
|
||||
return projects_service.search_all_projects(
|
||||
page=page,
|
||||
size=size,
|
||||
selected_project_types=selected_project_types,
|
||||
|
||||
@@ -2,17 +2,15 @@ import datetime
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
|
||||
from inse.projects import projects_search_client
|
||||
from inse.projects.projects_search_client import (
|
||||
BundProjectsSearchClient,
|
||||
CompleteProjectsSearchClient,
|
||||
DfgProjectsSearchClient,
|
||||
EuProjectsSearchClient,
|
||||
get_eu_organization_project_contributions,
|
||||
)
|
||||
from inse.projects.model import (
|
||||
BundProjectPage,
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
EuProjectPage,
|
||||
EuOrganizationProjectSummaryPage,
|
||||
FundingProjectPage,
|
||||
InstitutionFunderSummary,
|
||||
ProjectType,
|
||||
@@ -27,12 +25,13 @@ from inse.institutions.institutions_search_client import (
|
||||
)
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.persons.logic import get_author_name_by_id
|
||||
from inse.works.logic import get_publication_dois_of_author
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def search_projects(
|
||||
projects_search_client: CompleteProjectsSearchClient,
|
||||
def search_all_projects(
|
||||
page: int,
|
||||
size: int,
|
||||
sort_by: ProjectsSortBy,
|
||||
@@ -40,18 +39,20 @@ async def search_projects(
|
||||
selected_project_types: Optional[Set[ProjectType]] = None,
|
||||
title: Optional[str] = None,
|
||||
) -> FundingProjectPage:
|
||||
return await projects_search_client.search_projects(
|
||||
page=page,
|
||||
size=size,
|
||||
return projects_search_client.search_all_projects(
|
||||
projects_filtering_properties=ProjectsFilteringProperties(
|
||||
project_type=ProjectType.EU, # placeholder, shall be ignored in search_all_projects
|
||||
page=page,
|
||||
size=size,
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
query=title,
|
||||
),
|
||||
selected_project_types=selected_project_types,
|
||||
title=title,
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
)
|
||||
|
||||
|
||||
async def search_bund_projects(
|
||||
bund_search_client: BundProjectsSearchClient,
|
||||
def search_bund_projects(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
filtering_properties: ProjectsFilteringProperties,
|
||||
) -> BundProjectPage:
|
||||
@@ -60,15 +61,17 @@ async def search_bund_projects(
|
||||
f"Invalid project type: {filtering_properties.project_type}. Expected 'bund'."
|
||||
)
|
||||
|
||||
return await get_bund_projects_by_institution_id(
|
||||
bund_search_client=bund_search_client,
|
||||
logger.debug(
|
||||
f"search_bund_projects called with filtering_properties: {filtering_properties}"
|
||||
)
|
||||
|
||||
return get_bund_projects_by_institution_id(
|
||||
institutions_search_client=institutions_search_client,
|
||||
filtering_properties=filtering_properties,
|
||||
)
|
||||
|
||||
|
||||
async def get_bund_projects_by_institution_id(
|
||||
bund_search_client: BundProjectsSearchClient,
|
||||
def get_bund_projects_by_institution_id(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
filtering_properties: ProjectsFilteringProperties,
|
||||
) -> BundProjectPage:
|
||||
@@ -78,46 +81,41 @@ async def get_bund_projects_by_institution_id(
|
||||
logger.info(
|
||||
f"Fetching bund projects for institution_id={filtering_properties.raw_oa_institution_id}, page={filtering_properties.page}, size={filtering_properties.size}"
|
||||
)
|
||||
institution_aliases = institutions_search_client.get_institution_aliases_by_id(
|
||||
filtering_properties.raw_oa_institution_id
|
||||
institution_aliases = (
|
||||
institutions_search_client.get_institution_aliases_by_oa_institution_id(
|
||||
filtering_properties.raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
logger.debug(
|
||||
f"Found institution aliases for institution_id={filtering_properties.raw_oa_institution_id}: {institution_aliases}"
|
||||
f"get_bund_projects_by_institution_id: Found institution aliases for institution_id={filtering_properties.raw_oa_institution_id}: {institution_aliases}"
|
||||
)
|
||||
response = await bund_search_client.search_bund_projects(
|
||||
page=filtering_properties.page,
|
||||
size=filtering_properties.size,
|
||||
response = projects_search_client.search_bund_projects(
|
||||
institution_names=institution_aliases,
|
||||
topic=filtering_properties.query,
|
||||
sort_by=filtering_properties.sort_by,
|
||||
sort_direction=filtering_properties.sort_direction,
|
||||
filter_properties=filtering_properties,
|
||||
)
|
||||
logger.debug(f"get_bund_projects_by_institution_id response: {response}")
|
||||
return response
|
||||
|
||||
|
||||
async def search_cordis_eu_projects(
|
||||
eu_search_client: EuProjectsSearchClient,
|
||||
def search_cordis_eu_projects(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
projects_filtering_properties: ProjectsFilteringProperties,
|
||||
) -> CordisEuProjectPage:
|
||||
) -> EuOrganizationProjectSummaryPage:
|
||||
if projects_filtering_properties.project_type != "eu":
|
||||
raise ValueError(
|
||||
f"Invalid project type: {projects_filtering_properties.project_type}. Expected 'eu'."
|
||||
)
|
||||
|
||||
return await get_cordis_eu_projects_by_institution_id(
|
||||
eu_search_client=eu_search_client,
|
||||
return get_cordis_eu_projects_by_institution_id(
|
||||
institutions_search_client=institutions_search_client,
|
||||
projects_filtering_properties=projects_filtering_properties,
|
||||
)
|
||||
|
||||
|
||||
async def get_cordis_eu_projects_by_institution_id(
|
||||
eu_search_client: EuProjectsSearchClient,
|
||||
def get_cordis_eu_projects_by_institution_id(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
projects_filtering_properties: ProjectsFilteringProperties,
|
||||
) -> CordisEuProjectPage:
|
||||
) -> EuOrganizationProjectSummaryPage:
|
||||
if not projects_filtering_properties.raw_oa_institution_id:
|
||||
raise ValueError(
|
||||
"raw_oa_institution_id must be provided to fetch CORDIS EU projects by institution ID"
|
||||
@@ -126,81 +124,26 @@ async def get_cordis_eu_projects_by_institution_id(
|
||||
logger.info(
|
||||
f"Fetching CORDIS EU projects for institution_id={projects_filtering_properties.raw_oa_institution_id}, page={projects_filtering_properties.page}, size={projects_filtering_properties.size}"
|
||||
)
|
||||
institution_aliases = institutions_search_client.get_institution_aliases_by_id(
|
||||
projects_filtering_properties.raw_oa_institution_id
|
||||
institution_aliases = (
|
||||
institutions_search_client.get_institution_aliases_by_oa_institution_id(
|
||||
projects_filtering_properties.raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
logger.debug(
|
||||
f"Found institution aliases for institution_id={projects_filtering_properties.raw_oa_institution_id}: {institution_aliases}"
|
||||
)
|
||||
|
||||
institution_eu_organisation_id = await (
|
||||
institutions_search_client.get_eu_organisation_id_by_oa_institution_id(
|
||||
projects_filtering_properties.raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
if not institution_eu_organisation_id:
|
||||
logger.debug(
|
||||
f"No EU organization ID found for institution_id={projects_filtering_properties.raw_oa_institution_id}"
|
||||
)
|
||||
raise NotFoundException(
|
||||
f"EU organization ID for institution with id {projects_filtering_properties.raw_oa_institution_id} not found"
|
||||
)
|
||||
|
||||
cordis_eu_project_page = await eu_search_client.search_eu_projects2(
|
||||
eu_organisation_id=institution_eu_organisation_id,
|
||||
page = get_eu_organization_project_contributions(
|
||||
organization_names=institution_aliases,
|
||||
projects_filtering_properties=projects_filtering_properties,
|
||||
)
|
||||
|
||||
return cordis_eu_project_page
|
||||
logger.debug(f"get_cordis_eu_projects_by_institution_id response: {page}")
|
||||
|
||||
|
||||
async def get_eu_projects_by_institution_id(
|
||||
eu_search_client: EuProjectsSearchClient,
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
raw_oa_institution_id: str,
|
||||
topic: Optional[str],
|
||||
page: int,
|
||||
size: int,
|
||||
sort_by: str = "topic",
|
||||
sort_direction: str = "asc",
|
||||
) -> EuProjectPage:
|
||||
logger.info(
|
||||
f"Fetching EU projects for institution_id={raw_oa_institution_id}, page={page}, size={size}"
|
||||
)
|
||||
institution_aliases = institutions_search_client.get_institution_aliases_by_id(
|
||||
raw_oa_institution_id
|
||||
)
|
||||
logger.debug(
|
||||
f"Found institution aliases for institution_id={raw_oa_institution_id}: {institution_aliases}"
|
||||
)
|
||||
|
||||
institution_eu_organisation_id = await (
|
||||
institutions_search_client.get_eu_organisation_id_by_oa_institution_id(
|
||||
raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
if not institution_eu_organisation_id:
|
||||
logger.debug(
|
||||
f"No EU organization ID found for institution_id={raw_oa_institution_id}"
|
||||
)
|
||||
raise NotFoundException(
|
||||
f"EU organization ID for institution with id {raw_oa_institution_id} not found"
|
||||
)
|
||||
|
||||
response = await eu_search_client.search_eu_projects(
|
||||
page=page,
|
||||
size=size,
|
||||
institution_names=institution_aliases,
|
||||
topic=topic,
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
)
|
||||
logger.debug(f"get_eu_projects_by_institution_id response: {response}")
|
||||
return response
|
||||
return page
|
||||
|
||||
|
||||
async def get_dfg_projects_by_author_id(
|
||||
dfg_search_client: DfgProjectsSearchClient,
|
||||
author_id: str,
|
||||
topic: Optional[str],
|
||||
page: int,
|
||||
@@ -219,7 +162,7 @@ async def get_dfg_projects_by_author_id(
|
||||
)
|
||||
logger.debug(f"Found author name for author_id={author_id}: {name}")
|
||||
|
||||
response = await dfg_search_client.search_dfg_projects(
|
||||
response = projects_search_client.search_dfg_projects(
|
||||
page=page,
|
||||
size=size,
|
||||
names=[name],
|
||||
@@ -231,17 +174,18 @@ async def get_dfg_projects_by_author_id(
|
||||
|
||||
|
||||
async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
eu_search_client: EuProjectsSearchClient,
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
raw_oa_institution_id: str,
|
||||
) -> InstitutionFunderSummary:
|
||||
|
||||
cordis_eu_project_page = await search_cordis_eu_projects(
|
||||
eu_search_client,
|
||||
institutions_search_client,
|
||||
ProjectsFilteringProperties(
|
||||
institution_aliases = (
|
||||
institutions_search_client.get_institution_aliases_by_oa_institution_id(
|
||||
raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
page = get_eu_organization_project_contributions(
|
||||
organization_names=institution_aliases,
|
||||
projects_filtering_properties=ProjectsFilteringProperties(
|
||||
project_type=ProjectType.EU,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
page=0,
|
||||
size=10000,
|
||||
),
|
||||
@@ -249,30 +193,34 @@ async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
|
||||
return _calculate_funding_over_time(
|
||||
project_type=ProjectType.EU,
|
||||
projects=cordis_eu_project_page.elements,
|
||||
funding_start_attr="startDate",
|
||||
funding_end_attr="endDate",
|
||||
funding_amount_attr="totalCost",
|
||||
projects=page.elements,
|
||||
funding_start_attr="start_date",
|
||||
funding_end_attr="end_date",
|
||||
funding_amount_attr="ec_contribution",
|
||||
)
|
||||
|
||||
|
||||
async def get_institution_bund_projects_funding_over_time(
|
||||
bund_search_client: BundProjectsSearchClient,
|
||||
def get_institution_bund_projects_funding_over_time(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
raw_oa_institution_id: str,
|
||||
) -> InstitutionFunderSummary:
|
||||
logger.info(
|
||||
f"Fetching funding over time for institution_id={raw_oa_institution_id}"
|
||||
)
|
||||
institution_aliases = institutions_search_client.get_institution_aliases_by_id(
|
||||
raw_oa_institution_id
|
||||
institution_aliases = (
|
||||
institutions_search_client.get_institution_aliases_by_oa_institution_id(
|
||||
raw_oa_institution_id
|
||||
)
|
||||
)
|
||||
logger.debug(
|
||||
f"Found institution aliases for institution_id={raw_oa_institution_id}: {institution_aliases}"
|
||||
)
|
||||
response = await bund_search_client.search_bund_projects(
|
||||
page=0,
|
||||
size=10000,
|
||||
response = projects_search_client.search_bund_projects(
|
||||
filter_properties=ProjectsFilteringProperties(
|
||||
project_type=ProjectType.BUND,
|
||||
page=0,
|
||||
size=10000,
|
||||
),
|
||||
institution_names=institution_aliases,
|
||||
)
|
||||
|
||||
@@ -353,25 +301,49 @@ def _calculate_funding_over_time(
|
||||
)
|
||||
|
||||
|
||||
async def get_single_dfg_project(
|
||||
dfg_search_client: DfgProjectsSearchClient,
|
||||
def get_single_dfg_project(
|
||||
project_id: str,
|
||||
) -> DfgProjectDetails:
|
||||
logger.debug(f"Fetching single DFG project for id={project_id}")
|
||||
|
||||
project = await dfg_search_client.get_dfg_project_by_id(project_id)
|
||||
project = projects_search_client.get_dfg_project_by_id(project_id)
|
||||
if not project:
|
||||
raise NotFoundException(f"DFG project with id {project_id} not found")
|
||||
return project
|
||||
|
||||
|
||||
async def get_single_bund_project(
|
||||
bund_search_client: BundProjectsSearchClient,
|
||||
def get_single_bund_project(
|
||||
project_id: str,
|
||||
) -> BundProjectDetails:
|
||||
logger.debug(f"Fetching single BUND project for id={project_id}")
|
||||
|
||||
project = await bund_search_client.get_bund_project_by_id(project_id)
|
||||
project = projects_search_client.get_bund_project_by_id(project_id)
|
||||
if not project:
|
||||
raise NotFoundException(f"BUND project with id {project_id} not found")
|
||||
return project
|
||||
|
||||
|
||||
def search_cordis_eu_projects_for_author_id(
|
||||
raw_oa_author_id: str,
|
||||
) -> CordisEuProjectPage:
|
||||
|
||||
# Direct search not possible -> multi stage search
|
||||
# 1. Exisiting author has publications with DOIs
|
||||
# 2. CORDIS EU projects have associated publications with DOIs
|
||||
# 3. Matching DOIs of author publications with DOIs of CORDIS EU project publications -> projects with associated publications of the author
|
||||
|
||||
dois = get_publication_dois_of_author(raw_oa_author_id=raw_oa_author_id)
|
||||
|
||||
logger.debug(f"Found DOIs for author_id={raw_oa_author_id}: {dois}")
|
||||
|
||||
project_ids = projects_search_client.get_cordis_eu_project_ids_by_dois(dois=dois)
|
||||
|
||||
logger.debug(
|
||||
f"Found project IDs {project_ids} for author_id={raw_oa_author_id} and dois={dois}"
|
||||
)
|
||||
|
||||
funding_project_page = projects_search_client.get_cordis_eu_projects_by_project_ids(
|
||||
project_ids=project_ids
|
||||
)
|
||||
|
||||
return funding_project_page
|
||||
|
||||
@@ -256,10 +256,19 @@ def _datetime_str_or_none(value: Any) -> str | None:
|
||||
return f"{text}T00:00:00Z"
|
||||
return text
|
||||
|
||||
# Configuration for vector search similarity thresholds and boosts
|
||||
SIMILARITY_THRESHOLD = 0.62
|
||||
BOOST_LEXICAL = 1.0
|
||||
# higher values for semantic weights, because cosine similarity is between 0 and 1
|
||||
BOOST_DISPLAY_NAME_VECTOR = 30.0
|
||||
BOOST_DESCRIPTION_VECTOR = 15.0
|
||||
BOOST_KEYWORD_VECTORS = 25.0
|
||||
|
||||
async def vector_search_topics(
|
||||
*,
|
||||
query: str,
|
||||
limit: int = 25,
|
||||
search_type: str = "hybrid",
|
||||
) -> TopicsListResponse:
|
||||
"""
|
||||
Perform a semantic similarity search on the topicvectors index.
|
||||
@@ -267,7 +276,7 @@ async def vector_search_topics(
|
||||
try:
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.util import get_model
|
||||
|
||||
|
||||
except Exception as exc:
|
||||
logger.exception("Failed to load elasticsearch integration.")
|
||||
raise HTTPException(
|
||||
@@ -285,59 +294,76 @@ async def vector_search_topics(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail=f"Failed to encode query text: {exc}"
|
||||
)
|
||||
|
||||
|
||||
# 2. Query Elasticsearch using standard Bool Should hybrid search
|
||||
|
||||
should_clauses = []
|
||||
|
||||
# Lexical multi_match search (only in hybrid mode)
|
||||
if search_type == "hybrid":
|
||||
should_clauses.append({
|
||||
"multi_match": {
|
||||
"query": query,
|
||||
"fields": [
|
||||
"display_name^3",
|
||||
"keywords^2",
|
||||
"description^1"
|
||||
],
|
||||
"boost": BOOST_LEXICAL
|
||||
}
|
||||
})
|
||||
|
||||
# Semantic KNN clauses
|
||||
should_clauses.extend([
|
||||
{
|
||||
"knn": {
|
||||
"field": "display_name_vector",
|
||||
"query_vector": query_vector,
|
||||
"similarity": SIMILARITY_THRESHOLD,
|
||||
"boost": BOOST_DISPLAY_NAME_VECTOR,
|
||||
"k": 500,
|
||||
"num_candidates": 500
|
||||
}
|
||||
},
|
||||
{
|
||||
"knn": {
|
||||
"field": "description_vector",
|
||||
"query_vector": query_vector,
|
||||
"similarity": SIMILARITY_THRESHOLD,
|
||||
"boost": BOOST_DESCRIPTION_VECTOR,
|
||||
"k": 500,
|
||||
"num_candidates": 500
|
||||
}
|
||||
},
|
||||
{
|
||||
"nested": {
|
||||
"path": "keyword_vectors",
|
||||
"query": {
|
||||
"knn": {
|
||||
"field": "keyword_vectors.vector",
|
||||
"query_vector": query_vector,
|
||||
"similarity": SIMILARITY_THRESHOLD,
|
||||
"k": 500,
|
||||
"num_candidates": 500
|
||||
}
|
||||
},
|
||||
"score_mode": "max",
|
||||
"boost": BOOST_KEYWORD_VECTORS
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
body = {
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": query,
|
||||
"fields": [
|
||||
"display_name^3",
|
||||
"keywords^2",
|
||||
"description^1"
|
||||
],
|
||||
"boost": 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"knn": {
|
||||
"field": "display_name_vector",
|
||||
"query_vector": query_vector,
|
||||
"k": limit,
|
||||
"num_candidates": 100,
|
||||
"similarity": 0.62,
|
||||
"boost": 2.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"nested": {
|
||||
"path": "description_vectors",
|
||||
"query": {
|
||||
"knn": {
|
||||
"field": "description_vectors.vector",
|
||||
"query_vector": query_vector,
|
||||
"k": limit,
|
||||
"num_candidates": 100,
|
||||
"similarity": 0.62
|
||||
}
|
||||
},
|
||||
"score_mode": "max",
|
||||
"boost": 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
"should": should_clauses
|
||||
}
|
||||
},
|
||||
"_source": {
|
||||
"excludes": ["display_name_vector", "description_vectors", "description", "siblings"] # remove unrequired fields (description, sibling currently not needed)
|
||||
"excludes": ["display_name_vector", "description_vector", "keyword_vectors", "description"] # remove unrequired fields
|
||||
},
|
||||
"size": limit
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
raw_results = elasticsearch.search(
|
||||
index="topicvectors",
|
||||
@@ -350,20 +376,13 @@ async def vector_search_topics(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail=f"Elasticsearch vector search failed: {exc}"
|
||||
)
|
||||
|
||||
|
||||
# 3. Format result
|
||||
hits = raw_results.get("hits", {}).get("hits", [])
|
||||
|
||||
# Log scores to JSON for threshold analysis TODO: Remove after finetune
|
||||
try:
|
||||
from .score_logger import log_scores_to_json
|
||||
log_scores_to_json(hits, query)
|
||||
except Exception as exc:
|
||||
logger.warning(f"Could not log search scores: {exc}")
|
||||
|
||||
|
||||
total = len(hits)
|
||||
results = [hit.get("_source", {}) for hit in hits]
|
||||
|
||||
|
||||
data = {
|
||||
"meta": {
|
||||
"count": total,
|
||||
@@ -372,7 +391,7 @@ async def vector_search_topics(
|
||||
},
|
||||
"results": results
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
normalized_data = _normalize_topics_response(data)
|
||||
return TopicsListResponse.from_dict(normalized_data) or TopicsListResponse()
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
def log_scores_to_json(hits: List[Dict[str, Any]], query: str) -> None:
|
||||
"""
|
||||
Utility function to log the names and scores of all vector search hits to a JSON file.
|
||||
This helps in debugging and manually tweaking the similarity score thresholds.
|
||||
"""
|
||||
scores_data = []
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
topic_name = source.get("display_name") or source.get("name") or "Unknown"
|
||||
score = hit.get("_score", 0.0)
|
||||
scores_data.append({
|
||||
"topic_name": topic_name,
|
||||
"score": score
|
||||
})
|
||||
|
||||
|
||||
data_dir = Path("/data")
|
||||
|
||||
output_file = data_dir / "search_scores.json"
|
||||
|
||||
log_payload = {
|
||||
"query": query,
|
||||
"max_score": hits[0].get("_score", 0.0) if hits else 0.0,
|
||||
"results": scores_data
|
||||
}
|
||||
|
||||
try:
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
json.dump(log_payload, f, indent=2, ensure_ascii=False)
|
||||
print(f"DEBUG: Saved search scores for query '{query}' to {output_file}")
|
||||
except Exception as exc:
|
||||
print(f"DEBUG: Failed to save search scores: {exc}")
|
||||
@@ -129,9 +129,14 @@ async def vector_search_topics(
|
||||
int,
|
||||
Query(description="Maximum number of topics to return.", ge=1, le=100),
|
||||
] = 25,
|
||||
search_type: Annotated[
|
||||
str,
|
||||
Query(alias="searchType", description="Search approach: 'hybrid' or 'semantic'."),
|
||||
] = "hybrid",
|
||||
):
|
||||
return await logic.vector_search_topics(
|
||||
query=query,
|
||||
limit=limit,
|
||||
search_type=search_type,
|
||||
)
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ def get_persons_data(hit:dict):
|
||||
return author
|
||||
|
||||
from sentence_transformers import SentenceTransformer
|
||||
from .config import settings
|
||||
# Sentence Transformer Model
|
||||
_model: SentenceTransformer | None = None
|
||||
|
||||
@@ -55,5 +56,6 @@ def get_model():
|
||||
if os.environ.get("SENTENCE_TRANSFORMERS_HOME") == "/models":
|
||||
os.environ["HF_HUB_OFFLINE"] = "1"
|
||||
|
||||
_model = SentenceTransformer("paraphrase-multilingual-mpnet-base-v2")
|
||||
model_name = settings.sentence_transformers_model_name
|
||||
_model = SentenceTransformer(model_name)
|
||||
return _model
|
||||
@@ -29,6 +29,26 @@ from .search_client import OpenAlexWorksSearchClient
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
TOPIC_DETAIL_SOURCE_FIELDS = [
|
||||
"id",
|
||||
"display_name",
|
||||
"description",
|
||||
"subfield",
|
||||
"field",
|
||||
"domain",
|
||||
]
|
||||
|
||||
TOPIC_HIERARCHY_DESCRIPTION_INDICES = {
|
||||
"subfield": "openalex-subfields",
|
||||
"field": "openalex-fields",
|
||||
"domain": "openalex-domains",
|
||||
}
|
||||
|
||||
TOPIC_HIERARCHY_DESCRIPTION_SOURCE_FIELDS = [
|
||||
"id",
|
||||
"description",
|
||||
]
|
||||
|
||||
|
||||
async def get_author_works(
|
||||
author_id: str,
|
||||
@@ -121,6 +141,7 @@ async def get_primary_topic_counts(
|
||||
name=name,
|
||||
count=item["count"],
|
||||
description=info.get("description"),
|
||||
**_topic_hierarchy_fields(info),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -208,7 +229,7 @@ def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]:
|
||||
response = elasticsearch.search(
|
||||
index="openalex-topics",
|
||||
query={"terms": {"id": topic_ids}},
|
||||
source=["id", "display_name", "description"],
|
||||
source=TOPIC_DETAIL_SOURCE_FIELDS,
|
||||
size=len(topic_ids),
|
||||
)
|
||||
except httpx.HTTPError:
|
||||
@@ -225,11 +246,94 @@ def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]:
|
||||
details[topic_id] = {
|
||||
"display_name": source.get("display_name"),
|
||||
"description": source.get("description"),
|
||||
"subfield": _extract_topic_hierarchy_item(source, "subfield"),
|
||||
"field": _extract_topic_hierarchy_item(source, "field"),
|
||||
"domain": _extract_topic_hierarchy_item(source, "domain"),
|
||||
}
|
||||
|
||||
_enrich_topic_hierarchy_descriptions(details)
|
||||
|
||||
return details
|
||||
|
||||
|
||||
def _extract_topic_hierarchy_item(source: dict, key: str) -> dict[str, str | None]:
|
||||
hierarchy_item = source.get(key)
|
||||
|
||||
if not isinstance(hierarchy_item, dict):
|
||||
return {"id": None, "display_name": None, "description": None}
|
||||
|
||||
return {
|
||||
"id": hierarchy_item.get("id"),
|
||||
"display_name": hierarchy_item.get("display_name"),
|
||||
"description": hierarchy_item.get("description"),
|
||||
}
|
||||
|
||||
|
||||
def _enrich_topic_hierarchy_descriptions(details: dict[str, dict]) -> None:
|
||||
for hierarchy_key, index in TOPIC_HIERARCHY_DESCRIPTION_INDICES.items():
|
||||
hierarchy_ids = {
|
||||
item.get(hierarchy_key, {}).get("id")
|
||||
for item in details.values()
|
||||
if item.get(hierarchy_key, {}).get("id")
|
||||
}
|
||||
|
||||
descriptions = _get_topic_hierarchy_descriptions(index, list(hierarchy_ids))
|
||||
|
||||
for item in details.values():
|
||||
hierarchy_item = item.get(hierarchy_key) or {}
|
||||
hierarchy_id = hierarchy_item.get("id")
|
||||
|
||||
if hierarchy_id and hierarchy_id in descriptions:
|
||||
hierarchy_item["description"] = descriptions[hierarchy_id]
|
||||
|
||||
|
||||
def _get_topic_hierarchy_descriptions(
|
||||
index: str,
|
||||
hierarchy_ids: list[str],
|
||||
) -> dict[str, str | None]:
|
||||
if not hierarchy_ids:
|
||||
return {}
|
||||
|
||||
try:
|
||||
response = elasticsearch.search(
|
||||
index=index,
|
||||
query={"terms": {"id": hierarchy_ids}},
|
||||
source=TOPIC_HIERARCHY_DESCRIPTION_SOURCE_FIELDS,
|
||||
size=len(hierarchy_ids),
|
||||
)
|
||||
except httpx.HTTPError:
|
||||
logger.exception("Could not load topic hierarchy details from %s.", index)
|
||||
return {}
|
||||
|
||||
descriptions = {}
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
hierarchy_id = source.get("id")
|
||||
|
||||
if hierarchy_id:
|
||||
descriptions[hierarchy_id] = source.get("description")
|
||||
|
||||
return descriptions
|
||||
|
||||
|
||||
def _topic_hierarchy_fields(topic_details: dict) -> dict[str, str | None]:
|
||||
subfield = topic_details.get("subfield") or {}
|
||||
field = topic_details.get("field") or {}
|
||||
domain = topic_details.get("domain") or {}
|
||||
|
||||
return {
|
||||
"subfield_id": subfield.get("id"),
|
||||
"subfield_name": subfield.get("display_name"),
|
||||
"subfield_description": subfield.get("description"),
|
||||
"field_id": field.get("id"),
|
||||
"field_name": field.get("display_name"),
|
||||
"field_description": field.get("description"),
|
||||
"domain_id": domain.get("id"),
|
||||
"domain_name": domain.get("display_name"),
|
||||
"domain_description": domain.get("description"),
|
||||
}
|
||||
|
||||
|
||||
def _limit_works_by_complete_years(
|
||||
work_results: list[Work],
|
||||
target_publications: int,
|
||||
@@ -445,6 +549,7 @@ async def _get_topics_by_time_by_author_from_work_pages(
|
||||
name=topic["name"],
|
||||
count=topic["count"],
|
||||
description=info.get("description"),
|
||||
**_topic_hierarchy_fields(info),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -462,6 +567,7 @@ async def _get_topics_by_time_by_author_from_work_pages(
|
||||
name=topic["name"],
|
||||
count=topic["count"],
|
||||
description=info.get("description"),
|
||||
**_topic_hierarchy_fields(info),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -649,9 +755,7 @@ def _author_works_query(author_id: str) -> dict[str, Any]:
|
||||
|
||||
def _parse_year_count_buckets(response: dict) -> list[dict]:
|
||||
return (
|
||||
response.get("aggregations", {})
|
||||
.get("publication_years", {})
|
||||
.get("buckets", [])
|
||||
response.get("aggregations", {}).get("publication_years", {}).get("buckets", [])
|
||||
)
|
||||
|
||||
|
||||
@@ -691,13 +795,9 @@ def _collect_topic_ids_from_year_buckets(year_buckets: list[dict]) -> set[str]:
|
||||
topic_ids: set[str] = set()
|
||||
|
||||
for year_bucket in year_buckets:
|
||||
primary_buckets = (
|
||||
year_bucket.get("primary_topics", {}).get("buckets", [])
|
||||
)
|
||||
primary_buckets = year_bucket.get("primary_topics", {}).get("buckets", [])
|
||||
topic_buckets = (
|
||||
year_bucket.get("topics_nested", {})
|
||||
.get("topics", {})
|
||||
.get("buckets", [])
|
||||
year_bucket.get("topics_nested", {}).get("topics", {}).get("buckets", [])
|
||||
)
|
||||
|
||||
for bucket in primary_buckets + topic_buckets:
|
||||
@@ -723,9 +823,7 @@ def _build_timeline_elements_from_aggregations(
|
||||
continue
|
||||
|
||||
topics = _build_topic_counts_from_buckets(
|
||||
year_bucket.get("topics_nested", {})
|
||||
.get("topics", {})
|
||||
.get("buckets", []),
|
||||
year_bucket.get("topics_nested", {}).get("topics", {}).get("buckets", []),
|
||||
topic_details=topic_details,
|
||||
max_topics_per_year=max_topics_per_year,
|
||||
use_reverse_nested_count=True,
|
||||
@@ -776,11 +874,13 @@ def _build_topic_counts_from_buckets(
|
||||
name=display_name,
|
||||
count=count,
|
||||
description=info.get("description"),
|
||||
**_topic_hierarchy_fields(info),
|
||||
)
|
||||
)
|
||||
|
||||
return topics
|
||||
|
||||
|
||||
async def _search_author_works_data(
|
||||
search_client: OpenAlexWorksSearchClient,
|
||||
author_id: str,
|
||||
@@ -860,4 +960,50 @@ def _parse_full_work_search_response(data: dict) -> tuple[list[Work], int]:
|
||||
detail="OpenAlex works search response could not be parsed.",
|
||||
) from exc
|
||||
|
||||
return elements, total
|
||||
return elements, total
|
||||
|
||||
|
||||
def get_publication_dois_of_author(
|
||||
raw_oa_author_id: str,
|
||||
) -> List[str]:
|
||||
query = {
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"term": {
|
||||
"authorships.author.id": f"https://openalex.org/{raw_oa_author_id.strip().upper()}"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"filter": [{"exists": {"field": "doi"}}],
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
response = elasticsearch.search(
|
||||
index="openalex-works",
|
||||
source=["doi"],
|
||||
size=10000,
|
||||
query=query,
|
||||
cluster="nes",
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
logger.exception("Request for publication DOIs of author failed.")
|
||||
raise HTTPException(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail="Request for publication DOIs of author failed.",
|
||||
) from exc
|
||||
|
||||
dois = []
|
||||
for hit in response.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
doi = source.get("doi")
|
||||
if doi:
|
||||
dois.append(doi)
|
||||
|
||||
return dois
|
||||
|
||||
@@ -26,12 +26,13 @@ class OpenAlexWorksSearchClient:
|
||||
timeout: float | None = None,
|
||||
transport: httpx.AsyncBaseTransport | None = None,
|
||||
):
|
||||
self.base_url = (base_url or config.settings.openalex_works_search_base_url).rstrip("/")
|
||||
self.base_url = (base_url or config.settings.elasticsearch_url or "").rstrip("/")
|
||||
self.index = index or config.settings.openalex_works_search_index
|
||||
self.api_key = api_key if api_key is not None else config.settings.openalex_works_api_key
|
||||
self.api_key = api_key if api_key is not None else config.settings.elasticsearch_api_key
|
||||
self.timeout = timeout if timeout is not None else config.settings.openalex_works_search_timeout_seconds
|
||||
self.transport = transport
|
||||
|
||||
|
||||
def author_works_query(
|
||||
self,
|
||||
author_id: str,
|
||||
|
||||
+187
-4
@@ -17,6 +17,21 @@ GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_publications/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"size": 100,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"terms": {
|
||||
"projectID": ["287661"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_mapping
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
@@ -47,6 +62,73 @@ Content-Type: application/json
|
||||
}
|
||||
}
|
||||
|
||||
# 10.1371/journal.pone.0018216
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_publications/_mapping
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_publications/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_fp7_project_iprs/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_publications/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"terms": {
|
||||
"qaProcessedDoi": [
|
||||
"10.5555/3234847.3234861",
|
||||
"10.1145/1858367.1858373",
|
||||
"10.1145/3583120.3586961",
|
||||
"10.1109/ipin.2017.8115906",
|
||||
"10.1145/3274783.3275217",
|
||||
"10.1007/978-3-031-20716-7_7",
|
||||
"10.1109/percomw.2012.6197554",
|
||||
"10.1016/j.pmcj.2012.12.002",
|
||||
"10.1007/978-3-658-32266-3_30",
|
||||
"10.1109/percomw.2013.6529502",
|
||||
"10.1109/ie.2010.40",
|
||||
"10.18419/opus-2650",
|
||||
"10.1007/s00138-024-01553-z",
|
||||
"10.1007/978-3-030-90439-5_15",
|
||||
"10.1201/9781003338659-4",
|
||||
"10.1016/j.pmcj.2013.10.013",
|
||||
"10.1109/percom.2009.4912852",
|
||||
"10.1109/icra55743.2025.11128432",
|
||||
"10.1145/2494091.2497327",
|
||||
"10.1007/978-3-658-46485-1_31",
|
||||
"10.1109/ie.2017.22",
|
||||
"10.1109/jiot.2016.2554146",
|
||||
"10.1145/2493432.2493459",
|
||||
"10.3233/ais-160416",
|
||||
"10.1109/percomw.2007.111",
|
||||
"10.5194/asr-17-183-2020",
|
||||
"10.1007/978-3-658-36430-4_37",
|
||||
"10.1007/978-3-030-64559-5_50"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
@@ -79,6 +161,26 @@ GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"size": 1000,
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"term": {
|
||||
"name.keyword": "UNIVERSITAET DUISBURG-ESSEN"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"size": 0,
|
||||
"query": {
|
||||
@@ -101,6 +203,38 @@ Content-Type: application/json
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_projects/_mapping
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": {
|
||||
"terms": {
|
||||
"name": [
|
||||
"UNIVERSITÄT DUISBURG-ESSEN",
|
||||
"UNIVERSITY OF DUISBURG-ESSEN",
|
||||
"UNIVERSITAT DUISBURG-ESSEN",
|
||||
"UNIVERSITY OF DUISBURG ESSEN",
|
||||
"UNIVERSITAT DUISBURG-ESSEN",
|
||||
"UNIVERSITAET DUISBURG ESSEN",
|
||||
"UNIVERSITÄT DUISBURG ESSEN",
|
||||
"UNIVERSITAT DUISBURG ESSEN",
|
||||
"UNIVERSITÄT DUISBURG-ESSEN",
|
||||
"UNIVERSITAET DUISBURG-ESSEN",
|
||||
"UNIVERSITY OF DUISBURG-ESSEN"
|
||||
]
|
||||
}
|
||||
},
|
||||
"_source": ["projectID", "organisationID", "ecContribution"]
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
GET https://inse.nes.uni-due.de/elastic/cordis_eu_*_organizations/_search
|
||||
Authorization: ApiKey bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==
|
||||
@@ -132,18 +266,27 @@ Content-Type: application/json
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"term": {
|
||||
"name.keyword": "UNIVERSITAET DUISBURG-ESSEN"
|
||||
"terms": {
|
||||
"name.keyword": [
|
||||
"UNIVERSITAET DUISBURG-ESSEN",
|
||||
"UNIVERSITY OF DUISBURG-ESSEN",
|
||||
"UNIVERSITÄT DUISBURG-ESSEN",
|
||||
"UNIVERSITAT DUISBURG ESSEN",
|
||||
"UNIVERSITÄT DUISBURG ESSEN",
|
||||
"UNIVERSITY OF DUISBURG ESSEN",
|
||||
"UNIVERSITAET DUISBURG ESSEN",
|
||||
"UNIVERSITAT DUISBURG-ESSEN"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"aggs": {
|
||||
"specific_org_rcn_values": {
|
||||
"organisation_ids": {
|
||||
"terms": {
|
||||
"field": "organisationID",
|
||||
"size": 1000
|
||||
"size": 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1052,6 +1195,46 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
GET https://project.nes.uni-due.de/elastic/openalex-works/_search
|
||||
Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
GET https://project.nes.uni-due.de/elastic/openalex-works/_search
|
||||
Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ==
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"_source": ["title", "doi"],
|
||||
"size": 100,
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"term": {
|
||||
"authorships.author.id": "https://openalex.org/A5007170803"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"filter": [
|
||||
{
|
||||
"exists": {
|
||||
"field": "doi"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
GET https://project.nes.uni-due.de/elastic/openalex-authors/_search
|
||||
Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ==
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -10,6 +10,8 @@ api/iNSEAccountService.service.ts
|
||||
api/iNSEService.service.ts
|
||||
api/institutions.service.ts
|
||||
api/items.service.ts
|
||||
api/news.service.ts
|
||||
api/patents.service.ts
|
||||
api/personNetwork.service.ts
|
||||
api/persons.service.ts
|
||||
api/projects.service.ts
|
||||
@@ -59,6 +61,8 @@ model/dehydratedSource.ts
|
||||
model/dfgProjectDetails.ts
|
||||
model/dfgProjectPage.ts
|
||||
model/dfgProjectSummary.ts
|
||||
model/euOrganizationProjectSummary.ts
|
||||
model/euOrganizationProjectSummaryPage.ts
|
||||
model/filterInformation.ts
|
||||
model/filterProperties.ts
|
||||
model/funderByAuthor.ts
|
||||
@@ -85,10 +89,16 @@ model/latitude.ts
|
||||
model/location.ts
|
||||
model/longitude.ts
|
||||
model/matchedOfficer.ts
|
||||
model/mentionedPerson.ts
|
||||
model/meta.ts
|
||||
model/model2YrMeanCitedness.ts
|
||||
model/models.ts
|
||||
model/newsArticle.ts
|
||||
model/newsArticleDetail.ts
|
||||
model/newsPage.ts
|
||||
model/openAccess.ts
|
||||
model/patentEntry.ts
|
||||
model/patentsByAuthorResponse.ts
|
||||
model/personBio.ts
|
||||
model/projectType.ts
|
||||
model/projectsFilteringProperties.ts
|
||||
|
||||
@@ -10,6 +10,10 @@ export * from './institutions.service';
|
||||
import { InstitutionsService } from './institutions.service';
|
||||
export * from './items.service';
|
||||
import { ItemsService } from './items.service';
|
||||
export * from './news.service';
|
||||
import { NewsService } from './news.service';
|
||||
export * from './patents.service';
|
||||
import { PatentsService } from './patents.service';
|
||||
export * from './personNetwork.service';
|
||||
import { PersonNetworkService } from './personNetwork.service';
|
||||
export * from './persons.service';
|
||||
@@ -27,6 +31,8 @@ export const APIS = [
|
||||
INSEServiceService,
|
||||
InstitutionsService,
|
||||
ItemsService,
|
||||
NewsService,
|
||||
PatentsService,
|
||||
PersonNetworkService,
|
||||
PersonsService,
|
||||
ProjectsService,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,11 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
@@ -16,38 +22,16 @@ import {
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { PatentsByAuthorResponse } from '../model/patentsByAuthorResponse';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { BaseService } from '../api.base.service';
|
||||
|
||||
export interface PatentEntry {
|
||||
patent_id: string;
|
||||
source: string;
|
||||
title: string | null;
|
||||
abstract: string | null;
|
||||
publication_date: string | null;
|
||||
publication_year: string | null;
|
||||
inventors: string[];
|
||||
assignees: string[];
|
||||
ipc: string[];
|
||||
country: string | null;
|
||||
confidence_score: number;
|
||||
}
|
||||
|
||||
export interface PatentsByAuthorResponse {
|
||||
author_id: string;
|
||||
author_name: string | null;
|
||||
patent_count: number;
|
||||
patents: PatentEntry[];
|
||||
}
|
||||
|
||||
type GetPatentsByAuthorOptions = {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
};
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@@ -61,35 +45,51 @@ export class PatentsService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get patents by author.
|
||||
* Get patents matched to an author by name.
|
||||
* @endpoint get /api/inse-service/authors/{author_id}/patents
|
||||
* @param authorId
|
||||
* @param observe
|
||||
* @param reportProgress
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean,
|
||||
options?: GetPatentsByAuthorOptions,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<PatentsByAuthorResponse>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: GetPatentsByAuthorOptions,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: GetPatentsByAuthorOptions,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: GetPatentsByAuthorOptions,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error(
|
||||
@@ -127,18 +127,7 @@ export class PatentsService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam(
|
||||
{
|
||||
name: 'authorId',
|
||||
value: authorId,
|
||||
in: 'path',
|
||||
style: 'simple',
|
||||
explode: false,
|
||||
dataType: 'string',
|
||||
dataFormat: undefined,
|
||||
},
|
||||
)}/patents`;
|
||||
|
||||
let localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam({ name: 'authorId', value: authorId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}/patents`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<PatentsByAuthorResponse>(
|
||||
'get',
|
||||
|
||||
@@ -33,6 +33,8 @@ import { DfgProjectDetails } from '../model/dfgProjectDetails';
|
||||
// @ts-ignore
|
||||
import { DfgProjectPage } from '../model/dfgProjectPage';
|
||||
// @ts-ignore
|
||||
import { EuOrganizationProjectSummaryPage } from '../model/euOrganizationProjectSummaryPage';
|
||||
// @ts-ignore
|
||||
import { FundingProjectPage } from '../model/fundingProjectPage';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
@@ -225,6 +227,109 @@ export class ProjectsService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get EU projects for an author.
|
||||
* Returns a list of EU projects associated with the specified author ID.
|
||||
* @endpoint get /api/projects/author/{raw_oa_author_id}/eu
|
||||
* @param rawOaAuthorId The author ID to filter by.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getEuProjectsForAuthor(
|
||||
rawOaAuthorId: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<CordisEuProjectPage>;
|
||||
public getEuProjectsForAuthor(
|
||||
rawOaAuthorId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<CordisEuProjectPage>>;
|
||||
public getEuProjectsForAuthor(
|
||||
rawOaAuthorId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<CordisEuProjectPage>>;
|
||||
public getEuProjectsForAuthor(
|
||||
rawOaAuthorId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<any> {
|
||||
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
|
||||
throw new Error(
|
||||
'Required parameter rawOaAuthorId was null or undefined when calling getEuProjectsForAuthor.',
|
||||
);
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined =
|
||||
options?.httpHeaderAccept ??
|
||||
this.configuration.selectHeaderAccept(['application/json']);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set(
|
||||
'Accept',
|
||||
localVarHttpHeaderAcceptSelected,
|
||||
);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext =
|
||||
options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (
|
||||
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
|
||||
) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/projects/author/${this.configuration.encodeParam({ name: 'rawOaAuthorId', value: rawOaAuthorId, in: 'path', style: 'simple', explode: false, dataType: 'string', dataFormat: undefined })}/eu`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<CordisEuProjectPage>(
|
||||
'get',
|
||||
`${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined
|
||||
? { transferCache: localVarTransferCache }
|
||||
: {}),
|
||||
reportProgress: reportProgress,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get funding over time for bund projects.
|
||||
* Returns the funding over time for bund projects associated with the specified institution.
|
||||
@@ -788,7 +893,7 @@ export class ProjectsService extends BaseService {
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<CordisEuProjectPage>;
|
||||
): Observable<EuOrganizationProjectSummaryPage>;
|
||||
public searchCordisEuProjects(
|
||||
projectsFilteringProperties: ProjectsFilteringProperties,
|
||||
observe?: 'response',
|
||||
@@ -798,7 +903,7 @@ export class ProjectsService extends BaseService {
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<CordisEuProjectPage>>;
|
||||
): Observable<HttpResponse<EuOrganizationProjectSummaryPage>>;
|
||||
public searchCordisEuProjects(
|
||||
projectsFilteringProperties: ProjectsFilteringProperties,
|
||||
observe?: 'events',
|
||||
@@ -808,7 +913,7 @@ export class ProjectsService extends BaseService {
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<CordisEuProjectPage>>;
|
||||
): Observable<HttpEvent<EuOrganizationProjectSummaryPage>>;
|
||||
public searchCordisEuProjects(
|
||||
projectsFilteringProperties: ProjectsFilteringProperties,
|
||||
observe: any = 'body',
|
||||
@@ -871,7 +976,7 @@ export class ProjectsService extends BaseService {
|
||||
|
||||
let localVarPath = `/api/projects/institution/eu/search`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<CordisEuProjectPage>(
|
||||
return this.httpClient.request<EuOrganizationProjectSummaryPage>(
|
||||
'post',
|
||||
`${basePath}${localVarPath}`,
|
||||
{
|
||||
|
||||
@@ -710,6 +710,7 @@ export class TopicsService extends BaseService {
|
||||
public vectorSearchTopics(
|
||||
query: string,
|
||||
limit?: number,
|
||||
searchType?: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
@@ -721,6 +722,7 @@ export class TopicsService extends BaseService {
|
||||
public vectorSearchTopics(
|
||||
query: string,
|
||||
limit?: number,
|
||||
searchType?: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
@@ -732,6 +734,7 @@ export class TopicsService extends BaseService {
|
||||
public vectorSearchTopics(
|
||||
query: string,
|
||||
limit?: number,
|
||||
searchType?: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
@@ -743,6 +746,7 @@ export class TopicsService extends BaseService {
|
||||
public vectorSearchTopics(
|
||||
query: string,
|
||||
limit?: number,
|
||||
searchType?: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: {
|
||||
@@ -768,6 +772,13 @@ export class TopicsService extends BaseService {
|
||||
<any>limit,
|
||||
'limit',
|
||||
);
|
||||
if (searchType !== undefined && searchType !== null) {
|
||||
localVarQueryParameters = this.addToHttpParams(
|
||||
localVarQueryParameters,
|
||||
<any>searchType,
|
||||
'searchType',
|
||||
);
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface EuOrganizationProjectSummary {
|
||||
/**
|
||||
* The unique identifier of the organization.
|
||||
*/
|
||||
organization_id: string;
|
||||
/**
|
||||
* The unique identifier of the project.
|
||||
*/
|
||||
project_id: string;
|
||||
title?: string | null;
|
||||
start_date?: string | null;
|
||||
end_date?: string | null;
|
||||
acronym?: string | null;
|
||||
ec_contribution?: number | null;
|
||||
}
|
||||
@@ -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 { EuOrganizationProjectSummary } from './euOrganizationProjectSummary';
|
||||
|
||||
export interface EuOrganizationProjectSummaryPage {
|
||||
/**
|
||||
* The current page number.
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* The requested page size.
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* The total number of items.
|
||||
*/
|
||||
total?: number;
|
||||
/**
|
||||
* The organization project summaries on this page.
|
||||
*/
|
||||
elements?: Array<EuOrganizationProjectSummary>;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ export interface FundingProject {
|
||||
*/
|
||||
id: string;
|
||||
title?: string | null;
|
||||
acronym?: string | null;
|
||||
start_date?: string | null;
|
||||
end_date?: string | null;
|
||||
funding_amount?: number | null;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface MentionedPerson {
|
||||
name: string;
|
||||
is_ude?: boolean;
|
||||
person_id?: string | null;
|
||||
}
|
||||
@@ -38,6 +38,8 @@ export * from './dehydratedSource';
|
||||
export * from './dfgProjectDetails';
|
||||
export * from './dfgProjectPage';
|
||||
export * from './dfgProjectSummary';
|
||||
export * from './euOrganizationProjectSummary';
|
||||
export * from './euOrganizationProjectSummaryPage';
|
||||
export * from './filterInformation';
|
||||
export * from './filterProperties';
|
||||
export * from './funderByAuthor';
|
||||
@@ -64,9 +66,15 @@ export * from './latitude';
|
||||
export * from './location';
|
||||
export * from './longitude';
|
||||
export * from './matchedOfficer';
|
||||
export * from './mentionedPerson';
|
||||
export * from './meta';
|
||||
export * from './model2YrMeanCitedness';
|
||||
export * from './newsArticle';
|
||||
export * from './newsArticleDetail';
|
||||
export * from './newsPage';
|
||||
export * from './openAccess';
|
||||
export * from './patentEntry';
|
||||
export * from './patentsByAuthorResponse';
|
||||
export * from './personBio';
|
||||
export * from './projectType';
|
||||
export * from './projectsFilteringProperties';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface NewsArticle {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
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;
|
||||
full_content?: string | null;
|
||||
authors?: Array<MentionedPerson>;
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
import { NewsArticle } from './newsArticle';
|
||||
|
||||
export interface NewsPage {
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
results: Array<NewsArticle>;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface PatentEntry {
|
||||
patent_id: string;
|
||||
source: string;
|
||||
title?: string | null;
|
||||
abstract?: string | null;
|
||||
publication_date?: string | null;
|
||||
publication_year?: string | null;
|
||||
inventors?: Array<string>;
|
||||
assignees?: Array<string>;
|
||||
ipc?: Array<string>;
|
||||
country?: 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.
|
||||
*/
|
||||
import { PatentEntry } from './patentEntry';
|
||||
|
||||
export interface PatentsByAuthorResponse {
|
||||
author_id: string;
|
||||
author_name?: string | null;
|
||||
patent_count: number;
|
||||
patents: Array<PatentEntry>;
|
||||
}
|
||||
@@ -19,4 +19,13 @@ export interface TopicCount {
|
||||
*/
|
||||
count?: number;
|
||||
description?: string | null;
|
||||
subfield_id?: string | null;
|
||||
subfield_name?: string | null;
|
||||
subfield_description?: string | null;
|
||||
field_id?: string | null;
|
||||
field_name?: string | null;
|
||||
field_description?: string | null;
|
||||
domain_id?: string | null;
|
||||
domain_name?: string | null;
|
||||
domain_description?: string | null;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { bundSingleProjectResolver } from './resolvers/bund-single-project-resol
|
||||
import { cordisEuProjectPageResolver } from './resolvers/cordis-eu-project-page.resolver';
|
||||
import { cordisEuProjectsFundingResolver } from './resolvers/cordis-eu-projects-funding.resolver';
|
||||
import { fundingProjectPageResolver } from './resolvers/funding-project-page.resolver';
|
||||
import { personCordisEuProjectPageResolver } from './resolvers/person-cordis-eu-project-page.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
@@ -162,6 +163,7 @@ export const routes: Routes = [
|
||||
),
|
||||
resolve: {
|
||||
dfgProjectPage: dfgProjectsResolver,
|
||||
personCordisEuProjectPage: personCordisEuProjectPageResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
const keys = ['page', 'size', 'sort_by', 'sort_direction', 'search'];
|
||||
@@ -188,7 +190,33 @@ export const routes: Routes = [
|
||||
collaborationNetwork: collaborationNetworkResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
// No need to re-run for different table view or search term
|
||||
const network = from.data['collaborationNetwork'] as
|
||||
| {
|
||||
filter_information?: {
|
||||
min_possible_year?: number;
|
||||
max_possible_year?: number;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
|
||||
const filterInformation = network?.filter_information;
|
||||
|
||||
const defaultQueryParams: Record<string, string> = {
|
||||
filter_by: 'works',
|
||||
start_year: filterInformation?.min_possible_year
|
||||
? String(filterInformation.min_possible_year)
|
||||
: '',
|
||||
end_year: filterInformation?.max_possible_year
|
||||
? String(filterInformation.max_possible_year)
|
||||
: '',
|
||||
min_contributors: '2',
|
||||
max_contributors: '10',
|
||||
min_collaborations: '1',
|
||||
max_collaborations: '100',
|
||||
institutions: '',
|
||||
topics: '',
|
||||
};
|
||||
|
||||
const keys = [
|
||||
'filter_by',
|
||||
'start_year',
|
||||
@@ -201,9 +229,22 @@ export const routes: Routes = [
|
||||
'topics',
|
||||
];
|
||||
|
||||
return keys.some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
return keys.some((key) => {
|
||||
const fromRawValue = from.queryParamMap.get(key);
|
||||
const toRawValue = to.queryParamMap.get(key);
|
||||
|
||||
const fromValue =
|
||||
fromRawValue === null || fromRawValue === ''
|
||||
? defaultQueryParams[key]
|
||||
: fromRawValue;
|
||||
|
||||
const toValue =
|
||||
toRawValue === null || toRawValue === ''
|
||||
? defaultQueryParams[key]
|
||||
: toRawValue;
|
||||
|
||||
return fromValue !== toValue;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -4,19 +4,10 @@
|
||||
<div class="funding-area">
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>Suche nach Themen</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="search"
|
||||
[debounceTime]="300"
|
||||
[(debouncedValue)]="urlSearchTerm"
|
||||
(debouncedValueChange)="handleSearchTermChange($event)" />
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<button matIconButton matSuffix (click)="clearSearchTerm()">
|
||||
<mat-icon>clear</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<app-query-param-input
|
||||
label="Suche nach Themen"
|
||||
queryParamKey="search" />
|
||||
|
||||
<mat-tab-group
|
||||
[selectedIndex]="tabIndex()"
|
||||
(selectedTabChange)="selectedTabChange($event)">
|
||||
@@ -24,24 +15,20 @@
|
||||
<app-data-table
|
||||
[data]="euProjectData"
|
||||
[columns]="euProjectColumns"
|
||||
[activeSortKey]="urlSortKey()"
|
||||
[sortDirection]="urlSortDirection()"
|
||||
(sortChange)="handleSortChange($event)" />
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
</mat-tab>
|
||||
<mat-tab label="Bund">
|
||||
<app-data-table
|
||||
[data]="bundProjectData"
|
||||
[columns]="bundProjectColumns"
|
||||
[activeSortKey]="urlSortKey()"
|
||||
[sortDirection]="urlSortDirection()"
|
||||
(sortChange)="handleSortChange($event)" />
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<mat-paginator
|
||||
[length]="this.pageTotal()"
|
||||
[pageSize]="this.pageSize()"
|
||||
[pageIndex]="this.pageIndex()"
|
||||
(page)="handlePageChange($event)" />
|
||||
<app-query-param-paginator
|
||||
[total]="pageTotal()"
|
||||
[pageSizeOptions]="[10, 20, 50]" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<div class="funding-info-section">
|
||||
@@ -94,3 +81,15 @@
|
||||
<ng-template #fundingAmountTmp let-row>
|
||||
{{ row.funding_amount | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #euProjectActionsTmp let-row>
|
||||
<a mat-icon-button color="primary" [routerLink]="['/projects/eu', row.id]">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a></ng-template
|
||||
>
|
||||
|
||||
<ng-template #bundProjectActionsTmp let-row>
|
||||
<a mat-icon-button color="primary" [routerLink]="['/projects/bund', row.id]">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
@@ -4,22 +4,20 @@ import {
|
||||
effect,
|
||||
input,
|
||||
OnInit,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import {
|
||||
BundProject,
|
||||
BundProjectPage,
|
||||
CordisEuProject,
|
||||
CordisEuProjectPage,
|
||||
EuOrganizationProjectSummary,
|
||||
EuOrganizationProjectSummaryPage,
|
||||
InstitutionFunderSummary,
|
||||
} from '../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatTabChangeEvent, MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import {
|
||||
@@ -27,15 +25,16 @@ import {
|
||||
DataTableComponent,
|
||||
} from '../../shared/ui/data-table/data-table.component';
|
||||
import { CurrencyPipe, DatePipe } from '@angular/common';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { Sort, SortDirection } from '@angular/material/sort';
|
||||
import { DebounceDirective } from '../../directives/debounce.directive';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { InstitutionProjectsFundingGraphComponent } from '../institution-projects-funding-graph/institution-projects-funding-graph.component';
|
||||
import { PersonNetworkInfoCardComponent } from '../person-network-info-card/person-network-info-card.component';
|
||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import { QueryParamInputComponent } from '../../shared/ui/query-param-input/query-param-input.component';
|
||||
|
||||
type BundProjectRow = {
|
||||
id: string;
|
||||
topic: string;
|
||||
funding_start: Date;
|
||||
funding_end: Date;
|
||||
@@ -44,6 +43,7 @@ type BundProjectRow = {
|
||||
};
|
||||
|
||||
type EuProjectRow = {
|
||||
id: string;
|
||||
topic: string;
|
||||
funding_start: Date;
|
||||
funding_end: Date;
|
||||
@@ -56,17 +56,18 @@ type EuProjectRow = {
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatTabsModule,
|
||||
MatPaginatorModule,
|
||||
FormsModule,
|
||||
MatInputModule,
|
||||
DataTableComponent,
|
||||
DatePipe,
|
||||
CurrencyPipe,
|
||||
DebounceDirective,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
InstitutionProjectsFundingGraphComponent,
|
||||
PersonNetworkInfoCardComponent,
|
||||
RouterModule,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamInputComponent,
|
||||
],
|
||||
templateUrl: './institution-projects.component.html',
|
||||
styleUrl: './institution-projects.component.scss',
|
||||
@@ -76,13 +77,19 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
||||
fundingAmountTmp = viewChild.required<TemplateRef<any>>('fundingAmountTmp');
|
||||
|
||||
cordisEuProjectPage = input.required<CordisEuProjectPage>();
|
||||
cordisEuProjectPage = input.required<EuOrganizationProjectSummaryPage>();
|
||||
euProjectColumns: GenericColumn<EuProjectRow>[] = [];
|
||||
euProjectData: EuProjectRow[] = [];
|
||||
euProjectActionsTmp = viewChild.required<TemplateRef<any>>(
|
||||
'euProjectActionsTmp',
|
||||
);
|
||||
|
||||
bundProjectPage = input.required<BundProjectPage>();
|
||||
bundProjectColumns: GenericColumn<BundProjectRow>[] = [];
|
||||
bundProjectData: BundProjectRow[] = [];
|
||||
bundProjectActionsTmp = viewChild.required<TemplateRef<any>>(
|
||||
'bundProjectActionsTmp',
|
||||
);
|
||||
|
||||
bundProjectsFunding = input.required<InstitutionFunderSummary>();
|
||||
bundTotalFunding = computed(() => {
|
||||
@@ -108,24 +115,10 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
return funding.annual_average_over_period ?? 0;
|
||||
});
|
||||
|
||||
urlSortKey = signal<string>('');
|
||||
urlSortDirection = signal<SortDirection>('');
|
||||
urlSearchTerm = signal<string>('');
|
||||
|
||||
constructor(
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
private readonly router: Router,
|
||||
) {
|
||||
this.activatedRoute.queryParams
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((params) => {
|
||||
this.urlSortKey.set(params['sort_by'] ?? '');
|
||||
this.urlSortDirection.set(
|
||||
(params['sort_direction'] as SortDirection) ?? '',
|
||||
);
|
||||
this.urlSearchTerm.set(params['search'] ?? '');
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const euPage = this.cordisEuProjectPage();
|
||||
if (euPage) {
|
||||
@@ -142,20 +135,6 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
: [];
|
||||
}
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const searchTerm = this.urlSearchTerm();
|
||||
if (searchTerm) {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: searchTerm, page: 0, size: 10 },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
console.log('Funding over time data:', this.bundProjectsFunding());
|
||||
});
|
||||
}
|
||||
|
||||
readonly queryParams = toSignal(this.activatedRoute.queryParamMap, {
|
||||
@@ -166,12 +145,6 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
return this.queryParams()?.get('project_tab') ?? 'eu';
|
||||
});
|
||||
|
||||
readonly page = computed(() => {
|
||||
const pageParam = this.queryParams()?.get('page');
|
||||
const page = pageParam ? Number.parseInt(pageParam, 10) : 0;
|
||||
return Number.isNaN(page) ? 0 : page;
|
||||
});
|
||||
|
||||
readonly selectedPage = computed(() => {
|
||||
if (this.displayedProjects() === 'eu') {
|
||||
return this.cordisEuProjectPage();
|
||||
@@ -184,14 +157,6 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
return this.selectedPage()?.total ?? 0;
|
||||
});
|
||||
|
||||
readonly pageSize = computed(() => {
|
||||
return this.selectedPage()?.size ?? 10;
|
||||
});
|
||||
|
||||
readonly pageIndex = computed(() => {
|
||||
return this.selectedPage()?.page ?? 0;
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.euProjectColumns = [
|
||||
{
|
||||
@@ -221,10 +186,16 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
accessorKey: 'funding_amount',
|
||||
cellTemplate: this.fundingAmountTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.euProjectActionsTmp(),
|
||||
},
|
||||
];
|
||||
this.bundProjectColumns = [
|
||||
{
|
||||
id: 'topic',
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'topic',
|
||||
@@ -250,22 +221,30 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
accessorKey: 'funding_amount',
|
||||
cellTemplate: this.fundingAmountTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.bundProjectActionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
transformEuRow(project: CordisEuProject): EuProjectRow {
|
||||
transformEuRow(project: EuOrganizationProjectSummary): EuProjectRow {
|
||||
return {
|
||||
id: project.project_id,
|
||||
topic: project.title || '',
|
||||
funding_start: project.startDate
|
||||
? new Date(project.startDate)
|
||||
funding_start: project.start_date
|
||||
? new Date(project.start_date)
|
||||
: new Date(0),
|
||||
funding_end: project.endDate ? new Date(project.endDate) : new Date(0),
|
||||
funding_amount: Number(project.totalCost) || 0,
|
||||
funding_end: project.end_date ? new Date(project.end_date) : new Date(0),
|
||||
funding_amount: Number(project.ec_contribution) || 0,
|
||||
};
|
||||
}
|
||||
|
||||
transformBundRow(project: BundProject): BundProjectRow {
|
||||
return {
|
||||
id: project.funding_code || '',
|
||||
topic: project.topic || '',
|
||||
funding_start: project.funding_start
|
||||
? new Date(project.funding_start)
|
||||
@@ -296,32 +275,4 @@ export class InstitutionProjectsComponent implements OnInit {
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange(event: PageEvent): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { page: event.pageIndex, size: event.pageSize },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSortChange(event: Sort): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { sort_by: event.active, sort_direction: event.direction },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSearchTermChange(newTerm: string): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: newTerm, page: 0, size: 10 },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
clearSearchTerm(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: null, page: 0, size: 10 },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,34 +4,19 @@
|
||||
<mat-divider />
|
||||
|
||||
<div class="search-and-sorting">
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>Suche nach Namen</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="search"
|
||||
[debounceTime]="300"
|
||||
[(debouncedValue)]="urlSearchTerm"
|
||||
(debouncedValueChange)="handleSearchTermChange($event)" />
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<button matIconButton matSuffix (click)="clearSearchTerm()">
|
||||
<mat-icon>clear</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<app-query-param-input
|
||||
[label]="'Suche nach Namen'"
|
||||
[debounceTime]="400"
|
||||
[queryParamKey]="'search'" />
|
||||
|
||||
<div class="sorting">
|
||||
<select (change)="handleSortFieldChange($event)" [value]="urlSortBy()">
|
||||
<option value="relevance">Relevanz</option>
|
||||
<option value="name">Name</option>
|
||||
<option value="works_count">Anzahl Publikationen</option>
|
||||
<option value="citations_count">Anzahl Zitationen</option>
|
||||
</select>
|
||||
<app-query-param-selector
|
||||
[options]="sortingOptions"
|
||||
[queryParamKey]="'sort_by'" />
|
||||
|
||||
<select
|
||||
(change)="handleSortOrderChange($event)"
|
||||
[value]="urlSortingOrder()">
|
||||
<option value="desc">Absteigend</option>
|
||||
<option value="asc">Aufsteigend</option>
|
||||
</select>
|
||||
<app-query-param-selector
|
||||
[options]="sortingDirectionOptions"
|
||||
[queryParamKey]="'sorting_order'" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -106,11 +91,7 @@
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-paginator
|
||||
[length]="institutionPageValue.total"
|
||||
[pageSize]="institutionPageValue.size"
|
||||
[pageSizeOptions]="[10, 20, 50]"
|
||||
[pageIndex]="institutionPageValue.page"
|
||||
(page)="handlePageChange($event)">
|
||||
</mat-paginator>
|
||||
<app-query-param-paginator
|
||||
[total]="institutionPageValue.total ?? 0"
|
||||
[pageSizeOptions]="[10, 20, 50]" />
|
||||
</div>
|
||||
|
||||
@@ -25,26 +25,10 @@
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cards {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
background-color: var(--sg-background);
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 0.5rem;
|
||||
background-color: var(--sg-background);
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import { Component, effect, input, signal } from '@angular/core';
|
||||
import { Component, input } from '@angular/core';
|
||||
import { Institution, InstitutionPage } from '../../api';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { DebounceDirective } from '../../directives/debounce.directive';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import {
|
||||
QueryParamSelectorComponent,
|
||||
SelectorOption,
|
||||
} from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { QueryParamInputComponent } from '../../shared/ui/query-param-input/query-param-input.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institutions',
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatInputModule,
|
||||
MatIconModule,
|
||||
DebounceDirective,
|
||||
MatPaginator,
|
||||
MatDividerModule,
|
||||
RouterModule,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamSelectorComponent,
|
||||
QueryParamInputComponent,
|
||||
],
|
||||
templateUrl: './institutions.component.html',
|
||||
styleUrl: './institutions.component.scss',
|
||||
@@ -28,74 +30,21 @@ import { MatDividerModule } from '@angular/material/divider';
|
||||
export class InstitutionsComponent {
|
||||
institutionPage = input.required<InstitutionPage>();
|
||||
|
||||
urlSearchTerm = signal<string>('');
|
||||
urlSortBy = signal<string>('relevance');
|
||||
urlSortingOrder = signal<string>('desc');
|
||||
|
||||
constructor(
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
private readonly router: Router,
|
||||
) {
|
||||
this.activatedRoute.queryParams
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((params) => {
|
||||
this.urlSearchTerm.set(params['search'] || '');
|
||||
this.urlSortBy.set(params['sort_by'] || 'relevance');
|
||||
this.urlSortingOrder.set(params['sorting_order'] || 'desc');
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const searchTerm = this.urlSearchTerm();
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: searchTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleSearchTermChange(newTerm: string): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: newTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
clearSearchTerm(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: null },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange(event: PageEvent): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { page: event.pageIndex, size: event.pageSize },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
sortingOptions: SelectorOption[] = [
|
||||
{ value: 'relevance', display_name: 'Relevanz' },
|
||||
{ value: 'name', display_name: 'Name' },
|
||||
{ value: 'works_count', display_name: 'Anzahl Publikationen' },
|
||||
{ value: 'citations_count', display_name: 'Anzahl Zitationen' },
|
||||
];
|
||||
sortingDirectionOptions: SelectorOption[] = [
|
||||
{ value: 'asc', display_name: 'Aufsteigend' },
|
||||
{ value: 'desc', display_name: 'Absteigend' },
|
||||
];
|
||||
|
||||
extractInstitutionId(institution: Institution): string {
|
||||
return institution.id?.split('/').pop() ?? '';
|
||||
}
|
||||
|
||||
handleSortFieldChange(event: Event): void {
|
||||
const selectElement = event.target as HTMLSelectElement;
|
||||
const sortField = selectElement.value;
|
||||
this.router.navigate([], {
|
||||
queryParams: { sort_by: sortField },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSortOrderChange(event: Event): void {
|
||||
const selectElement = event.target as HTMLSelectElement;
|
||||
const sortOrder = selectElement.value;
|
||||
this.router.navigate([], {
|
||||
queryParams: { sorting_order: sortOrder },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
getDisplayName(institution: Institution): string {
|
||||
const primary = institution.display_name?.trim();
|
||||
if (primary && primary.length > 0) return primary;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<article class="person-card">
|
||||
<a [routerLink]="['/person', person.id, 'overview']" class="card-header">
|
||||
<a [routerLink]="['/person', person().id, 'overview']" class="card-header">
|
||||
<!-- Initials Avatar or Profile Image fallback -->
|
||||
<div [skText]="loading" class="avatar">
|
||||
{{ getInitials(person.display_name) }}
|
||||
<div [skText]="loading()" class="avatar">
|
||||
{{ initials() }}
|
||||
</div>
|
||||
<div class="header-main">
|
||||
<div class="bookmark">
|
||||
@@ -11,41 +11,58 @@
|
||||
(click)="
|
||||
toggleBookmark(); $event.stopPropagation(); $event.preventDefault()
|
||||
"
|
||||
[class.bookmarked]="isBookmarked"
|
||||
[class.bookmarked]="isBookmarked()"
|
||||
aria-label="Bookmark person">
|
||||
<mat-icon>{{
|
||||
isBookmarked ? 'bookmark' : 'bookmark_border'
|
||||
isBookmarked() ? 'bookmark' : 'bookmark_border'
|
||||
}}</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<h2
|
||||
[skText]="loading"
|
||||
[skText]="loading()"
|
||||
class="person-name"
|
||||
[title]="person.display_name ?? ''">
|
||||
{{ person.display_name ?? '' }}
|
||||
[title]="person().display_name ?? ''">
|
||||
{{ person().display_name ?? '' }}
|
||||
</h2>
|
||||
<p [skText]="loading" class="person-id">
|
||||
{{ getDistinguishingId(person) }}
|
||||
<p [skText]="loading()" class="person-id">
|
||||
{{ distinguishingId() }}
|
||||
</p>
|
||||
<p [skText]="loading" class="stats">
|
||||
{{ getStatsString() }}
|
||||
<p [skText]="loading()" class="stats">
|
||||
{{ statsString() }}
|
||||
</p>
|
||||
<p [skText]="loading" class="stats">
|
||||
{{ getHIndexString() }}
|
||||
<p [skText]="loading()" class="stats">
|
||||
{{ hIndexString() }}
|
||||
</p>
|
||||
@if (!loading()) {
|
||||
@if (careerStage(); as careerStage) {
|
||||
<div [skText]="loading()" class="career-stage-line">
|
||||
<span class="career-stage-label">Career Stage:</span>
|
||||
<span
|
||||
class="career-stage-chip"
|
||||
[matTooltip]="getCareerStageTooltip(careerStage)"
|
||||
matTooltipPosition="right"
|
||||
matTooltipClass="career-stage-tooltip"
|
||||
[matTooltipShowDelay]="250">
|
||||
{{ careerStage }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="card-body">
|
||||
@if (institution(person); as inst) {
|
||||
@if (institution(); as inst) {
|
||||
<div class="institution-row" style="margin-bottom: 8px">
|
||||
<span
|
||||
<button
|
||||
type="button"
|
||||
class="institution-tag"
|
||||
[matTooltip]="inst.display_name || ''"
|
||||
matTooltipPosition="above"
|
||||
(click)="
|
||||
institutionClick.emit(inst.display_name || '');
|
||||
$event.stopPropagation()
|
||||
"
|
||||
[title]="inst.display_name || ''">
|
||||
">
|
||||
<mat-icon
|
||||
style="
|
||||
font-size: 12px;
|
||||
@@ -57,12 +74,12 @@
|
||||
>apartment</mat-icon
|
||||
>
|
||||
<span
|
||||
[skText]="loading"
|
||||
[skText]="loading()"
|
||||
class="institution-name"
|
||||
style="vertical-align: middle"
|
||||
>{{ inst.display_name ?? '' }}</span
|
||||
>
|
||||
@if (inst.country_code && !loading) {
|
||||
@if (inst.country_code && !loading()) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
@@ -75,38 +92,41 @@
|
||||
>{{ inst.country_code.toUpperCase() }}</span
|
||||
>
|
||||
}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="topic-row">
|
||||
@for (topic of topics(person); track topic.id) {
|
||||
<span
|
||||
[skText]="loading"
|
||||
@for (topic of topics(); track topic.id) {
|
||||
<button
|
||||
type="button"
|
||||
[skText]="loading()"
|
||||
class="topic-tag"
|
||||
[class.active]="selectedTopics().has(topic.display_name || '')"
|
||||
[matTooltip]="getTopicTooltip(topic)"
|
||||
matTooltipPosition="above"
|
||||
(click)="
|
||||
topicClick.emit(topic.display_name || ''); $event.stopPropagation()
|
||||
"
|
||||
[title]="getTopicTooltip(topic)"
|
||||
>{{ topic.display_name }}</span
|
||||
>
|
||||
">
|
||||
{{ topic.display_name }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="action-buttons">
|
||||
<a [routerLink]="['/person', person.id, 'overview']" class="action-btn">
|
||||
<a [routerLink]="['/person', person().id, 'overview']" class="action-btn">
|
||||
<mat-icon>visibility</mat-icon>
|
||||
<span>Übersicht</span>
|
||||
</a>
|
||||
<a
|
||||
[routerLink]="['/person', person.id, 'publications']"
|
||||
[routerLink]="['/person', person().id, 'publications']"
|
||||
class="action-btn">
|
||||
<mat-icon>menu_book</mat-icon>
|
||||
<span>Publikationen</span>
|
||||
</a>
|
||||
<a [routerLink]="['/person', person.id, 'network']" class="action-btn">
|
||||
<a [routerLink]="['/person', person().id, 'network']" class="action-btn">
|
||||
<mat-icon>share</mat-icon>
|
||||
<span>Netzwerk</span>
|
||||
</a>
|
||||
|
||||
@@ -140,6 +140,9 @@
|
||||
transition: all 0.2s ease;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
line-height: normal;
|
||||
font-family: inherit;
|
||||
|
||||
.institution-name {
|
||||
overflow: hidden;
|
||||
@@ -159,10 +162,15 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
border-color: var(--sg-primary);
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 0 2px var(--sg-background),
|
||||
0 0 0 4px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +201,39 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.career-stage-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 10px;
|
||||
min-height: 18px;
|
||||
}
|
||||
|
||||
.career-stage-label {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.career-stage-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: var(--sg-surface-muted);
|
||||
color: var(--sg-primary);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 16px;
|
||||
flex-grow: 1;
|
||||
@@ -223,11 +264,36 @@
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
line-height: normal;
|
||||
font-family: inherit;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--sg-primary-soft);
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 0 2px var(--sg-background),
|
||||
0 0 0 4px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--sg-primary-soft);
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
font-weight: 700;
|
||||
box-shadow: 0 0 0 1.5px var(--sg-primary);
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
box-shadow:
|
||||
0 0 0 2px var(--sg-background),
|
||||
0 0 0 4px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +1,51 @@
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { Component, input, computed, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
|
||||
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-card',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink, MatIconModule, SkTextDirective],
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterLink,
|
||||
MatIconModule,
|
||||
SkTextDirective,
|
||||
MatTooltipModule,
|
||||
],
|
||||
templateUrl: './person-card.component.html',
|
||||
styleUrl: './person-card.component.scss',
|
||||
})
|
||||
export class PersonCardComponent {
|
||||
@Input({ required: true }) person!: CustomAuthor;
|
||||
@Input() isBookmarked = false;
|
||||
@Input() loading = false;
|
||||
@Output() bookmarkToggle = new EventEmitter<CustomAuthor>();
|
||||
@Output() topicClick = new EventEmitter<string>();
|
||||
@Output() institutionClick = new EventEmitter<string>();
|
||||
person = input.required<CustomAuthor>();
|
||||
isBookmarked = input<boolean>(false);
|
||||
loading = input<boolean>(false);
|
||||
selectedTopics = input<Set<string>>(new Set<string>());
|
||||
|
||||
getInitials(name: string | null | undefined): string {
|
||||
bookmarkToggle = output<CustomAuthor>();
|
||||
topicClick = output<string>();
|
||||
institutionClick = output<string>();
|
||||
|
||||
initials = computed<string>(() => {
|
||||
const name = this.person().display_name;
|
||||
if (!name) return 'U';
|
||||
const cleanName = name.replace(/Prof\.|Dr\.|M\.Sc\./g, '').trim();
|
||||
const parts = cleanName.split(' ');
|
||||
const first = parts[0]?.[0] || '';
|
||||
const last = parts[parts.length - 1]?.[0] || '';
|
||||
return (first + last).toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
getRatingClass(rating: string | null | undefined): string {
|
||||
const r = (rating || '').toLowerCase();
|
||||
if (r === 'sehr geeignet') return 'very-suitable';
|
||||
if (r === 'geeignet') return 'suitable';
|
||||
return 'possible';
|
||||
}
|
||||
|
||||
institution(person: CustomAuthor): DehydratedInstitution | undefined {
|
||||
if (person.last_known_institutions?.[0]) {
|
||||
return person.last_known_institutions[0];
|
||||
institution = computed<DehydratedInstitution | undefined>(() => {
|
||||
const p = this.person();
|
||||
if (p.last_known_institutions?.[0]) {
|
||||
return p.last_known_institutions[0];
|
||||
}
|
||||
|
||||
const affiliations = person.affiliations ?? [];
|
||||
const affiliations = p.affiliations ?? [];
|
||||
let newestInstitution: DehydratedInstitution | undefined =
|
||||
affiliations[0]?.institution ?? undefined;
|
||||
let newestYear = -1;
|
||||
@@ -55,12 +60,61 @@ export class PersonCardComponent {
|
||||
}
|
||||
|
||||
return newestInstitution;
|
||||
}
|
||||
});
|
||||
|
||||
topics(person: CustomAuthor): WorkTopic[] {
|
||||
return (person.topics ?? [])
|
||||
topics = computed<WorkTopic[]>(() => {
|
||||
return (this.person().topics ?? [])
|
||||
.filter((t): t is WorkTopic => !!t.display_name)
|
||||
.slice(0, 3);
|
||||
});
|
||||
|
||||
distinguishingId = computed<string>(() => {
|
||||
const p = this.person();
|
||||
if (p.orcid) {
|
||||
return p.orcid.replace('https://orcid.org/', '');
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
statsString = computed<string>(() => {
|
||||
const works = this.person().works_count;
|
||||
const citations = this.person().cited_by_count;
|
||||
const hasWorks = works !== undefined && works !== null;
|
||||
const hasCitations = citations !== undefined && citations !== null;
|
||||
|
||||
if (hasWorks && hasCitations) {
|
||||
return `Publikationen: ${works} · Zitationen: ${citations}`;
|
||||
} else if (hasWorks) {
|
||||
return `Publikationen: ${works}`;
|
||||
} else if (hasCitations) {
|
||||
return `Zitationen: ${citations}`;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
hIndexString = computed<string>(() => {
|
||||
const hIndex = this.person().summary_stats?.h_index;
|
||||
if (hIndex !== undefined && hIndex !== null) {
|
||||
return `h_index: ${hIndex}`;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
careerStage = computed<string | null>(() => {
|
||||
const stage = this.person().career_metrics?.career_stage;
|
||||
|
||||
if (!stage || stage === 'unknown') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stage;
|
||||
});
|
||||
|
||||
getRatingClass(rating: string | null | undefined): string {
|
||||
const r = (rating || '').toLowerCase();
|
||||
if (r === 'sehr geeignet') return 'very-suitable';
|
||||
if (r === 'geeignet') return 'suitable';
|
||||
return 'possible';
|
||||
}
|
||||
|
||||
getTopicTooltip(topic: WorkTopic): string {
|
||||
@@ -76,39 +130,24 @@ export class PersonCardComponent {
|
||||
return path;
|
||||
}
|
||||
|
||||
getDistinguishingId(person: CustomAuthor): string {
|
||||
if (!person) return '';
|
||||
if (person.orcid) {
|
||||
return person.orcid.replace('https://orcid.org/', '');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
getCareerStageTooltip(careerStage: string): string {
|
||||
const activeYears = this.person().career_metrics?.active_years ?? '-';
|
||||
|
||||
getStatsString(): string {
|
||||
const works = this.person.works_count;
|
||||
const citations = this.person.cited_by_count;
|
||||
const hasWorks = works !== undefined && works !== null;
|
||||
const hasCitations = citations !== undefined && citations !== null;
|
||||
|
||||
if (hasWorks && hasCitations) {
|
||||
return `Publikationen: ${works} · Zitationen: ${citations}`;
|
||||
} else if (hasWorks) {
|
||||
return `Publikationen: ${works}`;
|
||||
} else if (hasCitations) {
|
||||
return `Zitationen: ${citations}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
getHIndexString(): string {
|
||||
const hIndex = this.person.summary_stats?.h_index;
|
||||
if (hIndex !== undefined && hIndex !== null) {
|
||||
return `h_index: ${hIndex}`;
|
||||
}
|
||||
return '';
|
||||
return [
|
||||
`Aktuell: ${careerStage.replace(' Researcher', '')}`,
|
||||
`Aktive Publikationsjahre: ${activeYears}`,
|
||||
'',
|
||||
'Einteilung:',
|
||||
'Early: 1-4 aktive Publikationsjahre',
|
||||
'Emerging: 5-9 aktive Publikationsjahre',
|
||||
'Established: 10-14 aktive Publikationsjahre',
|
||||
'Senior: ab 15 aktiven Publikationsjahren',
|
||||
'',
|
||||
'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
toggleBookmark(): void {
|
||||
this.bookmarkToggle.emit(this.person);
|
||||
this.bookmarkToggle.emit(this.person());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ $text-muted: #64718f;
|
||||
right: 12px;
|
||||
z-index: 2;
|
||||
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
width: 51px;
|
||||
height: 51px;
|
||||
padding: 0;
|
||||
|
||||
background: transparent;
|
||||
|
||||
@@ -8,22 +8,78 @@
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
@if (visibleLegendGroups().length > 0) {
|
||||
<div class="interest-legend" aria-label="Aktuell sichtbare Themenbereiche">
|
||||
<mat-icon
|
||||
class="interest-legend-info"
|
||||
matTooltip="Fachgebiete geben die Farbfamilie vor, Themenbereiche bestimmen die konkrete Farbvariante."
|
||||
matTooltipPosition="above"
|
||||
aria-label="Informationen zur Farblegende">
|
||||
info_outline
|
||||
</mat-icon>
|
||||
|
||||
<div class="interest-legend-content">
|
||||
@for (group of visibleLegendGroups(); track group.id) {
|
||||
<span class="interest-legend-group">
|
||||
<span
|
||||
class="interest-legend-field"
|
||||
[matTooltip]="group.tooltip"
|
||||
[matTooltipDisabled]="!group.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above"
|
||||
>{{ group.name }}</span
|
||||
>
|
||||
<span class="interest-legend-items">
|
||||
@for (item of group.items; track item.id) {
|
||||
<span
|
||||
class="interest-legend-item"
|
||||
[matTooltip]="item.tooltip"
|
||||
[matTooltipDisabled]="!item.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above">
|
||||
<span
|
||||
class="interest-legend-dot"
|
||||
[style.background]="item.color"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ item.name }}</span>
|
||||
</span>
|
||||
}
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
|
||||
@if (hasHiddenLegendGroups()) {
|
||||
<button
|
||||
type="button"
|
||||
class="interest-legend-more"
|
||||
[attr.aria-expanded]="legendExpanded()"
|
||||
(click)="toggleLegend()">
|
||||
@if (legendExpanded()) {
|
||||
Weniger anzeigen
|
||||
} @else {
|
||||
+{{ hiddenLegendItemCount() }} weitere
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="interest-tags">
|
||||
@if (tags().length > 0) {
|
||||
@for (tag of tags(); track tag.label; let i = $index) {
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(i)"
|
||||
[matTooltip]="tag.description"
|
||||
@for (tag of tags(); track tag.label) {
|
||||
<app-topic-chip
|
||||
[label]="tag.label"
|
||||
[count]="tag.count"
|
||||
[description]="tag.description"
|
||||
[subfieldName]="tag.subfieldName"
|
||||
[fieldName]="tag.fieldName"
|
||||
[domainName]="tag.domainName"
|
||||
[color]="tag.color"
|
||||
[disabled]="!tag.id"
|
||||
(click)="onTagClick(tag)">
|
||||
<span class="topic-name">{{ tag.label }}</span>
|
||||
<span class="topic-count">
|
||||
{{ tag.count }}
|
||||
<mat-icon class="count-icon">article</mat-icon>
|
||||
</span>
|
||||
</button>
|
||||
countIcon="article"
|
||||
descriptionTooltipTarget="button"
|
||||
(chipClick)="onTagClick(tag)">
|
||||
</app-topic-chip>
|
||||
}
|
||||
} @else {
|
||||
<span class="interest-empty">Keine Themen gefunden</span>
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
margin: 0 0 18px;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.interest-card h3 {
|
||||
@@ -29,98 +30,6 @@
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.topic-chip {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
column-gap: 8px;
|
||||
box-sizing: border-box;
|
||||
min-height: 34px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--topic-border);
|
||||
border-radius: 8px;
|
||||
background: var(--topic-bg);
|
||||
color: var(--topic-color);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-name {
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.topic-count {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.topic-count .count-icon {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.purple {
|
||||
--topic-border: #d8cafe;
|
||||
--topic-bg: #f6f0ff;
|
||||
--topic-color: #7255d9;
|
||||
}
|
||||
|
||||
.blue {
|
||||
--topic-border: #bdd4ff;
|
||||
--topic-bg: #f0f6ff;
|
||||
--topic-color: #0b63ce;
|
||||
}
|
||||
|
||||
.green {
|
||||
--topic-border: #bdebcf;
|
||||
--topic-bg: #effaf3;
|
||||
--topic-color: #24834f;
|
||||
}
|
||||
|
||||
.orange {
|
||||
--topic-border: #ffd796;
|
||||
--topic-bg: #fff7e8;
|
||||
--topic-color: #c67500;
|
||||
}
|
||||
|
||||
.pink {
|
||||
--topic-border: #ffc7d7;
|
||||
--topic-bg: #fff1f5;
|
||||
--topic-color: #d12f61;
|
||||
}
|
||||
|
||||
.interest-footnote {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -136,6 +45,127 @@
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.interest-legend {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 9px;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
margin: 0 0 16px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.interest-legend-content,
|
||||
.interest-legend-group,
|
||||
.interest-legend-items,
|
||||
.interest-legend-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.interest-legend-info {
|
||||
flex: 0 0 auto;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
color: #7d8aa8;
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.interest-legend-content {
|
||||
gap: 7px;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.interest-legend-group {
|
||||
gap: 6px;
|
||||
flex: 0 1 auto;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
min-height: 24px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 999px;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.interest-legend-field {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
color: #07163d;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.interest-legend-items {
|
||||
flex: 0 1 auto;
|
||||
gap: 4px 7px;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.interest-legend-item {
|
||||
gap: 4px;
|
||||
flex: 0 0 auto;
|
||||
min-width: 0;
|
||||
color: #53617e;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
cursor: help;
|
||||
|
||||
span:last-child {
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
}
|
||||
}
|
||||
|
||||
.interest-legend-dot {
|
||||
flex: 0 0 auto;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.85);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
|
||||
}
|
||||
|
||||
.interest-legend-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
min-height: 24px;
|
||||
padding: 0 2px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--accent, #0057ff);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--accent, #0057ff);
|
||||
outline-offset: 2px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.interest-tags .interest-empty {
|
||||
padding: 9px 16px;
|
||||
border: 1px solid #e2e8f0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { PersonInterestingComponent } from './person-interesting.component';
|
||||
|
||||
@@ -9,6 +10,7 @@ describe('PersonInterestingComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [PersonInterestingComponent],
|
||||
providers: [provideRouter([])],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(PersonInterestingComponent);
|
||||
|
||||
@@ -1,28 +1,77 @@
|
||||
import { Component, input, computed, output } from '@angular/core';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
OnInit,
|
||||
computed,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { TopicCount } from '../../api';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
|
||||
|
||||
interface InterestTag {
|
||||
id: string;
|
||||
label: string;
|
||||
count: number;
|
||||
description: string;
|
||||
color: string;
|
||||
subfieldId: string;
|
||||
subfieldName: string;
|
||||
subfieldDescription: string;
|
||||
fieldId: string;
|
||||
fieldName: string;
|
||||
fieldDescription: string;
|
||||
domainId: string;
|
||||
domainName: string;
|
||||
domainDescription: string;
|
||||
}
|
||||
|
||||
interface InterestLegendGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
domainName: string;
|
||||
domainDescription: string;
|
||||
tooltip: string;
|
||||
items: InterestLegendItem[];
|
||||
}
|
||||
|
||||
interface InterestLegendItem {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
color: string;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
const MAX_TAGS = 5;
|
||||
const colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
const MAX_LEGEND_GROUPS = 3;
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-interesting',
|
||||
imports: [CommonModule, MatTooltipModule, MatIconModule],
|
||||
imports: [CommonModule, MatIconModule, MatTooltipModule, TopicChipComponent],
|
||||
templateUrl: './person-interesting.component.html',
|
||||
styleUrl: './person-interesting.component.scss',
|
||||
})
|
||||
export class PersonInterestingComponent {
|
||||
export class PersonInterestingComponent implements OnInit {
|
||||
private static readonly legendExpandedQueryParam =
|
||||
'interesting_legend_expanded';
|
||||
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly topics = input<TopicCount[] | null>(null);
|
||||
readonly legendExpanded = signal(false);
|
||||
|
||||
readonly tagClick = output<{ id: string; name: string }>();
|
||||
|
||||
@@ -39,18 +88,192 @@ export class PersonInterestingComponent {
|
||||
label,
|
||||
count: topic.count ?? 0,
|
||||
description: (topic.description ?? '').trim(),
|
||||
color: topicHierarchyColor(topic),
|
||||
subfieldId: topic.subfield_id ?? '',
|
||||
subfieldName: (topic.subfield_name ?? '').trim(),
|
||||
subfieldDescription: (topic.subfield_description ?? '').trim(),
|
||||
fieldId: topic.field_id ?? '',
|
||||
fieldName: (topic.field_name ?? '').trim(),
|
||||
fieldDescription: (topic.field_description ?? '').trim(),
|
||||
domainId: topic.domain_id ?? '',
|
||||
domainName: (topic.domain_name ?? '').trim(),
|
||||
domainDescription: (topic.domain_description ?? '').trim(),
|
||||
});
|
||||
}
|
||||
|
||||
return tags.sort((a, b) => b.count - a.count).slice(0, MAX_TAGS);
|
||||
});
|
||||
|
||||
getColorClass(index: number): string {
|
||||
return colors[index % colors.length];
|
||||
readonly legendGroups = computed<InterestLegendGroup[]>(() => {
|
||||
const groups = new Map<string, InterestLegendGroup>();
|
||||
|
||||
for (const tag of this.tags()) {
|
||||
if (!tag.subfieldName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fieldName = tag.fieldName || 'Ohne Field';
|
||||
const fieldId = tag.fieldId || fieldName.toLowerCase();
|
||||
const subfieldId = tag.subfieldId || tag.subfieldName.toLowerCase();
|
||||
|
||||
if (!groups.has(fieldId)) {
|
||||
groups.set(fieldId, {
|
||||
id: fieldId,
|
||||
name: fieldName,
|
||||
description: tag.fieldDescription,
|
||||
domainName: tag.domainName,
|
||||
domainDescription: tag.domainDescription,
|
||||
tooltip: this.buildLegendTooltip([
|
||||
{
|
||||
label: 'Fachgebiet',
|
||||
value: fieldName,
|
||||
description: tag.fieldDescription,
|
||||
},
|
||||
{
|
||||
label: 'Wissenschaftsbereich',
|
||||
value: tag.domainName,
|
||||
description: tag.domainDescription,
|
||||
},
|
||||
]),
|
||||
items: [],
|
||||
});
|
||||
}
|
||||
|
||||
const group = groups.get(fieldId);
|
||||
|
||||
if (!group || group.items.some((item) => item.id === subfieldId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.items.push({
|
||||
id: subfieldId,
|
||||
name: tag.subfieldName,
|
||||
description: tag.subfieldDescription,
|
||||
color: tag.color,
|
||||
tooltip: this.buildLegendTooltip([
|
||||
{
|
||||
label: 'Themenbereich',
|
||||
value: tag.subfieldName,
|
||||
description: tag.subfieldDescription,
|
||||
},
|
||||
{
|
||||
label: 'Fachgebiet',
|
||||
value: fieldName,
|
||||
description: tag.fieldDescription,
|
||||
},
|
||||
{
|
||||
label: 'Wissenschaftsbereich',
|
||||
value: tag.domainName,
|
||||
description: tag.domainDescription,
|
||||
},
|
||||
]),
|
||||
});
|
||||
}
|
||||
|
||||
return [...groups.values()]
|
||||
.map((group) => ({
|
||||
...group,
|
||||
items: group.items.sort((left, right) =>
|
||||
left.name.localeCompare(right.name),
|
||||
),
|
||||
}))
|
||||
.sort((left, right) => left.name.localeCompare(right.name));
|
||||
});
|
||||
|
||||
readonly visibleLegendGroups = computed<InterestLegendGroup[]>(() => {
|
||||
const groups = this.legendGroups();
|
||||
return this.legendExpanded() ? groups : groups.slice(0, MAX_LEGEND_GROUPS);
|
||||
});
|
||||
|
||||
readonly hasHiddenLegendGroups = computed<boolean>(
|
||||
() => this.legendGroups().length > MAX_LEGEND_GROUPS,
|
||||
);
|
||||
|
||||
readonly hiddenLegendItemCount = computed<number>(() =>
|
||||
this.legendGroups()
|
||||
.slice(MAX_LEGEND_GROUPS)
|
||||
.reduce((count, group) => count + group.items.length, 0),
|
||||
);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParamMap
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((queryParams) => {
|
||||
this.legendExpanded.set(
|
||||
this.parseBooleanQueryParam(
|
||||
queryParams.get(
|
||||
PersonInterestingComponent.legendExpandedQueryParam,
|
||||
),
|
||||
false,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onTagClick(tag: InterestTag): void {
|
||||
if (!tag.id) return;
|
||||
this.tagClick.emit({ id: tag.id, name: tag.label });
|
||||
}
|
||||
|
||||
toggleLegend(): void {
|
||||
const expanded = !this.legendExpanded();
|
||||
this.legendExpanded.set(expanded);
|
||||
|
||||
void this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
[PersonInterestingComponent.legendExpandedQueryParam]: expanded
|
||||
? 'true'
|
||||
: null,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
});
|
||||
}
|
||||
|
||||
private parseBooleanQueryParam(
|
||||
value: string | null,
|
||||
fallback: boolean,
|
||||
): boolean {
|
||||
if (value === null) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
if (value === 'true' || value === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value === 'false' || value === '0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private buildLegendTooltip(
|
||||
entries: Array<{ label: string; value: string; description: string }>,
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const entry of entries) {
|
||||
if (!entry.value && !entry.description) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lines.length > 0) {
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (entry.value) {
|
||||
lines.push(`${entry.label}: ${entry.value}`);
|
||||
}
|
||||
|
||||
if (entry.description) {
|
||||
lines.push('');
|
||||
lines.push(`Beschreibung: ${entry.description}`);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
<button
|
||||
mat-icon-button
|
||||
(click)="clearSearch()"
|
||||
matTooltip="Suche zurücksetzen">
|
||||
matTooltip="Suche zurücksetzen"
|
||||
aria-label="Suche zurücksetzen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
@@ -42,7 +43,10 @@
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
<button class="clear-all-btn" (click)="clearAllFilters()">
|
||||
<button
|
||||
class="clear-all-btn"
|
||||
(click)="clearAllFilters()"
|
||||
aria-label="Alle Filter zurücksetzen">
|
||||
Filter zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
@@ -56,14 +60,18 @@
|
||||
<div class="sort-selector">
|
||||
<span class="sort-label">Sortierung:</span>
|
||||
<div class="select-wrapper">
|
||||
<select [formControl]="sortValueControl">
|
||||
<select
|
||||
[formControl]="sortValueControl"
|
||||
aria-label="Sortierkriterium">
|
||||
<option [ngValue]="null">Beste Treffer (Relevanz)</option>
|
||||
<option value="works_count">Publikationen</option>
|
||||
<option value="cited_by_count">Zitierungen</option>
|
||||
<option value="summary_stats.h_index">h_index</option>
|
||||
</select>
|
||||
|
||||
<select [formControl]="sortOrderControl">
|
||||
<select
|
||||
[formControl]="sortOrderControl"
|
||||
aria-label="Sortierreihenfolge">
|
||||
<option value="desc">Absteigend</option>
|
||||
<option value="asc">Aufsteigend</option>
|
||||
</select>
|
||||
@@ -87,6 +95,7 @@
|
||||
[loading]="loading"
|
||||
[person]="person"
|
||||
[isBookmarked]="isBookmarked(person)"
|
||||
[selectedTopics]="selectedTopics()"
|
||||
(bookmarkToggle)="toggleBookmark($event)"
|
||||
(topicClick)="onCardTopicClick($event)"
|
||||
(institutionClick)="onCardInstitutionClick($event)">
|
||||
@@ -132,19 +141,23 @@
|
||||
<input
|
||||
type="text"
|
||||
[formControl]="topicSearchControl"
|
||||
aria-label="Thema suchen"
|
||||
placeholder="Thema suchen..." />
|
||||
@if (topicSearchControl.value) {
|
||||
<button
|
||||
class="clear-topic-search"
|
||||
(click)="topicSearchControl.setValue('')">
|
||||
(click)="topicSearchControl.setValue('')"
|
||||
aria-label="Themensuche zurücksetzen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-topic-hierarchy
|
||||
[selectedTopics]="selectedTopics"
|
||||
[selectedTopics]="selectedTopics()"
|
||||
[searchQuery]="topicSearchControl.value"
|
||||
[searchType]="topicSearchType()"
|
||||
(searchTypeChange)="onTopicSearchTypeChange($event)"
|
||||
(selectionChange)="onTopicSelectionChange($event)">
|
||||
</app-topic-hierarchy>
|
||||
</div>
|
||||
@@ -158,6 +171,7 @@
|
||||
type="text"
|
||||
[formControl]="institutionControl"
|
||||
[matAutocomplete]="auto"
|
||||
aria-label="Institution suchen"
|
||||
placeholder="Institution suchen..."
|
||||
(keyup.enter)="applySidebarFilters()" />
|
||||
<mat-autocomplete
|
||||
@@ -183,7 +197,8 @@
|
||||
@if (institutionControl.value) {
|
||||
<button
|
||||
class="clear-topic-search"
|
||||
(click)="clearInstitutionFilter()">
|
||||
(click)="clearInstitutionFilter()"
|
||||
aria-label="Institution zurücksetzen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
}
|
||||
@@ -198,7 +213,8 @@
|
||||
">
|
||||
<mat-checkbox
|
||||
[formControl]="yearFilterEnabledControl"
|
||||
(change)="applySidebarFilters()">
|
||||
(change)="applySidebarFilters()"
|
||||
aria-label="Zusammenarbeit nach Jahr filtern">
|
||||
<span
|
||||
style="font-size: 12px; font-weight: 500; color: var(--sg-text)"
|
||||
>Zusammenarbeit nach Jahr filtern</span
|
||||
@@ -217,7 +233,8 @@
|
||||
<mat-radio-group
|
||||
[formControl]="filterModeControl"
|
||||
(change)="applySidebarFilters()"
|
||||
style="display: flex; gap: 16px">
|
||||
style="display: flex; gap: 16px"
|
||||
aria-label="Modus für Jahresfilter">
|
||||
<mat-radio-button value="in"
|
||||
><span style="font-size: 12px; color: var(--sg-text)"
|
||||
>Genau in</span
|
||||
@@ -240,6 +257,7 @@
|
||||
[formControl]="filterYearControl"
|
||||
(change)="applySidebarFilters()"
|
||||
(keyup.enter)="applySidebarFilters()"
|
||||
aria-label="Jahr"
|
||||
placeholder="Z. B. 2025" />
|
||||
@if (filterYearControl.hasError('min')) {
|
||||
<mat-error>Jahr muss ≥ 1900 sein</mat-error>
|
||||
@@ -255,7 +273,10 @@
|
||||
|
||||
<!-- Sidebar Footer Action showing matches count -->
|
||||
<div class="sidebar-footer">
|
||||
<button class="submit-btn" (click)="applySidebarFilters()">
|
||||
<button
|
||||
class="submit-btn"
|
||||
(click)="applySidebarFilters()"
|
||||
aria-label="Gefundene Personen anzeigen">
|
||||
<span [skText]="loading"
|
||||
>{{ total | number: '1.0-0' }} Personen anzeigen</span
|
||||
>
|
||||
|
||||
@@ -13,18 +13,64 @@
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.results-column {
|
||||
// Shared flex layouts
|
||||
.page-header,
|
||||
.sidebar-header,
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.page-header,
|
||||
.toolbar {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.sidebar-header,
|
||||
.toolbar {
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.selection-summary,
|
||||
.active-filters-row,
|
||||
.chips-container,
|
||||
.sort-selector,
|
||||
.topic-search-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
// Shared column & sidebar column layouts
|
||||
.results-column,
|
||||
.empty-state,
|
||||
.filters-sidebar,
|
||||
.filter-section {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
// Shared containers styling
|
||||
.selection-summary,
|
||||
.active-filters-row,
|
||||
.filters-sidebar {
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
// Individual styles
|
||||
.results-column {
|
||||
gap: 20px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
|
||||
h1 {
|
||||
@@ -42,13 +88,8 @@
|
||||
}
|
||||
|
||||
.selection-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 8px 12px;
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
|
||||
strong {
|
||||
display: block;
|
||||
@@ -65,13 +106,8 @@
|
||||
}
|
||||
|
||||
.active-filters-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
background: var(--sg-surface);
|
||||
padding: 8px 16px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
flex-wrap: wrap;
|
||||
font-size: 13px;
|
||||
}
|
||||
@@ -82,15 +118,11 @@
|
||||
}
|
||||
|
||||
.chips-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filter-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
background: var(--sg-surface-soft);
|
||||
@@ -99,53 +131,53 @@
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text);
|
||||
|
||||
button {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
color: var(--sg-text-soft);
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 12px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shared button resets
|
||||
.filter-chip button,
|
||||
.clear-topic-search,
|
||||
.clear-all-btn {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.filter-chip button,
|
||||
.clear-topic-search {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
color: var(--sg-text-soft);
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
}
|
||||
|
||||
.filter-chip button mat-icon {
|
||||
font-size: 12px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.clear-topic-search mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.clear-all-btn {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-warning);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.result-count {
|
||||
font-size: 13px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.sort-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
color: var(--sg-text-muted);
|
||||
@@ -159,6 +191,14 @@
|
||||
color: var(--sg-text);
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow: 0 0 0 2px var(--sg-primary-soft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +209,6 @@
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 48px 16px;
|
||||
background: var(--sg-surface);
|
||||
@@ -204,24 +242,14 @@ mat-paginator {
|
||||
}
|
||||
|
||||
.filters-sidebar {
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
padding: 16px;
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
position: sticky;
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
|
||||
mat-icon {
|
||||
color: var(--sg-primary);
|
||||
@@ -238,8 +266,6 @@ mat-paginator {
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@@ -252,13 +278,18 @@ mat-paginator {
|
||||
}
|
||||
|
||||
.topic-search-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--sg-surface-soft);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
padding: 4px 8px;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
|
||||
&:focus-within {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow: 0 0 0 2px var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
@@ -276,20 +307,6 @@ mat-paginator {
|
||||
flex-grow: 1;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.clear-topic-search {
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
color: var(--sg-text-soft);
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
@@ -307,12 +324,21 @@ mat-paginator {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
transition:
|
||||
background 0.15s,
|
||||
box-shadow 0.15s;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--sg-primary-strong);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 0 2px var(--sg-background),
|
||||
0 0 0 4px var(--sg-primary);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
|
||||
@@ -78,8 +78,9 @@ export class PersonListComponent {
|
||||
defaultOrderValue = 'desc';
|
||||
|
||||
// Selected filter states
|
||||
selectedTopics = new Set<string>();
|
||||
searchValue = signal<string | null>(null);
|
||||
readonly selectedTopics = signal<Set<string>>(new Set<string>());
|
||||
readonly searchValue = signal<string | null>(null);
|
||||
readonly topicSearchType = signal<'hybrid' | 'semantic'>('hybrid');
|
||||
|
||||
// Applied filter states (reflecting actual URL query params)
|
||||
appliedInstitutionName = '';
|
||||
@@ -144,11 +145,14 @@ export class PersonListComponent {
|
||||
const filterYear = params['filterYear']
|
||||
? Number.parseInt(params['filterYear'], 10)
|
||||
: new Date().getFullYear() - 1;
|
||||
const topicSearch = params['topicSearch'] || '';
|
||||
const topicSearchType =
|
||||
params['topicSearchType'] === 'semantic' ? 'semantic' : 'hybrid';
|
||||
|
||||
const topics = this.parseQueryParamArray(params['topic']);
|
||||
|
||||
// restore values from query params
|
||||
this.selectedTopics = new Set(topics);
|
||||
this.selectedTopics.set(new Set(topics));
|
||||
this.currentPage = page;
|
||||
this.paginationService.selection = pageSize;
|
||||
|
||||
@@ -177,6 +181,10 @@ export class PersonListComponent {
|
||||
if (this.filterYearControl.value !== filterYear) {
|
||||
this.filterYearControl.setValue(filterYear);
|
||||
}
|
||||
if (this.topicSearchControl.value !== topicSearch) {
|
||||
this.topicSearchControl.setValue(topicSearch, { emitEvent: false });
|
||||
}
|
||||
this.topicSearchType.set(topicSearchType);
|
||||
|
||||
// Update applied filter states
|
||||
this.appliedInstitutionName = institutionName;
|
||||
@@ -214,6 +222,22 @@ export class PersonListComponent {
|
||||
.subscribe(() => {
|
||||
this.applySidebarFilters();
|
||||
});
|
||||
|
||||
this.topicSearchControl.valueChanges
|
||||
.pipe(
|
||||
debounceTime(300),
|
||||
distinctUntilChanged(),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((val) => {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
topicSearch: val || null,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private updateSortOrderState(value: any) {
|
||||
@@ -237,7 +261,7 @@ export class PersonListComponent {
|
||||
|
||||
// Filter selection checks
|
||||
isTopicSelected(topic: string): boolean {
|
||||
return this.selectedTopics.has(topic);
|
||||
return this.selectedTopics().has(topic);
|
||||
}
|
||||
|
||||
isRelevanceSelected(): boolean {
|
||||
@@ -245,11 +269,15 @@ export class PersonListComponent {
|
||||
}
|
||||
|
||||
toggleTopic(topic: string): void {
|
||||
if (this.selectedTopics.has(topic)) {
|
||||
this.selectedTopics.delete(topic);
|
||||
} else {
|
||||
this.selectedTopics.add(topic);
|
||||
}
|
||||
this.selectedTopics.update((set) => {
|
||||
const next = new Set(set);
|
||||
if (next.has(topic)) {
|
||||
next.delete(topic);
|
||||
} else {
|
||||
next.add(topic);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
@@ -260,7 +288,7 @@ export class PersonListComponent {
|
||||
label: string;
|
||||
}> {
|
||||
const list: Array<{ category: string; value: string; label: string }> = [];
|
||||
this.selectedTopics.forEach((t) => {
|
||||
this.selectedTopics().forEach((t) => {
|
||||
list.push({ category: 'topic', value: t, label: `Thema: ${t}` });
|
||||
});
|
||||
if (this.appliedInstitutionName) {
|
||||
@@ -280,7 +308,11 @@ export class PersonListComponent {
|
||||
|
||||
removeFilter(filter: { category: string; value: string }): void {
|
||||
if (filter.category === 'topic') {
|
||||
this.selectedTopics.delete(filter.value);
|
||||
this.selectedTopics.update((set) => {
|
||||
const next = new Set(set);
|
||||
next.delete(filter.value);
|
||||
return next;
|
||||
});
|
||||
} else if (filter.category === 'institutionName') {
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
this.updateYearFilterState('');
|
||||
@@ -293,7 +325,7 @@ export class PersonListComponent {
|
||||
}
|
||||
|
||||
clearAllFilters(): void {
|
||||
this.selectedTopics.clear();
|
||||
this.selectedTopics.set(new Set<string>());
|
||||
this.institutionControl.setValue('', { emitEvent: false });
|
||||
this.updateYearFilterState('');
|
||||
this.institutionOptions.set([]);
|
||||
@@ -309,9 +341,12 @@ export class PersonListComponent {
|
||||
}
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
topic: this.selectedTopics.size
|
||||
? Array.from(this.selectedTopics)
|
||||
topic: this.selectedTopics().size
|
||||
? Array.from(this.selectedTopics())
|
||||
: null,
|
||||
topicSearch: this.topicSearchControl.value || null,
|
||||
topicSearchType:
|
||||
this.topicSearchType() === 'semantic' ? 'semantic' : null,
|
||||
institutionName: this.institutionControl.value || null,
|
||||
sortBy: this.sortValueControl.value || null,
|
||||
sortOrder: this.sortOrderControl.value || null,
|
||||
@@ -363,12 +398,17 @@ export class PersonListComponent {
|
||||
}
|
||||
|
||||
onTopicSelectionChange(newSelection: Set<string>): void {
|
||||
this.selectedTopics = newSelection;
|
||||
this.selectedTopics.set(newSelection);
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
onTopicSearchTypeChange(type: 'hybrid' | 'semantic'): void {
|
||||
this.topicSearchType.set(type);
|
||||
this.applySidebarFilters();
|
||||
}
|
||||
|
||||
onCardTopicClick(topic: string): void {
|
||||
this.topicSearchControl.setValue(topic);
|
||||
this.toggleTopic(topic);
|
||||
}
|
||||
|
||||
onCardInstitutionClick(institutionName: string): void {
|
||||
|
||||
@@ -299,7 +299,7 @@ export class PersonNetworkComponent implements OnInit {
|
||||
console.log('Form value when opening dialog:', this.filterForm.value);
|
||||
const dialogRef = this.dialog.open(PersonNetworkFilterDialogComponent, {
|
||||
data: {
|
||||
collaborationNetwork: this.collaborationNetwork,
|
||||
collaborationNetwork: this.collaborationNetwork(),
|
||||
filterBy: this.filterForm.get('filterBy')?.value || 'works',
|
||||
startYear: this.filterForm.get('startYear')?.value,
|
||||
|
||||
@@ -407,22 +407,34 @@ export class PersonNetworkComponent implements OnInit {
|
||||
];
|
||||
|
||||
this.filterForm.valueChanges.pipe(debounceTime(300)).subscribe((value) => {
|
||||
console.log('Form value changed:', value);
|
||||
const queryParams = {
|
||||
table: value.displayedTable ?? 'collaborators',
|
||||
search_term: value.searchTerm ?? '',
|
||||
filter_by: value.filterBy ?? 'works',
|
||||
start_year: value.startYear ?? '',
|
||||
end_year: value.endYear ?? '',
|
||||
min_contributors: value.minContributors ?? 2,
|
||||
max_contributors: value.maxContributors ?? 10,
|
||||
min_collaborations: value.minCollaborations ?? 1,
|
||||
max_collaborations: value.maxCollaborations ?? 100,
|
||||
institutions: value.institutions?.join(',') ?? '',
|
||||
topics: value.topics?.join(',') ?? '',
|
||||
};
|
||||
|
||||
const currentQueryParams = this.activatedRoute.snapshot.queryParams;
|
||||
|
||||
const hasChanged = Object.entries(queryParams).some(([key, value]) => {
|
||||
return String(currentQueryParams[key] ?? '') !== String(value ?? '');
|
||||
});
|
||||
|
||||
if (!hasChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.activatedRoute,
|
||||
queryParams: {
|
||||
table: value.displayedTable,
|
||||
search_term: value.searchTerm,
|
||||
filter_by: value.filterBy,
|
||||
start_year: value.startYear,
|
||||
end_year: value.endYear,
|
||||
min_contributors: value.minContributors,
|
||||
max_contributors: value.maxContributors,
|
||||
min_collaborations: value.minCollaborations,
|
||||
max_collaborations: value.maxCollaborations,
|
||||
institutions: value.institutions?.join(','),
|
||||
topics: value.topics?.join(','),
|
||||
},
|
||||
queryParams,
|
||||
replaceUrl: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+144
-80
@@ -7,22 +7,87 @@
|
||||
<span>(basierend auf Publikationen)</span>
|
||||
</p>
|
||||
|
||||
<button
|
||||
*ngIf="
|
||||
showEarlierYearsControl &&
|
||||
timelineViewMode === 'compact' &&
|
||||
!loading &&
|
||||
!loadFailed
|
||||
"
|
||||
type="button"
|
||||
class="load-more-action-button"
|
||||
[disabled]="loadingEarlierYears"
|
||||
(click)="requestEarlierYears()">
|
||||
<span class="load-more-content">
|
||||
<mat-spinner *ngIf="loadingEarlierYears" diameter="16"></mat-spinner>
|
||||
<span>{{ earlierYearsLabel }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<div
|
||||
*ngIf="subfieldLegendGroups.length > 0"
|
||||
class="subfield-legend"
|
||||
[class.expanded]="subfieldLegendExpanded"
|
||||
aria-label="Aktuell sichtbare Themenbereiche">
|
||||
<div class="subfield-legend-header">
|
||||
<div class="subfield-legend-title">
|
||||
<span>Farben nach Themenbereich</span>
|
||||
<mat-icon
|
||||
class="subfield-legend-info"
|
||||
matTooltip="Fachgebiete geben die Farbfamilie vor, Themenbereiche bestimmen die konkrete Farbvariante."
|
||||
matTooltipPosition="above"
|
||||
aria-label="Informationen zur Farblegende">
|
||||
info_outline
|
||||
</mat-icon>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="subfield-legend-visibility-toggle"
|
||||
[attr.aria-expanded]="subfieldLegendVisible"
|
||||
(click)="toggleSubfieldLegendVisibility()">
|
||||
<span>
|
||||
{{
|
||||
subfieldLegendVisible
|
||||
? 'Legende ausblenden'
|
||||
: 'Legende einblenden'
|
||||
}}
|
||||
</span>
|
||||
<mat-icon aria-hidden="true">
|
||||
{{ subfieldLegendVisible ? 'expand_less' : 'expand_more' }}
|
||||
</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div *ngIf="subfieldLegendVisible" class="subfield-legend-content">
|
||||
<div
|
||||
*ngFor="
|
||||
let group of subfieldLegendGroups;
|
||||
trackBy: trackByLegendGroup
|
||||
"
|
||||
class="subfield-legend-group">
|
||||
<span
|
||||
class="subfield-legend-field"
|
||||
[matTooltip]="group.tooltip"
|
||||
[matTooltipDisabled]="!group.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above"
|
||||
>{{ group.name }}</span
|
||||
>
|
||||
|
||||
<span class="subfield-legend-items">
|
||||
<span
|
||||
*ngFor="let item of group.items; trackBy: trackByLegendItem"
|
||||
class="subfield-legend-item"
|
||||
[matTooltip]="item.tooltip"
|
||||
[matTooltipDisabled]="!item.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
matTooltipPosition="above">
|
||||
<span
|
||||
class="subfield-legend-dot"
|
||||
[style.background]="item.color"
|
||||
aria-hidden="true"></span>
|
||||
<span>{{ item.name }}</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
*ngIf="showSubfieldLegendToggle"
|
||||
type="button"
|
||||
class="subfield-legend-more-toggle"
|
||||
(click)="toggleSubfieldLegend()">
|
||||
{{
|
||||
subfieldLegendExpanded
|
||||
? 'Weniger anzeigen'
|
||||
: '+' + hiddenSubfieldLegendItemCount + ' weitere'
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span
|
||||
*ngIf="
|
||||
@@ -157,13 +222,11 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
*ngFor="
|
||||
let item of timelineItems;
|
||||
let index = index;
|
||||
trackBy: trackByYear
|
||||
"
|
||||
*ngFor="let item of timelineItems; trackBy: trackByYear"
|
||||
class="timeline-point"
|
||||
[ngClass]="getColorClass(index)">
|
||||
[style.--timeline-color]="
|
||||
getTopicColor(getMainTopicItem(item))
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
class="year-button"
|
||||
@@ -218,9 +281,10 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!getMainTopicItem(item)?.id"
|
||||
[matTooltip]="getTopicDescription(getMainTopicItem(item))"
|
||||
[matTooltip]="getTopicTooltip(getMainTopicItem(item))"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="
|
||||
!hasTopicDescription(getMainTopicItem(item))
|
||||
!hasTopicTooltip(getMainTopicItem(item))
|
||||
"
|
||||
(click)="
|
||||
selectTopic(getMainTopicItem(item), [item.year])
|
||||
@@ -248,28 +312,23 @@
|
||||
getDisplayedTopics(item).length > 0;
|
||||
else noTopicsForYear
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="
|
||||
let topic of getDisplayedTopics(item);
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
class="timeline-topic-chip"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[subfieldName]="topic.subfield_name"
|
||||
[fieldName]="topic.field_name"
|
||||
[domainName]="topic.domain_name"
|
||||
[countTooltip]="getYearTopicCountTooltip(topic, item)"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, [item.year])">
|
||||
<span
|
||||
class="topic-name"
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<span
|
||||
class="topic-count"
|
||||
[matTooltip]="getYearTopicCountTooltip(topic, item)">
|
||||
{{ topic.count }}
|
||||
</span>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, [item.year])">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noTopicsForYear>
|
||||
@@ -283,15 +342,26 @@
|
||||
</ng-container>
|
||||
|
||||
<ng-template #compactTimeline>
|
||||
<div *ngIf="showEarlierYearsControl" class="compact-load-more-row">
|
||||
<button
|
||||
type="button"
|
||||
class="load-more-action-button"
|
||||
[disabled]="loadingEarlierYears"
|
||||
(click)="requestEarlierYears()">
|
||||
<span class="load-more-content">
|
||||
<mat-spinner
|
||||
*ngIf="loadingEarlierYears"
|
||||
diameter="16"></mat-spinner>
|
||||
<span>{{ earlierYearsLabel }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="compact-phase-list">
|
||||
<article
|
||||
*ngFor="
|
||||
let phase of compactPhases;
|
||||
let index = index;
|
||||
trackBy: trackByPhase
|
||||
"
|
||||
*ngFor="let phase of compactPhases; trackBy: trackByPhase"
|
||||
class="phase-card"
|
||||
[ngClass]="getColorClass(index)">
|
||||
[style.--timeline-color]="getTopicColor(phase.primaryTopic)">
|
||||
<div class="phase-card-header">
|
||||
<span class="phase-marker"></span>
|
||||
|
||||
@@ -328,9 +398,10 @@
|
||||
type="button"
|
||||
class="main-topic-button"
|
||||
[disabled]="!phase.primaryTopic.id"
|
||||
[matTooltip]="getTopicDescription(phase.primaryTopic)"
|
||||
[matTooltip]="getTopicTooltip(phase.primaryTopic)"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="
|
||||
!hasTopicDescription(phase.primaryTopic)
|
||||
!hasTopicTooltip(phase.primaryTopic)
|
||||
"
|
||||
(click)="
|
||||
selectTopic(phase.primaryTopic, getPhaseYears(phase))
|
||||
@@ -344,25 +415,20 @@
|
||||
<div class="phase-topics">
|
||||
<ng-container
|
||||
*ngIf="phase.topics.length > 0; else noPhaseTopics">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="let topic of phase.topics; trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
class="phase-topic-chip"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[subfieldName]="topic.subfield_name"
|
||||
[fieldName]="topic.field_name"
|
||||
[domainName]="topic.domain_name"
|
||||
[countTooltip]="getPhaseTopicCountTooltip(topic, phase)"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, getPhaseYears(phase))">
|
||||
<span
|
||||
class="topic-name"
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<span
|
||||
class="topic-count"
|
||||
[matTooltip]="getPhaseTopicCountTooltip(topic, phase)">
|
||||
{{ topic.count }}
|
||||
</span>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, getPhaseYears(phase))">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseTopics>
|
||||
@@ -420,8 +486,7 @@
|
||||
).length > 0;
|
||||
else noPhaseYearTopics
|
||||
">
|
||||
<button
|
||||
type="button"
|
||||
<app-topic-chip
|
||||
*ngFor="
|
||||
let topic of getDisplayedTopicsForPrimaryTopic(
|
||||
year,
|
||||
@@ -429,19 +494,18 @@
|
||||
);
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="mini-topic-chip"
|
||||
size="mini"
|
||||
[label]="topic.name"
|
||||
[count]="topic.count"
|
||||
[description]="getTopicDescription(topic)"
|
||||
[subfieldName]="topic.subfield_name"
|
||||
[fieldName]="topic.field_name"
|
||||
[domainName]="topic.domain_name"
|
||||
[countTooltip]="getYearTopicCountTooltip(topic, year)"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="!topic.id"
|
||||
(click)="selectTopic(topic, [year.year])">
|
||||
<span
|
||||
[matTooltip]="getTopicDescription(topic)"
|
||||
[matTooltipDisabled]="!hasTopicDescription(topic)">
|
||||
{{ topic.name }}
|
||||
</span>
|
||||
<strong
|
||||
[matTooltip]="getYearTopicCountTooltip(topic, year)">
|
||||
{{ topic.count }}
|
||||
</strong>
|
||||
</button>
|
||||
(chipClick)="selectTopic(topic, [year.year])">
|
||||
</app-topic-chip>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseYearTopics>
|
||||
|
||||
+141
-134
@@ -11,9 +11,6 @@
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
button:not(:where(.topic-chip, .mini-topic-chip)) {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
@@ -67,6 +64,131 @@
|
||||
}
|
||||
}
|
||||
|
||||
.subfield-legend {
|
||||
width: min(760px, 100%);
|
||||
box-sizing: border-box;
|
||||
margin-top: 16px;
|
||||
padding: 13px 16px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.subfield-legend-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.subfield-legend-title,
|
||||
.subfield-legend-visibility-toggle,
|
||||
.subfield-legend-content,
|
||||
.subfield-legend-group,
|
||||
.subfield-legend-items,
|
||||
.subfield-legend-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.subfield-legend-title {
|
||||
gap: 5px;
|
||||
color: #07163d;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.subfield-legend-info {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
color: #7d8aa8;
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.subfield-legend-visibility-toggle {
|
||||
flex: 0 0 auto;
|
||||
gap: 4px;
|
||||
color: var(--accent);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
|
||||
mat-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.subfield-legend-content {
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 17px;
|
||||
}
|
||||
|
||||
.subfield-legend-group {
|
||||
gap: 9px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 28px;
|
||||
padding: 5px 9px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 999px;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.subfield-legend-field {
|
||||
flex: 0 0 auto;
|
||||
color: #07163d;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.subfield-legend-items {
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 11px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.subfield-legend-item {
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
color: #53617e;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.subfield-legend-dot {
|
||||
flex: 0 0 auto;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.85);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
|
||||
}
|
||||
|
||||
.subfield-legend-more-toggle {
|
||||
flex: 0 0 auto;
|
||||
color: var(--accent);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.view-toggle {
|
||||
justify-self: center;
|
||||
display: flex;
|
||||
@@ -291,12 +413,12 @@
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 3px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
background: var(--timeline-color);
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.16);
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.24);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,60 +488,9 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.topic-chip {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
column-gap: 8px;
|
||||
app-topic-chip.timeline-topic-chip {
|
||||
width: 100%;
|
||||
max-width: 210px;
|
||||
box-sizing: border-box;
|
||||
min-height: 34px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid var(--topic-border);
|
||||
border-radius: 8px;
|
||||
background: var(--topic-bg);
|
||||
color: var(--topic-color);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-name,
|
||||
.mini-topic-chip span {
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.topic-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.no-topics {
|
||||
@@ -427,6 +498,11 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.compact-load-more-row {
|
||||
display: flex;
|
||||
margin: 6px 0 28px;
|
||||
}
|
||||
|
||||
.compact-phase-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -453,13 +529,13 @@
|
||||
}
|
||||
|
||||
.phase-marker {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
margin-top: 5px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-top: 3px;
|
||||
border: 3px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
background: var(--timeline-color);
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.22);
|
||||
}
|
||||
|
||||
.phase-title-block {
|
||||
@@ -505,7 +581,7 @@
|
||||
gap: 7px;
|
||||
margin-top: 14px;
|
||||
|
||||
.topic-chip {
|
||||
app-topic-chip.phase-topic-chip {
|
||||
flex: 0 0 calc((100% - 7px) / 2);
|
||||
width: calc((100% - 7px) / 2);
|
||||
max-width: none;
|
||||
@@ -574,75 +650,6 @@
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mini-topic-chip {
|
||||
display: inline-grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
column-gap: 5px;
|
||||
max-width: 100%;
|
||||
padding: 4px 7px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: #f2f6ff;
|
||||
color: #40506f;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.25;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
strong {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
color: var(--accent);
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.purple {
|
||||
--timeline-color: #7255d9;
|
||||
--topic-border: #d8cafe;
|
||||
--topic-bg: #f6f0ff;
|
||||
--topic-color: #7255d9;
|
||||
}
|
||||
|
||||
.blue {
|
||||
--timeline-color: #2678e8;
|
||||
--topic-border: #bdd4ff;
|
||||
--topic-bg: #f0f6ff;
|
||||
--topic-color: #0b63ce;
|
||||
}
|
||||
|
||||
.green {
|
||||
--timeline-color: #39a96b;
|
||||
--topic-border: #bdebcf;
|
||||
--topic-bg: #effaf3;
|
||||
--topic-color: #24834f;
|
||||
}
|
||||
|
||||
.orange {
|
||||
--timeline-color: #f59e0b;
|
||||
--topic-border: #ffd796;
|
||||
--topic-bg: #fff7e8;
|
||||
--topic-color: #c67500;
|
||||
}
|
||||
|
||||
.pink {
|
||||
--timeline-color: #e0527c;
|
||||
--topic-border: #ffc7d7;
|
||||
--topic-bg: #fff1f5;
|
||||
--topic-color: #d12f61;
|
||||
}
|
||||
|
||||
.timeline-note {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -655,8 +662,8 @@
|
||||
}
|
||||
|
||||
.note-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border: 3px solid #dce5f5;
|
||||
border-radius: 50%;
|
||||
background: #52627f;
|
||||
|
||||
+347
-6
@@ -1,4 +1,5 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import {
|
||||
@@ -12,12 +13,24 @@ import {
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { TopicChipComponent } from '../../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { topicHierarchyColor } from '../../../../shared/utils/topic-colors';
|
||||
import { buildTopicHierarchyTooltip } from '../../../../shared/utils/topic-tooltip';
|
||||
|
||||
export interface TopicTimelineTopic {
|
||||
id?: string;
|
||||
name: string;
|
||||
count: number;
|
||||
description?: string;
|
||||
subfield_id?: string;
|
||||
subfield_name?: string;
|
||||
subfield_description?: string;
|
||||
field_id?: string;
|
||||
field_name?: string;
|
||||
field_description?: string;
|
||||
domain_id?: string;
|
||||
domain_name?: string;
|
||||
domain_description?: string;
|
||||
}
|
||||
|
||||
export interface TopicTimelineElement {
|
||||
@@ -65,10 +78,34 @@ interface TimelineScrollAnchor {
|
||||
scrollLeft: number;
|
||||
}
|
||||
|
||||
interface TopicSubfieldLegendItem {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
color: string;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
interface TopicFieldLegendGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
domainName: string;
|
||||
domainDescription: string;
|
||||
tooltip: string;
|
||||
items: TopicSubfieldLegendItem[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-research-timeline',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatProgressSpinnerModule, MatTooltipModule],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTooltipModule,
|
||||
TopicChipComponent,
|
||||
],
|
||||
templateUrl: './research-timeline.component.html',
|
||||
styleUrl: './research-timeline.component.scss',
|
||||
})
|
||||
@@ -84,12 +121,16 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
@Input() viewMode: TimelineViewMode = 'years';
|
||||
@Input() startYear: number | undefined;
|
||||
@Input() endYear: number | undefined;
|
||||
@Input() subfieldLegendVisible = true;
|
||||
@Input() subfieldLegendExpanded = false;
|
||||
|
||||
@Output() viewModeChange = new EventEmitter<TimelineViewMode>();
|
||||
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
|
||||
@Output() topicSelect = new EventEmitter<TimelineTopicSelection>();
|
||||
@Output() yearSelect = new EventEmitter<number[]>();
|
||||
@Output() loadEarlierYears = new EventEmitter<void>();
|
||||
@Output() subfieldLegendVisibleChange = new EventEmitter<boolean>();
|
||||
@Output() subfieldLegendExpandedChange = new EventEmitter<boolean>();
|
||||
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
|
||||
@@ -98,10 +139,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
selectedStartYear = 0;
|
||||
selectedEndYear = 0;
|
||||
|
||||
private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
private readonly columnWidth = 240;
|
||||
private readonly displayedTopicLimit = 3;
|
||||
private readonly displayedPhaseTopicLimit = 4;
|
||||
private readonly collapsedSubfieldLegendGroupLimit = 3;
|
||||
private readonly scrollRestoreThreshold = 24;
|
||||
private readonly expandedPhaseIds = new Set<string>();
|
||||
|
||||
@@ -157,6 +198,32 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return this.buildCompactPhases(this.timelineItems);
|
||||
}
|
||||
|
||||
get subfieldLegendGroups(): TopicFieldLegendGroup[] {
|
||||
const groups = this.allSubfieldLegendGroups;
|
||||
|
||||
if (this.subfieldLegendExpanded) {
|
||||
return groups;
|
||||
}
|
||||
|
||||
return groups.slice(0, this.collapsedSubfieldLegendGroupLimit);
|
||||
}
|
||||
|
||||
get hiddenSubfieldLegendItemCount(): number {
|
||||
if (this.subfieldLegendExpanded) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.allSubfieldLegendGroups
|
||||
.slice(this.collapsedSubfieldLegendGroupLimit)
|
||||
.reduce((count, group) => count + group.items.length, 0);
|
||||
}
|
||||
|
||||
get showSubfieldLegendToggle(): boolean {
|
||||
return (
|
||||
this.subfieldLegendExpanded || this.hiddenSubfieldLegendItemCount > 0
|
||||
);
|
||||
}
|
||||
|
||||
get hasYearRange(): boolean {
|
||||
return this.minYear > 0 && this.maxYear > 0 && this.minYear < this.maxYear;
|
||||
}
|
||||
@@ -335,8 +402,45 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return (topic?.description ?? '').trim();
|
||||
}
|
||||
|
||||
hasTopicDescription(topic: TopicTimelineTopic | undefined): boolean {
|
||||
return this.getTopicDescription(topic).length > 0;
|
||||
getTopicTooltip(topic: TopicTimelineTopic | undefined): string {
|
||||
return buildTopicHierarchyTooltip({
|
||||
topicName: topic?.name,
|
||||
description: topic?.description,
|
||||
subfieldName: topic?.subfield_name,
|
||||
fieldName: topic?.field_name,
|
||||
domainName: topic?.domain_name,
|
||||
});
|
||||
}
|
||||
|
||||
hasTopicTooltip(topic: TopicTimelineTopic | undefined): boolean {
|
||||
return this.getTopicTooltip(topic).length > 0;
|
||||
}
|
||||
|
||||
buildLegendTooltip(
|
||||
entries: Array<{ label: string; value: string; description: string }>,
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const entry of entries) {
|
||||
if (!entry.value && !entry.description) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lines.length > 0) {
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (entry.value) {
|
||||
lines.push(`${entry.label}: ${entry.value}`);
|
||||
}
|
||||
|
||||
if (entry.description) {
|
||||
lines.push('');
|
||||
lines.push(`Beschreibung: ${entry.description}`);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
getYearTopicCountTooltip(
|
||||
@@ -369,8 +473,26 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return this.expandedPhaseIds.has(phase.id);
|
||||
}
|
||||
|
||||
getColorClass(index: number): string {
|
||||
return this.colors[index % this.colors.length];
|
||||
getTopicColor(topic: TopicTimelineTopic | undefined): string {
|
||||
return topicHierarchyColor(topic);
|
||||
}
|
||||
|
||||
toggleSubfieldLegend(): void {
|
||||
this.subfieldLegendExpanded = !this.subfieldLegendExpanded;
|
||||
this.subfieldLegendExpandedChange.emit(this.subfieldLegendExpanded);
|
||||
}
|
||||
|
||||
toggleSubfieldLegendVisibility(): void {
|
||||
this.subfieldLegendVisible = !this.subfieldLegendVisible;
|
||||
this.subfieldLegendVisibleChange.emit(this.subfieldLegendVisible);
|
||||
}
|
||||
|
||||
trackByLegendGroup(_: number, group: TopicFieldLegendGroup): string {
|
||||
return group.id;
|
||||
}
|
||||
|
||||
trackByLegendItem(_: number, item: TopicSubfieldLegendItem): string {
|
||||
return item.id;
|
||||
}
|
||||
|
||||
trackByYear(_: number, item: TopicTimelineElement): number {
|
||||
@@ -519,6 +641,117 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
);
|
||||
}
|
||||
|
||||
private get allSubfieldLegendGroups(): TopicFieldLegendGroup[] {
|
||||
if (
|
||||
this.loading ||
|
||||
this.loadFailed ||
|
||||
this.timelineViewMode === 'wordcloud'
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const groups = new Map<string, TopicFieldLegendGroup>();
|
||||
|
||||
for (const topic of this.visibleLegendTopics) {
|
||||
const subfieldName = topic.subfield_name?.trim();
|
||||
|
||||
if (!subfieldName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fieldName = topic.field_name?.trim() || 'Ohne Field';
|
||||
const fieldKey = topic.field_id ?? this.normalizeTopicName(fieldName);
|
||||
const subfieldKey =
|
||||
topic.subfield_id ?? this.normalizeTopicName(subfieldName);
|
||||
|
||||
if (!groups.has(fieldKey)) {
|
||||
groups.set(fieldKey, {
|
||||
id: fieldKey,
|
||||
name: fieldName,
|
||||
description: topic.field_description?.trim() ?? '',
|
||||
domainName: topic.domain_name?.trim() ?? '',
|
||||
domainDescription: topic.domain_description?.trim() ?? '',
|
||||
tooltip: this.buildLegendTooltip([
|
||||
{
|
||||
label: 'Fachgebiet',
|
||||
value: fieldName,
|
||||
description: topic.field_description?.trim() ?? '',
|
||||
},
|
||||
{
|
||||
label: 'Wissenschaftsbereich',
|
||||
value: topic.domain_name?.trim() ?? '',
|
||||
description: topic.domain_description?.trim() ?? '',
|
||||
},
|
||||
]),
|
||||
items: [],
|
||||
});
|
||||
}
|
||||
|
||||
const group = groups.get(fieldKey);
|
||||
|
||||
if (!group || group.items.some((item) => item.id === subfieldKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.items.push({
|
||||
id: subfieldKey,
|
||||
name: subfieldName,
|
||||
description: topic.subfield_description?.trim() ?? '',
|
||||
color: this.getTopicColor(topic),
|
||||
tooltip: this.buildLegendTooltip([
|
||||
{
|
||||
label: 'Themenbereich',
|
||||
value: subfieldName,
|
||||
description: topic.subfield_description?.trim() ?? '',
|
||||
},
|
||||
{
|
||||
label: 'Fachgebiet',
|
||||
value: fieldName,
|
||||
description: topic.field_description?.trim() ?? '',
|
||||
},
|
||||
{
|
||||
label: 'Wissenschaftsbereich',
|
||||
value: topic.domain_name?.trim() ?? '',
|
||||
description: topic.domain_description?.trim() ?? '',
|
||||
},
|
||||
]),
|
||||
});
|
||||
}
|
||||
|
||||
return [...groups.values()]
|
||||
.map((group) => ({
|
||||
...group,
|
||||
items: group.items.sort((left, right) =>
|
||||
left.name.localeCompare(right.name),
|
||||
),
|
||||
}))
|
||||
.sort((left, right) => left.name.localeCompare(right.name));
|
||||
}
|
||||
|
||||
private get visibleLegendTopics(): TopicTimelineTopic[] {
|
||||
if (this.timelineViewMode === 'compact') {
|
||||
return this.compactPhases.flatMap((phase) => [
|
||||
phase.primaryTopic,
|
||||
...phase.topics,
|
||||
...(this.isPhaseExpanded(phase)
|
||||
? phase.years.flatMap((year) =>
|
||||
this.getDisplayedTopicsForPrimaryTopic(
|
||||
year,
|
||||
phase.primaryTopicName,
|
||||
),
|
||||
)
|
||||
: []),
|
||||
]);
|
||||
}
|
||||
|
||||
return this.timelineItems
|
||||
.flatMap((item) => [
|
||||
this.getMainTopicItem(item),
|
||||
...this.getDisplayedTopics(item),
|
||||
])
|
||||
.filter((topic): topic is TopicTimelineTopic => Boolean(topic));
|
||||
}
|
||||
|
||||
private initializeYearBounds(): void {
|
||||
const years = this.sortedElements
|
||||
.map((item) => item.year)
|
||||
@@ -646,6 +879,15 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
let count = 0;
|
||||
let id = primaryTopic.id;
|
||||
let description = primaryTopic.description;
|
||||
let subfieldId = primaryTopic.subfield_id;
|
||||
let subfieldName = primaryTopic.subfield_name;
|
||||
let subfieldDescription = primaryTopic.subfield_description;
|
||||
let fieldId = primaryTopic.field_id;
|
||||
let fieldName = primaryTopic.field_name;
|
||||
let fieldDescription = primaryTopic.field_description;
|
||||
let domainId = primaryTopic.domain_id;
|
||||
let domainName = primaryTopic.domain_name;
|
||||
let domainDescription = primaryTopic.domain_description;
|
||||
|
||||
for (const year of years) {
|
||||
for (const topic of year.primary_topics ?? []) {
|
||||
@@ -662,6 +904,42 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
if (!description && topic.description) {
|
||||
description = topic.description;
|
||||
}
|
||||
|
||||
if (!subfieldId && topic.subfield_id) {
|
||||
subfieldId = topic.subfield_id;
|
||||
}
|
||||
|
||||
if (!subfieldName && topic.subfield_name) {
|
||||
subfieldName = topic.subfield_name;
|
||||
}
|
||||
|
||||
if (!subfieldDescription && topic.subfield_description) {
|
||||
subfieldDescription = topic.subfield_description;
|
||||
}
|
||||
|
||||
if (!fieldId && topic.field_id) {
|
||||
fieldId = topic.field_id;
|
||||
}
|
||||
|
||||
if (!fieldName && topic.field_name) {
|
||||
fieldName = topic.field_name;
|
||||
}
|
||||
|
||||
if (!fieldDescription && topic.field_description) {
|
||||
fieldDescription = topic.field_description;
|
||||
}
|
||||
|
||||
if (!domainId && topic.domain_id) {
|
||||
domainId = topic.domain_id;
|
||||
}
|
||||
|
||||
if (!domainName && topic.domain_name) {
|
||||
domainName = topic.domain_name;
|
||||
}
|
||||
|
||||
if (!domainDescription && topic.domain_description) {
|
||||
domainDescription = topic.domain_description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,6 +948,15 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
name: primaryTopicName,
|
||||
count: count > 0 ? count : primaryTopic.count,
|
||||
description,
|
||||
subfield_id: subfieldId,
|
||||
subfield_name: subfieldName,
|
||||
subfield_description: subfieldDescription,
|
||||
field_id: fieldId,
|
||||
field_name: fieldName,
|
||||
field_description: fieldDescription,
|
||||
domain_id: domainId,
|
||||
domain_name: domainName,
|
||||
domain_description: domainDescription,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -681,6 +968,15 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
const originalNames = new Map<string, string>();
|
||||
const ids = new Map<string, string>();
|
||||
const descriptions = new Map<string, string>();
|
||||
const subfieldIds = new Map<string, string>();
|
||||
const subfieldNames = new Map<string, string>();
|
||||
const subfieldDescriptions = new Map<string, string>();
|
||||
const fieldIds = new Map<string, string>();
|
||||
const fieldNames = new Map<string, string>();
|
||||
const fieldDescriptions = new Map<string, string>();
|
||||
const domainIds = new Map<string, string>();
|
||||
const domainNames = new Map<string, string>();
|
||||
const domainDescriptions = new Map<string, string>();
|
||||
|
||||
for (const year of years) {
|
||||
for (const topic of year.topics ?? []) {
|
||||
@@ -700,6 +996,42 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
descriptions.set(normalizedName, topic.description);
|
||||
}
|
||||
|
||||
if (topic.subfield_id) {
|
||||
subfieldIds.set(normalizedName, topic.subfield_id);
|
||||
}
|
||||
|
||||
if (topic.subfield_name) {
|
||||
subfieldNames.set(normalizedName, topic.subfield_name);
|
||||
}
|
||||
|
||||
if (topic.subfield_description) {
|
||||
subfieldDescriptions.set(normalizedName, topic.subfield_description);
|
||||
}
|
||||
|
||||
if (topic.field_id) {
|
||||
fieldIds.set(normalizedName, topic.field_id);
|
||||
}
|
||||
|
||||
if (topic.field_name) {
|
||||
fieldNames.set(normalizedName, topic.field_name);
|
||||
}
|
||||
|
||||
if (topic.field_description) {
|
||||
fieldDescriptions.set(normalizedName, topic.field_description);
|
||||
}
|
||||
|
||||
if (topic.domain_id) {
|
||||
domainIds.set(normalizedName, topic.domain_id);
|
||||
}
|
||||
|
||||
if (topic.domain_name) {
|
||||
domainNames.set(normalizedName, topic.domain_name);
|
||||
}
|
||||
|
||||
if (topic.domain_description) {
|
||||
domainDescriptions.set(normalizedName, topic.domain_description);
|
||||
}
|
||||
|
||||
counts.set(
|
||||
normalizedName,
|
||||
(counts.get(normalizedName) ?? 0) + topic.count,
|
||||
@@ -713,6 +1045,15 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
name: originalNames.get(normalizedName) ?? normalizedName,
|
||||
count,
|
||||
description: descriptions.get(normalizedName),
|
||||
subfield_id: subfieldIds.get(normalizedName),
|
||||
subfield_name: subfieldNames.get(normalizedName),
|
||||
subfield_description: subfieldDescriptions.get(normalizedName),
|
||||
field_id: fieldIds.get(normalizedName),
|
||||
field_name: fieldNames.get(normalizedName),
|
||||
field_description: fieldDescriptions.get(normalizedName),
|
||||
domain_id: domainIds.get(normalizedName),
|
||||
domain_name: domainNames.get(normalizedName),
|
||||
domain_description: domainDescriptions.get(normalizedName),
|
||||
}))
|
||||
.sort((left, right) => {
|
||||
if (right.count !== left.count) {
|
||||
|
||||
@@ -9,8 +9,12 @@
|
||||
[viewMode]="timelineViewMode"
|
||||
[startYear]="timelineStartYear"
|
||||
[endYear]="timelineEndYear"
|
||||
[subfieldLegendVisible]="timelineLegendVisible"
|
||||
[subfieldLegendExpanded]="timelineLegendExpanded"
|
||||
(viewModeChange)="onTimelineViewModeChange($event)"
|
||||
(yearRangeChange)="onTimelineYearRangeChange($event)"
|
||||
(subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)"
|
||||
(subfieldLegendExpandedChange)="onTimelineLegendExpandedChange($event)"
|
||||
(topicSelect)="onTimelineTopicSelect($event)"
|
||||
(yearSelect)="onTimelineYearSelect($event)"
|
||||
(loadEarlierYears)="onTimelineLoadEarlierYears()">
|
||||
|
||||
@@ -28,6 +28,10 @@ export class PersonOverviewComponent implements OnInit {
|
||||
private static readonly timelineViewQueryParam = 'timeline_view';
|
||||
private static readonly timelineStartYearQueryParam = 'timeline_start_year';
|
||||
private static readonly timelineEndYearQueryParam = 'timeline_end_year';
|
||||
private static readonly timelineLegendVisibleQueryParam =
|
||||
'timeline_legend_visible';
|
||||
private static readonly timelineLegendExpandedQueryParam =
|
||||
'timeline_legend_expanded';
|
||||
private static readonly timelineTopicCountLimit = 4;
|
||||
private static readonly initialTimelineTargetPublications = 250;
|
||||
|
||||
@@ -49,6 +53,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
timelineStartYear: number | undefined;
|
||||
timelineEndYear: number | undefined;
|
||||
timelineLegendVisible = true;
|
||||
timelineLegendExpanded = false;
|
||||
|
||||
wordCloudOptions: EChartsOption | null = null;
|
||||
loadingWordCloud = false;
|
||||
@@ -84,6 +90,18 @@ export class PersonOverviewComponent implements OnInit {
|
||||
this.timelineEndYear = this.parseOptionalYear(
|
||||
queryParams.get(PersonOverviewComponent.timelineEndYearQueryParam),
|
||||
);
|
||||
this.timelineLegendVisible = this.parseBooleanQueryParam(
|
||||
queryParams.get(
|
||||
PersonOverviewComponent.timelineLegendVisibleQueryParam,
|
||||
),
|
||||
true,
|
||||
);
|
||||
this.timelineLegendExpanded = this.parseBooleanQueryParam(
|
||||
queryParams.get(
|
||||
PersonOverviewComponent.timelineLegendExpandedQueryParam,
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,6 +130,32 @@ export class PersonOverviewComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
onTimelineLegendVisibleChange(visible: boolean): void {
|
||||
this.timelineLegendVisible = visible;
|
||||
|
||||
this.updateTimelineQueryParams(
|
||||
{
|
||||
[PersonOverviewComponent.timelineLegendVisibleQueryParam]: visible
|
||||
? null
|
||||
: 'false',
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
onTimelineLegendExpandedChange(expanded: boolean): void {
|
||||
this.timelineLegendExpanded = expanded;
|
||||
|
||||
this.updateTimelineQueryParams(
|
||||
{
|
||||
[PersonOverviewComponent.timelineLegendExpandedQueryParam]: expanded
|
||||
? 'true'
|
||||
: null,
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
onTimelineTopicSelect(selection: TimelineTopicSelection): void {
|
||||
if (!selection.topic.id) {
|
||||
return;
|
||||
@@ -436,6 +480,15 @@ export class PersonOverviewComponent implements OnInit {
|
||||
name: topic.name,
|
||||
count: topic.count ?? 0,
|
||||
description: topic.description ?? undefined,
|
||||
subfield_id: topic.subfield_id ?? undefined,
|
||||
subfield_name: topic.subfield_name ?? undefined,
|
||||
subfield_description: topic.subfield_description ?? undefined,
|
||||
field_id: topic.field_id ?? undefined,
|
||||
field_name: topic.field_name ?? undefined,
|
||||
field_description: topic.field_description ?? undefined,
|
||||
domain_id: topic.domain_id ?? undefined,
|
||||
domain_name: topic.domain_name ?? undefined,
|
||||
domain_description: topic.domain_description ?? undefined,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -493,8 +546,27 @@ export class PersonOverviewComponent implements OnInit {
|
||||
return year;
|
||||
}
|
||||
|
||||
private parseBooleanQueryParam(
|
||||
value: string | null,
|
||||
fallback: boolean,
|
||||
): boolean {
|
||||
if (value === null) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
if (value === 'true' || value === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value === 'false' || value === '0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private updateTimelineQueryParams(
|
||||
queryParams: Record<string, string | number>,
|
||||
queryParams: Record<string, string | number | null>,
|
||||
replaceUrl: boolean,
|
||||
): void {
|
||||
void this.router.navigate([], {
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@if (selectedPatent.assignees.length > 0) {
|
||||
@if (hasAsignees(selectedPatent)) {
|
||||
<div class="detail-section">
|
||||
<h4>Anmelder</h4>
|
||||
<ul class="tag-list">
|
||||
@@ -59,7 +59,7 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (selectedPatent.ipc.length > 0) {
|
||||
@if (hasIpcs(selectedPatent)) {
|
||||
<div class="detail-section">
|
||||
<h4>Klassifikation (IPC)</h4>
|
||||
<ul class="tag-list tag-list--compact">
|
||||
@@ -164,7 +164,7 @@
|
||||
<div class="stat">
|
||||
<span class="stat-label">Datum</span>
|
||||
<span class="stat-value">{{
|
||||
formatDate(selectedPatent.publication_date)
|
||||
formatDate(selectedPatent.publication_date || '')
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { PatentsService, PatentEntry } from '../../api/api/patents.service';
|
||||
import { PatentsService } from '../../api/api/patents.service';
|
||||
import { PatentEntry } from '../../api';
|
||||
|
||||
type SortMode = 'date' | 'title';
|
||||
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
||||
@@ -32,6 +33,14 @@ export class PersonPatentsComponent implements OnInit {
|
||||
selectedPage = 1;
|
||||
readonly pageSize = 10;
|
||||
|
||||
hasAsignees(selectedPatent: PatentEntry | null): boolean {
|
||||
return !!selectedPatent?.assignees && selectedPatent.assignees.length > 0;
|
||||
}
|
||||
|
||||
hasIpcs(selectedPatent: PatentEntry | null): boolean {
|
||||
return !!selectedPatent?.ipc && selectedPatent.ipc.length > 0;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.parent?.paramMap.subscribe((params) => {
|
||||
const authorId = params.get('id') ?? '';
|
||||
|
||||
@@ -5,35 +5,27 @@
|
||||
</div>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>Suche nach Titel</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="search"
|
||||
[debounceTime]="300"
|
||||
[(debouncedValue)]="urlSearchTerm"
|
||||
(debouncedValueChange)="handleSearchTermChange($event)" />
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<button matIconButton matSuffix (click)="clearSearchTerm()">
|
||||
<mat-icon>clear</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<app-query-param-input label="Suche nach Titel" queryParamKey="search" />
|
||||
<mat-tab-group>
|
||||
<mat-tab label="DFG">
|
||||
<app-data-table
|
||||
[columns]="dfgProjectColumns"
|
||||
[data]="dfgProjectData"
|
||||
[detailTemplate]="dfgProjectDetailRowTmp"
|
||||
[activeSortKey]="urlSortKey()"
|
||||
[sortDirection]="urlSortDirection()"
|
||||
(sortChange)="handleSortChange($event)" />
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
</mat-tab>
|
||||
<mat-tab label="EU">
|
||||
<app-data-table
|
||||
[columns]="personCordisEuProjectColumns"
|
||||
[data]="personCordisEuProjectData"
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<mat-paginator
|
||||
[length]="this.pageTotal()"
|
||||
[pageSize]="this.pageSize()"
|
||||
[pageIndex]="this.pageIndex()"
|
||||
(page)="handlePageChange($event)" />
|
||||
<app-query-param-paginator
|
||||
[total]="this.pageTotal()"
|
||||
[pageSizeOptions]="[10]" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
@@ -66,3 +58,25 @@
|
||||
</ul>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #euProjectsFundingStartTmp let-element>
|
||||
{{ element.startDate | date: 'dd.MM.yyyy' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #euProjectsFundingEndTmp let-element>
|
||||
{{ element.endDate | date: 'dd.MM.yyyy' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #euProjectsFundingAmountTmp let-element>
|
||||
{{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #euProjectsActionsTmp let-element>
|
||||
<a
|
||||
[routerLink]="['/projects/eu', element.id]"
|
||||
target="_blank"
|
||||
mat-icon-button
|
||||
color="primary">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
@@ -4,11 +4,15 @@ import {
|
||||
effect,
|
||||
input,
|
||||
OnInit,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { DfgProjectPage, DfgProjectSummary } from '../../api';
|
||||
import {
|
||||
CordisEuProject,
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
DfgProjectSummary,
|
||||
} from '../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
@@ -19,11 +23,10 @@ import { MatCardModule } from '@angular/material/card';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { DebounceDirective } from '../../directives/debounce.directive';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { Sort, SortDirection } from '@angular/material/sort';
|
||||
import { Router, RouterModule } from '@angular/router';
|
||||
import { CurrencyPipe, DatePipe } from '@angular/common';
|
||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import { QueryParamInputComponent } from '../../shared/ui/query-param-input/query-param-input.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-projects',
|
||||
@@ -35,9 +38,11 @@ import { Sort, SortDirection } from '@angular/material/sort';
|
||||
MatTabsModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
DebounceDirective,
|
||||
MatPaginatorModule,
|
||||
RouterModule,
|
||||
DatePipe,
|
||||
CurrencyPipe,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamInputComponent,
|
||||
],
|
||||
templateUrl: './person-projects.component.html',
|
||||
styleUrl: './person-projects.component.scss',
|
||||
@@ -57,48 +62,35 @@ export class PersonProjectsComponent implements OnInit {
|
||||
'dfgProjectDetailRowTmp',
|
||||
);
|
||||
|
||||
urlSearchTerm = signal<string>('');
|
||||
urlSortKey = signal<string>('');
|
||||
urlSortDirection = signal<SortDirection>('');
|
||||
personCordisEuProjectPage = input.required<CordisEuProjectPage>();
|
||||
personCordisEuProjectColumns: GenericColumn<CordisEuProject>[] = [];
|
||||
personCordisEuProjectData: CordisEuProject[] = [];
|
||||
|
||||
euProjectsFundingStartTmp = viewChild.required<TemplateRef<any>>(
|
||||
'euProjectsFundingStartTmp',
|
||||
);
|
||||
euProjectsFundingEndTmp = viewChild.required<TemplateRef<any>>(
|
||||
'euProjectsFundingEndTmp',
|
||||
);
|
||||
euProjectsFundingAmountTmp = viewChild.required<TemplateRef<any>>(
|
||||
'euProjectsFundingAmountTmp',
|
||||
);
|
||||
euProjectsActionsTmp = viewChild.required<TemplateRef<any>>(
|
||||
'euProjectsActionsTmp',
|
||||
);
|
||||
|
||||
readonly pageTotal = computed(() => {
|
||||
return this.dfgProjectPage()?.total ?? 0;
|
||||
});
|
||||
|
||||
readonly pageSize = computed(() => {
|
||||
return this.dfgProjectPage()?.size ?? 10;
|
||||
});
|
||||
|
||||
readonly pageIndex = computed(() => {
|
||||
return this.dfgProjectPage()?.page ?? 0;
|
||||
});
|
||||
|
||||
constructor(
|
||||
private readonly router: Router,
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
) {
|
||||
this.activatedRoute.queryParamMap
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((params) => {
|
||||
this.urlSearchTerm.set(params.get('search') || '');
|
||||
});
|
||||
|
||||
constructor(private readonly router: Router) {
|
||||
effect(() => {
|
||||
console.log(
|
||||
'PersonProjectsComponent: dfgProjectPage changed',
|
||||
this.dfgProjectPage(),
|
||||
);
|
||||
this.dfgProjectData = this.dfgProjectPage().elements || [];
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const searchTerm = this.urlSearchTerm();
|
||||
if (searchTerm) {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: searchTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
this.personCordisEuProjectData =
|
||||
this.personCordisEuProjectPage().elements || [];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,33 +123,38 @@ export class PersonProjectsComponent implements OnInit {
|
||||
cellTemplate: this.dfgProjectActionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
handleSearchTermChange(newTerm: string): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: newTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
clearSearchTerm(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: null },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange(event: PageEvent): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { page: event.pageIndex, size: event.pageSize },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSortChange(event: Sort): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { sort_by: event.active, sort_direction: event.direction },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
this.personCordisEuProjectColumns = [
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title',
|
||||
},
|
||||
{
|
||||
id: 'startDate',
|
||||
header: 'Startdatum',
|
||||
type: 'display',
|
||||
cellTemplate: this.euProjectsFundingStartTmp(),
|
||||
},
|
||||
{
|
||||
id: 'endDate',
|
||||
header: 'Enddatum',
|
||||
type: 'display',
|
||||
cellTemplate: this.euProjectsFundingEndTmp(),
|
||||
},
|
||||
{
|
||||
id: 'ecMaxContribution',
|
||||
header: 'Förderbetrag (EU)',
|
||||
type: 'display',
|
||||
cellTemplate: this.euProjectsFundingAmountTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.euProjectsActionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,19 @@
|
||||
}
|
||||
</span>
|
||||
}
|
||||
@if (displayCareerStage()) {
|
||||
<div class="career-stage-line">
|
||||
<span class="career-stage-label">Career Stage:</span>
|
||||
<span
|
||||
class="career-stage-chip"
|
||||
[matTooltip]="careerStageTooltip()"
|
||||
matTooltipPosition="right"
|
||||
matTooltipClass="career-stage-tooltip"
|
||||
[matTooltipShowDelay]="250">
|
||||
{{ displayCareerStage() }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="profile-contact">
|
||||
<div>
|
||||
|
||||
@@ -85,6 +85,33 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.career-stage-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.career-stage-label {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.career-stage-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: var(--sg-surface-muted);
|
||||
color: var(--sg-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.profile-contact {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
ResolveEnd,
|
||||
@@ -19,7 +20,7 @@ import {
|
||||
import { of, switchMap, finalize, map, catchError } from 'rxjs';
|
||||
|
||||
import { PersonInterestingComponent } from '../person-interesting/person-interesting.component';
|
||||
import { PersonsService, WorksService } from '../../api';
|
||||
import { WorksService } from '../../api';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
|
||||
|
||||
@@ -28,6 +29,7 @@ import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
|
||||
imports: [
|
||||
MatIconModule,
|
||||
MatTabsModule,
|
||||
MatTooltipModule,
|
||||
PersonInterestingComponent,
|
||||
RouterOutlet,
|
||||
RouterModule,
|
||||
@@ -41,7 +43,6 @@ export class PersonComponent {
|
||||
private readonly router = inject(Router);
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
|
||||
private readonly personsApi = inject(PersonsService);
|
||||
private readonly worksApi = inject(WorksService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
@@ -62,9 +63,9 @@ export class PersonComponent {
|
||||
const event = this.routerEvents();
|
||||
|
||||
if (
|
||||
!(event instanceof RouterEvent) || // not a router event
|
||||
!this.isResolverEvent(event) || // not a resolver event
|
||||
!this.isNetworkRouterEvent(event) // not navigating to network route
|
||||
!(event instanceof RouterEvent) ||
|
||||
!this.isResolverEvent(event) ||
|
||||
!this.isNetworkRouterEvent(event)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -84,7 +85,6 @@ export class PersonComponent {
|
||||
return event.url.startsWith(`/person/${this.authorId()}/network`);
|
||||
}
|
||||
|
||||
// loading states
|
||||
readonly isPersonLoading = signal(false);
|
||||
readonly isBioLoading = signal(false);
|
||||
|
||||
@@ -111,6 +111,7 @@ export class PersonComponent {
|
||||
),
|
||||
{ initialValue: null },
|
||||
);
|
||||
|
||||
readonly displayName = computed(
|
||||
() => this.person()?.display_name ?? 'Unbekannte Person',
|
||||
);
|
||||
@@ -147,6 +148,36 @@ export class PersonComponent {
|
||||
readonly h_index = computed(
|
||||
() => this.person()?.summary_stats?.h_index ?? null,
|
||||
);
|
||||
readonly displayCareerStage = computed(() => {
|
||||
const stage = this.person()?.career_metrics?.career_stage;
|
||||
|
||||
if (!stage || stage === 'unknown') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stage;
|
||||
});
|
||||
readonly careerStageTooltip = computed(() => {
|
||||
const stage = this.displayCareerStage();
|
||||
if (!stage) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const activeYears = this.person()?.career_metrics?.active_years ?? '-';
|
||||
|
||||
return [
|
||||
`Aktuell: ${stage.replace(' Researcher', '')}`,
|
||||
`Aktive Publikationsjahre: ${activeYears}`,
|
||||
'',
|
||||
'Einteilung:',
|
||||
'Early: 1\u20134 aktive Publikationsjahre',
|
||||
'Emerging: 5\u20139 aktive Publikationsjahre',
|
||||
'Established: 10\u201314 aktive Publikationsjahre',
|
||||
'Senior: ab 15 aktiven Publikationsjahren',
|
||||
'',
|
||||
'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.',
|
||||
].join('\n');
|
||||
});
|
||||
readonly orcid = computed(() => {
|
||||
const rawOrcid = this.getId('orcid');
|
||||
if (!rawOrcid) {
|
||||
@@ -173,6 +204,7 @@ export class PersonComponent {
|
||||
),
|
||||
{ initialValue: [] },
|
||||
);
|
||||
|
||||
links = [
|
||||
{ label: 'Übersicht', path: 'overview', disabled: false },
|
||||
{
|
||||
|
||||
@@ -4,19 +4,11 @@
|
||||
<mat-divider />
|
||||
|
||||
<div style="padding: 0 1rem">
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>Suche nach Namen</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="search"
|
||||
[debounceTime]="300"
|
||||
[(debouncedValue)]="urlSearchTerm"
|
||||
(debouncedValueChange)="handleSearchTermChange($event)" />
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<button matIconButton matSuffix (click)="clearSearchTerm()">
|
||||
<mat-icon>clear</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<app-query-param-input
|
||||
label="Suche nach Namen"
|
||||
[debounceTime]="400"
|
||||
queryParamKey="search">
|
||||
</app-query-param-input>
|
||||
|
||||
<div
|
||||
style="
|
||||
@@ -34,16 +26,13 @@
|
||||
</mat-chip-listbox>
|
||||
|
||||
<div class="sorting">
|
||||
<select (change)="handleSortFieldChange($event)" [value]="urlSortBy()">
|
||||
<option value="title">Name</option>
|
||||
</select>
|
||||
<app-query-param-selector
|
||||
[options]="sortingOptions"
|
||||
queryParamKey="sort_by" />
|
||||
|
||||
<select
|
||||
(change)="handleSortOrderChange($event)"
|
||||
[value]="urlSortingOrder()">
|
||||
<option value="desc">Absteigend</option>
|
||||
<option value="asc">Aufsteigend</option>
|
||||
</select>
|
||||
<app-query-param-selector
|
||||
[options]="sortingDirectionOptions"
|
||||
queryParamKey="sorting_order" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -102,11 +91,7 @@
|
||||
|
||||
<mat-divider />
|
||||
|
||||
<mat-paginator
|
||||
[length]="fundingProjectPageValue.total"
|
||||
[pageSize]="fundingProjectPageValue.size"
|
||||
[pageSizeOptions]="[10, 20, 50]"
|
||||
[pageIndex]="fundingProjectPageValue.page"
|
||||
(page)="handlePageChange($event)">
|
||||
</mat-paginator>
|
||||
<app-query-param-paginator
|
||||
[total]="fundingProjectPageValue.total || 0"
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
</div>
|
||||
|
||||
@@ -25,22 +25,10 @@
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cards {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
background-color: var(--sg-background);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
import { Component, effect, input, signal } from '@angular/core';
|
||||
import { Component, input, signal } from '@angular/core';
|
||||
import { FundingProject, FundingProjectPage, ProjectType } from '../../api';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { DebounceDirective } from '../../directives/debounce.directive';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { DatePipe, UpperCasePipe } from '@angular/common';
|
||||
import { MatChipListboxChange, MatChipsModule } from '@angular/material/chips';
|
||||
import { QueryParamInputComponent } from '../../shared/ui/query-param-input/query-param-input.component';
|
||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import {
|
||||
QueryParamSelectorComponent,
|
||||
SelectorOption,
|
||||
} from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects',
|
||||
imports: [
|
||||
MatDividerModule,
|
||||
MatFormFieldModule,
|
||||
DebounceDirective,
|
||||
MatIconModule,
|
||||
MatCardModule,
|
||||
RouterModule,
|
||||
MatPaginator,
|
||||
MatInputModule,
|
||||
MatButtonModule,
|
||||
UpperCasePipe,
|
||||
DatePipe,
|
||||
MatChipsModule,
|
||||
QueryParamInputComponent,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamSelectorComponent,
|
||||
],
|
||||
templateUrl: './projects.component.html',
|
||||
styleUrl: './projects.component.scss',
|
||||
@@ -35,11 +36,14 @@ import { MatChipListboxChange, MatChipsModule } from '@angular/material/chips';
|
||||
export class ProjectsComponent {
|
||||
fundingProjectPage = input.required<FundingProjectPage>();
|
||||
|
||||
urlSearchTerm = signal<string>('');
|
||||
urlSortBy = signal<string>('relevance');
|
||||
urlSortingOrder = signal<string>('desc');
|
||||
urlChips = signal<ProjectType[]>(['eu', 'bund', 'dfg']);
|
||||
|
||||
sortingOptions: SelectorOption[] = [{ value: 'title', display_name: 'Name' }];
|
||||
sortingDirectionOptions: SelectorOption[] = [
|
||||
{ value: 'asc', display_name: 'Aufsteigend' },
|
||||
{ value: 'desc', display_name: 'Absteigend' },
|
||||
];
|
||||
|
||||
constructor(
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
private readonly router: Router,
|
||||
@@ -47,60 +51,10 @@ export class ProjectsComponent {
|
||||
this.activatedRoute.queryParams
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((params) => {
|
||||
this.urlSearchTerm.set(params['search'] || '');
|
||||
this.urlSortBy.set(params['sort_by'] || 'relevance');
|
||||
this.urlSortingOrder.set(params['sorting_order'] || 'desc');
|
||||
this.urlChips.set(
|
||||
(params['selected_project_types'] || 'eu,bund,dfg').split(','),
|
||||
);
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const searchTerm = this.urlSearchTerm();
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: searchTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleSearchTermChange(newTerm: string): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: newTerm },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
clearSearchTerm(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { search: null },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handlePageChange(event: PageEvent): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { page: event.pageIndex, size: event.pageSize },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSortFieldChange(event: Event): void {
|
||||
const selectElement = event.target as HTMLSelectElement;
|
||||
const sortField = selectElement.value;
|
||||
this.router.navigate([], {
|
||||
queryParams: { sort_by: sortField },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleSortOrderChange(event: Event): void {
|
||||
const selectElement = event.target as HTMLSelectElement;
|
||||
const sortOrder = selectElement.value;
|
||||
this.router.navigate([], {
|
||||
queryParams: { sorting_order: sortOrder },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
handleChipBoxChange(change: MatChipListboxChange): void {
|
||||
|
||||
@@ -1,11 +1,44 @@
|
||||
<div class="hierarchy-container">
|
||||
@if (searchQuery()) {
|
||||
<div
|
||||
class="search-mode-selector"
|
||||
style="
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
||||
padding-bottom: 8px;
|
||||
">
|
||||
<span
|
||||
style="
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--sg-text);
|
||||
opacity: 0.8;
|
||||
"
|
||||
>Modus:</span
|
||||
>
|
||||
<mat-radio-group
|
||||
[value]="searchType()"
|
||||
(change)="onSearchTypeChange($event.value)"
|
||||
style="display: flex; gap: 16px">
|
||||
<mat-radio-button value="hybrid">
|
||||
<span style="font-size: 12px; color: var(--sg-text)">Hybrid</span>
|
||||
</mat-radio-button>
|
||||
<mat-radio-button value="semantic">
|
||||
<span style="font-size: 12px; color: var(--sg-text)">Semantisch</span>
|
||||
</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
}
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<mat-spinner diameter="24"></mat-spinner>
|
||||
<span>Lade Themen...</span>
|
||||
</div>
|
||||
} @else {
|
||||
@if (searchQuery) {
|
||||
@if (searchQuery()) {
|
||||
<!-- Flat Search Results Mode -->
|
||||
<div class="search-results">
|
||||
<span class="results-meta"
|
||||
@@ -15,8 +48,13 @@
|
||||
@for (topic of filteredFlatTopics; track topic.id) {
|
||||
<div class="flat-row">
|
||||
<mat-checkbox
|
||||
[checked]="selectedTopics.has(topic.name)"
|
||||
(change)="toggleTopic(topic.name)">
|
||||
#tooltip="matTooltip"
|
||||
[checked]="selectedTopics().has(topic.name)"
|
||||
(change)="toggleTopic(topic.name)"
|
||||
[matTooltip]="topic.name"
|
||||
matTooltipPosition="above"
|
||||
(focusin)="tooltip.show()"
|
||||
(focusout)="tooltip.hide()">
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
</mat-checkbox>
|
||||
<span class="topic-path" [title]="topic.path">{{
|
||||
@@ -103,13 +141,18 @@
|
||||
<!-- LEVEL 4: Topic Checkbox -->
|
||||
<div class="tree-leaf topic-node">
|
||||
<mat-checkbox
|
||||
[checked]="selectedTopics.has(topic.name)"
|
||||
(change)="toggleTopic(topic.name)">
|
||||
<span
|
||||
class="topic-label"
|
||||
[title]="topic.name"
|
||||
>{{ topic.name }}</span
|
||||
>
|
||||
#tooltip="matTooltip"
|
||||
[checked]="
|
||||
selectedTopics().has(topic.name)
|
||||
"
|
||||
(change)="toggleTopic(topic.name)"
|
||||
[matTooltip]="topic.name"
|
||||
matTooltipPosition="above"
|
||||
(focusin)="tooltip.show()"
|
||||
(focusout)="tooltip.hide()">
|
||||
<span class="topic-label">{{
|
||||
topic.name
|
||||
}}</span>
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
width: 100%;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-background);
|
||||
padding: 4px;
|
||||
padding: 4px 8px 4px 4px;
|
||||
margin-top: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
@@ -55,6 +57,11 @@
|
||||
font-size: 12px;
|
||||
color: var(--sg-text);
|
||||
font-weight: 500;
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.topic-path {
|
||||
@@ -92,7 +99,7 @@
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 4px 6px;
|
||||
padding: 4px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
@@ -122,6 +129,7 @@
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,37 +166,62 @@
|
||||
}
|
||||
|
||||
.domain-children {
|
||||
padding-left: 12px;
|
||||
padding-left: 10px;
|
||||
border-left: 1px solid var(--sg-border-soft);
|
||||
margin-left: 12px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.field-children {
|
||||
padding-left: 14px;
|
||||
padding-left: 10px;
|
||||
border-left: 1px solid var(--sg-border-soft);
|
||||
margin-left: 14px;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.subfield-children {
|
||||
padding-left: 14px;
|
||||
padding-left: 10px;
|
||||
border-left: 1px dashed var(--sg-border-soft);
|
||||
margin-left: 14px;
|
||||
margin-left: 12px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.tree-leaf {
|
||||
padding: 2px 4px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.topic-node {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.topic-label {
|
||||
font-size: 11px;
|
||||
color: var(--sg-text);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
max-width: 190px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
mat-checkbox {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
|
||||
::ng-deep {
|
||||
.mdc-form-field {
|
||||
width: 100% !important;
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mdc-label {
|
||||
flex: 1 !important;
|
||||
min-width: 0 !important;
|
||||
overflow: hidden;
|
||||
padding-left: 8px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import {
|
||||
Component,
|
||||
Input,
|
||||
Output,
|
||||
EventEmitter,
|
||||
OnInit,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { Component, input, model, output, OnInit, signal } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { TopicsService } from '../../api/api/topics.service';
|
||||
import { Subject, of } from 'rxjs';
|
||||
import { combineLatest, of } from 'rxjs';
|
||||
import { toObservable } from '@angular/core/rxjs-interop';
|
||||
import {
|
||||
debounceTime,
|
||||
distinctUntilChanged,
|
||||
@@ -53,28 +49,18 @@ interface FlatTopic {
|
||||
MatCheckboxModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatRadioModule,
|
||||
MatTooltipModule,
|
||||
],
|
||||
templateUrl: './topic-hierarchy.component.html',
|
||||
styleUrl: './topic-hierarchy.component.scss',
|
||||
})
|
||||
export class TopicHierarchyComponent implements OnInit {
|
||||
@Input() selectedTopics: Set<string> = new Set<string>();
|
||||
selectedTopics = input<Set<string>>(new Set<string>());
|
||||
searchQuery = input<string>('');
|
||||
searchType = model<'hybrid' | 'semantic'>('hybrid');
|
||||
|
||||
private _searchQuery = '';
|
||||
@Input()
|
||||
set searchQuery(value: string) {
|
||||
if (value.length < 2) {
|
||||
this._searchQuery = '';
|
||||
} else {
|
||||
this._searchQuery = value;
|
||||
}
|
||||
this.filterFlatTopics();
|
||||
}
|
||||
get searchQuery(): string {
|
||||
return this._searchQuery;
|
||||
}
|
||||
|
||||
@Output() selectionChange = new EventEmitter<Set<string>>();
|
||||
selectionChange = output<Set<string>>();
|
||||
|
||||
domains: DomainNode[] = [];
|
||||
flatTopics: FlatTopic[] = [];
|
||||
@@ -86,32 +72,37 @@ export class TopicHierarchyComponent implements OnInit {
|
||||
expandedFields = new Set<string>();
|
||||
expandedSubfields = new Set<string>();
|
||||
|
||||
private readonly searchSubject = new Subject<string>();
|
||||
|
||||
constructor(private topicsService: TopicsService) {
|
||||
this.searchSubject
|
||||
combineLatest([
|
||||
toObservable(this.searchQuery),
|
||||
toObservable(this.searchType),
|
||||
])
|
||||
.pipe(
|
||||
debounceTime(300),
|
||||
distinctUntilChanged(),
|
||||
switchMap((query) => {
|
||||
if (!query) {
|
||||
distinctUntilChanged(
|
||||
(prev, curr) => prev[0] === curr[0] && prev[1] === curr[1],
|
||||
),
|
||||
switchMap(([query, searchType]) => {
|
||||
if (!query || query.length < 2) {
|
||||
this.filteredFlatTopics = [];
|
||||
return of({ results: [] });
|
||||
}
|
||||
this.loading.set(true);
|
||||
return this.topicsService.vectorSearchTopics(query, 50).pipe(
|
||||
catchError((err) => {
|
||||
console.error('Error in semantic topic search:', err);
|
||||
// Fallback to local filtering
|
||||
const q = query.toLowerCase();
|
||||
this.filteredFlatTopics = this.flatTopics.filter(
|
||||
(t) =>
|
||||
t.name.toLowerCase().includes(q) ||
|
||||
t.path.toLowerCase().includes(q),
|
||||
);
|
||||
return of({ results: [] });
|
||||
}),
|
||||
);
|
||||
return this.topicsService
|
||||
.vectorSearchTopics(query, 50, searchType)
|
||||
.pipe(
|
||||
catchError((err) => {
|
||||
console.error('Error in semantic topic search:', err);
|
||||
// Fallback to local filtering
|
||||
const q = query.toLowerCase();
|
||||
this.filteredFlatTopics = this.flatTopics.filter(
|
||||
(t) =>
|
||||
t.name.toLowerCase().includes(q) ||
|
||||
t.path.toLowerCase().includes(q),
|
||||
);
|
||||
return of({ results: [] });
|
||||
}),
|
||||
);
|
||||
}),
|
||||
)
|
||||
.subscribe((response) => {
|
||||
@@ -167,19 +158,14 @@ export class TopicHierarchyComponent implements OnInit {
|
||||
});
|
||||
});
|
||||
this.flatTopics = flat;
|
||||
this.filterFlatTopics();
|
||||
}
|
||||
|
||||
filterFlatTopics(): void {
|
||||
if (!this.searchQuery) {
|
||||
this.filteredFlatTopics = [];
|
||||
return;
|
||||
}
|
||||
this.searchSubject.next(this.searchQuery);
|
||||
onSearchTypeChange(type: 'hybrid' | 'semantic'): void {
|
||||
this.searchType.set(type);
|
||||
}
|
||||
|
||||
toggleTopic(name: string): void {
|
||||
const nextSelection = new Set(this.selectedTopics);
|
||||
const nextSelection = new Set(this.selectedTopics());
|
||||
if (nextSelection.has(name)) {
|
||||
nextSelection.delete(name);
|
||||
} else {
|
||||
|
||||
@@ -19,9 +19,9 @@ export const bundProjectPageResolver: ResolveFn<BundProjectPage> = (
|
||||
institutionId = route.parent?.paramMap.get('institutionId') ?? null;
|
||||
}
|
||||
|
||||
const sortBy = (route.queryParamMap.get('sort_by') ??
|
||||
const sortBy = (route.queryParamMap.get('sort_by') ||
|
||||
'title') as ProjectsSortBy;
|
||||
const sortDirection = (route.queryParamMap.get('sort_direction') ??
|
||||
const sortDirection = (route.queryParamMap.get('sort_direction') ||
|
||||
'asc') as SortDirection;
|
||||
|
||||
const search = route.queryParamMap.get('search');
|
||||
|
||||
@@ -8,6 +8,11 @@ import {
|
||||
WorksFilterProperties,
|
||||
} from '../api';
|
||||
|
||||
const DEFAULT_MIN_CONTRIBUTORS = 2;
|
||||
const DEFAULT_MAX_CONTRIBUTORS = 10;
|
||||
const DEFAULT_MIN_COLLABORATIONS = 1;
|
||||
const DEFAULT_MAX_COLLABORATIONS = 100;
|
||||
|
||||
export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
route,
|
||||
state,
|
||||
@@ -38,10 +43,10 @@ export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
end_year: endYear ? Number.parseInt(endYear, 10) : undefined,
|
||||
min_contributors: minContributors
|
||||
? Number.parseInt(minContributors, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MIN_CONTRIBUTORS,
|
||||
max_contributors: maxContributors
|
||||
? Number.parseInt(maxContributors, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MAX_CONTRIBUTORS,
|
||||
allowed_topics: topics ? topics.split(',') : undefined,
|
||||
};
|
||||
}
|
||||
@@ -49,10 +54,10 @@ export const collaborationNetworkResolver: ResolveFn<CollaborationNetwork> = (
|
||||
authorsFilterProperties = {
|
||||
min_collaborations: minCollaborations
|
||||
? Number.parseInt(minCollaborations, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MIN_COLLABORATIONS,
|
||||
max_collaborations: maxCollaborations
|
||||
? Number.parseInt(maxCollaborations, 10)
|
||||
: undefined,
|
||||
: DEFAULT_MAX_COLLABORATIONS,
|
||||
allowed_institutions: institutions ? institutions.split(',') : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { CordisEuProjectPage, ProjectsService } from '../api';
|
||||
import {
|
||||
EuOrganizationProjectSummaryPage,
|
||||
ProjectsService,
|
||||
ProjectsSortBy,
|
||||
SortDirection,
|
||||
} from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const cordisEuProjectPageResolver: ResolveFn<CordisEuProjectPage> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
export const cordisEuProjectPageResolver: ResolveFn<
|
||||
EuOrganizationProjectSummaryPage
|
||||
> = (route, state) => {
|
||||
const page = route.queryParamMap.get('page') ?? '1';
|
||||
const size = route.queryParamMap.get('size') ?? '10';
|
||||
let institutionId = route.paramMap.get('institutionId');
|
||||
@@ -13,8 +17,10 @@ export const cordisEuProjectPageResolver: ResolveFn<CordisEuProjectPage> = (
|
||||
institutionId = route.parent?.paramMap.get('institutionId') ?? null;
|
||||
}
|
||||
|
||||
const sortBy = route.queryParamMap.get('sort_by') ?? 'title';
|
||||
const sortDirection = route.queryParamMap.get('sort_direction') ?? 'asc';
|
||||
const sortBy = (route.queryParamMap.get('sort_by') ||
|
||||
'title') as ProjectsSortBy;
|
||||
const sortDirection = (route.queryParamMap.get('sort_direction') ||
|
||||
'asc') as SortDirection;
|
||||
const search = route.queryParamMap.get('search');
|
||||
|
||||
return inject(ProjectsService).searchCordisEuProjects({
|
||||
@@ -23,7 +29,7 @@ export const cordisEuProjectPageResolver: ResolveFn<CordisEuProjectPage> = (
|
||||
size: Number(size),
|
||||
raw_oa_institution_id: institutionId,
|
||||
query: search,
|
||||
sort_by: sortBy as 'title' | 'funding_start' | 'funding_end',
|
||||
sort_direction: sortDirection as 'asc' | 'desc',
|
||||
sort_by: sortBy,
|
||||
sort_direction: sortDirection,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { CordisEuProjectPage, ProjectsService } from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const personCordisEuProjectPageResolver: ResolveFn<
|
||||
CordisEuProjectPage
|
||||
> = (route, state) => {
|
||||
const rawAuthorId = route.parent?.params['id'];
|
||||
if (!rawAuthorId) {
|
||||
throw new Error('Author ID is required to resolve collaboration network');
|
||||
}
|
||||
return inject(ProjectsService).getEuProjectsForAuthor(rawAuthorId);
|
||||
};
|
||||
@@ -12,7 +12,7 @@ export const personListResolver: ResolveFn<CustomAuthorsListResponse> = (
|
||||
return [val];
|
||||
};
|
||||
const defaultIncludes =
|
||||
'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations';
|
||||
'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations,career_metrics';
|
||||
const params = route.queryParamMap;
|
||||
|
||||
const query = params.get('query') || undefined;
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { inject } from '@angular/core';
|
||||
import { AuthorsListResponse, PersonsService } from '../api';
|
||||
import { CustomAuthorsListResponse, PersonsService } from '../api';
|
||||
|
||||
export const personResolver: ResolveFn<AuthorsListResponse> = (
|
||||
export const personResolver: ResolveFn<CustomAuthorsListResponse> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
const PERSON_INCLUDE_TAGS =
|
||||
'topics_full,topic_share,summary_stats,ids,last_known_institutions,' +
|
||||
'sources,counts_by_year,works_api_url,dates,cited_by_count_boost';
|
||||
const params = route.paramMap;
|
||||
'display_name,works_count,cited_by_count,summary_stats,ids,' +
|
||||
'last_known_institutions,affiliations,topics,orcid,' +
|
||||
'topics_full,topic_share,sources,counts_by_year,works_api_url,' +
|
||||
'dates,cited_by_count_boost,career_metrics';
|
||||
|
||||
const query = params.get('id') || undefined;
|
||||
const authorId = route.paramMap.get('id') || undefined;
|
||||
const personsService = inject(PersonsService);
|
||||
|
||||
return personsService.searchPersons(query, undefined, PERSON_INCLUDE_TAGS);
|
||||
if (!authorId) {
|
||||
return { results: [] };
|
||||
}
|
||||
|
||||
return personsService.getPersonByID(authorId, PERSON_INCLUDE_TAGS);
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ mat-toolbar.main {
|
||||
}
|
||||
|
||||
.drawer--collapsed {
|
||||
width: 76px;
|
||||
width: 64px;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
[routerLink]="item.disabled ? null : item.route"
|
||||
[queryParams]="item.queryParams || null"
|
||||
routerLinkActive="active"
|
||||
[routerLinkActiveOptions]="navLinkActiveOptions"
|
||||
[class.disabled]="item.disabled"
|
||||
[matTooltip]="item.label"
|
||||
matTooltipPosition="right"
|
||||
@@ -61,6 +62,7 @@
|
||||
[routerLink]="item.disabled ? null : item.route"
|
||||
[queryParams]="item.queryParams || null"
|
||||
routerLinkActive="active"
|
||||
[routerLinkActiveOptions]="navLinkActiveOptions"
|
||||
[class.disabled]="item.disabled">
|
||||
<mat-icon matListItemIcon>{{ item.icon }}</mat-icon>
|
||||
<span matListItemTitle>{{ item.label }}</span>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
.sidebar--collapsed {
|
||||
align-items: center;
|
||||
padding: 18px 10px 20px;
|
||||
padding: 18px 8px 20px;
|
||||
}
|
||||
|
||||
.brand-row {
|
||||
@@ -268,3 +268,12 @@
|
||||
.loading-indicator {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.sidebar--collapsed .nav-list,
|
||||
.sidebar--collapsed .sidebar-actions {
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
.sidebar--collapsed .account-icon {
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
|
||||
import {
|
||||
IsActiveMatchOptions,
|
||||
Router,
|
||||
RouterLink,
|
||||
RouterLinkActive,
|
||||
} from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -30,6 +35,12 @@ export class AppMenuComponent {
|
||||
collapsed = input(false);
|
||||
canCollapse = input(false);
|
||||
toggleCollapsed = output<void>();
|
||||
readonly navLinkActiveOptions: IsActiveMatchOptions = {
|
||||
paths: 'subset',
|
||||
queryParams: 'ignored',
|
||||
matrixParams: 'ignored',
|
||||
fragment: 'ignored',
|
||||
};
|
||||
navItems = [
|
||||
{
|
||||
label: 'Dashboard',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
mat-table
|
||||
[dataSource]="dataSource"
|
||||
matSort
|
||||
(matSortChange)="onSortChange($event)"
|
||||
(matSortChange)="_handleSortChange($event)"
|
||||
multiTemplateDataRows>
|
||||
@for (col of columns(); track col.id) {
|
||||
<ng-container [matColumnDef]="col.id">
|
||||
|
||||
@@ -4,12 +4,14 @@ import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import {
|
||||
MatSort,
|
||||
MatSortModule,
|
||||
@@ -17,6 +19,7 @@ import {
|
||||
SortDirection,
|
||||
} from '@angular/material/sort';
|
||||
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
export interface BaseColumn<T> {
|
||||
id: string;
|
||||
@@ -55,15 +58,37 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
containerOverflow = computed(() => (this.maxHeight() ? 'auto' : 'visible'));
|
||||
stickyHeader = input<boolean>(true);
|
||||
|
||||
activeSortKey = input<string>('');
|
||||
sortDirection = input<SortDirection>('');
|
||||
sortChange = output<Sort>();
|
||||
queryParamSortKey = input<string | null>(null);
|
||||
queryParamSortDirectionKey = input<string | null>(null);
|
||||
|
||||
_urlSortValue = computed<string | null>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamSortKey();
|
||||
|
||||
return params && key ? params[key] || null : null;
|
||||
});
|
||||
|
||||
_urlSortDirectionValue = computed<string | null>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamSortDirectionKey();
|
||||
|
||||
return params && key ? params[key] || null : null;
|
||||
});
|
||||
|
||||
handleSortChange = output<Sort>();
|
||||
|
||||
displayedColumns = computed(() => this.columns().map((col) => col.id));
|
||||
dataSource = new MatTableDataSource<T>([]);
|
||||
|
||||
sort = viewChild.required(MatSort);
|
||||
|
||||
private readonly activatedRouter = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly queryParams = toSignal(
|
||||
this.activatedRouter.queryParams.pipe(takeUntilDestroyed()),
|
||||
);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const currentData = this.data();
|
||||
@@ -86,15 +111,23 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
|
||||
effect(() => {
|
||||
const matSortInstance = this.sort();
|
||||
const activeKey = this.activeSortKey();
|
||||
const direction = this.sortDirection();
|
||||
const activeKey = this._urlSortValue();
|
||||
const direction = this._urlSortDirectionValue();
|
||||
|
||||
if (
|
||||
matSortInstance.active !== activeKey ||
|
||||
matSortInstance.direction !== direction
|
||||
) {
|
||||
matSortInstance.active = activeKey;
|
||||
matSortInstance.direction = direction;
|
||||
if (activeKey == null) {
|
||||
matSortInstance.active = '';
|
||||
} else {
|
||||
matSortInstance.active = activeKey;
|
||||
}
|
||||
if (direction == null) {
|
||||
matSortInstance.direction = '';
|
||||
} else {
|
||||
matSortInstance.direction = direction as SortDirection;
|
||||
}
|
||||
|
||||
this.dataSource.sort = matSortInstance;
|
||||
}
|
||||
@@ -105,8 +138,25 @@ export class DataTableComponent<T> implements AfterViewInit {
|
||||
this.dataSource.sort = this.sort();
|
||||
}
|
||||
|
||||
onSortChange(sort: Sort) {
|
||||
this.sortChange.emit(sort);
|
||||
_handleSortChange(sort: Sort): void {
|
||||
this.handleSortChange.emit(sort);
|
||||
|
||||
const sortKey = this.queryParamSortKey();
|
||||
const sortDirectionKey = this.queryParamSortDirectionKey();
|
||||
if (sortKey != null) {
|
||||
const queryParams: any = {
|
||||
[sortKey]: sort.active || null,
|
||||
};
|
||||
|
||||
if (sortDirectionKey != null) {
|
||||
queryParams[sortDirectionKey] = sort.direction || null;
|
||||
}
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams,
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
toggleRow(row: T): void {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-label>{{ this.label() }}</mat-label>
|
||||
<input
|
||||
matInput
|
||||
type="search"
|
||||
[debounceTime]="this.debounceTime()"
|
||||
(debouncedValueChange)="this._handleValueChange($event)"
|
||||
[ngModel]="this._urlValue()" />
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<button matIconButton matSuffix type="button" (click)="clearInput()">
|
||||
<mat-icon>clear</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { DebounceDirective } from '../../../directives/debounce.directive';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-query-param-input',
|
||||
imports: [
|
||||
FormsModule,
|
||||
MatInputModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
DebounceDirective,
|
||||
],
|
||||
templateUrl: './query-param-input.component.html',
|
||||
styleUrl: './query-param-input.component.scss',
|
||||
})
|
||||
export class QueryParamInputComponent {
|
||||
queryParamKey = input.required<string>();
|
||||
queryParamPageKey = input<string>('page');
|
||||
label = input<string>('Suchen');
|
||||
debounceTime = input<number>(300);
|
||||
handleValueChange = output<string>();
|
||||
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly queryParams = toSignal(
|
||||
this.activatedRoute.queryParams.pipe(takeUntilDestroyed()),
|
||||
);
|
||||
|
||||
_urlValue = computed<string>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamKey();
|
||||
|
||||
return params && key ? params[key] || '' : '';
|
||||
});
|
||||
|
||||
clearInput(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: { [this.queryParamKey()]: null },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
_handleValueChange(newValue: string): void {
|
||||
this.handleValueChange?.emit(newValue);
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKey()]: newValue || null,
|
||||
[this.queryParamPageKey()]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<mat-paginator
|
||||
[length]="total()"
|
||||
[pageSize]="_urlSize()"
|
||||
[pageIndex]="_urlPage()"
|
||||
[pageSizeOptions]="pageSizeOptions()"
|
||||
(page)="_handlePageChange($event)" />
|
||||
@@ -0,0 +1,3 @@
|
||||
mat-paginator {
|
||||
background-color: var(--sg-background);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-query-param-paginator',
|
||||
imports: [MatPaginatorModule],
|
||||
templateUrl: './query-param-paginator.component.html',
|
||||
styleUrl: './query-param-paginator.component.scss',
|
||||
})
|
||||
export class QueryParamPaginatorComponent {
|
||||
queryParamPageKey = input<string>('page');
|
||||
queryParamSizeKey = input<string>('size');
|
||||
pageSizeOptions = input<number[]>([10, 25, 50]);
|
||||
|
||||
total = input.required<number>();
|
||||
|
||||
handlePageChange = output<PageEvent>();
|
||||
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly queryParams = toSignal(
|
||||
this.activatedRoute.queryParams.pipe(takeUntilDestroyed()),
|
||||
);
|
||||
|
||||
_urlPage = computed<number>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamPageKey();
|
||||
|
||||
return params && key ? +params[key] || 0 : 0;
|
||||
});
|
||||
|
||||
_urlSize = computed<number>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamSizeKey();
|
||||
|
||||
return params && key ? +params[key] || 10 : 10;
|
||||
});
|
||||
|
||||
_handlePageChange(event: PageEvent): void {
|
||||
this.handlePageChange?.emit(event);
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamPageKey()]: event.pageIndex || 0,
|
||||
[this.queryParamSizeKey()]: event.pageSize || 10,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<select (change)="_handleSelectionChange($event)" [ngModel]="_urlValue()">
|
||||
@for (option of options(); track $index) {
|
||||
<option [value]="option.value">{{ option.display_name }}</option>
|
||||
}
|
||||
</select>
|
||||
@@ -0,0 +1,10 @@
|
||||
select {
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
select:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Component, computed, inject, input, output } from '@angular/core';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
export type SelectorOption = {
|
||||
value: string;
|
||||
display_name: string;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-query-param-selector',
|
||||
imports: [FormsModule],
|
||||
templateUrl: './query-param-selector.component.html',
|
||||
styleUrl: './query-param-selector.component.scss',
|
||||
})
|
||||
export class QueryParamSelectorComponent {
|
||||
options = input.required<SelectorOption[]>();
|
||||
queryParamKey = input.required<string>();
|
||||
handleSelectionChange = output<Event>();
|
||||
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly queryParams = toSignal(
|
||||
this.activatedRoute.queryParams.pipe(takeUntilDestroyed()),
|
||||
);
|
||||
|
||||
_urlValue = computed<string>(() => {
|
||||
const params = this.queryParams();
|
||||
const key = this.queryParamKey();
|
||||
|
||||
return params && key ? params[key] || '' : '';
|
||||
});
|
||||
|
||||
_handleSelectionChange(event: Event): void {
|
||||
const newValue = (event.target as HTMLSelectElement).value;
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: { [this.queryParamKey()]: newValue },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
|
||||
this.handleSelectionChange.emit(event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip__button"
|
||||
[disabled]="disabled"
|
||||
[attr.aria-pressed]="active ? 'true' : null"
|
||||
[matTooltip]="buttonTooltip"
|
||||
[matTooltipDisabled]="!buttonTooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
(click)="handleClick()">
|
||||
<span
|
||||
class="topic-chip__label"
|
||||
[matTooltip]="labelTooltip"
|
||||
[matTooltipDisabled]="!labelTooltip"
|
||||
matTooltipClass="topic-chip-tooltip">
|
||||
{{ label }}
|
||||
</span>
|
||||
|
||||
@if (hasCount) {
|
||||
<span
|
||||
class="topic-chip__count"
|
||||
[matTooltip]="normalizedCountTooltip"
|
||||
[matTooltipDisabled]="!normalizedCountTooltip">
|
||||
{{ count }}
|
||||
@if (countIconName) {
|
||||
<mat-icon class="topic-chip__count-icon">{{ countIconName }}</mat-icon>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
</button>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user