feat: Implement device firmware and command APIs, add individual device administration page, and refine UI styling.

This commit is contained in:
2025-12-22 23:59:02 -05:00
parent dae7926eaa
commit 7d82a9e223
11 changed files with 579 additions and 80 deletions

View File

@@ -0,0 +1,343 @@
"use client";
import React, { useState, useEffect } from "react";
import {
Settings2, Save, RefreshCw, Power, Upload,
Cpu, Activity, CheckCircle2, AlertCircle, Loader2,
ChevronRight, HardDrive, ShieldAlert, Terminal
} from "lucide-react";
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import Link from "next/link";
import { useRouter } from "next/navigation";
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
interface Device {
id: string;
serialNumber: string;
macAddress: string;
name: string;
status: string;
firmwareVersion: string;
activeSlot: string;
temperature: number | null;
uptime: number | null;
}
export default function DeviceConfigPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = React.use(params);
const router = useRouter();
const [device, setDevice] = useState<Device | null>(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [uploading, setUploading] = useState(false);
const [formData, setFormData] = useState({ name: "", activeSlot: "A" });
const [file, setFile] = useState<File | null>(null);
const [message, setMessage] = useState<{ type: "success" | "error"; text: string } | null>(null);
useEffect(() => {
fetchDevice();
}, [id]);
const fetchDevice = async () => {
try {
const res = await fetch(`/api/devices`);
const data = await res.json();
const found = data.find((d: Device) => d.id === id);
if (found) {
setDevice(found);
setFormData({ name: found.name || "", activeSlot: found.activeSlot || "A" });
}
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
};
const handleSave = async () => {
setSaving(true);
try {
const res = await fetch(`/api/devices/${id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData),
});
if (res.ok) {
setMessage({ type: "success", text: "Device configuration synchronized." });
fetchDevice();
}
} catch (error) {
setMessage({ type: "error", text: "Synchronization failed." });
} finally {
setSaving(false);
setTimeout(() => setMessage(null), 3000);
}
};
const handleCommand = async (command: "REBOOT" | "SHUTDOWN") => {
if (!confirm(`Confirm ${command.toLowerCase()} sequence for ${device?.serialNumber}?`)) return;
try {
const res = await fetch(`/api/devices/${id}/command`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ command }),
});
if (res.ok) {
setMessage({ type: "success", text: `${command} signal transmitted.` });
}
} catch (error) {
setMessage({ type: "error", text: "Signal transmission failed." });
}
};
const handleUpload = async () => {
if (!file) return;
setUploading(true);
try {
const fd = new FormData();
fd.append("file", file);
fd.append("slot", formData.activeSlot);
const res = await fetch(`/api/devices/${id}/firmware`, {
method: "POST",
body: fd,
});
if (res.ok) {
setMessage({ type: "success", text: "Firmware orchestration complete." });
setFile(null);
fetchDevice();
}
} catch (error) {
setMessage({ type: "error", text: "Firmware deployment failed." });
} finally {
setUploading(false);
}
};
if (loading) {
return (
<div className="min-h-[60vh] flex flex-col items-center justify-center gap-4">
<Loader2 className="w-8 h-8 text-sky-500 animate-spin" />
<p className="text-secondary font-mono text-[10px] uppercase tracking-widest">Initialising Secure Direct Link...</p>
</div>
);
}
if (!device) return <div>Device not found</div>;
return (
<div className="space-y-8 pb-20 animate-in fade-in slide-in-from-bottom-4 duration-700">
{/* Breadcrumbs */}
<div className="flex items-center gap-3 text-[10px] font-black uppercase tracking-[0.2em] text-secondary">
<Link href="/admin" className="hover:text-sky-400 transition-colors">Admin</Link>
<ChevronRight className="w-3 h-3 opacity-20" />
<span className="text-secondary/60">Device Configuration</span>
<ChevronRight className="w-3 h-3 opacity-20" />
<span className="text-sky-400">{device.serialNumber}</span>
</div>
{/* Header Area */}
<div className="flex flex-col md:flex-row md:items-center justify-between gap-6">
<div className="space-y-1">
<h1 className="text-3xl font-black tracking-tight text-foreground flex items-center gap-3">
<Cpu className="w-8 h-8 text-sky-500" />
{device.name || "Unnamed Node"}
</h1>
<p className="text-secondary font-mono text-xs flex items-center gap-2">
<Terminal className="w-3.5 h-3.5 opacity-50" />
HWID: {device.serialNumber} {device.macAddress}
</p>
</div>
<div className="flex items-center gap-3">
<button
onClick={() => handleCommand("REBOOT")}
className="p-3 rounded-xl bg-secondary/5 border border-border text-secondary hover:text-amber-400 hover:bg-amber-400/5 hover:border-amber-400/20 transition-all group"
title="Reboot System"
>
<RefreshCw className="w-5 h-5 group-active:rotate-180 transition-transform duration-500" />
</button>
<button
onClick={() => handleCommand("SHUTDOWN")}
className="p-3 rounded-xl bg-secondary/5 border border-border text-secondary hover:text-rose-500 hover:bg-rose-500/5 hover:border-rose-500/20 transition-all"
title="Decommission Node"
>
<Power className="w-5 h-5" />
</button>
</div>
</div>
{message && (
<div className={cn(
"p-4 rounded-2xl border text-xs font-bold flex items-center gap-3 animate-in fade-in zoom-in duration-300",
message.type === "success" ? "bg-emerald-500/10 border-emerald-500/20 text-emerald-400" : "bg-rose-500/10 border-rose-500/20 text-rose-400"
)}>
{message.type === "success" ? <CheckCircle2 className="w-4 h-4" /> : <ShieldAlert className="w-4 h-4" />}
{message.text}
</div>
)}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
{/* General Configuration */}
<div className="lg:col-span-2 space-y-8">
<section className="bg-background border border-border rounded-[2.5rem] p-8 space-y-8 relative overflow-hidden group">
<div className="absolute top-0 right-0 p-8 opacity-[0.02]">
<Settings2 className="w-32 h-32" />
</div>
<div className="flex items-center gap-3 mb-2">
<div className="w-10 h-10 rounded-xl bg-sky-500/10 flex items-center justify-center text-sky-500">
<Settings2 className="w-5 h-5" />
</div>
<h2 className="text-[10px] font-black uppercase tracking-[0.3em] text-secondary">General Parameters</h2>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 relative z-10">
<div className="space-y-2">
<label className="text-[10px] font-black uppercase tracking-widest text-secondary ml-1">Device Designation</label>
<input
type="text"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
className="w-full bg-secondary/5 border border-border rounded-xl px-5 py-3 text-sm font-bold text-foreground focus:border-sky-500/50 outline-none transition-all"
placeholder="Enter node name..."
/>
</div>
<div className="space-y-2">
<label className="text-[10px] font-black uppercase tracking-widest text-secondary ml-1">Orchestration Slot</label>
<div className="flex p-1 bg-secondary/5 rounded-xl border border-border gap-1">
{["A", "B"].map((s) => (
<button
key={s}
onClick={() => setFormData({ ...formData, activeSlot: s })}
className={cn(
"flex-1 py-2 text-[10px] font-black uppercase tracking-widest rounded-lg transition-all",
formData.activeSlot === s
? "bg-background text-sky-400 shadow-sm border border-border"
: "text-secondary hover:text-foreground"
)}
>
Slot {s}
</button>
))}
</div>
</div>
</div>
<div className="pt-4">
<button
onClick={handleSave}
disabled={saving}
className="w-full md:w-auto bg-foreground text-background px-8 py-3 rounded-2xl text-[10px] font-black uppercase tracking-widest flex items-center justify-center gap-3 hover:opacity-90 active:scale-95 transition-all disabled:opacity-50"
>
{saving ? <Loader2 className="w-4 h-4 animate-spin" /> : <Save className="w-4 h-4" />}
Sync Config
</button>
</div>
</section>
{/* Firmware Manifest */}
<section className="bg-background border border-border rounded-[2.5rem] p-8 space-y-8 relative overflow-hidden group">
<div className="absolute top-0 right-0 p-8 opacity-[0.02]">
<HardDrive className="w-32 h-32" />
</div>
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-purple-500/10 flex items-center justify-center text-purple-400">
<Upload className="w-5 h-5" />
</div>
<h2 className="text-[10px] font-black uppercase tracking-[0.3em] text-secondary">Firmware Orchestration</h2>
</div>
<div className="bg-secondary/5 border border-dashed border-border rounded-3xl p-10 flex flex-col items-center justify-center gap-4 text-center transition-all hover:bg-secondary/10 hover:border-sky-500/30 group/upload relative z-10">
{file ? (
<div className="space-y-2">
<p className="text-sm font-bold text-foreground font-mono">{file.name}</p>
<p className="text-[10px] text-secondary uppercase tracking-widest">{(file.size / 1024 / 1024).toFixed(2)} MB Ready for deployment</p>
</div>
) : (
<>
<div className="w-12 h-12 rounded-full bg-secondary/5 flex items-center justify-center text-secondary group-hover/upload:text-sky-500 group-hover/upload:scale-110 transition-all">
<Upload className="w-6 h-6" />
</div>
<div className="space-y-1">
<p className="text-sm font-bold text-foreground">Click to select manifest</p>
<p className="text-[10px] text-secondary uppercase tracking-widest">Valid .bin or .elf binaries only</p>
</div>
</>
)}
<input
type="file"
className="absolute inset-0 opacity-0 cursor-pointer"
onChange={(e) => setFile(e.target.files?.[0] || null)}
accept=".bin,.elf"
/>
</div>
{file && (
<button
onClick={handleUpload}
disabled={uploading}
className="w-full bg-sky-500 text-white px-8 py-4 rounded-2xl text-[10px] font-black uppercase tracking-[0.3em] flex items-center justify-center gap-3 hover:bg-sky-400 shadow-[0_4px_20px_rgba(56,189,248,0.2)] active:scale-[0.98] transition-all disabled:opacity-50"
>
{uploading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Activity className="w-4 h-4" />}
Initiate Firmware Deployment
</button>
)}
</section>
</div>
{/* Status Sidebar */}
<div className="space-y-6">
<div className="bg-background border border-border rounded-3xl p-6 space-y-6">
<h3 className="text-[9px] font-black uppercase tracking-[0.2em] text-secondary flex items-center gap-2">
<Activity className="w-3 h-3 text-sky-400" />
Live Metrics
</h3>
<div className="space-y-4">
<div className="flex justify-between items-center p-3 bg-secondary/5 rounded-xl border border-border">
<span className="text-[10px] font-bold text-secondary uppercase tracking-widest">Active Slot</span>
<span className="text-xs font-black text-sky-400 font-mono">Slot {device.activeSlot}</span>
</div>
<div className="flex justify-between items-center p-3 bg-secondary/5 rounded-xl border border-border">
<span className="text-[10px] font-bold text-secondary uppercase tracking-widest">Core Version</span>
<span className="text-xs font-black text-foreground font-mono">v{device.firmwareVersion}</span>
</div>
<div className="flex justify-between items-center p-3 bg-secondary/5 rounded-xl border border-border">
<span className="text-[10px] font-bold text-secondary uppercase tracking-widest">Mesh Status</span>
<div className="flex items-center gap-2">
<span className={cn(
"w-2 h-2 rounded-full",
device.status === "ENROLLED" ? "bg-emerald-500 shadow-[0_0_8px] shadow-emerald-500/50" : "bg-amber-400"
)} />
<span className="text-[10px] font-black uppercase text-foreground">{device.status}</span>
</div>
</div>
</div>
<div className="pt-2 border-t border-border">
<div className="flex items-center gap-4 py-2">
<div className="flex-1">
<div className="flex justify-between mb-1">
<span className="text-[8px] font-black text-secondary uppercase tracking-widest">System Load</span>
<span className="text-[8px] font-black text-foreground uppercase tracking-widest">24%</span>
</div>
<div className="h-1 w-full bg-secondary/10 rounded-full overflow-hidden">
<div className="h-full bg-sky-500 w-[24%]" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}

View File

@@ -1,7 +1,7 @@
"use client";
import { useState, useEffect } from "react";
import { Shield, ArrowRight, Settings2, PlusCircle, CheckCircle2, XCircle, Clock } from "lucide-react";
import { Shield, ArrowRight, Settings2, PlusCircle, CheckCircle2, XCircle, Clock, ChevronRight } from "lucide-react";
import Link from "next/link";
interface Device {
@@ -57,7 +57,7 @@ export default function AdminPage() {
</div>
Command Center
</h1>
<p className="text-slate-500 font-medium text-sm tracking-wide">Manage device fleet, enrollment, and firmware orchestration.</p>
<p className="text-secondary font-medium text-sm tracking-wide">Manage device fleet, enrollment, and firmware orchestration.</p>
</div>
<button className="bg-sky-500 hover:bg-sky-400 text-white px-6 py-2.5 rounded-2xl text-[10px] font-black uppercase tracking-widest flex items-center gap-3 transition-all shadow-[0_0_25px_rgba(56,189,248,0.2)] hover:scale-105 active:scale-95">
<PlusCircle className="w-4 h-4" />
@@ -82,24 +82,30 @@ export default function AdminPage() {
<th className="px-8 py-5 text-right">Control</th>
</tr>
</thead>
<tbody className="divide-y divide-white/[0.02]">
<tbody className="divide-y divide-border">
{loading ? (
<tr>
<td colSpan={6} className="px-8 py-20 text-center text-slate-500 font-medium italic">Scanning network for head units...</td>
<td colSpan={6} className="px-8 py-20 text-center text-secondary font-medium italic">Scanning network for head units...</td>
</tr>
) : devices.length === 0 ? (
<tr>
<td colSpan={6} className="px-8 py-20 text-center text-slate-500 font-medium italic">No devices detected in local mesh.</td>
<td colSpan={6} className="px-8 py-20 text-center text-secondary font-medium italic">No devices detected in local mesh.</td>
</tr>
) : (
devices.map((device) => (
<tr key={device.id} className="hover:bg-white/[0.03] transition-all group">
<tr key={device.id} className="hover:bg-secondary/5 transition-all group">
<td className="px-8 py-4">
<div className="flex items-center gap-4">
<div className={`w-2 h-2 rounded-full shadow-[0_0_8px] ${device.status === 'ENROLLED' ? 'bg-sky-400 shadow-sky-400/50' : 'bg-amber-400 shadow-amber-400/50 animate-pulse'}`} />
<div className="flex flex-col">
<span className="text-xs font-black text-slate-200 uppercase tracking-tight">{device.serialNumber}</span>
<span className="font-mono text-[9px] text-slate-500 uppercase tracking-tighter">{device.macAddress}</span>
<Link
href={`/admin/devices/${device.id}`}
className="text-xs font-black text-foreground uppercase tracking-tight hover:text-sky-400 transition-colors flex items-center gap-2 group/link"
>
{device.serialNumber}
<ChevronRight className="w-3 h-3 opacity-0 -translate-x-2 group-hover/link:opacity-100 group-hover/link:translate-x-0 transition-all" />
</Link>
<span className="font-mono text-[9px] text-secondary uppercase tracking-tighter">{device.macAddress}</span>
</div>
</div>
</td>
@@ -112,13 +118,13 @@ export default function AdminPage() {
placeholder="Assign static name..."
/>
</td>
<td className="px-8 py-4 text-[10px] font-black font-mono text-slate-500 uppercase tracking-tighter">
<td className="px-8 py-4 text-[10px] font-black font-mono text-secondary uppercase tracking-tighter">
RPi Zero 2 W
</td>
<td className="px-8 py-4">
<div className="flex items-center gap-3">
<Settings2 className="w-4 h-4 text-slate-500" />
<span className="text-[9px] font-black text-slate-400 bg-white/5 py-1.5 px-3 rounded-xl border border-white/5 uppercase tracking-widest group-hover:border-sky-500/20 group-hover:text-sky-400 transition-colors">
<Settings2 className="w-4 h-4 text-secondary" />
<span className="text-[9px] font-black text-foreground bg-secondary/5 py-1.5 px-3 rounded-xl border border-border uppercase tracking-widest group-hover:border-sky-500/20 group-hover:text-sky-400 transition-colors">
Slot {device.activeSlot} <span className="mx-1.5 opacity-20">|</span> v{device.firmwareVersion}
</span>
</div>

View File

@@ -0,0 +1,44 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
export async function POST(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const { command } = await req.json();
// In a real implementation, this would communicate with the hardware
// For now, we simulate success and update the database accordingly
const device = await prisma.device.findUnique({
where: { id }
});
if (!device) {
return NextResponse.json({ error: "Device not found" }, { status: 404 });
}
switch (command) {
case "REBOOT":
// Simulate reboot logic
console.log(`[DEVICE CMD] Rebooting device ${device.serialNumber}`);
break;
case "SHUTDOWN":
// Simulate shutdown logic
console.log(`[DEVICE CMD] Shutting down device ${device.serialNumber}`);
await prisma.device.update({
where: { id },
data: { status: "OFFLINE" }
});
break;
default:
return NextResponse.json({ error: "Unknown command" }, { status: 400 });
}
return NextResponse.json({ success: true, command });
} catch (error) {
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -0,0 +1,39 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
export async function POST(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const formData = await req.formData();
const file = formData.get("file") as File;
const slot = formData.get("slot") as string;
if (!file) {
return NextResponse.json({ error: "No file uploaded" }, { status: 400 });
}
// Simulate firmware processing
console.log(`[FIRMWARE] Uploading ${file.name} to ${id} (Slot ${slot})`);
// Update device record to reflect new firmware (simulated)
const updatedDevice = await prisma.device.update({
where: { id },
data: {
firmwareVersion: "1.2.0-RC", // Simulated version bump
activeSlot: slot || undefined
}
});
return NextResponse.json({
success: true,
version: "1.2.0-RC",
slot: updatedDevice.activeSlot
});
} catch (error) {
console.error("Firmware upload error:", error);
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -7,13 +7,14 @@ export async function PATCH(
) {
try {
const { id } = await params;
const { status, name } = await req.json();
const { status, name, activeSlot } = await req.json();
const device = await prisma.device.update({
where: { id },
data: {
status: status || undefined,
name: name || undefined
name: name || undefined,
activeSlot: activeSlot || undefined
},
});

View File

@@ -8,10 +8,11 @@
}
:root {
--background: #f8fafc;
--foreground: #0f172a;
--border: rgba(15, 23, 42, 0.08);
--secondary: #64748b;
--background: #fdfdfe;
--foreground: #020617;
--border: rgba(2, 6, 23, 0.1);
--secondary: #475569;
--muted: #64748b;
}
[class~="dark"] {
@@ -19,13 +20,37 @@
--foreground: #f1f5f9;
--border: rgba(255, 255, 255, 0.05);
--secondary: #94a3b8;
--muted: #64748b;
}
[class*="backdrop-blur"] {
/* Safari support for backdrop filters */
-webkit-backdrop-filter: saturate(180%) blur(var(--tw-backdrop-blur, 12px));
backdrop-filter: saturate(180%) blur(var(--tw-backdrop-blur, 12px));
/* Safari Fix: Prevent content vanishing */
isolation: isolate;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
* {
transition: background-color 0.3s ease, border-color 0.3s ease, color 0.15s ease;
-webkit-tap-highlight-color: transparent;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Fix for Safari flickering with transitions on fixed backgrounds */
.fixed,
.sticky {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
transform: translateZ(0);
}
body {
background: var(--background);
background-color: var(--background);
color: var(--foreground);
min-height: 100vh;
min-height: 100dvh;
transition: background-color 0.3s ease, color 0.3s ease;
}

View File

@@ -39,7 +39,7 @@ interface DashboardData {
export default function DashboardPage() {
const [data, setData] = useState<DashboardData | null>(null);
const [loading, setLoading] = useState(true);
const [lastUpdate, setLastUpdate] = useState<Date>(new Date());
const [lastUpdate, setLastUpdate] = useState<Date | null>(null);
const [isUpdating, setIsUpdating] = useState(false);
const fetchData = async () => {
@@ -98,12 +98,12 @@ export default function DashboardPage() {
</h1>
</div>
<div className="flex items-center gap-3">
<div className="text-[10px] font-mono text-slate-500 uppercase tracking-tighter">
Last sync: <span className="text-slate-300">{lastUpdate.toLocaleTimeString()}</span>
<div className="text-[10px] font-mono text-secondary uppercase tracking-tighter">
Last sync: <span className="text-foreground">{lastUpdate ? lastUpdate.toLocaleTimeString() : "--:--:--"}</span>
</div>
<div className={cn(
"w-2 h-2 rounded-full transition-all duration-500",
isUpdating ? "bg-sky-400 shadow-[0_0_8px_rgba(56,189,248,0.8)]" : "bg-white/10"
isUpdating ? "bg-sky-400 shadow-[0_0_8px_rgba(56,189,248,0.8)]" : "bg-secondary/20"
)} />
</div>
</div>
@@ -119,7 +119,6 @@ export default function DashboardPage() {
key={i}
className={cn(
"bg-background border border-border rounded-2xl p-6 backdrop-blur-sm relative overflow-hidden group transition-all duration-700",
isUpdating && "bg-background/80 border-sky-500/20",
stat.glow
)}
>
@@ -127,20 +126,13 @@ export default function DashboardPage() {
<div className="flex items-center justify-between relative z-10">
<div>
<p className="text-slate-500 text-[10px] font-black uppercase tracking-[0.2em] mb-2">{stat.label}</p>
<h3 className={cn(
"text-4xl font-black tracking-tighter transition-all duration-500 font-mono",
isUpdating ? stat.color : "text-white"
)}>
<h3 className={cn("text-4xl font-black tracking-tighter transition-all duration-500 font-mono", stat.color)}>
{stat.value.toString().padStart(2, '0')}
</h3>
</div>
<div className={cn(
"w-12 h-12 rounded-xl flex items-center justify-center transition-all duration-700",
isUpdating ? "bg-white/10 scale-110" : "bg-white/5"
)}>
<div className="w-12 h-12 rounded-xl bg-secondary/5 flex items-center justify-center transition-all duration-700 group-hover:bg-secondary/10 group-hover:scale-110">
<stat.icon className={cn(
"w-6 h-6 transition-all duration-700",
isUpdating ? "opacity-100" : "opacity-40",
"w-6 h-6 transition-all duration-700 opacity-60 group-hover:opacity-100",
stat.color
)} />
</div>
@@ -165,11 +157,11 @@ export default function DashboardPage() {
<table className="w-full text-left border-collapse">
<thead>
<tr className="border-b border-border bg-background/30">
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-slate-500">Node</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-slate-500">Operation</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-slate-500">Status</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-slate-500">Execution</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-slate-500"></th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-secondary">Node</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-secondary">Operation</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-secondary">Status</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-secondary">Execution</th>
<th className="px-6 py-4 text-[10px] font-black uppercase tracking-[0.2em] text-secondary"></th>
</tr>
</thead>
<tbody className="divide-y divide-white/[0.02]">
@@ -179,24 +171,24 @@ export default function DashboardPage() {
</tr>
) : (
data.recentTests.map((test) => (
<tr key={test.id} className="hover:bg-white/[0.04] transition-all group animate-in fade-in slide-in-from-left-2 duration-500">
<tr key={test.id} className="hover:bg-secondary/5 transition-all group animate-in fade-in slide-in-from-left-2 duration-500">
<td className="px-6 py-4">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-white/5 border border-white/5 flex items-center justify-center font-mono text-[10px] font-bold text-sky-400">
<div className="w-8 h-8 rounded-lg bg-background border border-border flex items-center justify-center font-mono text-[10px] font-bold text-sky-400 shadow-sm">
HU
</div>
<div className="flex flex-col">
<span className="font-bold text-slate-200 text-xs">
<span className="font-bold text-foreground text-xs">
{test.device.name && test.device.name !== "Unnamed Device" ? test.device.name : test.device.serialNumber}
</span>
<span className="text-[9px] text-slate-500 font-mono tracking-tighter uppercase whitespace-nowrap">
<span className="text-[9px] text-secondary font-mono tracking-tighter uppercase whitespace-nowrap">
ID: {test.device.serialNumber}
</span>
</div>
</div>
</td>
<td className="px-6 py-4">
<span className="text-[10px] px-2 py-0.5 rounded bg-white/5 border border-white/5 text-slate-400 font-black uppercase tracking-widest whitespace-nowrap">
<span className="text-[10px] px-2 py-0.5 rounded bg-secondary/5 border border-border text-secondary font-black uppercase tracking-widest whitespace-nowrap">
{test.type.replace("_", " ")}
</span>
</td>
@@ -215,10 +207,10 @@ export default function DashboardPage() {
</td>
<td className="px-6 py-4">
<div className="flex flex-col">
<span className="text-[10px] font-bold text-slate-300 font-mono">
<span className="text-[10px] font-bold text-foreground font-mono">
{new Date(test.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false })}
</span>
<span className="text-[8px] text-slate-500 font-black uppercase tracking-widest">
<span className="text-[8px] text-secondary font-black uppercase tracking-widest">
{new Date(test.timestamp).toLocaleDateString([], { month: 'short', day: 'numeric' })}
</span>
</div>
@@ -250,7 +242,7 @@ export default function DashboardPage() {
Intelligence Engine
</h4>
<div className="space-y-3 relative z-10">
<p className="text-xs text-slate-400 leading-relaxed font-medium">
<p className="text-xs text-secondary leading-relaxed font-medium">
Real-time spectral analysis of HDMI bus metrics. Processing orchestrated with <span className="text-sky-400 font-bold">sub-ms</span> edge latency.
</p>
<div className="flex items-center gap-2 py-3 border-t border-sky-500/10">
@@ -258,19 +250,19 @@ export default function DashboardPage() {
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2 w-2 bg-green-500"></span>
</span>
<span className="text-[9px] font-black uppercase tracking-[0.15em] text-white">Neural Engine Online</span>
<span className="text-[9px] font-black uppercase tracking-[0.15em] text-foreground">Neural Engine Online</span>
</div>
</div>
</div>
<div className="bg-background border border-border rounded-2xl p-6">
<div className="flex items-center justify-between mb-6">
<h4 className="font-black text-slate-400 text-[10px] uppercase tracking-[0.3em]">Fleet Nodes</h4>
<h4 className="font-black text-secondary text-[10px] uppercase tracking-[0.3em]">Fleet Nodes</h4>
<Link href="/admin" className="text-[9px] text-sky-400 hover:text-sky-300 uppercase font-black tracking-widest">Manage All</Link>
</div>
<div className="space-y-3">
{data.enrolledDevices.length === 0 ? (
<p className="text-[10px] text-slate-500 italic text-center py-4 border border-dashed border-white/5 rounded-xl">No active nodes in mesh.</p>
<p className="text-[10px] text-secondary italic text-center py-4 border border-dashed border-border rounded-xl">No active nodes in mesh.</p>
) : (
data.enrolledDevices.map((device) => (
<div key={device.id} className="p-3 bg-secondary/5 hover:bg-secondary/10 transition-colors rounded-xl border border-border flex items-center justify-between group cursor-default">
@@ -279,10 +271,10 @@ export default function DashboardPage() {
<Cpu className="w-4 h-4 text-sky-400" />
</div>
<div className="flex flex-col">
<span className="text-[10px] font-black text-slate-200 uppercase tracking-wider">
<span className="text-[10px] font-black text-foreground uppercase tracking-wider">
{device.name && device.name !== "Unnamed Device" ? device.name : device.serialNumber}
</span>
<span className="text-[8px] text-slate-500 font-mono uppercase tracking-tighter">System Health: Optimal</span>
<span className="text-[8px] text-secondary font-mono uppercase tracking-tighter">System Health: Optimal</span>
</div>
</div>
<div className="w-1.5 h-1.5 rounded-full bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.5)]" />

View File

@@ -98,12 +98,12 @@ export default async function TestDetailsPage({ params }: { params: Promise<{ id
<div key={pin} className="space-y-4">
<div className="flex justify-between items-end">
<div className="flex flex-col">
<span className="text-[10px] font-black uppercase tracking-[0.15em] text-slate-500 mb-0.5">{pin.replace("_", " ")}</span>
<span className="text-[8px] text-slate-600 font-black uppercase">Spectral Diode Path</span>
<span className="text-[10px] font-black uppercase tracking-[0.15em] text-secondary mb-0.5">{pin.replace("_", " ")}</span>
<span className="text-[8px] text-muted font-black uppercase">Spectral Diode Path</span>
</div>
<span className="text-sky-400 font-mono text-lg font-black tracking-tight">{voltage.toFixed(3)}<span className="text-[10px] ml-0.5 opacity-60">V</span></span>
</div>
<div className="h-3 w-full bg-white/5 rounded-full overflow-hidden p-0.5 border border-white/5">
<div className="h-3 w-full bg-secondary/5 rounded-full overflow-hidden p-0.5 border border-border">
<div
className="h-full bg-gradient-to-r from-sky-600 via-sky-400 to-sky-300 rounded-full transition-all duration-1000 shadow-[0_0_12px_rgba(56,189,248,0.3)] relative group-hover:brightness-110"
style={{ width: `${Math.min((voltage / 0.8) * 100, 100)}%` }}
@@ -116,8 +116,8 @@ export default async function TestDetailsPage({ params }: { params: Promise<{ id
</div>
) : (
<div className="text-center py-20 flex flex-col items-center gap-4">
<AlertCircle className="w-12 h-12 text-slate-700" />
<p className="text-slate-500 italic font-bold text-sm">No detailed spectral metrics available for this sequence.</p>
<AlertCircle className="w-12 h-12 text-secondary/30" />
<p className="text-secondary italic font-bold text-sm">No detailed spectral metrics available for this sequence.</p>
</div>
)}
</div>
@@ -139,7 +139,7 @@ export default async function TestDetailsPage({ params }: { params: Promise<{ id
"{test.summary}"
</p>
<div className="mt-4 pt-4 border-t border-border flex items-center justify-between">
<span className="text-[8px] font-black uppercase text-secondary tracking-widest">Synthesized by AI Engine</span>
<span className="text-[8px] font-black uppercase text-muted tracking-widest">Synthesized by AI Engine</span>
<span className="text-emerald-500 text-[8px] font-black uppercase tracking-widest">Authenticated</span>
</div>
</div>