added orgminer content component
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
<div class="orgminer">
|
||||
<!-- ============================ SIDEBAR ============================ -->
|
||||
<aside class="orgminer-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<span class="sidebar-title">
|
||||
{{ orgName() || 'Organisation' }}
|
||||
</span>
|
||||
@if (data()) {
|
||||
<a
|
||||
class="sidebar-uri"
|
||||
[href]="data()!.uri"
|
||||
target="_blank"
|
||||
rel="noopener">
|
||||
{{ data()!.uri }}
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
<nav class="accordion">
|
||||
<!-- STAFF -->
|
||||
<div class="accordion-section">
|
||||
<button
|
||||
class="accordion-toggle"
|
||||
[class.active]="expandedCategory() === 'staff'"
|
||||
(click)="toggleCategory('staff')">
|
||||
<mat-icon>{{ PERSONS_ICON }}</mat-icon>
|
||||
<span class="cat-label">Personal</span>
|
||||
<span class="cat-count">{{ categoryCount('staff') }}</span>
|
||||
<span class="chevron" [class.open]="expandedCategory() === 'staff'"
|
||||
>▾</span
|
||||
>
|
||||
</button>
|
||||
|
||||
@if (expandedCategory() === 'staff') {
|
||||
<ul class="accordion-list">
|
||||
@for (person of data()?.staff ?? []; track person.name) {
|
||||
<li
|
||||
class="accordion-item"
|
||||
[class.selected]="isSelected('staff', person)"
|
||||
(click)="selectItem('staff', person)">
|
||||
{{ person.name }}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- PROJECTS -->
|
||||
<div class="accordion-section">
|
||||
<button
|
||||
class="accordion-toggle"
|
||||
[class.active]="expandedCategory() === 'projects'"
|
||||
(click)="toggleCategory('projects')">
|
||||
<mat-icon>{{ PROJECT_ICON }}</mat-icon>
|
||||
<span class="cat-label">Projekte</span>
|
||||
<span class="cat-count">{{ categoryCount('projects') }}</span>
|
||||
<span class="chevron" [class.open]="expandedCategory() === 'projects'"
|
||||
>▾</span
|
||||
>
|
||||
</button>
|
||||
|
||||
@if (expandedCategory() === 'projects') {
|
||||
<ul class="accordion-list">
|
||||
@for (project of data()?.projects ?? []; track project.title) {
|
||||
<li
|
||||
class="accordion-item"
|
||||
[class.selected]="isSelected('projects', project)"
|
||||
(click)="selectItem('projects', project)">
|
||||
{{ project.title }}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- NEWS -->
|
||||
<div class="accordion-section">
|
||||
<button
|
||||
class="accordion-toggle"
|
||||
[class.active]="expandedCategory() === 'news'"
|
||||
(click)="toggleCategory('news')">
|
||||
<mat-icon>{{ NEWS_ICON }}</mat-icon>
|
||||
<span class="cat-label">Nachrichten</span>
|
||||
<span class="cat-count">{{ categoryCount('news') }}</span>
|
||||
<span class="chevron" [class.open]="expandedCategory() === 'news'"
|
||||
>▾</span
|
||||
>
|
||||
</button>
|
||||
|
||||
@if (expandedCategory() === 'news') {
|
||||
<ul class="accordion-list">
|
||||
@for (n of data()?.news ?? []; track n.title) {
|
||||
<li
|
||||
class="accordion-item"
|
||||
[class.selected]="isSelected('news', n)"
|
||||
(click)="selectItem('news', n)">
|
||||
{{ n.title }}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<!-- ============================ DETAIL PANEL ============================ -->
|
||||
<main class="orgminer-detail">
|
||||
@if (!selection()) {
|
||||
<div class="empty-state">
|
||||
<p>Wählen Sie links ein Element aus, um Details anzuzeigen.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ---------------------------- STAFF DETAIL ---------------------------- -->
|
||||
@if (selectedStaff(); as staff) {
|
||||
<div class="detail-card">
|
||||
<h2 class="detail-title">{{ staff.name }}</h2>
|
||||
|
||||
<div class="detail-fields">
|
||||
@if (staff.email) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">E-Mail</span>
|
||||
<a class="detail-value" [href]="'mailto:' + staff.email">{{
|
||||
staff.email
|
||||
}}</a>
|
||||
</div>
|
||||
}
|
||||
@if (staff.telefon) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Telefon</span>
|
||||
<a class="detail-value" [href]="'tel:' + staff.telefon">{{
|
||||
staff.telefon
|
||||
}}</a>
|
||||
</div>
|
||||
}
|
||||
@if (staff.links?.length) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Links</span>
|
||||
<div class="detail-links">
|
||||
@for (link of staff.links; track link) {
|
||||
<a [href]="link" target="_blank" rel="noopener">{{ link }}</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (researchInterests(staff).length) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Forschungsinteressen</span>
|
||||
<div class="chip-list">
|
||||
@for (ri of researchInterests(staff); track ri) {
|
||||
<span class="chip">{{ ri }}</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-keyword-wordcloud [words]="selection()?.item?.keywords || []" />
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- --------------------------- PROJECT DETAIL --------------------------- -->
|
||||
@if (selectedProject(); as project) {
|
||||
<div class="detail-card">
|
||||
<div class="detail-title-row">
|
||||
<h2 class="detail-title">{{ project.title }}</h2>
|
||||
@if (project.project_type) {
|
||||
<span class="badge" [attr.data-type]="project.project_type">
|
||||
{{ project.project_type }}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="detail-fields">
|
||||
@if (project.topic) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Thema</span>
|
||||
<span class="detail-value">{{ project.topic }}</span>
|
||||
</div>
|
||||
}
|
||||
@if (project.names) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Verantwortlich</span>
|
||||
<span class="detail-value">{{ project.names }}</span>
|
||||
</div>
|
||||
}
|
||||
@if (project.links?.length) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Links</span>
|
||||
<div class="detail-links">
|
||||
@for (link of project.links; track link) {
|
||||
<a [href]="link" target="_blank" rel="noopener">{{ link }}</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<app-keyword-wordcloud [words]="selection()?.item?.keywords || []" />
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ----------------------------- NEWS DETAIL ----------------------------- -->
|
||||
@if (selectedNews(); as news) {
|
||||
<div class="detail-card">
|
||||
<h2 class="detail-title">{{ news.title }}</h2>
|
||||
|
||||
<div class="detail-fields">
|
||||
@if (news.date) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Datum</span>
|
||||
<span class="detail-value">{{ news.date }}</span>
|
||||
</div>
|
||||
}
|
||||
@if (news.topic) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Thema</span>
|
||||
<span class="detail-value">{{ news.topic }}</span>
|
||||
</div>
|
||||
}
|
||||
@if (news.links?.length) {
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Links</span>
|
||||
<div class="detail-links">
|
||||
@for (link of news.links; track link) {
|
||||
<a [href]="link" target="_blank" rel="noopener">{{ link }}</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-keyword-wordcloud [words]="selection()?.item?.keywords || []" />
|
||||
</div>
|
||||
}
|
||||
</main>
|
||||
</div>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<OrgminerContent | null>(null);
|
||||
readonly orgName = input<string | null>(null);
|
||||
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private isOwnNavigation = false;
|
||||
|
||||
readonly expandedCategory = signal<CategoryKey | null>(null);
|
||||
|
||||
/** currently selected object shown in the detail panel */
|
||||
readonly selection = signal<Selection | null>(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<string, string | number | null>,
|
||||
): 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<OrgminerStaff | OrgminerProject | OrgminerNews> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user