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 (
{machineList.length} machine{machineList.length !== 1 ? 's' : ''} registered, {onlineCount} online
Download and install the RemoteLink agent on the machines you want to control remotely.