sensorDigital, grafik Fest, drawPunkt eingefügt

This commit is contained in:
marco committed 2026-10-28 09:23:11 +01:00
1 parent 0de185c014
commit 30ad6d0e47
106 files changed
+1371 -317

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';
import { ChevronDown } from 'lucide-react';
import { proconNavigation } from '@/_config/procon-navigation';
interface NavigationItem { label: string; href?: string }
interface NavigationGroup { id: string; label: string; items: NavigationItem[] }
const groups: NavigationGroup[] = [
{ id: 'anlage', label: 'Anlage', items: [
{ label: 'Anlagenübersicht', href: '/' },
{ label: 'Anlage auswählen', href: '/alt/rk/anlagen' },
{ label: 'Gruppen', href: '/groups' },
{ label: 'Units', href: '/units' },
{ label: 'EA’s', href: '/signals' },
{ label: 'IO-Übersicht', href: '/ios' },
] },
{ id: 'import', label: 'Import', items: [
{ label: 'IO Import', href: '/signals/import' },
] },
{ id: 'procon', label: 'ProCon', items: [
{ label: 'ProCon-Übersicht', href: '/procon' },
...proconNavigation,
] },
{ id: 'visualisierung', label: 'Visualisierung', items: [
{ label: 'Web-Visu', href: '/visualisierung' },
{ label: 'Grafikbibliothek', href: '/visualisierung/bibliothek' },
{ label: 'VisuAggregate', href: '/visu-aggregate' },
{ label: 'Grafikübersicht', href: '/visu-aggregate/grafiken' },
{ label: 'Positionstabelle', href: '/procon/positionen' },
{ label: 'Zuordnung Aggregate', href: '/procon/zuordnung' },
{ label: 'Zuordnung Signale Analog' },
{ label: 'Zuordnung Signale Digital', href: '/sensoren-digital/bearbeiten' },
] },
];
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' }]
.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;
useEffect(() => {
if (activeGroup) setExpanded(current => ({ ...current, [activeGroup]: true }));
}, [activeGroup, pathname]);
function navigationLink(item: NavigationItem) {
if (!item.href) return <span aria-disabled="true" className="flex items-center justify-between gap-2 rounded px-3 py-1.5 text-gray-400">
<span>{item.label}</span><span className="text-[10px]">Geplant</span>
</span>;
const selected = active === item.href;
return <Link href={item.href} aria-current={selected ? 'page' : undefined}
className={`block rounded px-3 py-1.5 transition-colors focus-visible:outline-2 focus-visible:outline-blue-600 ${selected ? 'bg-blue-100 font-medium text-blue-900' : 'text-slate-700 hover:bg-slate-100'}`}>
{item.label}
</Link>;
}
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 => {
const open = expanded[group.id] ?? true;
return <section key={group.id}>
<button type="button" aria-expanded={open} aria-controls={`navigation-${group.id}`}
className="flex w-full items-center justify-between rounded px-3 py-2 text-left font-semibold text-slate-900 hover:bg-slate-100"
onClick={() => setExpanded(current => ({ ...current, [group.id]: !open }))}>
{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>)}
</ul>
</section>;
})}
<div className="border-t pt-3">{navigationLink({ label: 'Alt – bisherige Seiten', href: '/alt' })}</div>
</nav>
</aside>;
}