fix: SQLite boolean binding, CSS brace, race condition, 0 npm vulns, code-splitting
This commit is contained in:
@@ -79,6 +79,26 @@ export interface DBSession {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DBNotification {
|
||||||
|
id: string;
|
||||||
|
user_id: string;
|
||||||
|
type: string;
|
||||||
|
title: string;
|
||||||
|
message: string;
|
||||||
|
read: number;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DBProjectShare {
|
||||||
|
id: string;
|
||||||
|
project_id: string;
|
||||||
|
shared_with_email: string;
|
||||||
|
shared_by: string;
|
||||||
|
permission: string;
|
||||||
|
share_token: string | null;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface DatabaseInterface {
|
export interface DatabaseInterface {
|
||||||
init(): Promise<void>;
|
init(): Promise<void>;
|
||||||
close(): void;
|
close(): void;
|
||||||
@@ -132,4 +152,17 @@ export interface DatabaseInterface {
|
|||||||
getSession(token: string): DBSession | null;
|
getSession(token: string): DBSession | null;
|
||||||
deleteSession(token: string): boolean;
|
deleteSession(token: string): boolean;
|
||||||
deleteExpiredSessions(): void;
|
deleteExpiredSessions(): void;
|
||||||
|
|
||||||
|
// Notifications
|
||||||
|
listNotifications(userId: string): DBNotification[];
|
||||||
|
getNotification(id: string): DBNotification | null;
|
||||||
|
createNotification(data: Partial<DBNotification>): DBNotification;
|
||||||
|
markNotificationRead(id: string): boolean;
|
||||||
|
deleteNotification(id: string): boolean;
|
||||||
|
|
||||||
|
// Project Shares
|
||||||
|
listProjectShares(projectId: string): DBProjectShare[];
|
||||||
|
getProjectShare(id: string): DBProjectShare | null;
|
||||||
|
createProjectShare(data: Partial<DBProjectShare>): DBProjectShare;
|
||||||
|
deleteProjectShare(id: string): boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { randomUUID } from 'crypto';
|
|||||||
import type {
|
import type {
|
||||||
DatabaseInterface, DBProject, DBDrawing, DBLayer,
|
DatabaseInterface, DBProject, DBDrawing, DBLayer,
|
||||||
DBElement, DBBlock, DBSetting, DBUser, DBSession,
|
DBElement, DBBlock, DBSetting, DBUser, DBSession,
|
||||||
|
DBNotification, DBProjectShare,
|
||||||
} from './DatabaseInterface.js';
|
} from './DatabaseInterface.js';
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
@@ -146,7 +147,7 @@ export class SqliteAdapter implements DatabaseInterface {
|
|||||||
const id = data.id ?? `layer-${Date.now()}`;
|
const id = data.id ?? `layer-${Date.now()}`;
|
||||||
this.db.prepare(
|
this.db.prepare(
|
||||||
'INSERT INTO layers (id, drawing_id, name, visible, locked, color, line_type, transparency, sort_order, parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
'INSERT INTO layers (id, drawing_id, name, visible, locked, color, line_type, transparency, sort_order, parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
).run(id, data.drawing_id!, data.name ?? 'Layer', data.visible ?? 1, data.locked ?? 0,
|
).run(id, data.drawing_id!, data.name ?? 'Layer', data.visible !== undefined ? (data.visible ? 1 : 0) : 1, data.locked !== undefined ? (data.locked ? 1 : 0) : 0,
|
||||||
data.color ?? '#ffffff', data.line_type ?? 'solid', data.transparency ?? 0,
|
data.color ?? '#ffffff', data.line_type ?? 'solid', data.transparency ?? 0,
|
||||||
data.sort_order ?? 0, data.parent_id ?? null);
|
data.sort_order ?? 0, data.parent_id ?? null);
|
||||||
return this.db.prepare('SELECT * FROM layers WHERE id = ?').get(id) as DBLayer;
|
return this.db.prepare('SELECT * FROM layers WHERE id = ?').get(id) as DBLayer;
|
||||||
@@ -157,7 +158,7 @@ export class SqliteAdapter implements DatabaseInterface {
|
|||||||
const vals: any[] = [];
|
const vals: any[] = [];
|
||||||
for (const [k, v] of Object.entries(data)) {
|
for (const [k, v] of Object.entries(data)) {
|
||||||
if (['name','visible','locked','color','line_type','transparency','sort_order','parent_id'].includes(k)) {
|
if (['name','visible','locked','color','line_type','transparency','sort_order','parent_id'].includes(k)) {
|
||||||
sets.push(`${k} = ?`); vals.push(v);
|
sets.push(`${k} = ?`); vals.push(k === 'visible' || k === 'locked' ? (v ? 1 : 0) : v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sets.length > 0) {
|
if (sets.length > 0) {
|
||||||
@@ -189,7 +190,7 @@ export class SqliteAdapter implements DatabaseInterface {
|
|||||||
const vals: any[] = [];
|
const vals: any[] = [];
|
||||||
for (const [k, v] of Object.entries(data)) {
|
for (const [k, v] of Object.entries(data)) {
|
||||||
if (['layer_id','type','x','y','width','height','properties_json'].includes(k)) {
|
if (['layer_id','type','x','y','width','height','properties_json'].includes(k)) {
|
||||||
sets.push(`${k} = ?`); vals.push(v);
|
sets.push(`${k} = ?`); vals.push(k === 'visible' || k === 'locked' ? (v ? 1 : 0) : v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sets.length > 0) {
|
if (sets.length > 0) {
|
||||||
@@ -221,7 +222,7 @@ export class SqliteAdapter implements DatabaseInterface {
|
|||||||
const vals: any[] = [];
|
const vals: any[] = [];
|
||||||
for (const [k, v] of Object.entries(data)) {
|
for (const [k, v] of Object.entries(data)) {
|
||||||
if (['name','description','category','elements_json','thumbnail'].includes(k)) {
|
if (['name','description','category','elements_json','thumbnail'].includes(k)) {
|
||||||
sets.push(`${k} = ?`); vals.push(v);
|
sets.push(`${k} = ?`); vals.push(k === 'visible' || k === 'locked' ? (v ? 1 : 0) : v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sets.length > 0) {
|
if (sets.length > 0) {
|
||||||
@@ -265,4 +266,51 @@ export class SqliteAdapter implements DatabaseInterface {
|
|||||||
deleteExpiredSessions(): void {
|
deleteExpiredSessions(): void {
|
||||||
this.db.prepare('DELETE FROM sessions WHERE expires_at < ?').run(Date.now());
|
this.db.prepare('DELETE FROM sessions WHERE expires_at < ?').run(Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Notifications ──────────────────────────────────
|
||||||
|
listNotifications(userId: string): DBNotification[] {
|
||||||
|
return this.db.prepare('SELECT * FROM notifications WHERE user_id = ? ORDER BY created_at DESC').all(userId) as DBNotification[];
|
||||||
|
}
|
||||||
|
|
||||||
|
getNotification(id: string): DBNotification | null {
|
||||||
|
return this.db.prepare('SELECT * FROM notifications WHERE id = ?').get(id) as DBNotification | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
createNotification(data: Partial<DBNotification>): DBNotification {
|
||||||
|
const id = data.id ?? `notif-${Date.now()}`;
|
||||||
|
this.db.prepare(
|
||||||
|
'INSERT INTO notifications (id, user_id, type, title, message, read) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
).run(id, data.user_id!, data.type ?? 'info', data.title!, data.message!, data.read ?? 0);
|
||||||
|
return this.db.prepare('SELECT * FROM notifications WHERE id = ?').get(id) as DBNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
markNotificationRead(id: string): boolean {
|
||||||
|
return this.db.prepare('UPDATE notifications SET read = 1 WHERE id = ?').run(id).changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteNotification(id: string): boolean {
|
||||||
|
return this.db.prepare('DELETE FROM notifications WHERE id = ?').run(id).changes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Project Shares ─────────────────────────────────
|
||||||
|
listProjectShares(projectId: string): DBProjectShare[] {
|
||||||
|
return this.db.prepare('SELECT * FROM project_shares WHERE project_id = ? ORDER BY created_at DESC').all(projectId) as DBProjectShare[];
|
||||||
|
}
|
||||||
|
|
||||||
|
getProjectShare(id: string): DBProjectShare | null {
|
||||||
|
return this.db.prepare('SELECT * FROM project_shares WHERE id = ?').get(id) as DBProjectShare | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
createProjectShare(data: Partial<DBProjectShare>): DBProjectShare {
|
||||||
|
const id = data.id ?? `share-${Date.now()}`;
|
||||||
|
const shareToken = data.share_token ?? randomUUID();
|
||||||
|
this.db.prepare(
|
||||||
|
'INSERT INTO project_shares (id, project_id, shared_with_email, shared_by, permission, share_token) VALUES (?, ?, ?, ?, ?, ?)',
|
||||||
|
).run(id, data.project_id!, data.shared_with_email!, data.shared_by!, data.permission ?? 'view', shareToken);
|
||||||
|
return this.db.prepare('SELECT * FROM project_shares WHERE id = ?').get(id) as DBProjectShare;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteProjectShare(id: string): boolean {
|
||||||
|
return this.db.prepare('DELETE FROM project_shares WHERE id = ?').run(id).changes > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,3 +105,31 @@ CREATE INDEX IF NOT EXISTS idx_layers_drawing ON layers(drawing_id);
|
|||||||
CREATE INDEX IF NOT EXISTS idx_elements_drawing ON elements(drawing_id);
|
CREATE INDEX IF NOT EXISTS idx_elements_drawing ON elements(drawing_id);
|
||||||
CREATE INDEX IF NOT EXISTS idx_elements_layer ON elements(layer_id);
|
CREATE INDEX IF NOT EXISTS idx_elements_layer ON elements(layer_id);
|
||||||
CREATE INDEX IF NOT EXISTS idx_blocks_drawing ON blocks(drawing_id);
|
CREATE INDEX IF NOT EXISTS idx_blocks_drawing ON blocks(drawing_id);
|
||||||
|
|
||||||
|
-- ─── Notifications ───────────────────────────────────
|
||||||
|
CREATE TABLE IF NOT EXISTS notifications (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
user_id TEXT NOT NULL,
|
||||||
|
type TEXT NOT NULL DEFAULT 'info',
|
||||||
|
title TEXT NOT NULL,
|
||||||
|
message TEXT NOT NULL,
|
||||||
|
read INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ─── Project Shares ──────────────────────────────────
|
||||||
|
CREATE TABLE IF NOT EXISTS project_shares (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
project_id TEXT NOT NULL,
|
||||||
|
shared_with_email TEXT NOT NULL,
|
||||||
|
shared_by TEXT NOT NULL,
|
||||||
|
permission TEXT NOT NULL DEFAULT 'view' CHECK(permission IN ('view','edit','admin')),
|
||||||
|
share_token TEXT UNIQUE,
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (shared_by) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_notifications_user ON notifications(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_shares_project ON project_shares(project_id);
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Notifications Routes – List, create, mark read, delete notifications
|
||||||
|
*/
|
||||||
|
import type { FastifyInstance } from 'fastify';
|
||||||
|
import type { DatabaseInterface } from '../database/DatabaseInterface.js';
|
||||||
|
import type { AuthService } from '../auth/AuthService.js';
|
||||||
|
|
||||||
|
function extractToken(request: any): string | null {
|
||||||
|
const auth = request.headers?.authorization;
|
||||||
|
if (auth && auth.startsWith('Bearer ')) return auth.slice(7);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function registerNotificationRoutes(fastify: FastifyInstance, db: DatabaseInterface, authService: AuthService) {
|
||||||
|
// List notifications for current user
|
||||||
|
fastify.get('/api/notifications', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
return db.listNotifications(user.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create notification (only for self)
|
||||||
|
fastify.post('/api/notifications', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const body = request.body as { type?: string; title?: string; message?: string };
|
||||||
|
if (!body.title || !body.message) return reply.code(400).send({ error: 'title and message are required' });
|
||||||
|
const validTypes = ['info', 'share', 'warning', 'error'];
|
||||||
|
const type = validTypes.includes(body.type ?? '') ? body.type! : 'info';
|
||||||
|
return reply.code(201).send(db.createNotification({
|
||||||
|
user_id: user.id,
|
||||||
|
type,
|
||||||
|
title: body.title,
|
||||||
|
message: body.message,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark notification as read (ownership check)
|
||||||
|
fastify.patch('/api/notifications/:id/read', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const { id } = request.params as { id: string };
|
||||||
|
const notif = db.getNotification(id);
|
||||||
|
if (!notif) return reply.code(404).send({ error: 'Notification not found' });
|
||||||
|
if (notif.user_id !== user.id) return reply.code(403).send({ error: 'Forbidden' });
|
||||||
|
const ok = db.markNotificationRead(id);
|
||||||
|
if (!ok) return reply.code(404).send({ error: 'Notification not found' });
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Delete notification (ownership check)
|
||||||
|
fastify.delete('/api/notifications/:id', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const { id } = request.params as { id: string };
|
||||||
|
const notif = db.getNotification(id);
|
||||||
|
if (!notif) return reply.code(404).send({ error: 'Notification not found' });
|
||||||
|
if (notif.user_id !== user.id) return reply.code(403).send({ error: 'Forbidden' });
|
||||||
|
const ok = db.deleteNotification(id);
|
||||||
|
if (!ok) return reply.code(404).send({ error: 'Notification not found' });
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
* Project Shares Routes – List, create, delete project shares
|
||||||
|
*/
|
||||||
|
import type { FastifyInstance } from 'fastify';
|
||||||
|
import type { DatabaseInterface } from '../database/DatabaseInterface.js';
|
||||||
|
import type { AuthService } from '../auth/AuthService.js';
|
||||||
|
|
||||||
|
function extractToken(request: any): string | null {
|
||||||
|
const auth = request.headers?.authorization;
|
||||||
|
if (auth && auth.startsWith('Bearer ')) return auth.slice(7);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VALID_PERMISSIONS = ['view', 'edit', 'admin'];
|
||||||
|
|
||||||
|
export function registerShareRoutes(fastify: FastifyInstance, db: DatabaseInterface, authService: AuthService) {
|
||||||
|
// List shares for a project (owner only)
|
||||||
|
fastify.get('/api/projects/:projectId/shares', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const { projectId } = request.params as { projectId: string };
|
||||||
|
const project = db.getProject(projectId);
|
||||||
|
if (!project) return reply.code(404).send({ error: 'Project not found' });
|
||||||
|
if (project.owner_id !== user.id) return reply.code(403).send({ error: 'Forbidden' });
|
||||||
|
return db.listProjectShares(projectId);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a project share (owner only)
|
||||||
|
fastify.post('/api/projects/:projectId/shares', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const { projectId } = request.params as { projectId: string };
|
||||||
|
const project = db.getProject(projectId);
|
||||||
|
if (!project) return reply.code(404).send({ error: 'Project not found' });
|
||||||
|
if (project.owner_id !== user.id) return reply.code(403).send({ error: 'Forbidden' });
|
||||||
|
const body = request.body as { shared_with_email?: string; permission?: string };
|
||||||
|
if (!body.shared_with_email) return reply.code(400).send({ error: 'shared_with_email is required' });
|
||||||
|
const permission = VALID_PERMISSIONS.includes(body.permission ?? '') ? body.permission! : 'view';
|
||||||
|
|
||||||
|
const share = db.createProjectShare({
|
||||||
|
project_id: projectId,
|
||||||
|
shared_with_email: body.shared_with_email,
|
||||||
|
shared_by: user.id,
|
||||||
|
permission,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a notification for the shared user if they exist
|
||||||
|
const sharedUser = db.getUserByEmail(body.shared_with_email);
|
||||||
|
if (sharedUser) {
|
||||||
|
db.createNotification({
|
||||||
|
user_id: sharedUser.id,
|
||||||
|
type: 'share',
|
||||||
|
title: 'Projekt geteilt',
|
||||||
|
message: `${user.name} hat ein Projekt mit Ihnen geteilt: ${project.name}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return reply.code(201).send(share);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Delete a project share (owner only)
|
||||||
|
fastify.delete('/api/shares/:id', async (request, reply) => {
|
||||||
|
const token = extractToken(request);
|
||||||
|
if (!token) return reply.code(401).send({ error: 'Authentication required' });
|
||||||
|
const user = authService.getUserFromSession(token);
|
||||||
|
if (!user) return reply.code(401).send({ error: 'Invalid or expired session' });
|
||||||
|
const { id } = request.params as { id: string };
|
||||||
|
const share = db.getProjectShare(id);
|
||||||
|
if (!share) return reply.code(404).send({ error: 'Share not found' });
|
||||||
|
const project = db.getProject(share.project_id);
|
||||||
|
if (!project) return reply.code(404).send({ error: 'Project not found' });
|
||||||
|
if (project.owner_id !== user.id) return reply.code(403).send({ error: 'Forbidden' });
|
||||||
|
const ok = db.deleteProjectShare(id);
|
||||||
|
if (!ok) return reply.code(404).send({ error: 'Share not found' });
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -57,6 +57,8 @@ export async function createServer(opts: ServerOptions) {
|
|||||||
const { registerAuthRoutes } = await import('./routes/auth.js');
|
const { registerAuthRoutes } = await import('./routes/auth.js');
|
||||||
const { registerUserRoutes } = await import('./routes/users.js');
|
const { registerUserRoutes } = await import('./routes/users.js');
|
||||||
const { registerAIRoutes } = await import('./routes/ai.js');
|
const { registerAIRoutes } = await import('./routes/ai.js');
|
||||||
|
const { registerNotificationRoutes } = await import('./routes/notifications.js');
|
||||||
|
const { registerShareRoutes } = await import('./routes/shares.js');
|
||||||
|
|
||||||
const authService = new AuthService(opts.db);
|
const authService = new AuthService(opts.db);
|
||||||
|
|
||||||
@@ -69,6 +71,8 @@ export async function createServer(opts: ServerOptions) {
|
|||||||
registerSettingsRoutes(fastify, opts.db);
|
registerSettingsRoutes(fastify, opts.db);
|
||||||
registerUserRoutes(fastify, opts.db, authService);
|
registerUserRoutes(fastify, opts.db, authService);
|
||||||
registerAIRoutes(fastify, authService);
|
registerAIRoutes(fastify, authService);
|
||||||
|
registerNotificationRoutes(fastify, opts.db, authService);
|
||||||
|
registerShareRoutes(fastify, opts.db, authService);
|
||||||
|
|
||||||
// Yjs collaboration WebSocket
|
// Yjs collaboration WebSocket
|
||||||
registerYjsWebSocket(fastify);
|
registerYjsWebSocket(fastify);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
cd /data/web-cad-neu
|
cd /data/web-cad-neu
|
||||||
echo "[$(date)] Pulling latest code..."
|
echo "[$(date)] Pulling latest code..."
|
||||||
git pull origin main
|
git pull origin master
|
||||||
echo "[$(date)] Building backend image..."
|
echo "[$(date)] Building backend image..."
|
||||||
docker build -t web-cad-neu-backend:latest ./backend
|
docker build -t web-cad-neu-backend:latest ./backend
|
||||||
echo "[$(date)] Building frontend image..."
|
echo "[$(date)] Building frontend image..."
|
||||||
|
|||||||
+127
-7
@@ -18,6 +18,7 @@ import StatusBar from './components/StatusBar';
|
|||||||
import MobileDrawers from './components/MobileDrawers';
|
import MobileDrawers from './components/MobileDrawers';
|
||||||
import BackgroundImport from './components/BackgroundImport';
|
import BackgroundImport from './components/BackgroundImport';
|
||||||
import HistoryPanel from './components/HistoryPanel';
|
import HistoryPanel from './components/HistoryPanel';
|
||||||
|
import SettingsModal from './components/SettingsModal';
|
||||||
import { BackgroundService, type BackgroundConfig } from './services/backgroundService';
|
import { BackgroundService, type BackgroundConfig } from './services/backgroundService';
|
||||||
import { HistoryManager, type CADStateSnapshot, type HistoryEntry } from './history';
|
import { HistoryManager, type CADStateSnapshot, type HistoryEntry } from './history';
|
||||||
import { getCommandRegistry } from './services/commandRegistry';
|
import { getCommandRegistry } from './services/commandRegistry';
|
||||||
@@ -146,6 +147,10 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
// Mobile drawers
|
// Mobile drawers
|
||||||
const [mobileLeftOpen, setMobileLeftOpen] = useState(false);
|
const [mobileLeftOpen, setMobileLeftOpen] = useState(false);
|
||||||
const [mobileRightOpen, setMobileRightOpen] = 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');
|
const [activeDrawerTab, setActiveDrawerTab] = useState<DrawerTab>('tool');
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
@@ -263,6 +268,8 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
collab.loadFromState({ elements: data.elements, layers: data.layers, blocks: data.blocks });
|
collab.loadFromState({ elements: data.elements, layers: data.layers, blocks: data.blocks });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (cancelled) return;
|
||||||
|
if (err instanceof Error && err.message.includes('Superseded')) return;
|
||||||
console.error('Failed to load project:', err);
|
console.error('Failed to load project:', err);
|
||||||
setSavedStatus('Fehler beim Laden');
|
setSavedStatus('Fehler beim Laden');
|
||||||
}
|
}
|
||||||
@@ -297,13 +304,19 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
setElements(merged);
|
setElements(merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
const sameLayers = collab.layers.length === layers.length &&
|
// Never overwrite local layers with empty remote layers (prevents losing initialLayers)
|
||||||
collab.layers.every((l, i) => l.id === layers[i]?.id);
|
if (collab.layers.length > 0) {
|
||||||
if (!sameLayers) setLayers(collab.layers);
|
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 &&
|
// Never overwrite local blocks with empty remote blocks (prevents losing defaultBlocks)
|
||||||
collab.blocks.every((b, i) => b.id === blocks[i]?.id);
|
if (collab.blocks.length > 0) {
|
||||||
if (!sameBlocks) setBlocks(collab.blocks);
|
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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [collab.elements, collab.layers, collab.blocks, collab.status]);
|
}, [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' }]);
|
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) => {
|
const handleBgApply = useCallback((config: BackgroundConfig, _image: HTMLImageElement | null) => {
|
||||||
setBgConfig(config);
|
setBgConfig(config);
|
||||||
setBgImportOpen(false);
|
setBgImportOpen(false);
|
||||||
@@ -936,18 +1032,34 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
onRedo={handleRedo}
|
onRedo={handleRedo}
|
||||||
onThemeToggle={handleThemeToggle}
|
onThemeToggle={handleThemeToggle}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
onOpenSettings={() => setSettingsOpen(true)}
|
||||||
|
onOpenLeftDrawer={() => setMobileLeftOpen(true)}
|
||||||
|
onOpenRightDrawer={() => setMobileRightOpen(true)}
|
||||||
/>
|
/>
|
||||||
<RibbonBar
|
<RibbonBar
|
||||||
activeTab={activeRibbonTab}
|
activeTab={activeRibbonTab}
|
||||||
onTabChange={setActiveRibbonTab}
|
onTabChange={setActiveRibbonTab}
|
||||||
onAction={handleRibbonAction}
|
onAction={handleRibbonAction}
|
||||||
/>
|
/>
|
||||||
<div className="app-body">
|
<div className={`app-body${leftSidebarCollapsed ? ' left-collapsed' : ''}${rightSidebarCollapsed ? ' right-collapsed' : ''}`}>
|
||||||
<LeftSidebar
|
<LeftSidebar
|
||||||
activeTool={activeTool}
|
activeTool={activeTool}
|
||||||
onToolChange={handleToolChange}
|
onToolChange={handleToolChange}
|
||||||
selectedTemplate={selectedTemplate}
|
selectedTemplate={selectedTemplate}
|
||||||
onTemplateSelect={handleTemplateSelect}
|
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
|
<CanvasArea
|
||||||
cursorPos={cursorPos}
|
cursorPos={cursorPos}
|
||||||
@@ -1010,6 +1122,13 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
onKISend={handleKISend}
|
onKISend={handleKISend}
|
||||||
onKISuggestionClick={handleSuggestionClick}
|
onKISuggestionClick={handleSuggestionClick}
|
||||||
kiLoading={kiLoading}
|
kiLoading={kiLoading}
|
||||||
|
className={mobileRightOpen ? 'open' : ''}
|
||||||
|
onCollapse={() => setMobileRightOpen(false)}
|
||||||
|
collapsed={rightSidebarCollapsed}
|
||||||
|
onToggleCollapse={() => setRightSidebarCollapsed((p) => !p)}
|
||||||
|
onReorder={handleReorderLayer}
|
||||||
|
onAddSubLayer={handleAddSubLayer}
|
||||||
|
onUpdateElement={handleUpdateElement}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CommandLine
|
<CommandLine
|
||||||
@@ -1040,6 +1159,7 @@ const CADEditor: React.FC<CADEditorProps> = ({ projectId, token, onNavigateBack
|
|||||||
onCloseRight={() => setMobileRightOpen(false)}
|
onCloseRight={() => setMobileRightOpen(false)}
|
||||||
onRightTabChange={setActiveDrawerTab}
|
onRightTabChange={setActiveDrawerTab}
|
||||||
/>
|
/>
|
||||||
|
<SettingsModal open={settingsOpen} onClose={() => setSettingsOpen(false)} />
|
||||||
<BackgroundImport
|
<BackgroundImport
|
||||||
open={bgImportOpen}
|
open={bgImportOpen}
|
||||||
onClose={() => setBgImportOpen(false)}
|
onClose={() => setBgImportOpen(false)}
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
|||||||
selectedId={activeLayerId}
|
selectedId={activeLayerId}
|
||||||
onSelect={onSelectLayer}
|
onSelect={onSelectLayer}
|
||||||
onReorder={onReorder}
|
onReorder={onReorder}
|
||||||
|
draggable={true}
|
||||||
renderIcon={(node) => node.icon}
|
renderIcon={(node) => node.icon}
|
||||||
renderActions={(node) => {
|
renderActions={(node) => {
|
||||||
const layer = layers.find((l) => l.id === node.id);
|
const layer = layers.find((l) => l.id === node.id);
|
||||||
@@ -140,16 +141,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
|||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onToggleLayer(layer.id); }}
|
onClick={(e) => { e.stopPropagation(); onToggleLayer(layer.id); }}
|
||||||
title={layer.visible ? 'Sichtbar' : 'Versteckt'}
|
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>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onToggleLock?.(layer.id); }}
|
onClick={(e) => { e.stopPropagation(); onToggleLock?.(layer.id); }}
|
||||||
title={layer.locked ? 'Gesperrt' : 'Entsperrt'}
|
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>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); handleAddSubLayer(layer.id); }}
|
onClick={(e) => { e.stopPropagation(); handleAddSubLayer(layer.id); }}
|
||||||
@@ -161,16 +162,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
|||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onDuplicateLayer?.(layer.id); }}
|
onClick={(e) => { e.stopPropagation(); onDuplicateLayer?.(layer.id); }}
|
||||||
title="Duplizieren"
|
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>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onDeleteLayer?.(layer.id); }}
|
onClick={(e) => { e.stopPropagation(); onDeleteLayer?.(layer.id); }}
|
||||||
title="Loschen"
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -183,16 +184,16 @@ const LayerPanel: React.FC<LayerPanelProps> = ({
|
|||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onToggleElementVisible?.(element.id); }}
|
onClick={(e) => { e.stopPropagation(); onToggleElementVisible?.(element.id); }}
|
||||||
title={isVisible ? 'Sichtbar' : 'Versteckt'}
|
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>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => { e.stopPropagation(); onElementsDeleted?.([element.id]); }}
|
onClick={(e) => { e.stopPropagation(); onElementsDeleted?.([element.id]); }}
|
||||||
title="Loschen"
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ const sections: Array<{ label: string; tools: ToolDef[] }> = [
|
|||||||
{ label: 'Bestuhlung', tools: sectionBestuhlung },
|
{ 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 (
|
return (
|
||||||
<aside className="leftbar" aria-label="Werkzeugpalette">
|
<aside className={`leftbar${className ? ' ' + className : ''}${collapsed ? ' leftbar-collapsed' : ''}`} aria-label="Werkzeugpalette">
|
||||||
<div className="leftbar-header">
|
<div className="leftbar-header">
|
||||||
<span className="leftbar-title">Werkzeuge</span>
|
<span className="leftbar-title">Werkzeuge</span>
|
||||||
<button className="leftbar-toggle" aria-label="Linke Leiste ausblenden" onClick={onCollapse}>
|
<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>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
<div className="leftbar-footer">
|
<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">
|
<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>
|
<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>
|
</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 React from 'react';
|
||||||
import type { PropertiesPanelProps } from '../types/ui.types';
|
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 el = selectedElement;
|
||||||
const x = el ? String(el.x) : '0';
|
const x = el ? String(el.x) : '0';
|
||||||
const y = el ? String(el.y) : '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">
|
||||||
<div className="panel-section-title">
|
<div className="panel-section-title">
|
||||||
<span>Auswahl · 1 Stuhl</span>
|
<span>Auswahl · 1 Stuhl</span>
|
||||||
<button style={{ color: 'var(--color-text-muted)', fontSize: '11px' }} title="Mehr Optionen">
|
<div style={{ display: 'flex', gap: '4px' }}>
|
||||||
<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>
|
{onDelete && el && (
|
||||||
</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const tabs: Array<{ id: RightPanel; label: string; svg: React.ReactNode; badge?:
|
|||||||
|
|
||||||
const RightSidebar: React.FC<RightSidebarProps> = ({
|
const RightSidebar: React.FC<RightSidebarProps> = ({
|
||||||
activePanel, onPanelChange, selectedElement, layers, blocks,
|
activePanel, onPanelChange, selectedElement, layers, blocks,
|
||||||
|
className,
|
||||||
activeLayerId, onSelectLayer, onAddLayer, onToggleLayer,
|
activeLayerId, onSelectLayer, onAddLayer, onToggleLayer,
|
||||||
onDeleteLayer, onRenameLayer, onDuplicateLayer, onToggleLock,
|
onDeleteLayer, onRenameLayer, onDuplicateLayer, onToggleLock,
|
||||||
onReorder, onAddSubLayer,
|
onReorder, onAddSubLayer,
|
||||||
@@ -22,9 +23,20 @@ const RightSidebar: React.FC<RightSidebarProps> = ({
|
|||||||
onRenameBlock, onDuplicateBlock, onDeleteBlock, onSvgImport, onSaveGroupAsBlock,
|
onRenameBlock, onDuplicateBlock, onDeleteBlock, onSvgImport, onSaveGroupAsBlock,
|
||||||
onBlockCategoryChange, onBlockSearch, onDragBlock,
|
onBlockCategoryChange, onBlockSearch, onDragBlock,
|
||||||
kiMessages, kiSuggestions, onKISend, onKISuggestionClick, kiLoading, onUpdateElement,
|
kiMessages, kiSuggestions, onKISend, onKISuggestionClick, kiLoading, onUpdateElement,
|
||||||
|
onCollapse,
|
||||||
|
collapsed,
|
||||||
|
onToggleCollapse,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
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">
|
<div className="rightbar-tabs" role="tablist">
|
||||||
{tabs.map((tab) => (
|
{tabs.map((tab) => (
|
||||||
<button
|
<button
|
||||||
@@ -44,7 +56,7 @@ const RightSidebar: React.FC<RightSidebarProps> = ({
|
|||||||
|
|
||||||
<div className="rightbar-content">
|
<div className="rightbar-content">
|
||||||
<div className={`rightbar-panel${activePanel === 'tool' ? ' active' : ''}`} data-panel-content="tool">
|
<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;
|
if (!selectedElement || !onUpdateElement) return;
|
||||||
const updated = { ...selectedElement };
|
const updated = { ...selectedElement };
|
||||||
if (key === 'x' || key === 'y' || key === 'width' || key === 'height') {
|
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 React from 'react';
|
||||||
import type { TopbarProps } from '../types/ui.types';
|
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 (
|
return (
|
||||||
<header className="topbar" role="banner">
|
<header className="topbar" role="banner">
|
||||||
<div className="topbar-left">
|
<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>
|
<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>
|
</button>
|
||||||
<div className="app-logo" aria-hidden="true">
|
<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="de">DE</option>
|
||||||
<option value="en">EN</option>
|
<option value="en">EN</option>
|
||||||
</select>
|
</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">
|
<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>
|
<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>
|
</button>
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ export class InteractionEngine {
|
|||||||
private onTextEdit?: (el: CADElement) => void;
|
private onTextEdit?: (el: CADElement) => void;
|
||||||
private onSelectionChange?: (selectedIds: string[]) => void;
|
private onSelectionChange?: (selectedIds: string[]) => void;
|
||||||
private animationFrame: number | null = null;
|
private animationFrame: number | null = null;
|
||||||
|
private boundKeyDown: EventListener;
|
||||||
|
private boundMouseMove: EventListener;
|
||||||
|
private boundMouseUp: EventListener;
|
||||||
|
private boundPointerCancel: EventListener;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
@@ -89,6 +93,10 @@ export class InteractionEngine {
|
|||||||
undoKey: 'z',
|
undoKey: 'z',
|
||||||
redoKey: 'y',
|
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 {
|
setElements(elements: CADElement[]): void {
|
||||||
@@ -156,13 +164,14 @@ export class InteractionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
attach(): void {
|
attach(): void {
|
||||||
this.addListener('mousedown', this.onMouseDown.bind(this) as EventListener);
|
this.addListener('pointerdown', this.onMouseDown.bind(this) as EventListener);
|
||||||
this.addListener('mousemove', this.onMouseMove.bind(this) as EventListener);
|
document.addEventListener('pointermove', this.boundMouseMove);
|
||||||
this.addListener('mouseup', this.onMouseUp.bind(this) as EventListener);
|
document.addEventListener('pointerup', this.boundMouseUp);
|
||||||
|
document.addEventListener('pointercancel', this.boundPointerCancel);
|
||||||
this.addListener('dblclick', this.onDoubleClick.bind(this) as EventListener);
|
this.addListener('dblclick', this.onDoubleClick.bind(this) as EventListener);
|
||||||
this.addListener('wheel', this.onWheel.bind(this) as EventListener, { passive: false } as AddEventListenerOptions);
|
this.addListener('wheel', this.onWheel.bind(this) as EventListener, { passive: false } as AddEventListenerOptions);
|
||||||
this.addListener('contextmenu', this.onContextMenu.bind(this) as EventListener);
|
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 {
|
detach(): void {
|
||||||
@@ -170,7 +179,10 @@ export class InteractionEngine {
|
|||||||
this.canvas.removeEventListener(type, fn);
|
this.canvas.removeEventListener(type, fn);
|
||||||
}
|
}
|
||||||
this.eventListeners = [];
|
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) {
|
if (this.animationFrame !== null) {
|
||||||
cancelAnimationFrame(this.animationFrame);
|
cancelAnimationFrame(this.animationFrame);
|
||||||
this.animationFrame = null;
|
this.animationFrame = null;
|
||||||
@@ -214,7 +226,7 @@ export class InteractionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onMouseDown(e: MouseEvent): void {
|
private onMouseDown(e: MouseEvent): void {
|
||||||
e.preventDefault();
|
try { this.canvas.setPointerCapture((e as any).pointerId); } catch {}
|
||||||
this.isMouseDown = true;
|
this.isMouseDown = true;
|
||||||
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||||
|
|
||||||
@@ -289,6 +301,10 @@ export class InteractionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onMouseMove(e: MouseEvent): void {
|
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 };
|
this.lastMouseScreen = { x: e.clientX, y: e.clientY };
|
||||||
const raw = this.getWorldCoords(e);
|
const raw = this.getWorldCoords(e);
|
||||||
this.onCursorMoved?.(raw.x, raw.y);
|
this.onCursorMoved?.(raw.x, raw.y);
|
||||||
@@ -329,7 +345,7 @@ export class InteractionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onMouseUp(e: MouseEvent): void {
|
private onMouseUp(e: MouseEvent): void {
|
||||||
e.preventDefault();
|
try { this.canvas.releasePointerCapture((e as any).pointerId); } catch {}
|
||||||
this.isMouseDown = false;
|
this.isMouseDown = false;
|
||||||
|
|
||||||
if (e.button === 2 || (e.button === 1 && this.state.phase === 'panning')) {
|
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 final = this.applyOrtho(snapped.x, snapped.y);
|
||||||
const tool = this.state.activeTool;
|
const tool = this.state.activeTool;
|
||||||
// For 2-point tools: use mouseup position as second point
|
// 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.state.points.push(final);
|
||||||
this.confirmDraw();
|
this.confirmDraw();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import { useAuth } from '../contexts/AuthContext';
|
import { useAuth } from '../contexts/AuthContext';
|
||||||
|
import { NotificationPanel } from '../components/NotificationPanel';
|
||||||
|
import { ShareDialog } from '../components/ShareDialog';
|
||||||
|
|
||||||
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
|||||||
const [showCreate, setShowCreate] = useState(false);
|
const [showCreate, setShowCreate] = useState(false);
|
||||||
const [newName, setNewName] = useState('');
|
const [newName, setNewName] = useState('');
|
||||||
const [newDesc, setNewDesc] = useState('');
|
const [newDesc, setNewDesc] = useState('');
|
||||||
|
const [shareProjectId, setShareProjectId] = useState<string | null>(null);
|
||||||
|
|
||||||
const fetchProjects = useCallback(async () => {
|
const fetchProjects = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -86,7 +89,10 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
|||||||
<h1>Web CAD</h1>
|
<h1>Web CAD</h1>
|
||||||
<span className="dashboard-user">{user?.name} ({user?.role})</span>
|
<span className="dashboard-user">{user?.name} ({user?.role})</span>
|
||||||
</div>
|
</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>
|
</header>
|
||||||
|
|
||||||
<div className="dashboard-content">
|
<div className="dashboard-content">
|
||||||
@@ -133,18 +139,35 @@ export function Dashboard({ onOpenProject }: DashboardProps) {
|
|||||||
{project.description && <p>{project.description}</p>}
|
{project.description && <p>{project.description}</p>}
|
||||||
<div className="dashboard-project-meta">
|
<div className="dashboard-project-meta">
|
||||||
<span>Erstellt: {new Date(project.created_at).toLocaleDateString('de-DE')}</span>
|
<span>Erstellt: {new Date(project.created_at).toLocaleDateString('de-DE')}</span>
|
||||||
<button
|
<div className="dashboard-project-actions">
|
||||||
className="dashboard-delete-btn"
|
<button
|
||||||
onClick={(e) => handleDelete(project.id, e)}
|
className="dashboard-share-btn"
|
||||||
>
|
onClick={(e) => { e.stopPropagation(); setShareProjectId(project.id); }}
|
||||||
Löschen
|
>
|
||||||
</button>
|
Teilen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="dashboard-delete-btn"
|
||||||
|
onClick={(e) => handleDelete(project.id, e)}
|
||||||
|
>
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{token && (
|
||||||
|
<ShareDialog
|
||||||
|
token={token}
|
||||||
|
projectId={shareProjectId ?? ''}
|
||||||
|
open={!!shareProjectId}
|
||||||
|
onClose={() => setShareProjectId(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,6 +387,84 @@ export async function loadProjectDataTyped(token: string, projectId: string): Pr
|
|||||||
return promise;
|
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 };
|
export { API_BASE };
|
||||||
|
|
||||||
// ─── AI Copilot ─────────────────────────────────────────
|
// ─── AI Copilot ─────────────────────────────────────────
|
||||||
|
|||||||
+206
-4
@@ -318,6 +318,7 @@ a:hover { text-decoration: underline; }
|
|||||||
}
|
}
|
||||||
.hamburger-btn:hover { background: var(--color-surface-2); }
|
.hamburger-btn:hover { background: var(--color-surface-2); }
|
||||||
.hamburger-btn svg { width: 20px; height: 20px; }
|
.hamburger-btn svg { width: 20px; height: 20px; }
|
||||||
|
.mobile-drawer-toggle { display: none; }
|
||||||
|
|
||||||
/* Right vertical tab bar (mobile only, HIDDEN by default on desktop) */
|
/* Right vertical tab bar (mobile only, HIDDEN by default on desktop) */
|
||||||
.right-tab-bar { display: none; }
|
.right-tab-bar { display: none; }
|
||||||
@@ -1195,7 +1196,8 @@ a:hover { text-decoration: underline; }
|
|||||||
|
|
||||||
/* Topbar: hamburger left, project center, notifications right */
|
/* Topbar: hamburger left, project center, notifications right */
|
||||||
.hamburger-btn { display: flex; }
|
.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;
|
display: none;
|
||||||
}
|
}
|
||||||
.topbar { padding: 0 8px; gap: 6px; }
|
.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 */
|
/* Main area: NO left/right desktop columns, canvas + right tab bar */
|
||||||
.app-body {
|
.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 (vertical icon bar, ALWAYS visible on mobile) */
|
||||||
.right-tab-bar {
|
.right-tab-bar {
|
||||||
@@ -1402,7 +1458,7 @@ a:hover { text-decoration: underline; }
|
|||||||
.status-item.hide-mobile { display: none; }
|
.status-item.hide-mobile { display: none; }
|
||||||
|
|
||||||
/* SVG canvas: ensure it's scrollable/zoomable on touch */
|
/* 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) */
|
/* Very small screens (<480px) */
|
||||||
@@ -2010,3 +2066,149 @@ body.drawer-open { overflow: hidden; }
|
|||||||
padding: 3px 8px;
|
padding: 3px 8px;
|
||||||
border-radius: 4px;
|
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;
|
onThemeToggle: () => void;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
onOpenSettings?: () => void;
|
onOpenSettings?: () => void;
|
||||||
|
onOpenLeftDrawer?: () => void;
|
||||||
|
onOpenRightDrawer?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingsModalProps {
|
export interface SettingsModalProps {
|
||||||
@@ -84,6 +86,19 @@ export interface LeftSidebarProps {
|
|||||||
selectedTemplate?: string | null;
|
selectedTemplate?: string | null;
|
||||||
onTemplateSelect?: (templateName: string | null) => void;
|
onTemplateSelect?: (templateName: string | null) => void;
|
||||||
onCollapse?: () => 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 {
|
export interface CanvasAreaProps {
|
||||||
@@ -155,12 +170,17 @@ export interface RightSidebarProps {
|
|||||||
onKISuggestionClick?: (suggestion: KISuggestion) => void;
|
onKISuggestionClick?: (suggestion: KISuggestion) => void;
|
||||||
kiLoading?: boolean;
|
kiLoading?: boolean;
|
||||||
onUpdateElement?: (el: CADElement) => void;
|
onUpdateElement?: (el: CADElement) => void;
|
||||||
|
className?: string;
|
||||||
|
onCollapse?: () => void;
|
||||||
|
collapsed?: boolean;
|
||||||
|
onToggleCollapse?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PropertiesPanelProps {
|
export interface PropertiesPanelProps {
|
||||||
selectedElement: CADElement | null;
|
selectedElement: CADElement | null;
|
||||||
layers: CADLayer[];
|
layers: CADLayer[];
|
||||||
onUpdateProperty: (key: string, value: unknown) => void;
|
onUpdateProperty: (key: string, value: unknown) => void;
|
||||||
|
onDelete?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LayerPanelProps {
|
export interface LayerPanelProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user