From 04037c7acf79748206ecf5d51a9599418833ec61 Mon Sep 17 00:00:00 2001 From: Kevin Janssen Date: Fri, 20 Nov 2026 08:53:20 +0100 Subject: [PATCH] Display Windows fixed volumes individually in both fleet views --- crates/server/src/devices.rs | 24 ++++++++++++++++++++++- tests/browser/customer-management.spec.ts | 19 ++++++++++++++++-- web/src/devices.tsx | 15 +++++++++++++- web/src/style.css | 1 + 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/crates/server/src/devices.rs b/crates/server/src/devices.rs index 57156f8..521233c 100644 --- a/crates/server/src/devices.rs +++ b/crates/server/src/devices.rs @@ -261,7 +261,6 @@ pub async fn detail( .ok_or(Error(StatusCode::NOT_FOUND, "NOT_FOUND"))?; let hosts = assigned_hosts(&mut tx, tenant, now, std::slice::from_ref(&row)).await?; let mut item = project(&row, now, true, &hosts); - item["volumes"] = volumes(&item["inventory"]); item["recent_jobs"] = if p.permits_scope("operations:read") && crate::permissions::allowed(&mut tx, &p.name, "operations:read").await? { @@ -296,6 +295,14 @@ fn observed<'a>(data: &'a Value, scope: &str) -> &'a Value { } fn volumes(data: &Value) -> Value { let mut items = Vec::new(); + if let Some(drives) = observed(data, "windows.volumes")["drives"].as_array() { + let mut seen = std::collections::HashSet::new(); + for drive in drives.iter().take(26) { + let Some(name) = drive["name"].as_str() else { continue }; + if !matches!(name.as_bytes(), [b'A'..=b'Z', b':']) || !seen.insert(name) { continue; } + items.push(json!({"name":name,"free_bytes":drive["free_bytes"].as_u64(),"total_bytes":drive["total_bytes"].as_u64()})); + } + } if let Some(rows) = observed(data, "linux.volumes").as_array() { for entry in rows.iter().filter(|entry| entry["quality"] == "valid") { let v = &entry["data"]; @@ -552,6 +559,9 @@ fn project(row: &PgRow, now: DateTime, full: bool, hosts: &HashMap,_>("source_id"),"quality":if data.is_null(){"unknown"}else{"valid"}, "completeness":"partial","health":"unknown" }); + if full || observed(&data, "windows.volumes").is_object() { + item["volumes"] = volumes(&data); + } if device_type == Some(DeviceType::Virtual) && row.get::("lifecycle") == "current" { let assigned_id: Option = row.get("hypervisor_asset_id"); let assigned = assigned_id.and_then(|id| hosts.get(&id)); @@ -578,6 +588,18 @@ fn project(row: &PgRow, now: DateTime, full: bool, hosts: &HashMap String { let old = json!({"os":name,"observations":[{"scope":"windows.os","quality":"valid", "data":{"product_name":name,"build":build,"display_version":"26H2"}}]}); diff --git a/tests/browser/customer-management.spec.ts b/tests/browser/customer-management.spec.ts index 13402f2..e3ecd16 100644 --- a/tests/browser/customer-management.spec.ts +++ b/tests/browser/customer-management.spec.ts @@ -48,7 +48,12 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk json: listing(readings.map(([hostname, free, total]) => ({ 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 + disk_free_bytes: free, disk_total_bytes: total, + ...(hostname === 'mostly-free' ? { volumes: [ + { name: 'C:', free_bytes: free, total_bytes: total }, + { name: 'D:', free_bytes: 0, total_bytes: 64 * gib }, + { name: 'E:', free_bytes: null, total_bytes: null } + ] } : {}) }))) }); return route.fulfill({ status: 404 }); @@ -58,7 +63,11 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk for (const width of [1280, 900, 390]) { await page.setViewportSize({ width, height: 844 }); for (const label of ['RAM', 'Speicher']) { - const cell = (host: string) => row(host).locator(`[data-label="${label} belegt / gesamt"]`); + const cell = (host: string) => { + const column = row(host).locator(`[data-label="${label} belegt / gesamt"]`); + return host === 'mostly-free' && label === 'Speicher' + ? column.locator('.drive-capacity').filter({ hasText: 'C:' }) : column; + }; for (const [host, used, usedGiB] of [['mostly-free', 25, 4], ['all-used', 100, 16], ['all-free', 0, 0]] as const) { await expect(cell(host)).toContainText(`${usedGiB} / 16 GiB`); await expect(cell(host).locator('.capacity-caption')).toHaveText(`${used} % belegt`); @@ -77,6 +86,12 @@ test('shows used disk and RAM in GiB and draws the occupied share in red on desk await expect(cell(host)).toHaveText(host === 'invalid-total' ? 'Nicht gemeldet' : '– / 16 GiB'); } } + const drives = row('mostly-free').locator('.drive-capacity'); + await expect(drives).toHaveCount(3); + await expect(drives.nth(1)).toContainText('D: 64 / 64 GiB'); + 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); } }); diff --git a/web/src/devices.tsx b/web/src/devices.tsx index 564d68d..30eeb6a 100644 --- a/web/src/devices.tsx +++ b/web/src/devices.tsx @@ -119,6 +119,19 @@ function Capacity({ free, total }: { ); } +function DiskCapacity({ device }: { device: RecordValue }) { + // 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 ; + return <>{drives.map(drive => ( +
+ {String(drive.name)}{' '} +
+ ))}; +} + type Target = { customer: string; ids: string[] }; type Props = { detailPath: string; @@ -699,7 +712,7 @@ export function Devices({ )} - + diff --git a/web/src/style.css b/web/src/style.css index f4991aa..cdcc88f 100644 --- a/web/src/style.css +++ b/web/src/style.css @@ -105,6 +105,7 @@ section.fleet { padding:0; overflow:hidden; } .fleet-table input[type=checkbox] { margin:0; } .host-link { padding:0; background:none; color:var(--accent); text-align:left; font-weight:680; margin:0; overflow-wrap:anywhere; } .fleet-table .capacity-cell { font-variant-numeric:tabular-nums; } +.drive-capacity + .drive-capacity { margin-top:8px; } .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; }