Compare commits

...
Author SHA1 Message Date
farajollahi 7e79e8ed16 fix(dashboard): resolve merge conflicts and sync institution selection
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev This commit looks good
2026-08-26 14:55:16 +02:00
spsaefan 2ca33edaa4 Merge branch 'top10-personen-subtitles' into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-08-25 18:43:50 +02:00
farajollahi a5ae3a4605 clean code and structure dashboard modul
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-08-24 20:01:56 +02:00
spsaefan ad1e789e8e Style top person subtitles
LocationBasedServices/smartguide/pipeline/head This commit looks good
2026-08-22 20:22:06 +02:00
spsaefan 32d1e27fc5 Add top person subtitles 2026-08-22 20:21:47 +02:00
42 changed files with 2263 additions and 1972 deletions
@@ -0,0 +1,30 @@
@if (shouldDisplay()) {
<section class="field-treemap-section">
<header class="field-treemap-header">
<hgroup>
<h2>Field Treemap</h2>
<p>Publikationen Ihrer Organisation nach Field.</p>
</hgroup>
</header>
@if (loading()) {
<div class="field-treemap-loading" role="status" aria-live="polite">
<app-loading
text="Treemap-Daten für den gewählten Zeitraum werden geladen …"
[icon]="loadingIcon"
size="72"
diameter="72" />
</div>
} @else if (error()) {
<p class="statistics-error">
Die Field-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="treemap()"
[selectedNodeId]="selectedNodeId()"
(selectedNodeIdChange)="selectedNodeId.set($event)"
(topicSelect)="openTopic($event)" />
}
</section>
}
@@ -0,0 +1,45 @@
:host {
display: block;
}
.field-treemap-section {
margin-bottom: 2.5rem;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
}
.field-treemap-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
hgroup,
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 820px) {
align-items: flex-start;
flex-direction: column;
}
}
.field-treemap-loading {
display: grid;
min-height: 25rem;
place-items: center;
}
.statistics-error {
color: var(--sg-error);
}
@@ -0,0 +1,61 @@
import { Component, computed, inject, input, model } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ACCOUNT_TREE_ICON } from '../../../../shared/ui/icons';
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
import { TopicTreemapComponent } from '../../../../shared/ui/topic-treemap/topic-treemap.component';
import {
TopicTreemapData,
TopicTreemapTopicSelect,
} from '../../../../shared/ui/topic-treemap/topic-treemap.models';
import { DashboardPeriodMode } from '../../dashboard.models';
import {
TopicWordCloudDialogComponent,
TopicWordCloudDialogData,
} from '../topic-wordcloud-dialog/topic-wordcloud-dialog.component';
@Component({
selector: 'app-dashboard-field-treemap',
imports: [LoadingComponent, TopicTreemapComponent],
templateUrl: './dashboard-field-treemap.component.html',
styleUrl: './dashboard-field-treemap.component.scss',
})
export class DashboardFieldTreemapComponent {
readonly treemap = input<TopicTreemapData>();
readonly loading = input(false);
readonly error = input(false);
readonly selectedNodeId = model<string>();
readonly periodMode = input.required<DashboardPeriodMode>();
readonly fromYear = input.required<number>();
readonly toYear = input.required<number>();
readonly institutionId = input.required<string>();
readonly loadingIcon = ACCOUNT_TREE_ICON;
readonly hasData = computed(() =>
(this.treemap()?.fields ?? []).some(
(field) =>
field.total > 0 || field.values.some((value) => value.count > 0),
),
);
readonly shouldDisplay = computed(
() => this.loading() || this.error() || this.hasData(),
);
private readonly dialog = inject(MatDialog);
openTopic(topic: TopicTreemapTopicSelect): void {
const hasCustomPeriod = this.periodMode() !== 'all_time';
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
TopicWordCloudDialogComponent,
{
width: '85vw',
maxWidth: '92vw',
data: {
...topic,
fromYear: hasCustomPeriod ? this.fromYear() : undefined,
toYear: hasCustomPeriod ? this.toYear() : undefined,
institutionId: this.institutionId(),
},
},
);
}
}
@@ -0,0 +1,53 @@
<section class="dashboard-period-filter" aria-label="Dashboard-Zeitraum">
<app-filter-card>
<div class="dashboard-period-presets">
<button
type="button"
[class.active]="periodMode() === 'all_time'"
(click)="selectPeriodMode('all_time')">
Alle Zeiten
</button>
<button
type="button"
[class.active]="periodMode() === 'last_10_years'"
(click)="selectPeriodMode('last_10_years')">
Letzte 10 Jahre
</button>
<button
type="button"
[class.active]="periodMode() === 'last_5_years'"
(click)="selectPeriodMode('last_5_years')">
Letzte 5 Jahre
</button>
</div>
</app-filter-card>
<div class="dashboard-period-slider">
<app-year-range-slider
[minYear]="minYear()"
[maxYear]="maxYear()"
[startYear]="startYear()"
[endYear]="endYear()"
(startYearChange)="updateStartYear($event)"
(endYearChange)="updateEndYear($event)">
</app-year-range-slider>
</div>
<mat-form-field
class="dashboard-institution-filter"
appearance="outline"
subscriptSizing="dynamic">
<mat-label>Institution</mat-label>
<mat-select
[value]="selectedInstitutionId()"
[disabled]="institutionsLoading() || institutions().length === 0"
(selectionChange)="institutionSelected.emit($event.value)">
<mat-option value="all">Alle Institutionen</mat-option>
@for (institution of institutions(); track institution.id) {
<mat-option [value]="institution.id">
{{ institution.display_name }}
</mat-option>
}
</mat-select>
</mat-form-field>
</section>
@@ -0,0 +1,58 @@
:host {
display: block;
}
.dashboard-period-filter {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.dashboard-period-presets {
display: inline-flex;
overflow: hidden;
flex: 0 0 auto;
border: 1px solid var(--sg-border);
border-radius: 6px;
background: var(--sg-surface);
button {
padding: 0.55rem 0.8rem;
border: 0;
border-right: 1px solid var(--sg-border);
background: transparent;
color: var(--sg-text);
cursor: pointer;
font: inherit;
&.active {
background: var(--sg-blue-highlight);
color: var(--sg-card-bg);
}
}
button:last-child {
border-right: 0;
}
}
.dashboard-period-slider {
width: 280px;
max-width: 100%;
}
.dashboard-institution-filter {
width: 280px;
max-width: 100%;
margin-left: auto;
}
@media (max-width: 720px) {
.dashboard-institution-filter,
.dashboard-period-slider {
width: 100%;
margin-left: 0;
}
}
@@ -0,0 +1,42 @@
import { Component, input, model, output } from '@angular/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component';
import { DashboardInstitution } from '../../dashboard-statistics.service';
import { DashboardPeriodMode } from '../../dashboard.models';
import { FilterCardComponent } from '../../../../shared/ui/filter-card/filter-card.component';
@Component({
selector: 'app-dashboard-filter',
imports: [MatFormFieldModule, MatSelectModule, YearRangeSliderComponent, FilterCardComponent],
templateUrl: './dashboard-filter.component.html',
styleUrl: './dashboard-filter.component.scss',
})
export class DashboardFilterComponent {
readonly periodMode = input.required<DashboardPeriodMode>();
readonly minYear = input.required<number>();
readonly maxYear = input.required<number>();
readonly startYear = model.required<number>();
readonly endYear = model.required<number>();
readonly institutions = input<DashboardInstitution[]>([]);
readonly institutionsLoading = input(false);
readonly selectedInstitutionId = input('all');
readonly periodModeSelected = output<DashboardPeriodMode>();
readonly periodRangeChanged = output<void>();
readonly institutionSelected = output<string>();
selectPeriodMode(mode: DashboardPeriodMode): void {
this.periodModeSelected.emit(mode);
}
updateStartYear(year: number): void {
this.startYear.set(year);
this.periodRangeChanged.emit();
}
updateEndYear(year: number): void {
this.endYear.set(year);
this.periodRangeChanged.emit();
}
}
@@ -0,0 +1,48 @@
<section
class="dashboard-institution-tabs"
aria-label="Institutionen für Analysebereiche">
<div class="dashboard-institution-tab-bar">
<button
type="button"
class="dashboard-institution-tab-arrow"
[class.is-hidden]="!canScrollLeft"
[disabled]="!canScrollLeft"
aria-label="Vorherige Institutionen anzeigen"
(click)="scroll(-1)">
<mat-icon>chevron_left</mat-icon>
</button>
<div
#tabList
class="dashboard-institution-tab-list sg-tab-nav"
role="tablist"
(scroll)="updateScrollState()">
@for (institution of institutions(); track institution.id) {
<button
type="button"
role="tab"
[attr.aria-selected]="selectedInstitutionId() === institution.id"
[class.active]="selectedInstitutionId() === institution.id"
(click)="selectInstitution(institution.id)">
{{ institution.display_name }}
</button>
}
</div>
<button
type="button"
class="dashboard-institution-tab-arrow"
[class.is-hidden]="!canScrollRight"
[disabled]="!canScrollRight"
aria-label="Weitere Institutionen anzeigen"
(click)="scroll(1)">
<mat-icon>chevron_right</mat-icon>
</button>
</div>
@if (error()) {
<p class="statistics-error">
Die Institutionen konnten nicht geladen werden.
</p>
}
</section>
@@ -0,0 +1,115 @@
:host {
display: block;
}
.dashboard-institution-tabs {
margin: -0.25rem 0 2rem;
}
.dashboard-institution-tab-bar {
display: grid;
grid-template-columns: 40px minmax(0, 1fr) 40px;
align-items: stretch;
border-bottom: 1px solid var(--sg-border);
}
.dashboard-institution-tab-arrow {
display: grid;
width: 40px;
height: 48px;
padding: 0;
place-items: center;
border: 0;
background: transparent;
color: var(--sg-text-muted);
cursor: pointer;
transition:
color 0.15s ease,
background-color 0.15s ease,
opacity 0.15s ease;
&:hover:not(:disabled) {
background: var(--sg-option-hover);
color: var(--sg-text);
}
&:focus-visible {
outline-offset: -3px;
}
&:disabled {
cursor: default;
}
&.is-hidden {
visibility: hidden;
opacity: 0;
}
}
.dashboard-institution-tab-list {
display: flex;
overflow-x: auto;
overflow-y: hidden;
border-bottom: 0;
background: transparent;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
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;
text-align: center;
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);
}
}
}
}
.statistics-error {
color: var(--sg-error);
}
@@ -0,0 +1,74 @@
import {
AfterViewInit,
Component,
ElementRef,
HostListener,
OnChanges,
ViewChild,
input,
output,
} from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { DashboardInstitution } from '../../dashboard-statistics.service';
@Component({
selector: 'app-dashboard-institution-tabs',
imports: [MatIconModule],
templateUrl: './dashboard-institution-tabs.component.html',
styleUrl: './dashboard-institution-tabs.component.scss',
})
export class DashboardInstitutionTabsComponent
implements AfterViewInit, OnChanges
{
@ViewChild('tabList') private tabList?: ElementRef<HTMLElement>;
readonly institutions = input<DashboardInstitution[]>([]);
readonly selectedInstitutionId = input('');
readonly error = input(false);
readonly institutionSelected = output<string>();
canScrollLeft = false;
canScrollRight = false;
ngAfterViewInit(): void {
setTimeout(() => this.updateScrollState());
}
ngOnChanges(): void {
setTimeout(() => this.updateScrollState());
}
@HostListener('window:resize')
onWindowResize(): void {
this.updateScrollState();
}
selectInstitution(institutionId: string): void {
if (institutionId !== this.selectedInstitutionId()) {
this.institutionSelected.emit(institutionId);
}
}
scroll(direction: -1 | 1): void {
const tabList = this.tabList?.nativeElement;
if (!tabList) return;
tabList.scrollBy({
left: direction * Math.floor(tabList.clientWidth * 0.75),
behavior: 'smooth',
});
}
updateScrollState(): void {
const tabList = this.tabList?.nativeElement;
if (!tabList) {
this.canScrollLeft = false;
this.canScrollRight = false;
return;
}
const maxScrollLeft = tabList.scrollWidth - tabList.clientWidth;
this.canScrollLeft = tabList.scrollLeft > 1;
this.canScrollRight = tabList.scrollLeft < maxScrollLeft - 1;
}
}
@@ -0,0 +1,45 @@
@if (shouldDisplay()) {
<section class="project-status-section">
<header class="project-status-header">
<div>
<h2>Projektstatus nach Fördergeber</h2>
<p>
Laufende, kommende und abgeschlossene EU-, Bund- und DFG-Projekte
Ihrer Organisation.
</p>
</div>
@if (statusData(); as statuses) {
<div class="project-status-summary">
<span>EU: {{ total(statuses.eu) | number }}</span>
<span>Bund: {{ total(statuses.bund) | number }}</span>
<span>DFG: {{ total(statuses.dfg) | number }}</span>
</div>
}
</header>
@if (loading()) {
<div class="project-status-loading" role="status" aria-live="polite">
<app-loading
text="Projektstatus wird geladen …"
[icon]="loadingIcon"
size="64"
diameter="64" />
</div>
} @else if (allFailed()) {
<p class="statistics-error">
Der Status der EU-, Bund- und DFG-Projekte konnte nicht geladen werden.
</p>
} @else if (statusData(); as statuses) {
@if (failedSources()) {
<p class="statistics-error">
Projektstatusdaten für {{ failedSources() }} konnten nicht geladen
werden. Die übrigen Daten werden weiterhin angezeigt.
</p>
}
<app-eu-project-status-chart
[statuses]="statuses.eu"
[bmbfStatuses]="statuses.bund"
[dfgStatuses]="statuses.dfg" />
}
</section>
}
@@ -0,0 +1,59 @@
:host {
display: block;
}
.project-status-section {
margin-bottom: 2.5rem;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
}
.project-status-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 820px) {
align-items: flex-start;
flex-direction: column;
}
}
.project-status-loading {
display: grid;
min-height: 15rem;
place-items: center;
}
.project-status-summary {
display: flex;
flex: 0 0 auto;
gap: 0.5rem;
span {
padding: 0.35rem 0.65rem;
border-radius: 999px;
background: var(--sg-surface-muted);
color: var(--sg-text-muted);
font-size: 0.9rem;
font-weight: 600;
}
}
.statistics-error {
color: var(--sg-error);
}
@@ -0,0 +1,69 @@
import { DecimalPipe } from '@angular/common';
import { Component, computed, input } from '@angular/core';
import { STACKED_BAR_CHART_ICON } from '../../../../shared/ui/icons';
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
import {
BmbfProjectStatusStatistics,
DfgProjectStatusStatistics,
EuProjectStatusStatistics,
} from '../../dashboard-statistics.service';
import { EuProjectStatusChartComponent } from '../eu-project-status-chart/eu-project-status-chart.component';
@Component({
selector: 'app-dashboard-project-status',
imports: [DecimalPipe, EuProjectStatusChartComponent, LoadingComponent],
templateUrl: './dashboard-project-status.component.html',
styleUrl: './dashboard-project-status.component.scss',
})
export class DashboardProjectStatusComponent {
readonly active = input(false);
readonly euStatuses = input<EuProjectStatusStatistics>();
readonly bundStatuses = input<BmbfProjectStatusStatistics>();
readonly dfgStatuses = input<DfgProjectStatusStatistics>();
readonly euLoading = input(false);
readonly bundLoading = input(false);
readonly dfgLoading = input(false);
readonly euError = input(false);
readonly bundError = input(false);
readonly dfgError = input(false);
readonly loadingIcon = STACKED_BAR_CHART_ICON;
readonly loading = computed(
() => this.euLoading() || this.bundLoading() || this.dfgLoading(),
);
readonly allFailed = computed(
() => this.euError() && this.bundError() && this.dfgError(),
);
readonly failedSources = computed(() =>
[
this.euError() ? 'EU' : undefined,
this.bundError() ? 'Bund' : undefined,
this.dfgError() ? 'DFG' : undefined,
]
.filter((source): source is string => source !== undefined)
.join(' und '),
);
readonly statusData = computed(() => {
const eu = this.euStatuses();
const bund = this.bundStatuses();
const dfg = this.dfgStatuses();
return eu && bund && dfg ? { eu, bund, dfg } : undefined;
});
readonly shouldDisplay = computed(
() =>
this.active() &&
(this.loading() ||
this.euError() ||
this.bundError() ||
this.dfgError() ||
Boolean(this.statusData())),
);
total(statuses: {
ongoing: number;
upcoming: number;
completed: number;
}): number {
return statuses.ongoing + statuses.upcoming + statuses.completed;
}
}
@@ -0,0 +1,18 @@
<a
class="statistics-card"
[routerLink]="disabled() ? null : link()"
[queryParams]="queryParams()"
[class.disabled]="disabled()"
[attr.aria-disabled]="disabled() || null"
[attr.aria-label]="ariaLabel()"
[attr.tabindex]="disabled() ? -1 : null"
[matTooltip]="tooltip()"
matTooltipPosition="above">
<div class="statistics-icon" [class]="'statistics-icon--' + variant()">
<mat-icon>{{ icon() }}</mat-icon>
</div>
<div>
<span>{{ label() }}</span>
<strong>{{ loading() ? '…' : ((value() | number) ?? '–') }}</strong>
</div>
</a>
@@ -0,0 +1,76 @@
:host {
display: block;
}
.statistics-card {
display: flex;
align-items: center;
gap: 1rem;
min-height: 120px;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
box-shadow: var(--sg-shadow-sm);
color: inherit;
text-decoration: none;
transition:
border-color 160ms ease,
box-shadow 160ms ease,
transform 160ms ease;
&:hover {
border-color: var(--sg-card-hover-border);
box-shadow: var(--sg-shadow-md);
transform: translateY(-2px);
}
&:focus-visible {
outline: 3px solid var(--sg-card-hover-border);
outline-offset: 3px;
}
&.disabled {
pointer-events: none;
}
span {
display: block;
color: var(--sg-text-muted);
}
strong {
display: block;
margin: 0.2rem 0;
color: var(--sg-text);
font-size: clamp(1.7rem, 3vw, 2.3rem);
line-height: 1.1;
}
}
.statistics-icon {
display: grid;
flex: 0 0 52px;
width: 52px;
height: 52px;
place-items: center;
border-radius: 12px;
background: var(--sg-primary-soft);
color: var(--sg-blue-highlight);
&--persons {
background: var(--sg-success-soft);
color: var(--sg-success);
}
&--patents {
background: var(--sg-error-soft);
color: var(--sg-error);
}
&--bund-projects,
&--dfg-projects {
background: var(--sg-warning-soft);
color: var(--sg-warning);
}
}
@@ -0,0 +1,32 @@
import { DecimalPipe } from '@angular/common';
import { Component, input } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { Params, RouterLink, UrlTree } from '@angular/router';
export type DashboardStatisticCardVariant =
| 'publications'
| 'persons'
| 'patents'
| 'eu-projects'
| 'bund-projects'
| 'dfg-projects';
@Component({
selector: 'app-dashboard-statistic-card',
imports: [DecimalPipe, MatIconModule, MatTooltipModule, RouterLink],
templateUrl: './dashboard-statistic-card.component.html',
styleUrl: './dashboard-statistic-card.component.scss',
})
export class DashboardStatisticCardComponent {
readonly label = input.required<string>();
readonly value = input<number | null>();
readonly loading = input(false);
readonly icon = input.required<string>();
readonly variant = input.required<DashboardStatisticCardVariant>();
readonly link = input.required<string | readonly unknown[] | UrlTree>();
readonly queryParams = input<Params | null>(null);
readonly ariaLabel = input.required<string>();
readonly tooltip = input.required<string>();
readonly disabled = input(false);
}
@@ -0,0 +1,67 @@
<section class="statistics-grid" aria-label="Kennzahlen">
<app-dashboard-statistic-card
label="Publikationen"
[value]="statistics()?.publications"
[loading]="loading().publications"
[icon]="MENU_BOOK_ICON"
variant="publications"
[link]="['/institution', institutionRouteId(), 'publications']"
[disabled]="!institutionRouteId()"
[ariaLabel]="'Publikationen von ' + organizationName() + ' anzeigen'"
tooltip="Anzahl der Publikationen im ausgewählten Zeitraum" />
<app-dashboard-statistic-card
label="Personen"
[value]="statistics()?.persons"
[loading]="loading().persons"
[icon]="GROUPS_ICON"
variant="persons"
link="/persons"
[queryParams]="personListQueryParams()"
[ariaLabel]="'Personen von ' + organizationName() + ' anzeigen'"
tooltip="Anzahl der Personen im ausgewählten Zeitraum" />
<app-dashboard-statistic-card
label="Patente"
[value]="statistics()?.patents"
[loading]="loading().patents"
[icon]="PATENT_ICON"
variant="patents"
[link]="['/institution', institutionRouteId(), 'patents']"
[disabled]="!institutionRouteId()"
[ariaLabel]="'Patente von ' + organizationName() + ' anzeigen'"
tooltip="Anzahl der Patente im ausgewählten Zeitraum" />
<app-dashboard-statistic-card
label="EU-Projekte"
[value]="statistics()?.eu_projects"
[loading]="loading().eu_projects"
[icon]="PUBLIC_ICON"
variant="eu-projects"
link="/projects"
[queryParams]="{ selected_project_types: 'eu' }"
ariaLabel="EU-Projekte anzeigen"
tooltip="Anzahl der laufenden, abgeschlossenen und kommenden EU-Projekte im ausgewählten Zeitraum" />
<app-dashboard-statistic-card
label="Bund-Projekte"
[value]="statistics()?.bmbf_projects"
[loading]="loading().bmbf_projects"
[icon]="ACCOUNT_BALANCE_ICON"
variant="bund-projects"
link="/projects"
[queryParams]="{ selected_project_types: 'bund' }"
ariaLabel="Bund-Projekte anzeigen"
tooltip="Anzahl der laufenden, abgeschlossenen und kommenden Bund-Projekte im ausgewählten Zeitraum" />
<app-dashboard-statistic-card
label="DFG-Projekte"
[value]="statistics()?.dfg_projects"
[loading]="loading().dfg_projects"
[icon]="SCIENCE_ICON"
variant="dfg-projects"
link="/projects"
[queryParams]="{ selected_project_types: 'dfg' }"
ariaLabel="DFG-Projekte anzeigen"
tooltip="Anzahl der laufenden, abgeschlossenen und kommenden DFG-Projekte im ausgewählten Zeitraum" />
</section>
@@ -0,0 +1,6 @@
.statistics-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
@@ -0,0 +1,76 @@
import { Component, computed, input } from '@angular/core';
import {
ACCOUNT_BALANCE_ICON,
GROUPS_ICON,
MENU_BOOK_ICON,
PATENT_ICON,
PUBLIC_ICON,
SCIENCE_ICON,
} from '../../../../shared/ui/icons';
import { institutionPersonListQueryParamsForPeriod } from '../../../../shared/person-list-query-params';
import {
DashboardInstitution,
DashboardStatistics,
} from '../../dashboard-statistics.service';
import {
DashboardPeriodMode,
DashboardStatisticKey,
} from '../../dashboard.models';
import { DashboardStatisticCardComponent } from '../dashboard-statistic-card/dashboard-statistic-card.component';
@Component({
selector: 'app-dashboard-statistics-grid',
imports: [DashboardStatisticCardComponent],
templateUrl: './dashboard-statistics-grid.component.html',
styleUrl: './dashboard-statistics-grid.component.scss',
})
export class DashboardStatisticsGridComponent {
readonly statistics = input<Partial<DashboardStatistics>>();
readonly loading = input.required<
Readonly<Record<DashboardStatisticKey, boolean>>
>();
readonly institutions = input<DashboardInstitution[]>([]);
readonly selectedInstitutionId = input('all');
readonly periodMode = input.required<DashboardPeriodMode>();
readonly fromYear = input.required<number>();
readonly toYear = input.required<number>();
readonly MENU_BOOK_ICON = MENU_BOOK_ICON;
readonly GROUPS_ICON = GROUPS_ICON;
readonly PATENT_ICON = PATENT_ICON;
readonly PUBLIC_ICON = PUBLIC_ICON;
readonly ACCOUNT_BALANCE_ICON = ACCOUNT_BALANCE_ICON;
readonly SCIENCE_ICON = SCIENCE_ICON;
readonly organizationName = computed(
() => this.statistics()?.organization_name ?? 'Ihre Organisation',
);
readonly institutionRouteId = computed(() => {
const selectedInstitutionId = this.routeableInstitutionId(
this.selectedInstitutionId(),
);
if (selectedInstitutionId) return selectedInstitutionId;
return this.routeableInstitutionId(this.institutions()[0]?.id) ?? '';
});
readonly personListQueryParams = computed(() =>
institutionPersonListQueryParamsForPeriod(
this.institutionRouteId(),
this.organizationName(),
this.periodMode() === 'all_time' ? undefined : this.fromYear(),
this.periodMode() === 'all_time' ? undefined : this.toYear(),
),
);
private routeableInstitutionId(institutionId?: string | null): string | null {
const normalizedInstitutionId = institutionId
?.replace('https://openalex.org/', '')
.trim();
return normalizedInstitutionId && normalizedInstitutionId !== 'all'
? normalizedInstitutionId
: null;
}
}
@@ -0,0 +1,25 @@
@if (shouldDisplay()) {
<section class="top-authors-section">
<header class="top-authors-header">
<hgroup>
<h2>Top 10 Personen</h2>
<p>
Nach Anzahl der Works, DFG-Projekte, Patente und News Ihrer
Organisation.
</p>
</hgroup>
</header>
@if (error()) {
<p class="statistics-error">
Die Autorenstatistiken konnten nicht geladen werden.
</p>
} @else {
<div class="top-authors-grid" [class.loading]="loading()">
@for (dataset of visibleDatasets(); track dataset.title) {
<app-top-author-chart [dataset]="dataset" [loading]="loading()" />
}
</div>
}
</section>
}
@@ -0,0 +1,49 @@
:host {
display: block;
}
.top-authors-section {
margin-bottom: 2.5rem;
}
.top-authors-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
hgroup,
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 720px) {
align-items: flex-start;
flex-direction: column;
}
}
.top-authors-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1rem;
&.loading {
opacity: 0.65;
}
@media (max-width: 900px) {
grid-template-columns: 1fr;
}
}
.statistics-error {
color: var(--sg-error);
}
@@ -0,0 +1,77 @@
import { Component, computed, input } from '@angular/core';
import {
ACCOUNT_TREE_ICON,
ARTICLE_ICON,
DESCRIPTION_ICON,
MENU_BOOK_ICON,
PUBLIC_ICON,
} from '../../../../shared/ui/icons';
import { TopAuthorStatistics } from '../../dashboard-statistics.service';
import {
TopAuthorChartComponent,
TopAuthorDataset,
} from '../top-author-chart/top-author-chart.component';
@Component({
selector: 'app-dashboard-top-authors',
imports: [TopAuthorChartComponent],
templateUrl: './dashboard-top-authors.component.html',
styleUrl: './dashboard-top-authors.component.scss',
})
export class DashboardTopAuthorsComponent {
readonly statistics = input<TopAuthorStatistics>();
readonly loading = input(false);
readonly error = input(false);
readonly datasets = computed<TopAuthorDataset[]>(() => [
{
title: 'Publikationen',
subtitle:
'Top 10 Personen mit Publikationen der ausgewählten Institution. Die Zahl zeigt die Anzahl der Publikationen der jeweiligen Person.',
icon: MENU_BOOK_ICON,
entries: this.statistics()?.works ?? [],
},
{
title: 'EU-Projekte',
subtitle:
'Top 10 Personen, die an EU-Projekten der ausgewählten Institution beteiligt sind. Die Zahl zeigt, an wie vielen EU-Projekten die jeweilige Person beteiligt ist.',
icon: PUBLIC_ICON,
entries: this.statistics()?.eu_projects ?? [],
},
{
title: 'Patente',
subtitle:
'Top 10 Personen mit Zuordnung zu Patenten der ausgewählten Institution. Die Zahl zeigt, wie vielen Patenten die jeweilige Person zugeordnet wurde.',
icon: DESCRIPTION_ICON,
entries: this.statistics()?.patents ?? [],
},
{
title: 'DFG Projekte',
subtitle:
'Top 10 Personen, die an DFG-Projekten der ausgewählten Institution beteiligt sind. Die Zahl zeigt, an wie vielen DFG-Projekten die jeweilige Person beteiligt ist.',
icon: ACCOUNT_TREE_ICON,
entries: this.statistics()?.projects ?? [],
stripAuthorTitle: true,
},
{
title: 'News',
subtitle:
'Top 10 Personen der ausgewählten Institution, die in Nachrichten genannt werden. Die Zahl zeigt, in wie vielen Nachrichten die jeweilige Person vorkommt.',
icon: ARTICLE_ICON,
entries: this.statistics()?.news ?? [],
},
]);
readonly visibleDatasets = computed(() =>
this.loading()
? this.datasets()
: this.datasets().filter((dataset) => dataset.entries.length > 0),
);
readonly shouldDisplay = computed(
() =>
this.loading() ||
this.error() ||
this.datasets().some((dataset) => dataset.entries.length > 0),
);
}
@@ -1,9 +1,9 @@
import { Component, Input, OnChanges, effect, inject } from '@angular/core';
import { EChartsOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
import { ChartThemeService } from '../../../../shared/services/chart-theme.service';
import { DfgProjectTopic } from '../dashboard-statistics.service';
import { DfgProjectTopic } from '../../dashboard-statistics.service';
@Component({
selector: 'app-dfg-topic-donut',
@@ -1,13 +1,13 @@
import { Component, Input, OnChanges, effect, inject } from '@angular/core';
import { EChartsOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
import { ChartThemeService } from '../../../shared/services/chart-theme.service';
import { ChartThemeService } from '../../../../shared/services/chart-theme.service';
import {
BmbfProjectStatusStatistics,
DfgProjectStatusStatistics,
EuProjectStatusStatistics,
} from '../dashboard-statistics.service';
} from '../../dashboard-statistics.service';
@Component({
selector: 'app-eu-project-status-chart',
@@ -0,0 +1,41 @@
@if (shouldDisplay()) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>{{ sourceLabel() }}-Projekt-Topics</h2>
<p>
Gematchte {{ sourceLabel() }}-Projekte nach Field, Subfield und Topic.
Ein Klick auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (projectTopics(); as topics) {
<p class="topic-summary">
{{ topics.matched_project_count | number }} von
{{ topics.project_count | number }} Projekten gematcht
</p>
}
</header>
@if (loading()) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
[text]="sourceLabel() + '-Topics werden geladen …'"
[icon]="loadingIcon"
size="72"
diameter="72" />
</div>
} @else if (error()) {
<p class="statistics-error">
Die {{ sourceLabel() }}-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="treemap()"
[selectedNodeId]="selectedNodeId()"
[countLabel]="sourceLabel() + '-Projekte'"
[showCountInTooltip]="false"
(selectedNodeIdChange)="selectedNodeId.set($event)"
(topicSelect)="openTopic($event)" />
}
</section>
}
@@ -0,0 +1,50 @@
:host {
display: block;
}
.topic-heatmap-section {
margin-bottom: 2.5rem;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
}
.topic-heatmap-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 820px) {
align-items: flex-start;
flex-direction: column;
}
}
.topic-summary {
flex: 0 0 auto;
color: var(--sg-text-muted);
font-weight: 600;
}
.topic-heatmap-loading {
display: grid;
min-height: 25rem;
place-items: center;
}
.statistics-error {
color: var(--sg-error);
}
@@ -0,0 +1,72 @@
import { DecimalPipe } from '@angular/common';
import { Component, computed, inject, input, model } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ACCOUNT_TREE_ICON } from '../../../../shared/ui/icons';
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
import { TopicTreemapComponent } from '../../../../shared/ui/topic-treemap/topic-treemap.component';
import {
TopicTreemapData,
TopicTreemapTopicSelect,
} from '../../../../shared/ui/topic-treemap/topic-treemap.models';
import {
BundProjectTopics,
DfgProjectTopics,
EuProjectTopics,
} from '../../dashboard-statistics.service';
import {
TopicWordCloudDialogComponent,
TopicWordCloudDialogData,
} from '../topic-wordcloud-dialog/topic-wordcloud-dialog.component';
@Component({
selector: 'app-project-topics',
imports: [DecimalPipe, LoadingComponent, TopicTreemapComponent],
templateUrl: './project-topics.component.html',
styleUrl: './project-topics.component.scss',
})
export class ProjectTopicsComponent {
readonly source = input.required<'eu' | 'bund' | 'dfg'>();
readonly projectTopics = input<
EuProjectTopics | BundProjectTopics | DfgProjectTopics
>();
readonly treemap = input<TopicTreemapData>();
readonly loading = input(false);
readonly error = input(false);
readonly selectedNodeId = model<string>();
readonly loadingIcon = ACCOUNT_TREE_ICON;
readonly sourceLabel = computed(() => {
if (this.source() === 'eu') return 'EU';
if (this.source() === 'dfg') return 'DFG';
return 'BUND';
});
readonly shouldDisplay = computed(
() => this.loading() || this.error() || Boolean(this.projectTopics()),
);
private readonly dialog = inject(MatDialog);
openTopic(topic: TopicTreemapTopicSelect): void {
const projectTopic = this.projectTopics()?.topics.find(
(entry) => entry.id === topic.topicId,
);
if (!projectTopic) return;
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
TopicWordCloudDialogComponent,
{
width: '85vw',
maxWidth: '92vw',
data: {
...topic,
source: this.source(),
words: projectTopic.keywords.map((keyword) => ({
id: keyword.name,
name: keyword.name,
count: keyword.project_count,
})),
},
},
);
}
}
@@ -0,0 +1,43 @@
<article class="top-authors-chart">
<h3><mat-icon>{{ dataset().icon }}</mat-icon>{{ dataset().title }}</h3>
<p class="top-authors-chart-subtitle">{{ dataset().subtitle }}</p>
@for (
entry of dataset().entries;
track entry.id || entry.name;
let rank = $index
) {
<div class="author-bar-row">
<span class="author-rank">{{ rank + 1 }}</span>
<div class="author-bar-content">
<div class="author-bar-label">
@if (entry.id) {
<a
class="author-name author-link"
[routerLink]="['/person', entry.id, 'overview']"
[appComponentTooltip]="AuthorTooltipComponent"
[tooltipInputs]="{ authorId: entry.id }"
tooltipMaxWidth="500px"
[title]="authorDisplayName(entry)">
{{ authorDisplayName(entry) }}
</a>
} @else {
<span class="author-name" [title]="authorDisplayName(entry)">
{{ authorDisplayName(entry) }}
</span>
}
<strong>{{ entry.count | number }}</strong>
</div>
<div class="author-bar-track">
<span
class="author-bar-fill"
[style.width.%]="authorBarWidth(entry.count)"></span>
</div>
</div>
</div>
} @empty {
<p class="empty-chart">
{{ loading() ? 'Wird geladen …' : 'Keine Daten vorhanden.' }}
</p>
}
</article>
@@ -0,0 +1,99 @@
:host {
display: block;
}
.top-authors-chart {
height: 100%;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
h3 {
display: flex;
align-items: center;
gap: 0.5rem;
margin: 0;
color: var(--sg-text);
}
}
.top-authors-chart-subtitle {
margin: 0.35rem 0 1rem;
color: var(--sg-text-muted);
font-size: 13px;
line-height: 1.45;
}
.author-bar-row {
display: flex;
align-items: center;
gap: 0.65rem;
margin-top: 0.7rem;
}
.author-rank {
flex: 0 0 1.4rem;
color: var(--sg-text-muted);
font-size: 0.8rem;
text-align: center;
}
.author-bar-content {
min-width: 0;
flex: 1;
}
.author-bar-label {
display: flex;
justify-content: space-between;
gap: 0.75rem;
margin-bottom: 0.25rem;
font-size: 0.85rem;
.author-name {
overflow: hidden;
color: var(--sg-blue-highlight);
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.author-link {
overflow: hidden;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
&:hover {
text-decoration: underline;
}
&:focus-visible {
border-radius: 2px;
outline: 2px solid var(--sg-card-hover-border);
outline-offset: 2px;
}
}
.author-bar-track {
overflow: hidden;
height: 7px;
border-radius: 999px;
background: var(--sg-border);
}
.author-bar-fill {
display: block;
height: 100%;
border-radius: inherit;
background: var(--sg-blue-highlight);
transition: width 220ms ease;
}
.empty-chart {
margin: 2rem 0;
color: var(--sg-text-muted);
text-align: center;
}
@@ -0,0 +1,53 @@
import { DecimalPipe } from '@angular/common';
import { Component, input } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { RouterLink } from '@angular/router';
import { ComponentTooltipDirective } from '../../../../directives/component-tooltip.directive';
import { AppAuthorTooltipComponent } from '../../../../shared/ui/app-author-tooltip/app-author-tooltip.component';
import { TopAuthor } from '../../dashboard-statistics.service';
export interface TopAuthorDataset {
title: string;
subtitle: string;
icon: string;
entries: TopAuthor[];
stripAuthorTitle?: boolean;
}
@Component({
selector: 'app-top-author-chart',
imports: [
DecimalPipe,
MatIconModule,
RouterLink,
ComponentTooltipDirective,
],
templateUrl: './top-author-chart.component.html',
styleUrl: './top-author-chart.component.scss',
})
export class TopAuthorChartComponent {
readonly dataset = input.required<TopAuthorDataset>();
readonly loading = input(false);
readonly AuthorTooltipComponent = AppAuthorTooltipComponent;
authorBarWidth(count: number): number {
const maximum = Math.max(
...this.dataset().entries.map((entry) => entry.count),
1,
);
return (count / maximum) * 100;
}
authorDisplayName(entry: TopAuthor): string {
if (!this.dataset().stripAuthorTitle) return entry.name;
return (
entry.name
.replace(
/^(?:(?:(?:apl\.\s*)?prof(?:essor)?\.?|priv\.-doz\.?|pd|dr\.?)\s+)+/i,
'',
)
.trim() || entry.name
);
}
}
@@ -13,7 +13,7 @@ import { RouterLink } from '@angular/router';
import {
DashboardStatisticsService,
TopicWordCloudWord,
} from '../dashboard-statistics.service';
} from '../../dashboard-statistics.service';
import {
ACCOUNT_TREE_ICON,
CATEGORY_ICON,
@@ -26,7 +26,7 @@ import {
SEARCH_ICON,
SEARCH_OFF_ICON,
TUNE_ICON,
} from '../../../shared/ui/icons';
} from '../../../../shared/ui/icons';
export interface TopicWordCloudDialogData {
topicId: string;
@@ -1,576 +1,91 @@
<div class="dashboard-wrapper">
<section class="dashboard-period-filter" aria-label="Dashboard-Zeitraum">
<div class="dashboard-period-presets">
<button
type="button"
[class.active]="dashboardPeriodMode === 'all_time'"
(click)="setDashboardPeriodMode('all_time')">
Alle Zeiten
</button>
<button
type="button"
[class.active]="dashboardPeriodMode === 'last_10_years'"
(click)="setDashboardPeriodMode('last_10_years')">
Letzte 10 Jahre
</button>
<button
type="button"
[class.active]="dashboardPeriodMode === 'last_5_years'"
(click)="setDashboardPeriodMode('last_5_years')">
Letzte 5 Jahre
</button>
</div>
<div class="dashboard-period-slider">
<app-year-range-slider
[minYear]="topicTreemapMinYear"
[maxYear]="topicTreemapMaxYear"
[(startYear)]="dashboardFromYear"
[(endYear)]="dashboardToYear"
(startYearChange)="onDashboardPeriodRangeChange()"
(endYearChange)="onDashboardPeriodRangeChange()">
</app-year-range-slider>
</div>
<mat-form-field
class="dashboard-institution-filter"
appearance="outline"
subscriptSizing="dynamic">
<mat-label>Institution</mat-label>
<mat-select
[value]="selectedDashboardInstitutionId"
[disabled]="
dashboardInstitutionsLoading || dashboardInstitutions.length === 0
"
(selectionChange)="onDashboardInstitutionChange($event.value)">
<mat-option value="all">Alle Institutionen</mat-option>
@for (institution of dashboardInstitutions; track institution.id) {
<mat-option [value]="institution.id">
{{ institution.display_name }}
</mat-option>
}
</mat-select>
</mat-form-field>
</section>
<app-dashboard-filter
[periodMode]="dashboard.periodMode"
[minYear]="dashboard.minYear"
[maxYear]="dashboard.maxYear"
[(startYear)]="dashboard.fromYear"
[(endYear)]="dashboard.toYear"
[institutions]="dashboard.institutions"
[institutionsLoading]="dashboard.institutionsLoading"
[selectedInstitutionId]="dashboard.selectedInstitutionId"
(periodModeSelected)="setDashboardPeriodMode($event)"
(periodRangeChanged)="onDashboardPeriodRangeChange()"
(institutionSelected)="onDashboardInstitutionChange($event)" />
<section class="statistics-grid" aria-label="Kennzahlen">
<a
class="statistics-card"
[routerLink]="['/institution', institutionRouteId(), 'publications']"
[class.disabled]="!institutionRouteId()"
[attr.aria-disabled]="!institutionRouteId()"
[attr.aria-label]="
'Publikationen von ' + organizationName() + ' anzeigen'
"
matTooltip="Anzahl der Publikationen im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--publications">
<mat-icon>{{ MENU_BOOK_ICON }}</mat-icon>
</div>
<div>
<span>Publikationen</span>
<strong>
{{
isStatisticLoading('publications')
? '…'
: ((statistics?.publications | number) ?? '–')
}}
</strong>
</div>
</a>
<app-dashboard-statistics-grid
[statistics]="dashboard.statistics"
[loading]="dashboard.statisticLoading"
[institutions]="dashboard.institutions"
[selectedInstitutionId]="dashboard.selectedInstitutionId"
[periodMode]="dashboard.periodMode"
[fromYear]="dashboard.fromYear"
[toYear]="dashboard.toYear" />
<a
class="statistics-card"
routerLink="/persons"
[queryParams]="personListQueryParams()"
[attr.aria-label]="'Personen von ' + organizationName() + ' anzeigen'"
matTooltip="Anzahl der Personen im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--persons">
<mat-icon>{{ GROUPS_ICON }}</mat-icon>
</div>
<div>
<span>Personen</span>
<strong>
{{
isStatisticLoading('persons')
? '…'
: ((statistics?.persons | number) ?? '–')
}}
</strong>
</div>
</a>
<a
class="statistics-card"
[routerLink]="['/institution', institutionRouteId(), 'patents']"
[class.disabled]="!institutionRouteId()"
[attr.aria-disabled]="!institutionRouteId()"
[attr.aria-label]="'Patente von ' + organizationName() + ' anzeigen'"
matTooltip="Anzahl der Patente im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--patents">
<mat-icon>{{ patentIcon }}</mat-icon>
</div>
<div>
<span>Patente</span>
<strong>
{{
isStatisticLoading('patents')
? '…'
: ((statistics?.patents | number) ?? '–')
}}
</strong>
</div>
</a>
<a
class="statistics-card"
routerLink="/projects"
[queryParams]="{ selected_project_types: 'eu' }"
aria-label="EU-Projekte anzeigen"
matTooltip="Anzahl der laufenden, abgeschlossenen und kommenden EU-Projekte im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--eu-projects">
<mat-icon>{{ PUBLIC_ICON }}</mat-icon>
</div>
<div>
<span>EU-Projekte</span>
<strong>
{{
isStatisticLoading('eu_projects')
? '…'
: ((statistics?.eu_projects | number) ?? '–')
}}
</strong>
</div>
</a>
<a
class="statistics-card"
routerLink="/projects"
[queryParams]="{ selected_project_types: 'bund' }"
aria-label="Bund-Projekte anzeigen"
matTooltip="Anzahl der laufenden, abgeschlossenen und kommenden Bund-Projekte im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--bund-projects">
<mat-icon>{{ ACCOUNT_BALANCE_ICON }}</mat-icon>
</div>
<div>
<span>Bund-Projekte</span>
<strong>
{{
isStatisticLoading('bmbf_projects')
? '…'
: ((statistics?.bmbf_projects | number) ?? '–')
}}
</strong>
</div>
</a>
<a
class="statistics-card"
routerLink="/projects"
[queryParams]="{ selected_project_types: 'dfg' }"
aria-label="DFG-Projekte anzeigen"
matTooltip="Anzahl der laufenden, abgeschlossenen und kommenden DFG-Projekte im ausgewählten Zeitraum"
matTooltipPosition="above">
<div class="statistics-icon statistics-icon--dfg-projects">
<mat-icon>{{ SCIENCE_ICON }}</mat-icon>
</div>
<div>
<span>DFG-Projekte</span>
<strong>
{{
isStatisticLoading('dfg_projects')
? '…'
: ((statistics?.dfg_projects | number) ?? '–')
}}
</strong>
</div>
</a>
</section>
@if (statisticsError) {
@if (dashboard.statisticsError) {
<p class="statistics-error">Die Kennzahlen konnten nicht geladen werden.</p>
}
<section
class="dashboard-institution-tabs"
aria-label="Institutionen für Analysebereiche">
<h2>Institution auswählen</h2>
<div class="dashboard-institution-tab-bar">
<button
type="button"
class="dashboard-institution-tab-arrow"
[class.is-hidden]="!canScrollAnalyticalInstitutionTabsLeft"
[disabled]="!canScrollAnalyticalInstitutionTabsLeft"
aria-label="Vorherige Institutionen anzeigen"
(click)="scrollAnalyticalInstitutionTabs(-1)">
<mat-icon>{{ CHEVRON_LEFT_ICON }}</mat-icon>
</button>
<div
#analyticalInstitutionTabList
class="dashboard-institution-tab-list sg-tab-nav"
role="tablist"
(scroll)="updateAnalyticalInstitutionTabScrollState()">
@for (institution of dashboardInstitutions; track institution.id) {
<button
type="button"
role="tab"
[attr.aria-selected]="
selectedAnalyticalInstitutionId === institution.id
"
[class.active]="selectedAnalyticalInstitutionId === institution.id"
(click)="onAnalyticalInstitutionChange(institution.id)">
{{ institution.display_name }}
</button>
}
</div>
<button
type="button"
class="dashboard-institution-tab-arrow"
[class.is-hidden]="!canScrollAnalyticalInstitutionTabsRight"
[disabled]="!canScrollAnalyticalInstitutionTabsRight"
aria-label="Weitere Institutionen anzeigen"
(click)="scrollAnalyticalInstitutionTabs(1)">
<mat-icon>{{ CHEVRON_RIGHT_ICON }}</mat-icon>
</button>
</div>
@if (dashboardInstitutionsError) {
<p class="statistics-error">
Die Institutionen konnten nicht geladen werden.
</p>
}
</section>
<app-dashboard-institution-tabs
[institutions]="dashboard.institutions"
[selectedInstitutionId]="selectedAnalyticalInstitutionId"
[error]="dashboard.institutionsError"
(institutionSelected)="onAnalyticalInstitutionChange($event)" />
<app-dashboard-project-status
[active]="!!selectedAnalyticalInstitutionId"
[euStatuses]="dashboard.euProjectStatuses"
[bundStatuses]="dashboard.bmbfProjectStatuses"
[dfgStatuses]="dashboard.dfgProjectStatuses"
[euLoading]="dashboard.euProjectStatusesLoading"
[bundLoading]="dashboard.bmbfProjectStatusesLoading"
[dfgLoading]="dashboard.dfgProjectStatusesLoading"
[euError]="dashboard.euProjectStatusesError"
[bundError]="dashboard.bmbfProjectStatusesError"
[dfgError]="dashboard.dfgProjectStatusesError" />
@if (selectedAnalyticalInstitutionId) {
@if (
euProjectStatusesLoading ||
bmbfProjectStatusesLoading ||
dfgProjectStatusesLoading ||
euProjectStatusesError ||
bmbfProjectStatusesError ||
dfgProjectStatusesError ||
(euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses)
) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>Projektstatus nach Fördergeber</h2>
<p>
Laufende, kommende und abgeschlossene EU-, Bund- und DFG-Projekte
Ihrer Organisation.
</p>
</div>
@if (euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses) {
<div class="project-status-summary">
<span>
EU:
{{
euProjectStatuses.ongoing +
euProjectStatuses.upcoming +
euProjectStatuses.completed | number
}}
</span>
<span>
Bund:
{{
bmbfProjectStatuses.ongoing +
bmbfProjectStatuses.upcoming +
bmbfProjectStatuses.completed | number
}}
</span>
<span>
DFG:
{{
dfgProjectStatuses.ongoing +
dfgProjectStatuses.upcoming +
dfgProjectStatuses.completed | number
}}
</span>
</div>
}
</header>
@if (
euProjectStatusesLoading ||
bmbfProjectStatusesLoading ||
dfgProjectStatusesLoading
) {
<div class="project-status-loading" role="status" aria-live="polite">
<app-loading
text="Projektstatus wird geladen …"
[icon]="STACKED_BAR_CHART_ICON"
size="64"
diameter="64"></app-loading>
</div>
} @else if (
euProjectStatusesError &&
bmbfProjectStatusesError &&
dfgProjectStatusesError
) {
<p class="statistics-error">
Der Status der EU-, Bund- und DFG-Projekte konnte nicht geladen
werden.
</p>
} @else if (
euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses
) {
@if (
euProjectStatusesError ||
bmbfProjectStatusesError ||
dfgProjectStatusesError
) {
<p class="statistics-error">
Projektstatusdaten für {{ failedProjectStatusSources() }} konnten
nicht geladen werden. Die übrigen Daten werden weiterhin
angezeigt.
</p>
}
<app-eu-project-status-chart
[statuses]="euProjectStatuses"
[bmbfStatuses]="bmbfProjectStatuses"
[dfgStatuses]="dfgProjectStatuses"></app-eu-project-status-chart>
}
</section>
}
<app-dashboard-field-treemap
[treemap]="dashboard.topicTreemap"
[loading]="dashboard.topicTreemapLoading"
[error]="dashboard.topicTreemapError"
[(selectedNodeId)]="selectedTopicTreemapNode"
[periodMode]="dashboard.periodMode"
[fromYear]="dashboard.fromYear"
[toYear]="dashboard.toYear"
[institutionId]="selectedAnalyticalInstitutionId"
(selectedNodeIdChange)="onTopicTreemapNodeChange()" />
@if (topicTreemapLoading || topicTreemapError || hasTopicTreemapData()) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>Field Treemap</h2>
<p>Publikationen Ihrer Organisation nach Field.</p>
</div>
</header>
<app-project-topics
source="dfg"
[projectTopics]="dashboard.dfgProjectTopics"
[treemap]="dashboard.dfgTopicTreemap"
[loading]="dashboard.dfgTopicsLoading"
[error]="dashboard.dfgTopicsError"
[(selectedNodeId)]="selectedDfgTopicTreemapNode"
(selectedNodeIdChange)="onDfgTopicTreemapNodeChange()" />
@if (topicTreemapLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="Treemap-Daten für den gewählten Zeitraum werden geladen …"
[icon]="ACCOUNT_TREE_ICON"
size="72"
diameter="72"></app-loading>
</div>
} @else if (topicTreemapError) {
<p class="statistics-error">
Die Field-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="topicTreemap"
[selectedNodeId]="selectedTopicTreemapNode"
(selectedNodeIdChange)="onTopicTreemapNodeChange($event)"
(topicSelect)="onTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
<app-project-topics
source="eu"
[projectTopics]="dashboard.euProjectTopics"
[treemap]="dashboard.euTopicTreemap"
[loading]="dashboard.euTopicsLoading"
[error]="dashboard.euTopicsError"
[(selectedNodeId)]="selectedEuTopicTreemapNode"
(selectedNodeIdChange)="onEuTopicTreemapNodeChange()" />
@if (dfgTopicsLoading || dfgTopicsError || dfgProjectTopics) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>DFG-Projekt-Topics</h2>
<p>
Gematchte DFG-Projekte nach Field, Subfield und Topic. Ein Klick
auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (dfgProjectTopics) {
<p class="dfg-topic-summary">
{{ dfgProjectTopics.matched_project_count | number }} von
{{ dfgProjectTopics.project_count | number }} Projekten gematcht
</p>
}
</header>
<app-project-topics
source="bund"
[projectTopics]="dashboard.bundProjectTopics"
[treemap]="dashboard.bundTopicTreemap"
[loading]="dashboard.bundTopicsLoading"
[error]="dashboard.bundTopicsError"
[(selectedNodeId)]="selectedBundTopicTreemapNode"
(selectedNodeIdChange)="onBundTopicTreemapNodeChange()" />
@if (dfgTopicsLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="DFG-Topics werden geladen …"
[icon]="ACCOUNT_TREE_ICON"
size="72"
diameter="72"></app-loading>
</div>
} @else if (dfgTopicsError) {
<p class="statistics-error">
Die DFG-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="dfgTopicTreemap"
[selectedNodeId]="selectedDfgTopicTreemapNode"
countLabel="DFG-Projekte"
[showCountInTooltip]="false"
(selectedNodeIdChange)="onDfgTopicTreemapNodeChange($event)"
(topicSelect)="onDfgTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
@if (euTopicsLoading || euTopicsError || euProjectTopics) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>EU-Projekt-Topics</h2>
<p>
Gematchte EU-Projekte nach Field, Subfield und Topic. Ein Klick
auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (euProjectTopics) {
<p class="dfg-topic-summary">
{{ euProjectTopics.matched_project_count | number }} von
{{ euProjectTopics.project_count | number }} Projekten gematcht
</p>
}
</header>
@if (euTopicsLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="EU-Topics werden geladen …"
[icon]="ACCOUNT_TREE_ICON"
size="72"
diameter="72"></app-loading>
</div>
} @else if (euTopicsError) {
<p class="statistics-error">
Die EU-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="euTopicTreemap"
[selectedNodeId]="selectedEuTopicTreemapNode"
countLabel="EU-Projekte"
[showCountInTooltip]="false"
(selectedNodeIdChange)="onEuTopicTreemapNodeChange($event)"
(topicSelect)="onEuTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
@if (bundTopicsLoading || bundTopicsError || bundProjectTopics) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>BUND-Projekt-Topics</h2>
<p>
Gematchte BUND-Projekte nach Field, Subfield und Topic. Ein Klick
auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (bundProjectTopics) {
<p class="dfg-topic-summary">
{{ bundProjectTopics.matched_project_count | number }} von
{{ bundProjectTopics.project_count | number }} Projekten gematcht
</p>
}
</header>
@if (bundTopicsLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="BUND-Topics werden geladen …"
[icon]="ACCOUNT_TREE_ICON"
size="72"
diameter="72"></app-loading>
</div>
} @else if (bundTopicsError) {
<p class="statistics-error">
Die BUND-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="bundTopicTreemap"
[selectedNodeId]="selectedBundTopicTreemapNode"
countLabel="BUND-Projekte"
[showCountInTooltip]="false"
(selectedNodeIdChange)="onBundTopicTreemapNodeChange($event)"
(topicSelect)="onBundTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
@if (topAuthorsLoading || topAuthorsError || hasTopAuthorData()) {
<section class="top-authors-section">
<header class="top-authors-header">
<div>
<h2>Top 10 Personen</h2>
<p>
Nach Anzahl der Works, DFG-Projekte, Patente und News Ihrer
Organisation.
</p>
</div>
</header>
@if (topAuthorsError) {
<p class="statistics-error">
Die Autorenstatistiken konnten nicht geladen werden.
</p>
} @else {
<div class="top-authors-grid" [class.loading]="topAuthorsLoading">
@for (dataset of visibleTopAuthorDatasets(); track dataset.title) {
<article class="top-authors-chart">
<h3>
<mat-icon>{{ dataset.icon }}</mat-icon
>{{ dataset.title }}
</h3>
@for (
entry of dataset.entries;
track entry.id || entry.name;
let rank = $index
) {
<div class="author-bar-row">
<span class="author-rank">{{ rank + 1 }}</span>
<div class="author-bar-content">
<div class="author-bar-label">
@if (entry.id) {
<a
class="author-name author-link"
[routerLink]="authorLink(dataset, entry)"
[queryParams]="authorQueryParams(dataset, entry)"
[appComponentTooltip]="AuthorTooltipComponent"
[tooltipInputs]="{ authorId: entry.id }"
[tooltipMaxWidth]="'500px'"
[title]="authorDisplayName(dataset, entry)">
{{ authorDisplayName(dataset, entry) }}
</a>
} @else {
<span
class="author-name"
[title]="authorDisplayName(dataset, entry)">
{{ authorDisplayName(dataset, entry) }}
</span>
}
<strong>{{ entry.count | number }}</strong>
</div>
<div class="author-bar-track">
<span
class="author-bar-fill"
[style.width.%]="
authorBarWidth(dataset.entries, entry.count)
"></span>
</div>
</div>
</div>
} @empty {
<p class="empty-chart">
{{
topAuthorsLoading
? 'Wird geladen …'
: 'Keine Daten vorhanden.'
}}
</p>
}
</article>
}
</div>
}
</section>
}
<app-dashboard-top-authors
[statistics]="dashboard.topAuthors"
[loading]="dashboard.topAuthorsLoading"
[error]="dashboard.topAuthorsError" />
}
</div>
@@ -2,460 +2,9 @@
padding: 2rem;
color: var(--sg-text);
.dashboard-period-filter {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.dashboard-period-presets {
display: inline-flex;
overflow: hidden;
flex: 0 0 auto;
border: 1px solid var(--sg-border);
border-radius: 6px;
background: var(--sg-surface);
button {
padding: 0.55rem 0.8rem;
border: 0;
border-right: 1px solid var(--sg-border);
background: transparent;
color: var(--sg-text);
cursor: pointer;
font: inherit;
&.active {
background: var(--sg-blue-highlight);
color: var(--sg-card-bg);
}
}
button:last-child {
border-right: 0;
}
}
.dashboard-period-slider {
width: 280px;
max-width: 100%;
}
.dashboard-institution-filter {
width: 280px;
max-width: 100%;
margin-left: auto;
}
@media (max-width: 720px) {
.dashboard-institution-filter,
.dashboard-period-slider {
width: 100%;
margin-left: 0;
}
}
.statistics-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.statistics-card {
display: flex;
align-items: center;
gap: 1rem;
min-height: 120px;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
box-shadow: var(--sg-shadow-sm);
color: inherit;
text-decoration: none;
transition:
border-color 160ms ease,
box-shadow 160ms ease,
transform 160ms ease;
&:hover {
border-color: var(--sg-card-hover-border);
box-shadow: var(--sg-shadow-md);
transform: translateY(-2px);
}
&:focus-visible {
outline: 3px solid var(--sg-card-hover-border);
outline-offset: 3px;
}
&.disabled {
pointer-events: none;
}
span,
small {
display: block;
color: var(--sg-text-muted);
}
strong {
display: block;
margin: 0.2rem 0;
color: var(--sg-text);
font-size: clamp(1.7rem, 3vw, 2.3rem);
line-height: 1.1;
}
}
.statistics-icon {
display: grid;
flex: 0 0 52px;
width: 52px;
height: 52px;
place-items: center;
border-radius: 12px;
background: var(--sg-primary-soft);
color: var(--sg-blue-highlight);
&--persons {
background: var(--sg-success-soft);
color: var(--sg-success);
}
&--patents {
background: var(--sg-error-soft);
color: var(--sg-error);
}
&--eu-projects {
background: var(--sg-primary-soft);
color: var(--sg-blue-highlight);
}
&--bund-projects {
background: var(--sg-warning-soft);
color: var(--sg-warning);
}
&--dfg-projects {
background: var(--sg-warning-soft);
color: var(--sg-warning);
}
}
.statistics-error {
margin: -1rem 0 2rem;
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-bar {
display: grid;
grid-template-columns: 40px minmax(0, 1fr) 40px;
align-items: stretch;
border-bottom: 1px solid var(--sg-border);
}
.dashboard-institution-tab-arrow {
display: grid;
width: 40px;
height: 48px;
padding: 0;
place-items: center;
border: 0;
background: transparent;
color: var(--sg-text-muted);
cursor: pointer;
transition:
color 0.15s ease,
background-color 0.15s ease,
opacity 0.15s ease;
&:hover:not(:disabled) {
background: var(--sg-option-hover);
color: var(--sg-text);
}
&:focus-visible {
outline-offset: -3px;
}
&:disabled {
cursor: default;
}
&.is-hidden {
visibility: hidden;
opacity: 0;
}
}
.dashboard-institution-tab-list {
display: flex;
overflow-x: auto;
overflow-y: hidden;
border-bottom: 0;
background: transparent;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
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;
text-align: center;
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;
}
.topic-heatmap-section {
margin-bottom: 2.5rem;
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
}
.topic-heatmap-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 820px) {
align-items: flex-start;
flex-direction: column;
}
}
.topic-heatmap-loading {
min-height: 25rem;
display: grid;
place-items: center;
}
.project-status-loading {
min-height: 15rem;
display: grid;
place-items: center;
}
.project-status-summary {
display: flex;
flex: 0 0 auto;
gap: 0.5rem;
span {
padding: 0.35rem 0.65rem;
border-radius: 999px;
background: var(--sg-surface-muted);
color: var(--sg-text-muted);
font-size: 0.9rem;
font-weight: 600;
}
}
.dfg-topic-summary {
flex: 0 0 auto;
color: var(--sg-text-muted);
font-weight: 600;
}
.top-authors-header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
h2,
p {
margin: 0;
}
p {
margin-top: 0.35rem;
color: var(--sg-text-muted);
}
@media (max-width: 720px) {
align-items: flex-start;
flex-direction: column;
}
}
.top-authors-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1rem;
&.loading {
opacity: 0.65;
}
@media (max-width: 900px) {
grid-template-columns: 1fr;
}
}
.top-authors-chart {
padding: 1.25rem;
border: 1px solid var(--sg-border);
border-radius: 12px;
background: var(--sg-card-bg);
h3 {
display: flex;
align-items: center;
gap: 0.5rem;
margin: 0 0 1rem;
color: var(--sg-text);
}
}
.author-bar-row {
display: flex;
align-items: center;
gap: 0.65rem;
margin-top: 0.7rem;
}
.author-rank {
flex: 0 0 1.4rem;
color: var(--sg-text-muted);
font-size: 0.8rem;
text-align: center;
}
.author-bar-content {
min-width: 0;
flex: 1;
}
.author-bar-label {
display: flex;
justify-content: space-between;
gap: 0.75rem;
margin-bottom: 0.25rem;
font-size: 0.85rem;
.author-name {
overflow: hidden;
color: var(--sg-blue-highlight);
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.author-link {
overflow: hidden;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
&:hover {
text-decoration: underline;
}
&:focus-visible {
border-radius: 2px;
outline: 2px solid var(--sg-card-hover-border);
outline-offset: 2px;
}
}
.author-bar-track {
overflow: hidden;
height: 7px;
border-radius: 999px;
background: var(--sg-border);
}
.author-bar-fill {
display: block;
height: 100%;
border-radius: inherit;
background: var(--sg-blue-highlight);
transition: width 220ms ease;
}
.empty-chart {
margin: 2rem 0;
color: var(--sg-text-muted);
text-align: center;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,13 @@
export type DashboardPeriodMode =
| 'all_time'
| 'last_10_years'
| 'last_5_years'
| 'custom';
export type DashboardStatisticKey =
| 'publications'
| 'persons'
| 'patents'
| 'eu_projects'
| 'bmbf_projects'
| 'dfg_projects';
@@ -0,0 +1,64 @@
import { TopicTreemapData } from '../../../shared/ui/topic-treemap/topic-treemap.models';
import {
BundProjectTopics,
DfgProjectTopic,
DfgProjectTopics,
EuProjectTopics,
} from '../dashboard-statistics.service';
type ProjectTopics = DfgProjectTopics | EuProjectTopics | BundProjectTopics;
export function mapProjectTopicsToTreemap(
projectTopics: ProjectTopics,
): TopicTreemapData {
const fields = new Map<
string,
Map<string, { topics: DfgProjectTopic[] }>
>();
for (const topic of projectTopics.topics) {
const fieldName = topic.field?.trim() || 'Ohne Field';
const subfieldName = topic.subfield?.trim() || 'Ohne Subfield';
const subfields =
fields.get(fieldName) ??
new Map<string, { topics: DfgProjectTopic[] }>();
const subfield = subfields.get(subfieldName) ?? { topics: [] };
subfield.topics.push(topic);
subfields.set(subfieldName, subfield);
fields.set(fieldName, subfields);
}
return {
institution_id: projectTopics.institution_id,
organization_name: projectTopics.organization_name,
years: [],
fields: [...fields.entries()].map(([fieldName, subfields]) => {
const mappedSubfields = [...subfields.entries()].map(
([subfieldName, group]) => ({
id: `${fieldName}::${subfieldName}`,
name: subfieldName,
total:
group.topics[0]?.subfield_project_count ??
group.topics.reduce((sum, topic) => sum + topic.project_count, 0),
values: [],
topics: group.topics.map((topic) => ({
id: topic.id,
name: topic.name,
total: topic.project_count,
values: [],
})),
}),
);
return {
id: fieldName,
name: fieldName,
total:
[...subfields.values()][0]?.topics[0]?.field_project_count ??
mappedSubfields.reduce((sum, subfield) => sum + subfield.total, 0),
values: [],
subfields: mappedSubfields,
};
}),
};
}
@@ -0,0 +1,567 @@
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable, finalize } from 'rxjs';
import { TopicTreemapData } from '../../../shared/ui/topic-treemap/topic-treemap.models';
import {
DashboardPeriodMode,
DashboardStatisticKey,
} from '../dashboard.models';
import {
BmbfProjectStatusStatistics,
BundProjectTopics,
DashboardInstitution,
DashboardPeriodBounds,
DashboardStatisticValue,
DashboardStatistics,
DashboardStatisticsService,
DfgProjectStatusStatistics,
DfgProjectTopics,
EuProjectStatusStatistics,
EuProjectTopics,
TopAuthorStatistics,
} from '../dashboard-statistics.service';
import { mapProjectTopicsToTreemap } from './dashboard-topic-treemap.mapper';
@Injectable()
export class DashboardFacade {
readonly minYear = 1900;
readonly maxYear = new Date().getFullYear();
periodMode: DashboardPeriodMode = 'all_time';
fromYear = this.minYear;
toYear = this.maxYear;
institutions: DashboardInstitution[] = [];
selectedInstitutionId = 'all';
institutionsLoading = false;
institutionsError = false;
statistics?: Partial<DashboardStatistics>;
statisticsLoading = false;
statisticsError = false;
statisticLoading: Record<DashboardStatisticKey, boolean> = {
publications: false,
persons: false,
patents: false,
eu_projects: false,
bmbf_projects: false,
dfg_projects: false,
};
statisticErrors: Record<DashboardStatisticKey, boolean> = {
publications: false,
persons: false,
patents: false,
eu_projects: false,
bmbf_projects: false,
dfg_projects: false,
};
dfgProjectTopics?: DfgProjectTopics;
dfgTopicTreemap?: TopicTreemapData;
dfgTopicsLoading = false;
dfgTopicsError = false;
euProjectTopics?: EuProjectTopics;
euTopicTreemap?: TopicTreemapData;
euTopicsLoading = false;
euTopicsError = false;
bundProjectTopics?: BundProjectTopics;
bundTopicTreemap?: TopicTreemapData;
bundTopicsLoading = false;
bundTopicsError = false;
topAuthors?: TopAuthorStatistics;
topAuthorsLoading = false;
topAuthorsError = false;
topicTreemap?: TopicTreemapData;
topicTreemapLoading = false;
topicTreemapError = false;
euProjectStatuses?: EuProjectStatusStatistics;
euProjectStatusesLoading = false;
euProjectStatusesError = false;
bmbfProjectStatuses?: BmbfProjectStatusStatistics;
bmbfProjectStatusesLoading = false;
bmbfProjectStatusesError = false;
dfgProjectStatuses?: DfgProjectStatusStatistics;
dfgProjectStatusesLoading = false;
dfgProjectStatusesError = false;
private pendingStatisticRequests = 0;
private projectTopicsRequestId = 0;
private analyticalRequestId = 0;
constructor(
private readonly statisticsService: DashboardStatisticsService,
private readonly route: ActivatedRoute,
) {}
initialize(onInstitutionRestored: (institutionId: string) => void): void {
this.restorePeriodState();
this.loadStatistics();
this.loadInstitutions(onInstitutionRestored);
}
setPeriodMode(mode: DashboardPeriodMode): boolean {
if (mode === this.periodMode) return false;
this.periodMode = mode;
this.applyPresetPeriod();
return true;
}
setCustomPeriod(): void {
this.periodMode = 'custom';
}
selectInstitution(institutionId: string): void {
this.selectedInstitutionId = institutionId;
this.loadStatistics();
}
periodBounds(): DashboardPeriodBounds {
return this.periodMode === 'all_time'
? {}
: { fromYear: this.fromYear, toYear: this.toYear };
}
loadStatistics(): void {
this.statisticsError = false;
const period = this.periodBounds();
const institutionId = this.selectedInstitutionId;
this.loadStatistic(
'publications',
this.statisticsService.getPublicationCount(period, institutionId),
);
this.loadStatistic(
'persons',
this.statisticsService.getPersonCount(period, institutionId),
);
this.loadStatistic(
'patents',
this.statisticsService.getPatentCount(period, institutionId),
);
this.loadStatistic(
'eu_projects',
this.statisticsService.getEuProjectCount(period, institutionId),
);
this.loadStatistic(
'bmbf_projects',
this.statisticsService.getBmbfProjectCount(period, institutionId),
);
this.loadStatistic(
'dfg_projects',
this.statisticsService.getDfgProjectCount(period, institutionId),
);
}
loadProjectTopics(
period: DashboardPeriodBounds,
institutionId: string,
): void {
const requestId = ++this.projectTopicsRequestId;
this.loadDfgProjectTopics(period, institutionId, requestId);
this.loadEuProjectTopics(period, institutionId, requestId);
this.loadBundProjectTopics(period, institutionId, requestId);
}
invalidateProjectTopics(): void {
this.projectTopicsRequestId += 1;
this.dfgTopicsLoading = false;
this.euTopicsLoading = false;
this.bundTopicsLoading = false;
}
loadAnalyticalData(institutionId: string): void {
if (!institutionId) return;
const requestId = ++this.analyticalRequestId;
const period = this.periodBounds();
this.euProjectStatuses = undefined;
this.bmbfProjectStatuses = undefined;
this.dfgProjectStatuses = undefined;
this.loadTopAuthors(period, institutionId, requestId);
this.loadTopicTreemap(period, institutionId, requestId);
this.loadProjectTopics(period, institutionId);
this.loadEuProjectStatuses(period, institutionId, requestId);
this.loadBmbfProjectStatuses(period, institutionId, requestId);
this.loadDfgProjectStatuses(period, institutionId, requestId);
}
invalidateAnalyticalData(): void {
this.analyticalRequestId += 1;
this.invalidateProjectTopics();
this.topAuthorsLoading = false;
this.topicTreemapLoading = false;
this.euProjectStatusesLoading = false;
this.bmbfProjectStatusesLoading = false;
this.dfgProjectStatusesLoading = false;
}
private loadInstitutions(
onInstitutionRestored: (institutionId: string) => void,
): void {
this.institutionsLoading = true;
this.institutionsError = false;
this.statisticsService
.getInstitutions()
.pipe(finalize(() => (this.institutionsLoading = false)))
.subscribe({
next: (institutions) => {
this.institutions = institutions;
const requestedInstitution =
this.route.snapshot.queryParamMap.get('institution') ?? 'all';
const restoredInstitution = institutions.some(
(institution) => institution.id === requestedInstitution,
)
? requestedInstitution
: 'all';
if (restoredInstitution !== this.selectedInstitutionId) {
this.selectedInstitutionId = restoredInstitution;
this.loadStatistics();
}
onInstitutionRestored(
restoredInstitution === 'all' ? '' : restoredInstitution,
);
},
error: () => {
this.institutions = [];
this.institutionsError = true;
},
});
}
private loadDfgProjectTopics(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.dfgTopicsLoading = true;
this.dfgTopicsError = false;
this.statisticsService
.getDfgProjectTopics(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.projectTopicsRequestId) {
this.dfgTopicsLoading = false;
}
}),
)
.subscribe({
next: (topics) => {
if (requestId !== this.projectTopicsRequestId) return;
this.dfgProjectTopics = topics;
this.dfgTopicTreemap = mapProjectTopicsToTreemap(topics);
},
error: () => {
if (requestId === this.projectTopicsRequestId) {
this.dfgTopicsError = true;
}
},
});
}
private loadEuProjectTopics(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.euTopicsLoading = true;
this.euTopicsError = false;
this.statisticsService
.getEuProjectTopics(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.projectTopicsRequestId) {
this.euTopicsLoading = false;
}
}),
)
.subscribe({
next: (topics) => {
if (requestId !== this.projectTopicsRequestId) return;
this.euProjectTopics = topics;
this.euTopicTreemap = mapProjectTopicsToTreemap(topics);
},
error: () => {
if (requestId === this.projectTopicsRequestId) {
this.euTopicsError = true;
}
},
});
}
private loadBundProjectTopics(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.bundTopicsLoading = true;
this.bundTopicsError = false;
this.statisticsService
.getBundProjectTopics(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.projectTopicsRequestId) {
this.bundTopicsLoading = false;
}
}),
)
.subscribe({
next: (topics) => {
if (requestId !== this.projectTopicsRequestId) return;
this.bundProjectTopics = topics;
this.bundTopicTreemap = mapProjectTopicsToTreemap(topics);
},
error: () => {
if (requestId === this.projectTopicsRequestId) {
this.bundTopicsError = true;
}
},
});
}
private loadTopAuthors(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.topAuthorsLoading = true;
this.topAuthorsError = false;
this.statisticsService
.getTopAuthors(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.analyticalRequestId) {
this.topAuthorsLoading = false;
}
}),
)
.subscribe({
next: (statistics) => {
if (requestId === this.analyticalRequestId) {
this.topAuthors = statistics;
}
},
error: () => {
if (requestId === this.analyticalRequestId) {
this.topAuthorsError = true;
}
},
});
}
private loadTopicTreemap(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
if (this.fromYear > this.toYear) {
this.topicTreemapLoading = false;
this.topicTreemapError = true;
return;
}
this.topicTreemapLoading = true;
this.topicTreemapError = false;
this.statisticsService
.getTopicTreemap(period.fromYear, period.toYear, institutionId)
.pipe(
finalize(() => {
if (requestId === this.analyticalRequestId) {
this.topicTreemapLoading = false;
}
}),
)
.subscribe({
next: (treemap) => {
if (requestId === this.analyticalRequestId) {
this.topicTreemap = treemap;
}
},
error: () => {
if (requestId === this.analyticalRequestId) {
this.topicTreemapError = true;
}
},
});
}
private loadEuProjectStatuses(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.euProjectStatusesLoading = true;
this.euProjectStatusesError = false;
this.statisticsService
.getEuProjectStatuses(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.analyticalRequestId) {
this.euProjectStatusesLoading = false;
}
}),
)
.subscribe({
next: (statuses) => {
if (requestId === this.analyticalRequestId) {
this.euProjectStatuses = statuses;
}
},
error: () => {
if (requestId === this.analyticalRequestId) {
this.euProjectStatusesError = true;
this.euProjectStatuses = this.emptyProjectStatuses(institutionId);
}
},
});
}
private loadBmbfProjectStatuses(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.bmbfProjectStatusesLoading = true;
this.bmbfProjectStatusesError = false;
this.statisticsService
.getBmbfProjectStatuses(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.analyticalRequestId) {
this.bmbfProjectStatusesLoading = false;
}
}),
)
.subscribe({
next: (statuses) => {
if (requestId === this.analyticalRequestId) {
this.bmbfProjectStatuses = statuses;
}
},
error: () => {
if (requestId === this.analyticalRequestId) {
this.bmbfProjectStatusesError = true;
this.bmbfProjectStatuses = this.emptyProjectStatuses(institutionId);
}
},
});
}
private loadDfgProjectStatuses(
period: DashboardPeriodBounds,
institutionId: string,
requestId: number,
): void {
this.dfgProjectStatusesLoading = true;
this.dfgProjectStatusesError = false;
this.statisticsService
.getDfgProjectStatuses(period, institutionId)
.pipe(
finalize(() => {
if (requestId === this.analyticalRequestId) {
this.dfgProjectStatusesLoading = false;
}
}),
)
.subscribe({
next: (statuses) => {
if (requestId === this.analyticalRequestId) {
this.dfgProjectStatuses = statuses;
}
},
error: () => {
if (requestId === this.analyticalRequestId) {
this.dfgProjectStatusesError = true;
this.dfgProjectStatuses = this.emptyProjectStatuses(institutionId);
}
},
});
}
private emptyProjectStatuses(
institutionId: string,
): EuProjectStatusStatistics {
const institution = this.institutions.find(({ id }) => id === institutionId);
return {
institution_id: institutionId,
organization_name: institution?.display_name ?? '',
ongoing: 0,
upcoming: 0,
completed: 0,
};
}
private restorePeriodState(): void {
const params = this.route.snapshot.queryParamMap;
const mode = params.get('period');
if (
mode === 'all_time' ||
mode === 'last_10_years' ||
mode === 'last_5_years' ||
mode === 'custom'
) {
this.periodMode = mode;
}
this.applyPresetPeriod();
if (this.periodMode !== 'all_time') {
this.fromYear = this.parseYear(params.get('fromYear'), this.fromYear);
this.toYear = this.parseYear(params.get('toYear'), this.toYear);
}
if (this.fromYear > this.toYear) this.fromYear = this.toYear;
}
private applyPresetPeriod(): void {
if (this.periodMode === 'all_time') {
this.fromYear = this.minYear;
this.toYear = this.maxYear;
} else if (this.periodMode === 'last_10_years') {
this.fromYear = this.maxYear - 9;
this.toYear = this.maxYear;
} else if (this.periodMode === 'last_5_years') {
this.fromYear = this.maxYear - 4;
this.toYear = this.maxYear;
}
}
private parseYear(value: string | null, fallback: number): number {
const year = Number(value);
return Number.isInteger(year) && year >= this.minYear && year <= this.maxYear
? year
: fallback;
}
private loadStatistic(
key: DashboardStatisticKey,
request: Observable<DashboardStatisticValue>,
): void {
this.statisticLoading[key] = true;
this.statisticErrors[key] = false;
this.pendingStatisticRequests += 1;
this.statisticsLoading = true;
request
.pipe(
finalize(() => {
this.statisticLoading[key] = false;
this.pendingStatisticRequests -= 1;
this.statisticsLoading = this.pendingStatisticRequests > 0;
}),
)
.subscribe({
next: (statistic) => this.applyStatisticValue(key, statistic),
error: () => {
this.statisticErrors[key] = true;
this.statisticsError = true;
},
});
}
private applyStatisticValue(
key: DashboardStatisticKey,
statistic: DashboardStatisticValue,
): void {
const nextStatistics = {
...(this.statistics ?? {}),
institution_id: statistic.institution_id,
organization_name: statistic.organization_name,
[key]: statistic.value,
};
nextStatistics.projects =
(nextStatistics.eu_projects ?? 0) +
(nextStatistics.bmbf_projects ?? 0) +
(nextStatistics.dfg_projects ?? 0);
this.statistics = nextStatistics;
}
}