import { auth } from '@/auth' import { db } from '@/lib/db' import { machines } from '@/lib/db/schema' import { eq, desc } from 'drizzle-orm' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import Link from 'next/link' import { Download, Laptop, Link2 } from 'lucide-react' import { formatDistanceToNow } from 'date-fns' import { MachineActions } from '@/components/dashboard/machine-actions' export default async function MachinesPage() { const session = await auth() const machineList = await db .select() .from(machines) .where(eq(machines.userId, session!.user.id)) .orderBy(desc(machines.isOnline), desc(machines.lastSeen)) const onlineCount = machineList.filter((m) => m.isOnline).length return (

Machines

{machineList.length} machine{machineList.length !== 1 ? 's' : ''} registered, {onlineCount} online

{machineList.length > 0 ? (
{machineList.map((machine) => (
{machine.name} {machine.hostname || 'Unknown host'}
Status {machine.isOnline ? 'Online' : 'Offline'}
OS {machine.os || 'Unknown'} {machine.osVersion || ''}
Last seen {machine.lastSeen ? formatDistanceToNow(new Date(machine.lastSeen), { addSuffix: true }) : 'Never'}
Agent {machine.agentVersion || 'N/A'}
))}
) : (

No machines yet

Download and install the RemoteLink agent on the machines you want to control remotely.

)}
) }