diverse änderungen

This commit is contained in:
marco committed 2026-11-05 15:17:01 +01:00
1 parent 0e7b53e558
commit 54d5e58798
60 files changed
+1637 -122

No files matched your search

+18 -6
View File
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react';
import { ChevronDown } from 'lucide-react';
import { proconNavigation } from '@/_config/procon-navigation';
interface NavigationItem { label: string; href?: string }
interface NavigationItem { label: string; href?: string; children?: NavigationItem[] }
interface NavigationGroup { id: string; label: string; items: NavigationItem[] }
const groups: NavigationGroup[] = [
@@ -15,6 +15,7 @@ const groups: NavigationGroup[] = [
{ label: 'Anlage auswählen', href: '/alt/rk/anlagen' },
{ label: 'Gruppen', href: '/groups' },
{ label: 'Units', href: '/units' },
{ label: 'Anlagen-PDF', href: '/anlagen/pdf' },
{ label: 'EA’s', href: '/signals' },
{ label: 'IO-Übersicht', href: '/ios' },
{ label: 'Datensicherung', href: '/datensicherung' },
@@ -42,8 +43,9 @@ const groups: NavigationGroup[] = [
{ label: 'Web-Visu', href: '/visualisierung' },
{ label: 'Live-Anlagenansicht', href: '/live-anlage' },
{ label: 'Grafikbibliothek', href: '/visualisierung/bibliothek' },
{ label: 'VisuAggregate', href: '/visu-aggregate' },
{ label: 'Grafikübersicht', href: '/visu-aggregate/grafiken' },
{ label: 'VisuAggregate', href: '/visu-aggregate', children: [
{ label: 'Grafikübersicht', href: '/visu-aggregate/grafiken' },
] },
{ label: 'Positionstabelle', href: '/procon/positionen' },
{ label: 'Zuordnung Aggregate', href: '/procon/zuordnung' },
{ label: 'Zuordnung Signale Analog' },
@@ -55,10 +57,11 @@ export default function AppSidebar() {
const pathname = usePathname();
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
// Only the most specific route is active, including on detail and export pages.
const active = [...groups.flatMap(group => group.items), { label: 'Alt', href: '/alt' }]
const flatten = (items: NavigationItem[]): NavigationItem[] => items.flatMap(item => [item, ...flatten(item.children ?? [])]);
const active = [...groups.flatMap(group => flatten(group.items)), { label: 'Alt', href: '/alt' }]
.filter(item => item.href && (pathname === item.href || item.href !== '/' && pathname.startsWith(item.href + '/')))
.sort((a, b) => b.href!.length - a.href!.length)[0]?.href;
const activeGroup = groups.find(group => group.items.some(item => item.href === active))?.id;
const activeGroup = groups.find(group => flatten(group.items).some(item => item.href === active))?.id;
useEffect(() => {
if (activeGroup) setExpanded(current => ({ ...current, [activeGroup]: true }));
}, [activeGroup, pathname]);
@@ -74,6 +77,15 @@ export default function AppSidebar() {
</Link>;
}
function navigationEntry(item: NavigationItem) {
return <li key={item.label}>
{navigationLink(item)}
{item.children && <ul aria-label={`Unterpunkte ${item.label}`} className="ml-4 space-y-0.5 border-l pl-2">
{item.children.map(navigationEntry)}
</ul>}
</li>;
}
return <aside className="w-56 shrink-0 overflow-y-auto border-r bg-gray-50 p-3 sm:w-64">
<nav aria-label="Hauptnavigation" className="space-y-3 text-sm">
{groups.map(group => {
@@ -85,7 +97,7 @@ export default function AppSidebar() {
{group.label}<ChevronDown aria-hidden="true" size={16} className={open ? '' : '-rotate-90'} />
</button>
<ul id={`navigation-${group.id}`} hidden={!open} className="space-y-0.5">
{group.items.map(item => <li key={item.label}>{navigationLink(item)}</li>)}
{group.items.map(navigationEntry)}
</ul>
</section>;
})}