feature/keywords-analysis #228
@@ -0,0 +1,341 @@
|
||||
from typing import Any, Iterator
|
||||
from elasticsearch import Elasticsearch
|
||||
from collections import defaultdict
|
||||
import json
|
||||
from pathlib import Path
|
||||
from elasticsearch import NotFoundError
|
||||
# elasticseach library required. Here used elasticsearch==8.0.0
|
||||
# estimated execution time: 3-5 Minutes
|
||||
|
||||
def remove_year(patent_number: str) -> str:
|
||||
"""Remove a leading 4-digit year from the front of a patent number, if present.
|
||||
|
||||
Only strips the first 4 characters when they are all digits (i.e. actually
|
||||
look like a year). Otherwise the ID is returned unchanged.
|
||||
"""
|
||||
prefix = patent_number[:4]
|
||||
if len(patent_number) > 4 and prefix.isdigit():
|
||||
return patent_number[4:]
|
||||
return patent_number
|
||||
|
||||
|
||||
class PatentCounter:
|
||||
def __init__(
|
||||
self,
|
||||
source_es: Elasticsearch,
|
||||
target_es: Elasticsearch,
|
||||
source_index: str,
|
||||
results_file: str = "patent_matches.json",
|
||||
):
|
||||
self.source_es = source_es
|
||||
self.target_es = target_es
|
||||
self.source_index = source_index
|
||||
self.results_file = Path(results_file)
|
||||
|
||||
self.match_stats = defaultdict(int)
|
||||
|
||||
def _build_variations_uspto(self, patent_id: str) -> dict[str, str]:
|
||||
raw_id = patent_id.upper().removeprefix("US")
|
||||
no_year = remove_year(raw_id)
|
||||
|
||||
return {
|
||||
"publication_number": raw_id,
|
||||
"publication_number_no_year": no_year,
|
||||
"application_number": raw_id,
|
||||
"application_number_no_year": no_year,
|
||||
}
|
||||
|
||||
def _build_variations_epo(self, patent_id: str) -> dict[str, str]:
|
||||
raw_id = patent_id.upper().removeprefix("EP")
|
||||
no_year = remove_year(raw_id)
|
||||
|
||||
return {
|
||||
"doc_number": raw_id,
|
||||
"doc_number_no_year": no_year,
|
||||
"application_number": raw_id,
|
||||
"application_number_no_year": no_year,
|
||||
}
|
||||
|
||||
def _uspto_query_by_id(
|
||||
self,
|
||||
patent_id: str,
|
||||
size: int = 100,
|
||||
) -> dict[str, Any]:
|
||||
variations = self._build_variations_uspto(patent_id)
|
||||
body = {
|
||||
"size": size,
|
||||
"track_total_hits": True,
|
||||
"_source": [
|
||||
"publication_number",
|
||||
"application_number",
|
||||
"title",
|
||||
],
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"term": {"publication_number": variations["publication_number"]}},
|
||||
{"term": {"publication_number": variations["publication_number_no_year"]}},
|
||||
{"term": {"application_number": variations["application_number"]}},
|
||||
{"term": {"application_number": variations["application_number_no_year"]}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
}
|
||||
#print(f"USPTO query for {patent_id}: {json.dumps(body)}") # Debugging line
|
||||
return body
|
||||
|
||||
def _epo_query_by_id(
|
||||
self,
|
||||
patent_id: str,
|
||||
size: int = 100,
|
||||
) -> dict[str, Any]:
|
||||
variations = self._build_variations_epo(patent_id)
|
||||
body = {
|
||||
"size": size,
|
||||
"track_total_hits": True,
|
||||
"_source": [
|
||||
"doc_number",
|
||||
"application_number",
|
||||
"title_en",
|
||||
"title_fr",
|
||||
"title_de",
|
||||
],
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"term": {"doc_number": variations["doc_number"]}},
|
||||
{"term": {"application_number": variations["application_number"]}},
|
||||
{"term": {"doc_number": variations["doc_number_no_year"]}},
|
||||
{"term": {"application_number": variations["application_number_no_year"]}},
|
||||
{"wildcard": {
|
||||
"application_number": {
|
||||
"value": f"{variations['application_number']}*"
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
}
|
||||
#print(f"EP query for {patent_id}: {json.dumps(body)}") # Debugging line
|
||||
return body
|
||||
|
||||
def _scroll_all(self, query: dict) -> Iterator[dict]:
|
||||
"""Run a scroll query to completion, yielding each hit's _source,
|
||||
and always clearing the scroll context when done."""
|
||||
resp = self.source_es.search(
|
||||
index=self.source_index,
|
||||
body=query,
|
||||
scroll="5m",
|
||||
size=10000,
|
||||
)
|
||||
scroll_id = resp.get("_scroll_id")
|
||||
|
||||
try:
|
||||
while True:
|
||||
hits = resp["hits"]["hits"]
|
||||
if not hits:
|
||||
break
|
||||
|
||||
for hit in hits:
|
||||
yield hit["_source"]
|
||||
|
||||
try:
|
||||
resp = self.source_es.scroll(scroll_id=scroll_id, scroll="5m")
|
||||
scroll_id = resp.get("_scroll_id")
|
||||
except NotFoundError:
|
||||
break
|
||||
finally:
|
||||
if scroll_id:
|
||||
try:
|
||||
self.source_es.clear_scroll(scroll_id=scroll_id)
|
||||
except Exception:
|
||||
pass # best-effort cleanup, don't fail the run over this
|
||||
|
||||
def get_source_docs(self) -> Iterator[dict]:
|
||||
"""
|
||||
Yield source docs (with applicationIdentifier, applicationPrefix, title) in order:
|
||||
1. All EP patents (applicationPrefix: "EP")
|
||||
2. Then all USPTO patents (applicationPrefix: "US")
|
||||
"""
|
||||
query_ep = {
|
||||
"_source": ["applicationIdentifier", "applicationPrefix", "title"],
|
||||
"query": {"term": {"applicationPrefix": "EP"}},
|
||||
}
|
||||
query_us = {
|
||||
"_source": ["applicationIdentifier", "applicationPrefix", "title"],
|
||||
"query": {"term": {"applicationPrefix": "US"}},
|
||||
}
|
||||
|
||||
for source in self._scroll_all(query_ep):
|
||||
if source.get("applicationIdentifier"):
|
||||
yield source
|
||||
|
||||
for source in self._scroll_all(query_us):
|
||||
if source.get("applicationIdentifier"):
|
||||
yield source
|
||||
|
||||
def find_matches(self, patent_id: str, source_prefix: str, source_title: str) -> dict:
|
||||
"""Match a single source patent against the target indexes.
|
||||
|
||||
source_prefix/source_title are passed in from get_source_docs() rather
|
||||
than being re-fetched here, avoiding a redundant query per record and
|
||||
the IndexError that occurred when a fetch found no hits.
|
||||
"""
|
||||
variations_uspto = self._build_variations_uspto(patent_id)
|
||||
variations_epo = self._build_variations_epo(patent_id)
|
||||
raw_id_epo = patent_id.upper().removeprefix("EP")
|
||||
|
||||
matches = []
|
||||
matched_indexes = set()
|
||||
|
||||
# EP PATENTS -> Only match in EPO index
|
||||
if source_prefix == "EP":
|
||||
epo_resp = self.target_es.search(
|
||||
index="epo_index_1.0",
|
||||
body=self._epo_query_by_id(patent_id),
|
||||
)
|
||||
epo_hits = epo_resp["hits"]["hits"]
|
||||
|
||||
for hit in epo_hits:
|
||||
source = hit["_source"]
|
||||
|
||||
matched_field = None
|
||||
if source.get("doc_number") == raw_id_epo:
|
||||
matched_field = "doc_number"
|
||||
elif source.get("doc_number") == variations_epo["doc_number_no_year"]:
|
||||
matched_field = "doc_number_no_year"
|
||||
|
||||
matched_field_app = None
|
||||
if source.get("application_number") == raw_id_epo:
|
||||
matched_field_app = "application_number"
|
||||
elif source.get("application_number") == variations_epo["application_number_no_year"]:
|
||||
matched_field_app = "application_number_no_year"
|
||||
elif source.get("application_number", "").startswith(variations_epo["application_number"]):
|
||||
matched_field_app = "application_number_wildcard"
|
||||
matched_fields = [f for f in (matched_field, matched_field_app) if f]
|
||||
|
||||
for field in matched_fields:
|
||||
self.match_stats[f"epo:{field}"] += 1
|
||||
|
||||
all_ids = {
|
||||
"doc_number": source.get("doc_number"),
|
||||
"application_number": source.get("application_number"),
|
||||
}
|
||||
|
||||
matches.append({
|
||||
"index": "epo_index_1.0",
|
||||
"field": field,
|
||||
"doc_id": hit["_id"],
|
||||
"title_en": source.get("title_en"),
|
||||
"title_fr": source.get("title_fr"),
|
||||
"title_de": source.get("title_de"),
|
||||
"all_ids": all_ids,
|
||||
})
|
||||
|
||||
if epo_hits:
|
||||
matched_indexes.add("epo_index_1.0")
|
||||
|
||||
# US PATENTS -> Only match in USPTO index
|
||||
elif source_prefix == "US":
|
||||
uspto_resp = self.target_es.search(
|
||||
index="uspto_patents_3.0",
|
||||
body=self._uspto_query_by_id(patent_id),
|
||||
)
|
||||
uspto_hits = uspto_resp["hits"]["hits"]
|
||||
|
||||
for hit in uspto_hits:
|
||||
source = hit["_source"]
|
||||
pub = source.get("publication_number")
|
||||
app = source.get("application_number")
|
||||
|
||||
matched_field_pub = None
|
||||
if pub == variations_uspto["publication_number"]:
|
||||
matched_field_pub = "publication_number"
|
||||
elif pub == variations_uspto["publication_number_no_year"]:
|
||||
matched_field_pub = "publication_number_no_year"
|
||||
|
||||
matched_field_app = None
|
||||
if app == variations_uspto["application_number"]:
|
||||
matched_field_app = "application_number"
|
||||
elif app == variations_uspto["application_number_no_year"]:
|
||||
matched_field_app = "application_number_no_year"
|
||||
|
||||
matched_fields = [f for f in (matched_field_pub, matched_field_app) if f]
|
||||
|
||||
for field in matched_fields:
|
||||
self.match_stats[f"uspto:{field}"] += 1
|
||||
|
||||
matches.append({
|
||||
"index": "uspto_patents_3.0",
|
||||
"field": field,
|
||||
"doc_id": hit["_id"],
|
||||
"title": source.get("title"),
|
||||
})
|
||||
|
||||
if uspto_hits:
|
||||
matched_indexes.add("uspto_patents_3.0")
|
||||
|
||||
return {
|
||||
"source_id": patent_id,
|
||||
"source_prefix": source_prefix,
|
||||
"source_title": source_title,
|
||||
"found": len(matches) > 0,
|
||||
"matches": matches,
|
||||
"not_found_in": [
|
||||
idx for idx in ("epo_index_1.0", "uspto_patents_3.0")
|
||||
if idx not in matched_indexes
|
||||
],
|
||||
}
|
||||
|
||||
def count_matches(self):
|
||||
total = 0
|
||||
matched = 0
|
||||
all_results = []
|
||||
|
||||
for source_doc in self.get_source_docs():
|
||||
patent_id = source_doc["applicationIdentifier"]
|
||||
source_prefix = source_doc.get("applicationPrefix", "")
|
||||
source_title = source_doc.get("title", "")
|
||||
|
||||
total += 1
|
||||
result = self.find_matches(patent_id, source_prefix, source_title)
|
||||
|
||||
if result["found"]:
|
||||
matched += 1
|
||||
|
||||
all_results.append(result)
|
||||
|
||||
if total % 1000 == 0:
|
||||
print(f"Processed={total:,}, Matched={matched:,}")
|
||||
with open(self.results_file, "w") as f:
|
||||
json.dump(all_results, f, indent=2)
|
||||
|
||||
# Final save
|
||||
with open(self.results_file, "w") as f:
|
||||
json.dump(all_results, f, indent=2)
|
||||
|
||||
return total, matched
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
source_es = Elasticsearch('https://inse.nes.uni-due.de:443/elastic', basic_auth=('elastic', 'RLldUaJgbGeoqd3KCX3p'), request_timeout=60, max_retries=5, retry_on_timeout=True)
|
||||
|
||||
counter = PatentCounter(
|
||||
source_es=source_es,
|
||||
target_es=source_es,
|
||||
source_index="cordis_eu_fp7_project_iprs",
|
||||
results_file="patent_matches.json",
|
||||
)
|
||||
|
||||
total, matched = counter.count_matches()
|
||||
|
||||
print(f"Total IDs: {total:,}")
|
||||
print(f"Matched source IDs: {matched:,}")
|
||||
print(f"Not found: {total - matched:,}")
|
||||
|
||||
print("\nMatch statistics:")
|
||||
for key, count in sorted(counter.match_stats.items()):
|
||||
print(f"{key}: {count:,}")
|
||||
@@ -0,0 +1,77 @@
|
||||
Here’s a shorter, more concise version:
|
||||
|
||||
# Patent Matching Pipeline — CORDIS FP7 IPR Records ↔ EPO / USPTO
|
||||
|
||||
## Purpose
|
||||
|
||||
This pipeline validates FP7 patent records from CORDIS against external patent databases:
|
||||
|
||||
- **EPO index (`epo_index_1.0`)** for `EP` patents
|
||||
- **USPTO index (`uspto_patents_3.0`)** for `US` patents
|
||||
|
||||
The objective is to measure match coverage and determine which ID-matching strategies are reliable for downstream patent linking.
|
||||
|
||||
## Dataset
|
||||
|
||||
Source: `cordis_eu_fp7_project_iprs`
|
||||
Patents tested: 5196(total) - 2270(others) -> 2926 (EP and US patents)
|
||||
| Prefix | Count |
|
||||
| --------- | --------: |
|
||||
| EP | 1,952 |
|
||||
| US | 974 |
|
||||
| **Total** | **2,926** |
|
||||
|
||||
## Matching Strategies
|
||||
|
||||
### EPO
|
||||
|
||||
- `doc_number`: exact, no-year
|
||||
- `application_number`: exact, no-year, wildcard (`{id}*`)
|
||||
|
||||
### USPTO
|
||||
|
||||
- `application_number`: exact, no-year
|
||||
- `publication_number`: exact, no-year
|
||||
|
||||
Matching priority: **exact → no-year → wildcard** (first match wins).
|
||||
|
||||
## Results
|
||||
|
||||
| Metric | Count |
|
||||
| ----------- | ----: |
|
||||
| Total IDs | 2,926 |
|
||||
| Matched IDs | 1,713 |
|
||||
| Not Found | 1,213 |
|
||||
|
||||
### Match Counts by Field
|
||||
|
||||
| Field | Hits |
|
||||
| ---------------------------------- | ----: |
|
||||
| `epo:application_number_wildcard` | 1,864 |
|
||||
| `epo:doc_number` | 7 |
|
||||
| `uspto:application_number_no_year` | 564 |
|
||||
| `uspto:application_number` | 6 |
|
||||
|
||||
No matches were found for:
|
||||
|
||||
- `epo:application_number` (exact/no-year)
|
||||
- `epo:doc_number_no_year`
|
||||
- `uspto:publication_number` (exact/no-year)
|
||||
|
||||
## Findings
|
||||
|
||||
### EPO
|
||||
|
||||
| Strategy | Assessment |
|
||||
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `doc_number` | ❌ Unreliable; often matches unrelated patents |
|
||||
| `application_number` exact/no-year | ⚠️ No matches |
|
||||
| `application_number` wildcard (APPROVED) | ⚠️ Best coverage (1,864 hits) but over-matches related filings; requires secondary validation (e.g., title similarity) |
|
||||
|
||||
### USPTO
|
||||
|
||||
| Strategy | Assessment |
|
||||
| --------------------------------------- | --------------------------------------- |
|
||||
| `application_number` exact | ❌ Unreliable; numbering formats differ |
|
||||
| `application_number_no_year` (APPROVED) | ✅ Reliable (564 matches) |
|
||||
| `publication_number` | No useful matches |
|
||||
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,8 @@ class ESIndex(StrEnum):
|
||||
|
||||
PROJECTS_BUND_V1 = "projects_bund_v1"
|
||||
PROJECTS_DFG_ALL = "dfg_projects_2.0"
|
||||
PROJECTS_DFG_PERSONS = "dfg_persons_2.0"
|
||||
PROJECTS_DFG_INSTITUTES = "dfg_institutes_2.0"
|
||||
|
||||
CORDIS_EU_ORGANIZATIONS_WILDCARD = "cordis_eu_*_organizations"
|
||||
CORDIS_EU_PROJECTS_WILDCARD = "cordis_eu_*_projects"
|
||||
|
||||
@@ -118,7 +118,7 @@ def _parse_patent_id(patent_id: str) -> tuple[str, str]:
|
||||
async def _search_by_id(
|
||||
client: AllPatentsSearchClient,
|
||||
patent_id: str,
|
||||
filling_date: str | None = None,
|
||||
title: str | None = None,
|
||||
) -> list[model.PatentEntry]:
|
||||
try:
|
||||
source, number = _parse_patent_id(patent_id)
|
||||
@@ -126,28 +126,27 @@ async def _search_by_id(
|
||||
return []
|
||||
|
||||
if source == "EPO":
|
||||
data = await client.search_epo(client.epo_detail_query(number, filling_date))
|
||||
data = await client.search_epo(client.epo_detail_query(number, title))
|
||||
return parse_epo_hits(data)
|
||||
data = await client.search_uspto(client.uspto_detail_query(number, filling_date))
|
||||
data = await client.search_uspto(client.uspto_detail_query(number))
|
||||
return parse_uspto_hits(data)
|
||||
|
||||
|
||||
async def _search_by_title(
|
||||
client: AllPatentsSearchClient,
|
||||
title: str,
|
||||
filling_date: str | None = None,
|
||||
prefix: str | None = None,
|
||||
) -> list[model.PatentEntry]:
|
||||
if prefix and prefix.upper() == "US":
|
||||
data = await client.search_uspto(client.uspto_title_query(title, filling_date))
|
||||
data = await client.search_uspto(client.uspto_title_query(title))
|
||||
return parse_uspto_hits(data)
|
||||
if prefix and prefix.upper() == "EP":
|
||||
data = await client.search_epo(client.epo_title_query(title, filling_date))
|
||||
data = await client.search_epo(client.epo_title_query(title))
|
||||
return parse_epo_hits(data)
|
||||
|
||||
epo_data, uspto_data = await asyncio.gather(
|
||||
client.search_epo(client.epo_title_query(title, filling_date)),
|
||||
client.search_uspto(client.uspto_title_query(title, filling_date)),
|
||||
client.search_epo(client.epo_title_query(title)),
|
||||
client.search_uspto(client.uspto_title_query(title)),
|
||||
)
|
||||
return parse_epo_hits(epo_data) + parse_uspto_hits(uspto_data)
|
||||
|
||||
@@ -156,29 +155,23 @@ async def get_patent_by_id(
|
||||
patent_id: str,
|
||||
prefix: str | None = None,
|
||||
title: str | None = None,
|
||||
filling_date: str | None = None,
|
||||
ipc_client: IpcSearchClient | None = None,
|
||||
) -> model.PatentEntry:
|
||||
all_patents_client = AllPatentsSearchClient()
|
||||
ipc_search_client = ipc_client or IpcSearchClient()
|
||||
normalized_filling_date = (
|
||||
_normalize_patent_date(filling_date) if filling_date else None
|
||||
)
|
||||
|
||||
lookup_id = patent_id
|
||||
if prefix and not patent_id.upper().startswith(prefix.upper()):
|
||||
lookup_id = f"{prefix.upper()}{patent_id}"
|
||||
|
||||
try:
|
||||
patents = await _search_by_id(
|
||||
all_patents_client, lookup_id, normalized_filling_date
|
||||
all_patents_client, lookup_id,
|
||||
)
|
||||
|
||||
if not patents and title:
|
||||
patents = await _search_by_title(
|
||||
all_patents_client,
|
||||
title,
|
||||
normalized_filling_date,
|
||||
prefix,
|
||||
)
|
||||
|
||||
|
||||
@@ -45,11 +45,9 @@ async def get_patent_by_identifier(
|
||||
identifier: str,
|
||||
prefix: str | None = None,
|
||||
title: str | None = None,
|
||||
filling_date: str | None = None,
|
||||
):
|
||||
return await logic.get_patent_by_id(
|
||||
patent_id=identifier,
|
||||
prefix=prefix,
|
||||
title=title,
|
||||
filling_date=filling_date,
|
||||
)
|
||||
|
||||
@@ -152,21 +152,28 @@ class AllPatentsSearchClient:
|
||||
"query": query,
|
||||
}
|
||||
|
||||
def epo_detail_query(self, doc_number: str,filling_date: str | None = None) -> dict[str, Any]:
|
||||
def epo_detail_query(self, doc_number: str, title: str | None = None) -> dict[str, Any]:
|
||||
query: dict[str, Any] = {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"wildcard": { #eu cordis patents compatibility
|
||||
"application_number": {
|
||||
"value": f"{doc_number}*"
|
||||
}
|
||||
}
|
||||
},
|
||||
{"term": {"doc_number": doc_number}},
|
||||
{"term": {"doc_number": self.remove_year(doc_number)}},
|
||||
{"term": {"application_number": self.remove_year(doc_number)}},
|
||||
{"term": {"application_number": doc_number}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
if filling_date:
|
||||
query["bool"]["must"] = [{"term": {"application_filing_date": filling_date}}]
|
||||
|
||||
if title: #eu cordis patents compatibility
|
||||
query["bool"]["should"].append(
|
||||
{"match": {"title_en": title}}
|
||||
)
|
||||
query["bool"]["should"].append(
|
||||
{"match": {"title_de": title}}
|
||||
)
|
||||
return {
|
||||
"size": 1,
|
||||
"_source": [
|
||||
@@ -178,21 +185,16 @@ class AllPatentsSearchClient:
|
||||
"query": query,
|
||||
}
|
||||
|
||||
def uspto_detail_query(self, number: str,filling_date: str | None = None) -> dict[str, Any]:
|
||||
def uspto_detail_query(self, number: str) -> dict[str, Any]:
|
||||
query: dict[str, Any] = {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"term": {"publication_number": number}},
|
||||
{"term": {"publication_number": self.remove_year(number)}},
|
||||
{"term": {"application_number": number}},
|
||||
{"term": {"application_number": self.remove_year(number)}},
|
||||
{"term": {"application_number": self.remove_year(number)}}, #eu cordis patents compatibility
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
if filling_date:
|
||||
query["bool"]["must"] = [{"term": {"application_date": filling_date}}]
|
||||
|
||||
return {
|
||||
"size": 1,
|
||||
"_source": [
|
||||
@@ -204,7 +206,7 @@ class AllPatentsSearchClient:
|
||||
"query": query,
|
||||
}
|
||||
|
||||
def epo_title_query(self, title: str,filling_date: str | None = None) -> dict[str, Any]:
|
||||
def epo_title_query(self, title: str) -> dict[str, Any]:
|
||||
query: dict[str, Any] = {
|
||||
"bool": {
|
||||
"should": [
|
||||
@@ -214,9 +216,6 @@ class AllPatentsSearchClient:
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
if filling_date:
|
||||
query["bool"]["must"] = [{"term": {"application_filing_date": filling_date}}]
|
||||
|
||||
return {
|
||||
"size": 1,
|
||||
"_source": [
|
||||
@@ -228,16 +227,13 @@ class AllPatentsSearchClient:
|
||||
"query": query,
|
||||
}
|
||||
|
||||
def uspto_title_query(self, title: str,filling_date: str | None = None) -> dict[str, Any]:
|
||||
def uspto_title_query(self, title: str) -> dict[str, Any]:
|
||||
query: dict[str, Any] = {
|
||||
"bool": {
|
||||
"should": [{"match_phrase": {"title": title}}],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
if filling_date:
|
||||
query["bool"]["must"] = [{"term": {"application_date": filling_date}}]
|
||||
|
||||
return {
|
||||
"size": 1,
|
||||
"_source": [
|
||||
|
||||
@@ -87,18 +87,17 @@ async def find_ude_author_by_name(display_name: str) -> Optional[dict]:
|
||||
"display_name": hit.get("_source", {}).get("display_name"),
|
||||
}
|
||||
|
||||
|
||||
async def get_author_name_by_id(author_id: str) -> Optional[str]:
|
||||
try:
|
||||
query = {
|
||||
"_source": ["id", "display_name"],
|
||||
"query": {
|
||||
"term": {"id": {"value": f"https://openalex.org/{author_id.upper()}"}}
|
||||
"terms": {"id": [f"https://openalex.org/{author_id.upper()}"]}
|
||||
},
|
||||
"size": 1,
|
||||
}
|
||||
|
||||
data = await elasticsearch.search(index=INDEX_NAME, body=query)
|
||||
data = await elasticsearch.search(index=ESIndex.OPENALEX_AUTHORS, body=query)
|
||||
hits = data.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
return None
|
||||
@@ -107,7 +106,6 @@ async def get_author_name_by_id(author_id: str) -> Optional[str]:
|
||||
logger.exception(f"Error fetching author name for id {author_id}: {str(e)}")
|
||||
return None
|
||||
|
||||
|
||||
async def search_persons(
|
||||
author_id: Optional[str] = None,
|
||||
query: Optional[str] = None,
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
import urllib
|
||||
from inse.config import get_settings
|
||||
from inse.models.bund_project import BundProject
|
||||
from inse.projects.model import (
|
||||
BundProjectPage,
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
DfgProjectSummary,
|
||||
EuOrganizationProjectSummary,
|
||||
EuOrganizationProjectSummaryPage,
|
||||
EuOrganizationShort,
|
||||
EuProjectShort,
|
||||
FundingProject,
|
||||
FundingProjectPage,
|
||||
ProjectType,
|
||||
ProjectsFilteringProperties,
|
||||
ProjectsSortBy,
|
||||
SortDirection,
|
||||
)
|
||||
from inse.projects.eu_cordis_projects_enrichment_client import get_enriched_cordis_project_by_id
|
||||
from inse.models.dfg_project_details import DfgProjectDetails
|
||||
from inse.models.bund_project_details import BundProjectDetails
|
||||
from inse.models.cordis_eu_project import CordisEuProject
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESCluster, ESIndex
|
||||
from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails
|
||||
from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails
|
||||
from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails
|
||||
from typing import Union
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def get_dfg_author_names_by_ids(author_ids: List[str]) -> Optional[List[str]]:
|
||||
try:
|
||||
body = {
|
||||
"_source": ["id", "full_name"],
|
||||
"query": {
|
||||
"terms": {"id": [author_id for author_id in author_ids]}
|
||||
},
|
||||
"size": len(author_ids),
|
||||
}
|
||||
print(body)
|
||||
data = await elasticsearch.search(index=ESIndex.PROJECTS_DFG_PERSONS, body=body, cluster=ESCluster.INSE)
|
||||
hits = data.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
return []
|
||||
return [hit.get("_source", {}).get("full_name") for hit in hits]
|
||||
except Exception as e:
|
||||
logger.exception(f"Error fetching author names for ids {author_ids}: {str(e)}")
|
||||
return []
|
||||
|
||||
async def get_dfg_institution_names_by_ids(institution_ids: List[str]) -> Optional[List[str]]:
|
||||
try:
|
||||
body = {
|
||||
"_source": ["id","institute_name_de","institute_name_en"],
|
||||
"query": {
|
||||
"terms": {"id": [institution_id for institution_id in institution_ids]}
|
||||
},
|
||||
"size": len(institution_ids),
|
||||
}
|
||||
|
||||
data = await elasticsearch.search(index=ESIndex.PROJECTS_DFG_INSTITUTES, body=body, cluster=ESCluster.INSE)
|
||||
hits = data.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
return []
|
||||
return [hit.get("_source", {}).get("institute_name_de") or hit.get("_source", {}).get("institute_name_en") for hit in hits]
|
||||
except Exception as e:
|
||||
logger.exception(f"Error fetching institution names for ids {institution_ids}: {str(e)}")
|
||||
return []
|
||||
|
||||
async def get_person_ids_by_institution_names(
|
||||
institution_names: list[str],
|
||||
) -> list[int]:
|
||||
cleaned_names = [
|
||||
name.strip()
|
||||
for name in institution_names
|
||||
if name and name.strip()
|
||||
]
|
||||
|
||||
if not cleaned_names:
|
||||
return []
|
||||
|
||||
institution_fields = [
|
||||
"institute_name_de",
|
||||
"institute_name_en",
|
||||
"root_name_de",
|
||||
"root_name_en",
|
||||
]
|
||||
|
||||
should_clauses = []
|
||||
|
||||
for name in cleaned_names:
|
||||
for field in institution_fields:
|
||||
should_clauses.append(
|
||||
{
|
||||
"match_phrase": {
|
||||
field: name
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_PERSONS,
|
||||
cluster=ESCluster.INSE,
|
||||
body={
|
||||
"size": 10000,
|
||||
"_source": ["person_id"],
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": should_clauses,
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return list(
|
||||
{
|
||||
hit["_source"]["person_id"]
|
||||
for hit in response.get("hits", {}).get("hits", [])
|
||||
if hit.get("_source", {}).get("person_id") is not None
|
||||
}
|
||||
)
|
||||
@@ -84,55 +84,156 @@ class EuProjectPage(Page):
|
||||
elements: List[EuProject] = Field(
|
||||
default_factory=list, description="The EU projects on this page."
|
||||
)
|
||||
|
||||
class DfgInstitutionSummary(BaseModel):
|
||||
id: int
|
||||
name_de: Optional[str] = None
|
||||
name_en: Optional[str] = None
|
||||
|
||||
class DfgPersonSummary(BaseModel):
|
||||
person_id: int
|
||||
project_ref_id: int
|
||||
full_name: Optional[str] = None
|
||||
role_label_en: Optional[str] = None,
|
||||
role_label_de: Optional[str] = None,
|
||||
root_institution: Optional[DfgInstitutionSummary] = None,
|
||||
institution: Optional[DfgInstitutionSummary] = None
|
||||
|
||||
|
||||
|
||||
class DfgProjectSummary(BaseModel):
|
||||
id: str = Field(description="The unique identifier of the DFG project.")
|
||||
id: str = Field(
|
||||
description="The unique identifier of the DFG project."
|
||||
)
|
||||
|
||||
link: Optional[str] = Field(
|
||||
default=None, description="The link to the DFG project details."
|
||||
default=None,
|
||||
description="The link to the DFG project details."
|
||||
)
|
||||
|
||||
title: Optional[str] = Field(
|
||||
default=None, description="The title of the DFG project."
|
||||
default=None,
|
||||
description="The title of the DFG project."
|
||||
)
|
||||
|
||||
professional_classification: Optional[str] = Field(
|
||||
default=None, description="The professional classification of the DFG project."
|
||||
default=None,
|
||||
description="The professional classification of the DFG project."
|
||||
)
|
||||
|
||||
|
||||
funding_start: Optional[str] = Field(
|
||||
default=None, description="The funding start date of the DFG project."
|
||||
default=None,
|
||||
description="The funding start date of the DFG project."
|
||||
)
|
||||
|
||||
funding_end: Optional[str] = Field(
|
||||
default=None, description="The funding end date of the DFG project."
|
||||
default=None,
|
||||
description="The funding end date of the DFG project."
|
||||
)
|
||||
|
||||
root_institutions: List[DfgInstitutionSummary] = Field(
|
||||
default_factory=list,
|
||||
description=(
|
||||
"Root institutions associated with the project "
|
||||
"(e.g. universities or umbrella organizations)."
|
||||
),
|
||||
)
|
||||
|
||||
institutions: List[DfgInstitutionSummary] = Field(
|
||||
default_factory=list,
|
||||
description="Institutions associated with the project."
|
||||
)
|
||||
names: List[str] = Field(
|
||||
default_factory=list,
|
||||
description="The names of the researchers involved in the DFG project.",
|
||||
description="The names of the persons involved in the DFG project.",
|
||||
)
|
||||
persons: List[DfgPersonSummary] = Field(
|
||||
default_factory=list,
|
||||
description="The persons involved in the DFG project.",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
||||
source = hit.get("_source", {})
|
||||
fields = hit.get("fields", {})
|
||||
|
||||
# Extract names from nested persons array
|
||||
names = []
|
||||
institutions = {}
|
||||
root_institutions = {}
|
||||
project_persons = []
|
||||
|
||||
persons = source.get("persons", [])
|
||||
|
||||
if isinstance(persons, list):
|
||||
for p in persons:
|
||||
if isinstance(p, dict):
|
||||
full_name = p.get("full_name")
|
||||
if full_name:
|
||||
names.append(full_name.strip())
|
||||
if not names:
|
||||
names = fields.get("all_found_names", [])
|
||||
for person in persons:
|
||||
if not isinstance(person, dict):
|
||||
continue
|
||||
|
||||
full_name = person.get("full_name")
|
||||
|
||||
if full_name:
|
||||
names.append(full_name.strip())
|
||||
|
||||
institution = None
|
||||
if person.get("institute_id") is not None:
|
||||
institution = DfgInstitutionSummary(
|
||||
id=person["institute_id"],
|
||||
name_de=person.get("institute_name_de"),
|
||||
name_en=person.get("institute_name_en"),
|
||||
)
|
||||
|
||||
institutions[person["institute_id"]] = institution
|
||||
|
||||
root_institution = None
|
||||
if person.get("root_id") is not None:
|
||||
root_institution = DfgInstitutionSummary(
|
||||
id=person["root_id"],
|
||||
name_de=person.get("root_name_de"),
|
||||
name_en=person.get("root_name_en"),
|
||||
)
|
||||
|
||||
root_institutions[person["root_id"]] = root_institution
|
||||
|
||||
if person.get("person_id") is not None:
|
||||
project_persons.append(
|
||||
DfgPersonSummary(
|
||||
person_id=person["person_id"],
|
||||
project_ref_id=person.get("project_ref_id"),
|
||||
full_name=full_name,
|
||||
role_label_en=person.get("role_label_en"),
|
||||
role_label_de=person.get("role_label_de"),
|
||||
root_institution=root_institution,
|
||||
institution=institution,
|
||||
)
|
||||
)
|
||||
|
||||
return cls(
|
||||
id=hit.get("_id", ""),
|
||||
link=source.get("link") or source.get("page_url"),
|
||||
title=source.get("title") or source.get("title_de") or source.get("title_en"),
|
||||
professional_classification=source.get("Fachliche Zuordnung") or source.get("subject_area_de") or source.get("subject_area_en"),
|
||||
funding_start=str(source.get("funding_start")) if source.get("funding_start") is not None else None,
|
||||
funding_end=str(source.get("funding_end")) if source.get("funding_end") is not None else None,
|
||||
title=(
|
||||
source.get("title")
|
||||
or source.get("title_de")
|
||||
or source.get("title_en")
|
||||
),
|
||||
professional_classification=(
|
||||
source.get("Fachliche Zuordnung")
|
||||
or source.get("subject_area_de")
|
||||
or source.get("subject_area_en")
|
||||
),
|
||||
funding_start=(
|
||||
str(source.get("funding_start"))
|
||||
if source.get("funding_start") is not None
|
||||
else None
|
||||
),
|
||||
funding_end=(
|
||||
str(source.get("funding_end"))
|
||||
if source.get("funding_end") is not None
|
||||
else None
|
||||
),
|
||||
root_institutions=list(root_institutions.values()),
|
||||
institutions=list(institutions.values()),
|
||||
names=names,
|
||||
persons=project_persons,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ from inse.model import ESCluster, ESIndex
|
||||
from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails
|
||||
from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails
|
||||
from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails
|
||||
from inse.projects.logic import get_person_ids_by_institution_names
|
||||
from typing import Union
|
||||
settings = get_settings()
|
||||
|
||||
@@ -582,8 +583,11 @@ async def get_eu_cordis_projects_by_id(
|
||||
async def search_dfg_projects(
|
||||
page: int,
|
||||
size: int,
|
||||
institution_names: Optional[List[str]] = None,
|
||||
names: Optional[List[str]] = None,
|
||||
topic: Optional[str] = None,
|
||||
topics: Optional[List[str]] = None,
|
||||
title: Optional[str] = None,
|
||||
funding_years: Optional[List[str]] = None,
|
||||
sort_by: str = "id",
|
||||
sort_direction: str = "asc",
|
||||
) -> DfgProjectPage:
|
||||
@@ -592,8 +596,11 @@ async def search_dfg_projects(
|
||||
Args:
|
||||
page (int): The page number.
|
||||
size (int): The number of items per page.
|
||||
institution_names (Optional[List[str]], optional): The list of institution names to filter by. Defaults to None.
|
||||
names (Optional[List[str]], optional): The list of names to search for. Defaults to None.
|
||||
topic (Optional[str], optional): The topic to search for. Defaults to None.
|
||||
topics (Optional[List[str]], optional): The list of topics to search for. Defaults to None.
|
||||
title (Optional[str], optional): The title to search for. Defaults to None.
|
||||
funding_years (Optional[List[str]], optional): The funding years to filter by. Defaults to None.
|
||||
sort_by (str, optional): The field to sort by. Defaults to "id".
|
||||
sort_direction (str, optional): The direction to sort. Defaults to "asc".
|
||||
|
||||
@@ -623,53 +630,121 @@ async def search_dfg_projects(
|
||||
}
|
||||
|
||||
must_clauses: List[Dict[str, Any]] = []
|
||||
|
||||
if topic is not None and topic.strip() != "":
|
||||
must_clauses.append(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": topic,
|
||||
"fields": ["title", "title_de", "title_en"],
|
||||
if topics:
|
||||
for topic in topics:
|
||||
if topic.strip() != "":
|
||||
must_clauses.append(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": topic,
|
||||
"fields": ["title", "title_de", "title_en","abstract_de","abstract_en","subject_area_de","subject_area_en"],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if title:
|
||||
must_clauses.append(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": title,
|
||||
"fields": ["title", "title_de", "title_en"],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
}
|
||||
)
|
||||
if funding_years:
|
||||
must_clauses.append(
|
||||
{
|
||||
"terms": {
|
||||
"funding_start": funding_years
|
||||
}
|
||||
}
|
||||
)
|
||||
if names:
|
||||
name_should_clauses = []
|
||||
name_must_clauses = []
|
||||
|
||||
for full_name in names:
|
||||
name_parts = full_name.strip().split()
|
||||
if not name_parts:
|
||||
continue
|
||||
|
||||
match_musts = []
|
||||
|
||||
for part in name_parts:
|
||||
match_musts.append({
|
||||
"match": {
|
||||
"persons.full_name": {
|
||||
"query": part,
|
||||
"operator": "and"
|
||||
match_musts.append(
|
||||
{
|
||||
"match": {
|
||||
"persons.full_name": {
|
||||
"query": part,
|
||||
"operator": "and",
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
name_should_clauses.append({
|
||||
name_must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": match_musts
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if name_must_clauses:
|
||||
must_clauses.append(
|
||||
{
|
||||
"bool": {
|
||||
"must": name_must_clauses
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if institution_names:
|
||||
matching_person_ids = await get_person_ids_by_institution_names(
|
||||
institution_names
|
||||
)
|
||||
|
||||
if not matching_person_ids:
|
||||
return DfgProjectPage(
|
||||
elements=[],
|
||||
total=0,
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
|
||||
must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": match_musts
|
||||
"terms": {
|
||||
"persons.person_id": matching_person_ids
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
if name_should_clauses:
|
||||
must_clauses.append(
|
||||
{"bool": {"should": name_should_clauses, "minimum_should_match": 1}}
|
||||
)
|
||||
|
||||
if must_clauses:
|
||||
body["query"] = {
|
||||
"bool": {
|
||||
"must": must_clauses
|
||||
}
|
||||
}
|
||||
else:
|
||||
body["query"] = {
|
||||
"match_all": {}
|
||||
}
|
||||
if must_clauses:
|
||||
body["query"] = {"bool": {"must": must_clauses}}
|
||||
else:
|
||||
@@ -704,11 +779,40 @@ async def search_dfg_projects(
|
||||
sort_config = {"id": {"order": sort_direction}}
|
||||
|
||||
body["sort"] = [sort_config]
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_ALL,
|
||||
body=body,
|
||||
cluster=ESCluster.INSE
|
||||
)
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
person_ids = {
|
||||
person["person_id"]
|
||||
for hit in hits
|
||||
for person in hit["_source"].get("persons", [])
|
||||
if person.get("person_id") is not None
|
||||
}
|
||||
|
||||
person_lookup = await get_person_institutes(person_ids = list(person_ids), institution_names=institution_names)
|
||||
for hit in hits:
|
||||
persons = hit["_source"].get("persons", [])
|
||||
|
||||
for person in persons:
|
||||
person_id = person.get("person_id")
|
||||
|
||||
institute = person_lookup.get(person_id)
|
||||
|
||||
if institute:
|
||||
person["root_id"] = institute.get("root_id")
|
||||
person["institute_id"] = institute.get("institute_id")
|
||||
|
||||
person["root_name_de"] = institute.get("root_name_de")
|
||||
person["root_name_en"] = institute.get("root_name_en")
|
||||
|
||||
person["institute_name_de"] = institute.get("institute_name_de")
|
||||
person["institute_name_en"] = institute.get("institute_name_en")
|
||||
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
|
||||
@@ -730,6 +834,92 @@ def _complete_response_to_dfg_project_page(
|
||||
elements = [DfgProjectSummary.from_hit(hit) for hit in hits_block.get("hits", [])]
|
||||
return DfgProjectPage(elements=elements, total=total_hits, page=page, size=size)
|
||||
|
||||
async def get_person_institutes(
|
||||
person_ids: list[int],
|
||||
institution_names: list[str] | None = None,
|
||||
) -> dict[str, dict]:
|
||||
|
||||
if not person_ids:
|
||||
return {}
|
||||
query = {
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"terms": {
|
||||
"id": person_ids,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
if institution_names:
|
||||
query["bool"]["must"].append(
|
||||
{
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"match_phrase": {
|
||||
"institute_name_de": institution_names
|
||||
}
|
||||
},
|
||||
{
|
||||
"match_phrase": {
|
||||
"institute_name_en": institution_names
|
||||
}
|
||||
},
|
||||
{
|
||||
"match_phrase": {
|
||||
"root_name_de": institution_names
|
||||
}
|
||||
},
|
||||
{
|
||||
"match_phrase": {
|
||||
"root_name_en": institution_names
|
||||
}
|
||||
},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_DFG_PERSONS,
|
||||
cluster=ESCluster.INSE,
|
||||
body={
|
||||
"size": len(person_ids),
|
||||
"_source": [
|
||||
"person_id",
|
||||
"root_id",
|
||||
"institute_id",
|
||||
"root_name_de",
|
||||
"root_name_en",
|
||||
"institute_name_de",
|
||||
"institute_name_en",
|
||||
],
|
||||
"query": {
|
||||
"terms": {
|
||||
"person_id": person_ids,
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
result = {}
|
||||
|
||||
for hit in response["hits"]["hits"]:
|
||||
source = hit["_source"]
|
||||
|
||||
result[source["person_id"]] = {
|
||||
"person_id": source["person_id"],
|
||||
"root_id": source.get("root_id"),
|
||||
"institute_id": source.get("institute_id"),
|
||||
"root_name_de": source.get("root_name_de"),
|
||||
"root_name_en": source.get("root_name_en"),
|
||||
"institute_name_de": source.get("institute_name_de"),
|
||||
"institute_name_en": source.get("institute_name_en"),
|
||||
}
|
||||
return result
|
||||
|
||||
async def get_dfg_project_by_id(project_id: str) -> Optional[DfgProjectDetails]:
|
||||
"""Fetches the details of a single DFG project based on its project ID.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import Annotated, Optional, Set
|
||||
from typing import Annotated, Optional, Set, List
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, Path, Query, status
|
||||
|
||||
@@ -314,21 +314,33 @@ async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
response_model_by_alias=False,
|
||||
)
|
||||
async def get_dfg_projects(
|
||||
author_id: Annotated[str, Query(description="The author ID to filter by.")],
|
||||
topic: Annotated[
|
||||
Optional[str], Query(description="The topic to filter by.")
|
||||
author_id: Annotated[Optional[str], Query(description="The openalex author ID to filter by.")] = None,
|
||||
author_filter_ids: Annotated[Optional[List[str]], Query(description="The author IDs to filter by.")] = None,
|
||||
institution_ids: Annotated[
|
||||
Optional[List[str]], Query(description="The institution IDs to filter by.")
|
||||
] = None,
|
||||
title: Annotated[
|
||||
Optional[str], Query(description="The title to filter by.")
|
||||
] = None,
|
||||
topics: Annotated[
|
||||
Optional[List[str]], Query(description="The topics to filter by.")
|
||||
] = None,
|
||||
funding_years: Annotated[Optional[List[str]], Query(description="The funding years to filter by.")] = None,
|
||||
page: Annotated[int, Query(description="The page number.", ge=0)] = 0,
|
||||
size: Annotated[int, Query(description="The page size.", ge=1)] = 20,
|
||||
sort_by: Annotated[str, Query(description="The field to sort by.")] = "topic",
|
||||
sort_by: Annotated[str, Query(description="The field to sort by.")] = "title",
|
||||
sort_direction: Annotated[
|
||||
str, Query(description="The sort direction (asc or desc).")
|
||||
] = "asc",
|
||||
|
||||
) -> DfgProjectPage:
|
||||
logger.debug(
|
||||
"Received request to get DFG projects for author_id=%s, topic=%s, page=%d, size=%d, sort_by=%s, sort_direction=%s",
|
||||
"Received request to get DFG projects for author_id=%s, author_filter_ids=%s, topics=%s, title=%s, funding_years=%s, page=%d, size=%d, sort_by=%s, sort_direction=%s",
|
||||
author_id,
|
||||
topic,
|
||||
author_filter_ids,
|
||||
topics,
|
||||
title,
|
||||
funding_years,
|
||||
page,
|
||||
size,
|
||||
sort_by,
|
||||
@@ -336,7 +348,11 @@ async def get_dfg_projects(
|
||||
)
|
||||
return await projects_service.get_dfg_projects_by_author_id(
|
||||
author_id=author_id,
|
||||
topic=topic,
|
||||
author_filter_ids=author_filter_ids,
|
||||
institution_ids=institution_ids,
|
||||
funding_years=funding_years,
|
||||
title=title,
|
||||
topics=topics,
|
||||
page=page,
|
||||
size=size,
|
||||
sort_by=sort_by,
|
||||
|
||||
@@ -26,6 +26,7 @@ from inse.institutions.institutions_search_client import (
|
||||
)
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.persons.logic import get_author_name_by_id
|
||||
from inse.projects.logic import get_dfg_author_names_by_ids, get_dfg_institution_names_by_ids
|
||||
from inse.works.logic import get_publication_dois_of_author
|
||||
from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails
|
||||
from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails
|
||||
@@ -146,37 +147,79 @@ async def get_cordis_eu_projects_by_institution_id(
|
||||
|
||||
return page
|
||||
|
||||
|
||||
async def get_dfg_projects_by_author_id(
|
||||
author_id: str,
|
||||
topic: Optional[str],
|
||||
author_id: Optional[str],
|
||||
author_filter_ids: Optional[List[str]],
|
||||
institution_ids: Optional[List[str]],
|
||||
topics: Optional[List[str]],
|
||||
title: Optional[str],
|
||||
funding_years: Optional[List[str]],
|
||||
page: int,
|
||||
size: int,
|
||||
sort_by: str = "topic",
|
||||
sort_direction: str = "asc",
|
||||
) -> DfgProjectPage:
|
||||
logger.debug(
|
||||
f"Fetching DFG projects for author_id={author_id}, topic={topic}, page={page}, size={size}, sort_by={sort_by}, sort_direction={sort_direction}"
|
||||
"Fetching DFG projects for author_id=%s, author_filter_ids=%s, "
|
||||
"institution_ids=%s, topics=%s, title=%s, funding_years=%s, "
|
||||
"page=%s, size=%s, sort_by=%s, sort_direction=%s",
|
||||
author_id,
|
||||
author_filter_ids,
|
||||
institution_ids,
|
||||
topics,
|
||||
title,
|
||||
funding_years,
|
||||
page,
|
||||
size,
|
||||
sort_by,
|
||||
sort_direction,
|
||||
)
|
||||
name = await get_author_name_by_id(author_id)
|
||||
if not name:
|
||||
logger.debug(f"No author name found for author_id={author_id}")
|
||||
raise NotFoundException(
|
||||
f"Display name for author with id {author_id} not found"
|
||||
)
|
||||
logger.debug(f"Found author name for author_id={author_id}: {name}")
|
||||
filter_names = []
|
||||
author_name = (
|
||||
await get_author_name_by_id(author_id)
|
||||
if author_id
|
||||
else None
|
||||
)
|
||||
if author_id and not author_name:
|
||||
logger.debug("No author name found for author_id=%s", author_id)
|
||||
|
||||
response = await projects_search_client.search_dfg_projects(
|
||||
filter_names = (
|
||||
await get_dfg_author_names_by_ids(author_ids = author_filter_ids)
|
||||
if author_filter_ids
|
||||
else []
|
||||
)
|
||||
if author_filter_ids and not filter_names:
|
||||
logger.debug(
|
||||
"No author names found for author_filter_ids=%s",
|
||||
author_filter_ids,
|
||||
)
|
||||
|
||||
if author_name:
|
||||
filter_names.append(author_name)
|
||||
|
||||
institution_names = (
|
||||
await get_dfg_institution_names_by_ids(institution_ids)
|
||||
if institution_ids
|
||||
else []
|
||||
)
|
||||
|
||||
if institution_ids and not institution_names:
|
||||
logger.debug(
|
||||
"No institutions found for institution_ids=%s",
|
||||
institution_ids,
|
||||
)
|
||||
|
||||
return await projects_search_client.search_dfg_projects(
|
||||
page=page,
|
||||
size=size,
|
||||
names=[name],
|
||||
topic=topic,
|
||||
names=filter_names or [],
|
||||
institution_names=institution_names,
|
||||
topics=topics,
|
||||
title=title,
|
||||
funding_years=funding_years,
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
institutions_search_client: InstitutionsSearchClient,
|
||||
raw_oa_institution_id: str,
|
||||
|
||||
@@ -14,7 +14,7 @@ from inse.works.v2.model import (
|
||||
)
|
||||
from inse.auth.model import AccessTokenMetadata
|
||||
from inse.auth.service import CurrentUserAccessTokenPayloadDep
|
||||
|
||||
from inse.works.v2.service import get_works_by_keywords
|
||||
WORKS_v2_PREFIX = "/api/v2/works"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -83,7 +83,50 @@ async def get_author_works(
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/keyword/search",
|
||||
operation_id="getWorksByKeywords",
|
||||
response_model=WorkPageV2,
|
||||
summary="Search works by topics or raw keywords with filters."
|
||||
)
|
||||
async def search_works_by_keywords(
|
||||
topics: Annotated[list[str] | None, Query(description="List of topics to match.")] = None,
|
||||
topic_ids: Annotated[list[str] | None, Query(description="List of topic IDs to match.")] = None,
|
||||
filter_topic_ids: Annotated[
|
||||
list[str] | None,
|
||||
Query(description="Additional topic IDs to filter results by, independent of search mode."),
|
||||
] = None,
|
||||
keywords: Annotated[list[str] | None, Query(description="Raw keywords to search in title/abstract.")] = None,
|
||||
fuzzy: Annotated[bool, Query(description="Use topic resolution if True, otherwise use raw keywords.")] = True,
|
||||
publication_year: Annotated[list[int] | None, Query(description="A list of publication years to filter by.")] = None,
|
||||
publication_type: Annotated[list[str] | None, Query(description="A list of publication types to filter by.")] = None,
|
||||
institution_ids: Annotated[list[str] | None, Query(description="A list of institution IDs to filter by.")] = None,
|
||||
author_ids: Annotated[list[str] | None, Query(description="A list of author IDs to filter by.")] = None,
|
||||
language: Annotated[list[str] | None, Query(description="A list of language codes to filter by.")] = None,
|
||||
title: Annotated[str | None, Query(description="Title to search for in works.")] = None,
|
||||
page: Annotated[int, Query(description="The page number to retrieve. (0-based)", ge=0)] = 0,
|
||||
size: Annotated[int, Query(description="The number of works to retrieve per page.", ge=1, le=100)] = 10,
|
||||
sort_by: Annotated[WorkSortBy, Query(description="The field to sort by.")] = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: Annotated[SortDirection, Query(description="The order to sort by.")] = SortDirection.DESCENDING,
|
||||
) -> WorkPageV2:
|
||||
return await get_works_by_keywords(
|
||||
topics=topics or [],
|
||||
keywords=keywords or [],
|
||||
fuzzy=fuzzy,
|
||||
publication_year=publication_year or [],
|
||||
publication_type=publication_type or [],
|
||||
institution_ids=institution_ids or [],
|
||||
author_ids=author_ids or [],
|
||||
topic_ids=topic_ids or [],
|
||||
filter_topic_ids=filter_topic_ids or [],
|
||||
language=language or [],
|
||||
title=title,
|
||||
page=page,
|
||||
size=size,
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
)
|
||||
|
||||
@router.get(
|
||||
"/institution/{raw_oa_institution_id}",
|
||||
operation_id="getInstitutionWorkPage",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from fastapi import Query
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex, SortDirection
|
||||
from inse.model import ESIndex, SortDirection, ESCluster
|
||||
from inse.works.v2.model import (
|
||||
WorkClassification,
|
||||
WorkClassificationPage,
|
||||
@@ -229,6 +229,151 @@ async def get_works(
|
||||
|
||||
return await _execute_works_search(must, page, size, sort_by, sort_order)
|
||||
|
||||
async def get_works_by_keywords(
|
||||
topics: Optional[List[str]] = Query(None, description="List of topics to match."),
|
||||
topic_ids: Optional[List[str]] = Query(None, description="List of topic IDs to match."),
|
||||
filter_topic_ids: Optional[List[str]] = Query(
|
||||
None,
|
||||
description="Additional topic IDs to filter results by (OR semantics), "
|
||||
"applied independently of the fuzzy/keyword search mode.",
|
||||
),
|
||||
keywords: Optional[List[str]] = Query(None, description="Raw keywords to search in title/abstract."),
|
||||
title: Optional[str] = None,
|
||||
fuzzy: bool = Query(True, description="Use topic resolution if True, otherwise use raw keywords."),
|
||||
publication_year: Optional[List[int]] = Query(None),
|
||||
publication_type: Optional[List[str]] = Query(None, alias="type"),
|
||||
language: Optional[List[str]] = Query(None),
|
||||
institution_ids: Optional[List[str]] = Query(None),
|
||||
author_ids: Optional[List[str]] = Query(None),
|
||||
page: int = 0,
|
||||
size: int = 10,
|
||||
sort_by: WorkSortBy = Query(WorkSortBy.PUBLICATION_YEAR),
|
||||
sort_order: SortDirection = Query(SortDirection.DESCENDING),
|
||||
) -> WorkPageV2:
|
||||
#print(f"get_works_by_keywords called with topics={topics}, topic_ids={topic_ids}, filter_topic_ids={filter_topic_ids}, keywords={keywords}, fuzzy={fuzzy}, publication_year={publication_year}, publication_type={publication_type}, language={language},title={title}, institution_ids={institution_ids}, page={page}, size={size}, sort_by={sort_by}, sort_order={sort_order}")
|
||||
def _topics_nested_clause(should_clauses: List[Dict]) -> Dict:
|
||||
return {
|
||||
"nested": {
|
||||
"path": "topics",
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": should_clauses,
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
"score_mode": "max",
|
||||
}
|
||||
}
|
||||
|
||||
def _single_topic_id_match(topic_id: str) -> Dict:
|
||||
return {
|
||||
"bool": {
|
||||
"should": [
|
||||
_topics_nested_clause([{"term": {"topics.id": topic_id}}]),
|
||||
{"term": {"primary_topic.id": topic_id}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
|
||||
topic_clause = None
|
||||
|
||||
if fuzzy and topic_ids:
|
||||
filter_on_ids = list(set(topic_ids + filter_topic_ids))
|
||||
topic_clause = {
|
||||
"bool": {"must": [_single_topic_id_match(tid) for tid in filter_on_ids]}
|
||||
}
|
||||
elif keywords:
|
||||
keyword_clauses = []
|
||||
for kw in keywords:
|
||||
keyword_clauses.append({
|
||||
"bool": {
|
||||
"should": [
|
||||
{"nested": {"path": "keywords", "query": {"match_phrase": {"keywords.display_name": kw}}}},
|
||||
{"match_phrase": {"primary_topic.display_name": kw}},
|
||||
{"match_phrase": {"title": kw}},
|
||||
{"match_phrase": {"abstract": kw}},
|
||||
_topics_nested_clause([
|
||||
{"match_phrase": {"topics.display_name": kw}},
|
||||
{"match_phrase": {"topics.field.display_name": kw}},
|
||||
{"match_phrase": {"topics.subfield.display_name": kw}},
|
||||
{"match_phrase": {"topics.domain.display_name": kw}},
|
||||
]),
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
})
|
||||
topic_clause = {"bool": {"must": keyword_clauses}}
|
||||
|
||||
if not topic_clause:
|
||||
return WorkPageV2(elements=[], total=0, page=page, size=size)
|
||||
|
||||
#filters
|
||||
must = [topic_clause]
|
||||
|
||||
|
||||
if title:
|
||||
must.append(_title_query(title))
|
||||
if publication_year:
|
||||
must.append({"terms": {"publication_year": publication_year}})
|
||||
if publication_type:
|
||||
must.append({"terms": {"type": publication_type}})
|
||||
if language:
|
||||
must.append({"terms": {"language": language}})
|
||||
if institution_ids:
|
||||
must.append(_institutions_nested_query(institution_ids))
|
||||
if author_ids:
|
||||
must.append(_authors_nested_query(author_ids))
|
||||
|
||||
#sorting
|
||||
if sort_by == WorkSortBy.TITLE:
|
||||
sort = [{"title.keyword": sort_order.value}]
|
||||
else:
|
||||
sort = [{sort_by.value: sort_order.value}]
|
||||
print(f"Final query:",must)
|
||||
#search
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.OPENALEX_WORKS_WILDCARD,
|
||||
source=[
|
||||
"id",
|
||||
"title",
|
||||
"type",
|
||||
"publication_year",
|
||||
"language",
|
||||
"cited_by_count",
|
||||
"abstract",
|
||||
"keywords",
|
||||
"primary_topic",
|
||||
"authorships.author",
|
||||
"authorships.institutions.id",
|
||||
"authorships.institutions.display_name",
|
||||
"authorships.institutions.country_code",
|
||||
"topics",
|
||||
],
|
||||
query={"bool": {"must": must}},
|
||||
size=size,
|
||||
track_total_hits=True,
|
||||
offset=page * size,
|
||||
sort=sort,
|
||||
cluster=ESCluster.NES,
|
||||
)
|
||||
print(f"Elasticsearch response: {response}")
|
||||
logger.debug(f"Query: {{'bool': {{'must': {must}}}}}")
|
||||
#model mapping
|
||||
hits_block = response.get("hits", {})
|
||||
total = hits_block.get("total", {}).get("value", 0)
|
||||
hits = hits_block.get("hits", [])
|
||||
|
||||
elements: List[Work] = []
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
logger.debug(f"Hit source for keyword search: {source}")
|
||||
|
||||
work = Work.from_dict(source) # type: ignore
|
||||
if work is not None:
|
||||
elements.append(work)
|
||||
|
||||
return WorkPageV2(elements=elements, total=total, page=page, size=size)
|
||||
|
||||
async def get_author_works(
|
||||
raw_oa_author_id: str,
|
||||
|
||||
@@ -80,6 +80,8 @@ model/dehydratedAuthor.ts
|
||||
model/dehydratedFunder.ts
|
||||
model/dehydratedInstitution.ts
|
||||
model/dehydratedSource.ts
|
||||
model/dfgInstitutionSummary.ts
|
||||
model/dfgPersonSummary.ts
|
||||
model/dfgProjectDetails.ts
|
||||
model/dfgProjectPage.ts
|
||||
model/dfgProjectSummary.ts
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
*/
|
||||
|
||||
|
||||
export interface DfgInstitutionSummary {
|
||||
id: number;
|
||||
name_de?: string | null;
|
||||
name_en?: 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 { DfgInstitutionSummary } from './dfgInstitutionSummary';
|
||||
|
||||
|
||||
export interface DfgPersonSummary {
|
||||
person_id: number;
|
||||
project_ref_id: number;
|
||||
full_name?: string | null;
|
||||
role_label_en?: string | null;
|
||||
role_label_de?: string | null;
|
||||
root_institution?: DfgInstitutionSummary | null;
|
||||
institution?: DfgInstitutionSummary | null;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DfgInstitutionSummary } from './dfgInstitutionSummary';
|
||||
import { DfgPersonSummary } from './dfgPersonSummary';
|
||||
|
||||
|
||||
export interface DfgProjectSummary {
|
||||
@@ -20,8 +22,20 @@ export interface DfgProjectSummary {
|
||||
funding_start?: string | null;
|
||||
funding_end?: string | null;
|
||||
/**
|
||||
* The names of the researchers involved in the DFG project.
|
||||
* Root institutions associated with the project (e.g. universities or umbrella organizations).
|
||||
*/
|
||||
root_institutions?: Array<DfgInstitutionSummary>;
|
||||
/**
|
||||
* Institutions associated with the project.
|
||||
*/
|
||||
institutions?: Array<DfgInstitutionSummary>;
|
||||
/**
|
||||
* The names of the persons involved in the DFG project.
|
||||
*/
|
||||
names?: Array<string>;
|
||||
/**
|
||||
* The persons involved in the DFG project.
|
||||
*/
|
||||
persons?: Array<DfgPersonSummary>;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ export * from './dehydratedAuthor';
|
||||
export * from './dehydratedFunder';
|
||||
export * from './dehydratedInstitution';
|
||||
export * from './dehydratedSource';
|
||||
export * from './dfgInstitutionSummary';
|
||||
export * from './dfgPersonSummary';
|
||||
export * from './dfgProjectDetails';
|
||||
export * from './dfgProjectPage';
|
||||
export * from './dfgProjectSummary';
|
||||
|
||||
@@ -34,6 +34,7 @@ import {
|
||||
} from './resolvers/work-page.resolver';
|
||||
import { selectedTopicsResolver } from './resolvers/selected-topics.resolver';
|
||||
import { selectedInstitutionsResolver } from './resolvers/selected-institutions.resolver';
|
||||
import { SearchResultsStateService } from './modules/keywords-search/search-results/search-results-state.service';
|
||||
import { roleGuard } from './shared/guards/role.guard';
|
||||
import { UserRole } from './api';
|
||||
import { personCordisEuProjectPageResolver } from './resolvers/person-cordis-eu-project-page.resolver';
|
||||
@@ -160,12 +161,22 @@ export const routes: Routes = [
|
||||
import('./modules/keywords-search/search-results/search-results.component').then(
|
||||
(mod) => mod.KeywordsSearchResultsComponent,
|
||||
),
|
||||
providers: [SearchResultsStateService],
|
||||
children: [
|
||||
{ path: '', pathMatch: 'full', redirectTo: 'persons' },
|
||||
{ path: 'persons', component: KeywordsToPersonsResultsComponent },
|
||||
{ path: 'projects', component: KeywordsToProjectsResultsComponent },
|
||||
{ path: 'patents', component: KeywordsToPatentsResultsComponent },
|
||||
{ path: 'works', component: KeywordsToWorksResultsComponent },
|
||||
{
|
||||
path: 'works',
|
||||
component: KeywordsToWorksResultsComponent,
|
||||
runGuardsAndResolvers: 'always',
|
||||
resolve: {
|
||||
selectedTopicsPage: selectedTopicsResolver,
|
||||
selectedAuthorsPage: selectedAuthorsResolver,
|
||||
selectedInstitutionsPage: selectedInstitutionsResolver,
|
||||
},
|
||||
},
|
||||
{ path: 'news', component: KeywordsToNewsResultsComponent },
|
||||
{ path: 'trends', component: UniTrendParentComponent },
|
||||
],
|
||||
@@ -369,13 +380,12 @@ export const routes: Routes = [
|
||||
resolve: {
|
||||
dfgProjectPage: dfgProjectsResolver,
|
||||
personCordisEuProjectPage: personCordisEuProjectPageResolver,
|
||||
selectedDfgInstitutions: selectedInstitutionsResolver,
|
||||
selectedDfgAuthors: selectedAuthorsResolver,
|
||||
selectedEuInstitutions: selectedInstitutionsResolver,
|
||||
selectedEuAuthors: selectedAuthorsResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
const keys = ['page', 'size', 'sort_by', 'sort_direction', 'search'];
|
||||
return keys.some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{
|
||||
path: 'publications',
|
||||
@@ -388,7 +398,8 @@ export const routes: Routes = [
|
||||
selectedTopicsPage: selectedTopicsResolver,
|
||||
selectedInstitutionsPage: selectedInstitutionsResolver,
|
||||
authorWorkPage: workPageResolver,
|
||||
authorWorkClassificationMergePage: authorWorkClassificationPageResolver,
|
||||
authorWorkClassificationMergePage:
|
||||
authorWorkClassificationPageResolver,
|
||||
},
|
||||
data: {
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.PERSON,
|
||||
|
||||
@@ -159,7 +159,6 @@
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</div>
|
||||
<div class="toolbar-divider"></div>
|
||||
</div>
|
||||
|
||||
<div class="spacer toolbar-controls manual-input-controls">
|
||||
|
||||
@@ -964,6 +964,7 @@ export class KeywordsSearchComponent {
|
||||
const view = queryParams.get('view') ?? 'llm';
|
||||
const legend = queryParams.get('legend') ?? 'on';
|
||||
const legendExpanded = queryParams.get('legendExpanded') ?? 'off';
|
||||
const fuzzy = queryParams.get('fuzzy') === 'true';
|
||||
this.isRestoringState = true;
|
||||
this.form.patchValue(
|
||||
{
|
||||
@@ -977,6 +978,7 @@ export class KeywordsSearchComponent {
|
||||
this.subfieldLegendVisible.set(legend === 'on');
|
||||
this.subfieldLegendExpanded.set(legendExpanded === 'on');
|
||||
this.extractionSource.set(source as InputMode);
|
||||
this.topicMappingSearch.set(fuzzy);
|
||||
this.restoreStateFromSession();
|
||||
|
||||
const merged = this.uniqueKeywordEntries([
|
||||
|
||||
+48
-13
@@ -1,5 +1,6 @@
|
||||
import { Injectable, computed, signal } from '@angular/core';
|
||||
import { KeywordEntryWithTopic } from '../../../api/model/keywordEntryWithTopic';
|
||||
import { Topic } from '../../../api';
|
||||
|
||||
export type KeywordPatentLevel = 'broad' | 'coarse' | 'fine' | 'custom';
|
||||
|
||||
@@ -36,6 +37,32 @@ export class SearchResultsStateService {
|
||||
});
|
||||
|
||||
readonly keywords = computed(() => this._payload()?.keywords ?? []);
|
||||
readonly topics = computed(() => {
|
||||
const entries = this.selectedKeywordEntries();
|
||||
const seen = new Set<string>();
|
||||
const topics: Topic[] = [];
|
||||
for (const entry of entries) {
|
||||
const topic = entry.topic_mapping?.topic;
|
||||
if (topic?.id && !seen.has(topic.id)) {
|
||||
seen.add(topic.id);
|
||||
topics.push(topic);
|
||||
}
|
||||
}
|
||||
return topics;
|
||||
});
|
||||
|
||||
readonly topicIds = computed(() => {
|
||||
const entries = this.selectedKeywordEntries();
|
||||
const ids = new Set<string>();
|
||||
for (const entry of entries) {
|
||||
const topicId = entry.topic_mapping?.topic?.id;
|
||||
if (topicId) {
|
||||
ids.add(topicId);
|
||||
}
|
||||
}
|
||||
return Array.from(ids);
|
||||
});
|
||||
|
||||
readonly fuzzySearch = computed(
|
||||
() => this._payload()?.options.fuzzy ?? false,
|
||||
);
|
||||
@@ -46,21 +73,26 @@ export class SearchResultsStateService {
|
||||
() => this._payload()?.manualKeywords ?? [],
|
||||
);
|
||||
|
||||
// Compute unified list of KeywordEntryWithTopic matching selected keywords
|
||||
// Compute unified list of KeywordEntryWithTopic matching selected keywords.
|
||||
// Manual keywords intentionally take precedence over extracted ones when
|
||||
// both normalize to the same keyword.
|
||||
readonly selectedKeywordEntries = computed(() => {
|
||||
const payload = this._payload();
|
||||
if (!payload) return [];
|
||||
|
||||
const allEntries = [
|
||||
...(payload.extractedKeywords ?? []),
|
||||
...(payload.manualKeywords ?? []),
|
||||
];
|
||||
|
||||
const entryByKeyword = new Map<string, KeywordEntryWithTopic>();
|
||||
for (const entry of allEntries) {
|
||||
const kw = entry.llm_keyword?.keyword;
|
||||
|
||||
for (const entry of payload.extractedKeywords ?? []) {
|
||||
const kw = entry.llm_keyword?.keyword?.trim().toLowerCase();
|
||||
if (kw && !entryByKeyword.has(kw)) {
|
||||
entryByKeyword.set(kw, entry);
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of payload.manualKeywords ?? []) {
|
||||
const kw = entry.llm_keyword?.keyword?.trim().toLowerCase();
|
||||
if (kw) {
|
||||
entryByKeyword.set(kw.trim().toLowerCase(), entry);
|
||||
entryByKeyword.set(kw, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +110,7 @@ export class SearchResultsStateService {
|
||||
return result;
|
||||
});
|
||||
|
||||
// Keywords that did not resolve to a mapped topic entry
|
||||
// Keywords that did not resolve to a mapped topic entry.
|
||||
readonly missingKeywordLabels = computed(() => {
|
||||
const payload = this._payload();
|
||||
if (!payload) return [];
|
||||
@@ -86,7 +118,7 @@ export class SearchResultsStateService {
|
||||
const entryKeywordSet = new Set(
|
||||
this.selectedKeywordEntries()
|
||||
.map((entry) => entry.llm_keyword?.keyword?.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
.filter((kw): kw is string => !!kw),
|
||||
);
|
||||
|
||||
return payload.keywords.filter(
|
||||
@@ -94,8 +126,11 @@ export class SearchResultsStateService {
|
||||
);
|
||||
});
|
||||
|
||||
// Compute parallel keywords and topic names for trend dashboard strategies
|
||||
readonly keywordsList = computed(() => this.keywords());
|
||||
readonly keywordsList = this.keywords;
|
||||
|
||||
// Parallel topic-name list for trend dashboard strategies. Entries
|
||||
// without a resolvable keyword are skipped when building the lookup map
|
||||
// so they can never collide on an `undefined` key and shadow a real one.
|
||||
readonly topicsList = computed(() => {
|
||||
const list = this.keywords().map((kw) => {
|
||||
const entry = this.selectedKeywordEntries().find(
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<mat-slide-toggle
|
||||
labelPosition="before"
|
||||
(change)="onToggleFuzzySearch($event)"
|
||||
[checked]="fuzzySearch()"
|
||||
[checked]="state.fuzzySearch()"
|
||||
matTooltip="Wenn aktiviert, werden die extrahierten Keywords auf bekannte Themenbereiche abgebildet, was die Suchergebnisse vermehrt">
|
||||
Fuzzy Search
|
||||
</mat-slide-toggle>
|
||||
@@ -68,6 +68,7 @@
|
||||
[queryParams]="{
|
||||
keywords: state.payload()?.keywords?.join(','),
|
||||
fuzzy: state.payload()?.options?.fuzzy,
|
||||
topics: state.payload()?.options?.fuzzy ? state.topicIds() : null,
|
||||
}">
|
||||
<mat-icon>{{ route.icon }}</mat-icon>
|
||||
{{ route.label }}
|
||||
|
||||
@@ -63,56 +63,19 @@ export class KeywordsSearchResultsComponent {
|
||||
];
|
||||
|
||||
readonly selectedKeywordCount = computed(() => this.state.keywords().length);
|
||||
readonly fuzzySearch = signal<boolean>(false);
|
||||
readonly selectedKeywordEntries = computed(() => {
|
||||
const payload = this.state.payload();
|
||||
if (!payload) return [];
|
||||
|
||||
const allEntries = [
|
||||
...(payload.extractedKeywords ?? []),
|
||||
...(payload.manualKeywords ?? []),
|
||||
];
|
||||
|
||||
const entryByKeyword = new Map<string, KeywordEntryWithTopic>();
|
||||
|
||||
for (const entry of allEntries) {
|
||||
entryByKeyword.set(
|
||||
this.normalizeKeyword(this.getKeywordLabel(entry)),
|
||||
entry,
|
||||
);
|
||||
}
|
||||
|
||||
const result: KeywordEntryWithTopic[] = [];
|
||||
readonly allKeywordEntries = computed(() => {
|
||||
const seen = new Set<string>();
|
||||
|
||||
for (const keyword of payload.keywords) {
|
||||
const normalized = this.normalizeKeyword(keyword);
|
||||
const entry = entryByKeyword.get(normalized);
|
||||
|
||||
if (!entry || seen.has(normalized)) continue;
|
||||
|
||||
seen.add(normalized);
|
||||
result.push(entry);
|
||||
}
|
||||
|
||||
return result;
|
||||
const all = [
|
||||
...this.state.extractedKeywords(),
|
||||
...this.state.manualKeywords(),
|
||||
];
|
||||
return all.filter((entry) => {
|
||||
const kw = entry.llm_keyword?.keyword?.trim().toLowerCase();
|
||||
if (!kw || seen.has(kw)) return false;
|
||||
seen.add(kw);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
readonly missingKeywordLabels = computed(() => {
|
||||
const payload = this.state.payload();
|
||||
if (!payload) return [];
|
||||
|
||||
const entryKeywordSet = new Set(
|
||||
this.selectedKeywordEntries().map((entry) =>
|
||||
this.normalizeKeyword(this.getKeywordLabel(entry)),
|
||||
),
|
||||
);
|
||||
|
||||
return payload.keywords.filter(
|
||||
(keyword) => !entryKeywordSet.has(this.normalizeKeyword(keyword)),
|
||||
);
|
||||
});
|
||||
|
||||
constructor() {
|
||||
// Query params are authoritative (URL survives reload, deep links,
|
||||
// browser back/forward). sessionStorage is a best-effort cache for the
|
||||
@@ -136,11 +99,8 @@ export class KeywordsSearchResultsComponent {
|
||||
? cached!.patentKeywordEntries
|
||||
: undefined,
|
||||
});
|
||||
|
||||
this.fuzzySearch.set(fuzzySearch);
|
||||
});
|
||||
}
|
||||
|
||||
goBackToSearch(): void {
|
||||
void this.router.navigate(['/keywords'], {
|
||||
queryParamsHandling: 'merge',
|
||||
@@ -148,7 +108,7 @@ export class KeywordsSearchResultsComponent {
|
||||
}
|
||||
|
||||
getChipLabel(keyword: KeywordEntryWithTopic): string {
|
||||
if (!this.fuzzySearch()) {
|
||||
if (!this.state.fuzzySearch()) {
|
||||
return keyword.llm_keyword?.keyword ?? '';
|
||||
}
|
||||
return (
|
||||
@@ -226,9 +186,9 @@ export class KeywordsSearchResultsComponent {
|
||||
}
|
||||
|
||||
private sameKeywordSet(a: string[], b: string[]): boolean {
|
||||
if (a.length !== b.length) return false;
|
||||
const setA = new Set(a.map((k) => this.normalizeKeyword(k)));
|
||||
return b.every((k) => setA.has(this.normalizeKeyword(k)));
|
||||
const setA = new Set(a.map(this.normalizeKeyword.bind(this)));
|
||||
const setB = new Set(b.map(this.normalizeKeyword.bind(this)));
|
||||
return setA.size === setB.size && [...setA].every((k) => setB.has(k));
|
||||
}
|
||||
|
||||
private parseKeywordList(raw: string | null): string[] {
|
||||
@@ -251,12 +211,18 @@ export class KeywordsSearchResultsComponent {
|
||||
return value.trim().toLowerCase();
|
||||
}
|
||||
onToggleFuzzySearch(event: any): void {
|
||||
this.fuzzySearch.set(event.checked);
|
||||
this.updateQueryParams(event.checked);
|
||||
}
|
||||
updateQueryParams(fuzzy: boolean): void {
|
||||
console.log('Updating query params with keywords:', fuzzy);
|
||||
const queryParams = {
|
||||
fuzzy: fuzzy,
|
||||
topics: fuzzy ? this.state.topicIds() : null,
|
||||
};
|
||||
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
fuzzy: this.fuzzySearch(),
|
||||
},
|
||||
queryParams,
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
});
|
||||
|
||||
+20
-29
@@ -1,31 +1,22 @@
|
||||
<div class="result-layout">
|
||||
<mat-card class="results-card">
|
||||
<mat-card-content class="results-placeholder">
|
||||
<mat-icon>groups</mat-icon>
|
||||
<h2>Publikationsliste</h2>
|
||||
<p>
|
||||
Die aktuelle Gewichtung ist unter <code>normalized</code> verfügbar.
|
||||
</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<div class="content">
|
||||
<app-publication-filter
|
||||
[selectedTopicsPage]="selectedTopicsPage()"
|
||||
[selectedInstitutionsPage]="selectedInstitutionsPage()"
|
||||
[selectedAuthorsPage]="selectedAuthorsPage()"
|
||||
[showTopicFilter]="fuzzySearch()" />
|
||||
|
||||
<mat-card class="weights-card">
|
||||
<mat-card-content>
|
||||
<app-weights-sliders
|
||||
[options]="weightOptions"
|
||||
[initialWeights]="defaultWeights"
|
||||
title="Publikations-Gewichtung"
|
||||
description="Werte zwischen 0 und 1. Summe wird normalisiert zu 1."
|
||||
resetLabel="Ausgewogen"
|
||||
applyLabel="Neu gewichten"
|
||||
normalizedTitle="Normalisiert"
|
||||
queryParamPrefix="workW_"
|
||||
[persistInQueryParams]="true"
|
||||
[showApplyButton]="true"
|
||||
[showResetButton]="true"
|
||||
[showNormalizedPreview]="true"
|
||||
(weightsChange)="onWeightsChange($event)"
|
||||
(applyWeights)="onApplyWeights($event)" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@if (loading()) {
|
||||
<app-loading [icon]="'article'" />
|
||||
} @else {
|
||||
<app-publication-table
|
||||
[page]="works()"
|
||||
[authorFilterEnabled]="true"
|
||||
[institutionFilterEnabled]="true"
|
||||
[topicFilterEnabled]="fuzzySearch()" />
|
||||
}
|
||||
|
||||
<app-query-param-paginator
|
||||
[total]="total()"
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size" />
|
||||
</div>
|
||||
|
||||
+71
-16
@@ -1,29 +1,84 @@
|
||||
/* ============================================================
|
||||
RESULT LAYOUT
|
||||
============================================================ */
|
||||
.result-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(300px, 420px) 1fr;
|
||||
grid-template-areas: 'summary results';
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.publication-filter-stack {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.publication-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
align-items: start;
|
||||
|
||||
mat-form-field {
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.institution-filter {
|
||||
min-width: 260px;
|
||||
flex: 1 1 260px;
|
||||
}
|
||||
}
|
||||
|
||||
.search-summary-card {
|
||||
grid-area: summary;
|
||||
.filter-prefix-icon {
|
||||
margin-right: 0.25rem;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
}
|
||||
|
||||
.results-card {
|
||||
grid-area: results;
|
||||
.select-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
|
||||
|
||||
&__icon {
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
}
|
||||
|
||||
&__input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
font: inherit;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&__empty {
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.reset-filter-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.result-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.search-summary-card,
|
||||
.results-card {
|
||||
background: var(--sg-surface, #ffffff);
|
||||
border: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12));
|
||||
box-shadow: none;
|
||||
|
||||
.mat-mdc-card-content {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.results-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
+194
-86
@@ -1,111 +1,219 @@
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
OnInit,
|
||||
inject,
|
||||
signal,
|
||||
computed,
|
||||
input,
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { workQueryParamKeys } from '../../../../resolvers/work-page.resolver';
|
||||
import { PublicationFilterComponent } from '../../../../shared/ui/publication-filters/publication-filters.component';
|
||||
import { catchError, finalize, of, switchMap } from 'rxjs';
|
||||
|
||||
import { PublicationTableComponent } from '../../../../shared/ui/publication-table/publication-table.component';
|
||||
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
|
||||
import { WorkPageV2 } from '../../../../api/model/workPageV2';
|
||||
import { PaginationService } from '../../../../shared/services/pagination.service';
|
||||
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import {
|
||||
WeightMap,
|
||||
WeightSliderOption,
|
||||
WeightsSlidersComponent,
|
||||
WeightsSlidersValue,
|
||||
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
|
||||
Author,
|
||||
AuthorPage,
|
||||
Institution,
|
||||
InstitutionPageV2,
|
||||
Topic,
|
||||
TopicPageV2,
|
||||
WorkTopic,
|
||||
} from '../../../../api';
|
||||
import { SortDirection, WorkSortBy, WorksV2Service } from '../../../../api';
|
||||
import { SearchResultsStateService } from '../search-results-state.service';
|
||||
|
||||
const EMPTY_WORK_PAGE: WorkPageV2 = {
|
||||
elements: [],
|
||||
total: 0,
|
||||
page: 0,
|
||||
size: 10,
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-works-results',
|
||||
imports: [MatCardModule, MatIconModule, WeightsSlidersComponent],
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
LoadingComponent,
|
||||
PublicationTableComponent,
|
||||
PublicationFilterComponent,
|
||||
QueryParamPaginatorComponent,
|
||||
],
|
||||
templateUrl: './works-results.component.html',
|
||||
styleUrl: './works-results.component.scss',
|
||||
})
|
||||
export class KeywordsToWorksResultsComponent {
|
||||
// injects the state set by the parent route — no duplicate parsing here
|
||||
export class KeywordsToWorksResultsComponent implements OnInit {
|
||||
private readonly state = inject(SearchResultsStateService);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly worksService = inject(WorksV2Service);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
public readonly paginationService = inject(PaginationService);
|
||||
|
||||
readonly defaultWeights: WeightMap = {
|
||||
param1: 0.33,
|
||||
param2: 0.33,
|
||||
param3: 0.34,
|
||||
};
|
||||
loading = signal<boolean>(false);
|
||||
|
||||
readonly weightOptions: WeightSliderOption[] = [
|
||||
{
|
||||
key: 'param1',
|
||||
label: 'Parameter 1',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 1.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam1',
|
||||
},
|
||||
{
|
||||
key: 'param2',
|
||||
label: 'Parameter 2',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 2.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam2',
|
||||
},
|
||||
{
|
||||
key: 'param3',
|
||||
label: 'Parameter 3',
|
||||
icon: 'workspace_premium',
|
||||
description: 'Gewichtet Parameter 3.',
|
||||
defaultValue: 0.5,
|
||||
queryParamName: 'wParam3',
|
||||
},
|
||||
];
|
||||
private readonly yearParamKey = workQueryParamKeys.years;
|
||||
private readonly typeParamKey = workQueryParamKeys.types;
|
||||
private readonly languageParamKey = workQueryParamKeys.language;
|
||||
private readonly institutionParamKey = workQueryParamKeys.institutionId;
|
||||
private readonly authorParamKey = workQueryParamKeys.authorId;
|
||||
private readonly topicParamKey = workQueryParamKeys.topicId;
|
||||
private readonly pageParamKey = workQueryParamKeys.page;
|
||||
|
||||
readonly currentWeights = signal<WeightsSlidersValue>({
|
||||
raw: this.defaultWeights,
|
||||
normalized: {
|
||||
param1: 0.33,
|
||||
param2: 0.33,
|
||||
param3: 0.34,
|
||||
},
|
||||
rawSum: 2.5,
|
||||
normalizedSum: 1,
|
||||
valid: true,
|
||||
queryParamMap = toSignal(this.route.queryParamMap, {
|
||||
initialValue: this.route.snapshot.queryParamMap,
|
||||
});
|
||||
|
||||
readonly works = signal<unknown[]>([]); // placeholder until the results service lands
|
||||
selectedInstitutionIdsQueryParams = computed(() =>
|
||||
this.queryParamMap().getAll(this.institutionParamKey),
|
||||
);
|
||||
selectedAuthorIdsQueryParams = computed(() =>
|
||||
this.queryParamMap().getAll(this.authorParamKey),
|
||||
);
|
||||
|
||||
private hasLoadedInitial = false;
|
||||
selectedTopicIdsQueryParams = computed(() =>
|
||||
this.queryParamMap().getAll(this.topicParamKey),
|
||||
);
|
||||
|
||||
onWeightsChange(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
total = computed(() => this.works()?.total ?? 0);
|
||||
totalElements = computed(() => this.works()?.total ?? 0);
|
||||
elements = computed(() => this.works()?.elements ?? []);
|
||||
fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true');
|
||||
|
||||
// fires once with the query-param-aware initial state — use it to load
|
||||
if (!this.hasLoadedInitial) {
|
||||
this.hasLoadedInitial = true;
|
||||
this.loadworks();
|
||||
readonly works = toSignal(
|
||||
this.route.queryParamMap.pipe(
|
||||
switchMap((params) => this.fetchWorks(params)),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
),
|
||||
{ initialValue: EMPTY_WORK_PAGE },
|
||||
);
|
||||
|
||||
private readonly institutionsFromWorks = computed(() => {
|
||||
const map = new Map<string, Institution>();
|
||||
for (const work of this.works().elements ?? []) {
|
||||
for (const authorship of work.authorships ?? []) {
|
||||
for (const institution of authorship.institutions ?? []) {
|
||||
if (institution.id) map.set(institution.id, institution);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
private readonly authorsFromWorks = computed(() => {
|
||||
const map = new Map<string, Author>();
|
||||
for (const work of this.works().elements ?? []) {
|
||||
for (const authorship of work.authorships ?? []) {
|
||||
const author = authorship.author;
|
||||
if (author?.id) map.set(author.id, author);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
private readonly topicsFromWorks = computed(() => {
|
||||
const map = new Map<string, WorkTopic>();
|
||||
for (const work of this.works().elements ?? []) {
|
||||
for (const topic of work.topics ?? []) {
|
||||
if (topic.id) map.set(topic.id, topic);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
selectedAuthors = computed<Author[]>(() => {
|
||||
const byId = this.authorsFromWorks();
|
||||
return this.selectedAuthorIdsQueryParams()
|
||||
.map((id) => byId.get(id))
|
||||
.filter((author): author is Author => !!author);
|
||||
});
|
||||
|
||||
selectedInstitutionsPage = input.required<InstitutionPageV2>();
|
||||
selectedTopicsPage = input.required<TopicPageV2>();
|
||||
selectedAuthorsPage = input.required<AuthorPage>();
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
private fetchWorks(params: ParamMap) {
|
||||
this.loading.set(true);
|
||||
// Base search topics — derived from the keyword→topic mapping.
|
||||
// This remains the actual search criterion.
|
||||
const baseTopicIds = this.state
|
||||
.selectedKeywordEntries()
|
||||
.map((entry) => entry.topic_mapping?.topic?.id)
|
||||
.filter((id): id is string => !!id);
|
||||
|
||||
const keywords = this.state.keywords();
|
||||
|
||||
if (baseTopicIds.length === 0 && keywords.length === 0) {
|
||||
this.loading.set(false);
|
||||
return of(EMPTY_WORK_PAGE);
|
||||
}
|
||||
const title = params.get('title') ?? undefined;
|
||||
const filterTopicIds = params.getAll(this.topicParamKey);
|
||||
const page = Number(params.get(this.pageParamKey)) || 0;
|
||||
const size = Number(params.get('size')) || 10;
|
||||
const publicationYears = params
|
||||
.getAll(this.yearParamKey)
|
||||
.map(Number)
|
||||
.filter((year) => !Number.isNaN(year));
|
||||
const publicationTypes = params.getAll(this.typeParamKey);
|
||||
const publicationLanguages = params.getAll(this.languageParamKey);
|
||||
const institutionIds = params.getAll(this.institutionParamKey);
|
||||
const authorIds = params.getAll(this.authorParamKey);
|
||||
const fuzzy = params.get('fuzzy') === 'true';
|
||||
const sortBy = (params.get('sort_by') ?? 'publication_year') as WorkSortBy;
|
||||
const sortDirection = (params.get('sort_direction') ??
|
||||
'desc') as SortDirection;
|
||||
|
||||
return this.worksService
|
||||
.getWorksByKeywords(
|
||||
[],
|
||||
baseTopicIds,
|
||||
filterTopicIds,
|
||||
keywords,
|
||||
fuzzy,
|
||||
publicationYears,
|
||||
publicationTypes,
|
||||
institutionIds,
|
||||
authorIds,
|
||||
publicationLanguages,
|
||||
title,
|
||||
page,
|
||||
size,
|
||||
sortBy,
|
||||
sortDirection,
|
||||
)
|
||||
.pipe(
|
||||
catchError((err) => {
|
||||
console.error(err);
|
||||
return of(EMPTY_WORK_PAGE);
|
||||
}),
|
||||
finalize(() => this.loading.set(false)),
|
||||
);
|
||||
}
|
||||
|
||||
onApplyWeights(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
this.loadworks();
|
||||
}
|
||||
|
||||
private loadworks(): void {
|
||||
const weights = this.currentWeights();
|
||||
|
||||
const requestPayload = {
|
||||
manualKeywords: this.state.manualKeywords(),
|
||||
extractedKeywords: this.state.extractedKeywords(),
|
||||
keywords: this.state.keywords(),
|
||||
fuzzy: this.state.fuzzySearch(),
|
||||
weights: {
|
||||
raw: weights.raw,
|
||||
normalized: weights.normalized,
|
||||
clearFilters(): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
keywords: this.state.keywordsList().join(','),
|
||||
topicId: this.state.topicIds(),
|
||||
fuzzy: this.state.fuzzySearch(),
|
||||
page: 0,
|
||||
size: 10,
|
||||
sort_by: 'publication_year',
|
||||
sort_direction: 'desc',
|
||||
},
|
||||
};
|
||||
|
||||
console.log(requestPayload);
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* this.worksService.searchworks(requestPayload).subscribe({
|
||||
* next: results => this.works.set(results),
|
||||
* error: error => console.error(error),
|
||||
* });
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,8 @@ export class PatentDetailComponent implements OnInit {
|
||||
this.route.snapshot.queryParamMap.get('title') ?? undefined;
|
||||
const prefix =
|
||||
this.route.snapshot.queryParamMap.get('prefix') ?? undefined;
|
||||
const fillingDate =
|
||||
this.route.snapshot.queryParamMap.get('fillingDate') ?? undefined;
|
||||
|
||||
this.loadPatent(patentId, title, prefix, fillingDate);
|
||||
this.loadPatent(patentId, title, prefix);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,19 +131,14 @@ export class PatentDetailComponent implements OnInit {
|
||||
return getDescriptionPreview(text);
|
||||
}
|
||||
|
||||
private loadPatent(
|
||||
patentId: string,
|
||||
title?: string,
|
||||
prefix?: string,
|
||||
fillingDate?: string,
|
||||
): void {
|
||||
private loadPatent(patentId: string, title?: string, prefix?: string): void {
|
||||
this.loading = true;
|
||||
this.notFound = false;
|
||||
this.patent = null;
|
||||
this.expandedClassificationKeys.clear();
|
||||
|
||||
this.patentsService
|
||||
.getPatentByIdOrTitle(patentId, prefix, title, fillingDate)
|
||||
.getPatentByIdOrTitle(patentId, prefix, title)
|
||||
.pipe(finalize(() => (this.loading = false)))
|
||||
.subscribe({
|
||||
next: (patent: PatentEntry) => {
|
||||
|
||||
@@ -5,78 +5,26 @@
|
||||
</div>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<app-query-param-input label="Suche nach Titel" queryParamKey="search" />
|
||||
<mat-tab-group>
|
||||
<mat-tab-group
|
||||
[selectedIndex]="selectedTabIndex()"
|
||||
(selectedIndexChange)="onTabChange($event)">
|
||||
<mat-tab label="DFG">
|
||||
<app-data-table
|
||||
[columns]="dfgProjectColumns"
|
||||
[data]="dfgProjectData"
|
||||
[detailTemplate]="dfgProjectDetailRowTmp"
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
<app-project-filters
|
||||
[selectedInstitutions]="selectedDfgInstitutions()"
|
||||
[showAuthorFilter]="true"
|
||||
[showInstitutionFilter]="true" />
|
||||
<app-dfg-project-table
|
||||
[page]="dfgProjectPage()"
|
||||
[authorFilterEnabled]="true"
|
||||
[institutionFilterEnabled]="true" />
|
||||
</mat-tab>
|
||||
<mat-tab label="EU">
|
||||
<app-data-table
|
||||
[columns]="personCordisEuProjectColumns"
|
||||
[data]="personCordisEuProjectData"
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
<app-project-filters
|
||||
[selectedInstitutions]="selectedEuInstitutions()"
|
||||
[selectedAuthors]="selectedEuAuthors()" />
|
||||
<app-eu-project-table [page]="personCordisEuProjectPage()" />
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<app-query-param-paginator
|
||||
[total]="this.pageTotal()"
|
||||
[pageSizeOptions]="[10]" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
<ng-template #dfgProjectActionsTmp let-element>
|
||||
<a
|
||||
[routerLink]="['/projects/dfg', element.id]"
|
||||
target="_blank"
|
||||
mat-icon-button
|
||||
color="primary">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #dfgProjectFundingEndTmp let-element>
|
||||
{{ element.funding_end == '2999' ? 'laufend' : element.funding_end }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #dfgProjectDetailRowTmp let-element>
|
||||
<div class="detail-row">
|
||||
<ul>
|
||||
@for (
|
||||
name of element.names.sort((a, b) => a.localeCompare(b));
|
||||
track $index
|
||||
) {
|
||||
<li>
|
||||
{{ name }}
|
||||
</li>
|
||||
}
|
||||
</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>
|
||||
|
||||
@@ -1,160 +1,65 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
input,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
CordisEuProject,
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
DfgProjectSummary,
|
||||
Author,
|
||||
Institution,
|
||||
} from '../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../shared/ui/data-table/data-table.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
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 { 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';
|
||||
import { ProjectFilterComponent } from '../../shared/ui/project-filters/project-filters.component';
|
||||
import { DfgProjectTableComponent } from '../../shared/ui/dfg-project-table/dfg-project-table.component';
|
||||
import { EuProjectTableComponent } from '../../shared/ui/eu-project-table/eu-project-table.component';
|
||||
import { projectQueryParamKeys } from '../../resolvers/dfg-projects.resolver';
|
||||
import { euProjectQueryParamKeys } from '../../resolvers/person-cordis-eu-project-page.resolver';
|
||||
|
||||
const PROJECT_TAB_QUERY_PARAM_KEY = 'project_type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-projects',
|
||||
imports: [
|
||||
DataTableComponent,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatTabsModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
RouterModule,
|
||||
DatePipe,
|
||||
CurrencyPipe,
|
||||
QueryParamPaginatorComponent,
|
||||
QueryParamInputComponent,
|
||||
ProjectFilterComponent,
|
||||
DfgProjectTableComponent,
|
||||
EuProjectTableComponent,
|
||||
],
|
||||
templateUrl: './person-projects.component.html',
|
||||
styleUrl: './person-projects.component.scss',
|
||||
})
|
||||
export class PersonProjectsComponent implements OnInit {
|
||||
export class PersonProjectsComponent {
|
||||
dfgProjectPage = input.required<DfgProjectPage>();
|
||||
dfgProjectColumns: GenericColumn<DfgProjectSummary>[] = [];
|
||||
dfgProjectData: DfgProjectSummary[] = [];
|
||||
|
||||
dfgProjectFundingEndTmp = viewChild.required<TemplateRef<any>>(
|
||||
'dfgProjectFundingEndTmp',
|
||||
);
|
||||
dfgProjectActionsTmp = viewChild.required<TemplateRef<any>>(
|
||||
'dfgProjectActionsTmp',
|
||||
);
|
||||
dfgProjectDetailRowTmp = viewChild.required<TemplateRef<any>>(
|
||||
'dfgProjectDetailRowTmp',
|
||||
);
|
||||
|
||||
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',
|
||||
);
|
||||
selectedDfgInstitutions = input.required<Institution[]>();
|
||||
selectedDfgAuthors = input.required<Author[]>();
|
||||
selectedEuInstitutions = input.required<Institution[]>();
|
||||
selectedEuAuthors = input.required<Author[]>();
|
||||
|
||||
readonly pageTotal = computed(() => {
|
||||
return this.dfgProjectPage()?.total ?? 0;
|
||||
readonly dfgQueryParamKeys = projectQueryParamKeys;
|
||||
readonly euQueryParamKeys = euProjectQueryParamKeys;
|
||||
|
||||
constructor(
|
||||
private readonly router: Router,
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
) {}
|
||||
|
||||
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
|
||||
initialValue: this.activatedRoute.snapshot.queryParamMap,
|
||||
});
|
||||
|
||||
constructor(private readonly router: Router) {
|
||||
effect(() => {
|
||||
this.dfgProjectData = this.dfgProjectPage().elements || [];
|
||||
selectedTabIndex = computed(() => {
|
||||
const type = this.queryParamMap().get(PROJECT_TAB_QUERY_PARAM_KEY);
|
||||
return type === 'eu' ? 1 : 0;
|
||||
});
|
||||
|
||||
onTabChange(index: number): void {
|
||||
const type = index === 1 ? 'eu' : 'dfg';
|
||||
this.router.navigate([], {
|
||||
queryParams: { [PROJECT_TAB_QUERY_PARAM_KEY]: type },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
this.personCordisEuProjectData =
|
||||
this.personCordisEuProjectPage().elements || [];
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.dfgProjectColumns = [
|
||||
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
|
||||
{
|
||||
id: 'funding_start',
|
||||
header: 'Förderbeginn',
|
||||
type: 'accessor',
|
||||
accessorKey: 'funding_start',
|
||||
},
|
||||
{
|
||||
id: 'funding_end',
|
||||
header: 'Förderende',
|
||||
type: 'accessor',
|
||||
accessorKey: 'funding_end',
|
||||
cellTemplate: this.dfgProjectFundingEndTmp(),
|
||||
},
|
||||
{
|
||||
id: 'professional_classification',
|
||||
header: 'Fachliche Zuordnung',
|
||||
type: 'accessor',
|
||||
accessorKey: 'professional_classification',
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.dfgProjectActionsTmp(),
|
||||
},
|
||||
];
|
||||
|
||||
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(),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { EuProjectData } from '../../../api/model/euProjectData';
|
||||
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { OrganizationsTableComponent } from './organizations-table/organizations-table/organizations-table.component';
|
||||
import { OrganizationsTableComponent } from './organizations-table/organizations-table.component';
|
||||
import { PublicationsTableComponent } from './publications-table/publications-table.component';
|
||||
import { PatentsCardsComponent } from './patents-cards/patents-cards.component';
|
||||
import { DeliverablesCardsComponent } from './deliverables-cards/deliverables-cards.component';
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<div class="organizations-tab">
|
||||
<mat-card appearance="outlined">
|
||||
@if (showHeader) {
|
||||
<div class="section-header">
|
||||
<mat-icon>business</mat-icon>
|
||||
<h2>{{ headerTitle }} ({{ getOrgsCount() }})</h2>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="organizations-table-wrapper">
|
||||
<app-data-table [data]="orgsToDisplay()" [columns]="columns()">
|
||||
<ng-template #nameTemplate let-org>
|
||||
<div
|
||||
class="org-name-cell"
|
||||
(click)="searchForInstitutionName(org.name || org.shortName || '')">
|
||||
<span class="org-name-text">
|
||||
{{ org.name || org.shortName || 'Unbekannte Organisation' }}
|
||||
</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #roleTemplate let-org>
|
||||
@if (org.role) {
|
||||
<span class="role-chip">{{ org.role }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #cityTemplate let-org>
|
||||
@if (org.city) {
|
||||
<span class="country-chip">
|
||||
{{ org.city }}
|
||||
|
||||
@if (org.country) {
|
||||
<img
|
||||
alt=""
|
||||
class="country-flag"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
getSvgByCountryCode(org.country) +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #ecContributionTemplate let-org>
|
||||
@if (
|
||||
org.ecContribution !== undefined && org.ecContribution !== null
|
||||
) {
|
||||
<span class="currency-value">
|
||||
{{
|
||||
org.ecContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #activityTypeTemplate let-org>
|
||||
@if (org.activityType) {
|
||||
<span class="activity-chip">{{ org.activityType }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #smeTemplate let-org>
|
||||
@if (org.sme) {
|
||||
<span class="sme-badge">SME</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #organizationUrlTemplate let-org>
|
||||
<div class="links-container">
|
||||
@if (org.organizationURL) {
|
||||
<a
|
||||
[href]="org.organizationURL"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link-button"
|
||||
matTooltip="Website öffnen"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon class="link-icon">open_in_new</mat-icon>
|
||||
<span class="link-label">Web</span>
|
||||
</a>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
</app-data-table>
|
||||
<mat-paginator
|
||||
[length]="orgs.length"
|
||||
[pageSize]="pageSize()"
|
||||
(page)="onPageChange($event)"
|
||||
[pageSizeOptions]="paginationService.options">
|
||||
</mat-paginator>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
-5
@@ -1,10 +1,5 @@
|
||||
// Organizations
|
||||
|
||||
.organizations-tab {
|
||||
.card {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
Input,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { MatCard } from '@angular/material/card';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { PaginationService } from '../../../../shared/services/pagination.service';
|
||||
import { HEUOrganization } from '../../../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../../../shared/ui/data-table/data-table.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-organizations-table',
|
||||
imports: [
|
||||
MatIcon,
|
||||
MatCard,
|
||||
MatTooltipModule,
|
||||
CurrencyPipe,
|
||||
DataTableComponent,
|
||||
MatPaginatorModule,
|
||||
],
|
||||
templateUrl: './organizations-table.component.html',
|
||||
styleUrl: './organizations-table.component.scss',
|
||||
})
|
||||
export class OrganizationsTableComponent {
|
||||
private readonly router = inject(Router);
|
||||
public paginationService = inject(PaginationService);
|
||||
|
||||
@Input() orgs: HEUOrganization[] = [];
|
||||
@Input() showHeader: boolean = true;
|
||||
@Input() headerTitle: string = 'Organisationen';
|
||||
|
||||
pageIndex = signal(0);
|
||||
pageSize = signal(10);
|
||||
orgsToDisplay = computed(() => {
|
||||
const startIndex = this.pageIndex() * this.pageSize();
|
||||
return this.orgs.slice(startIndex, startIndex + this.pageSize());
|
||||
});
|
||||
|
||||
nameTemplate = viewChild<TemplateRef<any>>('nameTemplate');
|
||||
roleTemplate = viewChild<TemplateRef<any>>('roleTemplate');
|
||||
cityTemplate = viewChild<TemplateRef<any>>('cityTemplate');
|
||||
ecContributionTemplate = viewChild<TemplateRef<any>>(
|
||||
'ecContributionTemplate',
|
||||
);
|
||||
activityTypeTemplate = viewChild<TemplateRef<any>>('activityTypeTemplate');
|
||||
smeTemplate = viewChild<TemplateRef<any>>('smeTemplate');
|
||||
organizationUrlTemplate = viewChild<TemplateRef<any>>(
|
||||
'organizationUrlTemplate',
|
||||
);
|
||||
|
||||
columns = computed<GenericColumn<HEUOrganization>[]>(() => [
|
||||
{
|
||||
id: 'name',
|
||||
header: 'Name',
|
||||
type: 'accessor',
|
||||
accessorKey: 'name',
|
||||
cellTemplate: this.nameTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'role',
|
||||
header: 'Rolle',
|
||||
type: 'accessor',
|
||||
accessorKey: 'role',
|
||||
cellTemplate: this.roleTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'city',
|
||||
header: 'Stadt',
|
||||
type: 'accessor',
|
||||
accessorKey: 'city',
|
||||
cellTemplate: this.cityTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'ecContribution',
|
||||
header: 'EU-Beitrag',
|
||||
type: 'accessor',
|
||||
accessorKey: 'ecContribution',
|
||||
cellTemplate: this.ecContributionTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'activityType',
|
||||
header: 'Aktivitätstyp',
|
||||
type: 'accessor',
|
||||
accessorKey: 'activityType',
|
||||
cellTemplate: this.activityTypeTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'sme',
|
||||
header: 'SME',
|
||||
type: 'accessor',
|
||||
accessorKey: 'SME',
|
||||
cellTemplate: this.smeTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'organizationURL',
|
||||
header: 'URL',
|
||||
type: 'accessor',
|
||||
accessorKey: 'organizationURL',
|
||||
cellTemplate: this.organizationUrlTemplate(),
|
||||
},
|
||||
]);
|
||||
|
||||
searchForInstitutionName(institutionName: string): void {
|
||||
if (!institutionName) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.router.navigate(['/institutions'], {
|
||||
queryParams: {
|
||||
search: institutionName,
|
||||
},
|
||||
});
|
||||
}
|
||||
onPageChange(event: PageEvent): void {
|
||||
this.pageIndex.set(event.pageIndex);
|
||||
this.pageSize.set(event.pageSize);
|
||||
}
|
||||
|
||||
getSvgByCountryCode(code: string | undefined | null): string {
|
||||
if (!code) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const codeLower = code.toLowerCase();
|
||||
|
||||
if (codeLower === 'uk') {
|
||||
return 'gb';
|
||||
}
|
||||
|
||||
return codeLower;
|
||||
}
|
||||
|
||||
getOrgsCount(): number {
|
||||
return this.orgs?.length || 0;
|
||||
}
|
||||
}
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
<div class="organizations-tab">
|
||||
<mat-card appearance="outlined">
|
||||
<div class="section-header">
|
||||
<mat-icon>business</mat-icon>
|
||||
<h2>Organisationen ({{ orgs.length || 0 }})</h2>
|
||||
</div>
|
||||
<div class="organizations-table-wrapper">
|
||||
<table mat-table [dataSource]="orgs" class="mat-elevation-z2">
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef>Name</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
<div
|
||||
class="org-name-cell"
|
||||
(click)="searchForInstitutionName(org.name || '')">
|
||||
<span class="org-name-text">{{
|
||||
org.name || org.shortName || 'Unbekannte Organisation'
|
||||
}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Role Column -->
|
||||
<ng-container matColumnDef="role">
|
||||
<th mat-header-cell *matHeaderCellDef>Rolle</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.role) {
|
||||
<span class="role-chip">{{ org.role }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Country Column -->
|
||||
<ng-container matColumnDef="country">
|
||||
<th mat-header-cell *matHeaderCellDef>Stadt</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.city) {
|
||||
<span class="country-chip">
|
||||
{{ org.city }}
|
||||
|
||||
<img
|
||||
alt=""
|
||||
class="country-flag"
|
||||
[src]="`https://flagcdn.io/${getSvgByCountryCode(org.country)}.svg`"
|
||||
height="10" />
|
||||
</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- EU Contribution Column -->
|
||||
<ng-container matColumnDef="ecContribution">
|
||||
<th mat-header-cell *matHeaderCellDef>EU-Beitrag</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.ecContribution) {
|
||||
<span class="currency-value">{{
|
||||
org.ecContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Activity Type Column -->
|
||||
<ng-container matColumnDef="activityType">
|
||||
<th mat-header-cell *matHeaderCellDef>Aktivitätstyp</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.activityType) {
|
||||
<span class="activity-chip">{{ org.activityType }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- SME Badge Column -->
|
||||
<ng-container matColumnDef="sme">
|
||||
<th mat-header-cell *matHeaderCellDef>SME</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.sme) {
|
||||
<span class="sme-badge">SME</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- URL Badge Column -->
|
||||
<ng-container matColumnDef="organizationURL">
|
||||
<th mat-header-cell *matHeaderCellDef>URL</th>
|
||||
<td mat-cell *matCellDef="let org">
|
||||
<div class="links-container">
|
||||
@if (org.organizationURL) {
|
||||
<a
|
||||
[href]="org.organizationURL"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="Website öffnen">
|
||||
<mat-icon class="link-icon">open_in_new</mat-icon>
|
||||
<span class="link-label">Web</span>
|
||||
</a>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="organizationDisplayedColumns"></tr>
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: organizationDisplayedColumns"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { MatCard } from '@angular/material/card';
|
||||
import { HEUOrganization } from '../../../../../api';
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
@Component({
|
||||
selector: 'app-organizations-table',
|
||||
imports: [MatTableModule, MatIcon, MatCard, CurrencyPipe],
|
||||
templateUrl: './organizations-table.component.html',
|
||||
styleUrl: './organizations-table.component.scss',
|
||||
})
|
||||
export class OrganizationsTableComponent {
|
||||
private readonly router = inject(Router);
|
||||
|
||||
@Input() orgs!: HEUOrganization[];
|
||||
@Input() showHeader: boolean = true;
|
||||
@Input() headerTitle: string = 'Organizationen';
|
||||
|
||||
// Displayed columns for the organizations table
|
||||
organizationDisplayedColumns: string[] = [
|
||||
'name',
|
||||
'role',
|
||||
'country',
|
||||
'ecContribution',
|
||||
'activityType',
|
||||
'sme',
|
||||
'organizationURL',
|
||||
];
|
||||
|
||||
searchForInstitutionName(institutionName: string): void {
|
||||
this.router.navigate(['/institutions'], {
|
||||
queryParams: {
|
||||
search: institutionName,
|
||||
},
|
||||
});
|
||||
}
|
||||
getSvgByCountryCode(code: string) {
|
||||
const codeLower = code.toLowerCase();
|
||||
if (codeLower === 'uk') {
|
||||
return 'gb';
|
||||
}
|
||||
return codeLower;
|
||||
}
|
||||
getOrgsCount(): number {
|
||||
return this.orgs?.length || 0;
|
||||
}
|
||||
}
|
||||
+111
-128
@@ -6,138 +6,121 @@
|
||||
<h2>{{ headerTitle }} ({{ getPublicationCount() }})</h2>
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<table mat-table [dataSource]="publications" class="mat-elevation-z2">
|
||||
<!-- Title Column -->
|
||||
<ng-container matColumnDef="title">
|
||||
<th mat-header-cell *matHeaderCellDef>Titel</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
<div class="pub-title-cell" (click)="searchForPublication(pub)">
|
||||
<span class="pub-title-text">
|
||||
{{ pub.title || 'Kein Titel' }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Authors Column -->
|
||||
<ng-container matColumnDef="authors">
|
||||
<th mat-header-cell *matHeaderCellDef>Autoren</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
@if (pub.authors) {
|
||||
@let authorList = parseAuthors(pub.authors);
|
||||
@if (authorList.length > 0) {
|
||||
<div class="authors-container">
|
||||
@for (author of authorList; track author; let last = $last) {
|
||||
<span class="author-wrapper">
|
||||
<span
|
||||
class="author-name"
|
||||
(click)="
|
||||
searchForPersonName(author); $event.stopPropagation()
|
||||
">
|
||||
{{ author }}
|
||||
</span>
|
||||
@if (!last) {
|
||||
<span class="author-separator">, </span>
|
||||
}
|
||||
</span>
|
||||
<app-data-table [data]="publicationsToDisplay()" [columns]="columns()">
|
||||
<ng-template #titleTemplate let-pub>
|
||||
<div class="pub-title-cell" (click)="searchForPublication(pub)">
|
||||
<span class="pub-title-text">
|
||||
{{ pub.title || 'Kein Titel' }}
|
||||
</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTemplate let-pub>
|
||||
@if (pub.authors) {
|
||||
@let authorList = parseAuthors(pub.authors);
|
||||
|
||||
@if (authorList.length > 0) {
|
||||
<div class="authors-container">
|
||||
@for (author of authorList; track author; let last = $last) {
|
||||
<span class="author-wrapper">
|
||||
<span
|
||||
class="author-name"
|
||||
(click)="
|
||||
searchForPersonName(author); $event.stopPropagation()
|
||||
">
|
||||
{{ author }}
|
||||
</span>
|
||||
|
||||
@if (!last) {
|
||||
<span class="author-separator">, </span>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Journal Column -->
|
||||
<ng-container matColumnDef="journal">
|
||||
<th mat-header-cell *matHeaderCellDef>Zeitschrift</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
@if (pub.journalNumber) {
|
||||
<span class="journal-chip" [matTooltip]="pub.journalNumber">{{
|
||||
pub.journalNumber
|
||||
}}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Year Column -->
|
||||
<ng-container matColumnDef="year">
|
||||
<th mat-header-cell *matHeaderCellDef>Jahr</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
@if (pub.publishedYear) {
|
||||
<span class="year-value">{{ pub.publishedYear }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Publisher Column -->
|
||||
<ng-container matColumnDef="publisher">
|
||||
<th mat-header-cell *matHeaderCellDef>Verlag</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
@if (pub.publisher) {
|
||||
<span class="publisher-text">{{ pub.publisher }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Links Column -->
|
||||
<ng-container matColumnDef="links">
|
||||
<th mat-header-cell *matHeaderCellDef>Links</th>
|
||||
<td mat-cell *matCellDef="let pub">
|
||||
<div class="links-container">
|
||||
@if (pub.doi) {
|
||||
<a
|
||||
[href]="'https://doi.org/' + pub.doi"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="DOI öffnen">
|
||||
<mat-icon class="link-icon">open_in_new</mat-icon>
|
||||
<span class="link-label">DOI</span>
|
||||
</a>
|
||||
}
|
||||
@if (pub.repositoryUrl) {
|
||||
<a
|
||||
[href]="pub.repositoryUrl"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="Repository öffnen">
|
||||
<mat-icon class="link-icon">folder_open</mat-icon>
|
||||
<span class="link-label">Repo</span>
|
||||
</a>
|
||||
}
|
||||
@if (pub.publicationUrl) {
|
||||
<a
|
||||
[href]="pub.publicationUrl"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="Publikation öffnen">
|
||||
<mat-icon class="link-icon">article</mat-icon>
|
||||
<span class="link-label">Link</span>
|
||||
</a>
|
||||
}
|
||||
@if (!pub.doi && !pub.repositoryUrl && !pub.publicationUrl) {
|
||||
<span class="empty-value">—</span>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="publicationDisplayedColumns"></tr>
|
||||
<tr
|
||||
mat-row
|
||||
*matRowDef="let row; columns: publicationDisplayedColumns"
|
||||
class="publication-row"></tr>
|
||||
</table>
|
||||
</div>
|
||||
<ng-template #journalTemplate let-pub>
|
||||
@if (pub.journalNumber) {
|
||||
<span class="journal-chip" [matTooltip]="pub.journalNumber">
|
||||
{{ pub.journalNumber }}
|
||||
</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #yearTemplate let-pub>
|
||||
@if (pub.publishedYear) {
|
||||
<span class="year-value">{{ pub.publishedYear }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #publisherTemplate let-pub>
|
||||
@if (pub.publisher) {
|
||||
<span class="publisher-text">{{ pub.publisher }}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #linksTemplate let-pub>
|
||||
<div class="links-container">
|
||||
@if (pub.doi) {
|
||||
<a
|
||||
[href]="'https://doi.org/' + pub.doi"
|
||||
target="_blank"
|
||||
class="link-button doi-link"
|
||||
matTooltip="DOI öffnen"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon class="link-icon">link</mat-icon>
|
||||
<span class="link-label">DOI</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (pub.repositoryUrl) {
|
||||
<a
|
||||
[href]="pub.repositoryUrl"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="Repository öffnen"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon class="link-icon">folder_open</mat-icon>
|
||||
<span class="link-label">Repo</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (pub.publicationUrl) {
|
||||
<a
|
||||
[href]="pub.publicationUrl"
|
||||
target="_blank"
|
||||
class="link-button"
|
||||
matTooltip="Publikation öffnen"
|
||||
(click)="$event.stopPropagation()">
|
||||
<mat-icon class="link-icon">article</mat-icon>
|
||||
<span class="link-label">Link</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (!pub.doi && !pub.repositoryUrl && !pub.publicationUrl) {
|
||||
<span class="empty-value">—</span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
</app-data-table>
|
||||
<mat-paginator
|
||||
[length]="publications.length"
|
||||
[pageSize]="pageSize()"
|
||||
(page)="onPageChange($event)"
|
||||
[pageSizeOptions]="paginationService.options">
|
||||
</mat-paginator>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
-25
@@ -77,12 +77,6 @@
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.authors-text {
|
||||
color: #4a5a6a;
|
||||
font-size: 13px;
|
||||
color: #1a1a1a;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.author-name:hover {
|
||||
color: #005a9c;
|
||||
text-decoration: underline;
|
||||
@@ -172,13 +166,6 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.publicationDisplayedColumns {
|
||||
// Hide less important columns on mobile
|
||||
.mat-column-publisher {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.journal-chip {
|
||||
max-width: 120px;
|
||||
font-size: 11px;
|
||||
@@ -212,15 +199,6 @@
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.authors-text {
|
||||
font-size: 11px;
|
||||
max-width: 100px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.links-container {
|
||||
gap: 4px;
|
||||
}
|
||||
@@ -231,6 +209,3 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.deliverable-item {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
+89
-13
@@ -1,36 +1,112 @@
|
||||
import { Component, computed, inject, Input } from '@angular/core';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
Input,
|
||||
viewChild,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { MatCard } from '@angular/material/card';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { HEUPublication } from '../../../../api';
|
||||
import { Router } from '@angular/router';
|
||||
import { TemplateRef } from '@angular/core';
|
||||
import { PaginationService } from '../../../../shared/services/pagination.service';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../../../shared/ui/data-table/data-table.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publications-table',
|
||||
imports: [CommonModule, MatTableModule, MatIcon, MatCard, MatTooltipModule],
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatIcon,
|
||||
MatCard,
|
||||
MatTooltipModule,
|
||||
DataTableComponent,
|
||||
MatPaginatorModule,
|
||||
],
|
||||
templateUrl: './publications-table.component.html',
|
||||
styleUrl: './publications-table.component.scss',
|
||||
})
|
||||
export class PublicationsTableComponent {
|
||||
private router = inject(Router);
|
||||
public paginationService = inject(PaginationService);
|
||||
|
||||
@Input() publications: HEUPublication[] = [];
|
||||
@Input() showHeader: boolean = true;
|
||||
@Input() headerTitle: string = 'Publikationen';
|
||||
|
||||
pageIndex = signal(0);
|
||||
pageSize = signal(10);
|
||||
publicationsToDisplay = computed(() => {
|
||||
const startIndex = this.pageIndex() * this.pageSize();
|
||||
return this.publications.slice(startIndex, startIndex + this.pageSize());
|
||||
});
|
||||
// Templates for custom cell rendering
|
||||
titleTemplate = viewChild<TemplateRef<any>>('titleTemplate');
|
||||
authorsTemplate = viewChild<TemplateRef<any>>('authorsTemplate');
|
||||
journalTemplate = viewChild<TemplateRef<any>>('journalTemplate');
|
||||
yearTemplate = viewChild<TemplateRef<any>>('yearTemplate');
|
||||
publisherTemplate = viewChild<TemplateRef<any>>('publisherTemplate');
|
||||
linksTemplate = viewChild<TemplateRef<any>>('linksTemplate');
|
||||
|
||||
// Displayed columns for the publications table
|
||||
publicationDisplayedColumns: string[] = [
|
||||
'title',
|
||||
'authors',
|
||||
'journal',
|
||||
'year',
|
||||
'publisher',
|
||||
'links',
|
||||
];
|
||||
author_names = computed(() => 'keka');
|
||||
columns = computed<GenericColumn<HEUPublication>[]>(() => [
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title',
|
||||
cellTemplate: this.titleTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
header: 'Autoren',
|
||||
type: 'display',
|
||||
cellTemplate: this.authorsTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'journalNumber',
|
||||
header: 'Zeitschrift',
|
||||
type: 'accessor',
|
||||
accessorKey: 'journalNumber',
|
||||
cellTemplate: this.journalTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'publishedYear',
|
||||
header: 'Jahr',
|
||||
type: 'accessor',
|
||||
accessorKey: 'publishedYear',
|
||||
cellTemplate: this.yearTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'publisher',
|
||||
header: 'Verlag',
|
||||
type: 'accessor',
|
||||
accessorKey: 'publisher',
|
||||
cellTemplate: this.publisherTemplate(),
|
||||
},
|
||||
{
|
||||
id: 'links',
|
||||
header: 'Links',
|
||||
type: 'display',
|
||||
cellTemplate: this.linksTemplate(),
|
||||
},
|
||||
]);
|
||||
|
||||
onPageChange(event: PageEvent): void {
|
||||
this.pageIndex.set(event.pageIndex);
|
||||
this.pageSize.set(event.pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
* Navigate to publication details
|
||||
*/
|
||||
searchForPublication(pub: HEUPublication): void {
|
||||
|
||||
@@ -2,26 +2,60 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { DfgProjectPage, ProjectsService } from '../api';
|
||||
|
||||
export const projectQueryParamKeys = {
|
||||
page: 'page',
|
||||
size: 'size',
|
||||
title: 'title',
|
||||
institutionId: 'institutionId',
|
||||
years: 'years',
|
||||
authorId: 'authorId',
|
||||
topicId: 'topicId',
|
||||
sortBy: 'sort_by',
|
||||
sortDirection: 'sort_direction',
|
||||
} as const;
|
||||
|
||||
export const dfgProjectsResolver: ResolveFn<DfgProjectPage> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
const page = route.queryParamMap.get('page') ?? '0';
|
||||
const size = route.queryParamMap.get('size') ?? '10';
|
||||
const rawAuthorId = route.parent?.params['id'];
|
||||
if (!rawAuthorId) {
|
||||
throw new Error('Author ID is required to resolve collaboration network');
|
||||
}
|
||||
|
||||
const searchTerm = route.queryParamMap.get('search');
|
||||
const sortBy = route.queryParamMap.get('sort_by') || 'title';
|
||||
const sortDirection = route.queryParamMap.get('sort_direction') || 'asc';
|
||||
const page = Number(route.queryParamMap.get(projectQueryParamKeys.page)) || 0;
|
||||
const size =
|
||||
Number(route.queryParamMap.get(projectQueryParamKeys.size)) || 10;
|
||||
const searchTerm =
|
||||
route.queryParamMap.get(projectQueryParamKeys.title) ?? undefined;
|
||||
const sortBy =
|
||||
route.queryParamMap.get(projectQueryParamKeys.sortBy) || 'title';
|
||||
const sortDirection =
|
||||
route.queryParamMap.get(projectQueryParamKeys.sortDirection) || 'asc';
|
||||
|
||||
// TODO: verify ProjectsService.getDfgProjects accepts institution/author
|
||||
// filters. Wire these in once the service signature supports them.
|
||||
const topics = route.queryParamMap.getAll(projectQueryParamKeys.topicId);
|
||||
|
||||
const years = route.queryParamMap.getAll(projectQueryParamKeys.years);
|
||||
const institutionIds = route.queryParamMap.getAll(
|
||||
projectQueryParamKeys.institutionId,
|
||||
);
|
||||
const authorIds = route.queryParamMap.getAll(projectQueryParamKeys.authorId);
|
||||
console.log(
|
||||
'RESOLVING',
|
||||
authorIds,
|
||||
institutionIds,
|
||||
topics,
|
||||
years,
|
||||
searchTerm,
|
||||
);
|
||||
return inject(ProjectsService).getDfgProjects(
|
||||
rawAuthorId,
|
||||
searchTerm ?? undefined,
|
||||
Number(page),
|
||||
Number(size),
|
||||
authorIds,
|
||||
institutionIds,
|
||||
searchTerm,
|
||||
topics,
|
||||
years,
|
||||
page,
|
||||
size,
|
||||
sortBy,
|
||||
sortDirection,
|
||||
);
|
||||
|
||||
@@ -1,13 +1,50 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { CordisEuProjectPage, ProjectsService } from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const euProjectQueryParamKeys = {
|
||||
page: 'page',
|
||||
size: 'size',
|
||||
title: 'title',
|
||||
institutionId: 'institutionId',
|
||||
authorId: 'authorId',
|
||||
sortBy: 'sort_by',
|
||||
sortDirection: 'sort_direction',
|
||||
} as const;
|
||||
|
||||
export const personCordisEuProjectPageResolver: ResolveFn<
|
||||
CordisEuProjectPage
|
||||
> = (route, state) => {
|
||||
const rawAuthorId = route.parent?.paramMap.get('id') ?? null;
|
||||
if (!rawAuthorId) {
|
||||
throw new Error('Author ID is required to resolve collaboration network');
|
||||
throw new Error('Author ID is required to resolve EU projects.');
|
||||
}
|
||||
return inject(ProjectsService).getEuProjectsForAuthor(rawAuthorId);
|
||||
|
||||
const page =
|
||||
Number(route.queryParamMap.get(euProjectQueryParamKeys.page)) || 0;
|
||||
const size =
|
||||
Number(route.queryParamMap.get(euProjectQueryParamKeys.size)) || 10;
|
||||
const searchTerm =
|
||||
route.queryParamMap.get(euProjectQueryParamKeys.title) ?? undefined;
|
||||
const sortBy =
|
||||
route.queryParamMap.get(euProjectQueryParamKeys.sortBy) || 'title';
|
||||
const sortDirection =
|
||||
route.queryParamMap.get(euProjectQueryParamKeys.sortDirection) || 'asc';
|
||||
|
||||
const institutionIds = route.queryParamMap.getAll(
|
||||
euProjectQueryParamKeys.institutionId,
|
||||
);
|
||||
const authorIds = route.queryParamMap.getAll(
|
||||
euProjectQueryParamKeys.authorId,
|
||||
);
|
||||
return inject(ProjectsService).getEuProjectsForAuthor(
|
||||
rawAuthorId,
|
||||
// searchTerm,
|
||||
// page,
|
||||
// size,
|
||||
// sortBy,
|
||||
// sortDirection,
|
||||
// institutionIds,
|
||||
// authorIds,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
<app-query-param-paginator
|
||||
[total]="total()"
|
||||
[queryParamPageKey]="queryParamKeys.page"
|
||||
[queryParamSizeKey]="queryParamKeys.size"
|
||||
[pageSizeOptions]="[10]" />
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{ element.funding_end == '2999' ? 'laufend' : element.funding_end }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-element>
|
||||
<a
|
||||
[routerLink]="['/projects/dfg', element.id]"
|
||||
target="_blank"
|
||||
mat-icon-button
|
||||
color="primary">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTmp let-project>
|
||||
@let projectAuthors = getProjectAuthors(project);
|
||||
@let isProjectAuthorsExpanded = isProjectPersonsExpanded(project);
|
||||
@let visibleAuthors =
|
||||
isProjectAuthorsExpanded ? projectAuthors : projectAuthors.slice(0, 3);
|
||||
<div class="author-tags" aria-label="Autoren" style="padding: 0.5rem 0">
|
||||
@for (author of visibleAuthors; track author.person_id) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isAuthorActive(author.person_id!)"
|
||||
[matTooltip]="getAuthorTooltipText(author)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getAuthorTooltipText(author)"
|
||||
(click)="filterByAuthor(author.person_id!)">
|
||||
<mat-icon class="institution-icon">person</mat-icon>
|
||||
<span class="institution-name">{{ author.full_name }}</span>
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (projectAuthors.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="isProjectAuthorsExpanded"
|
||||
(click)="toggleProjectAuthorsExpansion(project)">
|
||||
{{
|
||||
isProjectAuthorsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (projectAuthors.length - 3)
|
||||
}}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #institutionsTmp let-project>
|
||||
@let institutions = getProjectInstitutions(project);
|
||||
|
||||
<div
|
||||
class="institution-tags"
|
||||
aria-label="Institutionen"
|
||||
style="padding: 0.5rem 0">
|
||||
@for (
|
||||
institution of isProjectInstitutionsExpanded(project)
|
||||
? institutions
|
||||
: institutions.slice(0, 3);
|
||||
track getProjectInstitutionId(institution)
|
||||
) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isInstitutionActive(institution.id!)"
|
||||
[matTooltip]="getInstitutionTooltipText(institution)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getInstitutionTooltipText(institution)"
|
||||
(click)="filterByInstitution(institution)">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{ institution.name_de }}</span>
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (institutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
(click)="toggleProjectInstitutionsExpansion(project)">
|
||||
@if (isProjectInstitutionsExpanded(project)) {
|
||||
Weniger anzeigen
|
||||
} @else {
|
||||
+{{ institutions.length - 3 }} weitere
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<!--
|
||||
<ng-template #institutionsTmp let-work>
|
||||
@let publicationInstitutions = getWorkInstitutions(work);
|
||||
@let institutionsExpanded = isWorkInstitutionsExpanded(work);
|
||||
@let visibleInstitutions =
|
||||
institutionsExpanded
|
||||
? publicationInstitutions
|
||||
: publicationInstitutions.slice(0, 3);
|
||||
<div
|
||||
class="institution-tags"
|
||||
aria-label="Institutionen"
|
||||
style="padding: 0.5rem 0">
|
||||
@for (institution of visibleInstitutions; track institution.id) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isInstitutionActive(institution.id!)"
|
||||
[matTooltip]="getInstitutionTooltipText(institution)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getInstitutionTooltipText(institution)"
|
||||
(click)="filterByInstitution(institution)">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{ institution.display_name }}</span>
|
||||
@if (institution.country_code) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
institution.country_code.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
<span class="country-code">{{
|
||||
institution.country_code.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (publicationInstitutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="institutionsExpanded"
|
||||
(click)="toggleWorkInstitutionsExpansion(work)">
|
||||
{{
|
||||
institutionsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (publicationInstitutions.length - 3)
|
||||
}}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template> -->
|
||||
@@ -0,0 +1,594 @@
|
||||
.page {
|
||||
padding: 28px 32px 42px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.publication-filter-stack {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 25px;
|
||||
}
|
||||
|
||||
.publication-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.publication-filters mat-form-field {
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
.publication-filters .institution-filter,
|
||||
.publication-filters .topic-filter {
|
||||
flex: 1 1 200px;
|
||||
width: auto;
|
||||
min-width: 180px;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.publication-filters .sort-field {
|
||||
width: 235px;
|
||||
}
|
||||
|
||||
.publication-filters .reset-filter-btn {
|
||||
min-width: 132px;
|
||||
height: 42px;
|
||||
padding: 0 14px;
|
||||
border-color: #d9e2f0;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
color: var(--sg-text);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.publication-filters .reset-filter-btn mat-icon {
|
||||
margin-right: 6px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-text-field-wrapper {
|
||||
height: 42px;
|
||||
background: var(--sg-surface-soft);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-focused .mat-mdc-text-field-wrapper {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow: 0 0 0 2px var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-flex {
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-infix {
|
||||
min-height: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mdc-notched-outline__leading,
|
||||
::ng-deep .publication-filters .mdc-notched-outline__notch,
|
||||
::ng-deep .publication-filters .mdc-notched-outline__trailing {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter-prefix-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 18px;
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-icon-prefix {
|
||||
padding: 0 4px 0 10px;
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-select-value,
|
||||
::ng-deep .publication-filters input.mat-mdc-input-element {
|
||||
color: var(--sg-text);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-select-placeholder,
|
||||
::ng-deep .publication-filters input.mat-mdc-input-element::placeholder {
|
||||
color: var(--sg-text-muted);
|
||||
opacity: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-icon-suffix,
|
||||
::ng-deep .publication-filters .mat-mdc-select-arrow-wrapper {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.active-filters-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 8px 16px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.active-filters-label {
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.chips-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.filter-meta-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--sg-border-strong);
|
||||
border-radius: 4px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.filter-topic-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: min(320px, 46vw);
|
||||
padding: 3px 8px;
|
||||
border-radius: 7px;
|
||||
background: color-mix(in srgb, var(--topic-color) 22%, #ffffff);
|
||||
color: color-mix(in srgb, var(--topic-color) 45%, #07163d);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
box-shadow: inset 0 0 0 1px
|
||||
color-mix(in srgb, var(--topic-color) 45%, transparent);
|
||||
}
|
||||
|
||||
.filter-topic-chip__icon {
|
||||
flex: 0 0 auto;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.active-institution-filter,
|
||||
.active-meta-filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.filter-institution-chip,
|
||||
.publication-institution-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
border: 1px solid var(--sg-primary-border, var(--sg-border));
|
||||
border-radius: 4px;
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-primary);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.filter-institution-chip {
|
||||
max-width: 340px;
|
||||
}
|
||||
|
||||
.publication-institution-tag {
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&: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);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active:hover,
|
||||
&.active:focus-visible {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-icon,
|
||||
.publication-institution-tag .institution-icon,
|
||||
.filter-meta-chip__icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-right: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.filter-meta-chip__icon {
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-name,
|
||||
.publication-institution-tag .institution-name {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.filter-institution-chip .flag-img,
|
||||
.publication-institution-tag .flag-img {
|
||||
flex-shrink: 0;
|
||||
margin-left: 6px;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.filter-institution-chip .country-code,
|
||||
.publication-institution-tag .country-code {
|
||||
flex-shrink: 0;
|
||||
margin-left: 2px;
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon,
|
||||
.publication-institution-tag .institution-open-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-institution-chip:hover .institution-open-icon,
|
||||
.publication-institution-tag:hover .institution-open-icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon:hover,
|
||||
.publication-institution-tag .institution-open-icon:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.filter-meta-chip__label,
|
||||
.filter-topic-chip__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.active-institution-filter button,
|
||||
.active-meta-filter button {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--sg-text-soft);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
}
|
||||
|
||||
.active-institution-filter button mat-icon,
|
||||
.active-meta-filter button mat-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
min-width: 1120px;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 10px;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: inline-block;
|
||||
max-width: 520px;
|
||||
line-height: 1.35;
|
||||
color: var(--sg-text);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.title:hover {
|
||||
color: var(--sg-text);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
table.is-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.table-status {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-height: 240px;
|
||||
padding: 32px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
}
|
||||
|
||||
.cell-filter-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: var(--sg-text);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
font-weight: 600;
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.type-filter-btn {
|
||||
display: inline-flex;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 1px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.topic-chips,
|
||||
.institution-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.topic-chips {
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.institution-tags {
|
||||
align-items: flex-start;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.publication-institution-more,
|
||||
.publication-topic-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: #fff;
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.publication-topic-more {
|
||||
max-width: 180px;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-header-cell {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-row {
|
||||
height: 86px;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-cell {
|
||||
color: var(--sg-text);
|
||||
border-bottom-color: var(--sg-border);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table-wrap ::ng-deep {
|
||||
.mat-column-type,
|
||||
.mat-column-year,
|
||||
.mat-column-language,
|
||||
.mat-column-citations,
|
||||
.mat-mdc-header-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mat-mdc-cell:not(:last-child),
|
||||
.mat-mdc-header-cell:not(:last-child) {
|
||||
border-right: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.mat-column-institutions,
|
||||
.mat-column-topics {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 66px;
|
||||
padding: 0 22px 0 28px;
|
||||
border: 0;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.page {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.publication-filter-stack {
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.publication-filters {
|
||||
justify-content: stretch;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.publication-filters mat-form-field,
|
||||
.publication-filters button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.publication-filters .institution-filter,
|
||||
.publication-filters .topic-filter {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.active-filters-row {
|
||||
align-self: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
mat-expansion-panel {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-none);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
mat-expansion-panel-header {
|
||||
padding: 0 16px;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
mat-panel-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
mat-panel-description {
|
||||
font-size: 14px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
// ------------------------
|
||||
|
||||
.author-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
max-width: 280px;
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
input,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { DfgProjectPage, DfgProjectSummary } from '../../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../data-table/data-table.component';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component';
|
||||
import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DfgPersonSummary } from '../../../api/model/dfgPersonSummary';
|
||||
import { MatTooltip } from '@angular/material/tooltip';
|
||||
@Component({
|
||||
selector: 'app-dfg-project-table',
|
||||
imports: [
|
||||
DataTableComponent,
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
QueryParamPaginatorComponent,
|
||||
MatTooltip,
|
||||
],
|
||||
templateUrl: './dfg-project-table.component.html',
|
||||
styleUrl: './dfg-project-table.component.scss',
|
||||
})
|
||||
export class DfgProjectTableComponent implements OnInit {
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
page = input.required<DfgProjectPage>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
topicFilterEnabled = input<boolean>(false);
|
||||
|
||||
elements = computed(() => this.page().elements ?? []);
|
||||
|
||||
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
|
||||
initialValue: this.activatedRoute.snapshot.queryParamMap,
|
||||
});
|
||||
queryParamKeys = projectQueryParamKeys;
|
||||
total = computed(() => this.page().total ?? 0);
|
||||
|
||||
columns: GenericColumn<DfgProjectSummary>[] = [];
|
||||
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
|
||||
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
|
||||
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
|
||||
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
|
||||
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
detailRowTmp = viewChild.required<TemplateRef<any>>('detailRowTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
|
||||
expandedProjectAuthorsId: string[] = [];
|
||||
expandedProjectInstitutionsId: string[] = [];
|
||||
|
||||
selectedYearsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.years).map(Number);
|
||||
});
|
||||
|
||||
selectedAuthorIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.authorId);
|
||||
});
|
||||
|
||||
selectedInstitutionIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.institutionId);
|
||||
});
|
||||
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('DFG PROJECTS', this.page());
|
||||
this.columns = [
|
||||
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
|
||||
{
|
||||
id: 'funding_start',
|
||||
header: 'Förderbeginn',
|
||||
type: 'accessor',
|
||||
accessorKey: 'funding_start',
|
||||
},
|
||||
{
|
||||
id: 'funding_end',
|
||||
header: 'Förderende',
|
||||
type: 'accessor',
|
||||
accessorKey: 'funding_end',
|
||||
cellTemplate: this.fundingEndTmp(),
|
||||
},
|
||||
{
|
||||
id: 'names',
|
||||
header: 'user',
|
||||
type: 'accessor',
|
||||
accessorKey: 'names',
|
||||
cellTemplate: this.authorsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
header: 'Institutionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.institutionsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'professional_classification',
|
||||
header: 'Fachliche Zuordnung',
|
||||
type: 'accessor',
|
||||
accessorKey: 'professional_classification',
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.actionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sortNames(names: string[] | undefined): string[] {
|
||||
return [...(names ?? [])].sort((a, b) => a.localeCompare(b));
|
||||
}
|
||||
isAuthorActive(authorId: number): boolean {
|
||||
return (
|
||||
!!authorId &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedAuthorIdsQueryParams().includes(String(authorId))
|
||||
);
|
||||
}
|
||||
getProjectAuthors(project: DfgProjectSummary): DfgPersonSummary[] {
|
||||
return project.persons?.filter((a): a is DfgPersonSummary => !!a) || [];
|
||||
}
|
||||
|
||||
toggleProjectAuthorsExpansion(project: DfgProjectSummary): void {
|
||||
if (!project.id) return;
|
||||
|
||||
if (this.expandedProjectAuthorsId.includes(project.id)) {
|
||||
this.expandedProjectAuthorsId = this.expandedProjectAuthorsId.filter(
|
||||
(id) => id !== project.id,
|
||||
);
|
||||
} else {
|
||||
this.expandedProjectAuthorsId.push(project.id);
|
||||
}
|
||||
}
|
||||
isProjectPersonsExpanded(project: DfgProjectSummary): boolean {
|
||||
if (!project.id) return false;
|
||||
|
||||
return this.expandedProjectAuthorsId.includes(project.id);
|
||||
}
|
||||
getAuthorTooltipText(author: DfgPersonSummary): string {
|
||||
if (this.authorFilterEnabled() && author.person_id) {
|
||||
return `Nach Autor filtern: ${author.full_name}`;
|
||||
}
|
||||
return `Autor: ${author.full_name}`;
|
||||
}
|
||||
filterByAuthor(authorId: number): void {
|
||||
if (!authorId || !this.authorFilterEnabled()) return;
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
if (selectedAuthorIds.includes(String(authorId))) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.authorId]: selectedAuthorIds.filter(
|
||||
(id) => id !== String(authorId),
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.authorId]: [
|
||||
...selectedAuthorIds,
|
||||
String(authorId),
|
||||
],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isProjectInstitutionsExpanded(project: DfgProjectSummary): boolean {
|
||||
if (!project.id) return false;
|
||||
|
||||
return this.expandedProjectInstitutionsId.includes(project.id);
|
||||
}
|
||||
|
||||
toggleProjectInstitutionsExpansion(project: DfgProjectSummary): void {
|
||||
if (!project.id) return;
|
||||
|
||||
if (this.expandedProjectInstitutionsId.includes(project.id)) {
|
||||
this.expandedProjectInstitutionsId =
|
||||
this.expandedProjectInstitutionsId.filter((id) => id !== project.id);
|
||||
} else {
|
||||
this.expandedProjectInstitutionsId.push(project.id);
|
||||
}
|
||||
}
|
||||
|
||||
getProjectInstitutions(project: DfgProjectSummary): any[] {
|
||||
const institutions = new Map<string, any>();
|
||||
|
||||
for (const institution of project.institutions ?? []) {
|
||||
const id = this.getProjectInstitutionId(institution);
|
||||
if (!id) continue;
|
||||
|
||||
institutions.set(id, institution);
|
||||
}
|
||||
|
||||
return Array.from(institutions.values()).sort((a, b) =>
|
||||
this.getProjectInstitutionName(a).localeCompare(
|
||||
this.getProjectInstitutionName(b),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
getProjectInstitutionId(institution: any): string | null {
|
||||
const id = institution.id;
|
||||
|
||||
return id == null ? null : String(id);
|
||||
}
|
||||
|
||||
getProjectInstitutionName(institution: any): string {
|
||||
return institution.name_de ?? institution.name_en;
|
||||
}
|
||||
|
||||
isInstitutionActive(
|
||||
institutionId: string | number | null | undefined,
|
||||
): boolean {
|
||||
return (
|
||||
!!institutionId &&
|
||||
this.institutionFilterEnabled() &&
|
||||
this.selectedInstitutionIdsQueryParams().includes(String(institutionId))
|
||||
);
|
||||
}
|
||||
|
||||
filterByInstitution(institution: any): void {
|
||||
const institutionId = this.getProjectInstitutionId(institution);
|
||||
|
||||
if (!institutionId || !this.institutionFilterEnabled()) return;
|
||||
|
||||
const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams();
|
||||
|
||||
if (selectedInstitutionIds.includes(institutionId)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionId]: selectedInstitutionIds.filter(
|
||||
(id) => id !== institutionId,
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionId]: [
|
||||
...selectedInstitutionIds,
|
||||
institutionId,
|
||||
],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getInstitutionTooltipText(institution: any): string {
|
||||
const name = this.getProjectInstitutionName(institution);
|
||||
|
||||
if (this.institutionFilterEnabled()) {
|
||||
return `Nach Institution filtern: ${name}`;
|
||||
}
|
||||
|
||||
return `Institution: ${name}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
<app-query-param-paginator
|
||||
[total]="total()"
|
||||
[queryParamPageKey]="queryParamKeys.page"
|
||||
[queryParamSizeKey]="queryParamKeys.size"
|
||||
[pageSizeOptions]="[10]" />
|
||||
|
||||
<ng-template #fundingStartTmp let-element>
|
||||
{{ element.startDate | date: 'dd.MM.yyyy' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{ element.endDate | date: 'dd.MM.yyyy' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #fundingAmountTmp let-element>
|
||||
{{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp 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>
|
||||
@@ -0,0 +1,78 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
input,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { CordisEuProject, CordisEuProjectPage } from '../../../api';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../data-table/data-table.component';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { CurrencyPipe, DatePipe } from '@angular/common';
|
||||
import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component';
|
||||
import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-eu-project-table',
|
||||
imports: [
|
||||
DataTableComponent,
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
DatePipe,
|
||||
CurrencyPipe,
|
||||
QueryParamPaginatorComponent,
|
||||
],
|
||||
templateUrl: './eu-project-table.component.html',
|
||||
styleUrl: './eu-project-table.component.scss',
|
||||
})
|
||||
export class EuProjectTableComponent implements OnInit {
|
||||
page = input.required<CordisEuProjectPage>();
|
||||
queryParamKeys = projectQueryParamKeys;
|
||||
|
||||
elements = computed(() => this.page().elements ?? []);
|
||||
total = computed(() => this.page().total ?? 0);
|
||||
|
||||
columns: GenericColumn<CordisEuProject>[] = [];
|
||||
|
||||
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
|
||||
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
||||
fundingAmountTmp = viewChild.required<TemplateRef<any>>('fundingAmountTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
|
||||
ngOnInit(): void {
|
||||
this.columns = [
|
||||
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
|
||||
{
|
||||
id: 'startDate',
|
||||
header: 'Startdatum',
|
||||
type: 'display',
|
||||
cellTemplate: this.fundingStartTmp(),
|
||||
},
|
||||
{
|
||||
id: 'endDate',
|
||||
header: 'Enddatum',
|
||||
type: 'display',
|
||||
cellTemplate: this.fundingEndTmp(),
|
||||
},
|
||||
{
|
||||
id: 'ecMaxContribution',
|
||||
header: 'Förderbetrag (EU)',
|
||||
type: 'display',
|
||||
cellTemplate: this.fundingAmountTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
type: 'display',
|
||||
cellTemplate: this.actionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="content">
|
||||
@if (showTitleFilter()) {
|
||||
<app-query-param-input
|
||||
[queryParamKey]="queryParamKeys.title"
|
||||
label="Suche nach Titel"
|
||||
placeholder="Suche"
|
||||
[debounceTime]="300" />
|
||||
}
|
||||
<div class="select-area">
|
||||
@if (showInstitutionFilter()) {
|
||||
<app-searchable-institution-select
|
||||
[label]="institutionLabel()"
|
||||
[selectedInstitutions]="selectedInstitutions()"
|
||||
(handleInstitutionSelectChange)="
|
||||
handleInstitutionSelectChange($event)
|
||||
" />
|
||||
}
|
||||
@if (showYearFilter()) {
|
||||
<app-searchable-year-select
|
||||
[label]="yearLabel()"
|
||||
[selectedYears]="selectedYears()"
|
||||
(handleYearSelectChange)="handleYearSelectChange($event)" />
|
||||
}
|
||||
@if (showAuthorFilter()) {
|
||||
<app-searchable-author-select
|
||||
[label]="authorLabel()"
|
||||
[selectedAuthors]="selectedAuthors()"
|
||||
(handleAuthorSelectChange)="handleAuthorSelectChange($event)" />
|
||||
}
|
||||
<button mat-stroked-button color="primary" (click)="resetFilters()">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
Filter zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
<app-selected-filters [observers]="observers()" />
|
||||
</div>
|
||||
@@ -0,0 +1,13 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.select-area {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { Author, Institution } from '../../../api';
|
||||
import { QueryParamInputComponent } from '../query-param-input/query-param-input.component';
|
||||
import { SearchableInstitutionSelectComponent } from '../searchable-institution-select/searchable-institution-select.component';
|
||||
import { SearchableAuthorSelectComponent } from '../searchable-author-select/searchable-author-select.component';
|
||||
import { SearchableYearSelectComponent } from '../searchable-year-select/searchable-year-select.component';
|
||||
import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
|
||||
import {
|
||||
FilterObserver,
|
||||
SelectedFiltersComponent,
|
||||
} from '../selected-filters/selected-filters.component';
|
||||
import { map } from 'rxjs/internal/operators/map';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-filters',
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
QueryParamInputComponent,
|
||||
SearchableInstitutionSelectComponent,
|
||||
SearchableAuthorSelectComponent,
|
||||
SearchableYearSelectComponent,
|
||||
SelectedFiltersComponent,
|
||||
],
|
||||
templateUrl: './project-filters.component.html',
|
||||
styleUrl: './project-filters.component.scss',
|
||||
})
|
||||
export class ProjectFilterComponent {
|
||||
constructor(private readonly router: Router) {}
|
||||
|
||||
// Each tab (DFG / EU) passes its OWN key set so they never collide.
|
||||
queryParamKeys = projectQueryParamKeys;
|
||||
|
||||
selectedInstitutions = input<Institution[]>([]);
|
||||
selectedTopics = input<string[]>([]);
|
||||
selectedAuthors = input<Author[]>([]);
|
||||
|
||||
showTitleFilter = input<boolean>(true);
|
||||
showInstitutionFilter = input<boolean>(true);
|
||||
showAuthorFilter = input<boolean>(true);
|
||||
showYearFilter = input<boolean>(true);
|
||||
|
||||
queryParamMap = toSignal(this.router.routerState.root.queryParamMap, {
|
||||
initialValue: this.router.routerState.snapshot.root.queryParamMap,
|
||||
});
|
||||
|
||||
selectedInstitutionIds = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.institutionId),
|
||||
);
|
||||
|
||||
selectedAuthorIds = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.authorId),
|
||||
);
|
||||
|
||||
selectedYears = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.years).map(Number),
|
||||
);
|
||||
yearLabel = computed(() => {
|
||||
const selectedYears = this.selectedYears();
|
||||
if (selectedYears.length === 0) {
|
||||
return 'Jahr';
|
||||
} else if (selectedYears.length === 1) {
|
||||
return selectedYears[0].toString();
|
||||
} else {
|
||||
return `${selectedYears.length} Jahre`;
|
||||
}
|
||||
});
|
||||
|
||||
institutionLabel = computed(() => {
|
||||
const selected = this.selectedInstitutions().filter((i) =>
|
||||
this.selectedInstitutionIds().includes(i.id!),
|
||||
);
|
||||
if (selected.length === 0) return 'Institution';
|
||||
if (selected.length === 1) return selected[0].display_name ?? 'Institution';
|
||||
return `${selected.length} Institutionen`;
|
||||
});
|
||||
|
||||
authorLabel = computed(() => {
|
||||
const selected = this.selectedAuthors().filter((a) =>
|
||||
this.selectedAuthorIds().includes(a.id!),
|
||||
);
|
||||
if (selected.length === 0) return 'Autor';
|
||||
if (selected.length === 1) return selected[0].display_name ?? 'Autor';
|
||||
return `${selected.length} Autoren`;
|
||||
});
|
||||
|
||||
observers = computed<FilterObserver[]>(() => {
|
||||
const keys = this.queryParamKeys;
|
||||
return [
|
||||
{ id: 'search', queryParamKey: keys.title, icon: 'search' },
|
||||
{
|
||||
id: 'years',
|
||||
queryParamKey: projectQueryParamKeys.years,
|
||||
icon: 'calendar_today',
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
queryParamKey: keys.institutionId,
|
||||
icon: 'apartment',
|
||||
valueFormatter: (value: string) =>
|
||||
this.selectedInstitutions().find((i) => i.id === value)
|
||||
?.display_name ?? value,
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
queryParamKey: keys.authorId,
|
||||
icon: 'person',
|
||||
valueFormatter: (value: string) =>
|
||||
this.selectedAuthors().find((a) => a.id === value)?.display_name ??
|
||||
value,
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
handleYearSelectChange = (selectedYear: number): void => {
|
||||
if (this.selectedYears().includes(selectedYear)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.years]: this.selectedYears().filter(
|
||||
(year) => year !== selectedYear,
|
||||
),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.years]: [
|
||||
...this.selectedYears(),
|
||||
selectedYear,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
handleInstitutionSelectChange = (institution: Institution): void => {
|
||||
if (!institution.id) return;
|
||||
const keys = this.queryParamKeys;
|
||||
const selectedIds = this.selectedInstitutionIds();
|
||||
const nextIds = selectedIds.includes(institution.id)
|
||||
? selectedIds.filter((id) => id !== institution.id)
|
||||
: [...selectedIds, institution.id];
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: { [keys.institutionId]: nextIds, [keys.page]: 0 },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
};
|
||||
|
||||
handleAuthorSelectChange = (author: Author): void => {
|
||||
if (!author.id) return;
|
||||
const keys = this.queryParamKeys;
|
||||
const selectedIds = this.selectedAuthorIds();
|
||||
const nextIds = selectedIds.includes(author.id)
|
||||
? selectedIds.filter((id) => id !== author.id)
|
||||
: [...selectedIds, author.id];
|
||||
|
||||
this.router.navigate([], {
|
||||
queryParams: { [keys.authorId]: nextIds, [keys.page]: 0 },
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
};
|
||||
|
||||
resetFilters = (): void => {
|
||||
const keys = this.queryParamKeys;
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[keys.title]: null,
|
||||
[keys.institutionId]: null,
|
||||
[keys.authorId]: null,
|
||||
[keys.years]: null,
|
||||
[keys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -77,7 +77,10 @@
|
||||
@let visibleAuthors =
|
||||
workAuthorsExpanded ? workAuthors : workAuthors.slice(0, 3);
|
||||
<div class="author-tags" aria-label="Autoren" style="padding: 0.5rem 0">
|
||||
@for (author of visibleAuthors; track author.id) {
|
||||
@for (
|
||||
author of visibleAuthors;
|
||||
track author.id ?? 'name-' + author.display_name
|
||||
) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
|
||||
@@ -56,6 +56,7 @@ export class PublicationTableComponent implements OnInit {
|
||||
page = input.required<WorkPageV2>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
topicFilterEnabled = input<boolean>(false);
|
||||
|
||||
elements = computed(() => this.page().elements ?? []);
|
||||
|
||||
@@ -406,7 +407,7 @@ export class PublicationTableComponent implements OnInit {
|
||||
}
|
||||
|
||||
filterByTopic(topic: WorkTopic): void {
|
||||
if (!topic.id) return;
|
||||
if (!topic.id || !this.topicFilterEnabled()) return;
|
||||
const selectedTopicIds = this.selectedTopicIdsQueryParams();
|
||||
if (selectedTopicIds.includes(topic.id)) {
|
||||
this.router.navigate([], {
|
||||
@@ -458,7 +459,7 @@ export class PublicationTableComponent implements OnInit {
|
||||
}
|
||||
|
||||
getAuthorTooltipText(author: DehydratedAuthor): string {
|
||||
if (this.authorFilterEnabled()) {
|
||||
if (this.authorFilterEnabled() && author.id) {
|
||||
return `Nach Autor filtern: ${author.display_name}`;
|
||||
}
|
||||
return `Autor: ${author.display_name}`;
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
of,
|
||||
switchMap,
|
||||
} from 'rxjs';
|
||||
import { Topic } from '../../../api';
|
||||
import { Topic } from '../../../api/model/topic';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topic-autocomplete',
|
||||
|
||||
Reference in New Issue
Block a user