feat(rack): add shift-click context modal for connections with color and edge type configurability
This commit is contained in:
@@ -6,14 +6,25 @@ const router = Router();
|
||||
// POST /api/connections
|
||||
router.post('/', async (req, res, next) => {
|
||||
try {
|
||||
const { fromPortId, toPortId, color, label } = req.body;
|
||||
const conn = await connService.createConnection({ fromPortId, toPortId, color, label });
|
||||
const { fromPortId, toPortId, color, label, edgeType } = req.body;
|
||||
const conn = await connService.createConnection({ fromPortId, toPortId, color, label, edgeType });
|
||||
res.status(201).json(conn);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// PUT /api/connections/:id
|
||||
router.put('/:id', async (req, res, next) => {
|
||||
try {
|
||||
const { color, label, edgeType } = req.body;
|
||||
const conn = await connService.updateConnection(req.params.id, { color, label, edgeType });
|
||||
res.json(conn);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/connections/:id
|
||||
router.delete('/:id', async (req, res, next) => {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { prisma } from '../lib/prisma';
|
||||
import { AppError } from '../types/index';
|
||||
|
||||
export async function createConnection(data: { fromPortId: string; toPortId: string; color?: string; label?: string }) {
|
||||
export async function createConnection(data: { fromPortId: string; toPortId: string; color?: string; label?: string; edgeType?: string }) {
|
||||
// Check if both ports exist
|
||||
const [from, to] = await Promise.all([
|
||||
prisma.port.findUnique({ where: { id: data.fromPortId } }),
|
||||
@@ -22,6 +22,13 @@ export async function deleteConnection(id: string) {
|
||||
return prisma.connection.delete({ where: { id } });
|
||||
}
|
||||
|
||||
export async function updateConnection(id: string, data: Partial<{ color: string; label: string; edgeType: string }>) {
|
||||
return prisma.connection.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteByPorts(portId1: string, portId2: string) {
|
||||
return prisma.connection.deleteMany({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user