Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e29257b808 |
@@ -10,7 +10,7 @@ Jede Installation ist an Kunde, Gerät und Agentenidentität gebunden. Die Stand
|
||||
|
||||
Der Agent meldet den Gerätetyp mit dem passiven Hardwareinventar. `physical` bezeichnet einen physischen Rechner, `virtual` ein virtualisiertes System und `hypervisor` eine erkannte Hostrolle. Proxmox VE erscheint als `hypervisor` mit `Proxmox VE` in der Spalte OS. Eine erkannte Hostrolle hat Vorrang, auch bei verschachtelter Virtualisierung. Bei fehlender Angabe zeigt die WebUI „Nicht gemeldet“. Die Geräteabfragen in WebUI und MCP verwenden denselben gespeicherten Typ. [Inventarprojektion](crates/server/src/devices.rs)
|
||||
|
||||
Für aktuelle virtuelle Geräte kann die WebUI einen registrierten Hypervisor aus demselben Kundenbestand zuordnen. Die Geräteübersicht zeigt diese Verbindung unter dem Hostnamen der VM und verlinkt auf die Gerätedetails des Hypervisors. Die Zuordnung gilt, solange der verknüpfte Host im Bestand ist und sich als Hypervisor meldet. Eine VM mit gemeldetem Hersteller Hetzner erhält bei fehlendem konkreten Host den Anzeigeplatzhalter „Hetzner Cloud“. Der Platzhalter hat keine Kopplung und zählt nicht als registriertes Gerät.
|
||||
Für aktuelle virtuelle Geräte kann die WebUI einen registrierten Hypervisor aus demselben Kundenbestand zuordnen. Die Geräteübersicht des Bestands gliedert die Geräte einer Seite in Blöcke: je Hypervisor ein Block mit dem Host und seinen eingerückten VMs, danach „Hetzner Cloud“, „Physische Geräte“ und „Nicht zugeordnet“. Der Blockkopf des Hypervisors verlinkt auf dessen Gerätedetails, auch wenn der Host selbst nicht auf der Seite steht. An jeder VM steht, ob die Zuordnung automatisch erkannt oder manuell gesetzt wurde. Die Historie bleibt eine einfache Liste. Die Zuordnung gilt, solange der verknüpfte Host im Bestand ist und sich als Hypervisor meldet. Eine VM mit gemeldetem Hersteller Hetzner erhält bei fehlendem konkreten Host den Anzeigeplatzhalter „Hetzner Cloud“. Der Platzhalter hat keine Kopplung und zählt nicht als registriertes Gerät.
|
||||
|
||||
Ein aufgenommener Proxmox-VE-Host meldet über einen vom Installer eingerichteten, nur lesenden API-Token (`PVEAuditor`) die Gäste seines Nodes, die geplanten vzdump-Backupjobs und die Läufe der letzten acht Tage. Die Gerätedetails des Hosts listen VMs und Container mit Status, Ressourcen, zugeordnetem Gerät und letzter erfolgreicher Sicherung. Darunter folgen die Backupjobs mit Zeitplan, Storage, gesicherten Gästen, letztem fälligen Zeitpunkt, Ergebnis und nächstem Lauf sowie die Gäste ohne Backupjob. Der Server bewertet jeden aktiven Job als gelaufen, fehlgeschlagen, verpasst, laufend oder noch nicht fällig. Er beantwortet damit, ob alle geplanten Backups gelaufen sind. Ein virtuelles Gerät, dessen MAC-Adresse eindeutig in der Gastliste eines Proxmox-Hosts desselben Kunden steht, wird diesem Host automatisch als Hypervisor zugeordnet und so gekennzeichnet. Eine manuelle Zuordnung hat Vorrang und lässt sich wieder an die automatische Erkennung zurückgeben. [Proxmox-Host](deploy/proxmox/README.md)
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ Alle acht Versuche lieferten Exitcode 0. Bei beiden Neustarts wurde die Wiederan
|
||||
| RAM und CPU-Auslastung in der Übersicht | RAM als verfügbar / gesamt in GiB mit demselben Belegungsbalken wie beim Speicherplatz. Die CPU-Spalte zeigt die letzte gemessene Auslastung in Prozent. Am 18. November wurde `6ed57c4` mit Schema 41 produktiv aktiviert. Beide TLS-Healthchecks und der öffentliche WebUI-Index stimmten mit dem Build überein. Die öffentliche Übersicht zeigte die RAM-Balken auf Desktop und bei 390 px Breite für alle drei Geräte. Die Detailansicht und die automatische Aktualisierung wurden in Chromium auf Linux x64 und ARM64 nachgelesen. OTRS meldete um 18:05 UTC nach dem signierten Wechsel auf `0.1.0-arm64.3` `6,2 / 7,6 GiB` und `1,1 %`. Um 18:06 UTC meldeten Linux x64 `0.1.0-mvp.9`, Windows `0.1.18` und ARM64 frische CPU-Werte und waren authentisiert erreichbar. [Geräteansicht](../web/src/devices.tsx) · [Geräteprojektion](../crates/server/src/devices.rs) |
|
||||
| Gerätetyp in der Übersicht | Spalte „Type“ nach „Hostname“ mit `physical`, `virtual` und `hypervisor`. Erkannte Proxmox-VE-Hosts zeigen `Proxmox VE` als OS. Am 18. November wurde `c599baa` auf dem öffentlichen Server aktiviert. Der Serverrunner bestätigte API, Gateway und öffentlichen API-Dienst mit Binärhash `4f9c8c60…`. Der öffentliche WebUI-Index stimmte mit dem gebauten Bundle überein. Die unveränderten Geräteidentitäten meldeten nach regulärem signierten Update `virtual` auf Linux mit `0.1.0-mvp.7` um 16:45 UTC und Windows mit `0.1.17` um 16:47 UTC. Geräteliste, Details, Mobilansicht mit 390 px und Historie sind in der öffentlichen WebUI geprüft. Beide Pakete sind in Development A und B und als Starter für leere Kataloge veröffentlicht. Die Typen `physical` und `hypervisor` sind mit Testdaten geprüft. Die Feldabnahme auf einem physischen Gerät und einem Proxmox-VE-Host steht aus. [Inventarprojektion](../crates/server/src/devices.rs) · [Geräteansicht](../web/src/devices.tsx) |
|
||||
| Hostzuordnung bei VMs | Die WebUI zeigt einen zugeordneten Hypervisor direkt an der VM. Der Browsertest prüfte Zuordnung, Verlinkung, Entfernen und den Hetzner-Platzhalter bei 390 px Breite. In PostgreSQL wurden die Page-Grenze, archivierte Hypervisoren und die Trennung der Kunden geprüft. 80 WebUI-Tests, vier Browsertests und fünf Rust-Gerätetests bestanden. Revision `bcd3bd8` wurde am 18. November um 21:43 UTC mit Schema 43 aktiviert. Der Serverrunner bestätigte die TLS-Healthchecks und der öffentliche Index entsprach dem Build. In der öffentlichen WebUI zeigten zwei vorhandene Hetzner-VMs den Platzhalter auf Desktop und Mobil. Die Auswahl war im Gerätedetail verfügbar. Der Bestand enthielt zum Prüfzeitpunkt keinen registrierten Hypervisor. [Geräteansicht](../web/src/device-hypervisor.tsx) · [Hostsuche](../crates/server/src/hypervisors.sql) |
|
||||
| Gruppierte Geräteübersicht | Der Bestand zeigt je Hypervisor einen Block mit Host und eingerückten VMs, danach „Hetzner Cloud“, „Physische Geräte“ und „Nicht zugeordnet“. Am 20. November bestanden 87 WebUI-Tests, darunter vier zur Gruppierung (Reihenfolge, Host außerhalb der Seite, Kundentrennung, manuell zugeordneter Host), und die lokale Browsersuite mit dem angepassten Zuordnungstest bei 390 px Breite. Desktop- und Mobildarstellung wurden mit Beispieldaten im Browser angesehen. Eine Sichtprüfung mit persönlicher Sitzung auf dem Entwicklungsserver steht aus. [Gruppierung](../web/src/device-groups.ts) · [Geräteliste](../web/src/devices.tsx) |
|
||||
| Von der Auswahl zur Ausgabe | Die WebUI bindet die ausgewählte Skriptversion, zeigt den Inhalt vor Genehmigung und verlinkt das Ergebnis je Gerät. Ein abgelehnter Antrag erzeugte null Jobs. [Auftragsablauf](evidence/webui-auftragsablauf-20261117.json) · [Ergebnislinks und Entscheidungen](evidence/webui-order-history-20261118.json) Auf OTRS ARM64 wurde der Root-Skript-Helper nachträglich mit dem HTTPS-Installer aktiviert. Die zentrale Geräteregel bindet das berechtigte WebUI-Konto an diese Installation und den signierten Helper. Die öffentliche WebUI-Vorschau akzeptierte Root für OTRS. Die Probe blieb bei einer Vorschau und erzeugte null Anträge, Jobs, Outbox-Einträge und Startgrants. [OTRS-Nachweis](evidence/linux-arm64-otrs-root-helper-20261118.json) |
|
||||
| Frische Installation und periodisches Agentupdate | Beide VMs wurden über HTTPS aufgenommen und übernahmen anschließend ein signiertes Folgepaket mit derselben Geräteidentität. Auf Windows ist der öffentliche GNU-Kanal einschließlich Prüfung des offiziellen Schlüssels belegt. [Linux](evidence/linux-public-installer-update-20261117.json) · [Windows GNU](evidence/windows-gnu-official-vm-20261118.json). ARM64 erweitert denselben HTTPS-Installer mit automatischer Architekturerkennung. Release `0.1.0-arm64.1` ist veröffentlicht und als Starter verfügbar. Auf Ubuntu 22.04.5 ARM64 wurden die öffentlichen Downloads, die Signaturprüfung, die Ablehnung einer veränderten Agentdatei und der native Start aller drei Dateien im Prüfmodus beobachtet. OTRS ist mit Gerätezertifikat aufgenommen und meldet authentisierte Heartbeats. Die erste Kontaktprüfung wartet seit der Korrektur auf das Zertifikat. Der öffentliche Installer lief auf OTRS erneut ohne Traceback und ohne neuen Einmalcode. Der ARM64-Katalogabruf ist bestätigt. Ein späterer Versionswechsel auf ARM64 steht aus. [ARM64-Release](evidence/linux-arm64-installer-20261118.json) · [Geräteaufnahme und Nachtest](evidence/linux-arm64-enrollment-heartbeat-20261118.json) |
|
||||
| Erste Windows-Meldung ohne `DisplayVersion` | Bei einem betroffenen Gerät nahm das Gateway das Enrollment und die authentisierten Verbindungsaufbauten an, erhielt aber weder Inventar noch Heartbeat. Windows GNU `0.1.26` aus `037b5e3` nutzt bei fehlendem `DisplayVersion` den Registrywert `ReleaseId` oder meldet Produkt und Build ohne Versionsbezeichnung. Drei Regressionen und die Inventarprobe liefen nativ auf der Windows-Test-VM. Das offiziell signierte Paket (Sequenz 27) ist im Katalog des betroffenen Kunden und als Starter für neue Windows-Kataloge verfügbar. Die Test-VM übernahm das reguläre Update, meldete einen neuen Heartbeat mit derselben Identität und startete beide signierten Binärdateien mit den erwarteten Hashes. Die erneute Meldung des betroffenen Geräts mit derselben Identität steht aus. Bei durch den Erstkontakt blockiertem Installer den vorhandenen `RmmDiscoveryReleasePull` lokal starten; nach erfolgreichem Update den Installer mit derselben Identität abschließen. [Nachweis](evidence/windows-missing-display-version-20261119.json) |
|
||||
|
||||
@@ -441,9 +441,10 @@ test('shows real VM hosts and the Hetzner placeholder without adding a device',
|
||||
});
|
||||
|
||||
await page.goto(origin + '/#geraete');
|
||||
const vmRow = page.getByRole('row').filter({ has: page.getByRole('button', { name: vm.hostname }) });
|
||||
await expect(vmRow).toContainText('Hetzner Cloud');
|
||||
await expect(vmRow).toContainText('Platzhalter');
|
||||
const block = (name: string) => page.getByRole('group', { name });
|
||||
await expect(block('Hetzner Cloud')).toContainText('Platzhalter');
|
||||
await expect(block('Hetzner Cloud').getByRole('button', { name: vm.hostname })).toBeVisible();
|
||||
await expect(block('Hypervisor pve-01')).toContainText('Keine zugeordneten virtuellen Maschinen');
|
||||
await expect(page.getByRole('button', { name: 'Hetzner Cloud' })).toHaveCount(0);
|
||||
await expect(page.locator('.fleet-table tbody tr')).toHaveCount(2);
|
||||
await page.getByRole('button', { name: vm.hostname }).click();
|
||||
@@ -455,10 +456,14 @@ test('shows real VM hosts and the Hetzner placeholder without adding a device',
|
||||
await expect(page.getByText('Hypervisor zugeordnet.', { exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Zur Geräteliste' }).click();
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
const hostLink = vmRow.getByRole('link', { name: pve.hostname });
|
||||
await expect(hostLink).toBeVisible();
|
||||
await expect(vmRow).not.toContainText('Hetzner Cloud');
|
||||
await hostLink.click();
|
||||
const hostBlock = block('Hypervisor pve-01');
|
||||
await expect(hostBlock.locator('tbody tr')).toHaveCount(2);
|
||||
await expect(hostBlock.locator('tbody tr').first()).toContainText(pve.hostname);
|
||||
await expect(hostBlock.locator('tr.guest')).toContainText(vm.hostname);
|
||||
await expect(hostBlock.locator('tr.guest')).toContainText('manuell zugeordnet');
|
||||
await expect(hostBlock).toContainText('1 virtuelle Maschine');
|
||||
await expect(block('Hetzner Cloud')).toHaveCount(0);
|
||||
await hostBlock.getByRole('link', { name: pve.hostname }).click();
|
||||
await expect(page.getByRole('heading', { name: pve.hostname })).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Virtuelle Maschinen und Container' })).toBeVisible();
|
||||
await expect(page.getByRole('row').filter({ hasText: 'alpine-ct' })).toContainText('Container');
|
||||
@@ -473,5 +478,5 @@ test('shows real VM hosts and the Hetzner placeholder without adding a device',
|
||||
await page.getByRole('button', { name: 'Zuordnung speichern' }).click();
|
||||
await expect(page.getByText('Hostzuordnung entfernt.', { exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Zur Geräteliste' }).click();
|
||||
await expect(vmRow).toContainText('Hetzner Cloud');
|
||||
await expect(block('Hetzner Cloud').getByRole('button', { name: vm.hostname })).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import type { RecordValue } from './api';
|
||||
import { groupDevices } from './device-groups';
|
||||
|
||||
const tenant = '11111111-1111-4111-8111-111111111111';
|
||||
const device = (hostname: string, device_type: string | null, extra: RecordValue = {}): RecordValue => ({
|
||||
tenant_id: tenant, customer_name: 'Testkunde', asset_id: hostname + '-asset', agent_id: hostname + '-agent',
|
||||
hostname, device_type, ...extra });
|
||||
const on = (host: string, tenantHost = host) => ({ hypervisor: {
|
||||
kind: 'device', asset_id: tenantHost + '-asset', agent_id: tenantHost + '-agent', hostname: host } });
|
||||
const hetzner = { hypervisor: { kind: 'placeholder', provider: 'hetzner', hostname: 'Hetzner Cloud' } };
|
||||
const shape = (items: RecordValue[]) => groupDevices(items).map(g =>
|
||||
[g.kind, g.title, g.rows.map(r => r.role + ':' + String(r.device.hostname)).join(',')]);
|
||||
|
||||
it('lists each hypervisor with its virtual machines, then Hetzner, physical and unassigned devices', () => {
|
||||
expect(shape([
|
||||
device('vm-b', 'virtual', on('pve-01')),
|
||||
device('laptop', 'physical'),
|
||||
device('cloud', 'virtual', hetzner),
|
||||
device('pve-01', 'hypervisor'),
|
||||
device('stray', 'virtual'),
|
||||
device('vm-a', 'virtual', on('pve-01')),
|
||||
device('pve-02', 'hypervisor'),
|
||||
device('untyped', null),
|
||||
])).toEqual([
|
||||
['hypervisor', 'pve-01', 'host:pve-01,guest:vm-b,guest:vm-a'],
|
||||
['hypervisor', 'pve-02', 'host:pve-02'],
|
||||
['hetzner', '', 'guest:cloud'],
|
||||
['physical', '', 'plain:laptop'],
|
||||
['unassigned', '', 'plain:stray,plain:untyped'],
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps the block and the link of a hypervisor that is not on this page', () => {
|
||||
const [group] = groupDevices([device('vm-a', 'virtual', on('pve-01'))]);
|
||||
expect(group).toMatchObject({ kind: 'hypervisor', title: 'pve-01', hostListed: false,
|
||||
hostPath: 'geraete/' + tenant + '/pve-01-asset/pve-01-agent' });
|
||||
expect(group?.rows.map(r => r.role)).toEqual(['guest']);
|
||||
});
|
||||
|
||||
it('never merges hosts of two customers that share an asset id', () => {
|
||||
const other = { tenant_id: '22222222-2222-4222-8222-222222222222', customer_name: 'Anderer Kunde' };
|
||||
const groups = groupDevices([
|
||||
device('pve-01', 'hypervisor'),
|
||||
device('vm-a', 'virtual', { ...on('pve-01'), ...other }),
|
||||
]);
|
||||
expect(groups.map(g => [g.customer, g.hostListed, g.rows.length])).toEqual([
|
||||
['Testkunde', true, 1], ['Anderer Kunde', false, 1]]);
|
||||
});
|
||||
|
||||
it('uses a manually assigned host as the head of its block whatever type it reports', () => {
|
||||
expect(shape([device('vm-a', 'virtual', on('esx')), device('esx', 'physical')])).toEqual([
|
||||
['hypervisor', 'esx', 'host:esx,guest:vm-a']]);
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
import { record, type RecordValue } from './api';
|
||||
|
||||
export type GroupKind = 'hypervisor' | 'hetzner' | 'physical' | 'unassigned';
|
||||
export type RowRole = 'host' | 'guest' | 'plain';
|
||||
export type FleetGroup = {
|
||||
key: string;
|
||||
kind: GroupKind;
|
||||
/** Hostname of the hypervisor; empty for the fixed blocks. */
|
||||
title: string;
|
||||
customer: string;
|
||||
/** Detail route of the hypervisor, also when its row is not part of this page. */
|
||||
hostPath: string | null;
|
||||
hostListed: boolean;
|
||||
rows: { device: RecordValue; role: RowRole }[];
|
||||
};
|
||||
|
||||
const text = (value: unknown) => (typeof value === 'string' ? value : '');
|
||||
const route = (tenant: string, asset: string, agent: string) =>
|
||||
tenant && asset && agent ? ['geraete', tenant, asset, agent].map(encodeURIComponent).join('/') : null;
|
||||
|
||||
/** The registered hypervisor a virtual device is assigned to, if any. */
|
||||
function assignedHost(device: RecordValue) {
|
||||
if (device.device_type !== 'virtual' || !device.hypervisor || typeof device.hypervisor !== 'object') return null;
|
||||
const info = record(device.hypervisor);
|
||||
const asset = text(info.asset_id);
|
||||
return info.kind === 'device' && asset ? { asset, agent: text(info.agent_id), hostname: text(info.hostname) } : null;
|
||||
}
|
||||
|
||||
function isHetzner(device: RecordValue) {
|
||||
if (device.device_type !== 'virtual' || !device.hypervisor || typeof device.hypervisor !== 'object') return false;
|
||||
const info = record(device.hypervisor);
|
||||
return info.kind === 'placeholder' && info.provider === 'hetzner';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts one page of the device list into blocks: one per hypervisor with its virtual
|
||||
* machines, then Hetzner guests, physical devices and everything without a known place.
|
||||
* A hypervisor is a block of its own within its customer; guests whose host is not on
|
||||
* this page still get that host's block, without the host row.
|
||||
*/
|
||||
export function groupDevices(items: RecordValue[]): FleetGroup[] {
|
||||
const hosts = new Map<string, FleetGroup>();
|
||||
const fixed = new Map<GroupKind, FleetGroup>();
|
||||
const hostGroup = (tenant: string, asset: string) => {
|
||||
const key = tenant + '/' + asset;
|
||||
let group = hosts.get(key);
|
||||
if (!group) {
|
||||
group = { key, kind: 'hypervisor', title: '', customer: '', hostPath: null, hostListed: false, rows: [] };
|
||||
hosts.set(key, group);
|
||||
}
|
||||
return group;
|
||||
};
|
||||
const fixedGroup = (kind: GroupKind) => {
|
||||
let group = fixed.get(kind);
|
||||
if (!group) {
|
||||
group = { key: kind, kind, title: '', customer: '', hostPath: null, hostListed: false, rows: [] };
|
||||
fixed.set(kind, group);
|
||||
}
|
||||
return group;
|
||||
};
|
||||
const referenced = new Set<string>();
|
||||
for (const device of items) {
|
||||
const host = assignedHost(device);
|
||||
if (host) referenced.add(text(device.tenant_id) + '/' + host.asset);
|
||||
}
|
||||
for (const device of items) {
|
||||
const tenant = text(device.tenant_id), asset = text(device.asset_id);
|
||||
const host = assignedHost(device);
|
||||
if (device.device_type === 'hypervisor' || (!host && referenced.has(tenant + '/' + asset))) {
|
||||
const group = hostGroup(tenant, asset);
|
||||
group.title = text(device.hostname);
|
||||
group.customer = text(device.customer_name);
|
||||
group.hostPath = route(tenant, asset, text(device.agent_id));
|
||||
group.hostListed = true;
|
||||
group.rows.unshift({ device, role: 'host' });
|
||||
} else if (host) {
|
||||
const group = hostGroup(tenant, host.asset);
|
||||
if (!group.hostListed) {
|
||||
group.title = host.hostname;
|
||||
group.customer = text(device.customer_name);
|
||||
group.hostPath = route(tenant, host.asset, host.agent);
|
||||
}
|
||||
group.rows.push({ device, role: 'guest' });
|
||||
} else {
|
||||
const kind = isHetzner(device) ? 'hetzner' : device.device_type === 'physical' ? 'physical' : 'unassigned';
|
||||
fixedGroup(kind).rows.push({ device, role: kind === 'hetzner' ? 'guest' : 'plain' });
|
||||
}
|
||||
}
|
||||
return [...hosts.values(),
|
||||
...(['hetzner', 'physical', 'unassigned'] as const).flatMap(kind => fixed.get(kind) ?? [])];
|
||||
}
|
||||
+156
-91
@@ -21,6 +21,7 @@ import { OPNsenseDetails } from './opnsense';
|
||||
import { ProxmoxDetails } from './proxmox';
|
||||
import { DeviceCustomerTransfer } from './device-customer-transfer';
|
||||
import { HypervisorAssignment, HypervisorLabel } from './device-hypervisor';
|
||||
import { groupDevices, type FleetGroup, type RowRole } from './device-groups';
|
||||
import { ErrorBox, errorText, useResource } from './resource';
|
||||
import { NavIcon, orderDetailRoute } from './navigation';
|
||||
import { orderTitle, Status } from './order-presentation';
|
||||
@@ -32,6 +33,49 @@ import { SystemNonstartReview } from './system-nonstart-review';
|
||||
|
||||
const unknown = 'Nicht gemeldet';
|
||||
const noPurpose = 'Nicht hinterlegt';
|
||||
const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;
|
||||
|
||||
function groupName(group: FleetGroup) {
|
||||
return group.kind === 'hypervisor' ? 'Hypervisor ' + (group.title || 'unbekannt')
|
||||
: group.kind === 'hetzner' ? 'Hetzner Cloud'
|
||||
: group.kind === 'physical' ? 'Physische Geräte' : 'Nicht zugeordnet';
|
||||
}
|
||||
|
||||
/** How a listed virtual machine got its place under a registered hypervisor. */
|
||||
function linkSource(d: RecordValue) {
|
||||
if (!d.hypervisor || typeof d.hypervisor !== 'object') return '';
|
||||
const info = record(d.hypervisor);
|
||||
return info.kind !== 'device' ? '' : info.source === 'proxmox' ? 'automatisch erkannt' : 'manuell zugeordnet';
|
||||
}
|
||||
|
||||
function GroupHeader({ group, showCustomer }: { group: FleetGroup; showCustomer: boolean }) {
|
||||
const guests = group.rows.filter((r) => r.role !== 'host').length;
|
||||
const machines = plural(guests, 'virtuelle Maschine', 'virtuelle Maschinen');
|
||||
const [icon, eyebrow, title, facts] =
|
||||
group.kind === 'hypervisor'
|
||||
? (['server', 'Hypervisor',
|
||||
group.hostPath ? <a href={'#' + group.hostPath}>{group.title || 'Unbekannter Host'}</a> : group.title || 'Unbekannter Host',
|
||||
[guests ? machines : 'Keine zugeordneten virtuellen Maschinen',
|
||||
!group.hostListed && 'Host in dieser Ansicht nicht enthalten',
|
||||
showCustomer && group.customer]] as const)
|
||||
: group.kind === 'hetzner'
|
||||
? (['cloud', 'Externer Anbieter', 'Hetzner Cloud', [machines, 'Platzhalter, kein Gerät im Bestand']] as const)
|
||||
: group.kind === 'physical'
|
||||
? (['geraete', 'Eigene Hardware', 'Physische Geräte', [plural(guests, 'Gerät', 'Geräte')]] as const)
|
||||
: (['offen', 'Ohne Zuordnung', 'Nicht zugeordnet',
|
||||
[plural(guests, 'Gerät', 'Geräte'), 'kein Hypervisor oder Gerätetyp erkannt']] as const);
|
||||
return (
|
||||
<div className="fleet-group-head">
|
||||
<span className="group-icon"><NavIcon name={icon} /></span>
|
||||
<div>
|
||||
<span className="group-eyebrow">{eyebrow}</span>
|
||||
<strong>{title}</strong>
|
||||
</div>
|
||||
<p>{facts.filter(Boolean).map((fact, i) => <span key={i}>{fact}</span>)}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const number = new Intl.NumberFormat('de-DE', { maximumFractionDigits: 1 });
|
||||
const date = new Intl.DateTimeFormat('de-DE', { dateStyle: 'medium', timeStyle: 'short' });
|
||||
function label(value: unknown) {
|
||||
@@ -580,6 +624,105 @@ export function Devices({
|
||||
}}
|
||||
/>
|
||||
);
|
||||
const columns = ['Hostname', 'Type', 'Zweck', 'OS', 'Status', 'Speicher belegt / gesamt', 'RAM belegt / gesamt', 'CPU', 'Kunde'];
|
||||
const row = (d: RecordValue, role: RowRole | 'flat') => {
|
||||
const asset = objectId(d, 'asset'),
|
||||
agent = objectId(d, 'agent'),
|
||||
customer = objectId(d, 'tenant'),
|
||||
model = cpu(d),
|
||||
purpose = typeof d.purpose === 'string' ? d.purpose : '';
|
||||
const show = () => {
|
||||
setDeletionNotice('');
|
||||
window.location.hash = ['geraete', customer, asset, agent]
|
||||
.map(encodeURIComponent)
|
||||
.join('/');
|
||||
};
|
||||
const another = selection.ids.length > 0 && selection.customer !== customer;
|
||||
return (
|
||||
<tr key={agent} onClick={show} className={role === 'flat' ? undefined : role}>
|
||||
{!history && (
|
||||
<td className="target-col" onClick={(e) => e.stopPropagation()}>
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={'Ziel ' + asset}
|
||||
title={
|
||||
another ? 'Aufträge werden je Kunde geplant' : 'Für Auftrag auswählen'
|
||||
}
|
||||
disabled={another}
|
||||
checked={selection.customer === customer && selection.ids.includes(asset)}
|
||||
onChange={(e) => select(d, e.target.checked)}
|
||||
/>
|
||||
</td>
|
||||
)}
|
||||
<td className="hostname">
|
||||
<button
|
||||
className="host-link"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
show();
|
||||
}}
|
||||
>
|
||||
{label(d.hostname)}
|
||||
</button>
|
||||
{role === 'flat' && <HypervisorLabel device={d} />}
|
||||
{role === 'guest' && linkSource(d) && <small className="link-source">{linkSource(d)}</small>}
|
||||
</td>
|
||||
<td data-label="Type">{label(d.device_type)}</td>
|
||||
<td data-label="Zweck" className="purpose-col">
|
||||
<span className={'purpose-text' + (purpose ? '' : ' muted')} title={purpose || undefined}>
|
||||
{purpose || noPurpose}
|
||||
</span>
|
||||
</td>
|
||||
<td data-label="OS">{label(d.os)}</td>
|
||||
<td data-label="Status" className="device-presence">
|
||||
<Presence d={d} />
|
||||
{d.status === 'offline' && d.lifecycle === 'current' && (
|
||||
<small>Zuletzt {time(d.last_contact_at)}</small>
|
||||
)}
|
||||
</td>
|
||||
<td data-label="Speicher belegt / gesamt" className="capacity-cell">
|
||||
<DiskCapacity device={d} />
|
||||
</td>
|
||||
<td data-label="RAM belegt / gesamt" className="capacity-cell" title={measuredAt(d.ram_observed_at)}>
|
||||
<Capacity free={d.ram_available_bytes} total={d.ram_total_bytes} />
|
||||
</td>
|
||||
<td data-label="CPU">
|
||||
{model.primary}
|
||||
{model.secondary && <small>{model.secondary}</small>}
|
||||
<small title={measuredAt(d.cpu_usage_observed_at)}>
|
||||
Auslastung {cpuUsage(d.cpu_usage_percent)}
|
||||
</small>
|
||||
</td>
|
||||
<td data-label="Kunde">{label(d.customer_name)}</td>
|
||||
</tr>
|
||||
);
|
||||
};
|
||||
/** Every block shares these column widths, so the blocks line up under one heading. */
|
||||
const table = (rows: { device: RecordValue; role: RowRole | 'flat' }[], heading: 'visible' | 'hidden' | 'only') => (
|
||||
<div className={'table fleet-table' + (heading === 'only' ? ' fleet-head' : '')} aria-hidden={heading === 'only' || undefined}>
|
||||
<table>
|
||||
<colgroup>
|
||||
{!history && <col className="target-col" />}
|
||||
{columns.map((h) => <col key={h} className={h === 'Zweck' ? 'purpose-col' : h === 'Hostname' ? 'host-col' : undefined} />)}
|
||||
</colgroup>
|
||||
<thead className={heading === 'hidden' ? 'sr-only' : undefined}>
|
||||
<tr>
|
||||
{!history && (
|
||||
<th className="target-col">
|
||||
<span className="sr-only">Ziel auswählen</span>
|
||||
</th>
|
||||
)}
|
||||
{columns.map((h) => (
|
||||
<th scope="col" key={h} className={h === 'Zweck' ? 'purpose-col' : undefined}>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
{heading !== 'only' && <tbody>{rows.map((r) => row(r.device, r.role))}</tbody>}
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<div className="page-title">
|
||||
@@ -669,99 +812,21 @@ export function Devices({
|
||||
{!list.data && !list.error && <p className="list-message">Geräte werden geladen …</p>}
|
||||
{list.data && (
|
||||
<>
|
||||
<div className="table fleet-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{!history && (
|
||||
<th className="target-col">
|
||||
<span className="sr-only">Ziel auswählen</span>
|
||||
</th>
|
||||
)}
|
||||
{['Hostname', 'Type', 'Zweck', 'OS', 'Status', 'Speicher belegt / gesamt', 'RAM belegt / gesamt', 'CPU', 'Kunde'].map(
|
||||
(h) => (
|
||||
<th scope="col" key={h} className={h === 'Zweck' ? 'purpose-col' : undefined}>
|
||||
{h}
|
||||
</th>
|
||||
{history ? (
|
||||
table(list.data.items.map((device) => ({ device, role: 'flat' as const })), 'visible')
|
||||
) : (
|
||||
!!list.data.items.length && (
|
||||
<div className="fleet-groups">
|
||||
{table([], 'only')}
|
||||
{groupDevices(list.data.items).map((group) => (
|
||||
<div className={'fleet-group ' + group.kind} role="group" aria-label={groupName(group)} key={group.key}>
|
||||
<GroupHeader group={group} showCustomer={!filter} />
|
||||
{table(group.rows, 'hidden')}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{list.data.items.map((d) => {
|
||||
const asset = objectId(d, 'asset'),
|
||||
agent = objectId(d, 'agent'),
|
||||
customer = objectId(d, 'tenant'),
|
||||
model = cpu(d),
|
||||
purpose = typeof d.purpose === 'string' ? d.purpose : '';
|
||||
const show = () => {
|
||||
setDeletionNotice('');
|
||||
window.location.hash = ['geraete', customer, asset, agent]
|
||||
.map(encodeURIComponent)
|
||||
.join('/');
|
||||
};
|
||||
const another = selection.ids.length > 0 && selection.customer !== customer;
|
||||
return (
|
||||
<tr key={agent} onClick={show}>
|
||||
{!history && (
|
||||
<td className="target-col" onClick={(e) => e.stopPropagation()}>
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={'Ziel ' + asset}
|
||||
title={
|
||||
another ? 'Aufträge werden je Kunde geplant' : 'Für Auftrag auswählen'
|
||||
}
|
||||
disabled={another}
|
||||
checked={selection.customer === customer && selection.ids.includes(asset)}
|
||||
onChange={(e) => select(d, e.target.checked)}
|
||||
/>
|
||||
</td>
|
||||
)}
|
||||
<td className="hostname">
|
||||
<button
|
||||
className="host-link"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
show();
|
||||
}}
|
||||
>
|
||||
{label(d.hostname)}
|
||||
</button>
|
||||
<HypervisorLabel device={d} />
|
||||
</td>
|
||||
<td data-label="Type">{label(d.device_type)}</td>
|
||||
<td data-label="Zweck" className="purpose-col">
|
||||
<span className={'purpose-text' + (purpose ? '' : ' muted')} title={purpose || undefined}>
|
||||
{purpose || noPurpose}
|
||||
</span>
|
||||
</td>
|
||||
<td data-label="OS">{label(d.os)}</td>
|
||||
<td data-label="Status" className="device-presence">
|
||||
<Presence d={d} />
|
||||
{d.status === 'offline' && d.lifecycle === 'current' && (
|
||||
<small>Zuletzt {time(d.last_contact_at)}</small>
|
||||
)}
|
||||
</td>
|
||||
<td data-label="Speicher belegt / gesamt" className="capacity-cell">
|
||||
<DiskCapacity device={d} />
|
||||
</td>
|
||||
<td data-label="RAM belegt / gesamt" className="capacity-cell" title={measuredAt(d.ram_observed_at)}>
|
||||
<Capacity free={d.ram_available_bytes} total={d.ram_total_bytes} />
|
||||
</td>
|
||||
<td data-label="CPU">
|
||||
{model.primary}
|
||||
{model.secondary && <small>{model.secondary}</small>}
|
||||
<small title={measuredAt(d.cpu_usage_observed_at)}>
|
||||
Auslastung {cpuUsage(d.cpu_usage_percent)}
|
||||
</small>
|
||||
</td>
|
||||
<td data-label="Kunde">{label(d.customer_name)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!list.data.items.length && (
|
||||
<div className="empty-list">
|
||||
<NavIcon name="geraete" />
|
||||
|
||||
@@ -12,7 +12,10 @@ const glyphs = {
|
||||
suchen: 'M16 16l5 5 M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0',
|
||||
plus: 'M12 5v14 M5 12h14',
|
||||
abmelden: 'M10 4H4v16h6 M8 12h13 M16 7l5 5-5 5',
|
||||
zurueck: 'M20 12H4 M10 6l-6 6 6 6'
|
||||
zurueck: 'M20 12H4 M10 6l-6 6 6 6',
|
||||
server: 'M3 4h18v7H3z M3 13h18v7H3z M7 7.5h.01 M7 16.5h.01 M11 7.5h6 M11 16.5h6',
|
||||
cloud: 'M7 19a4.5 4.5 0 0 1-.6-9A6 6 0 0 1 18 11.2a3.9 3.9 0 0 1 0 7.8z',
|
||||
offen: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z M9.6 9.4a2.5 2.5 0 1 1 3.6 2.3c-.8.5-1.2 1-1.2 1.9 M12 17h.01'
|
||||
};
|
||||
export function NavIcon({ name }: { name: keyof typeof glyphs }) {
|
||||
return (
|
||||
|
||||
+30
-1
@@ -97,7 +97,32 @@ section.fleet { padding:0; overflow:hidden; }
|
||||
.vm-hypervisor { display:flex; align-items:baseline; gap:6px; margin-top:5px; color:var(--subtle); font-size:.78rem; overflow-wrap:anywhere; }
|
||||
.vm-hypervisor .nav-icon { width:13px; height:13px; flex:none; align-self:flex-start; margin-top:2px; }
|
||||
.fleet-table .target-col { width:35px; }
|
||||
.fleet-table th.purpose-col { width:17%; }
|
||||
.fleet-table th.purpose-col,.fleet-table col.purpose-col { width:17%; }
|
||||
.fleet-groups { --group:var(--accent); --group-soft:#eaf3ef; padding:0 14px 16px; background:#f7f9f8; border-top:1px solid var(--line); }
|
||||
.fleet-head thead th { background:none; border-bottom:0; padding-block:11px 9px; }
|
||||
.fleet-group { background:var(--surface); border:1px solid var(--line); border-left:4px solid var(--group); border-radius:10px; overflow:hidden; box-shadow:0 1px 2px rgba(21,45,42,.05); }
|
||||
.fleet-group + .fleet-group { margin-top:14px; }
|
||||
.fleet-group.hetzner { --group:#b4432f; --group-soft:#fbeeea; }
|
||||
.fleet-group.physical { --group:var(--blue); --group-soft:#e8f1f4; }
|
||||
.fleet-group.unassigned { --group:#a8791f; --group-soft:#faf1df; border-style:dashed; border-left-style:solid; }
|
||||
.fleet-group-head { display:flex; align-items:center; gap:12px; padding:11px 16px 11px 14px; background:linear-gradient(90deg,var(--group-soft),transparent 75%); border-bottom:1px solid var(--line); }
|
||||
.group-icon { display:grid; place-items:center; flex:none; width:34px; height:34px; border-radius:9px; background:var(--group); color:#fff; }
|
||||
.group-icon .nav-icon { width:18px; height:18px; }
|
||||
.fleet-group-head > div { display:flex; flex-direction:column; min-width:0; }
|
||||
.group-eyebrow { color:var(--group); font-size:.68rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase; }
|
||||
.fleet-group-head strong { font-size:1.04rem; letter-spacing:-.015em; overflow-wrap:anywhere; }
|
||||
.fleet-group-head strong a { color:inherit; text-decoration:none; } .fleet-group-head strong a:hover { text-decoration:underline; }
|
||||
.fleet-group-head p { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:6px; margin:0 0 0 auto; }
|
||||
.fleet-group-head p span { border-radius:20px; padding:2px 10px; background:var(--surface); border:1px solid var(--line); color:var(--subtle); font-size:.78rem; white-space:nowrap; }
|
||||
.fleet-group-head p span:first-child { border-color:transparent; background:var(--group-soft); color:var(--group); font-weight:650; }
|
||||
.fleet-group .fleet-table tbody tr:last-child td { border-bottom:0; }
|
||||
.fleet-group tr.host { background:#fbfdfc; } .fleet-group tr.host .host-link { color:var(--ink); }
|
||||
.link-source { display:block; color:var(--subtle); overflow-wrap:normal; }
|
||||
.fleet-table col.host-col { width:15%; }
|
||||
/* Guests hang on a branch below their host. */
|
||||
.fleet-group tr.guest td.hostname { position:relative; padding-left:38px; }
|
||||
.fleet-group tr.guest td.hostname::before { content:''; position:absolute; left:12px; top:0; bottom:50%; width:16px; border-left:2px solid var(--group); border-bottom:2px solid var(--group); border-bottom-left-radius:8px; opacity:.45; }
|
||||
.fleet-group tr.guest:not(:last-child) td.hostname::after { content:''; position:absolute; left:12px; top:50%; bottom:0; border-left:2px solid var(--group); opacity:.45; }
|
||||
.purpose-text { white-space:pre-wrap; overflow-wrap:anywhere; }
|
||||
.fleet-table .purpose-text { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow:hidden; }
|
||||
.device-purpose textarea { font-family:inherit; }
|
||||
@@ -167,6 +192,10 @@ ul.compact { margin:4px 0 0; padding-left:18px; font-size:.85rem; }
|
||||
.fleet-table td,.fleet-table td:first-child,.fleet-table td:last-child {display:block;padding:0;border:0;font-size:.9rem;}
|
||||
.fleet-table td[data-label]::before {content:attr(data-label);display:block;color:var(--subtle);font-size:.73rem;}
|
||||
.fleet-table .hostname {grid-column:1/-1;padding-right:28px;} .host-link {font-size:1rem;}
|
||||
.fleet-head {display:none;} .fleet-groups {padding:12px 10px;border-top:0;} .fleet-group .fleet-table tr:first-child {border-top:0;}
|
||||
.fleet-group-head {flex-wrap:wrap;} .fleet-group-head p span {white-space:normal;} .fleet-group-head p {margin-left:46px;justify-content:flex-start;flex-basis:100%;}
|
||||
.fleet-group tr.guest {margin-left:16px;border-left:2px solid color-mix(in srgb,var(--group) 45%,transparent);}
|
||||
.fleet-group tr.guest td.hostname {padding-left:0;} .fleet-group tr.guest td.hostname::before,.fleet-group tr.guest td.hostname::after {display:none;}
|
||||
.fleet-table .purpose-col {grid-column:1/-1;}
|
||||
.fleet-table .target-col {position:absolute;right:14px;top:14px;width:auto;} .capacity-track {width:min(76px,100%);}
|
||||
.list-footer {border-top:1px solid var(--line);flex-wrap:wrap;} .facts {grid-template-columns:1fr 1fr;gap:12px;}
|
||||
|
||||
Reference in New Issue
Block a user