mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 23:21:57 -06:00
Design Overhaul of Device Details Page
This commit is contained in:
@@ -344,9 +344,9 @@ def collect_network():
|
|||||||
"try { "
|
"try { "
|
||||||
"$ip = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction Stop | "
|
"$ip = Get-NetIPAddress -AddressFamily IPv4 -ErrorAction Stop | "
|
||||||
"Where-Object { $_.IPAddress -and $_.IPAddress -notmatch '^169\\.254\\.' -and $_.IPAddress -ne '127.0.0.1' }; "
|
"Where-Object { $_.IPAddress -and $_.IPAddress -notmatch '^169\\.254\\.' -and $_.IPAddress -ne '127.0.0.1' }; "
|
||||||
"$ad = Get-NetAdapter | ForEach-Object { $_ | Select-Object -Property InterfaceAlias, MacAddress }; "
|
"$ad = Get-NetAdapter | ForEach-Object { $_ | Select-Object -Property InterfaceAlias, MacAddress, LinkSpeed }; "
|
||||||
"$map = @{}; foreach($a in $ad){ $map[$a.InterfaceAlias] = $a.MacAddress }; "
|
"$map = @{}; foreach($a in $ad){ $map[$a.InterfaceAlias] = @{ Mac=$a.MacAddress; LinkSpeed=('' + $a.LinkSpeed).Trim() } }; "
|
||||||
"$out = @(); foreach($e in $ip){ $mac = $map[$e.InterfaceAlias]; $out += [pscustomobject]@{ InterfaceAlias=$e.InterfaceAlias; IPAddress=$e.IPAddress; MacAddress=$mac } } "
|
"$out = @(); foreach($e in $ip){ $m = $map[$e.InterfaceAlias]; $mac = $m.Mac; $ls = $m.LinkSpeed; $out += [pscustomobject]@{ InterfaceAlias=$e.InterfaceAlias; IPAddress=$e.IPAddress; MacAddress=$mac; LinkSpeed=$ls } } "
|
||||||
"$out | ConvertTo-Json -Depth 3 } catch { '' }"
|
"$out | ConvertTo-Json -Depth 3 } catch { '' }"
|
||||||
)
|
)
|
||||||
data = _ps_json(ps_cmd, timeout=60)
|
data = _ps_json(ps_cmd, timeout=60)
|
||||||
@@ -357,9 +357,10 @@ def collect_network():
|
|||||||
alias = e.get('InterfaceAlias') or 'unknown'
|
alias = e.get('InterfaceAlias') or 'unknown'
|
||||||
ip = e.get('IPAddress') or ''
|
ip = e.get('IPAddress') or ''
|
||||||
mac = e.get('MacAddress') or 'unknown'
|
mac = e.get('MacAddress') or 'unknown'
|
||||||
|
link = e.get('LinkSpeed') or ''
|
||||||
if not ip:
|
if not ip:
|
||||||
continue
|
continue
|
||||||
item = tmp.setdefault(alias, {'adapter': alias, 'ips': [], 'mac': mac})
|
item = tmp.setdefault(alias, {'adapter': alias, 'ips': [], 'mac': mac, 'link_speed': link})
|
||||||
if ip not in item['ips']:
|
if ip not in item['ips']:
|
||||||
item['ips'].append(ip)
|
item['ips'].append(ip)
|
||||||
if tmp:
|
if tmp:
|
||||||
@@ -408,6 +409,88 @@ def collect_network():
|
|||||||
return adapters
|
return adapters
|
||||||
|
|
||||||
|
|
||||||
|
def collect_cpu() -> dict:
|
||||||
|
"""Collect CPU model, cores, and base clock (best-effort cross-platform)."""
|
||||||
|
out: dict = {}
|
||||||
|
try:
|
||||||
|
plat = platform.system().lower()
|
||||||
|
if plat == 'windows':
|
||||||
|
try:
|
||||||
|
ps_cmd = (
|
||||||
|
"Get-CimInstance Win32_Processor | "
|
||||||
|
"Select-Object Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed | ConvertTo-Json"
|
||||||
|
)
|
||||||
|
data = _ps_json(ps_cmd, timeout=15)
|
||||||
|
if isinstance(data, dict):
|
||||||
|
data = [data]
|
||||||
|
name = ''
|
||||||
|
phys = 0
|
||||||
|
logi = 0
|
||||||
|
mhz = 0
|
||||||
|
for idx, cpu in enumerate(data or []):
|
||||||
|
if idx == 0:
|
||||||
|
name = str(cpu.get('Name') or '')
|
||||||
|
try:
|
||||||
|
mhz = int(cpu.get('MaxClockSpeed') or 0)
|
||||||
|
except Exception:
|
||||||
|
mhz = 0
|
||||||
|
try:
|
||||||
|
phys += int(cpu.get('NumberOfCores') or 0)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
logi += int(cpu.get('NumberOfLogicalProcessors') or 0)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
out = {
|
||||||
|
'name': name.strip(),
|
||||||
|
'physical_cores': phys or None,
|
||||||
|
'logical_cores': logi or None,
|
||||||
|
'base_clock_ghz': (float(mhz) / 1000.0) if mhz else None,
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
elif plat == 'darwin':
|
||||||
|
try:
|
||||||
|
name = subprocess.run(["sysctl", "-n", "machdep.cpu.brand_string"], capture_output=True, text=True, timeout=5).stdout.strip()
|
||||||
|
except Exception:
|
||||||
|
name = ''
|
||||||
|
try:
|
||||||
|
cores = int(subprocess.run(["sysctl", "-n", "hw.ncpu"], capture_output=True, text=True, timeout=5).stdout.strip() or '0')
|
||||||
|
except Exception:
|
||||||
|
cores = 0
|
||||||
|
out = {'name': name, 'logical_cores': cores or None}
|
||||||
|
return out
|
||||||
|
else:
|
||||||
|
# Linux
|
||||||
|
try:
|
||||||
|
brand = ''
|
||||||
|
cores = 0
|
||||||
|
with open('/proc/cpuinfo', 'r', encoding='utf-8', errors='ignore') as fh:
|
||||||
|
for line in fh:
|
||||||
|
if not brand and 'model name' in line:
|
||||||
|
brand = line.split(':', 1)[-1].strip()
|
||||||
|
if 'processor' in line:
|
||||||
|
cores += 1
|
||||||
|
out = {'name': brand, 'logical_cores': cores or None}
|
||||||
|
return out
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# psutil fallback
|
||||||
|
try:
|
||||||
|
if psutil:
|
||||||
|
return {
|
||||||
|
'name': platform.processor() or '',
|
||||||
|
'physical_cores': psutil.cpu_count(logical=False) if hasattr(psutil, 'cpu_count') else None,
|
||||||
|
'logical_cores': psutil.cpu_count(logical=True) if hasattr(psutil, 'cpu_count') else None,
|
||||||
|
}
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return out or {}
|
||||||
|
|
||||||
def detect_device_type():
|
def detect_device_type():
|
||||||
try:
|
try:
|
||||||
plat = platform.system().lower()
|
plat = platform.system().lower()
|
||||||
@@ -645,6 +728,48 @@ def _build_details_fallback() -> dict:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# CPU information (summary + display string)
|
||||||
|
try:
|
||||||
|
cpu = collect_cpu()
|
||||||
|
if cpu:
|
||||||
|
summary['cpu'] = cpu
|
||||||
|
cores = cpu.get('logical_cores') or cpu.get('physical_cores')
|
||||||
|
ghz = cpu.get('base_clock_ghz')
|
||||||
|
name = (cpu.get('name') or '').strip()
|
||||||
|
parts = []
|
||||||
|
if name:
|
||||||
|
parts.append(name)
|
||||||
|
if ghz:
|
||||||
|
try:
|
||||||
|
parts.append(f"({float(ghz):.1f}GHz)")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if cores:
|
||||||
|
parts.append(f"@ {int(cores)} Cores")
|
||||||
|
if parts:
|
||||||
|
summary['processor'] = ' '.join(parts)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Total RAM (bytes) for quick UI metrics
|
||||||
|
try:
|
||||||
|
total = 0
|
||||||
|
mem_list = collect_memory()
|
||||||
|
for m in (mem_list or []):
|
||||||
|
try:
|
||||||
|
total += int(m.get('capacity') or 0)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if not total and psutil:
|
||||||
|
try:
|
||||||
|
total = int(psutil.virtual_memory().total)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if total:
|
||||||
|
summary['total_ram'] = total
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
details = {
|
details = {
|
||||||
'summary': summary,
|
'summary': summary,
|
||||||
'software': collect_software(),
|
'software': collect_software(),
|
||||||
|
|||||||
@@ -914,9 +914,22 @@ const LOCAL_STORAGE_KEY = "borealis_persistent_state";
|
|||||||
</Menu>
|
</Menu>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<Box sx={{ display: "flex", flexGrow: 1, overflow: "hidden" }}>
|
<Box sx={{ display: "flex", flexGrow: 1, overflow: "auto", minHeight: 0 }}>
|
||||||
<NavigationSidebar currentPage={currentPage} onNavigate={setCurrentPage} isAdmin={isAdmin} />
|
<NavigationSidebar currentPage={currentPage} onNavigate={setCurrentPage} isAdmin={isAdmin} />
|
||||||
<Box sx={{ flexGrow: 1, display: "flex", flexDirection: "column", overflow: "hidden" }}>
|
<Box
|
||||||
|
sx={{
|
||||||
|
flexGrow: 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
overflow: 'auto',
|
||||||
|
minHeight: 0,
|
||||||
|
// Ensure primary page container (usually a Paper with m:2) fills to the bottom
|
||||||
|
'& > *': {
|
||||||
|
alignSelf: 'stretch',
|
||||||
|
minHeight: 'calc(100% - 32px)' // account for typical m:2 top+bottom margins
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
{renderMainContent()}
|
{renderMainContent()}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogActions
|
DialogActions
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import StorageRoundedIcon from "@mui/icons-material/StorageRounded";
|
||||||
|
import MemoryRoundedIcon from "@mui/icons-material/MemoryRounded";
|
||||||
|
import SpeedRoundedIcon from "@mui/icons-material/SpeedRounded";
|
||||||
|
import DeveloperBoardRoundedIcon from "@mui/icons-material/DeveloperBoardRounded";
|
||||||
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
|
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
|
||||||
import { ClearDeviceActivityDialog } from "../Dialogs.jsx";
|
import { ClearDeviceActivityDialog } from "../Dialogs.jsx";
|
||||||
import Prism from "prismjs";
|
import Prism from "prismjs";
|
||||||
@@ -226,9 +230,28 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
}, [details.software, softwareSearch, softwareOrderBy, softwareOrder]);
|
}, [details.software, softwareSearch, softwareOrderBy, softwareOrder]);
|
||||||
|
|
||||||
const summary = details.summary || {};
|
const summary = details.summary || {};
|
||||||
|
// Build a best-effort CPU display from summary fields
|
||||||
|
const cpuInfo = useMemo(() => {
|
||||||
|
const cpu = summary.cpu || {};
|
||||||
|
const cores = cpu.logical_cores || cpu.cores || cpu.physical_cores;
|
||||||
|
let ghz = cpu.base_clock_ghz;
|
||||||
|
if (!ghz && typeof (summary.processor || '') === 'string') {
|
||||||
|
const m = String(summary.processor).match(/\(([^)]*?)ghz\)/i);
|
||||||
|
if (m && m[1]) {
|
||||||
|
const n = parseFloat(m[1]);
|
||||||
|
if (!Number.isNaN(n)) ghz = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const name = (cpu.name || '').trim();
|
||||||
|
const fromProcessor = (summary.processor || '').trim();
|
||||||
|
const display = fromProcessor || [name, ghz ? `(${Number(ghz).toFixed(1)}GHz)` : null, cores ? `@ ${cores} Cores` : null].filter(Boolean).join(' ');
|
||||||
|
return { cores, ghz, name, display };
|
||||||
|
}, [summary]);
|
||||||
|
|
||||||
const summaryItems = [
|
const summaryItems = [
|
||||||
{ label: "Hostname", value: summary.hostname || agent.hostname || device?.hostname || "unknown" },
|
{ label: "Hostname", value: summary.hostname || agent.hostname || device?.hostname || "unknown" },
|
||||||
{ label: "Operating System", value: summary.operating_system || agent.agent_operating_system || "unknown" },
|
{ label: "Operating System", value: summary.operating_system || agent.agent_operating_system || "unknown" },
|
||||||
|
{ label: "Processor", value: cpuInfo.display || "unknown" },
|
||||||
{ label: "Device Type", value: summary.device_type || "unknown" },
|
{ label: "Device Type", value: summary.device_type || "unknown" },
|
||||||
{ label: "Last User", value: (
|
{ label: "Last User", value: (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
@@ -246,42 +269,206 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
{ label: "Last Seen", value: formatLastSeen(agent.last_seen || device?.lastSeen) }
|
{ label: "Last Seen", value: formatLastSeen(agent.last_seen || device?.lastSeen) }
|
||||||
];
|
];
|
||||||
|
|
||||||
const renderSummary = () => (
|
const MetricCard = ({ icon, title, main, sub, color }) => {
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
const edgeColor = color || '#232323';
|
||||||
<Table size="small">
|
const parseHex = (hex) => {
|
||||||
<TableBody>
|
const v = String(hex || '').replace('#', '');
|
||||||
<TableRow>
|
const n = parseInt(v.length === 3 ? v.split('').map(c => c + c).join('') : v, 16);
|
||||||
<TableCell sx={{ fontWeight: 500 }}>Description</TableCell>
|
return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
|
||||||
<TableCell>
|
};
|
||||||
<TextField
|
const hexToRgba = (hex, alpha = 1) => {
|
||||||
size="small"
|
try { const { r, g, b } = parseHex(hex); return `rgba(${r}, ${g}, ${b}, ${alpha})`; } catch { return `rgba(88,166,255, ${alpha})`; }
|
||||||
value={description}
|
};
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
const lightenToRgba = (hex, p = 0.5, alpha = 1) => {
|
||||||
onBlur={saveDescription}
|
try {
|
||||||
placeholder="Enter description"
|
const { r, g, b } = parseHex(hex);
|
||||||
sx={{
|
const mix = (c) => Math.round(c + (255 - c) * p);
|
||||||
input: { color: "#fff" },
|
const R = mix(r), G = mix(g), B = mix(b);
|
||||||
"& .MuiOutlinedInput-root": {
|
return `rgba(${R}, ${G}, ${B}, ${alpha})`;
|
||||||
"& fieldset": { borderColor: "#555" },
|
} catch { return hexToRgba('#58a6ff', alpha); }
|
||||||
"&:hover fieldset": { borderColor: "#888" }
|
};
|
||||||
}
|
return (
|
||||||
}}
|
<Paper elevation={0} sx={{
|
||||||
/>
|
px: 2, py: 1.5, borderRadius: 2, position: 'relative',
|
||||||
</TableCell>
|
color: '#fff', minWidth: 260,
|
||||||
</TableRow>
|
border: '1px solid #2f2f2f',
|
||||||
{summaryItems.map((item) => (
|
// Base color with subtle left-to-right Borealis-blue gradient overlay
|
||||||
<TableRow key={item.label}>
|
background: `linear-gradient(90deg, rgba(88,166,255,0.12) 0%, rgba(88,166,255,0.06) 55%, rgba(88,166,255,0) 100%), ${edgeColor}`,
|
||||||
<TableCell sx={{ fontWeight: 500 }}>{item.label}</TableCell>
|
boxShadow: `inset 0 0 0 1px ${lightenToRgba(edgeColor, 0.35, 0.6)}`
|
||||||
<TableCell>{item.value}</TableCell>
|
}}>
|
||||||
</TableRow>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 1 }}>
|
||||||
))}
|
{icon}
|
||||||
</TableBody>
|
<Typography variant="caption" sx={{ opacity: 0.95, fontWeight: 700 }}>{title}</Typography>
|
||||||
</Table>
|
</Box>
|
||||||
</Box>
|
<Typography variant="h6" sx={{ lineHeight: 1.2, mb: 1 }}>{main}</Typography>
|
||||||
|
<Box sx={{ flexGrow: 1, minHeight: 12 }} />
|
||||||
|
<Box sx={{ minHeight: 8 }} />
|
||||||
|
{sub ? <Typography variant="body2" sx={{ opacity: 0.85 }}>{sub}</Typography> : null}
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Island = ({ title, children, sx }) => (
|
||||||
|
<Paper elevation={0} sx={{ p: 1.5, borderRadius: 2, bgcolor: '#1c1c1c', border: '1px solid #2a2a2a', mb: 1.5, ...(sx || {}) }}>
|
||||||
|
<Typography variant="caption" sx={{ color: '#58a6ff', fontWeight: 400, fontSize: '14px', letterSpacing: 0.2, display: 'block', mb: 1 }}>{title}</Typography>
|
||||||
|
{children}
|
||||||
|
</Paper>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const renderSummary = () => {
|
||||||
|
// Derive metric values
|
||||||
|
// CPU tile: model as main, speed as sub (like screenshot)
|
||||||
|
const cpuMain = (cpuInfo.name || (summary.processor || '') || '').split('\n')[0] || 'Unknown CPU';
|
||||||
|
const cpuSub = cpuInfo.ghz || cpuInfo.cores
|
||||||
|
? (
|
||||||
|
<span>
|
||||||
|
{cpuInfo.ghz ? `${Number(cpuInfo.ghz).toFixed(2)}GHz ` : ''}
|
||||||
|
{cpuInfo.cores ? <span style={{ opacity: 0.75 }}>({cpuInfo.cores}-Cores)</span> : null}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// MEMORY: total RAM
|
||||||
|
let totalRam = summary.total_ram;
|
||||||
|
if (!totalRam && Array.isArray(details.memory)) {
|
||||||
|
try { totalRam = details.memory.reduce((a, m) => a + (Number(m.capacity || 0) || 0), 0); } catch {}
|
||||||
|
}
|
||||||
|
const memVal = totalRam ? `${formatBytes(totalRam)}` : 'Unknown';
|
||||||
|
// RAM speed best-effort: use max speed among modules
|
||||||
|
let memSpeed = '';
|
||||||
|
try {
|
||||||
|
const speeds = (details.memory || [])
|
||||||
|
.map(m => parseInt(String(m.speed || '').replace(/[^0-9]/g, ''), 10))
|
||||||
|
.filter(v => !Number.isNaN(v) && v > 0);
|
||||||
|
if (speeds.length) memSpeed = `Speed: ${Math.max(...speeds)} MT/s`;
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
// STORAGE: OS drive (Windows C: if available)
|
||||||
|
let osDrive = null;
|
||||||
|
if (Array.isArray(details.storage)) {
|
||||||
|
osDrive = details.storage.find((d) => String(d.drive || '').toUpperCase().startsWith('C:')) || details.storage[0] || null;
|
||||||
|
}
|
||||||
|
const storageMain = osDrive && osDrive.total != null ? `${formatBytes(osDrive.total)}` : 'Unknown';
|
||||||
|
const storageSub = (osDrive && osDrive.used != null && osDrive.total != null)
|
||||||
|
? `${formatBytes(osDrive.used)} of ${formatBytes(osDrive.total)} used`
|
||||||
|
: (osDrive && osDrive.free != null && osDrive.total != null)
|
||||||
|
? `${formatBytes(osDrive.total - osDrive.free)} of ${formatBytes(osDrive.total)} used`
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// NETWORK: Speed of adapter with internal IP or first
|
||||||
|
const primaryIp = (summary.internal_ip || '').trim();
|
||||||
|
let nic = null;
|
||||||
|
if (Array.isArray(details.network)) {
|
||||||
|
nic = details.network.find((n) => (n.ips || []).includes(primaryIp)) || details.network[0] || null;
|
||||||
|
}
|
||||||
|
function normalizeSpeed(val) {
|
||||||
|
const s = String(val || '').trim();
|
||||||
|
if (!s) return 'unknown';
|
||||||
|
const low = s.toLowerCase();
|
||||||
|
if (low.includes('gbps') || low.includes('mbps')) return s;
|
||||||
|
const m = low.match(/(\d+\.?\d*)\s*([gmk]?)(bps)/);
|
||||||
|
if (!m) return s;
|
||||||
|
let num = parseFloat(m[1]);
|
||||||
|
const unit = m[2];
|
||||||
|
if (unit === 'g') return `${num} Gbps`;
|
||||||
|
if (unit === 'm') return `${num} Mbps`;
|
||||||
|
if (unit === 'k') return `${(num/1000).toFixed(1)} Mbps`;
|
||||||
|
// raw bps
|
||||||
|
if (num >= 1e9) return `${(num/1e9).toFixed(1)} Gbps`;
|
||||||
|
if (num >= 1e6) return `${(num/1e6).toFixed(0)} Mbps`;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
const netVal = nic ? normalizeSpeed(nic.link_speed || nic.speed) : 'Unknown';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
{/* Metrics row at the very top */}
|
||||||
|
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat( auto-fit, minmax(260px, 1fr) )', gap: 1.5, mb: 2 }}>
|
||||||
|
<MetricCard
|
||||||
|
icon={<DeveloperBoardRoundedIcon sx={{ fontSize: 32, opacity: 0.95 }} />}
|
||||||
|
title="Processor"
|
||||||
|
main={cpuMain}
|
||||||
|
sub={cpuSub}
|
||||||
|
color="#132332"
|
||||||
|
/>
|
||||||
|
<MetricCard
|
||||||
|
icon={<MemoryRoundedIcon sx={{ fontSize: 32, opacity: 0.95 }} />}
|
||||||
|
title="Installed RAM"
|
||||||
|
main={memVal}
|
||||||
|
sub={memSpeed || ' '}
|
||||||
|
color="#291a2e"
|
||||||
|
/>
|
||||||
|
<MetricCard
|
||||||
|
icon={<StorageRoundedIcon sx={{ fontSize: 32, opacity: 0.95 }} />}
|
||||||
|
title="Storage"
|
||||||
|
main={storageMain}
|
||||||
|
sub={storageSub || ' '}
|
||||||
|
color="#142616"
|
||||||
|
/>
|
||||||
|
<MetricCard
|
||||||
|
icon={<SpeedRoundedIcon sx={{ fontSize: 32, opacity: 0.95 }} />}
|
||||||
|
title="Network"
|
||||||
|
main={netVal}
|
||||||
|
sub={(nic && nic.adapter) ? nic.adapter : ' '}
|
||||||
|
color="#2b1a18"
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
{/* Split pane: three-column layout (Summary | Storage | Memory/Network) */}
|
||||||
|
<Box sx={{
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateColumns: { xs: '1fr', md: '1.2fr 1fr 1fr' },
|
||||||
|
gap: 2
|
||||||
|
}}>
|
||||||
|
{/* Left column: Summary table */}
|
||||||
|
<Island title="Device Summary">
|
||||||
|
<Box>
|
||||||
|
<Table size="small">
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={{ fontWeight: 500 }}>Description</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<TextField
|
||||||
|
size="small"
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
onBlur={saveDescription}
|
||||||
|
placeholder="Enter description"
|
||||||
|
sx={{
|
||||||
|
input: { color: '#fff' },
|
||||||
|
'& .MuiOutlinedInput-root': {
|
||||||
|
'& fieldset': { borderColor: '#555' },
|
||||||
|
'&:hover fieldset': { borderColor: '#888' }
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
{summaryItems.map((item) => (
|
||||||
|
<TableRow key={item.label}>
|
||||||
|
<TableCell sx={{ fontWeight: 500 }}>{item.label}</TableCell>
|
||||||
|
<TableCell>{item.value}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</Box>
|
||||||
|
</Island>
|
||||||
|
|
||||||
|
{/* Middle column: Storage */}
|
||||||
|
<Island title="Storage">{renderStorage()}</Island>
|
||||||
|
|
||||||
|
{/* Right column: Memory + Network */}
|
||||||
|
<Box>
|
||||||
|
<Island title="Memory">{renderMemory()}</Island>
|
||||||
|
<Island title="Network">{renderNetwork()}</Island>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const placeholderTable = (headers) => (
|
const placeholderTable = (headers) => (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -306,8 +493,8 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
return placeholderTable(["Software Name", "Version", "Action"]);
|
return placeholderTable(["Software Name", "Version", "Action"]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box sx={{ width: '100%' }}>
|
||||||
<Box sx={{ mb: 1 }}>
|
<Box sx={{ mb: 1, width: '100%' }}>
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Search software..."
|
placeholder="Search software..."
|
||||||
@@ -322,8 +509,8 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box sx={{ width: '100%' }}>
|
||||||
<Table size="small">
|
<Table size="small" sx={{ width: '100%' }}>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell sortDirection={softwareOrderBy === "name" ? softwareOrder : false}>
|
<TableCell sortDirection={softwareOrderBy === "name" ? softwareOrder : false}>
|
||||||
@@ -366,7 +553,7 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
const rows = details.memory || [];
|
const rows = details.memory || [];
|
||||||
if (!rows.length) return placeholderTable(["Slot", "Speed", "Serial Number", "Capacity"]);
|
if (!rows.length) return placeholderTable(["Slot", "Speed", "Serial Number", "Capacity"]);
|
||||||
return (
|
return (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -440,80 +627,54 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!rows.length)
|
if (!rows.length) {
|
||||||
return placeholderTable([
|
return placeholderTable(["Drive", "Type", "Capacity"]);
|
||||||
"Drive Letter",
|
}
|
||||||
"Disk Type",
|
|
||||||
"Used",
|
const fmtPct = (v) => (v !== undefined && !Number.isNaN(v) ? `${v.toFixed(0)}%` : "unknown");
|
||||||
"Free %",
|
|
||||||
"Free GB",
|
|
||||||
"Total Size",
|
|
||||||
"Usage",
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box>
|
||||||
<Table size="small">
|
{rows.map((d, i) => {
|
||||||
<TableHead>
|
const usage = d.usage ?? (d.total ? ((d.used || 0) / d.total) * 100 : 0);
|
||||||
<TableRow>
|
const used = d.used;
|
||||||
<TableCell>Drive Letter</TableCell>
|
const free = d.freeBytes;
|
||||||
<TableCell>Disk Type</TableCell>
|
const total = d.total;
|
||||||
<TableCell>Used</TableCell>
|
return (
|
||||||
<TableCell>Free %</TableCell>
|
<Box key={`${d.drive}-${i}`} sx={{ p: 1, borderBottom: '1px solid #2a2a2a', '&:last-child': { borderBottom: 'none' } }}>
|
||||||
<TableCell>Free GB</TableCell>
|
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 1 }}>
|
||||||
<TableCell>Total Size</TableCell>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.2 }}>
|
||||||
<TableCell>Usage</TableCell>
|
<Box sx={{ width: 8, height: 8, bgcolor: '#58a6ff', borderRadius: 0.5 }} />
|
||||||
</TableRow>
|
<Typography variant="body2" sx={{ fontWeight: 600 }}>{`Drive ${String(d.drive || '').replace('\\', '')}`}</Typography>
|
||||||
</TableHead>
|
<Typography variant="caption" sx={{ opacity: 0.7 }}>{d.disk_type || 'Fixed Disk'}</Typography>
|
||||||
<TableBody>
|
</Box>
|
||||||
{rows.map((d, i) => (
|
<Typography variant="body2" sx={{ opacity: 0.9 }}>{total !== undefined ? formatBytes(total) : 'unknown'}</Typography>
|
||||||
<TableRow key={`${d.drive}-${i}`}>
|
</Box>
|
||||||
<TableCell>{d.drive}</TableCell>
|
<Box sx={{
|
||||||
<TableCell>{d.disk_type}</TableCell>
|
position: 'relative', height: 8, borderRadius: 1,
|
||||||
<TableCell>
|
bgcolor: '#2b2b2b',
|
||||||
{d.used !== undefined && !Number.isNaN(d.used)
|
background: 'linear-gradient(180deg, #323232 0%, #2a2a2a 100%)',
|
||||||
? formatBytes(d.used)
|
boxShadow: 'inset 0 0 0 1px #3a3a3a, inset 0 1px 0 rgba(255,255,255,0.06)'
|
||||||
: "unknown"}
|
}}>
|
||||||
</TableCell>
|
<Box sx={{
|
||||||
<TableCell>
|
position: 'absolute', left: 0, top: 0, bottom: 0,
|
||||||
{d.freePct !== undefined && !Number.isNaN(d.freePct)
|
width: `${Math.max(0, Math.min(100, usage || 0)).toFixed(0)}%`,
|
||||||
? `${d.freePct.toFixed(1)}%`
|
borderRadius: 1,
|
||||||
: "unknown"}
|
background: 'linear-gradient(90deg, rgba(0,209,140,0.95) 0%, rgba(0,209,140,0.80) 45%, rgba(0,209,140,0.70) 100%)',
|
||||||
</TableCell>
|
boxShadow: 'inset 0 0 0 1px rgba(255,255,255,0.15), 0 0 6px rgba(0,209,140,0.25)'
|
||||||
<TableCell>
|
}} />
|
||||||
{d.freeBytes !== undefined && !Number.isNaN(d.freeBytes)
|
</Box>
|
||||||
? formatBytes(d.freeBytes)
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 0.75 }}>
|
||||||
: "unknown"}
|
<Typography variant="caption" sx={{ opacity: 0.85 }}>
|
||||||
</TableCell>
|
{used !== undefined ? `${formatBytes(used)} - ${fmtPct(usage)} in use` : 'unknown'}
|
||||||
<TableCell>
|
</Typography>
|
||||||
{d.total !== undefined && !Number.isNaN(d.total)
|
<Typography variant="caption" sx={{ opacity: 0.85 }}>
|
||||||
? formatBytes(d.total)
|
{free !== undefined && total !== undefined ? `${formatBytes(free)} - ${fmtPct(100 - (usage || 0))} remaining` : ''}
|
||||||
: "unknown"}
|
</Typography>
|
||||||
</TableCell>
|
</Box>
|
||||||
<TableCell>
|
</Box>
|
||||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
);
|
||||||
<Box sx={{ flexGrow: 1, mr: 1 }}>
|
})}
|
||||||
<LinearProgress
|
|
||||||
variant="determinate"
|
|
||||||
value={d.usage ?? 0}
|
|
||||||
sx={{
|
|
||||||
height: 10,
|
|
||||||
bgcolor: "#333",
|
|
||||||
"& .MuiLinearProgress-bar": { bgcolor: "#00d18c" }
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="body2">
|
|
||||||
{d.usage !== undefined && !Number.isNaN(d.usage)
|
|
||||||
? `${d.usage.toFixed(1)}%`
|
|
||||||
: "unknown"}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
))}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -522,7 +683,7 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
const rows = details.network || [];
|
const rows = details.network || [];
|
||||||
if (!rows.length) return placeholderTable(["Adapter", "IP Address", "MAC Address"]);
|
if (!rows.length) return placeholderTable(["Adapter", "IP Address", "MAC Address"]);
|
||||||
return (
|
return (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -598,7 +759,7 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
}, [historyRows, historyOrderBy, historyOrder]);
|
}, [historyRows, historyOrderBy, historyOrder]);
|
||||||
|
|
||||||
const renderHistory = () => (
|
const renderHistory = () => (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: "auto" }}>
|
<Box>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -681,10 +842,7 @@ export default function DeviceDetails({ device, onBack }) {
|
|||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ label: "Summary", content: renderSummary() },
|
{ label: "Summary", content: renderSummary() },
|
||||||
{ label: "Software", content: renderSoftware() },
|
{ label: "Installed Software", content: renderSoftware() },
|
||||||
{ label: "Memory", content: renderMemory() },
|
|
||||||
{ label: "Storage", content: renderStorage() },
|
|
||||||
{ label: "Network", content: renderNetwork() },
|
|
||||||
{ label: "Activity History", content: renderHistory() }
|
{ label: "Activity History", content: renderHistory() }
|
||||||
];
|
];
|
||||||
// Use the snapshotted status so it stays static while on this page
|
// Use the snapshotted status so it stays static while on this page
|
||||||
|
|||||||
Reference in New Issue
Block a user