fix(admin/machines): replace leftover companyFilter with companyQuery; remove remaining any casts; add readBool helper; clean imports
This commit is contained in:
parent
b5fbf69cc1
commit
f89424c168
1 changed files with 24 additions and 13 deletions
|
|
@ -8,7 +8,6 @@ import { toast } from "sonner"
|
|||
import { ClipboardCopy, ServerCog, Cpu, MemoryStick, Monitor, HardDrive, Pencil } from "lucide-react"
|
||||
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
|
|
@ -198,6 +197,12 @@ function fmtBool(value: unknown) {
|
|||
return "—"
|
||||
}
|
||||
|
||||
function readBool(source: unknown, key: string): boolean | undefined {
|
||||
if (!source || typeof source !== "object") return undefined
|
||||
const value = (source as Record<string, unknown>)[key]
|
||||
return typeof value === "boolean" ? value : undefined
|
||||
}
|
||||
|
||||
function getStatusVariant(status?: string | null) {
|
||||
if (!status) return { label: statusLabels.unknown, className: statusClasses.unknown }
|
||||
const normalized = status.toLowerCase()
|
||||
|
|
@ -251,7 +256,7 @@ export function AdminMachinesOverview({ tenantId }: { tenantId: string }) {
|
|||
.toLowerCase()
|
||||
return hay.includes(text)
|
||||
})
|
||||
}, [machines, q, statusFilter, osFilter, companyFilter, onlyAlerts])
|
||||
}, [machines, q, statusFilter, osFilter, companyQuery, onlyAlerts])
|
||||
|
||||
return (
|
||||
<div className="grid gap-6">
|
||||
|
|
@ -795,7 +800,7 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
|||
<Cpu className="size-5 text-slate-500" />
|
||||
<div className="min-w-0">
|
||||
<p className="text-xs text-muted-foreground">CPU</p>
|
||||
<p className="break-words text-sm font-semibold text-foreground">{String((winCpu as any)?.Name ?? "—")}</p>
|
||||
<p className="break-words text-sm font-semibold text-foreground">{winCpu?.Name ?? "—"}</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
|
@ -813,7 +818,7 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
|||
<Monitor className="size-5 text-slate-500" />
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-xs text-muted-foreground">GPU</p>
|
||||
<p className="truncate text-sm font-semibold text-foreground">{String((winGpu as any)?.Name ?? "—")}</p>
|
||||
<p className="truncate text-sm font-semibold text-foreground">{winGpu?.Name ?? "—"}</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
|
@ -940,13 +945,19 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
|||
<div className="rounded-md border border-slate-200 bg-slate-50/60 p-3">
|
||||
<p className="text-xs font-semibold uppercase text-slate-500">Adaptadores de vídeo</p>
|
||||
<ul className="mt-2 grid gap-1 text-xs text-muted-foreground">
|
||||
{(windowsExt.videoControllers as Array<any>).map((v, idx) => (
|
||||
<li key={`vid-${idx}`}>
|
||||
<span className="font-medium text-foreground">{v?.Name ?? "—"}</span>
|
||||
{v?.AdapterRAM ? <span className="ml-1">{formatBytes(Number(v.AdapterRAM))}</span> : null}
|
||||
{v?.DriverVersion ? <span className="ml-1">· Driver {v.DriverVersion}</span> : null}
|
||||
</li>
|
||||
))}
|
||||
{(windowsExt.videoControllers as Array<unknown>).map((vRaw, idx) => {
|
||||
const v = (vRaw && typeof vRaw === "object") ? (vRaw as Record<string, unknown>) : undefined
|
||||
const name = typeof v?.["Name"] === "string" ? (v["Name"] as string) : "—"
|
||||
const ram = typeof v?.["AdapterRAM"] === "number" ? (v["AdapterRAM"] as number) : undefined
|
||||
const driver = typeof v?.["DriverVersion"] === "string" ? (v["DriverVersion"] as string) : undefined
|
||||
return (
|
||||
<li key={`vid-${idx}`}>
|
||||
<span className="font-medium text-foreground">{name}</span>
|
||||
{typeof ram === "number" ? <span className="ml-1">{formatBytes(ram)}</span> : null}
|
||||
{driver ? <span className="ml-1">· Driver {driver}</span> : null}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
) : null}
|
||||
|
|
@ -985,8 +996,8 @@ export function MachineDetails({ machine }: MachineDetailsProps) {
|
|||
<div className="rounded-md border border-slate-200 bg-slate-50/60 p-3">
|
||||
<p className="text-xs font-semibold uppercase text-slate-500">Defender</p>
|
||||
<div className="mt-2 grid grid-cols-2 gap-2 text-sm">
|
||||
<DetailLine label="Antivírus" value={fmtBool((windowsExt.defender as any)?.AntivirusEnabled)} />
|
||||
<DetailLine label="Proteção em tempo real" value={fmtBool((windowsExt.defender as any)?.RealTimeProtectionEnabled)} />
|
||||
<DetailLine label="Antivírus" value={fmtBool(readBool(windowsExt.defender, "AntivirusEnabled"))} />
|
||||
<DetailLine label="Proteção em tempo real" value={fmtBool(readBool(windowsExt.defender, "RealTimeProtectionEnabled"))} />
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue