From 24ee9df743077861558352ac6255fbd540ca1c5a Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Mon, 1 Jun 2026 20:56:45 +0200 Subject: [PATCH] Add compact research timeline view --- .../research-timeline.component.html | 299 ++++++++++++------ .../research-timeline.component.scss | 245 +++++++++++--- .../research-timeline.component.ts | 179 +++++++++++ 3 files changed, 582 insertions(+), 141 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index 83f217f8..cfd25c2e 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -8,69 +8,75 @@

-
-
-
- Zeitraum +
+ - -
+ +
-
- {{ selectedStartYear }} - bis - {{ selectedEndYear }} -
+
+
+ Zeitraum -
-
- - - - -
- -
- {{ minYear }} - {{ maxYear }} -
+ Zurücksetzen +
-
- +
+ {{ selectedStartYear }} + bis + {{ selectedEndYear }} +
- +
+
+ + + + +
+ +
+ {{ minYear }} + {{ maxYear }}
@@ -85,55 +91,146 @@ -
-
- + +
+
+ -
-
- {{ item.year }} - +
+
+ {{ item.year }} + +
+
+ +
+
+

{{ getMainTopic(item) }}

+ + + {{ item.publication_count }} + {{ item.publication_count === 1 ? 'Publikation' : 'Publikationen' }} + + +
+ + + {{ topic.name }} + {{ topic.count }} + + + + + + Keine weiteren Topics + + +
+
- -
-
-

{{ getMainTopic(item) }}

- - - {{ item.publication_count }} - {{ item.publication_count === 1 ? 'Publikation' : 'Publikationen' }} - - -
- - - {{ topic.name }} - {{ topic.count }} - - - - - - Keine weiteren Topics - - -
-
-
-
+ + + +
+
+
+ + +
+ {{ getPhaseYearLabel(phase) }} +

{{ phase.primaryTopicName }}

+ + {{ phase.publication_count }} + {{ phase.publication_count === 1 ? 'Publikation' : 'Publikationen' }} + +
+
+ +
+ + + {{ topic.name }} + {{ topic.count }} + + + + + + Keine weiteren Topics + + +
+ + + +
+
+
+ {{ year.year }} + + {{ year.publication_count }} + {{ year.publication_count === 1 ? 'Publikation' : 'Publikationen' }} + +
+ +
+ + + {{ topic.name }} + {{ topic.count }} + + + + + + Keine weiteren Topics + + +
+
+
+
+
+
diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss index 0d673ef0..f5daf94e 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.scss @@ -9,15 +9,15 @@ } .timeline-header { - display: flex; - justify-content: space-between; + display: grid; + grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr); align-items: flex-start; gap: 24px; margin-bottom: 28px; } .timeline-title { - min-width: 260px; + min-width: 0; h2 { margin: 0 0 6px; @@ -39,17 +39,10 @@ } } -.timeline-header-actions { - display: flex; - align-items: flex-start; - justify-content: flex-end; - gap: 14px; - flex: 1; -} - .year-filter { - width: min(250px, 100%); - padding: 1px 10px; + justify-self: end; + width: min(285px, 100%); + padding: 8px 10px; border: 1px solid #dbe5f6; border-radius: 10px; background: #fbfdff; @@ -198,9 +191,9 @@ } .view-toggle { + justify-self: center; display: flex; gap: 4px; - flex: 0 0 auto; padding: 4px; border: 1px solid #dbe5f6; border-radius: 10px; @@ -209,7 +202,7 @@ button { border: none; border-radius: 8px; - padding: 9px 16px; + padding: 9px 18px; background: transparent; color: #3f4b66; font-size: 14px; @@ -225,14 +218,6 @@ color: #0057ff; box-shadow: inset 0 0 0 1px #3d7cff; } - - &.inactive-button { - cursor: default; - } - - &.inactive-button:hover { - background: transparent; - } } } @@ -377,36 +362,206 @@ font-size: 12px; } +.compact-phase-list { + display: flex; + flex-wrap: wrap; + align-items: stretch; + gap: 14px; +} + +.phase-card { + flex: 0 1 calc((100% - 28px) / 3); + max-width: 520px; + min-width: 300px; + box-sizing: border-box; + padding: 15px 16px; + border: 1px solid #dbe5f6; + border-left-width: 4px; + border-radius: 14px; + background: #fbfdff; +} + +.phase-card-header { + display: flex; + align-items: flex-start; + gap: 10px; +} + +.phase-marker { + flex: 0 0 auto; + width: 11px; + height: 11px; + margin-top: 5px; + border: 3px solid #ffffff; + border-radius: 50%; + box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14); +} + +.phase-title-block { + min-width: 0; + + h3 { + margin: 3px 0 4px; + color: #07163d; + font-size: 15px; + font-weight: 700; + line-height: 1.35; + } +} + +.phase-years { + display: inline-flex; + width: fit-content; + padding: 2px 8px; + border-radius: 999px; + background: #eef4ff; + color: #0057ff; + font-size: 12px; + font-weight: 700; +} + +.phase-publications { + color: #68748f; + font-size: 12px; +} + +.phase-topics { + display: flex; + flex-wrap: wrap; + gap: 7px; + margin-top: 14px; +} + +.phase-toggle { + margin-top: 13px; + border: none; + background: transparent; + color: #0057ff; + font-size: 12px; + font-weight: 700; + cursor: pointer; + padding: 0; +} + +.phase-year-details { + display: flex; + flex-direction: column; + margin-top: 13px; + padding-top: 4px; + border-top: 1px solid #dbe5f6; +} + +.phase-year-row { + display: grid; + grid-template-columns: 72px 1fr; + gap: 10px; + align-items: start; + padding: 10px 0; +} + +.phase-year-row + .phase-year-row { + border-top: 1px solid #e4ebf7; +} + +.phase-year-meta { + display: flex; + flex-direction: column; + gap: 2px; + + strong { + color: #07163d; + font-size: 13px; + } + + span { + color: #68748f; + font-size: 11px; + } +} + +.phase-year-topics { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +.mini-topic-chip { + display: inline-flex; + align-items: center; + gap: 5px; + max-width: 100%; + padding: 4px 7px; + border-radius: 7px; + background: #f2f6ff; + color: #40506f; + font-size: 11px; + line-height: 1.25; + + span { + overflow-wrap: anywhere; + } + + strong { + color: #0057ff; + font-size: 10px; + } +} + .purple { - .dot { + .dot, + .phase-marker { background: #7255d9; } } .blue { - .dot { + .dot, + .phase-marker { background: #2678e8; } } .green { - .dot { + .dot, + .phase-marker { background: #39a96b; } } .orange { - .dot { + .dot, + .phase-marker { background: #f59e0b; } } .pink { - .dot { + .dot, + .phase-marker { background: #e0527c; } } +.phase-card.purple { + border-left-color: #7255d9; +} + +.phase-card.blue { + border-left-color: #2678e8; +} + +.phase-card.green { + border-left-color: #39a96b; +} + +.phase-card.orange { + border-left-color: #f59e0b; +} + +.phase-card.pink { + border-left-color: #e0527c; +} + .topic-chip.purple { border: 1px solid #d8cafe; background: #f6f0ff; @@ -471,14 +626,23 @@ color: #b42318; } -@media (max-width: 980px) { +@media (max-width: 1100px) { .timeline-header { - flex-direction: column; + grid-template-columns: 1fr; } - .timeline-header-actions { + .view-toggle { + justify-self: start; + } + + .year-filter { + justify-self: stretch; width: 100%; - justify-content: space-between; + } + + .phase-card { + flex-basis: calc((100% - 14px) / 2); + max-width: none; } } @@ -487,14 +651,6 @@ padding: 20px; } - .timeline-header-actions { - flex-direction: column; - } - - .year-filter { - width: 100%; - } - .view-toggle { width: 100%; @@ -502,4 +658,13 @@ flex: 1; } } + + .phase-card { + flex-basis: 100%; + min-width: 0; + } + + .phase-year-row { + grid-template-columns: 1fr; + } } \ No newline at end of file diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts index aa5b00c2..1f478634 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts @@ -13,6 +13,26 @@ export interface TopicTimelineElement { primary_topics?: TopicTimelineTopic[]; } +type TimelineViewMode = 'years' | 'compact'; + +interface ResearchTimelinePhase { + id: string; + startYear: number; + endYear: number; + publication_count: number; + primaryTopicName: string; + years: TopicTimelineElement[]; + topics: TopicTimelineTopic[]; +} + +interface WorkingResearchTimelinePhase { + startYear: number; + endYear: number; + publication_count: number; + primaryTopicName: string; + years: TopicTimelineElement[]; +} + @Component({ selector: 'app-research-timeline', standalone: true, @@ -25,6 +45,8 @@ export class ResearchTimelineComponent implements OnChanges { @Input() loading = false; @Input() loadFailed = false; + timelineViewMode: TimelineViewMode = 'years'; + minYear = 0; maxYear = 0; selectedStartYear = 0; @@ -33,6 +55,8 @@ export class ResearchTimelineComponent implements OnChanges { private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink']; private readonly columnWidth = 240; private readonly displayedTopicLimit = 3; + private readonly displayedPhaseTopicLimit = 4; + private readonly expandedPhaseIds = new Set(); ngOnChanges(changes: SimpleChanges): void { if (changes['elements']) { @@ -46,6 +70,10 @@ export class ResearchTimelineComponent implements OnChanges { }); } + get compactPhases(): ResearchTimelinePhase[] { + return this.buildCompactPhases(this.timelineItems); + } + get hasYearRange(): boolean { return this.minYear > 0 && this.maxYear > 0 && this.minYear < this.maxYear; } @@ -72,6 +100,10 @@ export class ResearchTimelineComponent implements OnChanges { return Math.max(count * this.columnWidth, 1000); } + setTimelineViewMode(mode: TimelineViewMode): void { + this.timelineViewMode = mode; + } + onStartYearInput(event: Event): void { const nextStartYear = this.parseYearInput(event); @@ -108,11 +140,39 @@ export class ResearchTimelineComponent implements OnChanges { getDisplayedTopics(item: TopicTimelineElement): TopicTimelineTopic[] { const primaryTopicName = this.getPrimaryTopic(item)?.name; + return this.getDisplayedTopicsForPrimaryTopic(item, primaryTopicName); + } + + getDisplayedTopicsForPrimaryTopic( + item: TopicTimelineElement, + primaryTopicName: string | undefined, + ): TopicTimelineTopic[] { return (item.topics ?? []) .filter((topic) => !this.isSameTopic(topic.name, primaryTopicName)) .slice(0, this.displayedTopicLimit); } + getPhaseYearLabel(phase: ResearchTimelinePhase): string { + if (phase.startYear === phase.endYear) { + return `${phase.startYear}`; + } + + return `${phase.startYear}–${phase.endYear}`; + } + + togglePhase(phase: ResearchTimelinePhase): void { + if (this.expandedPhaseIds.has(phase.id)) { + this.expandedPhaseIds.delete(phase.id); + return; + } + + this.expandedPhaseIds.add(phase.id); + } + + isPhaseExpanded(phase: ResearchTimelinePhase): boolean { + return this.expandedPhaseIds.has(phase.id); + } + getColorClass(index: number): string { return this.colors[index % this.colors.length]; } @@ -125,6 +185,10 @@ export class ResearchTimelineComponent implements OnChanges { return topic.name; } + trackByPhase(_: number, phase: ResearchTimelinePhase): string { + return phase.id; + } + private get sortedElements(): TopicTimelineElement[] { return [...(this.elements ?? [])].sort((left, right) => left.year - right.year); } @@ -147,6 +211,121 @@ export class ResearchTimelineComponent implements OnChanges { this.resetYearRange(); } + private buildCompactPhases(items: TopicTimelineElement[]): ResearchTimelinePhase[] { + const phases: ResearchTimelinePhase[] = []; + let currentPhase: WorkingResearchTimelinePhase | undefined; + + for (const item of items) { + const candidates = this.getDominantPrimaryTopicCandidates(item); + + if (candidates.length === 0) { + this.pushWorkingPhase(phases, currentPhase); + currentPhase = this.createWorkingPhase(item, this.getMainTopic(item)); + continue; + } + + const matchingCandidate = currentPhase + ? candidates.find((candidate) => this.isSameTopic(candidate.name, currentPhase?.primaryTopicName)) + : undefined; + + const canExtendCurrentPhase = + Boolean(currentPhase) && + Boolean(matchingCandidate) && + item.year === currentPhase!.endYear + 1; + + if (currentPhase && canExtendCurrentPhase) { + currentPhase.endYear = item.year; + currentPhase.publication_count += item.publication_count; + currentPhase.years.push(item); + continue; + } + + this.pushWorkingPhase(phases, currentPhase); + currentPhase = this.createWorkingPhase(item, candidates[0].name); + } + + this.pushWorkingPhase(phases, currentPhase); + + return phases; + } + + private createWorkingPhase( + item: TopicTimelineElement, + primaryTopicName: string, + ): WorkingResearchTimelinePhase { + return { + startYear: item.year, + endYear: item.year, + publication_count: item.publication_count, + primaryTopicName, + years: [item], + }; + } + + private pushWorkingPhase( + phases: ResearchTimelinePhase[], + workingPhase: WorkingResearchTimelinePhase | undefined, + ): void { + if (!workingPhase) { + return; + } + + phases.push({ + ...workingPhase, + id: `${workingPhase.startYear}-${workingPhase.endYear}-${this.normalizeTopicName( + workingPhase.primaryTopicName, + )}`, + topics: this.aggregatePhaseTopics(workingPhase.years, workingPhase.primaryTopicName), + }); + } + + private aggregatePhaseTopics( + years: TopicTimelineElement[], + primaryTopicName: string, + ): TopicTimelineTopic[] { + const counts = new Map(); + const originalNames = new Map(); + + for (const year of years) { + for (const topic of year.topics ?? []) { + if (this.isSameTopic(topic.name, primaryTopicName)) { + continue; + } + + const normalizedName = this.normalizeTopicName(topic.name); + + originalNames.set(normalizedName, topic.name); + counts.set(normalizedName, (counts.get(normalizedName) ?? 0) + topic.count); + } + } + + return Array.from(counts.entries()) + .map(([normalizedName, count]) => ({ + name: originalNames.get(normalizedName) ?? normalizedName, + count, + })) + .sort((left, right) => { + if (right.count !== left.count) { + return right.count - left.count; + } + + return left.name.localeCompare(right.name); + }) + .slice(0, this.displayedPhaseTopicLimit); + } + + private getDominantPrimaryTopicCandidates(item: TopicTimelineElement): TopicTimelineTopic[] { + const primaryTopics = item.primary_topics ?? []; + + if (primaryTopics.length === 0) { + return []; + } + + const maxCount = Math.max(...primaryTopics.map((topic) => topic.count)); + + return primaryTopics.filter((topic) => topic.count === maxCount); + } + private getFirstTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined { return (item.topics ?? [])[0]; }