From 517657fa76f051895c271e41dbb4fa671acb115d Mon Sep 17 00:00:00 2001 From: genja Date: Wed, 4 Nov 2026 21:44:20 +0100 Subject: [PATCH] layout adjusted, shared components reused --- .../founder-dashboard.component.html | 640 +++++++++++------- .../founder-dashboard.component.scss | 256 +++---- .../founder-dashboard.component.ts | 202 ++++-- .../researcher-network.component.html | 351 ++++++---- .../researcher-network.component.scss | 135 ++-- .../researcher-network.component.ts | 170 ++++- .../multiplier-researcher-network.resolver.ts | 12 - .../multiplier-researcher-page.resolver.ts | 103 +++ .../multiplier-researcher.resolver.ts | 12 - .../multiplier-network-graph.component.html | 1 + .../multiplier-network-graph.component.scss | 2 +- .../multiplier-network-graph.component.ts | 4 +- 12 files changed, 1195 insertions(+), 693 deletions(-) delete mode 100644 webapp/src/app/resolvers/multiplier-researcher-network.resolver.ts create mode 100644 webapp/src/app/resolvers/multiplier-researcher-page.resolver.ts delete mode 100644 webapp/src/app/resolvers/multiplier-researcher.resolver.ts diff --git a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.html b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.html index 69c55fad..911aa83a 100644 --- a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.html +++ b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.html @@ -1,270 +1,412 @@
-

Universität · Gründungspotenzial

-

Welche Forschenden könnten künftig gründen?

-

- Ein Modell bewertet jede Forschende und jeden Forschenden gegen rund 9.000 - Wissenschaftler:innen aus acht Universitäten. Der Score allein ist noch - keine Shortlist – viele Top-Scores sind fehlerhafte Datensätze. Dieses - Dashboard zeigt zuerst das Screening, danach die Personen, die es - bestehen. -

+

Gründungspotenzial · {{ universityName() }}

+ @if (hasData()) { +
+

Welche Forschenden könnten künftig gründen?

+

+ Dieses Dashboard zeigt das Gründungspotenzial der Forschenden der + {{ universityName() }}. Ein Modell bewertet jede Person gegen rund 9.000 + Wissenschaftler:innen aus acht Universitäten. Der Score allein ist noch + keine Shortlist – viele Top-Scores sind fehlerhafte Datensätze. Deshalb + zeigt die Seite zuerst das Screening, danach die Personen, die es + bestehen. +

+
-
-
-
Forschende im Index
-
{{ fmtInt(kpis().total) }}
-
gesamte Kohorte
-
-
-
Bestehen Datenqualität
-
{{ fmtInt(kpis().passed) }}
-
{{ kpis().share }} % der Kohorte
-
-
-
Auf der Shortlist
-
{{ fmtInt(kpis().shortlisted) }}
-
- Score ≥ {{ fmt1(threshold()) }}{{ screened() ? ', gescreent' : ', ungescreent' }} -
-
-
- -
-

1 · Warum die Shortlist klein ist

-

- Jeder Balken zeigt, wie viele Personen nach einer Screening-Regel übrig - bleiben. Die mittleren Regeln existieren, weil OpenAlex-Profile manchmal - zusammengeführt oder falsch datiert sind – und dieses Modell darauf - besonders empfindlich reagiert. -

-
- @for (row of funnel(); track row.key) { -
-
{{ row.label }}
-
-
+
+ + +
Forschende im Index
+
{{ fmtInt(kpis().total) }}
+
gesamte Kohorte
+
+
+ + +
Bestehen Datenqualität
+
{{ fmtInt(kpis().passed) }}
+
{{ kpis().share }} % der Kohorte
+
+
+ + +
Auf der Shortlist
+
{{ fmtInt(kpis().shortlisted) }}
+
+ Score ≥ {{ fmt1(threshold()) + }}{{ screened() ? ', gescreent' : ', ungescreent' }}
-
{{ fmtInt(row.count) }}
-
{{ row.lost ? '−' + fmtInt(row.lost) : '' }}
-
- } + +
-
-
-

2 · Die Shortlist

-

- Verschiebe den Schwellenwert, um Listenlänge gegen Sicherheit abzuwägen. - Aktiviere das Screening für eine handlungsfähige Liste; deaktiviere es, um - zu sehen, was der rohe Modell-Score hervorgebracht hätte – orange Zeilen - sind Datensätze, die eine Datenqualitätsregel verletzt haben. Klicke auf - eine Person, um ihre Karte zu öffnen. -

+
+

1 · Warum die Shortlist klein ist

+

+ Jeder Balken zeigt, wie viele Personen nach einer Screening-Regel übrig + bleiben. Die mittleren Regeln existieren, weil OpenAlex-Profile manchmal + zusammengeführt oder falsch datiert sind – und dieses Modell darauf + besonders empfindlich reagiert. +

+
+ @for (row of funnel(); track row.key) { +
+
{{ row.label }}
+
+ +
+
{{ fmtInt(row.count) }}
+
+ {{ row.lost ? '−' + fmtInt(row.lost) : '' }} +
+
+ } +
+
-
-
- -
- Publikationen {{ fmtInt(row.pubs) }} - Patente {{ fmtInt(row.patents) }} - Industrie-Publikationen {{ fmtInt(row.industry) }} - Förderungen {{ fmtInt(row.grants) }} - aktive Jahre {{ fmtInt(row.activeYears) }} -
-
- } - - -
-

3 · Woher die Kandidat:innen kommen

-

Beide Panels nutzen die Shortlist am aktuellen Schwellenwert.

-
-
-
Karrierestufe
-
- @for (s of stageRows(); track s.label) { -
- {{ s.label }} - - - - {{ s.count }} / {{ fmtInt(s.pool) }} +
+ Balken sind Kandidatenzahlen; die graue Zahl ist der gescreente + Pool der Stufe.
- } -
-
Balken sind Kandidatenzahlen; die graue Zahl ist der gescreente Pool der Stufe.
-
-
-
Forschungsfeld, vs. Anteil an der Kohorte
-
- @for (a of areaRows(); track a.label) { -
- {{ a.label }} - - - - {{ a.count }} · {{ fmt1(a.cohortShare) }} % der Kohorte + + + + + +
+ Forschungsfeld, vs. Anteil an der Kohorte
- } -
-
- Balken sind Kandidatenzahlen. Die graue Zahl ist der Anteil des Feldes an der - gescreenten Kohorte – ein Feld deutlich über seinem Anteil überproduziert. -
+
+ @for (a of areaRows(); track a.code) { +
+ {{ a.label ?? a.code }} + + + + {{ a.shortlist_count ?? 0 }} + · {{ fmt1((a.cohort_share ?? 0) * 100) }} % der + Kohorte +
+ } +
+
+ Balken sind Kandidatenzahlen. Die graue Zahl ist der Anteil des + Feldes an der gescreenten Kohorte – ein Feld deutlich über seinem + Anteil überproduziert. +
+ +
-
-
+ + } @else { + + + {{ FOUNDER_ICON }} +

Noch kein Gründungspotenzial berechnet

+

+ Für die {{ universityName() }} wurde das + Gründungspotenzial noch nicht berechnet. Sobald die Auswertung + vorliegt, erscheinen hier die Kandidat:innen, ihre Scores und ihre + Multiplikator-Netzwerke. +

+
+
+ } + + + + {{ row.name }} + + {{ row.candidate.career_bucket ?? '–' }} + @if (row.areaLabel) { + · {{ row.areaLabel }} + } + + + + + + @if (row.score !== null) { + + + + + {{ fmt1(row.score) }} + + } @else { + – + } + + + + + + @for (v of row.within; track $index) { + + } + + + {{ row.within.map((v) => (v === null ? '–' : round(v))).join(' · ') }} + + + + + + + {{ fmtInt(row.candidate.founder_features?.publications) }} Publ. + @if (row.candidate.founder_features?.patents) { + · {{ fmtInt(row.candidate.founder_features?.patents) }} Pat. + } + @if (row.candidate.founder_features?.industry_collab_papers) { + · + {{ fmtInt(row.candidate.founder_features?.industry_collab_papers) }} Ind. + } + + + + + + @if (!row.candidate.screen.passed && row.flagLabel) { + {{ row.flagLabel }} + } + + + diff --git a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.scss b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.scss index 06365095..cfb880bf 100644 --- a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.scss +++ b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.scss @@ -28,6 +28,11 @@ font-size: 15.5px; margin: 0; max-width: 66ch; + + strong { + color: var(--sg-text); + font-weight: 600; + } } } @@ -35,6 +40,42 @@ section { margin-top: 40px; } +.empty-state { + margin-top: 28px; + max-width: 72ch; + background: var(--sg-surface-muted); + + .mat-mdc-card-content { + padding: 28px 30px; + } + + &__icon { + font-size: 34px; + width: 34px; + height: 34px; + color: var(--sg-text-soft); + margin-bottom: 10px; + } + + h2 { + font-size: 22px; + margin: 0 0 10px; + color: var(--sg-text); + } + + p { + font-size: 15px; + line-height: 1.55; + color: var(--sg-text-muted); + margin: 0; + } + + strong { + color: var(--sg-text); + font-weight: 600; + } +} + h2 { font-size: 20px; margin: 0 0 4px; @@ -61,9 +102,10 @@ h2 { .kpi { background: var(--sg-surface-muted); - border: 1px solid var(--sg-border); - border-radius: 10px; - padding: 14px 16px; + + .mat-mdc-card-content { + padding: 14px 16px; + } .kpi__key { font-size: 11px; @@ -114,17 +156,19 @@ h2 { } .funnel__track { + --mat-progress-bar-track-height: 20px; + --mat-progress-bar-active-indicator-height: 20px; + --mat-progress-bar-track-color: transparent; + --mat-progress-bar-active-indicator-color: var(--sg-blue-highlight); background: var(--sg-surface-muted); border-radius: 4px; height: 22px; overflow: hidden; border: 1px solid var(--sg-border); -} -.funnel__bar { - height: 100%; - background: var(--sg-blue-highlight); - border-radius: 0 4px 4px 0; + .mat-mdc-progress-bar { + height: 100%; + } } .funnel__count { @@ -175,70 +219,78 @@ h2 { margin-left: auto; } - input[type='range'] { - accent-color: var(--sg-blue-highlight); - width: 150px; + &__slider { + width: 220px; + min-width: 160px; } } // -- List --------------------------------------------------------------- -.list { - border: 1px solid var(--sg-border); - border-radius: 10px; +.list-card { overflow: hidden; + + .mat-mdc-card-content { + padding: 0; + } } -.list__head, -.list__row { - display: grid; - grid-template-columns: 1.5fr 0.9fr 1.15fr 0.95fr auto; - gap: 12px; - padding: 9px 14px; - align-items: center; - font-size: 13px; -} - -.list__head { - background: var(--sg-surface-muted); - border-bottom: 1px solid var(--sg-border); - font-size: 11px; - letter-spacing: 0.07em; - text-transform: uppercase; - color: var(--sg-text-soft); -} - -.list__row { - border: none; - border-bottom: 1px solid var(--sg-border); +.list-card .data-table-container table { width: 100%; - text-align: left; - color: inherit; - background: none; - cursor: pointer; - font: inherit; - color: var(--sg-text); + background: transparent; + font-size: 13px; - &:last-child { - border-bottom: none; + .mat-mdc-header-cell { + padding: 8px 14px; + background: var(--sg-surface-muted); + font-size: 11px; + letter-spacing: 0.07em; + text-transform: uppercase; + color: var(--sg-text-soft); } - &:hover, - &:focus-visible { - background: var(--sg-primary-soft); - outline: none; + .mat-mdc-cell { + padding: 8px 14px; + color: var(--sg-text); } - &--flag { - background: var(--sg-error-soft); + .mat-column-name { + width: 32%; + } - &:hover { - background: var(--sg-error-soft); - filter: brightness(0.97); + .mat-column-score { + width: 15%; + } + + .mat-column-within { + width: 22%; + } + + .mat-column-evidence { + width: 21%; + } + + .mat-column-actions { + width: 10%; + text-align: right; + } + + tr.element-row { + cursor: pointer; + + &:hover, + &:focus-visible { + background: var(--sg-primary-soft); + outline: none; + } + + &:focus-visible { + outline: 2px solid var(--sg-blue-highlight); + outline-offset: -2px; } } - &--selected { + tr.selected { box-shadow: inset 3px 0 0 var(--sg-blue-highlight); } } @@ -261,6 +313,10 @@ h2 { } .list__meter { + --mat-progress-bar-track-height: 8px; + --mat-progress-bar-active-indicator-height: 8px; + --mat-progress-bar-track-color: transparent; + --mat-progress-bar-active-indicator-color: var(--sg-blue-highlight); display: block; background: var(--sg-surface-soft); border-radius: 3px; @@ -268,13 +324,10 @@ h2 { flex: 1; min-width: 44px; overflow: hidden; -} -.list__meter-fill { - display: block; - height: 100%; - background: var(--sg-blue-highlight); - border-radius: 0 3px 3px 0; + .mat-mdc-progress-bar { + height: 100%; + } } .list__score-value { @@ -334,30 +387,6 @@ h2 { white-space: nowrap; } -.net-button { - display: inline-flex; - align-items: center; - justify-content: center; - border: 1px solid var(--sg-border); - background: var(--sg-surface); - color: var(--sg-text-muted); - border-radius: 8px; - width: 30px; - height: 30px; - cursor: pointer; - - &:hover { - color: var(--sg-blue-highlight); - border-color: var(--sg-blue-highlight); - } - - mat-icon { - font-size: 18px; - width: 18px; - height: 18px; - } -} - .list__empty { padding: 24px 14px; color: var(--sg-text-soft); @@ -367,12 +396,13 @@ h2 { // -- Detail card -------------------------------------------------------- .card { - border: 1px solid var(--sg-border); - border-radius: 12px; background: var(--sg-surface-muted); - padding: 20px; margin-top: 16px; + .mat-mdc-card-content { + padding: 20px; + } + h3 { margin: 0 0 2px; font-size: 20px; @@ -398,31 +428,6 @@ h2 { color: var(--sg-error); } -.open-network { - display: inline-flex; - align-items: center; - gap: 6px; - border: 1px solid var(--sg-border); - background: var(--sg-surface); - color: var(--sg-text); - border-radius: 8px; - padding: 7px 12px; - cursor: pointer; - font-size: 13px; - font-weight: 600; - - &:hover { - border-color: var(--sg-blue-highlight); - color: var(--sg-blue-highlight); - } - - mat-icon { - font-size: 18px; - width: 18px; - height: 18px; - } -} - .card__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); @@ -456,6 +461,11 @@ h2 { flex-wrap: wrap; gap: 7px; margin-top: 14px; + + b { + color: var(--sg-text); + font-variant-numeric: tabular-nums; + } } .fact { @@ -477,6 +487,15 @@ h2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; + align-items: stretch; +} + +.chart-card { + height: 100%; + + .mat-mdc-card-content { + padding: 14px 16px; + } } .chart__ttl { @@ -501,19 +520,20 @@ h2 { } .chart__track { + --mat-progress-bar-track-height: 14px; + --mat-progress-bar-active-indicator-height: 14px; + --mat-progress-bar-track-color: transparent; + --mat-progress-bar-active-indicator-color: var(--sg-blue-highlight); display: block; background: var(--sg-surface-muted); border-radius: 3px; height: 16px; overflow: hidden; border: 1px solid var(--sg-border); -} -.chart__fill { - display: block; - height: 100%; - border-radius: 0 3px 3px 0; - background: var(--sg-blue-highlight); + .mat-mdc-progress-bar { + height: 100%; + } } .chart__num { diff --git a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.ts b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.ts index ecf58241..5c3e11c1 100644 --- a/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.ts +++ b/webapp/src/app/modules/founder-potential/founder-dashboard/founder-dashboard.component.ts @@ -5,60 +5,62 @@ import { inject, input, signal, + TemplateRef, + viewChild, } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { ActivatedRoute, Router, RouterModule } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { toSignal } from '@angular/core/rxjs-interop'; +import { MatButtonModule } from '@angular/material/button'; +import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; +import { MatSliderModule } from '@angular/material/slider'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { + CareerStageStatistics, FounderCandidate, FounderCandidatePage, FounderStatistics, + ResearchAreaStatistics, } from '../../../api'; import { FUNNEL_STAGE_LABELS, SCREEN_REASON_LABELS, - TAG_LABELS, clamp, fmt1, fmtInt, fmtSubScore, + tagDescription, + tagLabel, } from '../founder-potential.utils'; import { ScoreBarComponent } from '../../../shared/ui/score-bar/score-bar.component'; import { QueryParamPaginatorComponent } from '../../../shared/ui/query-param-paginator/query-param-paginator.component'; -import { NETWORK_ICON } from '../../../shared/ui/icons'; +import { ChipComponent } from '../../../shared/ui/chip/chip.component'; +import { + DataTableComponent, + GenericColumn, +} from '../../../shared/ui/data-table/data-table.component'; +import { FOUNDER_ICON, NETWORK_ICON } from '../../../shared/ui/icons'; +import { CredentialService } from '../../../shared/services/credential.service'; +const FALLBACK_UNIVERSITY = 'Universität Duisburg-Essen'; +const SUB_SCORE_KEYS = ['bridger', 'mentor', 'amplifier'] as const; + +/** + * A shortlist row: the generated candidate plus only the values that the + * table derives from it (display name, the 1/3/5-year slice, the headline + * screen reason). Everything else is read from `candidate` directly. + */ interface FounderRow { - id: string; + candidate: FounderCandidate; name: string; - careerBucket: string | null; areaLabel: string | null; score: number | null; within: (number | null)[]; - pubs: number; - patents: number; - industry: number; - grants: number; - activeYears: number; - passed: boolean; flagLabel: string | null; - sub: { bridger: number; mentor: number; amplifier: number }; - tags: string[]; -} - -interface StageRow { - label: string; - count: number; - pool: number; -} - -interface AreaRow { - label: string; - count: number; - cohortShare: number; - ratio: number | null; } @Component({ @@ -66,23 +68,41 @@ interface AreaRow { standalone: true, imports: [ CommonModule, - RouterModule, + MatButtonModule, + MatCardModule, MatIconModule, + MatProgressBarModule, MatSlideToggleModule, + MatSliderModule, + MatTooltipModule, ScoreBarComponent, QueryParamPaginatorComponent, + ChipComponent, + DataTableComponent, ], templateUrl: './founder-dashboard.component.html', styleUrl: './founder-dashboard.component.scss', }) export class FounderDashboardComponent { readonly NETWORK_ICON = NETWORK_ICON; + readonly FOUNDER_ICON = FOUNDER_ICON; readonly statistics = input.required(); readonly candidates = input.required(); private readonly router = inject(Router); private readonly route = inject(ActivatedRoute); + private readonly credentials = inject(CredentialService, { optional: true }); + + /** The university whose cohort is shown; comes from the account profile. */ + readonly universityName = computed( + () => this.credentials?.organizationName() || FALLBACK_UNIVERSITY, + ); + + /** False when the pipeline has not produced any documents for this university. */ + readonly hasData = computed( + () => (this.statistics().provenance?.document_count ?? 0) > 0, + ); private readonly queryParams = toSignal(this.route.queryParamMap, { initialValue: this.route.snapshot.queryParamMap, @@ -131,6 +151,50 @@ export class FounderDashboardComponent { // -- Shortlist ---------------------------------------------------------- + private readonly nameTemplate = + viewChild.required>('nameTemplate'); + private readonly scoreTemplate = + viewChild.required>('scoreTemplate'); + private readonly withinTemplate = + viewChild.required>('withinTemplate'); + private readonly evidenceTemplate = + viewChild.required>('evidenceTemplate'); + private readonly actionsTemplate = + viewChild.required>('actionsTemplate'); + + readonly columns = computed[]>(() => [ + { + id: 'name', + header: 'Forschende:r', + type: 'display', + cellTemplate: this.nameTemplate(), + }, + { + id: 'score', + header: 'Score', + type: 'display', + cellTemplate: this.scoreTemplate(), + }, + { + id: 'within', + header: 'Innerhalb 1 / 3 / 5 J.', + type: 'display', + cellTemplate: this.withinTemplate(), + }, + { + id: 'evidence', + header: 'Evidenz', + type: 'display', + cellTemplate: this.evidenceTemplate(), + }, + { + id: 'actions', + header: '', + type: 'display', + cellTemplate: this.actionsTemplate(), + }, + ]); + readonly total = computed(() => this.candidates().total ?? 0); readonly rows = computed(() => @@ -142,10 +206,23 @@ export class FounderDashboardComponent { readonly selectedRow = computed(() => { const id = this.selectedId(); const rows = this.rows(); - if (id) return rows.find((r) => r.id === id) ?? null; + if (id) { + return rows.find((r) => r.candidate.author_id === id) ?? null; + } return rows[0] ?? null; }); + /** The three multiplier roles of the selected person, with their tooltips. */ + readonly subScores = computed(() => { + const peerRanks = this.selectedRow()?.candidate.multiplier_peer_ranks; + return SUB_SCORE_KEYS.map((key) => ({ + key, + label: tagLabel(key), + hint: tagDescription(key), + value: peerRanks?.[key] ?? 0, + })); + }); + selectCandidate(id: string): void { this.selectedId.set(id); } @@ -156,14 +233,17 @@ export class FounderDashboardComponent { // -- Controls ----------------------------------------------------------- - onThresholdInput(event: Event): void { - const value = (event.target as HTMLInputElement).valueAsNumber; + /** Discrete label inside the Material slider thumb. */ + readonly formatThreshold = (value: number): string => String(value); + + onSliderInput(value: number): void { if (Number.isFinite(value)) this.thresholdDraft.set(value); } - onThresholdCommit(event: Event): void { - const value = (event.target as HTMLInputElement).valueAsNumber; + onSliderCommit(value = this.thresholdDraft()): void { if (!Number.isFinite(value)) return; + this.thresholdDraft.set(value); + if (value === this.threshold()) return; void this.router.navigate([], { relativeTo: this.route, queryParams: { threshold: value, page: 0 }, @@ -181,33 +261,22 @@ export class FounderDashboardComponent { // -- Stage / area charts ------------------------------------------------ - readonly stageRows = computed(() => { - const stages = this.statistics().career_stages ?? []; - return stages.map((s) => ({ - label: s.career_bucket, - count: s.shortlist_plain ?? 0, - pool: s.screened ?? 0, - })); - }); - - readonly stageMax = computed(() => - Math.max(1, ...this.stageRows().map((s) => s.count)), + readonly stageRows = computed( + () => this.statistics().career_stages ?? [], ); - readonly areaRows = computed(() => { - const areas = [...(this.statistics().research_areas ?? [])] + readonly stageMax = computed(() => + Math.max(1, ...this.stageRows().map((s) => s.shortlist_plain ?? 0)), + ); + + readonly areaRows = computed(() => + [...(this.statistics().research_areas ?? [])] .sort((a, b) => (b.shortlist_count ?? 0) - (a.shortlist_count ?? 0)) - .slice(0, 7); - return areas.map((a) => ({ - label: a.label ?? a.code, - count: a.shortlist_count ?? 0, - cohortShare: (a.cohort_share ?? 0) * 100, - ratio: a.ratio ?? null, - })); - }); + .slice(0, 7), + ); readonly areaMax = computed(() => - Math.max(1, ...this.areaRows().map((a) => a.count)), + Math.max(1, ...this.areaRows().map((a) => a.shortlist_count ?? 0)), ); // -- Formatting helpers for the template -------------------------------- @@ -215,7 +284,8 @@ export class FounderDashboardComponent { readonly fmtInt = fmtInt; readonly fmt1 = fmt1; readonly fmtSubScore = fmtSubScore; - readonly tagLabel = (tag: string) => TAG_LABELS[tag] ?? tag; + readonly tagLabel = tagLabel; + readonly tagDescription = tagDescription; /** Clamp a percentile into the 0-100 band for bar widths. */ readonly clamp0 = (value: number | null) => @@ -231,37 +301,21 @@ export class FounderDashboardComponent { function toRow(c: FounderCandidate): FounderRow { const fp = c.founder_potential; - const ff = c.founder_features; - const pr = c.multiplier_peer_ranks; - const reasons = c.screen?.reasons ?? []; - const passed = c.screen?.passed ?? true; + const reasons = c.screen.reasons ?? []; return { - id: c.author_id, + candidate: c, name: c.display_name ?? c.author_id, - careerBucket: c.career_bucket ?? null, - areaLabel: ff?.publication_research_area_label ?? null, + areaLabel: c.founder_features?.publication_research_area_label ?? null, score: fp?.external_percentile ?? null, within: [ fp?.external_percentile_within_1y ?? null, fp?.external_percentile_within_3y ?? null, fp?.external_percentile_within_5y ?? null, ], - pubs: ff?.publications ?? 0, - patents: ff?.patents ?? 0, - industry: ff?.industry_collab_papers ?? 0, - grants: ff?.grants ?? 0, - activeYears: c.active_years ?? 0, - passed, flagLabel: reasons.length > 0 ? (SCREEN_REASON_LABELS[reasons[0]] ?? reasons[0]) : null, - sub: { - bridger: pr?.bridger ?? 0, - mentor: pr?.mentor ?? 0, - amplifier: pr?.amplifier ?? 0, - }, - tags: c.tags ?? [], }; } diff --git a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.html b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.html index f53c871b..319187b2 100644 --- a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.html +++ b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.html @@ -1,137 +1,230 @@
- - {{ ARROW_BACK_ICON }} - Zurück zur Übersicht - - -
-

Smart-Guide · Multiplikator-Detektion

-

{{ name() }}

-
- @if (careerBucket()) { - - } - {{ fmtInt(nWorks()) }} Publikationen · {{ fmtInt(activeYears()) }} aktive Jahre - @if (suspicious()) { - {{ WARNING_ICON }} Zusammengeführtes Profil - } -
- @if (tags().length) { -
- @for (tag of tags(); track tag) { - {{ tagLabel(tag) }} + @if (unavailable(); as empty) { + + + {{ PERSON_OFF_ICON }} +

{{ empty.title }}

+

{{ empty.body }}

+ @if (empty.hint) { +

{{ empty.hint }}

+ } + + {{ ARROW_BACK_ICON }} + Zurück zum Gründungspotenzial + +
+
+ } @else { +
+

+ Smart-Guide · Multiplikator-Detektion · {{ universityName() }} +

+

{{ name() }}

+
+ @if (careerBucket()) { + } -
- } -
- -
- @for (entry of roleLegend(); track entry.role) { - - {{ entry.label }} - - } - Kollaboration (Breite = Stärke) - überwiegend institutionsübergreifend - Knotengröße = aktive Jahre -
- -
-
- @if ((network().nodes?.length ?? 0) > 0) { - - } @else { -
Kein Netzwerk verfügbar.
- } -
- {{ fmtInt(netMeta().shown) }} der {{ fmtInt(netMeta().totalCoauthors) }} - Koautor:innen dargestellt · {{ fmtInt(netMeta().cohortCoauthors) }} aus der - UDE-Kohorte · {{ fmtInt(netMeta().mentees) }} Mentees -
-
- -
-
-

Multiplikator-Scores

-

Rang gegen Peers dieser Universität, gleiche Karrierestufe. Schwelle: 85.

- @for (s of subScores(); track s.label) { - + >{{ fmtInt(nWorks()) }} Publikationen · + {{ fmtInt(activeYears()) }} aktive Jahre + @if (suspicious()) { + {{ WARNING_ICON }} Zusammengeführtes + Profil }
- -
-

Gründungspotenzial

-

Rang gegen ~9.000 Wissenschaftler:innen an anderen Universitäten.

- - - - - @if (founder().timingApplicable && founder().yearsToFounding !== null) { -

- @if ((founder().yearsToFounding ?? 0) <= 0) { - Das Aktivitätsmuster wirkt bereits gründungsbereit. - } @else { - Voraussichtlich in {{ fmt1(founder().yearsToFounding) }} Jahren gründungsreif. - } -

- } -
- -
- Publikationen {{ fmtInt(facts().pubs) }} - Patente {{ fmtInt(facts().patents) }} - Industrie-Publikationen {{ fmtInt(facts().industry) }} - Förderungen {{ fmtInt(facts().grants) }} - aktive Jahre {{ fmtInt(facts().activeYears) }} -
-
-
- -
-

Metriken im Detail

-

- Jeder Rohwert steht neben seinem Peer-Rang (0–1), damit nachvollziehbar - bleibt, warum eine Person so eingestuft wurde. -

-
- - - - - - - - - - @for (row of metricRows(); track row.key) { - - - - - + @if (tags().length) { +
+ @for (tag of tags(); track tag) { + + {{ tagLabel(tag) }} + } -
-
MetrikWertPeer-Rang
{{ row.label }}{{ fmtMetricValue(row.raw) }}{{ fmtPeerRank(row.rank) }}
-
-
+
+ } +
-
- Konfiguration {{ network().config_hash ?? '–' }} · - berechnet {{ network().computed_at ?? '–' }}. Klick auf - einen Knoten öffnet das Profil der Person. -
+
+ @for (entry of roleLegend(); track entry.role) { + + + {{ entry.label }} + + } + Kollaboration (Breite = Stärke) + überwiegend + institutionsübergreifend + Knotengröße = aktive Jahre +
+ +
+ + + @if (network(); as net) { + @if ((net.nodes?.length ?? 0) > 0) { + + } @else { +
Kein Netzwerk verfügbar.
+ } + } @else { +
Kein Netzwerk verfügbar.
+ } +
+ {{ fmtInt(netMeta().shown) }} der + {{ fmtInt(netMeta().totalCoauthors) }} Koautor:innen dargestellt · + {{ fmtInt(netMeta().cohortCoauthors) }} aus der UDE-Kohorte · + {{ fmtInt(netMeta().mentees) }} Mentees +
+
+
+ + + +
+
+

Multiplikator-Scores

+

+ Rang gegen Peers dieser Universität, gleiche Karrierestufe. + Schwelle: 85. +

+ @for (s of subScores(); track s.key) { + + } +
+ +
+

Gründungspotenzial

+

+ Rang gegen ~9.000 Wissenschaftler:innen an anderen + Universitäten. +

+ + + + + @if ( + founder().timingApplicable && founder().yearsToFounding !== null + ) { +

+ @if ((founder().yearsToFounding ?? 0) <= 0) { + Das Aktivitätsmuster wirkt bereits gründungsbereit. + } @else { + Voraussichtlich in + {{ fmt1(founder().yearsToFounding) }} Jahren gründungsreif. + } +

+ } +
+ +
+ Publikationen {{ fmtInt(facts().pubs) }} + Patente {{ fmtInt(facts().patents) }} + Industrie-Publikationen + {{ fmtInt(facts().industry) }} + Förderungen {{ fmtInt(facts().grants) }} + aktive Jahre {{ fmtInt(facts().activeYears) }} +
+ +
+

Metriken im Detail

+

+ Jeder Rohwert steht neben seinem Peer-Rang (0–1), damit + nachvollziehbar bleibt, warum eine Person so eingestuft wurde. +

+
+ + + + + + + + + + + + + + + + + + +
Metrik{{ row.label }}Wert + {{ fmtMetricValue(row.metric.raw) }} + + Peer-Rang + + {{ fmtPeerRank(row.metric.peer_rank) }} +
+
+
+
+
+
+
+ +
+ Konfiguration + {{ network()?.config_hash ?? '–' }} · berechnet + am + {{ + network()?.computed_at | date: 'dd.MM.yyyy HH:mm' + }} +
+ }
diff --git a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.scss b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.scss index d03a65f5..8cfa7d8b 100644 --- a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.scss +++ b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.scss @@ -1,22 +1,19 @@ .researcher-network { - max-width: 1160px; + max-width: 1440px; margin: 0 auto; padding: 24px 8px 64px; } .back-link { - display: inline-flex; - align-items: center; - gap: 6px; - font-size: 13px; - color: var(--sg-text-muted); - text-decoration: none; margin-bottom: 16px; + color: var(--sg-text-muted); + font-size: 13px; mat-icon { font-size: 18px; width: 18px; height: 18px; + margin-right: 4px; } &:hover { @@ -75,18 +72,6 @@ margin-top: 4px; } -.tag-pill { - font-size: 11.5px; - font-weight: 600; - padding: 2.5px 10px; - border-radius: 999px; - letter-spacing: 0.04em; - border: 1px solid var(--sg-border); - color: var(--sg-text); - background: var(--sg-blue-highlight); - color: #fff; -} - .legend { position: sticky; top: 0; @@ -135,20 +120,22 @@ .case-grid { display: grid; - grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); - gap: 26px; + grid-template-columns: minmax(0, 1.9fr) minmax(340px, 1fr); + gap: 28px; align-items: start; margin-top: 26px; } .netbox { - border: 1px solid var(--sg-border); - border-radius: 10px; background: var(--sg-surface-muted); overflow: hidden; + .mat-mdc-card-content { + padding: 0; + } + &__empty { - height: 480px; + height: 640px; display: flex; align-items: center; justify-content: center; @@ -156,6 +143,12 @@ } } +.detail-card { + .mat-mdc-card-content { + padding: 18px; + } +} + .netfoot { font-size: 12px; color: var(--sg-text-soft); @@ -195,14 +188,6 @@ display: flex; flex-wrap: wrap; gap: 7px; -} - -.fact { - font-size: 12px; - background: var(--sg-surface-soft); - border-radius: 6px; - padding: 4px 9px; - color: var(--sg-text-muted); b { color: var(--sg-text); @@ -211,20 +196,7 @@ } .metrics { - margin-top: 48px; - - h2 { - font-size: 20px; - margin: 0 0 4px; - color: var(--sg-text); - font-weight: 700; - } - - .note { - font-size: 13px; - color: var(--sg-text-muted); - margin: 2px 0 16px; - } + min-width: 0; } .scroller { @@ -232,18 +204,13 @@ } table.mx { - border-collapse: collapse; width: 100%; - font-size: 12.5px; + background: transparent; + font-size: 12px; - th, - td { - text-align: left; - padding: 6px 9px; - border-bottom: 1px solid var(--sg-border); - } - - th { + .mat-mdc-header-cell { + padding: 0 7px; + height: 20px; color: var(--sg-text-soft); font-weight: 600; font-size: 11px; @@ -251,13 +218,18 @@ table.mx { letter-spacing: 0.06em; } - td { + .mat-mdc-cell { color: var(--sg-text-muted); + vertical-align: middle; + line-height: 1.2; + } + .mat-mdc-row { + height: 25px; } - td.num { - font-variant-numeric: tabular-nums; + .num { text-align: right; + font-variant-numeric: tabular-nums; color: var(--sg-text); white-space: nowrap; @@ -268,6 +240,45 @@ table.mx { } } +.unavailable { + margin-top: 32px; + max-width: 68ch; + background: var(--sg-surface-muted); + + .mat-mdc-card-content { + padding: 28px 30px; + } + + &__icon { + font-size: 34px; + width: 34px; + height: 34px; + color: var(--sg-text-soft); + margin-bottom: 10px; + } + + h1 { + font-size: 24px; + line-height: 1.2; + margin: 0 0 10px; + color: var(--sg-text); + } + + &__body { + font-size: 15px; + line-height: 1.55; + color: var(--sg-text); + margin: 0 0 8px; + } + + &__hint { + font-size: 13px; + line-height: 1.5; + color: var(--sg-text-muted); + margin: 0 0 20px; + } +} + footer.page { margin-top: 48px; border-top: 1px solid var(--sg-border); @@ -282,8 +293,12 @@ footer.page { font-size: 11.5px; } -@media (max-width: 900px) { +@media (max-width: 1000px) { .case-grid { grid-template-columns: 1fr; } + + .netbox__empty { + height: 420px; + } } diff --git a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.ts b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.ts index 779a05f5..097477ea 100644 --- a/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.ts +++ b/webapp/src/app/modules/founder-potential/researcher-network/researcher-network.component.ts @@ -1,18 +1,25 @@ import { Component, computed, inject, input } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { Router, RouterModule } from '@angular/router'; +import { NavigationEnd, Router, RouterModule } from '@angular/router'; +import { MatButtonModule } from '@angular/material/button'; +import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; +import { MatTableModule } from '@angular/material/table'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { pipe } from 'rxjs'; -import { EgoNetwork, ResearcherDetail } from '../../../api'; import { METRIC_DEFS, - TAG_LABELS, fmt1, fmtInt, fmtMetricValue, fmtPeerRank, fmtSubScore, + tagDescription, + tagLabel, } from '../founder-potential.utils'; +import { MetricValue, ResearcherMetrics } from '../../../api'; +import { ResearcherPageState } from '../../../resolvers/multiplier-researcher-page.resolver'; import { MULTIPLIER_ROLE_LABELS, multiplierRoleColor, @@ -20,11 +27,32 @@ import { } from '../../../shared/ui/multiplier-network-graph/multiplier-network-graph.component'; import { ScoreBarComponent } from '../../../shared/ui/score-bar/score-bar.component'; import { CareerStageChipComponent } from '../../../shared/ui/career-stage-chip/career-stage-chip.component'; +import { ChipComponent } from '../../../shared/ui/chip/chip.component'; import { ChartThemeService } from '../../../shared/services/chart-theme.service'; -import { ARROW_BACK_ICON, WARNING_ICON } from '../../../shared/ui/icons'; - +import { CredentialService } from '../../../shared/services/credential.service'; +import { + ARROW_BACK_ICON, + PERSON_OFF_ICON, + WARNING_ICON, +} from '../../../shared/ui/icons'; +import { filter } from 'rxjs/operators'; const TAG_THRESHOLD = 0.85; const ROLE_ORDER = ['ego', 'cohort', 'mentee', 'industry', 'external']; +const SUB_SCORE_KEYS = ['bridger', 'mentor', 'amplifier'] as const; +const FALLBACK_UNIVERSITY = 'Universität Duisburg-Essen'; + +interface UnavailableView { + title: string; + body: string; + hint: string | null; +} + +/** A metric definition paired with the API's own raw/peer-rank block. */ +interface MetricRow { + key: keyof ResearcherMetrics; + label: string; + metric: MetricValue; +} @Component({ selector: 'app-researcher-network', @@ -32,46 +60,115 @@ const ROLE_ORDER = ['ego', 'cohort', 'mentee', 'industry', 'external']; imports: [ CommonModule, RouterModule, + MatButtonModule, + MatCardModule, MatIconModule, + MatTableModule, + MatTooltipModule, MultiplierNetworkGraphComponent, ScoreBarComponent, CareerStageChipComponent, + ChipComponent, ], templateUrl: './researcher-network.component.html', styleUrl: './researcher-network.component.scss', }) export class ResearcherNetworkComponent { + constructor() { + this.router.events + .pipe(filter((event: any) => event instanceof NavigationEnd)) + .subscribe(() => { + document.body.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }); + } + readonly ARROW_BACK_ICON = ARROW_BACK_ICON; readonly WARNING_ICON = WARNING_ICON; + readonly PERSON_OFF_ICON = PERSON_OFF_ICON; - readonly researcher = input.required(); - readonly network = input.required(); + /** Resolved detail + network, or the backend's explanation why they are missing. */ + readonly page = input.required(); private readonly router = inject(Router); private readonly chartTheme = inject(ChartThemeService); + private readonly credentials = inject(CredentialService, { optional: true }); - readonly name = computed( - () => this.researcher().display_name ?? this.network().display_name ?? this.researcher().author_id, + readonly universityName = computed( + () => this.credentials?.organizationName() || FALLBACK_UNIVERSITY, ); - readonly careerBucket = computed(() => this.researcher().career_bucket ?? null); - readonly activeYears = computed(() => this.researcher().active_years ?? 0); - readonly nWorks = computed(() => this.researcher().n_works ?? 0); - readonly suspicious = computed(() => this.researcher().suspicious_profile ?? false); + private readonly available = computed(() => { + const page = this.page(); + return page.status === 'ok' ? page : null; + }); - readonly tags = computed(() => this.researcher().tags ?? []); + readonly researcher = computed(() => this.available()?.researcher ?? null); + readonly network = computed(() => this.available()?.network ?? null); + + readonly unavailable = computed(() => { + const page = this.page(); + if (page.status !== 'unavailable') return null; + + const university = this.universityName(); + const who = page.displayName ?? 'diese Person'; + + if (page.reason === 'OTHER_INSTITUTION') { + return { + title: 'Kein Gründungspotenzial für diese Universität', + body: `Für ${who} wurde kein Gründungspotenzial für die ${university} berechnet.`, + hint: page.authorInstitution + ? `Die Person ist aktuell der Einrichtung „${page.authorInstitution}“ zugeordnet, nicht der ${university}.` + : `Die Person ist keiner Einrichtung der ${university} zugeordnet.`, + }; + } + if (page.reason === 'NOT_INDEXED') { + return { + title: 'Noch keine berechneten Daten', + body: `Für ${who} wurde noch kein Gründungspotenzial berechnet.`, + hint: `Die Person gehört zur ${university}, ist aber noch nicht in der Auswertung enthalten.`, + }; + } + return { + title: 'Keine Daten zu dieser Person', + body: 'Zu dieser Person liegen keine berechneten Daten vor.', + hint: null, + }; + }); + + readonly name = computed( + () => + this.researcher()?.display_name ?? + this.network()?.display_name ?? + this.researcher()?.author_id ?? + 'Unbekannt', + ); + + readonly careerBucket = computed( + () => this.researcher()?.career_bucket ?? null, + ); + readonly activeYears = computed(() => this.researcher()?.active_years ?? 0); + readonly nWorks = computed(() => this.researcher()?.n_works ?? 0); + readonly suspicious = computed( + () => this.researcher()?.suspicious_profile ?? false, + ); + + readonly tags = computed(() => this.researcher()?.tags ?? []); readonly subScores = computed(() => { - const pr = this.researcher().multiplier_peer_ranks; - return [ - { label: 'Brückenbauer', raw: pr?.bridger ?? 0 }, - { label: 'Mentor', raw: pr?.mentor ?? 0 }, - { label: 'Verstärker', raw: pr?.amplifier ?? 0 }, - ]; + const pr = this.researcher()?.multiplier_peer_ranks; + return SUB_SCORE_KEYS.map((key) => ({ + key, + label: tagLabel(key), + hint: tagDescription(key), + value: pr?.[key] ?? 0, + })); }); readonly founder = computed(() => { - const fp = this.researcher().founder_potential; + const fp = this.researcher()?.founder_potential; return { score: fp?.external_percentile ?? null, within1: fp?.external_percentile_within_1y ?? null, @@ -83,7 +180,7 @@ export class ResearcherNetworkComponent { }); readonly facts = computed(() => { - const ff = this.researcher().founder_features; + const ff = this.researcher()?.founder_features; return { pubs: ff?.publications ?? 0, patents: ff?.patents ?? 0, @@ -96,25 +193,23 @@ export class ResearcherNetworkComponent { readonly netMeta = computed(() => { const n = this.network(); return { - totalCoauthors: n.total_coauthors ?? 0, - cohortCoauthors: n.cohort_coauthors ?? 0, - mentees: n.mentee_count ?? 0, - shown: n.shown ?? 0, + totalCoauthors: n?.total_coauthors ?? 0, + cohortCoauthors: n?.cohort_coauthors ?? 0, + mentees: n?.mentee_count ?? 0, + shown: n?.shown ?? 0, }; }); - readonly metricRows = computed(() => - METRIC_DEFS.map((def) => { - const metric = this.researcher().metrics?.[def.key]; - return { - key: def.key, - label: def.label, - raw: metric?.raw ?? null, - rank: metric?.peer_rank ?? null, - }; - }), + readonly metricRows = computed(() => + METRIC_DEFS.map((def) => ({ + key: def.key, + label: def.label, + metric: this.researcher()?.metrics?.[def.key] ?? {}, + })), ); + readonly displayedMetricColumns = ['metric', 'value', 'rank']; + readonly roleLegend = computed(() => ROLE_ORDER.map((role) => ({ role, @@ -134,6 +229,7 @@ export class ResearcherNetworkComponent { readonly fmtSubScore = fmtSubScore; readonly fmtPeerRank = fmtPeerRank; readonly fmtMetricValue = fmtMetricValue; - readonly tagLabel = (tag: string) => TAG_LABELS[tag] ?? tag; + readonly tagLabel = tagLabel; + readonly tagDescription = tagDescription; readonly tagThreshold = TAG_THRESHOLD * 100; } diff --git a/webapp/src/app/resolvers/multiplier-researcher-network.resolver.ts b/webapp/src/app/resolvers/multiplier-researcher-network.resolver.ts deleted file mode 100644 index fa70f892..00000000 --- a/webapp/src/app/resolvers/multiplier-researcher-network.resolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ResolveFn } from '@angular/router'; -import { inject } from '@angular/core'; -import { EgoNetwork, MultiplicatorsService } from '../api'; - -/** One researcher's ego co-author network (nodes and edges, no layout). */ -export const multiplierResearcherNetworkResolver: ResolveFn = ( - route, -) => { - const service = inject(MultiplicatorsService); - const authorId = route.paramMap.get('authorId') ?? ''; - return service.getMultiplicatorResearcherNetwork(authorId); -}; diff --git a/webapp/src/app/resolvers/multiplier-researcher-page.resolver.ts b/webapp/src/app/resolvers/multiplier-researcher-page.resolver.ts new file mode 100644 index 00000000..d79b6882 --- /dev/null +++ b/webapp/src/app/resolvers/multiplier-researcher-page.resolver.ts @@ -0,0 +1,103 @@ +import { inject } from '@angular/core'; +import { HttpErrorResponse } from '@angular/common/http'; +import { ResolveFn } from '@angular/router'; +import { catchError, map, of, switchMap, throwError } from 'rxjs'; + +import { EgoNetwork, MultiplicatorsService, ResearcherDetail } from '../api'; + +/** + * Why the backend has no multiplicator document for this author. + * + * This mirrors `ResearcherUnavailableReason` on the backend. It is not in the + * generated client because it is transported in the 404 *error body*, and the + * OpenAPI generator (and the Angular client) do not type error responses. + */ +export type ResearcherUnavailableReason = + | 'OTHER_INSTITUTION' + | 'NOT_INDEXED' + | 'UNKNOWN_AUTHOR' + | 'UNKNOWN'; + +export type ResearcherPageState = + | { + status: 'ok'; + /** Generated model, unchanged. */ + researcher: ResearcherDetail; + /** Generated model; null when the ego network document is missing. */ + network: EgoNetwork | null; + } + | { + status: 'unavailable'; + authorId: string; + reason: ResearcherUnavailableReason; + /** Technical message from the API; used for logging only. */ + message: string | null; + displayName: string | null; + /** The author's current institution, when it is somewhere else. */ + authorInstitution: string | null; + }; + +const REASONS: readonly ResearcherUnavailableReason[] = [ + 'OTHER_INSTITUTION', + 'NOT_INDEXED', + 'UNKNOWN_AUTHOR', +]; + +/** + * Loads the researcher detail and, only on success, their ego network. + * + * A 404 is not an error for this page: the backend explains in the body why + * the person is missing (other institution, not indexed, unknown author), so + * we turn it into a renderable state instead of letting the global navigation + * error handler redirect to /error. Any other status is rethrown. + */ +export const multiplierResearcherPageResolver: ResolveFn< + ResearcherPageState +> = (route) => { + const service = inject(MultiplicatorsService); + const authorId = route.paramMap.get('authorId') ?? ''; + + return service.getMultiplicatorResearcher(authorId).pipe( + switchMap((researcher) => + service.getMultiplicatorResearcherNetwork(authorId).pipe( + catchError(() => of(null)), + map( + (network): ResearcherPageState => ({ + status: 'ok', + researcher, + network, + }), + ), + ), + ), + catchError((error: unknown) => { + if (error instanceof HttpErrorResponse && error.status === 404) { + return of(toUnavailable(authorId, error)); + } + return throwError(() => error); + }), + ); +}; + +function toUnavailable( + requestedAuthorId: string, + error: HttpErrorResponse, +): Extract { + const body = (error.error ?? {}) as Record; + const reason = REASONS.includes(body['reason'] as ResearcherUnavailableReason) + ? (body['reason'] as ResearcherUnavailableReason) + : 'UNKNOWN'; + + return { + status: 'unavailable', + authorId: asString(body['author_id']) ?? requestedAuthorId, + reason, + message: asString(body['message']), + displayName: asString(body['display_name']), + authorInstitution: asString(body['author_institution']), + }; +} + +function asString(value: unknown): string | null { + return typeof value === 'string' && value.length > 0 ? value : null; +} diff --git a/webapp/src/app/resolvers/multiplier-researcher.resolver.ts b/webapp/src/app/resolvers/multiplier-researcher.resolver.ts deleted file mode 100644 index b3ae2802..00000000 --- a/webapp/src/app/resolvers/multiplier-researcher.resolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ResolveFn } from '@angular/router'; -import { inject } from '@angular/core'; -import { MultiplicatorsService, ResearcherDetail } from '../api'; - -/** Full multiplier + founder-potential detail for one researcher. */ -export const multiplierResearcherResolver: ResolveFn = ( - route, -) => { - const service = inject(MultiplicatorsService); - const authorId = route.paramMap.get('authorId') ?? ''; - return service.getMultiplicatorResearcher(authorId); -}; diff --git a/webapp/src/app/shared/ui/multiplier-network-graph/multiplier-network-graph.component.html b/webapp/src/app/shared/ui/multiplier-network-graph/multiplier-network-graph.component.html index f0b9e634..0317a26b 100644 --- a/webapp/src/app/shared/ui/multiplier-network-graph/multiplier-network-graph.component.html +++ b/webapp/src/app/shared/ui/multiplier-network-graph/multiplier-network-graph.component.html @@ -1,5 +1,6 @@
(); + /** Chart height in pixels. */ + readonly height = input(480); readonly nodeClick = output(); private readonly chartTheme = inject(ChartThemeService); @@ -160,7 +162,7 @@ export class MultiplierNetworkGraphComponent { inst: node.inst ?? '', activeYears, nWorks: isEgo ? nWorks : undefined, - symbolSize: isEgo ? 34 : clamp(12 + activeYears * 2, 12, 44), + symbolSize: isEgo ? 24 : clamp(8 + activeYears * 1.1, 8, 26), itemStyle: { color: this.roleColor(role), borderColor: isEgo ? textColor : 'transparent',