diff --git a/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.html b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.html new file mode 100644 index 00000000..517a045c --- /dev/null +++ b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.html @@ -0,0 +1,236 @@ +
+ + + + +
+ @if (!selection()) { +
+

Wählen Sie links ein Element aus, um Details anzuzeigen.

+
+ } + + + @if (selectedStaff(); as staff) { +
+

{{ staff.name }}

+ +
+ @if (staff.email) { +
+ E-Mail + {{ + staff.email + }} +
+ } + @if (staff.telefon) { +
+ Telefon + {{ + staff.telefon + }} +
+ } + @if (staff.links?.length) { +
+ Links + +
+ } + @if (researchInterests(staff).length) { +
+ Forschungsinteressen +
+ @for (ri of researchInterests(staff); track ri) { + {{ ri }} + } +
+
+ } +
+ + +
+ } + + + @if (selectedProject(); as project) { +
+
+

{{ project.title }}

+ @if (project.project_type) { + + {{ project.project_type }} + + } +
+ +
+ @if (project.topic) { +
+ Thema + {{ project.topic }} +
+ } + @if (project.names) { +
+ Verantwortlich + {{ project.names }} +
+ } + @if (project.links?.length) { +
+ Links + +
+ } +
+ +
+ } + + + @if (selectedNews(); as news) { +
+

{{ news.title }}

+ +
+ @if (news.date) { +
+ Datum + {{ news.date }} +
+ } + @if (news.topic) { +
+ Thema + {{ news.topic }} +
+ } + @if (news.links?.length) { +
+ Links + +
+ } +
+ + +
+ } +
+
diff --git a/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.scss b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.scss new file mode 100644 index 00000000..a56a5ec5 --- /dev/null +++ b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.scss @@ -0,0 +1,270 @@ +.orgminer { + display: flex; + width: 100%; + height: 100%; + min-height: 600px; + border: 1px solid #e2e5ea; + border-radius: 8px; + overflow: hidden; + background: #fff; +} + +/* ============================ SIDEBAR ============================ */ + +.orgminer-sidebar { + width: 280px; + flex-shrink: 0; + border-right: 1px solid #e2e5ea; + background: #f7f8fa; + display: flex; + flex-direction: column; + overflow-y: auto; +} + +.sidebar-header { + padding: 16px; + border-bottom: 1px solid #e2e5ea; + + .sidebar-title { + display: block; + font-weight: 700; + font-size: 0.95rem; + color: #222; + margin-bottom: 4px; + } + + .sidebar-uri { + font-size: 0.75rem; + color: #5b8ff9; + word-break: break-all; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } +} + +.accordion { + flex: 1; + overflow-y: auto; +} + +.accordion-section { + border-bottom: 1px solid #e9ebef; +} + +.accordion-toggle { + width: 100%; + display: flex; + align-items: center; + gap: 8px; + padding: 12px 16px; + background: transparent; + border: none; + cursor: pointer; + font-size: 0.9rem; + font-weight: 600; + color: #333; + text-align: left; + + &:hover { + background: #eef1f5; + } + + &.active { + background: #e8f0fe; + color: #1a56db; + } + + .cat-icon { + font-size: 1rem; + } + + .cat-label { + flex: 1; + } + + .cat-count { + font-size: 0.75rem; + color: #888; + background: #e2e5ea; + border-radius: 10px; + padding: 1px 8px; + } + + .chevron { + transition: transform 0.2s ease; + font-size: 0.8rem; + color: #888; + + &.open { + transform: rotate(180deg); + } + } +} + +.accordion-list { + list-style: none; + margin: 0; + padding: 4px 0 8px 0; + max-height: 320px; + overflow-y: auto; +} + +.accordion-item { + padding: 8px 16px 8px 40px; + font-size: 0.85rem; + color: #444; + cursor: pointer; + border-left: 3px solid transparent; + + &:hover { + background: #eef1f5; + } + + &.selected { + background: #e8f0fe; + border-left-color: #1a56db; + color: #1a56db; + font-weight: 600; + } +} + +/* ============================ DETAIL PANEL ============================ */ + +.orgminer-detail { + flex: 1; + overflow-y: auto; + padding: 24px; +} + +.empty-state { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + color: #999; + font-size: 0.95rem; +} + +.detail-card { + display: flex; + flex-direction: column; + gap: 20px; +} + +.detail-title-row { + display: flex; + align-items: center; + gap: 12px; +} + +.detail-title { + margin: 0; + font-size: 1.4rem; + font-weight: 700; + color: #1a1a1a; +} + +.badge { + font-size: 0.7rem; + font-weight: 700; + text-transform: uppercase; + padding: 3px 10px; + border-radius: 12px; + background: #e2e5ea; + color: #444; + + &[data-type='EU'] { + background: #dbeafe; + color: #1d4ed8; + } + &[data-type='BUND'] { + background: #dcfce7; + color: #15803d; + } + &[data-type='Other'] { + background: #fef3c7; + color: #92400e; + } +} + +.detail-fields { + display: flex; + flex-direction: column; + gap: 12px; +} + +.detail-row { + display: flex; + gap: 12px; + font-size: 0.9rem; + align-items: flex-start; +} + +.detail-label { + min-width: 140px; + flex-shrink: 0; + font-weight: 600; + color: #666; +} + +.detail-value { + color: #222; +} + +.detail-links { + display: flex; + flex-direction: column; + gap: 4px; + + a { + color: #5b8ff9; + font-size: 0.85rem; + word-break: break-all; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } +} + +.chip-list { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +.chip { + background: #eef1f5; + color: #333; + font-size: 0.78rem; + padding: 4px 10px; + border-radius: 14px; +} + +/* ============================ WORDCLOUD ============================ */ + +.wordcloud-section { + border-top: 1px solid #e9ebef; + padding-top: 16px; +} + +.wordcloud-title { + margin: 0 0 8px 0; + font-size: 0.95rem; + font-weight: 600; + color: #333; +} + +.wordcloud-chart { + width: 100%; + height: 360px; +} + +.no-keywords { + color: #999; + font-size: 0.85rem; +} diff --git a/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.ts b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.ts new file mode 100644 index 00000000..28881d99 --- /dev/null +++ b/webapp/src/app/modules/hierarchy/orgminer-content/orgminer-content.component.ts @@ -0,0 +1,190 @@ +import { + Component, + DestroyRef, + computed, + inject, + input, + signal, + OnChanges, + OnInit, + SimpleChanges, +} from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { ActivatedRoute, Router } from '@angular/router'; +import { OrgminerContent } from '../../../api/model/orgminerContent'; +import { OrgminerStaff } from '../../../api/model/orgminerStaff'; +import { OrgminerProject } from '../../../api/model/orgminerProject'; +import { OrgminerNews } from '../../../api/model/orgminerNews'; +import { KeywordWordcloudComponent } from '../../../shared/ui/keyword-wordcloud/keyword-wordcloud.component'; +import { MatIconModule } from '@angular/material/icon'; +import { + PERSONS_ICON, + PROJECT_ICON, + NEWS_ICON, +} from '../../../shared/ui/icons'; +/* ------------------------------ Data model ------------------------------ */ + +type CategoryKey = 'staff' | 'projects' | 'news'; + +const EXPANDED_CATEGORY_PARAM = 'orgExpanded'; +const SELECTION_CATEGORY_PARAM = 'orgSelectionCategory'; +const SELECTION_INDEX_PARAM = 'orgSelectionIndex'; + +interface Selection { + category: CategoryKey; + item: OrgminerStaff | OrgminerProject | OrgminerNews; +} + +@Component({ + selector: 'app-orgminer-content', + standalone: true, + imports: [KeywordWordcloudComponent, MatIconModule], + templateUrl: './orgminer-content.component.html', + styleUrls: ['./orgminer-content.component.scss'], +}) +export class OrgminerContentComponent implements OnChanges, OnInit { + readonly data = input(null); + readonly orgName = input(null); + + private readonly router = inject(Router); + private readonly route = inject(ActivatedRoute); + private readonly destroyRef = inject(DestroyRef); + private isOwnNavigation = false; + + readonly expandedCategory = signal(null); + + /** currently selected object shown in the detail panel */ + readonly selection = signal(null); + readonly PERSONS_ICON = PERSONS_ICON; + readonly PROJECT_ICON = PROJECT_ICON; + readonly NEWS_ICON = NEWS_ICON; + ngOnInit(): void { + this.route.queryParamMap + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => { + if (this.isOwnNavigation) { + this.isOwnNavigation = false; + return; + } + this.restoreStateFromUrl(); + }); + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes['data']) { + this.selection.set(null); + this.restoreStateFromUrl(); + } + } + /* ------------------------------ sidebar UI ------------------------------ */ + + toggleCategory(category: CategoryKey): void { + const expandedCategory = + this.expandedCategory() === category ? null : category; + this.expandedCategory.set(expandedCategory); + this.updateQueryParams({ + [EXPANDED_CATEGORY_PARAM]: expandedCategory, + }); + } + + selectItem( + category: CategoryKey, + item: OrgminerStaff | OrgminerProject | OrgminerNews, + ): void { + this.selection.set({ category, item }); + this.expandedCategory.set(category); + this.updateQueryParams({ + [EXPANDED_CATEGORY_PARAM]: category, + [SELECTION_CATEGORY_PARAM]: category, + [SELECTION_INDEX_PARAM]: this.itemIndex(category, item), + }); + } + + private restoreStateFromUrl(): void { + const params = this.route.snapshot.queryParamMap; + const expandedCategory = this.toCategoryKey( + params.get(EXPANDED_CATEGORY_PARAM), + ); + this.expandedCategory.set(expandedCategory); + + const category = this.toCategoryKey(params.get(SELECTION_CATEGORY_PARAM)); + const index = Number(params.get(SELECTION_INDEX_PARAM)); + const items = category ? this.itemsFor(category) : []; + if (category && Number.isInteger(index) && items[index]) { + this.selection.set({ category, item: items[index] }); + } else { + this.selection.set(null); + } + } + + private updateQueryParams( + queryParams: Record, + ): void { + this.isOwnNavigation = true; + this.router + .navigate([], { + relativeTo: this.route, + queryParams, + queryParamsHandling: 'merge', + replaceUrl: true, + }) + .then((navigated) => { + if (!navigated) this.isOwnNavigation = false; + }); + } + + private itemIndex( + category: CategoryKey, + item: OrgminerStaff | OrgminerProject | OrgminerNews, + ): number { + return this.itemsFor(category).indexOf(item); + } + + private itemsFor( + category: CategoryKey, + ): Array { + const data = this.data(); + if (!data) return []; + return data[category] ?? []; + } + + private toCategoryKey(value: string | null): CategoryKey | null { + return value === 'staff' || value === 'projects' || value === 'news' + ? value + : null; + } + + isSelected(category: CategoryKey, item: unknown): boolean { + const sel = this.selection(); + return !!sel && sel.category === category && sel.item === item; + } + + categoryCount(category: CategoryKey): number { + const d = this.data(); + if (!d) return 0; + return d[category]?.length ?? 0; + } + + /* ------------------------------ detail panel ----------------------------- */ + + selectedStaff(): OrgminerStaff | null { + const s = this.selection(); + return s?.category === 'staff' ? (s.item as OrgminerStaff) : null; + } + + selectedProject(): OrgminerProject | null { + const s = this.selection(); + return s?.category === 'projects' ? (s.item as OrgminerProject) : null; + } + + selectedNews(): OrgminerNews | null { + const s = this.selection(); + return s?.category === 'news' ? (s.item as OrgminerNews) : null; + } + + researchInterests(staff: OrgminerStaff): string[] { + const ri = staff.research_interests; + if (!ri) return []; + return ri; + } +}