fix: SQLite boolean binding, CSS brace, race condition, 0 npm vulns, code-splitting
This commit is contained in:
+127
-7
@@ -18,6 +18,7 @@ import StatusBar from './components/StatusBar';
|
||||
import MobileDrawers from './components/MobileDrawers';
|
||||
import BackgroundImport from './components/BackgroundImport';
|
||||
import HistoryPanel from './components/HistoryPanel';
|
||||
import SettingsModal from './components/SettingsModal';
|
||||
import { BackgroundService, type BackgroundConfig } from './services/backgroundService';
|
||||
import { HistoryManager, type CADStateSnapshot, type HistoryEntry } from './history';
|
||||
import { getCommandRegistry } from './services/commandRegistry';
|
||||
@@ -146,6 +147,10 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
// Mobile drawers
|
||||
const [mobileLeftOpen, setMobileLeftOpen] = useState(false);
|
||||
const [mobileRightOpen, setMobileRightOpen] = useState(false);
|
||||
// Desktop sidebar collapse
|
||||
const [leftSidebarCollapsed, setLeftSidebarCollapsed] = useState(false);
|
||||
const [rightSidebarCollapsed, setRightSidebarCollapsed] = useState(false);
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [activeDrawerTab, setActiveDrawerTab] = useState<DrawerTab>('tool');
|
||||
|
||||
// Background
|
||||
@@ -263,6 +268,8 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
collab.loadFromState({ elements: data.elements, layers: data.layers, blocks: data.blocks });
|
||||
}
|
||||
} catch (err) {
|
||||
if (cancelled) return;
|
||||
if (err instanceof Error && err.message.includes('Superseded')) return;
|
||||
console.error('Failed to load project:', err);
|
||||
setSavedStatus('Fehler beim Laden');
|
||||
}
|
||||
@@ -297,13 +304,19 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
setElements(merged);
|
||||
}
|
||||
|
||||
const sameLayers = collab.layers.length === layers.length &&
|
||||
collab.layers.every((l, i) => l.id === layers[i]?.id);
|
||||
if (!sameLayers) setLayers(collab.layers);
|
||||
// Never overwrite local layers with empty remote layers (prevents losing initialLayers)
|
||||
if (collab.layers.length > 0) {
|
||||
const sameLayers = collab.layers.length === layers.length &&
|
||||
collab.layers.every((l, i) => l.id === layers[i]?.id);
|
||||
if (!sameLayers) setLayers(collab.layers);
|
||||
}
|
||||
|
||||
const sameBlocks = collab.blocks.length === blocks.length &&
|
||||
collab.blocks.every((b, i) => b.id === blocks[i]?.id);
|
||||
if (!sameBlocks) setBlocks(collab.blocks);
|
||||
// Never overwrite local blocks with empty remote blocks (prevents losing defaultBlocks)
|
||||
if (collab.blocks.length > 0) {
|
||||
const sameBlocks = collab.blocks.length === blocks.length &&
|
||||
collab.blocks.every((b, i) => b.id === blocks[i]?.id);
|
||||
if (!sameBlocks) setBlocks(collab.blocks);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [collab.elements, collab.layers, collab.blocks, collab.status]);
|
||||
|
||||
@@ -787,6 +800,89 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
setCommandHistory((prev) => [...prev, { prefix: '·', text: 'Zoom: an Ansicht angepasst', type: 'info' }]);
|
||||
}, []);
|
||||
|
||||
// Layer reorder (drag & drop)
|
||||
const handleReorderLayer = useCallback((draggedId: string, targetId: string, position: 'before' | 'after' | 'inside') => {
|
||||
setLayers((prev) => {
|
||||
const dragged = prev.find((l) => l.id === draggedId);
|
||||
if (!dragged) return prev;
|
||||
|
||||
if (position === 'inside') {
|
||||
// Make dragged a child of target
|
||||
const updated = prev.map((l) =>
|
||||
l.id === draggedId ? { ...l, parentId: targetId } : l
|
||||
);
|
||||
return updated;
|
||||
}
|
||||
|
||||
// before/after: reorder at same level
|
||||
const target = prev.find((l) => l.id === targetId);
|
||||
if (!target) return prev;
|
||||
|
||||
const parentId = target.parentId;
|
||||
const siblings = prev
|
||||
.filter((l) => l.parentId === parentId && l.id !== draggedId)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder);
|
||||
|
||||
const targetIdx = siblings.findIndex((l) => l.id === targetId);
|
||||
const insertIdx = position === 'before' ? targetIdx : targetIdx + 1;
|
||||
|
||||
siblings.splice(insertIdx, 0, { ...dragged, parentId });
|
||||
|
||||
// Reassign sortOrder
|
||||
const reordered = siblings.map((l, i) => ({ ...l, sortOrder: i }));
|
||||
|
||||
// Merge back: non-siblings keep original, siblings get reordered
|
||||
const nonSiblings = prev.filter((l) => l.parentId !== parentId || l.id === draggedId);
|
||||
const result = [...nonSiblings.filter((l) => l.id !== draggedId), ...reordered];
|
||||
return result;
|
||||
});
|
||||
setCommandHistory((prev) => [...prev, { prefix: '·', text: 'Ebene verschoben', type: 'info' }]);
|
||||
}, []);
|
||||
|
||||
// Add sub-layer
|
||||
const handleAddSubLayer = useCallback((parentId: string) => {
|
||||
setLayers((prev) => {
|
||||
const parent = prev.find((l) => l.id === parentId);
|
||||
if (!parent) return prev;
|
||||
const newId = `layer-${Date.now()}`;
|
||||
const siblings = prev.filter((l) => l.parentId === parentId);
|
||||
const newLayer: CADLayer = {
|
||||
id: newId, name: `Teilebene ${siblings.length + 1}`, visible: true, locked: false,
|
||||
color: parent.color, lineType: 'solid', transparency: 0,
|
||||
sortOrder: siblings.length, parentId,
|
||||
};
|
||||
if (drawingId && token) {
|
||||
createLayerTyped(token, drawingId, newLayer).catch((err) => {
|
||||
console.error('Failed to save sub-layer:', err);
|
||||
});
|
||||
}
|
||||
return [...prev, newLayer];
|
||||
});
|
||||
}, [drawingId, token]);
|
||||
|
||||
// Update single element (from properties panel)
|
||||
const handleUpdateElement = useCallback((updated: CADElement) => {
|
||||
setElements((prev) => {
|
||||
const newElements = prev.map((e) => (e.id === updated.id ? updated : e));
|
||||
historyManagerRef.current.pushSnapshot({
|
||||
elements: newElements, layers, blocks, groups, bgConfig,
|
||||
}, 'Element geändert');
|
||||
return newElements;
|
||||
});
|
||||
syncHistory();
|
||||
collab.setElement(updated);
|
||||
if (token) {
|
||||
setSavedStatus('Speichert…');
|
||||
updateElement(token, updated.id, updated).then(() => {
|
||||
setSavedStatus('gespeichert');
|
||||
}).catch((err) => {
|
||||
console.error('Failed to update element:', err);
|
||||
setSavedStatus('Fehler beim Speichern');
|
||||
});
|
||||
}
|
||||
setSelectedElement(updated);
|
||||
}, [layers, blocks, groups, bgConfig, syncHistory, token, collab]);
|
||||
|
||||
const handleBgApply = useCallback((config: BackgroundConfig, _image: HTMLImageElement | null) => {
|
||||
setBgConfig(config);
|
||||
setBgImportOpen(false);
|
||||
@@ -936,18 +1032,34 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
onRedo={handleRedo}
|
||||
onThemeToggle={handleThemeToggle}
|
||||
theme={theme}
|
||||
onOpenSettings={() => setSettingsOpen(true)}
|
||||
onOpenLeftDrawer={() => setMobileLeftOpen(true)}
|
||||
onOpenRightDrawer={() => setMobileRightOpen(true)}
|
||||
/>
|
||||
<RibbonBar
|
||||
activeTab={activeRibbonTab}
|
||||
onTabChange={setActiveRibbonTab}
|
||||
onAction={handleRibbonAction}
|
||||
/>
|
||||
<div className="app-body">
|
||||
<div className={`app-body${leftSidebarCollapsed ? ' left-collapsed' : ''}${rightSidebarCollapsed ? ' right-collapsed' : ''}`}>
|
||||
<LeftSidebar
|
||||
activeTool={activeTool}
|
||||
onToolChange={handleToolChange}
|
||||
selectedTemplate={selectedTemplate}
|
||||
onTemplateSelect={handleTemplateSelect}
|
||||
className={mobileLeftOpen ? 'open' : ''}
|
||||
onCollapse={() => setMobileLeftOpen(false)}
|
||||
collapsed={leftSidebarCollapsed}
|
||||
onToggleCollapse={() => setLeftSidebarCollapsed((p) => !p)}
|
||||
blocks={blocks}
|
||||
onDragBlock={handleDragBlock}
|
||||
onBlockCategoryChange={handleBlockCategoryChange}
|
||||
onBlockSearch={handleBlockSearch}
|
||||
onRenameBlock={handleRenameBlock}
|
||||
onDuplicateBlock={handleDuplicateBlock}
|
||||
onDeleteBlock={handleDeleteBlock}
|
||||
onSvgImport={handleSvgImport}
|
||||
onSaveGroupAsBlock={handleSaveGroupAsBlock}
|
||||
/>
|
||||
<CanvasArea
|
||||
cursorPos={cursorPos}
|
||||
@@ -1010,6 +1122,13 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
onKISend={handleKISend}
|
||||
onKISuggestionClick={handleSuggestionClick}
|
||||
kiLoading={kiLoading}
|
||||
className={mobileRightOpen ? 'open' : ''}
|
||||
onCollapse={() => setMobileRightOpen(false)}
|
||||
collapsed={rightSidebarCollapsed}
|
||||
onToggleCollapse={() => setRightSidebarCollapsed((p) => !p)}
|
||||
onReorder={handleReorderLayer}
|
||||
onAddSubLayer={handleAddSubLayer}
|
||||
onUpdateElement={handleUpdateElement}
|
||||
/>
|
||||
</div>
|
||||
<CommandLine
|
||||
@@ -1040,6 +1159,7 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
||||
onCloseRight={() => setMobileRightOpen(false)}
|
||||
onRightTabChange={setActiveDrawerTab}
|
||||
/>
|
||||
<SettingsModal open={settingsOpen} onClose={() => setSettingsOpen(false)} />
|
||||
<BackgroundImport
|
||||
open={bgImportOpen}
|
||||
onClose={() => setBgImportOpen(false)}
|
||||
|
||||
@@ -131,6 +131,7 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
||||
selectedId={activeLayerId}
|
||||
onSelect={onSelectLayer}
|
||||
onReorder={onReorder}
|
||||
draggable={true}
|
||||
renderIcon={(node) => node.icon}
|
||||
renderActions={(node) => {
|
||||
const layer = layers.find((l) => l.id === node.id);
|
||||
@@ -140,16 +141,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onToggleLayer(layer.id); }}
|
||||
title={layer.visible ? 'Sichtbar' : 'Versteckt'}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: layer.visible ? 'var(--text-color, #ccc)' : 'var(--text-muted, #666)' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: layer.visible ? 'var(--text-color, #ccc)' : 'var(--text-muted, #666)', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
{layer.visible ? '👁' : '🚫'}
|
||||
{layer.visible ? <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg> : <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>}
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onToggleLock?.(layer.id); }}
|
||||
title={layer.locked ? 'Gesperrt' : 'Entsperrt'}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: layer.locked ? 'var(--accent, #f59e0b)' : 'var(--text-muted, #666)' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: layer.locked ? 'var(--accent, #f59e0b)' : 'var(--text-muted, #666)', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
{layer.locked ? '🔒' : '🔓'}
|
||||
{layer.locked ? <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> : <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>}
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleAddSubLayer(layer.id); }}
|
||||
@@ -161,16 +162,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onDuplicateLayer?.(layer.id); }}
|
||||
title="Duplizieren"
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: 'var(--text-color, #ccc)' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: 'var(--text-color, #ccc)', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
⧉
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onDeleteLayer?.(layer.id); }}
|
||||
title="Loschen"
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: '#f44336' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: '#f44336', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
✕
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
@@ -183,16 +184,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onToggleElementVisible?.(element.id); }}
|
||||
title={isVisible ? 'Sichtbar' : 'Versteckt'}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: isVisible ? 'var(--text-color, #ccc)' : 'var(--text-muted, #666)' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: isVisible ? 'var(--text-color, #ccc)' : 'var(--text-muted, #666)', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
{isVisible ? '👁' : '🚫'}
|
||||
{isVisible ? <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg> : <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>}
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onElementsDeleted?.([element.id]); }}
|
||||
title="Loschen"
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: '#f44336' }}
|
||||
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: '2px', color: '#f44336', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
✕
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -56,9 +56,9 @@ const sections: Array<{ label: string; tools: ToolDef[] }> = [
|
||||
{ label: 'Bestuhlung', tools: sectionBestuhlung },
|
||||
];
|
||||
|
||||
const LeftSidebar: React.FC<LeftSidebarProps> = ({ activeTool, onToolChange, selectedTemplate, onTemplateSelect, onCollapse }) => {
|
||||
const LeftSidebar: React.FC<LeftSidebarProps> = ({ activeTool, onToolChange, selectedTemplate, onTemplateSelect, onCollapse, className, collapsed, onToggleCollapse }) => {
|
||||
return (
|
||||
<aside className="leftbar" aria-label="Werkzeugpalette">
|
||||
<aside className={`leftbar${className ? ' ' + className : ''}${collapsed ? ' leftbar-collapsed' : ''}`} aria-label="Werkzeugpalette">
|
||||
<div className="leftbar-header">
|
||||
<span className="leftbar-title">Werkzeuge</span>
|
||||
<button className="leftbar-toggle" aria-label="Linke Leiste ausblenden" onClick={onCollapse}>
|
||||
@@ -120,7 +120,13 @@ const LeftSidebar: React.FC<LeftSidebarProps> = ({ activeTool, onToolChange, sel
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
<div className="leftbar-footer">
|
||||
{onToggleCollapse && (
|
||||
<button className="leftbar-footer-btn" title="Linke Leiste ein-/ausklappen" aria-label="Linke Leiste ein-/ausklappen" onClick={onToggleCollapse}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
|
||||
</button>
|
||||
)}
|
||||
<button className="leftbar-footer-btn" title="Plugin hinzufügen" aria-label="Plugin hinzufügen">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* NotificationPanel – Shows user notifications with mark-read and delete
|
||||
*/
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { getNotifications, markNotificationRead, deleteNotification, type NotificationItem } from '../services/api';
|
||||
|
||||
interface NotificationPanelProps {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export function NotificationPanel({ token }: NotificationPanelProps) {
|
||||
const [notifications, setNotifications] = useState<NotificationItem[]>([]);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const fetchNotifications = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const data = await getNotifications(token);
|
||||
setNotifications(data);
|
||||
} catch {
|
||||
setError('Fehler beim Laden');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [token]);
|
||||
|
||||
// Initial load on mount for badge count
|
||||
useEffect(() => {
|
||||
fetchNotifications();
|
||||
}, [fetchNotifications]);
|
||||
|
||||
// Refresh when dropdown opens
|
||||
useEffect(() => {
|
||||
if (open) fetchNotifications();
|
||||
}, [open, fetchNotifications]);
|
||||
|
||||
// Click-outside handler
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const handleClick = (e: MouseEvent) => {
|
||||
if (wrapperRef.current && !wrapperRef.current.contains(e.target as Node)) {
|
||||
setOpen(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener('mousedown', handleClick);
|
||||
return () => document.removeEventListener('mousedown', handleClick);
|
||||
}, [open]);
|
||||
|
||||
const unreadCount = notifications.filter(n => !n.read).length;
|
||||
|
||||
const handleMarkRead = async (id: string) => {
|
||||
try {
|
||||
await markNotificationRead(token, id);
|
||||
setNotifications(prev => prev.map(n => n.id === id ? { ...n, read: 1 } : n));
|
||||
} catch {
|
||||
setError('Fehler beim Markieren');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
try {
|
||||
await deleteNotification(token, id);
|
||||
setNotifications(prev => prev.filter(n => n.id !== id));
|
||||
} catch {
|
||||
setError('Fehler beim Löschen');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="notification-panel-wrapper" ref={wrapperRef}>
|
||||
<button
|
||||
className="notification-bell-btn"
|
||||
onClick={() => setOpen(!open)}
|
||||
title="Benachrichtigungen"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" />
|
||||
<path d="M13.73 21a2 2 0 0 1-3.46 0" />
|
||||
</svg>
|
||||
{unreadCount > 0 && <span className="notification-badge">{unreadCount}</span>}
|
||||
</button>
|
||||
{open && (
|
||||
<div className="notification-dropdown">
|
||||
<div className="notification-dropdown-header">
|
||||
<h3>Benachrichtigungen</h3>
|
||||
<button className="notification-close" onClick={() => setOpen(false)}>×</button>
|
||||
</div>
|
||||
{error && <p className="notification-empty">{error}</p>}
|
||||
{loading ? (
|
||||
<p className="notification-loading">Lädt…</p>
|
||||
) : notifications.length === 0 ? (
|
||||
<p className="notification-empty">Keine Benachrichtigungen</p>
|
||||
) : (
|
||||
<div className="notification-list">
|
||||
{notifications.map(n => (
|
||||
<div key={n.id} className={`notification-item ${n.read ? 'read' : 'unread'}`}>
|
||||
<div className="notification-item-content">
|
||||
<span className={`notification-type-badge type-${n.type}`}>{n.type}</span>
|
||||
<span className="notification-title">{n.title}</span>
|
||||
<span className="notification-message">{n.message}</span>
|
||||
<span className="notification-time">{new Date(n.created_at).toLocaleString('de-DE')}</span>
|
||||
</div>
|
||||
<div className="notification-item-actions">
|
||||
{!n.read && (
|
||||
<button className="notification-action-btn" onClick={() => handleMarkRead(n.id)} title="Als gelesen markieren">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polyline points="20 6 9 17 4 12" /></svg>
|
||||
</button>
|
||||
)}
|
||||
<button className="notification-action-btn delete" onClick={() => handleDelete(n.id)} title="Löschen">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import type { PropertiesPanelProps } from '../types/ui.types';
|
||||
|
||||
const PropertiesPanel: React.FC<PropertiesPanelProps> = ({ selectedElement, layers, onUpdateProperty }) => {
|
||||
const PropertiesPanel: React.FC<PropertiesPanelProps> = ({ selectedElement, layers, onUpdateProperty, onDelete }) => {
|
||||
const el = selectedElement;
|
||||
const x = el ? String(el.x) : '0';
|
||||
const y = el ? String(el.y) : '0';
|
||||
@@ -17,9 +17,21 @@ const PropertiesPanel: React.FC<PropertiesPanelProps> = ({ selectedElement, laye
|
||||
<div className="panel-section">
|
||||
<div className="panel-section-title">
|
||||
<span>Auswahl · 1 Stuhl</span>
|
||||
<button style={{ color: 'var(--color-text-muted)', fontSize: '11px' }} title="Mehr Optionen">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>
|
||||
</button>
|
||||
<div style={{ display: 'flex', gap: '4px' }}>
|
||||
{onDelete && el && (
|
||||
<button
|
||||
onClick={onDelete}
|
||||
title="Auswahl löschen (Entf)"
|
||||
aria-label="Auswahl löschen"
|
||||
style={{ color: '#f44336', background: 'none', border: 'none', cursor: 'pointer', padding: '2px', display: 'flex', alignItems: 'center' }}
|
||||
>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
||||
</button>
|
||||
)}
|
||||
<button style={{ color: 'var(--color-text-muted)', fontSize: '11px', background: 'none', border: 'none', cursor: 'pointer', padding: '2px' }} title="Mehr Optionen">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ const tabs: Array<{ id: RightPanel; label: string; svg: React.ReactNode; badge?:
|
||||
|
||||
const RightSidebar: React.FC<RightSidebarProps> = ({
|
||||
activePanel, onPanelChange, selectedElement, layers, blocks,
|
||||
className,
|
||||
activeLayerId, onSelectLayer, onAddLayer, onToggleLayer,
|
||||
onDeleteLayer, onRenameLayer, onDuplicateLayer, onToggleLock,
|
||||
onReorder, onAddSubLayer,
|
||||
@@ -22,9 +23,20 @@ const RightSidebar: React.FC<RightSidebarProps> = ({
|
||||
onRenameBlock, onDuplicateBlock, onDeleteBlock, onSvgImport, onSaveGroupAsBlock,
|
||||
onBlockCategoryChange, onBlockSearch, onDragBlock,
|
||||
kiMessages, kiSuggestions, onKISend, onKISuggestionClick, kiLoading, onUpdateElement,
|
||||
onCollapse,
|
||||
collapsed,
|
||||
onToggleCollapse,
|
||||
}) => {
|
||||
return (
|
||||
<aside className="rightbar" aria-label="Eigenschaften-Panels">
|
||||
<aside className={`rightbar${className ? ' ' + className : ''}${collapsed ? ' rightbar-collapsed' : ''}`} aria-label="Eigenschaften-Panels">
|
||||
<button className="rightbar-close" aria-label="Rechte Leiste schließen" onClick={onCollapse}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
|
||||
</button>
|
||||
{onToggleCollapse && (
|
||||
<button className="rightbar-collapse-toggle" aria-label="Rechte Leiste ein-/ausklappen" onClick={onToggleCollapse} title="Rechte Leiste ein-/ausklappen">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
|
||||
</button>
|
||||
)}
|
||||
<div className="rightbar-tabs" role="tablist">
|
||||
{tabs.map((tab) => (
|
||||
<button
|
||||
@@ -44,7 +56,7 @@ const RightSidebar: React.FC<RightSidebarProps> = ({
|
||||
|
||||
<div className="rightbar-content">
|
||||
<div className={`rightbar-panel${activePanel === 'tool' ? ' active' : ''}`} data-panel-content="tool">
|
||||
{activePanel === 'tool' && <PropertiesPanel selectedElement={selectedElement} layers={layers} onUpdateProperty={(key, value) => {
|
||||
{activePanel === 'tool' && <PropertiesPanel selectedElement={selectedElement} layers={layers} onDelete={selectedElement && onElementsDeleted ? () => onElementsDeleted([selectedElement.id]) : undefined} onUpdateProperty={(key, value) => {
|
||||
if (!selectedElement || !onUpdateElement) return;
|
||||
const updated = { ...selectedElement };
|
||||
if (key === 'x' || key === 'y' || key === 'width' || key === 'height') {
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* ShareDialog – Share a project with other users by email
|
||||
*/
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { getProjectShares, createProjectShare, deleteProjectShare, type ProjectShare } from '../services/api';
|
||||
|
||||
interface ShareDialogProps {
|
||||
token: string;
|
||||
projectId: string;
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
export function ShareDialog({ token, projectId, open, onClose }: ShareDialogProps) {
|
||||
const [shares, setShares] = useState<ProjectShare[]>([]);
|
||||
const [email, setEmail] = useState('');
|
||||
const [permission, setPermission] = useState('view');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const fetchShares = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const data = await getProjectShares(token, projectId);
|
||||
setShares(data);
|
||||
} catch {
|
||||
setError('Fehler beim Laden der Freigaben');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [token, projectId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) fetchShares();
|
||||
}, [open, fetchShares]);
|
||||
|
||||
const handleShare = async () => {
|
||||
if (!email.trim()) return;
|
||||
if (!EMAIL_REGEX.test(email.trim())) {
|
||||
setError('Ungültige E-Mail-Adresse');
|
||||
return;
|
||||
}
|
||||
// Check for duplicate share
|
||||
if (shares.some(s => s.shared_with_email === email.trim())) {
|
||||
setError('Projekt bereits mit dieser E-Mail geteilt');
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const newShare = await createProjectShare(token, projectId, {
|
||||
shared_with_email: email.trim(),
|
||||
permission,
|
||||
});
|
||||
setShares(prev => [newShare, ...prev]);
|
||||
setEmail('');
|
||||
setPermission('view');
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Freigabe fehlgeschlagen');
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
try {
|
||||
await deleteProjectShare(token, id);
|
||||
setShares(prev => prev.filter(s => s.id !== id));
|
||||
} catch {
|
||||
setError('Fehler beim Entfernen der Freigabe');
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') handleShare();
|
||||
};
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
return (
|
||||
<div className="share-dialog-overlay" onClick={onClose}>
|
||||
<div className="share-dialog" onClick={e => e.stopPropagation()}>
|
||||
<div className="share-dialog-header">
|
||||
<h3>Projekt teilen</h3>
|
||||
<button className="share-dialog-close" onClick={onClose}>×</button>
|
||||
</div>
|
||||
<div className="share-dialog-body">
|
||||
<div className="share-form">
|
||||
<input
|
||||
type="email"
|
||||
placeholder="E-Mail-Adresse"
|
||||
value={email}
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
className="share-email-input"
|
||||
/>
|
||||
<select value={permission} onChange={e => setPermission(e.target.value)} className="share-permission-select">
|
||||
<option value="view">Ansicht</option>
|
||||
<option value="edit">Bearbeitung</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
<button className="share-add-btn" onClick={handleShare} disabled={submitting}>
|
||||
{submitting ? '…' : 'Teilen'}
|
||||
</button>
|
||||
</div>
|
||||
{error && <p className="share-error">{error}</p>}
|
||||
{loading ? (
|
||||
<p className="share-loading">Lädt…</p>
|
||||
) : shares.length === 0 ? (
|
||||
<p className="share-empty">Noch niemandem geteilt</p>
|
||||
) : (
|
||||
<div className="share-list">
|
||||
{shares.map(s => (
|
||||
<div key={s.id} className="share-item">
|
||||
<div className="share-item-info">
|
||||
<span className="share-email">{s.shared_with_email}</span>
|
||||
<span className="share-permission-badge">{s.permission}</span>
|
||||
</div>
|
||||
<button className="share-remove-btn" onClick={() => handleDelete(s.id)} title="Freigabe entfernen">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import type { TopbarProps } from '../types/ui.types';
|
||||
|
||||
const Topbar: React.FC<TopbarProps> = ({ projectName, savedStatus, onUndo, onRedo, onThemeToggle, theme, onOpenSettings }) => {
|
||||
const Topbar: React.FC<TopbarProps> = ({ projectName, savedStatus, onUndo, onRedo, onThemeToggle, theme, onOpenSettings, onOpenLeftDrawer, onOpenRightDrawer }) => {
|
||||
return (
|
||||
<header className="topbar" role="banner">
|
||||
<div className="topbar-left">
|
||||
<button className="hamburger-btn" aria-label="Werkzeuge öffnen">
|
||||
<button className="hamburger-btn" aria-label="Werkzeuge öffnen" onClick={onOpenLeftDrawer}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>
|
||||
</button>
|
||||
<div className="app-logo" aria-hidden="true">
|
||||
@@ -46,6 +46,9 @@ const Topbar: React.FC<TopbarProps> = ({ projectName, savedStatus, onUndo, onRed
|
||||
<option value="de">DE</option>
|
||||
<option value="en">EN</option>
|
||||
</select>
|
||||
<button className="icon-btn-top mobile-drawer-toggle" aria-label="Panel öffnen" title="Panel öffnen" onClick={onOpenRightDrawer}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
|
||||
</button>
|
||||
<button className="icon-btn-top" aria-label="Benachrichtigungen" title="Benachrichtigungen">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>
|
||||
</button>
|
||||
|
||||
@@ -55,6 +55,10 @@ export class InteractionEngine {
|
||||
private onTextEdit?: (el: CADElement) => void;
|
||||
private onSelectionChange?: (selectedIds: string[]) => void;
|
||||
private animationFrame: number | null = null;
|
||||
private boundKeyDown: EventListener;
|
||||
private boundMouseMove: EventListener;
|
||||
private boundMouseUp: EventListener;
|
||||
private boundPointerCancel: EventListener;
|
||||
|
||||
constructor(
|
||||
canvas: HTMLCanvasElement,
|
||||
@@ -89,6 +93,10 @@ export class InteractionEngine {
|
||||
undoKey: 'z',
|
||||
redoKey: 'y',
|
||||
};
|
||||
this.boundKeyDown = this.onKeyDown.bind(this) as EventListener;
|
||||
this.boundMouseMove = this.onMouseMove.bind(this) as EventListener;
|
||||
this.boundMouseUp = this.onMouseUp.bind(this) as EventListener;
|
||||
this.boundPointerCancel = this.onMouseUp.bind(this) as EventListener;
|
||||
}
|
||||
|
||||
setElements(elements: CADElement[]): void {
|
||||
@@ -156,13 +164,14 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
attach(): void {
|
||||
this.addListener('mousedown', this.onMouseDown.bind(this) as EventListener);
|
||||
this.addListener('mousemove', this.onMouseMove.bind(this) as EventListener);
|
||||
this.addListener('mouseup', this.onMouseUp.bind(this) as EventListener);
|
||||
this.addListener('pointerdown', this.onMouseDown.bind(this) as EventListener);
|
||||
document.addEventListener('pointermove', this.boundMouseMove);
|
||||
document.addEventListener('pointerup', this.boundMouseUp);
|
||||
document.addEventListener('pointercancel', this.boundPointerCancel);
|
||||
this.addListener('dblclick', this.onDoubleClick.bind(this) as EventListener);
|
||||
this.addListener('wheel', this.onWheel.bind(this) as EventListener, { passive: false } as AddEventListenerOptions);
|
||||
this.addListener('contextmenu', this.onContextMenu.bind(this) as EventListener);
|
||||
document.addEventListener('keydown', this.onKeyDown.bind(this) as EventListener);
|
||||
document.addEventListener('keydown', this.boundKeyDown);
|
||||
}
|
||||
|
||||
detach(): void {
|
||||
@@ -170,7 +179,10 @@ export class InteractionEngine {
|
||||
this.canvas.removeEventListener(type, fn);
|
||||
}
|
||||
this.eventListeners = [];
|
||||
document.removeEventListener('keydown', this.onKeyDown.bind(this) as EventListener);
|
||||
document.removeEventListener('pointermove', this.boundMouseMove);
|
||||
document.removeEventListener('pointerup', this.boundMouseUp);
|
||||
document.removeEventListener('pointercancel', this.boundPointerCancel);
|
||||
document.removeEventListener('keydown', this.boundKeyDown);
|
||||
if (this.animationFrame !== null) {
|
||||
cancelAnimationFrame(this.animationFrame);
|
||||
this.animationFrame = null;
|
||||
@@ -214,7 +226,7 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseDown(e: MouseEvent): void {
|
||||
e.preventDefault();
|
||||
try { this.canvas.setPointerCapture((e as any).pointerId); } catch {}
|
||||
this.isMouseDown = true;
|
||||
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||
|
||||
@@ -289,6 +301,10 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseMove(e: MouseEvent): void {
|
||||
if (this.state.phase === 'idle' && !this.isMouseDown) {
|
||||
const rect = this.canvas.getBoundingClientRect();
|
||||
if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) return;
|
||||
}
|
||||
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||
const raw = this.getWorldCoords(e);
|
||||
this.onCursorMoved?.(raw.x, raw.y);
|
||||
@@ -329,7 +345,7 @@ export class InteractionEngine {
|
||||
}
|
||||
|
||||
private onMouseUp(e: MouseEvent): void {
|
||||
e.preventDefault();
|
||||
try { this.canvas.releasePointerCapture((e as any).pointerId); } catch {}
|
||||
this.isMouseDown = false;
|
||||
|
||||
if (e.button === 2 || (e.button === 1 && this.state.phase === 'panning')) {
|
||||
@@ -359,7 +375,7 @@ export class InteractionEngine {
|
||||
const final = this.applyOrtho(snapped.x, snapped.y);
|
||||
const tool = this.state.activeTool;
|
||||
// For 2-point tools: use mouseup position as second point
|
||||
if (tool === 'line' || tool === 'rect' || tool === 'circle' || tool === 'dimension' || tool === 'leader') {
|
||||
if (tool === 'line' || tool === 'rect' || tool === 'circle' || tool === 'dimension' || tool === 'leader' || tool === 'arc' || tool === 'polygon' || tool === 'revcloud') {
|
||||
this.state.points.push(final);
|
||||
this.confirmDraw();
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { NotificationPanel } from '../components/NotificationPanel';
|
||||
import { ShareDialog } from '../components/ShareDialog';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
||||
|
||||
@@ -25,6 +27,7 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
||||
const [showCreate, setShowCreate] = useState(false);
|
||||
const [newName, setNewName] = useState('');
|
||||
const [newDesc, setNewDesc] = useState('');
|
||||
const [shareProjectId, setShareProjectId] = useState<string | null>(null);
|
||||
|
||||
const fetchProjects = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -86,7 +89,10 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
||||
<h1>Web CAD</h1>
|
||||
<span className="dashboard-user">{user?.name} ({user?.role})</span>
|
||||
</div>
|
||||
<button className="dashboard-logout" onClick={logout}>Abmelden</button>
|
||||
<div className="dashboard-header-actions">
|
||||
{token && <NotificationPanel token={token} />}
|
||||
<button className="dashboard-logout" onClick={logout}>Abmelden</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="dashboard-content">
|
||||
@@ -133,18 +139,35 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
||||
{project.description && <p>{project.description}</p>}
|
||||
<div className="dashboard-project-meta">
|
||||
<span>Erstellt: {new Date(project.created_at).toLocaleDateString('de-DE')}</span>
|
||||
<button
|
||||
className="dashboard-delete-btn"
|
||||
onClick={(e) => handleDelete(project.id, e)}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
<div className="dashboard-project-actions">
|
||||
<button
|
||||
className="dashboard-share-btn"
|
||||
onClick={(e) => { e.stopPropagation(); setShareProjectId(project.id); }}
|
||||
>
|
||||
Teilen
|
||||
</button>
|
||||
<button
|
||||
className="dashboard-delete-btn"
|
||||
onClick={(e) => handleDelete(project.id, e)}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{token && (
|
||||
<ShareDialog
|
||||
token={token}
|
||||
projectId={shareProjectId ?? ''}
|
||||
open={!!shareProjectId}
|
||||
onClose={() => setShareProjectId(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -387,6 +387,84 @@ export async function loadProjectDataTyped(token: string, projectId: string): Pr
|
||||
return promise;
|
||||
}
|
||||
|
||||
// ─── Notifications ───────────────────────────────────────
|
||||
export interface NotificationItem {
|
||||
id: string;
|
||||
user_id: string;
|
||||
type: string;
|
||||
title: string;
|
||||
message: string;
|
||||
read: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export async function getNotifications(token: string): Promise<NotificationItem[]> {
|
||||
const res = await fetch(`${API_BASE}/api/notifications`, { headers: authHeaders(token) });
|
||||
if (!res.ok) throw new Error('Failed to load notifications');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createNotification(token: string, data: { type?: string; title: string; message: string }): Promise<NotificationItem> {
|
||||
const res = await fetch(`${API_BASE}/api/notifications`, {
|
||||
method: 'POST',
|
||||
headers: { ...authHeaders(token), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to create notification');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function markNotificationRead(token: string, id: string): Promise<void> {
|
||||
const res = await fetch(`${API_BASE}/api/notifications/${id}/read`, {
|
||||
method: 'PATCH',
|
||||
headers: authHeaders(token),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to mark notification as read');
|
||||
}
|
||||
|
||||
export async function deleteNotification(token: string, id: string): Promise<void> {
|
||||
const res = await fetch(`${API_BASE}/api/notifications/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(token),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to delete notification');
|
||||
}
|
||||
|
||||
// ─── Project Shares ──────────────────────────────────────
|
||||
export interface ProjectShare {
|
||||
id: string;
|
||||
project_id: string;
|
||||
shared_with_email: string;
|
||||
shared_by: string;
|
||||
permission: string;
|
||||
share_token: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export async function getProjectShares(token: string, projectId: string): Promise<ProjectShare[]> {
|
||||
const res = await fetch(`${API_BASE}/api/projects/${projectId}/shares`, { headers: authHeaders(token) });
|
||||
if (!res.ok) throw new Error('Failed to load shares');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createProjectShare(token: string, projectId: string, data: { shared_with_email: string; permission?: string }): Promise<ProjectShare> {
|
||||
const res = await fetch(`${API_BASE}/api/projects/${projectId}/shares`, {
|
||||
method: 'POST',
|
||||
headers: { ...authHeaders(token), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to create share');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteProjectShare(token: string, shareId: string): Promise<void> {
|
||||
const res = await fetch(`${API_BASE}/api/shares/${shareId}`, {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(token),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to delete share');
|
||||
}
|
||||
|
||||
export { API_BASE };
|
||||
|
||||
// ─── AI Copilot ─────────────────────────────────────────
|
||||
|
||||
+206
-4
@@ -318,6 +318,7 @@ a:hover { text-decoration: underline; }
|
||||
}
|
||||
.hamburger-btn:hover { background: var(--color-surface-2); }
|
||||
.hamburger-btn svg { width: 20px; height: 20px; }
|
||||
.mobile-drawer-toggle { display: none; }
|
||||
|
||||
/* Right vertical tab bar (mobile only, HIDDEN by default on desktop) */
|
||||
.right-tab-bar { display: none; }
|
||||
@@ -1195,7 +1196,8 @@ a:hover { text-decoration: underline; }
|
||||
|
||||
/* Topbar: hamburger left, project center, notifications right */
|
||||
.hamburger-btn { display: flex; }
|
||||
.app-name, .saved-badge, .lang-select, .topbar > .topbar-right > *:not(.hamburger-btn):not(.icon-btn-top[aria-label="Benachrichtigungen"]):not(.avatar) {
|
||||
.mobile-drawer-toggle { display: flex; }
|
||||
.app-name, .saved-badge, .lang-select, .topbar > .topbar-right > *:not(.hamburger-btn):not(.mobile-drawer-toggle):not(.icon-btn-top[aria-label="Benachrichtigungen"]):not(.avatar) {
|
||||
display: none;
|
||||
}
|
||||
.topbar { padding: 0 8px; gap: 6px; }
|
||||
@@ -1236,9 +1238,63 @@ a:hover { text-decoration: underline; }
|
||||
|
||||
/* Main area: NO left/right desktop columns, canvas + right tab bar */
|
||||
.app-body {
|
||||
grid-template-columns: 1fr var(--mobile-right-tab-w);
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.leftbar, .rightbar { display: none; }
|
||||
/* Sidebars become slide-in overlays on mobile */
|
||||
.leftbar, .rightbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: var(--drawer-w);
|
||||
max-width: 88vw;
|
||||
background: var(--color-surface);
|
||||
box-shadow: var(--shadow-drawer);
|
||||
transition: transform var(--t-drawer);
|
||||
will-change: transform;
|
||||
}
|
||||
.leftbar {
|
||||
left: 0;
|
||||
transform: translateX(-100%);
|
||||
border-right: 1px solid var(--color-border);
|
||||
}
|
||||
.rightbar {
|
||||
right: 0;
|
||||
transform: translateX(100%);
|
||||
border-left: 1px solid var(--color-border);
|
||||
width: var(--drawer-w);
|
||||
}
|
||||
.leftbar.open { transform: translateX(0); }
|
||||
.rightbar.open { transform: translateX(0); }
|
||||
/* Hide empty MobileDrawers overlays — real sidebars are used as slide-in overlays */
|
||||
.drawer { display: none !important; }
|
||||
body.drawer-open { overflow: auto !important; }
|
||||
/* Mobile sidebars: scrollable content, visible labels */
|
||||
.leftbar { overflow-y: auto; -webkit-overflow-scrolling: touch; }
|
||||
.leftbar-toggle { display: grid !important; }
|
||||
.rightbar-close { display: grid !important; }
|
||||
.rightbar-close {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: 6px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
}
|
||||
.rightbar-close svg { width: 18px; height: 18px; }
|
||||
.rightbar-close:hover { background: var(--color-surface-3); }
|
||||
.leftbar-title { display: block; }
|
||||
.tool-section-label { display: block; padding: 0 6px 6px; }
|
||||
.tool-btn-label { display: block; }
|
||||
.tool-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
|
||||
.rightbar { overflow-y: auto; -webkit-overflow-scrolling: touch; }
|
||||
|
||||
/* Right tab bar (vertical icon bar, ALWAYS visible on mobile) */
|
||||
.right-tab-bar {
|
||||
@@ -1402,7 +1458,7 @@ a:hover { text-decoration: underline; }
|
||||
.status-item.hide-mobile { display: none; }
|
||||
|
||||
/* SVG canvas: ensure it's scrollable/zoomable on touch */
|
||||
.canvas-svg { touch-action: pinch-zoom pan-x pan-y; }
|
||||
.canvas-svg { touch-action: none; }
|
||||
}
|
||||
|
||||
/* Very small screens (<480px) */
|
||||
@@ -2010,3 +2066,149 @@ body.drawer-open { overflow: hidden; }
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
/* ─── Notification Panel ─────────────────────────────── */
|
||||
.dashboard-header-actions { display: flex; align-items: center; gap: 12px; }
|
||||
.notification-panel-wrapper { position: relative; }
|
||||
.notification-bell-btn {
|
||||
position: relative; background: none; border: none; cursor: pointer;
|
||||
color: var(--color-text-muted); padding: 6px; border-radius: 6px; transition: background 0.2s;
|
||||
}
|
||||
.notification-bell-btn:hover { background: var(--color-border); }
|
||||
.notification-badge {
|
||||
position: absolute; top: 0; right: 0; background: var(--color-primary); color: white;
|
||||
font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
|
||||
display: flex; align-items: center; justify-content: center; padding: 0 4px;
|
||||
}
|
||||
.notification-dropdown {
|
||||
position: absolute; top: 100%; right: 0; margin-top: 8px; width: 360px;
|
||||
background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 1000; max-height: 480px; overflow-y: auto;
|
||||
}
|
||||
.notification-dropdown-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 12px 16px; border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
.notification-dropdown-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
|
||||
.notification-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--color-text-muted); }
|
||||
.notification-loading, .notification-empty { padding: 16px; text-align: center; color: var(--color-text-muted); font-size: 13px; }
|
||||
.notification-list { padding: 4px 0; }
|
||||
.notification-item {
|
||||
display: flex; justify-content: space-between; align-items: flex-start;
|
||||
padding: 10px 16px; border-bottom: 1px solid var(--color-border); gap: 8px;
|
||||
}
|
||||
.notification-item.unread { background: rgba(52, 152, 219, 0.08); }
|
||||
.notification-item-content { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
||||
.notification-type-badge {
|
||||
font-size: 10px; text-transform: uppercase; font-weight: 600; color: var(--color-text-muted);
|
||||
padding: 1px 6px; border-radius: 3px; background: var(--color-border); align-self: flex-start;
|
||||
}
|
||||
.notification-type-badge.type-share { color: #2ecc71; background: rgba(46, 204, 113, 0.15); }
|
||||
.notification-type-badge.type-info { color: #3498db; background: rgba(52, 152, 219, 0.15); }
|
||||
.notification-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
|
||||
.notification-message { font-size: 12px; color: var(--color-text-muted); line-height: 1.4; }
|
||||
.notification-time { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
|
||||
.notification-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
|
||||
.notification-action-btn {
|
||||
background: none; border: none; cursor: pointer; padding: 4px;
|
||||
color: var(--color-text-muted); border-radius: 4px; transition: background 0.2s;
|
||||
}
|
||||
.notification-action-btn:hover { background: var(--color-border); }
|
||||
.notification-action-btn.delete:hover { color: #e74c3c; }
|
||||
|
||||
/* ─── Share Dialog ────────────────────────────────────── */
|
||||
.share-dialog-overlay {
|
||||
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 2000;
|
||||
}
|
||||
.share-dialog {
|
||||
background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 12px;
|
||||
width: 440px; max-width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,0.4);
|
||||
}
|
||||
.share-dialog-header {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 16px 20px; border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
.share-dialog-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
|
||||
.share-dialog-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--color-text-muted); }
|
||||
.share-dialog-body { padding: 20px; }
|
||||
.share-form { display: flex; gap: 8px; margin-bottom: 16px; }
|
||||
.share-email-input {
|
||||
flex: 1; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 6px;
|
||||
background: var(--color-bg); color: var(--color-text); font-size: 13px;
|
||||
}
|
||||
.share-permission-select {
|
||||
padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 6px;
|
||||
background: var(--color-bg); color: var(--color-text); font-size: 13px;
|
||||
}
|
||||
.share-add-btn {
|
||||
padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
|
||||
background: var(--color-primary); color: white; font-size: 13px; font-weight: 600;
|
||||
}
|
||||
.share-add-btn:hover { opacity: 0.9; }
|
||||
.share-error { color: #e74c3c; font-size: 12px; margin: 8px 0; }
|
||||
.share-loading, .share-empty { padding: 16px; text-align: center; color: var(--color-text-muted); font-size: 13px; }
|
||||
.share-list { display: flex; flex-direction: column; gap: 8px; }
|
||||
.share-item {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 6px;
|
||||
}
|
||||
.share-item-info { display: flex; align-items: center; gap: 8px; }
|
||||
.share-email { font-size: 13px; color: var(--color-text); }
|
||||
.share-permission-badge {
|
||||
font-size: 10px; text-transform: uppercase; font-weight: 600; padding: 2px 8px;
|
||||
border-radius: 4px; background: var(--color-border); color: var(--color-text-muted);
|
||||
}
|
||||
.share-remove-btn {
|
||||
background: none; border: none; cursor: pointer; padding: 4px;
|
||||
color: var(--color-text-muted); border-radius: 4px; transition: color 0.2s;
|
||||
}
|
||||
.share-remove-btn:hover { color: #e74c3c; }
|
||||
|
||||
/* ─── Dashboard Share Button ──────────────────────────── */
|
||||
.dashboard-project-actions { display: flex; gap: 6px; }
|
||||
.dashboard-share-btn {
|
||||
padding: 4px 10px; border: 1px solid var(--color-border); border-radius: 4px;
|
||||
background: transparent; color: var(--color-text-muted); cursor: pointer; font-size: 12px;
|
||||
}
|
||||
.dashboard-share-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
|
||||
|
||||
|
||||
/* ─── Desktop Sidebar Collapse ─────────────────────────── */
|
||||
.rightbar-collapse-toggle {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 32px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--color-surface-2);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
color: var(--color-text-muted);
|
||||
z-index: 10;
|
||||
transition: all var(--t-fast);
|
||||
}
|
||||
.rightbar-collapse-toggle:hover {
|
||||
background: var(--color-surface-3);
|
||||
color: var(--color-text);
|
||||
}
|
||||
.rightbar-collapse-toggle svg { width: 14px; height: 14px; }
|
||||
|
||||
.app-body.right-collapsed .rightbar { width: 0; min-width: 0; overflow: hidden; border-left: none; }
|
||||
.app-body.right-collapsed .rightbar-tabs,
|
||||
.app-body.right-collapsed .rightbar-content,
|
||||
.app-body.right-collapsed .rightbar-close { display: none; }
|
||||
|
||||
.leftbar-collapsed .tool-section,
|
||||
.leftbar-collapsed .leftbar-title,
|
||||
.leftbar-collapsed .leftbar-footer-btn:not(:first-child) { display: none; }
|
||||
.leftbar-collapsed .leftbar-header { justify-content: center; padding: 4px; border: none; }
|
||||
.leftbar-collapsed .leftbar-toggle svg { transform: rotate(180deg); }
|
||||
|
||||
/* Tree drag & drop indicators */
|
||||
.tree-drag-before { border-top: 2px solid var(--color-primary); }
|
||||
.tree-drag-after { border-bottom: 2px solid var(--color-primary); }
|
||||
.tree-drag-inside { background: var(--color-surface-2); outline: 2px solid var(--color-primary); outline-offset: -2px; }
|
||||
.tree-dragging { opacity: 0.5; }
|
||||
|
||||
@@ -65,6 +65,8 @@ export interface TopbarProps {
|
||||
onThemeToggle: () => void;
|
||||
theme: Theme;
|
||||
onOpenSettings?: () => void;
|
||||
onOpenLeftDrawer?: () => void;
|
||||
onOpenRightDrawer?: () => void;
|
||||
}
|
||||
|
||||
export interface SettingsModalProps {
|
||||
@@ -84,6 +86,19 @@ export interface LeftSidebarProps {
|
||||
selectedTemplate?: string | null;
|
||||
onTemplateSelect?: (templateName: string | null) => void;
|
||||
onCollapse?: () => void;
|
||||
className?: string;
|
||||
collapsed?: boolean;
|
||||
onToggleCollapse?: () => void;
|
||||
blocks?: BlockDefinition[];
|
||||
onDragBlock?: (blockId: string) => void;
|
||||
onBlockDrop?: (blockId: string, x: number, y: number) => void;
|
||||
onBlockCategoryChange?: (cat: string) => void;
|
||||
onBlockSearch?: (query: string) => void;
|
||||
onRenameBlock?: (id: string, name: string) => void;
|
||||
onDuplicateBlock?: (id: string) => void;
|
||||
onDeleteBlock?: (id: string) => void;
|
||||
onSvgImport?: (svg: string, name: string, category: string) => void;
|
||||
onSaveGroupAsBlock?: (name: string) => void;
|
||||
}
|
||||
|
||||
export interface CanvasAreaProps {
|
||||
@@ -155,12 +170,17 @@ export interface RightSidebarProps {
|
||||
onKISuggestionClick?: (suggestion: KISuggestion) => void;
|
||||
kiLoading?: boolean;
|
||||
onUpdateElement?: (el: CADElement) => void;
|
||||
className?: string;
|
||||
onCollapse?: () => void;
|
||||
collapsed?: boolean;
|
||||
onToggleCollapse?: () => void;
|
||||
}
|
||||
|
||||
export interface PropertiesPanelProps {
|
||||
selectedElement: CADElement | null;
|
||||
layers: CADLayer[];
|
||||
onUpdateProperty: (key: string, value: unknown) => void;
|
||||
onDelete?: () => void;
|
||||
}
|
||||
|
||||
export interface LayerPanelProps {
|
||||
|
||||
Reference in New Issue
Block a user