VMs are now shown in the search results

This commit is contained in:
headlessdev
2025-04-19 14:39:02 +02:00
parent 44817d6685
commit 86d48bc082
4 changed files with 93 additions and 16 deletions

View File

@@ -20,13 +20,25 @@ export async function POST(request: NextRequest) {
});
const hostsWithVms = await Promise.all(
hosts.map(async (host) => ({
...host,
hostedVMs: await prisma.server.findMany({
hosts.map(async (host) => {
const vms = await prisma.server.findMany({
where: { hostServer: host.id },
orderBy: { name: 'asc' }
})
}))
});
// Add isVM flag to VMs
const vmsWithFlag = vms.map(vm => ({
...vm,
isVM: true,
hostedVMs: [] // Initialize empty hostedVMs array for VMs
}));
return {
...host,
isVM: false, // Mark as physical server/not a VM
hostedVMs: vmsWithFlag
};
})
);
const totalHosts = await prisma.server.count({