+
Máquinas registradas
@@ -310,79 +296,10 @@ export function AdminMachinesOverview({ tenantId }: { tenantId: string }) {
{machines.length === 0 ? (
) : (
-
-
-
-
- Hostname
- Status
- Último heartbeat
- Empresa
- Plataforma
- Resumo
-
-
-
- {filteredMachines.map((machine: MachinesQueryItem) => (
- setSelectedId(machine.id)}
- className={cn(
- "cursor-pointer transition-colors hover:bg-muted/50",
- selectedId === machine.id ? "bg-muted/60" : undefined
- )}
- >
-
- {machine.hostname}
- {machine.authEmail ?? "—"}
-
-
-
-
-
-
-
-
- {formatRelativeTime(machine.lastHeartbeatAt ? new Date(machine.lastHeartbeatAt) : null)}
-
-
-
- {machine.companySlug ?? "—"}
-
-
-
- {machine.osName ?? "—"}
- {machine.osVersion ? ` ${machine.osVersion}` : ""}
-
-
- {machine.architecture ? machine.architecture.toUpperCase() : "—"}
-
-
-
-
- {Array.isArray(machine.postureAlerts) && machine.postureAlerts.length > 0 ? (
- {machine.postureAlerts.length} alertas
- ) : (
- 0 alertas
- )}
- {Array.isArray(machine.inventory?.disks) ? (
- {machine.inventory?.disks?.length ?? 0} discos
- ) : null}
- {Array.isArray(machine.inventory?.services) ? (
- {machine.inventory?.services?.length ?? 0} serviços
- ) : null}
-
-
-
- ))}
-
-
-
+
)}
-
-
)
}
@@ -410,7 +327,7 @@ type MachineDetailsProps = {
machine: MachinesQueryItem | null
}
-function MachineDetails({ machine }: MachineDetailsProps) {
+export function MachineDetails({ machine }: MachineDetailsProps) {
const metadata = machine?.inventory ?? null
const metrics = machine?.metrics ?? null
const hardware = metadata?.hardware ?? null
@@ -1115,6 +1032,90 @@ function MachineDetails({ machine }: MachineDetailsProps) {
)
}
+function MachinesGrid({ machines }: { machines: MachinesQueryItem[] }) {
+ if (!machines || machines.length === 0) return
+ return (
+
+ {machines.map((m) => (
+
+ ))}
+
+ )
+}
+
+function MachineCard({ machine }: { machine: MachinesQueryItem }) {
+ const { className } = getStatusVariant(machine.status)
+ const lastHeartbeat = machine.lastHeartbeatAt ? new Date(machine.lastHeartbeatAt) : null
+ const memUsed = Number((machine.metrics as any)?.memoryUsedBytes ?? NaN)
+ const memTotal = Number((machine.metrics as any)?.memoryTotalBytes ?? NaN)
+ const memPct = Number((machine.metrics as any)?.memoryUsedPercent ?? (memUsed && memTotal ? (memUsed / memTotal) * 100 : NaN))
+ const cpuPct = Number((machine.metrics as any)?.cpuUsagePercent ?? NaN)
+
+ return (
+
+
+
+
+
+ {machine.hostname}
+
+ {machine.authEmail ?? "—"}
+
+
+
+
+ {machine.osName ?? "SO"} {machine.osVersion ?? ""}
+
+ {machine.architecture ? (
+
+ {machine.architecture.toUpperCase()}
+
+ ) : null}
+ {machine.companySlug ? (
+ {machine.companySlug}
+ ) : null}
+
+
+
+
+ {formatPercent(cpuPct)}
+
+
+
+
+ {Number.isFinite(memUsed) && Number.isFinite(memTotal)
+ ? `${formatBytes(memUsed)} / ${formatBytes(memTotal)}`
+ : formatPercent(memPct)}
+
+
+
+
+
+
+ {Array.isArray(machine.inventory?.disks) ? `${machine.inventory?.disks?.length ?? 0} discos` : "—"}
+
+
+ {lastHeartbeat ? formatRelativeTime(lastHeartbeat) : "sem heartbeat"}
+
+
+
+
+
+ )
+}
+
function DetailLine({ label, value }: { label: string; value?: string | number | null }) {
if (value === null || value === undefined) return null
if (typeof value === "string" && (value.trim() === "" || value === "undefined" || value === "null")) {