mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 03:08:42 -06:00
Initial Device Type Logic
This commit is contained in:
@@ -211,6 +211,7 @@ export default function DeviceDetails({ device, onBack }) {
|
||||
const summaryItems = [
|
||||
{ label: "Device Name", value: summary.hostname || agent.hostname || device?.hostname || "unknown" },
|
||||
{ label: "Operating System", value: summary.operating_system || agent.agent_operating_system || "unknown" },
|
||||
{ label: "Device Type", value: summary.device_type || "unknown" },
|
||||
{ label: "Last User", value: (
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<Box component="span" sx={{
|
||||
|
@@ -95,7 +95,7 @@ export default function DeviceList({ onSelectDevice }) {
|
||||
os: a.agent_operating_system || a.os || "-",
|
||||
// Enriched fields from details cache
|
||||
lastUser: details.lastUser || "",
|
||||
type: "", // Placeholder until provided by backend
|
||||
type: a.device_type || details.type || "",
|
||||
created: details.created || "",
|
||||
createdTs: details.createdTs || 0,
|
||||
};
|
||||
@@ -128,9 +128,10 @@ export default function DeviceList({ onSelectDevice }) {
|
||||
const parsed = Date.parse(createdRaw.replace(" ", "T"));
|
||||
createdTs = isNaN(parsed) ? 0 : Math.floor(parsed / 1000);
|
||||
}
|
||||
const deviceType = (summary.device_type || "").trim();
|
||||
setDetailsByHost((prev) => ({
|
||||
...prev,
|
||||
[h]: { lastUser, created: createdRaw, createdTs },
|
||||
[h]: { lastUser, created: createdRaw, createdTs, type: deviceType },
|
||||
}));
|
||||
} catch {
|
||||
// ignore per-host failure
|
||||
@@ -146,6 +147,7 @@ export default function DeviceList({ onSelectDevice }) {
|
||||
return {
|
||||
...r,
|
||||
lastUser: det.lastUser || r.lastUser,
|
||||
type: det.type || r.type,
|
||||
created: det.created || r.created,
|
||||
createdTs: det.createdTs || r.createdTs,
|
||||
};
|
||||
|
@@ -743,6 +743,7 @@ def load_agents_from_db():
|
||||
"agent_operating_system": summary.get("operating_system")
|
||||
or summary.get("agent_operating_system")
|
||||
or "-",
|
||||
"device_type": summary.get("device_type") or "",
|
||||
"last_seen": summary.get("last_seen") or 0,
|
||||
"status": "Offline",
|
||||
}
|
||||
@@ -809,6 +810,18 @@ def save_agent_details():
|
||||
last_seen = (prev_details.get("summary") or {}).get("last_seen")
|
||||
if last_seen:
|
||||
incoming_summary["last_seen"] = int(last_seen)
|
||||
# Refresh server-side cache so /api/agents includes latest OS and device type
|
||||
try:
|
||||
if agent_id and agent_id in registered_agents:
|
||||
rec = registered_agents[agent_id]
|
||||
os_name = incoming_summary.get("operating_system") or incoming_summary.get("agent_operating_system")
|
||||
if os_name:
|
||||
rec["agent_operating_system"] = os_name
|
||||
dt = (incoming_summary.get("device_type") or "").strip()
|
||||
if dt:
|
||||
rec["device_type"] = dt
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user