feature/keyword_search_rework #157
@@ -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,14 +33,6 @@ 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 = []
|
||||
@@ -75,7 +65,67 @@ def fetch_all_topics():
|
||||
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
|
||||
|
||||
@@ -83,22 +133,24 @@ def bulk_index_topics(topics, display_name_vectors, nested_description_vectors):
|
||||
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
|
||||
@@ -124,6 +176,8 @@ 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.")
|
||||
@@ -133,44 +187,50 @@ def main():
|
||||
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)
|
||||
all_texts_to_embed.append(desc)
|
||||
|
||||
print(f"Embedding {len(all_texts_to_embed)} texts (display names and description passages)...")
|
||||
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,7 @@ 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
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ class Settings(BaseSettings):
|
||||
llm_api_key: Optional[str] = None
|
||||
llm_model: 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
|
||||
|
||||
@@ -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.
|
||||
@@ -287,53 +296,70 @@ async def vector_search_topics(
|
||||
)
|
||||
|
||||
# 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
|
||||
}
|
||||
@@ -354,13 +380,6 @@ async def vector_search_topics(
|
||||
# 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]
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -24,4 +24,18 @@ export * from './topics.service';
|
||||
import { TopicsService } from './topics.service';
|
||||
export * from './works.service';
|
||||
import { WorksService } from './works.service';
|
||||
export const APIS = [CompanyConnectionsService, FundingService, INSEAccountServiceService, INSEServiceService, InstitutionsService, ItemsService, NewsService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, WorksService];
|
||||
export const APIS = [
|
||||
CompanyConnectionsService,
|
||||
FundingService,
|
||||
INSEAccountServiceService,
|
||||
INSEServiceService,
|
||||
InstitutionsService,
|
||||
ItemsService,
|
||||
NewsService,
|
||||
PatentsService,
|
||||
PersonNetworkService,
|
||||
PersonsService,
|
||||
ProjectsService,
|
||||
TopicsService,
|
||||
WorksService,
|
||||
];
|
||||
|
||||
+1003
-497
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,12 +9,18 @@
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams,
|
||||
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||
} from '@angular/common/http';
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import {
|
||||
HttpClient,
|
||||
HttpHeaders,
|
||||
HttpParams,
|
||||
HttpResponse,
|
||||
HttpEvent,
|
||||
HttpParameterCodec,
|
||||
HttpContext,
|
||||
} from '@angular/common/http';
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
@@ -22,74 +28,121 @@ import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
import { PatentsByAuthorResponse } from '../model/patentsByAuthorResponse';
|
||||
|
||||
// @ts-ignore
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { BaseService } from '../api.base.service';
|
||||
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PatentsService extends BaseService {
|
||||
constructor(
|
||||
protected httpClient: HttpClient,
|
||||
@Optional() @Inject(BASE_PATH) basePath: string | string[],
|
||||
@Optional() configuration?: Configuration,
|
||||
) {
|
||||
super(basePath, configuration);
|
||||
}
|
||||
|
||||
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) {
|
||||
super(basePath, configuration);
|
||||
/**
|
||||
* Get patents matched to an author by name.
|
||||
* @endpoint get /api/inse-service/authors/{author_id}/patents
|
||||
* @param authorId
|
||||
* @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?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<PatentsByAuthorResponse>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpResponse<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<HttpEvent<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(
|
||||
authorId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false,
|
||||
options?: {
|
||||
httpHeaderAccept?: 'application/json';
|
||||
context?: HttpContext;
|
||||
transferCache?: boolean;
|
||||
},
|
||||
): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error(
|
||||
'Required parameter authorId was null or undefined when calling getPatentsByAuthor.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get patents matched to an author by name.
|
||||
* @endpoint get /api/inse-service/authors/{author_id}/patents
|
||||
* @param authorId
|
||||
* @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?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<PatentsByAuthorResponse>;
|
||||
public getPatentsByAuthor(authorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(authorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<PatentsByAuthorResponse>>;
|
||||
public getPatentsByAuthor(authorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error('Required parameter authorId was null or undefined when calling getPatentsByAuthor.');
|
||||
}
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
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/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', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
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/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',
|
||||
`${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined
|
||||
? { transferCache: localVarTransferCache }
|
||||
: {}),
|
||||
reportProgress: reportProgress,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,27 +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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,23 +9,21 @@
|
||||
*/
|
||||
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>;
|
||||
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>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,23 +9,19 @@
|
||||
*/
|
||||
import { ProjectType } from './projectType';
|
||||
|
||||
|
||||
export interface FundingProject {
|
||||
/**
|
||||
* The type of the project.
|
||||
*/
|
||||
type: ProjectType;
|
||||
/**
|
||||
* The unique identifier of the project.
|
||||
*/
|
||||
id: string;
|
||||
title?: string | null;
|
||||
acronym?: string | null;
|
||||
start_date?: string | null;
|
||||
end_date?: string | null;
|
||||
funding_amount?: number | null;
|
||||
export interface FundingProject {
|
||||
/**
|
||||
* The type of the project.
|
||||
*/
|
||||
type: ProjectType;
|
||||
/**
|
||||
* The unique identifier of the project.
|
||||
*/
|
||||
id: string;
|
||||
title?: string | null;
|
||||
acronym?: string | null;
|
||||
start_date?: string | null;
|
||||
end_date?: string | null;
|
||||
funding_amount?: number | null;
|
||||
}
|
||||
export namespace FundingProject {
|
||||
}
|
||||
|
||||
|
||||
export namespace FundingProject {}
|
||||
|
||||
@@ -1,17 +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;
|
||||
export interface MentionedPerson {
|
||||
name: string;
|
||||
is_ude?: boolean;
|
||||
person_id?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +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;
|
||||
export interface NewsArticle {
|
||||
id: string;
|
||||
date?: string | null;
|
||||
maintitle?: string | null;
|
||||
author?: string | null;
|
||||
url?: string | null;
|
||||
relevant?: boolean | null;
|
||||
snippet?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,16 +9,14 @@
|
||||
*/
|
||||
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>;
|
||||
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>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,11 +9,9 @@
|
||||
*/
|
||||
import { NewsArticle } from './newsArticle';
|
||||
|
||||
|
||||
export interface NewsPage {
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
results: Array<NewsArticle>;
|
||||
export interface NewsPage {
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
results: Array<NewsArticle>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,11 +9,9 @@
|
||||
*/
|
||||
import { PatentEntry } from './patentEntry';
|
||||
|
||||
|
||||
export interface PatentsByAuthorResponse {
|
||||
author_id: string;
|
||||
author_name?: string | null;
|
||||
patent_count: number;
|
||||
patents: Array<PatentEntry>;
|
||||
export interface PatentsByAuthorResponse {
|
||||
author_id: string;
|
||||
author_name?: string | null;
|
||||
patent_count: number;
|
||||
patents: Array<PatentEntry>;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,9 +75,7 @@
|
||||
undefined
|
||||
" />
|
||||
<app-person-network-info-card
|
||||
[description]="
|
||||
'Durchschnittliche jährliche Förderung durch die Europäische Union'
|
||||
"
|
||||
[description]="'Durchschnittliche jährliche Förderung durch die Europäische Union'"
|
||||
[value]="
|
||||
(euAverageAnnualFunding()
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de') ?? undefined
|
||||
|
||||
@@ -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,43 @@
|
||||
(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>
|
||||
</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 +59,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 +77,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,11 +231,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,51 @@ 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 '';
|
||||
});
|
||||
|
||||
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 +120,7 @@ export class PersonCardComponent {
|
||||
return path;
|
||||
}
|
||||
|
||||
getDistinguishingId(person: CustomAuthor): string {
|
||||
if (!person) return '';
|
||||
if (person.orcid) {
|
||||
return person.orcid.replace('https://orcid.org/', '');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
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 '';
|
||||
}
|
||||
|
||||
toggleBookmark(): void {
|
||||
this.bookmarkToggle.emit(this.person);
|
||||
this.bookmarkToggle.emit(this.person());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
>
|
||||
|
||||
@@ -159,6 +159,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +267,14 @@ mat-paginator {
|
||||
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;
|
||||
@@ -307,12 +323,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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -7,10 +7,9 @@ import {
|
||||
} from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const cordisEuProjectPageResolver: ResolveFn<EuOrganizationProjectSummaryPage> = (
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user