feature/Keyword_search_rework #237
@@ -942,9 +942,6 @@ async def get_top_topics_for_entity(
|
||||
except Exception as e:
|
||||
logger.error("Failed to query top project topics for entity: %s", e)
|
||||
return {"items": []}
|
||||
|
||||
# Default fallback institution: University of Duisburg-Essen
|
||||
DEFAULT_INSTITUTION_ID = "https://openalex.org/I62318514"
|
||||
DEFAULT_INSTITUTION_NAME = "University of Duisburg-Essen"
|
||||
DEFAULT_TOP_TOPICS_SIZE = 20
|
||||
|
||||
@@ -995,18 +992,34 @@ async def get_top_topics_for_entity(
|
||||
from inse.patents.search_client import PatentSearchClient
|
||||
patent_client = PatentSearchClient()
|
||||
short_id = entity_id.split("/")[-1]
|
||||
full_id = f"https://openalex.org/{short_id}"
|
||||
|
||||
aliases = [short_id, entity_id]
|
||||
aliases = [short_id, entity_id, full_id]
|
||||
if entity_type == "institution":
|
||||
try:
|
||||
from inse.institutions.institutions_search_client import InstitutionsSearchClient
|
||||
client = InstitutionsSearchClient()
|
||||
resolved_aliases = await client.get_institution_aliases_by_oa_institution_id(short_id)
|
||||
if resolved_aliases:
|
||||
aliases = list(resolved_aliases)
|
||||
aliases.extend(resolved_aliases)
|
||||
|
||||
inst_res = await elasticsearch.search(
|
||||
index=str(ESIndex.OPENALEX_INSTITUTIONS),
|
||||
query={"terms": {"id": [full_id, short_id]}},
|
||||
size=1,
|
||||
source=["display_name"],
|
||||
cluster="nes"
|
||||
)
|
||||
hits = inst_res.get("hits", {}).get("hits", [])
|
||||
if hits:
|
||||
d_name = hits[0]["_source"].get("display_name")
|
||||
if d_name:
|
||||
aliases.append(d_name)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to resolve institution aliases in get_top_topics_for_entity: %s", e)
|
||||
|
||||
|
||||
aliases = list(set([a for a in aliases if a]))
|
||||
|
||||
include_german = True
|
||||
if entity_type == "country" and entity_id.strip().upper() != "DE":
|
||||
include_german = False
|
||||
@@ -1100,22 +1113,35 @@ async def get_top_topics_for_entity(
|
||||
for topic_idx, p_ids in project_ids_by_index.items():
|
||||
if not p_ids:
|
||||
continue
|
||||
for i in range(0, len(p_ids), 500):
|
||||
chunk = p_ids[i:i+500]
|
||||
for i in range(0, len(p_ids), 1000):
|
||||
chunk = p_ids[i:i+1000]
|
||||
payload = {
|
||||
"query": {"terms": {"project_id": chunk}},
|
||||
"size": 10000,
|
||||
"_source": ["topic_matches"]
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"terms": {"project_id": chunk}},
|
||||
{"terms": {"project_id.keyword": chunk}}
|
||||
],
|
||||
"minimum_should_match": 1
|
||||
}
|
||||
},
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"topics": {
|
||||
"terms": {
|
||||
"field": "topic_matches.topic_display_name.keyword",
|
||||
"size": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try:
|
||||
res = await patent_client._search(index=topic_idx, payload=payload)
|
||||
hits = res.get("hits", {}).get("hits", [])
|
||||
for hit in hits:
|
||||
matches = hit.get("_source", {}).get("topic_matches", [])
|
||||
for m in matches:
|
||||
t_name = m.get("topic_display_name")
|
||||
if t_name:
|
||||
topic_counts[t_name] = topic_counts.get(t_name, 0) + 1
|
||||
buckets = res.get("aggregations", {}).get("topics", {}).get("buckets", [])
|
||||
for b in buckets:
|
||||
t_name = b["key"]
|
||||
cnt = b["doc_count"]
|
||||
topic_counts[t_name] = topic_counts.get(t_name, 0) + cnt
|
||||
except Exception as e:
|
||||
logger.warning("Failed to aggregate topics from %s: %s", topic_idx, e)
|
||||
|
||||
@@ -1134,6 +1160,37 @@ async def get_top_topics_for_entity(
|
||||
logger.error("Failed to query top project topics for entity: %s", e)
|
||||
return {"items": []}
|
||||
|
||||
if search_type == "news":
|
||||
try:
|
||||
res = await elasticsearch.search(
|
||||
index="aktuell_postproc",
|
||||
body={
|
||||
"query": {"match_all": {}},
|
||||
"size": 0,
|
||||
"aggs": {
|
||||
"top_topics": {
|
||||
"terms": {
|
||||
"field": "topics.display_name.keyword",
|
||||
"size": DEFAULT_TOP_TOPICS_SIZE
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cluster="inse"
|
||||
)
|
||||
buckets = res.get("aggregations", {}).get("top_topics", {}).get("buckets", [])
|
||||
items = [{"name": b["key"], "count": b["doc_count"]} for b in buckets]
|
||||
total_hits = res.get("hits", {}).get("total", {})
|
||||
total_val = total_hits.get("value", 0) if isinstance(total_hits, dict) else int(total_hits or 0)
|
||||
sum_top = sum(b["count"] for b in items)
|
||||
other_count = max(0, total_val - sum_top)
|
||||
if other_count > 0:
|
||||
items.append({"name": "Andere Themen", "count": other_count})
|
||||
return {"items": items}
|
||||
except Exception as e:
|
||||
logger.error("Failed to query top news topics for entity: %s", e)
|
||||
return {"items": []}
|
||||
|
||||
# Default fallback: openalex-works* query for publications/authors
|
||||
# 1. Normalize ID and prepare filter clause
|
||||
if entity_type == "institution":
|
||||
|
||||
@@ -1448,33 +1448,67 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
end_year = datetime.datetime.now().year - 1
|
||||
years_range = list(range(start_year, end_year + 1))
|
||||
|
||||
search_terms = keywords if keywords else topics
|
||||
|
||||
# Each series will map all topic keys to its data.
|
||||
# Each series entity represents one topic/keyword.
|
||||
accumulated_data = {
|
||||
f"news_topic_{t}": {top: {yr: (0, 1) for yr in years_range} for top in topics}
|
||||
for t in topics
|
||||
}
|
||||
|
||||
# Query UDE news postprocessed index to get matching news IDs
|
||||
AKTUELLES_SEARCH_FIELDS = ["main_content", "full_content", "maintitle", "subtitle", "intro_content"]
|
||||
STOP_WORDS = {"in", "and", "or", "und", "oder", "der", "die", "das", "von", "mit", "zu", "at", "by", "on", "for", "to", "a", "an", "the"}
|
||||
|
||||
# Query UDE news postprocessed index to get matching news IDs without 10k capping
|
||||
async def fetch_news_ids_for_term(idx: int, t_name: str) -> List[str]:
|
||||
term = search_terms[idx] if idx < len(search_terms) else t_name
|
||||
if fuzzy:
|
||||
term = t_name
|
||||
es_query = {"match": {"topics.display_name": term}}
|
||||
else:
|
||||
if keywords and idx < len(keywords) and keywords[idx]:
|
||||
raw_kw = keywords[idx]
|
||||
term = raw_kw.split(",")[0].strip() if isinstance(raw_kw, str) else raw_kw
|
||||
if not term:
|
||||
term = t_name
|
||||
else:
|
||||
term = t_name
|
||||
es_query = {"match": {"keywords": term}}
|
||||
|
||||
news_ids = set()
|
||||
try:
|
||||
res = await elasticsearch.search(
|
||||
async for hit in elasticsearch.scan(
|
||||
index="aktuell_postproc",
|
||||
query={"match": {"keywords": term}},
|
||||
size=10000,
|
||||
query=es_query,
|
||||
source=["news_id"],
|
||||
cluster="inse"
|
||||
)
|
||||
return [
|
||||
hit["_source"]["news_id"]
|
||||
for hit in res.get("hits", {}).get("hits", [])
|
||||
if hit.get("_source", {}).get("news_id")
|
||||
]
|
||||
):
|
||||
nid = hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.add(nid)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to search UDE news postproc keywords: %s", e)
|
||||
return []
|
||||
logger.warning("Failed to scan UDE news postproc: %s", e)
|
||||
|
||||
# If non-fuzzy keyword search, also search article content fields in 'aktuell' index
|
||||
if not fuzzy and term and term.lower() not in STOP_WORDS and len(term.strip()) > 1:
|
||||
try:
|
||||
content_query = {
|
||||
"query_string": {
|
||||
"query": term,
|
||||
"fields": AKTUELLES_SEARCH_FIELDS,
|
||||
"default_operator": "AND"
|
||||
}
|
||||
}
|
||||
async for hit in elasticsearch.scan(
|
||||
index="aktuell",
|
||||
query=content_query,
|
||||
source=["news_id"],
|
||||
cluster="inse"
|
||||
):
|
||||
nid = hit.get("_id") or hit.get("_source", {}).get("news_id")
|
||||
if nid:
|
||||
news_ids.add(nid)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to scan UDE news content in aktuell: %s", e)
|
||||
|
||||
return list(news_ids)
|
||||
|
||||
# Find all matching news IDs concurrently
|
||||
matching_ids_list = await asyncio.gather(*[
|
||||
@@ -1484,36 +1518,36 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
async def count_by_year(t_name: str, news_ids: List[str]):
|
||||
if not news_ids:
|
||||
return
|
||||
try:
|
||||
# Query aktuell index using matching news IDs and aggregate by date_year
|
||||
res = await elasticsearch.search(
|
||||
index="aktuell",
|
||||
body={
|
||||
"query": {"bool": {"filter": [
|
||||
{"ids": {"values": news_ids}},
|
||||
{"range": {"date_year": {"gte": start_year, "lte": end_year}}}
|
||||
]}},
|
||||
"aggs": {
|
||||
"by_year": {
|
||||
"terms": {"field": "date_year", "size": len(years_range) * 2}
|
||||
entity_key = f"news_topic_{t_name}"
|
||||
# Batch news_ids in chunks of 2000 to avoid ES query clause limits
|
||||
for i in range(0, len(news_ids), 2000):
|
||||
chunk = news_ids[i:i+2000]
|
||||
try:
|
||||
res = await elasticsearch.search(
|
||||
index="aktuell",
|
||||
body={
|
||||
"query": {"bool": {"filter": [
|
||||
{"ids": {"values": chunk}},
|
||||
{"range": {"date_year": {"gte": start_year, "lte": end_year}}}
|
||||
]}},
|
||||
"aggs": {
|
||||
"by_year": {
|
||||
"terms": {"field": "date_year", "size": len(years_range) * 2}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
size=0,
|
||||
cluster="inse"
|
||||
)
|
||||
buckets = res.get("aggregations", {}).get("by_year", {}).get("buckets", [])
|
||||
for b in buckets:
|
||||
yr = int(b.get("key"))
|
||||
count = int(b.get("doc_count", 0))
|
||||
if yr in years_range:
|
||||
entity_key = f"news_topic_{t_name}"
|
||||
# Set this count for all topic keys in this topic's series
|
||||
for top in topics:
|
||||
accumulated_data[entity_key][top] = dict(accumulated_data[entity_key][top])
|
||||
accumulated_data[entity_key][top][yr] = (count, 1)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to aggregate news years from ES: %s", e)
|
||||
},
|
||||
size=0,
|
||||
cluster="inse"
|
||||
)
|
||||
buckets = res.get("aggregations", {}).get("by_year", {}).get("buckets", [])
|
||||
for b in buckets:
|
||||
yr = int(b.get("key"))
|
||||
count = int(b.get("doc_count", 0))
|
||||
if yr in years_range:
|
||||
prev_count, _ = accumulated_data[entity_key][t_name][yr]
|
||||
accumulated_data[entity_key][t_name][yr] = (prev_count + count, 1)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to aggregate news years from ES for chunk: %s", e)
|
||||
|
||||
# Aggregate news publication years concurrently
|
||||
await asyncio.gather(*[
|
||||
@@ -1526,21 +1560,27 @@ class NewsTrendStrategy(TrendStrategy):
|
||||
for t_name in topics:
|
||||
entity_key = f"news_topic_{t_name}"
|
||||
topic_data_map = {}
|
||||
for topic in topics:
|
||||
yearly_data_items = []
|
||||
lookup = normalized_lookup.get((entity_key, topic), {})
|
||||
norm_vals = lookup.get("normalized", [0.0] * len(years_range))
|
||||
cum_vals = lookup.get("cumulative", [0.0] * len(years_range))
|
||||
|
||||
for idx, yr in enumerate(years_range):
|
||||
count, _ = accumulated_data[entity_key][topic][yr]
|
||||
yearly_data_items.append(TopicYearlyData(
|
||||
year=yr,
|
||||
raw=count,
|
||||
normalized=norm_vals[idx],
|
||||
cumulative=cum_vals[idx],
|
||||
institutions_count=1
|
||||
))
|
||||
# Extract yearly data items for t_name from accumulated_data[entity_key][t_name]
|
||||
lookup = normalized_lookup.get((entity_key, t_name), {})
|
||||
norm_vals = lookup.get("normalized", [0.0] * len(years_range))
|
||||
cum_vals = lookup.get("cumulative", [0.0] * len(years_range))
|
||||
|
||||
yearly_data_items = []
|
||||
for idx, yr in enumerate(years_range):
|
||||
count, _ = accumulated_data[entity_key][t_name][yr]
|
||||
yearly_data_items.append(TopicYearlyData(
|
||||
year=yr,
|
||||
raw=count,
|
||||
normalized=norm_vals[idx],
|
||||
cumulative=cum_vals[idx],
|
||||
institutions_count=1
|
||||
))
|
||||
|
||||
# Populate topic_data_map for ALL topic keys in topics with t_name's yearly items.
|
||||
# This ensures uni-trend-chart accessing topic_data[selectedTopic] for any selected topic
|
||||
# always gets t_name's true data items for series t_name.
|
||||
for topic in topics:
|
||||
topic_data_map[topic] = yearly_data_items
|
||||
|
||||
series_list.append(TrendSeries(
|
||||
|
||||
@@ -48,6 +48,7 @@ import { selectedDfgAuthorsResolver } from './resolvers/selected-dfg-authors.res
|
||||
import { selectedDfgInstitutionsResolver } from './resolvers/selected-dfg-institutions.resolver';
|
||||
import { primaryCategoryYearAggregationPageResolver } from './resolvers/primary-category-year-aggregation-page.resolver';
|
||||
import { selectedEuInstitutionsResolver } from './resolvers/selected-eu-institutions.resolver';
|
||||
import { uniTrendResolver } from './resolvers/uni-trend.resolver';
|
||||
import { EuProjectsComponent } from './shared/ui/eu-projects/eu-projects.component';
|
||||
import { DfgProjectsComponent } from './shared/ui/dfg-projects/dfg-projects.component';
|
||||
export const routes: Routes = [
|
||||
@@ -244,7 +245,30 @@ export const routes: Routes = [
|
||||
},
|
||||
},
|
||||
{ path: 'news', component: KeywordsToNewsResultsComponent },
|
||||
{ path: 'trends', component: UniTrendParentComponent },
|
||||
{
|
||||
path: 'trends',
|
||||
component: UniTrendParentComponent,
|
||||
resolve: {
|
||||
trendData: uniTrendResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => {
|
||||
const keys = [
|
||||
'search_type',
|
||||
'topic',
|
||||
'topics',
|
||||
'keyword',
|
||||
'keywords',
|
||||
'institutions',
|
||||
'countries',
|
||||
'regions',
|
||||
'authors',
|
||||
'fuzzy',
|
||||
];
|
||||
return keys.some(
|
||||
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
+6
-2
@@ -39,10 +39,14 @@ export class UniTrendChartComponent {
|
||||
const xAxisData = years.map(String);
|
||||
|
||||
// Resolve the active topic to compare one at a time to prevent line overlaps
|
||||
const topics = Object.keys(trendData.series[0].topic_data || {});
|
||||
const availableKeys = Object.keys(trendData.series[0].topic_data || {});
|
||||
const displayNameKeys = availableKeys.filter(
|
||||
(k) => !/^T\d+$/i.test(k) && !k.startsWith('http'),
|
||||
);
|
||||
const topics = displayNameKeys.length > 0 ? displayNameKeys : availableKeys;
|
||||
const active = this.activeTopic();
|
||||
const selectedTopic =
|
||||
active && topics.includes(active)
|
||||
active && (availableKeys.includes(active) || topics.includes(active))
|
||||
? active
|
||||
: topics.length > 0
|
||||
? topics[0]
|
||||
|
||||
+186
-147
@@ -2,139 +2,129 @@
|
||||
<!-- Strategy Selection Toggles Bar -->
|
||||
<div class="strategy-toggles-bar">
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'publications'"
|
||||
(click)="setSearchType('publications')">
|
||||
(click)="setSearchType('publications')"
|
||||
matTooltip="Zeigt Publikationstrends nach Einrichtung, Land oder Region">
|
||||
<mat-icon>library_books</mat-icon> Publikationen
|
||||
</button>
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'authors'"
|
||||
(click)="setSearchType('authors')">
|
||||
(click)="setSearchType('authors')"
|
||||
matTooltip="Zeigt Publikationstrends einzelner Autoren">
|
||||
<mat-icon>people</mat-icon> Autoren
|
||||
</button>
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'patents'"
|
||||
(click)="setSearchType('patents')">
|
||||
(click)="setSearchType('patents')"
|
||||
matTooltip="Zeigt Patentanmeldungstrends">
|
||||
<mat-icon>assignment</mat-icon> Patente
|
||||
</button>
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'projects'"
|
||||
(click)="setSearchType('projects')">
|
||||
(click)="setSearchType('projects')"
|
||||
matTooltip="Zeigt Drittmittelförderungstrends">
|
||||
<mat-icon>business_center</mat-icon> Projekte
|
||||
</button>
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'news'"
|
||||
[disabled]="!isUde()"
|
||||
[title]="
|
||||
[matTooltip]="
|
||||
!isUde()
|
||||
? 'News-Trends sind nur für die Universität Duisburg-Essen verfügbar'
|
||||
: ''
|
||||
: 'Zeigt Pressemitteilungstrends der UDE'
|
||||
"
|
||||
(click)="setSearchType('news')">
|
||||
<mat-icon>campaign</mat-icon> News
|
||||
</button>
|
||||
<button
|
||||
mat-button
|
||||
[class.active]="selectedSearchType() === 'all'"
|
||||
(click)="setSearchType('all')">
|
||||
(click)="setSearchType('all')"
|
||||
matTooltip="Zeigt den aggregierten Themenlebenszyklus über alle Fachbereiche">
|
||||
<mat-icon>dashboard</mat-icon> Themenlebenszyklus (All)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="trend-layout">
|
||||
<!-- Linkes Sidebar-Panel: Steuerung -->
|
||||
<aside class="trend-sidebar">
|
||||
<!-- Zeitraum-Auswahl -->
|
||||
<app-year-range-slider
|
||||
[minYear]="2000"
|
||||
[maxYear]="2026"
|
||||
[(startYear)]="startYear"
|
||||
[(endYear)]="endYear"
|
||||
(startYearChange)="updateUrlParams()"
|
||||
(endYearChange)="updateUrlParams()">
|
||||
</app-year-range-slider>
|
||||
<!-- Combined Header Controls Bar: Slider and Scale Toggles on the Same Height -->
|
||||
<div class="trend-top-controls-bar">
|
||||
<div class="control-section slider-section">
|
||||
<app-year-range-slider
|
||||
[minYear]="2000"
|
||||
[maxYear]="2026"
|
||||
[(startYear)]="startYear"
|
||||
[(endYear)]="endYear"
|
||||
(startYearChange)="updateUrlParams()"
|
||||
(endYearChange)="updateUrlParams()">
|
||||
</app-year-range-slider>
|
||||
</div>
|
||||
|
||||
<!-- Länder/Kontinente vergleichen -->
|
||||
@if (activeConfig().showLocationSelector) {
|
||||
<app-location-selector
|
||||
[comparisonCountries]="comparisonCountries()"
|
||||
[comparisonRegions]="comparisonRegions()"
|
||||
[locationQuery]="locationQuery()"
|
||||
[locationSearchResults]="locationSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addLocation)="addLocation($event)"
|
||||
(removeLocation)="removeLocation($event.id, $event.type)"
|
||||
(searchChange)="onLocationSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-location-selector>
|
||||
}
|
||||
<div class="control-section scale-section">
|
||||
<span class="toggle-label">Visualisierungsskala:</span>
|
||||
<mat-button-toggle-group
|
||||
[value]="chartMode()"
|
||||
(change)="onChartModeChange($event)"
|
||||
aria-label="Visualisierungsskala">
|
||||
<mat-button-toggle
|
||||
value="normalized"
|
||||
matTooltip="Normiert das Publikationsvolumen auf [0,1], um die Form von Wachstumstrends zu vergleichen.">
|
||||
<mat-icon>trending_down</mat-icon>
|
||||
<span class="toggle-text">Normierte Skala</span>
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle
|
||||
value="total"
|
||||
matTooltip="Zeigt die absolute Anzahl der Publikationen.">
|
||||
<mat-icon>bar_chart</mat-icon>
|
||||
<span class="toggle-text">Gesamtvolumen</span>
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle
|
||||
value="cumulative"
|
||||
matTooltip="Zeigt das normierte kumulierte Publikationswachstum (S-Kurve).">
|
||||
<mat-icon>trending_up</mat-icon>
|
||||
<span class="toggle-text">S-Kurve (Normiert)</span>
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Top-Autoren einer Einrichtung hinzufügen (Authors Tab Sidebar Placement) -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-institution-selector
|
||||
[searchQuery]="authorInstSearchQuery()"
|
||||
[searchResults]="authorInstSearchResults()"
|
||||
(addInstitutionAuthors)="
|
||||
addInstitutionAuthors($event.id, $event.name)
|
||||
"
|
||||
(searchChange)="onAuthorInstSearchChange($event)">
|
||||
</app-author-institution-selector>
|
||||
}
|
||||
</aside>
|
||||
|
||||
<!-- Rechtes Haupt-Panel: Toggles & Diagramm -->
|
||||
<main class="trend-main">
|
||||
@if (isTrendLoading() && !rawTrendResponse()) {
|
||||
<!-- Main Full-Width Content Area -->
|
||||
<main class="trend-main-fullwidth">
|
||||
@if (isPageResolving() || (isTrendLoading() && !rawTrendResponse())) {
|
||||
<app-loading
|
||||
text="Trenddaten werden initialisiert..."
|
||||
text="Trenddaten werden geladen..."
|
||||
icon="trending_up"
|
||||
[size]="200"
|
||||
[diameter]="200"></app-loading>
|
||||
} @else if (rawTrendResponse()) {
|
||||
<div class="trend-toggles-bar">
|
||||
<span class="toggle-label">Visualisierungsskala:</span>
|
||||
<div class="toggle-buttons">
|
||||
<button
|
||||
[class.active]="chartMode() === 'normalized'"
|
||||
(click)="setChartMode('normalized')"
|
||||
title="Normiert das Publikationsvolumen auf [0,1], um die Form von Wachstumstrends zu vergleichen.">
|
||||
<mat-icon>trending_down</mat-icon> Normierte Skala
|
||||
</button>
|
||||
<button
|
||||
[class.active]="chartMode() === 'total'"
|
||||
(click)="setChartMode('total')"
|
||||
title="Zeigt die absolute Anzahl der Publikationen.">
|
||||
<mat-icon>bar_chart</mat-icon> Gesamtvolumen
|
||||
</button>
|
||||
<button
|
||||
[class.active]="chartMode() === 'cumulative'"
|
||||
(click)="setChartMode('cumulative')"
|
||||
title="Zeigt das normierte kumulierte Publikationswachstum (S-Kurve).">
|
||||
<mat-icon>trending_up</mat-icon> S-Kurve (Normiert)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chart Holder Card (100% Full Width) -->
|
||||
<div class="chart-holder-card">
|
||||
@if (isTrendLoading()) {
|
||||
<div class="loader-overlay">
|
||||
<div class="spinner"></div>
|
||||
<p>Trenddaten werden abgerufen...</p>
|
||||
</div>
|
||||
}
|
||||
@if (
|
||||
selectedTrendTopics().length > 1 && selectedSearchType() !== 'news'
|
||||
) {
|
||||
@if (selectedTrendTopics().length > 0) {
|
||||
<div class="chart-topic-tabs">
|
||||
@for (topic of selectedTrendTopics(); track topic) {
|
||||
<app-topic-chip
|
||||
[label]="topic"
|
||||
[active]="activeChartTopic() === topic"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="isTopicEmpty(topic)"
|
||||
(chipClick)="updateActiveChartTopic(topic)">
|
||||
</app-topic-chip>
|
||||
@if (selectedSearchType() === 'news') {
|
||||
<app-topic-chip
|
||||
[label]="topic"
|
||||
[active]="true"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="false"
|
||||
[matTooltip]="topic"
|
||||
style="pointer-events: none; cursor: default">
|
||||
</app-topic-chip>
|
||||
} @else if (selectedTrendTopics().length > 1) {
|
||||
<app-topic-chip
|
||||
[label]="topic"
|
||||
[active]="activeChartTopic() === topic"
|
||||
[color]="getTopicColor(topic)"
|
||||
[disabled]="isTopicEmpty(topic)"
|
||||
[matTooltip]="topic"
|
||||
(chipClick)="updateActiveChartTopic(topic)">
|
||||
</app-topic-chip>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -149,27 +139,39 @@
|
||||
|
||||
<!-- Pie Charts Row -->
|
||||
@if (
|
||||
selectedPieEntity() &&
|
||||
selectedSearchType() !== 'news' &&
|
||||
(selectedPieEntity() || selectedSearchType() === 'news') &&
|
||||
selectedSearchType() !== 'all'
|
||||
) {
|
||||
<div class="pie-charts-row" style="margin-bottom: 24px">
|
||||
<app-uni-pie-chart
|
||||
[data]="trendResponse()"
|
||||
[loading]="isTrendLoading()"
|
||||
[entityId]="selectedPieEntity()!.id"
|
||||
[entityName]="selectedPieEntity()!.name"
|
||||
[startYear]="startYear()"
|
||||
[endYear]="endYear()"
|
||||
[getTopicColor]="boundGetTopicColor">
|
||||
</app-uni-pie-chart>
|
||||
<div class="pie-charts-row">
|
||||
@if (selectedSearchType() === 'news') {
|
||||
<app-uni-pie-chart
|
||||
[titleText]="'Verteilung der ausgewählten Themen'"
|
||||
[pieData]="newsSelectedTopicsPieData()"
|
||||
[loading]="isTrendLoading()"
|
||||
[startYear]="startYear()"
|
||||
[endYear]="endYear()"
|
||||
[getTopicColor]="boundGetTopicColor">
|
||||
</app-uni-pie-chart>
|
||||
} @else {
|
||||
<app-uni-pie-chart
|
||||
[data]="trendResponse()"
|
||||
[loading]="isTrendLoading()"
|
||||
[entityId]="selectedPieEntity()!.id"
|
||||
[entityName]="selectedPieEntity()!.name"
|
||||
[startYear]="startYear()"
|
||||
[endYear]="endYear()"
|
||||
[getTopicColor]="boundGetTopicColor">
|
||||
</app-uni-pie-chart>
|
||||
}
|
||||
|
||||
<app-uni-pie-chart
|
||||
[titleText]="
|
||||
'Top ' +
|
||||
topTopicsSize() +
|
||||
' Themen (Gesamt): ' +
|
||||
selectedPieEntity()!.name
|
||||
(selectedSearchType() === 'news'
|
||||
? 'Alle News'
|
||||
: (selectedPieEntity()?.name ?? ''))
|
||||
"
|
||||
[pieData]="topTopicsData()"
|
||||
[loading]="isTopTopicsLoading() || isTrendLoading()"
|
||||
@@ -181,49 +183,86 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Unified Institution Search, Compare, & Recommendations -->
|
||||
@if (activeConfig().showInstitutionSelector) {
|
||||
<app-institution-selector
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonInstitutions]="comparisonInstitutions()"
|
||||
[primaryInstitution]="primaryInstitution()"
|
||||
[primaryInstitutionName]="primaryInstitutionName()"
|
||||
[topSuggestions]="topSuggestions()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="searchQuery()"
|
||||
[searchResults]="searchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addInstitution)="addInstitution($event.id, $event.name)"
|
||||
(removeInstitution)="removeInstitution($event)"
|
||||
(searchChange)="onSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-institution-selector>
|
||||
}
|
||||
<!-- Combined Child Component Selectors Row (fits into a single line on desktop) -->
|
||||
<div class="comparison-selectors-row">
|
||||
<!-- Countries / Regions Selector -->
|
||||
@if (activeConfig().showLocationSelector) {
|
||||
<app-location-selector
|
||||
class="selector-item"
|
||||
[comparisonCountries]="comparisonCountries()"
|
||||
[comparisonRegions]="comparisonRegions()"
|
||||
[locationQuery]="locationQuery()"
|
||||
[locationSearchResults]="locationSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addLocation)="addLocation($event)"
|
||||
(removeLocation)="removeLocation($event.id, $event.type)"
|
||||
(searchChange)="onLocationSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-location-selector>
|
||||
}
|
||||
|
||||
<!-- Reusable Author Selection UI (Main Panel below chart) -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-selector
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonAuthors]="comparisonAuthors()"
|
||||
[topSuggestions]="recommendedAuthors()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="authorSearchQuery()"
|
||||
[searchResults]="authorSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addAuthor)="addAuthor($event.id, $event.name)"
|
||||
(removeAuthor)="removeAuthor($event)"
|
||||
(searchChange)="onAuthorSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-author-selector>
|
||||
}
|
||||
<!-- Top-Autoren einer Einrichtung hinzufügen -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-institution-selector
|
||||
class="selector-item"
|
||||
[searchQuery]="authorInstSearchQuery()"
|
||||
[searchResults]="authorInstSearchResults()"
|
||||
(addInstitutionAuthors)="
|
||||
addInstitutionAuthors($event.id, $event.name)
|
||||
"
|
||||
(searchChange)="onAuthorInstSearchChange($event)">
|
||||
</app-author-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Unified Institution Search, Compare, & Recommendations -->
|
||||
@if (activeConfig().showInstitutionSelector) {
|
||||
<app-institution-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonInstitutions]="comparisonInstitutions()"
|
||||
[primaryInstitution]="primaryInstitution()"
|
||||
[primaryInstitutionName]="primaryInstitutionName()"
|
||||
[topSuggestions]="topSuggestions()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="searchQuery()"
|
||||
[searchResults]="searchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addInstitution)="addInstitution($event.id, $event.name)"
|
||||
(removeInstitution)="removeInstitution($event)"
|
||||
(searchChange)="onSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-institution-selector>
|
||||
}
|
||||
|
||||
<!-- Reusable Author Selection UI -->
|
||||
@if (activeConfig().showAuthorSelector) {
|
||||
<app-author-selector
|
||||
class="selector-item selector-item--main"
|
||||
[activeTab]="selectedSearchType()"
|
||||
[comparisonAuthors]="comparisonAuthors()"
|
||||
[topSuggestions]="recommendedAuthors()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="authorSearchQuery()"
|
||||
[searchResults]="authorSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
[selectedPieEntityId]="selectedPieEntity()?.id ?? null"
|
||||
(addAuthor)="addAuthor($event.id, $event.name)"
|
||||
(removeAuthor)="removeAuthor($event)"
|
||||
(searchChange)="onAuthorSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)"
|
||||
(selectPie)="onSelectPieEntity($event)">
|
||||
</app-author-selector>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="no-data-fallback">
|
||||
<mat-icon>trending_up</mat-icon>
|
||||
|
||||
+185
-199
@@ -1,185 +1,14 @@
|
||||
.trend-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 300px minmax(0, 1fr);
|
||||
gap: 1.5rem;
|
||||
margin-top: 1.5rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.trend-sidebar {
|
||||
.trend-layout-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.control-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 1.25rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
|
||||
h3 {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
color: #6b7280;
|
||||
margin: 0 0 0.75rem 0;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: #374151;
|
||||
cursor: pointer;
|
||||
|
||||
input[type='checkbox'] {
|
||||
accent-color: #3b82f6;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-list-info {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 8px 0;
|
||||
border: 1px dashed #e5e7eb;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.trend-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.trend-toggles-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 0.6rem 1rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
.toggle-label {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: #4b5563;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle-buttons {
|
||||
display: flex;
|
||||
background: #f3f4f6;
|
||||
border-radius: 6px;
|
||||
padding: 2px;
|
||||
|
||||
button {
|
||||
padding: 0.4rem 0.8rem;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
color: #4b5563;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
&:hover:not(.active) {
|
||||
color: #111827;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
&.active {
|
||||
background: white;
|
||||
color: #3b82f6;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chart-holder-card {
|
||||
position: relative;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e5e7eb;
|
||||
overflow: hidden;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
.chart-topic-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.6rem 1rem;
|
||||
background: #f9fafb;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.loader-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.spinner {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 3px solid rgba(59, 130, 246, 0.1);
|
||||
border-radius: 50%;
|
||||
border-top-color: #3b82f6;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 0.8125rem;
|
||||
color: #4b5563;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
font-family:
|
||||
'Inter',
|
||||
system-ui,
|
||||
-apple-system,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.strategy-toggles-bar {
|
||||
@@ -190,14 +19,13 @@
|
||||
border-radius: 12px;
|
||||
padding: 6px;
|
||||
border: 1px solid #e2e8f0;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
button {
|
||||
padding: 0.5rem 1rem;
|
||||
padding: 0.45rem 0.9rem;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: #64748b;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
@@ -207,38 +35,189 @@
|
||||
transition: all 0.2s ease;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
&:hover:not(.active):not([disabled]) {
|
||||
color: #0f172a;
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.4;
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: white;
|
||||
color: #3b82f6;
|
||||
color: #2563eb;
|
||||
font-weight: 600;
|
||||
box-shadow:
|
||||
0 4px 6px -1px rgba(0, 0, 0, 0.05),
|
||||
0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
||||
0 2px 4px rgba(0, 0, 0, 0.05),
|
||||
0 1px 2px rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.trend-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Combined Top Header Control Bar */
|
||||
.trend-top-controls-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 1.5rem;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.slider-section {
|
||||
flex: 1;
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
.scale-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.toggle-label {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: #4b5563;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
mat-button-toggle-group {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #f8fafc;
|
||||
box-shadow: none;
|
||||
|
||||
mat-button-toggle {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
color: #475569;
|
||||
|
||||
mat-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 4px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.toggle-text {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-button-toggle-checked {
|
||||
background-color: white !important;
|
||||
color: #2563eb !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.trend-main-fullwidth {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-holder-card {
|
||||
position: relative;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e5e7eb;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
overflow: hidden;
|
||||
min-height: 450px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chart-topic-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.loader-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
|
||||
p {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #3b82f6;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pie-charts-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1.5rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
gap: 1.25rem;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.comparison-selectors-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
gap: 1.25rem;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
.selector-item {
|
||||
flex: 1 1 300px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
&.selector-item--main {
|
||||
flex: 2 1 450px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,14 +228,21 @@
|
||||
justify-content: center;
|
||||
min-height: 400px;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e5e7eb;
|
||||
color: #9ca3af;
|
||||
gap: 0.5rem;
|
||||
gap: 0.75rem;
|
||||
|
||||
mat-icon {
|
||||
font-size: 48px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
font-size: 56px;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
color: #6b7280;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
+284
-54
@@ -11,16 +11,26 @@ import {
|
||||
} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
Router,
|
||||
ResolveStart,
|
||||
ResolveEnd,
|
||||
} from '@angular/router';
|
||||
import { forkJoin } from 'rxjs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import {
|
||||
MatButtonToggleModule,
|
||||
MatButtonToggleChange,
|
||||
} from '@angular/material/button-toggle';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { UniTrendChartComponent } from '../uni-trend-chart/uni-trend-chart.component';
|
||||
import { UniPieChartComponent } from '../uni-pie-chart/uni-pie-chart.component';
|
||||
import {
|
||||
@@ -115,8 +125,10 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
|
||||
UniPieChartComponent,
|
||||
MatCheckboxModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTooltipModule,
|
||||
TopicChipComponent,
|
||||
YearRangeSliderComponent,
|
||||
LocationSelectorComponent,
|
||||
@@ -208,6 +220,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
readonly fetchedFuzzy = signal<boolean | null>(null);
|
||||
|
||||
// Results & Loading signals
|
||||
readonly isPageResolving = signal<boolean>(false);
|
||||
readonly rawTrendResponse = signal<TrendResponse | null>(null);
|
||||
readonly isTrendLoading = signal<boolean>(false);
|
||||
readonly topSuggestions = signal<TopInstitutionItem[]>([]);
|
||||
@@ -263,6 +276,29 @@ export class UniTrendParentComponent implements OnInit {
|
||||
|
||||
readonly boundGetTopicColor = this.getTopicColor.bind(this);
|
||||
|
||||
readonly newsSelectedTopicsPieData = computed(() => {
|
||||
const data = this.trendResponse();
|
||||
if (!data || !data.series || this.selectedSearchType() !== 'news') {
|
||||
return null;
|
||||
}
|
||||
const startYr = this.startYear();
|
||||
const endYr = this.endYear();
|
||||
|
||||
return data.series.map((s) => {
|
||||
const topicName = s.entity_name;
|
||||
const yearlyItems =
|
||||
s.topic_data[topicName] || Object.values(s.topic_data)[0] || [];
|
||||
const totalRaw = yearlyItems
|
||||
.filter((y) => y.year >= startYr && y.year <= endYr)
|
||||
.reduce((sum, item) => sum + (item.raw || 0), 0);
|
||||
|
||||
return {
|
||||
name: topicName,
|
||||
value: totalRaw,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// Autocomplete UI state
|
||||
readonly searchQuery = signal<string>('');
|
||||
readonly searchResults = signal<AutocompleteResponseResultsInner[]>([]);
|
||||
@@ -294,12 +330,25 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
|
||||
getEntityColor(entityId: string): string {
|
||||
if (this.selectedSearchType() === 'news') {
|
||||
const topicName = entityId.startsWith('news_topic_')
|
||||
? entityId.slice('news_topic_'.length)
|
||||
: entityId;
|
||||
return this.getTopicColor(topicName);
|
||||
}
|
||||
|
||||
const cleanId = (id: string | null | undefined): string => {
|
||||
if (!id) return '';
|
||||
const lower = id.toLowerCase().trim();
|
||||
return lower.includes('/') ? lower.split('/').pop()! : lower;
|
||||
};
|
||||
|
||||
const defaultInstId = 'https://openalex.org/I62318514';
|
||||
const primaryId = this.primaryInstitution() || defaultInstId;
|
||||
const insts = this.comparisonInstitutions().map((i) => i.id);
|
||||
const countries = this.comparisonCountries().map((c) => c.id);
|
||||
const regions = this.comparisonRegions().map((r) => r.id);
|
||||
const authors = this.comparisonAuthors().map((a) => a.id);
|
||||
const primaryId = cleanId(this.primaryInstitution() || defaultInstId);
|
||||
const insts = this.comparisonInstitutions().map((i) => cleanId(i.id));
|
||||
const countries = this.comparisonCountries().map((c) => cleanId(c.id));
|
||||
const regions = this.comparisonRegions().map((r) => cleanId(r.id));
|
||||
const authors = this.comparisonAuthors().map((a) => cleanId(a.id));
|
||||
|
||||
const orderedIds = [
|
||||
primaryId,
|
||||
@@ -309,7 +358,8 @@ export class UniTrendParentComponent implements OnInit {
|
||||
...authors,
|
||||
];
|
||||
|
||||
const idx = orderedIds.indexOf(entityId);
|
||||
const targetCleanId = cleanId(entityId);
|
||||
const idx = orderedIds.indexOf(targetCleanId);
|
||||
if (idx === -1) return '#9ca3af';
|
||||
|
||||
const entityColors = [
|
||||
@@ -345,17 +395,128 @@ export class UniTrendParentComponent implements OnInit {
|
||||
readonly boundGetEntityColor = (id: string) => this.getEntityColor(id);
|
||||
readonly boundIsVisible = (id: string) => this.isVisible(id);
|
||||
|
||||
// Computed: filters out items locally if they were removed from list
|
||||
// Computed: filters out items locally if they were removed from list and normalizes topic_data keys & entity names
|
||||
readonly trendResponse = computed(() => {
|
||||
const raw = this.rawTrendResponse();
|
||||
if (!raw) return null;
|
||||
if (!raw || !raw.series) return null;
|
||||
|
||||
const topics = this.selectedTrendTopics();
|
||||
const type = this.selectedSearchType();
|
||||
|
||||
const cleanId = (id: string | null | undefined): string => {
|
||||
if (!id) return '';
|
||||
const lower = id.toLowerCase().trim();
|
||||
return lower.includes('/') ? lower.split('/').pop()! : lower;
|
||||
};
|
||||
|
||||
const primaryInstCleanId = cleanId(
|
||||
this.primaryInstitution() || 'I62318514',
|
||||
);
|
||||
|
||||
const resolveEntityName = (s: TrendSeries): string => {
|
||||
const cId = cleanId(s.entity_id);
|
||||
|
||||
if (s.entity_type === 'institution') {
|
||||
if (cId === primaryInstCleanId) {
|
||||
return (
|
||||
this.primaryInstitutionName() ||
|
||||
s.entity_name ||
|
||||
'Haupt-Einrichtung'
|
||||
);
|
||||
}
|
||||
const foundInst = this.comparisonInstitutions().find(
|
||||
(i) => cleanId(i.id) === cId,
|
||||
);
|
||||
if (foundInst && foundInst.name && foundInst.name !== foundInst.id) {
|
||||
return foundInst.name;
|
||||
}
|
||||
} else if (s.entity_type === 'country') {
|
||||
const foundCountry = this.comparisonCountries().find(
|
||||
(c) => cleanId(c.id) === cId,
|
||||
);
|
||||
if (
|
||||
foundCountry &&
|
||||
foundCountry.name &&
|
||||
foundCountry.name !== foundCountry.id
|
||||
) {
|
||||
return foundCountry.name;
|
||||
}
|
||||
} else if (s.entity_type === 'region') {
|
||||
const foundRegion = this.comparisonRegions().find(
|
||||
(r) => cleanId(r.id) === cId,
|
||||
);
|
||||
if (
|
||||
foundRegion &&
|
||||
foundRegion.name &&
|
||||
foundRegion.name !== foundRegion.id
|
||||
) {
|
||||
return foundRegion.name;
|
||||
}
|
||||
} else if (s.entity_type === 'author') {
|
||||
const foundAuthor = this.comparisonAuthors().find(
|
||||
(a) => cleanId(a.id) === cId,
|
||||
);
|
||||
if (
|
||||
foundAuthor &&
|
||||
foundAuthor.name &&
|
||||
foundAuthor.name !== foundAuthor.id
|
||||
) {
|
||||
return foundAuthor.name;
|
||||
}
|
||||
}
|
||||
|
||||
return s.entity_name &&
|
||||
!s.entity_name.startsWith('I') &&
|
||||
s.entity_name.length > 8
|
||||
? s.entity_name
|
||||
: s.entity_name || cId;
|
||||
};
|
||||
|
||||
// Map series topic_data keys to display names so they match selectedTrendTopics
|
||||
const normalizeTopicData = (s: TrendSeries): TrendSeries => {
|
||||
const nameResolved = resolveEntityName(s);
|
||||
if (!s.topic_data) return { ...s, entity_name: nameResolved };
|
||||
const rawTopicKeys = Object.keys(s.topic_data);
|
||||
if (rawTopicKeys.length === 0) return { ...s, entity_name: nameResolved };
|
||||
|
||||
const newTopicData: Record<string, TopicYearlyData[]> = {};
|
||||
|
||||
topics.forEach((topicName, idx) => {
|
||||
const mappedName = this.getMappedTopic(topicName);
|
||||
let matchKey = rawTopicKeys.find(
|
||||
(rk) =>
|
||||
rk.toLowerCase() === topicName.toLowerCase() ||
|
||||
rk.toLowerCase() === mappedName.toLowerCase() ||
|
||||
rk.toLowerCase().includes(topicName.toLowerCase()) ||
|
||||
rk.toLowerCase().includes(mappedName.toLowerCase()),
|
||||
);
|
||||
|
||||
if (!matchKey && rawTopicKeys[idx]) {
|
||||
matchKey = rawTopicKeys[idx];
|
||||
}
|
||||
|
||||
if (matchKey && s.topic_data[matchKey]) {
|
||||
newTopicData[topicName] = s.topic_data[matchKey];
|
||||
} else if (rawTopicKeys[0] && s.topic_data[rawTopicKeys[0]]) {
|
||||
newTopicData[topicName] = s.topic_data[rawTopicKeys[0]];
|
||||
}
|
||||
});
|
||||
|
||||
// Preserve existing keys as well
|
||||
Object.assign(newTopicData, s.topic_data);
|
||||
|
||||
return {
|
||||
...s,
|
||||
entity_name: nameResolved,
|
||||
topic_data: newTopicData,
|
||||
};
|
||||
};
|
||||
|
||||
if (type === 'news' || type === 'all' || type === 'patents') {
|
||||
return {
|
||||
...raw,
|
||||
series: raw.series.map((s) => ({
|
||||
...s,
|
||||
...normalizeTopicData(s),
|
||||
visible: this.isVisible(s.entity_id),
|
||||
})),
|
||||
};
|
||||
@@ -368,7 +529,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
const filtered = raw.series
|
||||
.filter((s) => currentAuthorIds.has(s.entity_id.toLowerCase()))
|
||||
.map((s) => ({
|
||||
...s,
|
||||
...normalizeTopicData(s),
|
||||
visible: this.isVisible(s.entity_id),
|
||||
}));
|
||||
return {
|
||||
@@ -378,13 +539,6 @@ export class UniTrendParentComponent implements OnInit {
|
||||
}
|
||||
|
||||
// Default: publications, patents, projects
|
||||
// Resilient ID normalization helper
|
||||
const cleanId = (id: string | null | undefined): string => {
|
||||
if (!id) return '';
|
||||
const lower = id.toLowerCase().trim();
|
||||
return lower.includes('/') ? lower.split('/').pop()! : lower;
|
||||
};
|
||||
|
||||
const currentInstIds = new Set(
|
||||
this.comparisonInstitutions().map((i: CompareItem) => cleanId(i.id)),
|
||||
);
|
||||
@@ -394,9 +548,6 @@ export class UniTrendParentComponent implements OnInit {
|
||||
const currentRegionIds = new Set(
|
||||
this.comparisonRegions().map((r: CompareItem) => cleanId(r.id)),
|
||||
);
|
||||
const primaryInstCleanId = cleanId(
|
||||
this.primaryInstitution() || 'I62318514',
|
||||
);
|
||||
|
||||
const primaryInstSeries: TrendSeries[] = [];
|
||||
const compInstSeries: TrendSeries[] = [];
|
||||
@@ -428,7 +579,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
...countrySeries,
|
||||
...regionSeries,
|
||||
].map((s) => ({
|
||||
...s,
|
||||
...normalizeTopicData(s),
|
||||
visible: this.isVisible(s.entity_id),
|
||||
}));
|
||||
|
||||
@@ -445,6 +596,50 @@ export class UniTrendParentComponent implements OnInit {
|
||||
this.availableYears.push(y);
|
||||
}
|
||||
|
||||
this.router.events.subscribe((event) => {
|
||||
if (event instanceof ResolveStart) {
|
||||
this.isPageResolving.set(true);
|
||||
} else if (event instanceof ResolveEnd) {
|
||||
this.isPageResolving.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Subscribe to route resolver data
|
||||
this.route.data.subscribe((data) => {
|
||||
if (data['trendData']) {
|
||||
const resolved = data['trendData'];
|
||||
const res = resolved.trendResponse ?? resolved;
|
||||
this.rawTrendResponse.set(res);
|
||||
|
||||
const type = resolved.searchType || this.selectedSearchType();
|
||||
this.selectedSearchType.set(type);
|
||||
this.fetchedSearchType.set(type);
|
||||
|
||||
const fuzzy = this.state?.fuzzySearch() ?? true;
|
||||
this.fetchedFuzzy.set(fuzzy);
|
||||
|
||||
if (resolved.topics && resolved.topics.length > 0) {
|
||||
this.selectedTrendTopics.set(resolved.topics);
|
||||
this.fetchedTopics.set([...resolved.topics]);
|
||||
if (
|
||||
!this.activeChartTopic() ||
|
||||
!resolved.topics.includes(this.activeChartTopic())
|
||||
) {
|
||||
this.activeChartTopic.set(resolved.topics[0]);
|
||||
}
|
||||
} else {
|
||||
this.fetchedTopics.set([...this.selectedTrendTopics()]);
|
||||
}
|
||||
|
||||
this.fetchedInstitutions.set([...this.comparisonInstitutions()]);
|
||||
this.fetchedCountries.set([...this.comparisonCountries()]);
|
||||
this.fetchedRegions.set([...this.comparisonRegions()]);
|
||||
this.fetchedAuthors.set([...this.comparisonAuthors()]);
|
||||
|
||||
this.isTrendLoading.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Effect: automatically sync checkboxes list whenever input keywords or fuzzy state changes
|
||||
effect(() => {
|
||||
const kws = this.keywords();
|
||||
@@ -511,7 +706,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
});
|
||||
|
||||
// Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive with subset check)
|
||||
// Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive with cached rawTrendResponse check)
|
||||
effect(() => {
|
||||
const topics = this.selectedTrendTopics();
|
||||
const insts = this.comparisonInstitutions();
|
||||
@@ -526,55 +721,59 @@ export class UniTrendParentComponent implements OnInit {
|
||||
const fetchedT = new Set(untracked(() => this.fetchedTopics()));
|
||||
const fetchedType = untracked(() => this.fetchedSearchType());
|
||||
const fetchedF = untracked(() => this.fetchedFuzzy());
|
||||
const rawRes = untracked(() => this.rawTrendResponse());
|
||||
|
||||
const allTopicsFetched = topics.every((t) => fetchedT.has(t));
|
||||
const sameType = searchType === fetchedType;
|
||||
const sameFuzzy = fuzzy === fetchedF;
|
||||
|
||||
let allEntitiesFetched = false;
|
||||
if (sameType) {
|
||||
if (sameType && rawRes && rawRes.series) {
|
||||
const rawSeriesCleanIds = new Set(
|
||||
rawRes.series.map((s) => {
|
||||
const id = s.entity_id;
|
||||
return id.includes('/')
|
||||
? id.split('/').pop()!.toLowerCase()
|
||||
: id.toLowerCase();
|
||||
}),
|
||||
);
|
||||
|
||||
if (searchType === 'authors') {
|
||||
const fetchedA = new Set(
|
||||
untracked(() => this.fetchedAuthors()).map((a) =>
|
||||
a.id.toLowerCase(),
|
||||
),
|
||||
);
|
||||
allEntitiesFetched = authors.every((a) =>
|
||||
fetchedA.has(a.id.toLowerCase()),
|
||||
);
|
||||
allEntitiesFetched =
|
||||
authors.length === 0 ||
|
||||
authors.every((a) => {
|
||||
const cleanA = a.id.includes('/')
|
||||
? a.id.split('/').pop()!.toLowerCase()
|
||||
: a.id.toLowerCase();
|
||||
return rawSeriesCleanIds.has(cleanA);
|
||||
});
|
||||
} else if (searchType === 'news' || searchType === 'all') {
|
||||
allEntitiesFetched = true;
|
||||
} else {
|
||||
// publications, patents, projects
|
||||
const fetchedI = new Set(
|
||||
untracked(() => this.fetchedInstitutions()).map((i) =>
|
||||
i.id.toLowerCase(),
|
||||
),
|
||||
);
|
||||
const fetchedC = new Set(
|
||||
untracked(() => this.fetchedCountries()).map((c) =>
|
||||
c.id.toLowerCase(),
|
||||
),
|
||||
);
|
||||
const fetchedR = new Set(
|
||||
untracked(() => this.fetchedRegions()).map((r) =>
|
||||
r.id.toLowerCase(),
|
||||
),
|
||||
);
|
||||
allEntitiesFetched =
|
||||
insts.every((i) => fetchedI.has(i.id.toLowerCase())) &&
|
||||
countries.every((c) => fetchedC.has(c.id.toLowerCase())) &&
|
||||
regions.every((r) => fetchedR.has(r.id.toLowerCase()));
|
||||
(insts.length === 0 ||
|
||||
insts.every((i) => {
|
||||
const cleanI = i.id.includes('/')
|
||||
? i.id.split('/').pop()!.toLowerCase()
|
||||
: i.id.toLowerCase();
|
||||
return rawSeriesCleanIds.has(cleanI);
|
||||
})) &&
|
||||
(countries.length === 0 ||
|
||||
countries.every((c) =>
|
||||
rawSeriesCleanIds.has(c.id.toLowerCase()),
|
||||
)) &&
|
||||
(regions.length === 0 ||
|
||||
regions.every((r) => rawSeriesCleanIds.has(r.id.toLowerCase())));
|
||||
}
|
||||
}
|
||||
|
||||
const hasResponse = !!untracked(() => this.rawTrendResponse());
|
||||
if (
|
||||
allTopicsFetched &&
|
||||
sameType &&
|
||||
sameFuzzy &&
|
||||
allEntitiesFetched &&
|
||||
hasResponse
|
||||
!!rawRes
|
||||
) {
|
||||
// All requested data is already present in rawTrendResponse, so skip backend call!
|
||||
return;
|
||||
@@ -762,7 +961,7 @@ export class UniTrendParentComponent implements OnInit {
|
||||
const end = this.endYear();
|
||||
const strategy = this.selectedSearchType();
|
||||
|
||||
if (!entity || strategy === 'news' || strategy === 'all') {
|
||||
if (!entity || strategy === 'all') {
|
||||
this.topTopicsData.set([]);
|
||||
return;
|
||||
}
|
||||
@@ -1068,7 +1267,32 @@ export class UniTrendParentComponent implements OnInit {
|
||||
)
|
||||
.subscribe({
|
||||
next: (response: TrendResponse) => {
|
||||
this.rawTrendResponse.set(response);
|
||||
const currentRaw = untracked(() => this.rawTrendResponse());
|
||||
if (!currentRaw || !currentRaw.series) {
|
||||
this.rawTrendResponse.set(response);
|
||||
} else {
|
||||
const seriesMap = new Map<string, TrendSeries>();
|
||||
currentRaw.series.forEach((s) => {
|
||||
seriesMap.set(`${s.entity_type}_${s.entity_id}`, s);
|
||||
});
|
||||
response.series.forEach((s) => {
|
||||
const key = `${s.entity_type}_${s.entity_id}`;
|
||||
const prev = seriesMap.get(key);
|
||||
if (prev && prev.topic_data && s.topic_data) {
|
||||
seriesMap.set(key, {
|
||||
...prev,
|
||||
...s,
|
||||
topic_data: { ...prev.topic_data, ...s.topic_data },
|
||||
});
|
||||
} else {
|
||||
seriesMap.set(key, s);
|
||||
}
|
||||
});
|
||||
this.rawTrendResponse.set({
|
||||
...response,
|
||||
series: Array.from(seriesMap.values()),
|
||||
});
|
||||
}
|
||||
this.isTrendLoading.set(false);
|
||||
this.updateUrlParams();
|
||||
},
|
||||
@@ -1311,6 +1535,12 @@ export class UniTrendParentComponent implements OnInit {
|
||||
this.updateUrlParams();
|
||||
}
|
||||
|
||||
onChartModeChange(event: MatButtonToggleChange) {
|
||||
if (event.value) {
|
||||
this.setChartMode(event.value);
|
||||
}
|
||||
}
|
||||
|
||||
isTopicEmpty(topic: string): boolean {
|
||||
const data = this.trendResponse();
|
||||
if (!data || !data.series || data.series.length === 0) {
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { catchError, of, Observable, map } from 'rxjs';
|
||||
import { TrendResponse, UniversityRankingsService } from '../api';
|
||||
import { SearchResultsStateService } from '../modules/keywords-search/search-results/search-results-state.service';
|
||||
|
||||
export interface UniTrendResolvedData {
|
||||
trendResponse: TrendResponse | null;
|
||||
searchType: string;
|
||||
topics: string[];
|
||||
keywords: string[];
|
||||
fuzzy: boolean;
|
||||
}
|
||||
|
||||
export const uniTrendResolver: ResolveFn<UniTrendResolvedData> = (
|
||||
route,
|
||||
_state,
|
||||
): Observable<UniTrendResolvedData> => {
|
||||
const params = route.queryParamMap;
|
||||
const searchState = inject(SearchResultsStateService, { optional: true });
|
||||
|
||||
const searchType = params.get('search_type') || 'publications';
|
||||
const fuzzy = params.get('fuzzy') !== 'false';
|
||||
|
||||
// Extract keywords & topics
|
||||
let keywords = params.getAll('keyword');
|
||||
if (keywords.length === 0) {
|
||||
const rawKeywords = params.get('keywords');
|
||||
if (rawKeywords) {
|
||||
keywords = rawKeywords
|
||||
.split(',')
|
||||
.map((k) => k.trim())
|
||||
.filter((k) => k.length > 0);
|
||||
}
|
||||
}
|
||||
if (keywords.length === 0 && searchState) {
|
||||
keywords = searchState.keywords();
|
||||
}
|
||||
|
||||
let topics = params.getAll('topic');
|
||||
if (topics.length === 0) {
|
||||
const rawTopics = params.get('topics');
|
||||
if (rawTopics) {
|
||||
topics = rawTopics
|
||||
.split(',')
|
||||
.map((t) => t.trim())
|
||||
.filter((t) => t.length > 0);
|
||||
}
|
||||
}
|
||||
if (topics.length === 0 && searchState) {
|
||||
topics = fuzzy ? searchState.topicsList() : searchState.keywords();
|
||||
}
|
||||
|
||||
// Fallback defaults if no topics/keywords present yet
|
||||
if (topics.length === 0 && keywords.length === 0) {
|
||||
topics = ['Artificial Intelligence'];
|
||||
keywords = ['artificial intelligence'];
|
||||
} else if (topics.length === 0) {
|
||||
topics = keywords;
|
||||
} else if (keywords.length === 0) {
|
||||
keywords = topics;
|
||||
}
|
||||
|
||||
// Parse institutions
|
||||
const instParams = params.getAll('institutions');
|
||||
let institutions = instParams.map((i) => {
|
||||
const parts = i.split('|');
|
||||
const cleanId = parts[0].includes('/')
|
||||
? parts[0].split('/').pop() || parts[0]
|
||||
: parts[0];
|
||||
return cleanId;
|
||||
});
|
||||
if (institutions.length === 0) {
|
||||
institutions = ['I62318514'];
|
||||
}
|
||||
|
||||
// Parse countries
|
||||
const countryParams = params.getAll('countries');
|
||||
let countries = countryParams.map((c) => c.split('|')[0]);
|
||||
if (countries.length === 0) {
|
||||
countries = ['DE'];
|
||||
}
|
||||
|
||||
// Parse regions & authors
|
||||
const regionParams = params.getAll('regions');
|
||||
const regions = regionParams.map((r) => r.split('|')[0]);
|
||||
|
||||
const authorParams = params.getAll('authors');
|
||||
const authors = authorParams.map((a) => a.split('|')[0]);
|
||||
|
||||
const apiService = inject(UniversityRankingsService);
|
||||
|
||||
return apiService
|
||||
.getTrendApiInseServiceUniversityRankingsTrendGet(
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
institutions,
|
||||
countries,
|
||||
regions,
|
||||
authors,
|
||||
searchType as any,
|
||||
)
|
||||
.pipe(
|
||||
map((trendResponse) => ({
|
||||
trendResponse,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
})),
|
||||
catchError((err) => {
|
||||
console.error('uniTrendResolver failed to load trend data:', err);
|
||||
return of({
|
||||
trendResponse: null,
|
||||
searchType,
|
||||
topics,
|
||||
keywords,
|
||||
fuzzy,
|
||||
});
|
||||
}),
|
||||
);
|
||||
};
|
||||
+8
-1
@@ -1,3 +1,10 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.author-institution-selector-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -7,7 +14,7 @@
|
||||
padding: 24px;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
box-sizing: border-box;
|
||||
margin-top: 20px;
|
||||
margin-top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.author-selector-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.5fr;
|
||||
@@ -8,7 +15,7 @@
|
||||
padding: 24px;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
box-sizing: border-box;
|
||||
margin-top: 20px;
|
||||
margin-top: 0;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
@@ -146,6 +153,8 @@
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.comparison-item {
|
||||
@@ -158,6 +167,8 @@
|
||||
gap: 8px;
|
||||
transition: all 0.2s ease;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.item-name {
|
||||
display: inline-flex;
|
||||
@@ -168,7 +179,9 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 180px;
|
||||
min-width: 0;
|
||||
max-width: 240px;
|
||||
flex: 1 1 auto;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
@@ -220,15 +233,13 @@
|
||||
|
||||
.suggestions-flex {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 10px;
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.suggestion-item-horizontal {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.institution-selector-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.5fr;
|
||||
@@ -8,7 +15,7 @@
|
||||
padding: 24px;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
box-sizing: border-box;
|
||||
margin-top: 20px;
|
||||
margin-top: 0;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
@@ -54,14 +61,23 @@
|
||||
padding: 3px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 0.7rem;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
.label {
|
||||
color: #166534;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.name {
|
||||
color: #15803d;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-width: 0;
|
||||
max-width: 260px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +182,8 @@
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.comparison-item {
|
||||
@@ -178,6 +196,8 @@
|
||||
gap: 8px;
|
||||
transition: all 0.2s ease;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.item-name {
|
||||
display: inline-flex;
|
||||
@@ -188,7 +208,9 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 180px;
|
||||
min-width: 0;
|
||||
max-width: 240px;
|
||||
flex: 1 1 auto;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
@@ -240,15 +262,13 @@
|
||||
|
||||
.suggestions-flex {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 10px;
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.suggestion-item-horizontal {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.control-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
@@ -99,6 +106,11 @@
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
.search-form-field {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
|
||||
Reference in New Issue
Block a user