diff --git a/crates/server/src/devices.rs b/crates/server/src/devices.rs index 521233c..3d42dc1 100644 --- a/crates/server/src/devices.rs +++ b/crates/server/src/devices.rs @@ -562,6 +562,13 @@ fn project(row: &PgRow, now: DateTime, full: bool, hosts: &HashMap("lifecycle") == "current" { let assigned_id: Option = row.get("hypervisor_asset_id"); let assigned = assigned_id.and_then(|id| hosts.get(&id)); diff --git a/tests/browser/customer-management.spec.ts b/tests/browser/customer-management.spec.ts index e3ecd16..8dafce8 100644 --- a/tests/browser/customer-management.spec.ts +++ b/tests/browser/customer-management.spec.ts @@ -30,6 +30,7 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk ['missing-available', null, 16 * gib], ['invalid-range', 17 * gib, 16 * gib], ['invalid-total', 0, 0], + ['linux-drives', null, null], ] as const; const listing = (items: unknown[]) => ({ items, next_cursor: null, truncated: false, completeness: 'complete', as_of: '2026-11-19T12:00:00Z' @@ -49,6 +50,11 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk tenant_id: customer.tenant_id, customer_name: customer.name, asset_id: hostname, agent_id: hostname, lifecycle: 'current', status: 'online', hostname, ram_available_bytes: free, ram_total_bytes: total, disk_free_bytes: free, disk_total_bytes: total, + ...(hostname === 'linux-drives' ? {disks:[ + {kind:'disk',name:'sda',model:'Testplatte',total_bytes:64*gib,used_bytes:16*gib,available_bytes:40*gib}, + {kind:'disk',name:'sdb',total_bytes:64*gib,used_bytes:null,available_bytes:null}, + {kind:'group',name:'md0',members:['sda','sdb'],total_bytes:8*gib,used_bytes:2*gib,available_bytes:6*gib} + ]} : {}), ...(hostname === 'mostly-free' ? { volumes: [ { name: 'C:', free_bytes: free, total_bytes: total }, { name: 'D:', free_bytes: 0, total_bytes: 64 * gib }, @@ -92,6 +98,14 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk await expect(drives.nth(1).getByRole('img', { name: '100 % belegt, 0 % frei' })).toBeVisible(); await expect(drives.nth(2)).toHaveText('E: Nicht gemeldet'); await expect(drives.nth(2).getByRole('img')).toHaveCount(0); + const linux = row('linux-drives').locator('.drive-capacity'); + await expect(linux).toHaveCount(3); + await expect(linux.nth(0)).toContainText('16 / 64 GiB'); + await expect(linux.nth(0).getByRole('img',{name:'25 % belegt, 62,5 % frei, 12,5 % nicht zugeordnet'})).toBeVisible(); + await expect(linux.nth(1)).toContainText('Belegung nicht ermittelbar'); + await expect(linux.nth(1)).toContainText('Im Verbund: md0'); + await expect(linux.nth(2)).toContainText('Verbund: md0'); + await expect(linux.nth(2)).toContainText('2 / 8 GiB'); } }); diff --git a/web/src/devices.tsx b/web/src/devices.tsx index 30eeb6a..965cbe2 100644 --- a/web/src/devices.tsx +++ b/web/src/devices.tsx @@ -119,12 +119,41 @@ function Capacity({ free, total }: { ); } +function LinuxDisk({ disk, groups }: { disk: RecordValue; groups: string[] }) { + const { used_bytes: used, available_bytes: free, total_bytes: total } = disk; + const size = typeof total === 'number' && Number.isFinite(total) && total > 0 ? total : null; + const valid = size !== null && typeof used === 'number' && used >= 0 && typeof free === 'number' && free >= 0 && used + free <= size; + const usedPct = valid ? used / size * 100 : 0, freePct = valid ? free / size * 100 : 0; + const summary = valid ? `${number.format(usedPct)} % belegt, ${number.format(freePct)} % frei, ${number.format(Math.max(0,100-usedPct-freePct))} % nicht zugeordnet` : 'Belegung nicht ermittelbar'; + const group = disk.kind === 'group'; + return
+ {group ? 'Verbund: ' : ''}{label(disk.name)} + {typeof disk.model === 'string' && {disk.model}} + {group && Array.isArray(disk.members) && disk.members.length > 0 && {disk.members.filter(v => typeof v === 'string').join(', ')}} + {!group && groups.length > 0 && Im Verbund: {groups.join(', ')}} +
{size === null ? 'Größe nicht gemeldet' : `${valid ? gib(used) : '–'} / ${gib(size)} GiB`}
+ {size !== null && + + + } + {valid ? `${number.format(usedPct)} % belegt` : summary} +
; +} + function DiskCapacity({ device }: { device: RecordValue }) { + if ('disks' in device) { + const disks = Array.isArray(device.disks) ? device.disks.filter(d => d && typeof d === 'object' && ['disk','group'].includes(d.kind) && typeof d.name === 'string') : []; + return <>{disks.length ? disks.map((disk,i) => g.kind === 'group' && Array.isArray(g.members) && g.members.includes(disk.name)).map(g => g.name) : []}/>) : + Keine Festplatten gemeldet} + {device.disks_truncated === true && Liste gekürzt}; + } // Only Windows fleet rows use drive letters. Linux mount inventories remain // available in the detail view, without expanding every fleet row. const drives = Array.isArray(device.volumes) ? device.volumes.map(v => record(v)).filter(v => typeof v.name === 'string' && /^[A-Z]:$/.test(v.name)) : []; - if (!drives.length) return ; + if (!drives.length) return <>{device.source_id === 'linux.base' && Root-Dateisystem /} + ; return <>{drives.map(drive => (
{String(drive.name)}{' '} diff --git a/web/src/style.css b/web/src/style.css index cdcc88f..35ad473 100644 --- a/web/src/style.css +++ b/web/src/style.css @@ -109,6 +109,8 @@ section.fleet { padding:0; overflow:hidden; } .capacity-track { display:flex; width:min(90px,100%); border-radius:2px; background:#e1ebe6; height:6px; margin-top:6px; overflow:hidden; } .capacity-used { flex:none; background:#c78980; } .capacity-free { flex:1; background:#2e7657; } +.disk-track { background:#aebbb6; } +.disk-track .capacity-free { flex:none; } .capacity-caption { display:block; color:var(--subtle); } .presence { display:inline-flex; align-items:center; gap:5px; border-radius:20px; padding:2px 8px; background:#edf1ef; color:#4d5f59; font-size:.8rem; font-weight:650; } .presence i { width:6px; height:6px; border-radius:50%; background:currentColor; }