Merge branch 'dev' of nes.uni-due.de:lbs/smartguide into feature/keywords-analysis

This commit is contained in:
2026-07-18 19:53:30 +02:00
323 changed files with 140214 additions and 87735 deletions
@@ -74,7 +74,9 @@
<div class="detail-stats">
<div class="stat">
<span class="stat-label">Match-Score</span>
<span class="stat-value">{{ formatScore(match.match_score) }}</span>
<span class="stat-value">{{
formatScore(match.match_score)
}}</span>
</div>
<div class="stat">
<span class="stat-label">Gematchte Keywords</span>
@@ -117,8 +119,13 @@
}
</div>
<button type="button" class="patent-detail-action" (click)="openDetail()">
<span class="patent-detail-action__label">Patentdetails anzeigen</span>
<button
type="button"
class="patent-detail-action"
(click)="openDetail()">
<span class="patent-detail-action__label"
>Patentdetails anzeigen</span
>
<span class="material-icons" aria-hidden="true">chevron_right</span>
</button>
</div>
@@ -48,7 +48,10 @@ export class KeywordsPatentsComponent {
}
pageCount(): number {
return Math.max(1, Math.ceil(this.filteredMatches().length / this.pageSize));
return Math.max(
1,
Math.ceil(this.filteredMatches().length / this.pageSize),
);
}
hasPagination(): boolean {
@@ -56,7 +56,9 @@ export function buildPatentSearchItemsFromPayload(
return buildPatentSearchItems(fallbackEntries);
}
export function readPatentsCache(keywords: string[]): KeywordPatentMatch[] | null {
export function readPatentsCache(
keywords: string[],
): KeywordPatentMatch[] | null {
const raw = sessionStorage.getItem(PATENTS_CACHE_KEY);
if (!raw) return null;
@@ -168,6 +170,8 @@ function hasPatentComponentScores(match: KeywordPatentMatch): boolean {
);
}
export function canReweightPatentMatches(matches: KeywordPatentMatch[]): boolean {
export function canReweightPatentMatches(
matches: KeywordPatentMatch[],
): boolean {
return matches.length > 0 && matches.every(hasPatentComponentScores);
}
@@ -132,18 +132,15 @@ export class SearchResultsStateService {
// without a resolvable keyword are skipped when building the lookup map
// so they can never collide on an `undefined` key and shadow a real one.
readonly topicsList = computed(() => {
const entryByKeyword = new Map<string, KeywordEntryWithTopic>();
for (const entry of this.selectedKeywordEntries()) {
const kw = entry.llm_keyword?.keyword?.trim().toLowerCase();
if (kw) {
entryByKeyword.set(kw, entry);
}
}
return this.keywords().map((kw) => {
const entry = entryByKeyword.get(kw.trim().toLowerCase());
const list = this.keywords().map((kw) => {
const entry = this.selectedKeywordEntries().find(
(e) =>
e.llm_keyword?.keyword?.trim().toLowerCase() ===
kw.trim().toLowerCase(),
);
return entry?.topic_mapping?.topic?.display_name ?? kw;
});
return Array.from(new Set(list));
});
setPayload(payload: SearchResultsPayload): void {
@@ -26,10 +26,10 @@ mat-panel-description {
.purpose-info-cards {
width: 100%;
display: flex;
gap: 1rem;
flex-wrap: wrap;
margin-top: 1rem;
display: flex;
gap: 1rem;
flex-wrap: wrap;
margin-top: 1rem;
}
.publication-list {
@@ -56,4 +56,4 @@ mat-panel-description {
width: 18px;
height: 18px;
line-height: 18px;
}
}
@@ -18,12 +18,13 @@ import {
RouterModule,
RouterOutlet,
} from '@angular/router';
import { of, switchMap, finalize, map, catchError } from 'rxjs';
import { of, switchMap, finalize, map, catchError, combineLatest } from 'rxjs';
import { PersonInterestingComponent } from '../person-interesting/person-interesting.component';
import { WorksService } from '../../api';
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
import { PersonDataResolved } from '../../resolvers/person.resolver';
import { BookmarkService } from '../../shared/services/bookmark.service';
@Component({
@@ -101,8 +102,17 @@ export class PersonComponent {
readonly person = toSignal(
this.activatedRoute.data.pipe(
map(({ personData }) => {
return personData?.results[0] ?? null;
switchMap((data) => {
const resolved = data['personData'] as PersonDataResolved | undefined;
if (!resolved) {
this.isPersonLoading.set(false);
return of(null);
}
this.isPersonLoading.set(true);
return resolved.personData$.pipe(
map((response) => response?.results?.[0] ?? null),
finalize(() => this.isPersonLoading.set(false)),
);
}),
),
{ initialValue: null },
@@ -118,8 +128,12 @@ export class PersonComponent {
}
readonly personBio = toSignal(
this.activatedRoute.data.pipe(
switchMap((data) => {
combineLatest([this.activatedRoute.data, toObservable(this.person)]).pipe(
switchMap(([data, person]) => {
if (!person) {
this.isBioLoading.set(false);
return of(null);
}
const resolved = data['personBio'] as PersonBioResolved | undefined;
if (!resolved) {
this.isBioLoading.set(false);
@@ -216,9 +230,13 @@ export class PersonComponent {
readonly isTopicsLoading = signal(false);
readonly primaryTopicCounts = toSignal(
toObservable(this.authorId).pipe(
switchMap((id) => {
if (!id) return of([]);
toObservable(this.person).pipe(
switchMap((person) => {
const id = this.authorId();
if (!person || !id) {
this.isTopicsLoading.set(false);
return of([]);
}
this.isTopicsLoading.set(true);
return this.worksApi.getPrimaryTopicCountsByAuthor(id).pipe(
catchError((err) => {
@@ -1,3 +1,11 @@
<div class="pie-chart-holder">
<div echarts [options]="chartOptions()" class="pie-chart-container"></div>
@if (loading()) {
<div class="pie-loader-overlay">
<mat-spinner diameter="35"></mat-spinner>
<span class="pie-loader-text">Lade Daten...</span>
</div>
}
@for (key of [entityId() || titleText() || 'overall']; track key) {
<div echarts [options]="chartOptions()" class="pie-chart-container"></div>
}
</div>
@@ -9,9 +9,32 @@
box-sizing: border-box;
width: 100%;
height: 380px;
position: relative;
}
.pie-chart-container {
width: 100%;
height: 100%;
}
.pie-loader-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.85);
border-radius: 16px;
z-index: 10;
gap: 0.75rem;
.pie-loader-text {
font-size: 12px;
color: #6b7280;
font-weight: 500;
}
}
@@ -10,11 +10,13 @@ import { NgxEchartsDirective } from 'ngx-echarts';
import { TrendResponse } from '../../../api';
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
@Component({
selector: 'app-uni-pie-chart',
templateUrl: './uni-pie-chart.component.html',
styleUrl: './uni-pie-chart.component.scss',
imports: [NgxEchartsDirective, CommonModule],
imports: [NgxEchartsDirective, CommonModule, MatProgressSpinner],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UniPieChartComponent {
@@ -79,128 +79,144 @@
<!-- Rechtes Haupt-Panel: Toggles & Diagramm -->
<main class="trend-main">
<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>
@if (isTrendLoading() && !rawTrendResponse()) {
<app-loading
text="Trenddaten werden initialisiert..."
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>
</div>
<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'
) {
<div class="chart-topic-tabs">
@for (topic of selectedTrendTopics(); track topic) {
<app-topic-chip
[label]="topic"
[active]="activeChartTopic() === topic"
[color]="getTopicColor(topic)"
(chipClick)="updateActiveChartTopic(topic)">
</app-topic-chip>
}
</div>
}
<app-uni-trend-chart
[data]="trendResponse()"
[mode]="chartMode()"
[activeTopic]="activeChartTopic()"
[startYear]="startYear()"
[endYear]="endYear()"
[getEntityColor]="boundGetEntityColor"></app-uni-trend-chart>
</div>
<!-- Pie Charts Row -->
@if (
selectedPieEntity() &&
selectedSearchType() !== 'news' &&
selectedSearchType() !== 'all'
) {
<div class="pie-charts-row" style="margin-bottom: 24px">
<app-uni-pie-chart
<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'
) {
<div class="chart-topic-tabs">
@for (topic of selectedTrendTopics(); track topic) {
<app-topic-chip
[label]="topic"
[active]="activeChartTopic() === topic"
[color]="getTopicColor(topic)"
(chipClick)="updateActiveChartTopic(topic)">
</app-topic-chip>
}
</div>
}
<app-uni-trend-chart
[data]="trendResponse()"
[entityId]="selectedPieEntity()!.id"
[entityName]="selectedPieEntity()!.name"
[mode]="chartMode()"
[activeTopic]="activeChartTopic()"
[startYear]="startYear()"
[endYear]="endYear()"
[getTopicColor]="boundGetTopicColor">
</app-uni-pie-chart>
<app-uni-pie-chart
[titleText]="'Top 10 Themen (Gesamt): ' + selectedPieEntity()!.name"
[pieData]="topTopicsData()"
[loading]="isTopTopicsLoading()"
[error]="topTopicsError()"
[startYear]="startYear()"
[endYear]="endYear()"
[getTopicColor]="boundGetTopicColor">
</app-uni-pie-chart>
[getEntityColor]="boundGetEntityColor"></app-uni-trend-chart>
</div>
}
<!-- Unified Institution Search, Compare, & Recommendations -->
@if (activeConfig().showInstitutionSelector) {
<app-institution-selector
[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>
}
<!-- Pie Charts Row -->
@if (
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>
<!-- Reusable Author Selection UI (Main Panel below chart) -->
@if (activeConfig().showAuthorSelector) {
<app-author-selector
[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>
<app-uni-pie-chart
[titleText]="
'Top 10 Themen (Gesamt): ' + selectedPieEntity()!.name
"
[pieData]="topTopicsData()"
[loading]="isTopTopicsLoading() || isTrendLoading()"
[error]="topTopicsError()"
[startYear]="startYear()"
[endYear]="endYear()"
[getTopicColor]="boundGetTopicColor">
</app-uni-pie-chart>
</div>
}
<!-- Unified Institution Search, Compare, & Recommendations -->
@if (activeConfig().showInstitutionSelector) {
<app-institution-selector
[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 (Main Panel below chart) -->
@if (activeConfig().showAuthorSelector) {
<app-author-selector
[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>
}
} @else {
<div class="no-data-fallback">
<mat-icon>trending_up</mat-icon>
<p>Bitte wählen Sie Themen aus, um die Trends zu laden.</p>
</div>
}
</main>
</div>
@@ -1,6 +1,6 @@
.trend-layout {
display: grid;
grid-template-columns: 300px 1fr;
grid-template-columns: 300px minmax(0, 1fr);
gap: 1.5rem;
margin-top: 1.5rem;
font-family: 'Inter', sans-serif;
@@ -237,3 +237,22 @@
grid-template-columns: 1fr;
}
}
.no-data-fallback {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 400px;
background: white;
border-radius: 10px;
border: 1px solid #e5e7eb;
color: #9ca3af;
gap: 0.5rem;
mat-icon {
font-size: 48px;
width: 48px;
height: 48px;
}
}
@@ -43,6 +43,7 @@ import { InstitutionSelectorComponent } from '../../../shared/ui/institution-sel
import { AuthorSelectorComponent } from '../../../shared/ui/author-selector/author-selector.component';
import { AuthorInstitutionSelectorComponent } from '../../../shared/ui/author-institution-selector/author-institution-selector.component';
import { SearchResultsStateService } from '../../keywords-search/search-results/search-results-state.service';
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
export interface CompareItem {
id: string;
@@ -81,7 +82,7 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
},
projects: {
showInstitutionSelector: true,
showLocationSelector: false,
showLocationSelector: true,
showAuthorSelector: false,
yAxisLabel: 'Projektförderung (Anz)',
chartTitle: 'Drittmittelförderung-Trends',
@@ -120,6 +121,7 @@ export const TREND_CONFIGS: Record<string, TrendStrategyConfig> = {
InstitutionSelectorComponent,
AuthorSelectorComponent,
AuthorInstitutionSelectorComponent,
LoadingComponent,
],
templateUrl: './uni-trend-parent.component.html',
styleUrl: './uni-trend-parent.component.scss',
@@ -755,7 +757,6 @@ export class UniTrendParentComponent implements OnInit {
// Use mapped topic names if softSearch is false
const topics = this.state?.topicsList() ?? kws;
const topic = topics[0] || kws[0] || 'Artificial Intelligence';
this.isSuggestionsLoading.set(true);
forkJoin({
deInsts:
@@ -797,7 +798,6 @@ export class UniTrendParentComponent implements OnInit {
name,
}));
this.comparisonInstitutions.set(list);
this.isSuggestionsLoading.set(false);
if (!this.rawTrendResponse()) {
this.fetchTrendData();
@@ -805,7 +805,6 @@ export class UniTrendParentComponent implements OnInit {
},
error: (err: any) => {
console.error('Failed to load default institutions dynamically:', err);
this.isSuggestionsLoading.set(false);
},
});
}
@@ -817,7 +816,6 @@ export class UniTrendParentComponent implements OnInit {
const topics = this.state?.topicsList() ?? kws;
const topic = topics[0] || kws[0] || 'Artificial Intelligence';
this.isSuggestionsLoading.set(true);
this.personsApiService
.searchPersonsList(
@@ -837,7 +835,6 @@ export class UniTrendParentComponent implements OnInit {
name: author.display_name || 'Unbekannt',
}));
this.comparisonAuthors.set(list);
this.isSuggestionsLoading.set(false);
if (!this.rawTrendResponse()) {
this.fetchTrendData();
@@ -845,7 +842,6 @@ export class UniTrendParentComponent implements OnInit {
},
error: (err) => {
console.error('Failed to load default authors:', err);
this.isSuggestionsLoading.set(false);
},
});
}