mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Network & Edit mode
This commit is contained in:
@@ -14,6 +14,9 @@ export async function GET(request: NextRequest) {
|
||||
where: {
|
||||
id: Number(siteId),
|
||||
},
|
||||
include: {
|
||||
networks: true, // Include all network relationships
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ site });
|
||||
|
||||
31
app/api/sites/networks/add/route.ts
Normal file
31
app/api/sites/networks/add/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import prisma from "@/app/prisma";
|
||||
|
||||
interface Body {
|
||||
siteId: number;
|
||||
name: string;
|
||||
ipv4Subnet?: string;
|
||||
ipv6Subnet?: string;
|
||||
gateway?: string;
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const body: Body = await request.json();
|
||||
|
||||
try {
|
||||
const network = await prisma.network.create({
|
||||
data: {
|
||||
siteId: body.siteId,
|
||||
name: body.name,
|
||||
ipv4Subnet: body.ipv4Subnet,
|
||||
ipv6Subnet: body.ipv6Subnet,
|
||||
gateway: body.gateway,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ network }, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error("Error creating network:", error);
|
||||
return NextResponse.json({ error: "Failed to create network" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user