@if (article.full_content) { -

+ [content]="article.full_content" + [highlights]="articleHighlights" /> } @else {

Kein Inhalt verfügbar.

} diff --git a/webapp/src/app/modules/news-detail/news-detail.component.scss b/webapp/src/app/modules/news-detail/news-detail.component.scss index 1d31ab79..ba40e8bd 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.scss +++ b/webapp/src/app/modules/news-detail/news-detail.component.scss @@ -600,25 +600,3 @@ main { background: transparent; } } - -:host ::ng-deep .kw-mark { - background: transparent; - color: var(--t); - text-decoration: underline; - text-decoration-color: var(--t); - text-decoration-style: solid; - text-decoration-thickness: 2px; - text-underline-offset: 2px; - font-weight: inherit; - border-radius: 2px; - padding: 0 1px; - transition: background 0.15s; - - &:hover { - background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); - } - - &.kw-flash { - animation: kw-flash 2.4s ease-out forwards; - } -} diff --git a/webapp/src/app/modules/news-detail/news-detail.component.ts b/webapp/src/app/modules/news-detail/news-detail.component.ts index fdbb74f9..f048b76f 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.ts +++ b/webapp/src/app/modules/news-detail/news-detail.component.ts @@ -12,8 +12,10 @@ import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; - +import { + HighlightedTextComponent, + HighlightTerm, +} from '../../shared/ui/highlighted-text/highlighted-text.component'; import { WorksService } from '../../api'; import { topicHierarchyColor } from '../../resolvers/utils/topic-colors'; import { LoadingComponent } from '../../shared/ui/loading/loading.component'; @@ -54,21 +56,21 @@ interface NewsArticleDetail { MatTooltipModule, RouterLink, LoadingComponent, + HighlightedTextComponent, ], templateUrl: './news-detail.component.html', styleUrl: './news-detail.component.scss', }) export class NewsDetailComponent implements OnInit { - @ViewChild('articleBody') articleBodyRef?: ElementRef; + @ViewChild('articleBody', { read: ElementRef }) + articleBodyRef?: ElementRef; private readonly router = inject(Router); private readonly destroyRef = inject(DestroyRef); private readonly route = inject(ActivatedRoute); private readonly httpClient = inject(HttpClient); private readonly worksService = inject(WorksService); - private readonly sanitizer = inject(DomSanitizer); article: NewsArticleDetail | null = null; - highlightedContent: SafeHtml = this.sanitizer.bypassSecurityTrustHtml(''); loading = false; notFound = false; @@ -172,7 +174,6 @@ export class NewsDetailComponent implements OnInit { .subscribe({ next: (article) => { this.article = article; - this.highlightedContent = this.buildHighlightedContent(article); this.expandedTopicId = null; this.personsPage = 0; this.loading = false; @@ -184,56 +185,33 @@ export class NewsDetailComponent implements OnInit { }); } - private buildHighlightedContent(article: NewsArticleDetail): SafeHtml { - const text = article.full_content; - if (!text) return this.sanitizer.bypassSecurityTrustHtml(''); - const keywords = article.keywords ?? []; + get articleHighlights(): HighlightTerm[] { + const article = this.article; + if (!article) return []; - const keywordColorMap = new Map(); + const topicByKeyword = new Map(); for (const topic of article.topics ?? []) { if (topic.source_keyword) { - keywordColorMap.set( - topic.source_keyword.toLowerCase(), - this.getTopicColor(topic), - ); + topicByKeyword.set(topic.source_keyword.toLowerCase(), topic); } } - let html = this.escapeHtml(text); - [...keywords] - .sort((a, b) => b.length - a.length) - .forEach((kw) => { - const color = keywordColorMap.get(kw.toLowerCase()); - if (!color) return; - const kwHtml = this.escapeHtml(kw); - const escaped = this.escapeRegex(kwHtml); - const before = '(?$1`, - ); + const highlights: HighlightTerm[] = []; + for (const keyword of article.keywords ?? []) { + const topic = topicByKeyword.get(keyword.toLowerCase()); + if (!topic) continue; + + highlights.push({ + term: keyword, + topic: { + id: topic.id, + name: topic.display_name, + field_name: topic.field_name, + domain_name: topic.domain_name, + }, }); - return this.sanitizer.bypassSecurityTrustHtml(html); - } + } - private escapeHtml(text: string): string { - return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - - private escapeRegex(text: string): string { - return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + return highlights; } } From 1758227f1e6092b577b1c1c89138556296e3bb20 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:43:52 +0200 Subject: [PATCH 019/152] Add institution tabs --- .../dashboard/dashboard.component.html | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/webapp/src/app/modules/dashboard/dashboard.component.html b/webapp/src/app/modules/dashboard/dashboard.component.html index f25fcc0b..d9683eb5 100644 --- a/webapp/src/app/modules/dashboard/dashboard.component.html +++ b/webapp/src/app/modules/dashboard/dashboard.component.html @@ -193,6 +193,39 @@

Die Kennzahlen konnten nicht geladen werden.

} +
+

Institution auswählen

+
+ + @for (institution of dashboardInstitutions; track institution.id) { + + } +
+ @if (dashboardInstitutionsError) { +

+ Die Institutionen konnten nicht geladen werden. +

+ } +
+ @if ( euProjectStatusesLoading || bmbfProjectStatusesLoading || From fbcee778d2ecf6903dc025c3c99d071cb1897120 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:44:34 +0200 Subject: [PATCH 020/152] Add institution tab styles --- .../dashboard/dashboard.component.scss | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/webapp/src/app/modules/dashboard/dashboard.component.scss b/webapp/src/app/modules/dashboard/dashboard.component.scss index 00aa14a1..ebc289ad 100644 --- a/webapp/src/app/modules/dashboard/dashboard.component.scss +++ b/webapp/src/app/modules/dashboard/dashboard.component.scss @@ -152,6 +152,74 @@ color: var(--sg-error); } + .dashboard-institution-tabs { + margin: -0.25rem 0 2rem; + + h2 { + margin: 0 0 0.75rem; + font-size: 1.2rem; + line-height: 1.25; + } + } + + .dashboard-institution-tab-list { + display: flex; + overflow-x: auto; + overflow-y: hidden; + border-bottom: 1px solid var(--sg-border); + background: transparent; + scrollbar-width: thin; + + button { + position: relative; + flex: 0 0 auto; + min-width: 120px; + height: 48px; + padding: 0 16px; + border: 0; + border-radius: 0; + background: transparent; + color: var(--sg-text-muted); + cursor: pointer; + font: inherit; + font-size: 14px; + font-weight: 600; + line-height: 48px; + white-space: nowrap; + transition: + color 0.15s ease, + background-color 0.15s ease; + + &::after { + position: absolute; + right: 0; + bottom: 0; + left: 0; + border-top: 3px solid transparent; + background: transparent; + content: ''; + } + + &:hover { + background: var(--sg-option-hover); + color: var(--sg-text); + } + + &:focus-visible { + outline: 3px solid var(--sg-card-hover-border); + outline-offset: -3px; + } + + &.active { + color: var(--sg-blue-highlight); + + &::after { + border-top-color: var(--sg-blue-highlight); + } + } + } + } + .top-authors-section { margin-bottom: 2.5rem; } From 82fa2e816b857343d83f28d3a73dedadfc272965 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:45:24 +0200 Subject: [PATCH 021/152] Add institution filtering --- .../dashboard/dashboard-statistics.service.ts | 42 +++- .../modules/dashboard/dashboard.component.ts | 238 ++++++++++++++---- 2 files changed, 219 insertions(+), 61 deletions(-) diff --git a/webapp/src/app/modules/dashboard/dashboard-statistics.service.ts b/webapp/src/app/modules/dashboard/dashboard-statistics.service.ts index 3ae23a74..831d48a7 100644 --- a/webapp/src/app/modules/dashboard/dashboard-statistics.service.ts +++ b/webapp/src/app/modules/dashboard/dashboard-statistics.service.ts @@ -175,28 +175,31 @@ export class DashboardStatisticsService { getEuProjectStatuses( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/eu/status`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } getBmbfProjectStatuses( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/bmbf/status`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } getDfgProjectStatuses( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/dfg/status`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } @@ -222,39 +225,43 @@ export class DashboardStatisticsService { getDfgProjectTopics( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/dfg/topics`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } getEuProjectTopics( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/eu/topics`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } getBundProjectTopics( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { return this.httpClient.get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/bund/topics`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ); } getTopAuthors( period: DashboardPeriodBounds = {}, + institutionId = 'all', ): Observable { const analysis = (source: string) => this.httpClient .get( `${this.apiConfiguration?.basePath ?? ''}/api/dashboard/top-authors/${source}`, - { params: this.periodParams(period) }, + { params: this.analyticalParams(period, institutionId) }, ) .pipe(catchError(() => of(null))); @@ -288,8 +295,11 @@ export class DashboardStatisticsService { getTopicTreemap( fromYear?: number, toYear?: number, + institutionId = 'all', ): Observable { - const params: Record = {}; + const params: Record = { + institution_id: institutionId, + }; if (fromYear !== undefined) params['from_year'] = fromYear; if (toYear !== undefined) params['to_year'] = toYear; @@ -303,8 +313,12 @@ export class DashboardStatisticsService { topicId: string, fromYear?: number, toYear?: number, + institutionId = 'all', ): Observable { - const params: Record = { topicId }; + const params: Record = { + topicId, + institution_id: institutionId, + }; if (fromYear !== undefined) params['from_year'] = fromYear; if (toYear !== undefined) params['to_year'] = toYear; return this.httpClient.get( @@ -329,4 +343,14 @@ export class DashboardStatisticsService { institution_id: institutionId, }; } + + private analyticalParams( + period: DashboardPeriodBounds, + institutionId: string, + ): Record { + return { + ...this.periodParams(period), + institution_id: institutionId, + }; + } } diff --git a/webapp/src/app/modules/dashboard/dashboard.component.ts b/webapp/src/app/modules/dashboard/dashboard.component.ts index d396c12b..52bffe64 100644 --- a/webapp/src/app/modules/dashboard/dashboard.component.ts +++ b/webapp/src/app/modules/dashboard/dashboard.component.ts @@ -135,6 +135,7 @@ export class DashboardComponent implements OnInit { dashboardToYear = this.topicTreemapMaxYear; dashboardInstitutions: DashboardInstitution[] = []; selectedDashboardInstitutionId = 'all'; + selectedAnalyticalInstitutionId = 'all'; dashboardInstitutionsLoading = false; dashboardInstitutionsError = false; selectedTopicTreemapNode?: string; @@ -143,6 +144,7 @@ export class DashboardComponent implements OnInit { selectedBundTopicTreemapNode?: string; private topicTreemapReloadQueued = false; private topicTreemapRequestId = 0; + private analyticalRequestId = 0; constructor( private statisticsService: DashboardStatisticsService, @@ -185,6 +187,20 @@ export class DashboardComponent implements OnInit { this.selectedDashboardInstitutionId = restoredInstitution; this.loadStatistics(); } + const requestedAnalyticalInstitution = + this.route.snapshot.queryParamMap.get('analyticalInstitution') ?? + 'all'; + const restoredAnalyticalInstitution = institutions.some( + (institution) => institution.id === requestedAnalyticalInstitution, + ) + ? requestedAnalyticalInstitution + : 'all'; + if ( + restoredAnalyticalInstitution !== this.selectedAnalyticalInstitutionId + ) { + this.selectedAnalyticalInstitutionId = restoredAnalyticalInstitution; + this.reloadAnalyticalData(); + } }, error: () => { this.dashboardInstitutions = []; @@ -416,6 +432,13 @@ export class DashboardComponent implements OnInit { this.loadStatistics(); } + onAnalyticalInstitutionChange(institutionId: string): void { + if (institutionId === this.selectedAnalyticalInstitutionId) return; + this.selectedAnalyticalInstitutionId = institutionId; + this.updateDashboardPeriodUrl(); + this.reloadAnalyticalData(); + } + onTopicTreemapNodeChange(nodeId: string | undefined): void { this.selectedTopicTreemapNode = nodeId; this.updateDashboardPeriodUrl(); @@ -519,6 +542,7 @@ export class DashboardComponent implements OnInit { ...topic, fromYear: period.fromYear, toYear: period.toYear, + institutionId: this.selectedAnalyticalInstitutionId, }, }, ); @@ -585,6 +609,7 @@ export class DashboardComponent implements OnInit { euTreemapNode: this.selectedEuTopicTreemapNode ?? null, bundTreemapNode: this.selectedBundTopicTreemapNode ?? null, institution: this.selectedDashboardInstitutionId, + analyticalInstitution: this.selectedAnalyticalInstitutionId, }, queryParamsHandling: 'merge', replaceUrl: true, @@ -611,14 +636,19 @@ export class DashboardComponent implements OnInit { private reloadPeriodData(): void { this.loadStatistics(); - this.loadTopAuthors(); - this.loadTopicTreemap(); - this.loadDfgProjectTopics(); - this.loadEuProjectTopics(); - this.loadBundProjectTopics(); - this.loadEuProjectStatuses(); - this.loadBmbfProjectStatuses(); - this.loadDfgProjectStatuses(); + this.reloadAnalyticalData(); + } + + private reloadAnalyticalData(): void { + const requestId = ++this.analyticalRequestId; + this.loadTopAuthors(requestId); + this.loadTopicTreemap(requestId); + this.loadDfgProjectTopics(requestId); + this.loadEuProjectTopics(requestId); + this.loadBundProjectTopics(requestId); + this.loadEuProjectStatuses(requestId); + this.loadBmbfProjectStatuses(requestId); + this.loadDfgProjectStatuses(requestId); } private loadStatistic( @@ -666,149 +696,253 @@ export class DashboardComponent implements OnInit { this.statistics = nextStatistics; } - private loadTopAuthors(): void { + private loadTopAuthors(requestId = this.analyticalRequestId): void { this.topAuthorsLoading = true; this.topAuthorsError = false; this.statisticsService - .getTopAuthors(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.topAuthorsLoading = false))) + .getTopAuthors( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.topAuthorsLoading = false; + } + }), + ) .subscribe({ next: (statistics) => { - this.topAuthors = statistics; + if (requestId === this.analyticalRequestId) { + this.topAuthors = statistics; + } }, error: () => { - this.topAuthorsError = true; + if (requestId === this.analyticalRequestId) { + this.topAuthorsError = true; + } }, }); } - private loadDfgProjectTopics(): void { + private loadDfgProjectTopics(requestId = this.analyticalRequestId): void { this.dfgTopicsLoading = true; this.dfgTopicsError = false; this.statisticsService - .getDfgProjectTopics(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.dfgTopicsLoading = false))) + .getDfgProjectTopics( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.dfgTopicsLoading = false; + } + }), + ) .subscribe({ next: (topics) => { - this.dfgProjectTopics = topics; - this.dfgTopicTreemap = this.buildDfgTopicTreemapData(topics); + if (requestId === this.analyticalRequestId) { + this.dfgProjectTopics = topics; + this.dfgTopicTreemap = this.buildDfgTopicTreemapData(topics); + } }, error: () => { - this.dfgTopicsError = true; + if (requestId === this.analyticalRequestId) { + this.dfgTopicsError = true; + } }, }); } - private loadEuProjectTopics(): void { + private loadEuProjectTopics(requestId = this.analyticalRequestId): void { this.euTopicsLoading = true; this.euTopicsError = false; this.statisticsService - .getEuProjectTopics(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.euTopicsLoading = false))) + .getEuProjectTopics( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.euTopicsLoading = false; + } + }), + ) .subscribe({ next: (topics) => { - this.euProjectTopics = topics; - this.euTopicTreemap = this.buildDfgTopicTreemapData(topics); + if (requestId === this.analyticalRequestId) { + this.euProjectTopics = topics; + this.euTopicTreemap = this.buildDfgTopicTreemapData(topics); + } }, error: () => { - this.euTopicsError = true; + if (requestId === this.analyticalRequestId) { + this.euTopicsError = true; + } }, }); } - private loadBundProjectTopics(): void { + private loadBundProjectTopics(requestId = this.analyticalRequestId): void { this.bundTopicsLoading = true; this.bundTopicsError = false; this.statisticsService - .getBundProjectTopics(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.bundTopicsLoading = false))) + .getBundProjectTopics( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.bundTopicsLoading = false; + } + }), + ) .subscribe({ next: (topics) => { - this.bundProjectTopics = topics; - this.bundTopicTreemap = this.buildDfgTopicTreemapData(topics); + if (requestId === this.analyticalRequestId) { + this.bundProjectTopics = topics; + this.bundTopicTreemap = this.buildDfgTopicTreemapData(topics); + } }, error: () => { - this.bundTopicsError = true; + if (requestId === this.analyticalRequestId) { + this.bundTopicsError = true; + } }, }); } - private loadEuProjectStatuses(): void { + private loadEuProjectStatuses(requestId = this.analyticalRequestId): void { this.euProjectStatusesLoading = true; this.euProjectStatusesError = false; this.statisticsService - .getEuProjectStatuses(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.euProjectStatusesLoading = false))) + .getEuProjectStatuses( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.euProjectStatusesLoading = false; + } + }), + ) .subscribe({ next: (statuses) => { - this.euProjectStatuses = statuses; + if (requestId === this.analyticalRequestId) { + this.euProjectStatuses = statuses; + } }, error: () => { - this.euProjectStatusesError = true; + if (requestId === this.analyticalRequestId) { + this.euProjectStatusesError = true; + } }, }); } - private loadBmbfProjectStatuses(): void { + private loadBmbfProjectStatuses(requestId = this.analyticalRequestId): void { this.bmbfProjectStatusesLoading = true; this.bmbfProjectStatusesError = false; this.statisticsService - .getBmbfProjectStatuses(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.bmbfProjectStatusesLoading = false))) + .getBmbfProjectStatuses( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.bmbfProjectStatusesLoading = false; + } + }), + ) .subscribe({ next: (statuses) => { - this.bmbfProjectStatuses = statuses; + if (requestId === this.analyticalRequestId) { + this.bmbfProjectStatuses = statuses; + } }, error: () => { - this.bmbfProjectStatusesError = true; + if (requestId === this.analyticalRequestId) { + this.bmbfProjectStatusesError = true; + } }, }); } - private loadDfgProjectStatuses(): void { + private loadDfgProjectStatuses(requestId = this.analyticalRequestId): void { this.dfgProjectStatusesLoading = true; this.dfgProjectStatusesError = false; this.statisticsService - .getDfgProjectStatuses(this.selectedPeriodBounds()) - .pipe(finalize(() => (this.dfgProjectStatusesLoading = false))) + .getDfgProjectStatuses( + this.selectedPeriodBounds(), + this.selectedAnalyticalInstitutionId, + ) + .pipe( + finalize(() => { + if (requestId === this.analyticalRequestId) { + this.dfgProjectStatusesLoading = false; + } + }), + ) .subscribe({ next: (statuses) => { - this.dfgProjectStatuses = statuses; + if (requestId === this.analyticalRequestId) { + this.dfgProjectStatuses = statuses; + } }, error: () => { - this.dfgProjectStatusesError = true; + if (requestId === this.analyticalRequestId) { + this.dfgProjectStatusesError = true; + } }, }); } - private loadTopicTreemap(): void { + private loadTopicTreemap(analyticalRequestId = this.analyticalRequestId): void { if (this.dashboardFromYear > this.dashboardToYear) { this.topicTreemapLoading = false; this.topicTreemapError = true; return; } - const requestId = ++this.topicTreemapRequestId; + const treemapRequestId = ++this.topicTreemapRequestId; const period = this.selectedPeriodBounds(); this.topicTreemapLoading = true; this.topicTreemapError = false; this.statisticsService - .getTopicTreemap(period.fromYear, period.toYear) + .getTopicTreemap( + period.fromYear, + period.toYear, + this.selectedAnalyticalInstitutionId, + ) .pipe( finalize(() => { - if (requestId === this.topicTreemapRequestId) { + if ( + analyticalRequestId === this.analyticalRequestId && + treemapRequestId === this.topicTreemapRequestId + ) { this.topicTreemapLoading = false; } }), ) .subscribe({ next: (treemap) => { - if (requestId === this.topicTreemapRequestId) { + if ( + analyticalRequestId === this.analyticalRequestId && + treemapRequestId === this.topicTreemapRequestId + ) { this.topicTreemap = treemap; } }, error: () => { - if (requestId === this.topicTreemapRequestId) { + if ( + analyticalRequestId === this.analyticalRequestId && + treemapRequestId === this.topicTreemapRequestId + ) { this.topicTreemapError = true; } }, From c70e6bf4890ef7316378d3d2e0326779fd04e0d2 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:45:40 +0200 Subject: [PATCH 022/152] Filter word cloud by institution --- .../topic-wordcloud-dialog/topic-wordcloud-dialog.component.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webapp/src/app/modules/dashboard/topic-wordcloud-dialog/topic-wordcloud-dialog.component.ts b/webapp/src/app/modules/dashboard/topic-wordcloud-dialog/topic-wordcloud-dialog.component.ts index a8b75dc0..21bb9610 100644 --- a/webapp/src/app/modules/dashboard/topic-wordcloud-dialog/topic-wordcloud-dialog.component.ts +++ b/webapp/src/app/modules/dashboard/topic-wordcloud-dialog/topic-wordcloud-dialog.component.ts @@ -22,6 +22,7 @@ export interface TopicWordCloudDialogData { subfieldName?: string; fromYear?: number; toYear?: number; + institutionId?: string; words?: TopicWordCloudWord[]; source?: 'publications' | 'dfg' | 'eu' | 'bund'; } @@ -82,6 +83,7 @@ export class TopicWordCloudDialogComponent { this.data.topicId, this.data.fromYear, this.data.toYear, + this.data.institutionId, ) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe({ From 6a6ec8662cf5e353590415a8d2b6ae0c165d0d56 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:45:56 +0200 Subject: [PATCH 023/152] Filter dashboard analytics by institution --- service/src/main/inse/dashboard/router.py | 119 +++++++++++++++++---- service/src/main/inse/dashboard/service.py | 20 ++++ 2 files changed, 117 insertions(+), 22 deletions(-) diff --git a/service/src/main/inse/dashboard/router.py b/service/src/main/inse/dashboard/router.py index f6408c94..96b1dbe0 100644 --- a/service/src/main/inse/dashboard/router.py +++ b/service/src/main/inse/dashboard/router.py @@ -24,6 +24,7 @@ from .model import ( TopicWordCloud, ) from .service import ( + get_dashboard_analytical_institution, get_dashboard_institutions, get_dashboard_organization, get_dashboard_patents, @@ -190,15 +191,21 @@ async def dashboard_eu_projects( response_model=EuProjectStatusStatistics, ) async def dashboard_eu_project_statuses( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> EuProjectStatusStatistics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_eu_project_statuses( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -234,15 +241,21 @@ async def dashboard_bmbf_projects( response_model=BmbfProjectStatusStatistics, ) async def dashboard_bmbf_project_statuses( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> BmbfProjectStatusStatistics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_bmbf_project_statuses( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -278,15 +291,21 @@ async def dashboard_dfg_projects( response_model=DfgProjectStatusStatistics, ) async def dashboard_dfg_project_statuses( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> DfgProjectStatusStatistics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_dfg_project_statuses( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -298,15 +317,21 @@ async def dashboard_dfg_project_statuses( response_model=DfgProjectTopics, ) async def dashboard_dfg_project_topics( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> DfgProjectTopics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_dfg_topics( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -318,15 +343,21 @@ async def dashboard_dfg_project_topics( response_model=EuProjectTopics, ) async def dashboard_eu_project_topics( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> EuProjectTopics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_eu_topics( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -338,15 +369,21 @@ async def dashboard_eu_project_topics( response_model=BundProjectTopics, ) async def dashboard_bund_project_topics( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> BundProjectTopics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_dashboard_bund_topics( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, from_year=from_year, to_year=to_year, ) @@ -362,15 +399,21 @@ async def dashboard_top_authors( default="all_time", pattern="^(all_time|last_5_years)$", ), + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorStatistics: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_top_authors( - organization.openalex_institution_id, - organization.name, + selected_institution_id, + selected_institution_name, works_period=works_period, from_year=from_year, to_year=to_year, @@ -386,14 +429,18 @@ async def dashboard_top_work_authors( works_period: Literal["all_time", "last_5_years"] = Query( default="all_time", pattern="^(all_time|last_5_years)$" ), + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorAnalysis: organization = get_dashboard_organization(session, access_token) + selected_institution_id, _ = await get_dashboard_analytical_institution( + session, organization, institution_id + ) return await get_top_work_authors( - organization.openalex_institution_id, works_period, from_year, to_year + selected_institution_id, works_period, from_year, to_year ) @@ -403,14 +450,20 @@ async def dashboard_top_work_authors( response_model=TopAuthorAnalysis, ) async def dashboard_top_project_authors( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorAnalysis: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_top_project_authors( - organization.openalex_institution_id, organization.name, from_year, to_year + selected_institution_id, selected_institution_name, from_year, to_year ) @@ -420,14 +473,18 @@ async def dashboard_top_project_authors( response_model=TopAuthorAnalysis, ) async def dashboard_top_eu_project_authors( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorAnalysis: organization = get_dashboard_organization(session, access_token) + selected_institution_id, _ = await get_dashboard_analytical_institution( + session, organization, institution_id + ) return await get_top_eu_project_authors( - organization.openalex_institution_id, from_year, to_year + selected_institution_id, from_year, to_year ) @@ -437,14 +494,18 @@ async def dashboard_top_eu_project_authors( response_model=TopAuthorAnalysis, ) async def dashboard_top_patent_authors( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorAnalysis: organization = get_dashboard_organization(session, access_token) + selected_institution_id, _ = await get_dashboard_analytical_institution( + session, organization, institution_id + ) return await get_top_patent_authors( - organization.openalex_institution_id, from_year, to_year + selected_institution_id, from_year, to_year ) @@ -454,14 +515,18 @@ async def dashboard_top_patent_authors( response_model=TopAuthorAnalysis, ) async def dashboard_top_news_authors( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), session: Session = Depends(get_session), access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopAuthorAnalysis: organization = get_dashboard_organization(session, access_token) + selected_institution_id, _ = await get_dashboard_analytical_institution( + session, organization, institution_id + ) return await get_top_news_authors( - organization.openalex_institution_id, from_year, to_year + selected_institution_id, from_year, to_year ) @@ -471,6 +536,7 @@ async def dashboard_top_news_authors( response_model=TopicHeatmap, ) async def dashboard_topic_heatmap( + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), limit: int = Query(default=25, ge=1, le=50), @@ -478,9 +544,14 @@ async def dashboard_topic_heatmap( access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopicHeatmap: organization = get_dashboard_organization(session, access_token) + selected_institution_id, selected_institution_name = ( + await get_dashboard_analytical_institution( + session, organization, institution_id + ) + ) return await get_topic_heatmap( - institution_id=organization.openalex_institution_id, - organization_name=organization.name, + institution_id=selected_institution_id, + organization_name=selected_institution_name, from_year=from_year, to_year=to_year, limit=limit, @@ -494,6 +565,7 @@ async def dashboard_topic_heatmap( ) async def dashboard_topic_word_cloud( topic_id: str = Query(alias="topicId", min_length=1), + institution_id: str | None = Query(default=None), from_year: int | None = Query(default=None, ge=1900, le=2100), to_year: int | None = Query(default=None, ge=1900, le=2100), limit: int = Query(default=30, ge=1, le=100), @@ -501,8 +573,11 @@ async def dashboard_topic_word_cloud( access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep, ) -> TopicWordCloud: organization = get_dashboard_organization(session, access_token) + selected_institution_id, _ = await get_dashboard_analytical_institution( + session, organization, institution_id + ) return await get_topic_word_cloud( - institution_id=organization.openalex_institution_id, + institution_id=selected_institution_id, topic_id=topic_id, from_year=from_year, to_year=to_year, diff --git a/service/src/main/inse/dashboard/service.py b/service/src/main/inse/dashboard/service.py index a45ec108..21a7351d 100644 --- a/service/src/main/inse/dashboard/service.py +++ b/service/src/main/inse/dashboard/service.py @@ -108,6 +108,26 @@ async def get_dashboard_statistic_institution_ids( return [selected_id] +async def get_dashboard_analytical_institution( + session: Session, + organization: Organization, + selected_institution_id: str | None, +) -> tuple[str, str]: + if selected_institution_id in (None, "all"): + return organization.openalex_institution_id, organization.name + + selected_id = _raw_institution_id(selected_institution_id) + institutions = await get_dashboard_institutions(session, organization) + for institution in institutions: + if institution.id == selected_id: + return selected_id, institution.display_name + + raise HTTPException( + status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + detail="Institution is not associated with this organization.", + ) + + def _statistic_scope_id(institution_ids: list[str]) -> str: return ( _normalize_institution_id(institution_ids[0]) From 8d7323a387a94ad5daf6b8ac145a6c93c2c22bca Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:46:05 +0200 Subject: [PATCH 024/152] Add institution filter tests --- .../src/main/inse/dashboard/test_service.py | 102 ++++++++++++++++++ .../dashboard-statistics.service.spec.ts | 91 ++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 webapp/src/app/modules/dashboard/dashboard-statistics.service.spec.ts diff --git a/service/src/main/inse/dashboard/test_service.py b/service/src/main/inse/dashboard/test_service.py index c325780e..a57c762b 100644 --- a/service/src/main/inse/dashboard/test_service.py +++ b/service/src/main/inse/dashboard/test_service.py @@ -15,6 +15,7 @@ from inse.auth.model import ( UserRole, ) from inse.dashboard.service import ( + get_dashboard_analytical_institution, get_dashboard_institutions, get_dashboard_organization, get_dashboard_persons, @@ -1682,6 +1683,107 @@ async def test_dashboard_institutions_include_openalex_associations(): ] +@pytest.mark.anyio +async def test_dashboard_analytical_institution_all_uses_root_organization(): + engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) + SQLModel.metadata.create_all(engine) + + with Session(engine) as session: + organization = Organization( + name="Example University", + openalex_institution_id="I123", + ) + session.add(organization) + session.commit() + session.refresh(organization) + + result = await get_dashboard_analytical_institution( + session, + organization, + "all", + ) + + assert result == ("I123", "Example University") + + +@pytest.mark.anyio +async def test_dashboard_analytical_institution_uses_selected_tab_institution(): + engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) + SQLModel.metadata.create_all(engine) + + with Session(engine) as session: + organization = Organization( + name="Example University", + openalex_institution_id="I123", + ) + session.add(organization) + session.commit() + session.refresh(organization) + session.add( + OrganizationInstitution( + organization_id=organization.id, + openalex_institution_id="I123", + position=0, + ) + ) + session.commit() + + associations = [ + InstitutionAssociationsResponse( + id="I123", + display_name="Main institution", + associated_institutions=[ + InstitutionAssociation( + id="I456", + display_name="Child institution", + relationship="child", + ), + ], + ) + ] + with patch( + "inse.dashboard.service.organization_management_service." + "resolve_institution_associations", + new=AsyncMock(return_value=associations), + ): + result = await get_dashboard_analytical_institution( + session, + organization, + "https://openalex.org/I456", + ) + + assert result == ("I456", "Child institution") + + +@pytest.mark.anyio +async def test_dashboard_analytical_institution_rejects_unassociated_selection(): + engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) + SQLModel.metadata.create_all(engine) + + with Session(engine) as session: + organization = Organization( + name="Example University", + openalex_institution_id="I123", + ) + session.add(organization) + session.commit() + session.refresh(organization) + + with patch( + "inse.dashboard.service.organization_management_service." + "resolve_institution_associations", + new=AsyncMock(return_value=[]), + ): + with pytest.raises(HTTPException) as exc_info: + await get_dashboard_analytical_institution( + session, + organization, + "I999", + ) + + assert exc_info.value.status_code == 422 + + def test_get_dashboard_organization_rejects_missing_openalex_id(): engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) SQLModel.metadata.create_all(engine) diff --git a/webapp/src/app/modules/dashboard/dashboard-statistics.service.spec.ts b/webapp/src/app/modules/dashboard/dashboard-statistics.service.spec.ts new file mode 100644 index 00000000..b1129469 --- /dev/null +++ b/webapp/src/app/modules/dashboard/dashboard-statistics.service.spec.ts @@ -0,0 +1,91 @@ +import { TestBed } from '@angular/core/testing'; +import { + HttpTestingController, + provideHttpClientTesting, +} from '@angular/common/http/testing'; +import { provideHttpClient } from '@angular/common/http'; + +import { DashboardStatisticsService } from './dashboard-statistics.service'; + +describe('DashboardStatisticsService', () => { + let service: DashboardStatisticsService; + let httpMock: HttpTestingController; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + DashboardStatisticsService, + provideHttpClient(), + provideHttpClientTesting(), + ], + }); + + service = TestBed.inject(DashboardStatisticsService); + httpMock = TestBed.inject(HttpTestingController); + }); + + afterEach(() => { + httpMock.verify(); + }); + + it('sends the selected institution and period for lower project status requests', () => { + service + .getEuProjectStatuses({ fromYear: 2024, toYear: 2026 }, 'I456') + .subscribe(); + + const request = httpMock.expectOne((req) => { + return req.url === '/api/dashboard/projects/eu/status'; + }); + + expect(request.request.params.get('institution_id')).toBe('I456'); + expect(request.request.params.get('from_year')).toBe('2024'); + expect(request.request.params.get('to_year')).toBe('2026'); + + request.flush({ + institution_id: 'https://openalex.org/I456', + organization_name: 'Selected institution', + ongoing: 1, + upcoming: 0, + completed: 2, + }); + }); + + it('sends only the active institution for a topic treemap request', () => { + service.getTopicTreemap(2024, 2026, 'I789').subscribe(); + + const request = httpMock.expectOne((req) => { + return req.url === '/api/dashboard/topic-heatmap'; + }); + + expect(request.request.params.get('institution_id')).toBe('I789'); + expect(request.request.params.get('from_year')).toBe('2024'); + expect(request.request.params.get('to_year')).toBe('2026'); + + request.flush({ + institution_id: 'https://openalex.org/I789', + organization_name: 'Selected institution', + years: [], + fields: [], + }); + }); + + it('keeps all as the default lower-dashboard institution scope', () => { + service.getBundProjectTopics().subscribe(); + + const request = httpMock.expectOne((req) => { + return req.url === '/api/dashboard/projects/bund/topics'; + }); + + expect(request.request.params.get('institution_id')).toBe('all'); + expect(request.request.params.has('from_year')).toBeFalse(); + expect(request.request.params.has('to_year')).toBeFalse(); + + request.flush({ + institution_id: 'https://openalex.org/I123', + organization_name: 'Root organization', + project_count: 0, + matched_project_count: 0, + topics: [], + }); + }); +}); From bee9b6e8fdcc647c57b62d42fc886b8533798365 Mon Sep 17 00:00:00 2001 From: genja Date: Sat, 15 Aug 2026 23:01:04 +0200 Subject: [PATCH 025/152] added details row for dfg projects --- .../dfg-project-table.component.html | 122 ++++++++- .../dfg-project-table.component.scss | 246 ++++++++++++++++++ .../dfg-project-table.component.ts | 146 ++++++++++- 3 files changed, 504 insertions(+), 10 deletions(-) diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html index 790baa53..ec8f7600 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html @@ -1,6 +1,7 @@ @@ -9,7 +10,9 @@ queryParamPageKey="page" queryParamSizeKey="size" [pageSizeOptions]="[10, 25, 50]" /> - + + {{ element.title_de }} + {{ @@ -42,12 +45,11 @@ + matTooltipPosition="above"> category - {{ - getClassificationFullChain(classification) - }} + + {{ getClassificationFullChain(classification) }} } @empty { - @@ -60,7 +62,115 @@ }