added resolver and changed layout

This commit is contained in:
Kazgatari
2026-07-23 19:29:22 +02:00
parent 399ed285e2
commit d3686f9de9
6 changed files with 659 additions and 356 deletions
+27 -1
View File
@@ -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,32 @@ 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',
'start_year',
'end_year',
'fuzzy',
];
return keys.some(
(key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
);
},
},
],
},
{
@@ -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]
@@ -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,90 @@
</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>
}
<!-- Restructured Full-Width Comparison Panels Grid -->
<div class="comparison-panels-grid">
<!-- Countries / Regions Selector -->
@if (activeConfig().showLocationSelector) {
<div class="comparison-panel-card">
<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>
}
<!-- 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) {
<div class="comparison-panel-card">
<app-author-institution-selector
[searchQuery]="authorInstSearchQuery()"
[searchResults]="authorInstSearchResults()"
(addInstitutionAuthors)="
addInstitutionAuthors($event.id, $event.name)
"
(searchChange)="onAuthorInstSearchChange($event)">
</app-author-institution-selector>
</div>
}
<!-- Unified Institution Search, Compare, & Recommendations -->
@if (activeConfig().showInstitutionSelector) {
<div class="comparison-panel-card full-width-panel">
<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>
</div>
}
<!-- Reusable Author Selection UI -->
@if (activeConfig().showAuthorSelector) {
<div class="comparison-panel-card full-width-panel">
<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>
</div>
}
</div>
} @else {
<div class="no-data-fallback">
<mat-icon>trending_up</mat-icon>
@@ -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,41 +35,194 @@
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-panels-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 1.25rem;
width: 100%;
box-sizing: border-box;
@media (max-width: 768px) {
grid-template-columns: 1fr;
.full-width-panel {
grid-column: 1 / -1;
}
}
.comparison-panel-card {
background: white;
border-radius: 12px;
border: 1px solid #e5e7eb;
padding: 1.25rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
width: 100%;
box-sizing: border-box;
}
.no-data-fallback {
display: flex;
flex-direction: column;
@@ -249,14 +230,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;
}
}
@@ -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,6 +330,13 @@ 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 defaultInstId = 'https://openalex.org/I62318514';
const primaryId = this.primaryInstitution() || defaultInstId;
const insts = this.comparisonInstitutions().map((i) => i.id);
@@ -345,17 +388,57 @@ 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
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();
// Map series topic_data keys to display names so they match selectedTrendTopics
const normalizeTopicData = (s: TrendSeries): TrendSeries => {
if (!s.topic_data) return s;
const rawTopicKeys = Object.keys(s.topic_data);
if (rawTopicKeys.length === 0) return s;
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,
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 +451,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 {
@@ -428,7 +511,7 @@ export class UniTrendParentComponent implements OnInit {
...countrySeries,
...regionSeries,
].map((s) => ({
...s,
...normalizeTopicData(s),
visible: this.isVisible(s.entity_id),
}));
@@ -445,6 +528,36 @@ 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);
if (resolved.searchType) {
this.selectedSearchType.set(resolved.searchType);
}
if (resolved.topics && resolved.topics.length > 0) {
this.selectedTrendTopics.set(resolved.topics);
if (
!this.activeChartTopic() ||
!resolved.topics.includes(this.activeChartTopic())
) {
this.activeChartTopic.set(resolved.topics[0]);
}
}
this.isTrendLoading.set(false);
}
});
// Effect: automatically sync checkboxes list whenever input keywords or fuzzy state changes
effect(() => {
const kws = this.keywords();
@@ -762,7 +875,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;
}
@@ -1311,6 +1424,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,
});
}),
);
};