fix: connectivity panel rearrangement. LXD VM for repeatable tests.

This commit is contained in:
slawek committed 2026-11-22 15:59:40 +01:00
1 parent 85a1ffa21f
commit da889b4865
15 files changed
+363 -47

No files matched your search

+26 -7
View File
@@ -13,29 +13,48 @@ const LAYOUT_KEY = 'linux-manager-ui.network-layout'
const readDetails = () => request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
/**
* The server's network, from its /config: the external and the internal interface with their addresses, the internal
* gateway and the local CIDRs, and the IPv4 routes. The panels are on a board whose layout is kept in the browser.
* The server's network, from its /config: the interfaces but loopback, external when they hold an IPv4 default route
* and internal otherwise; the internal gateway and the local CIDRs while the router is on; and the IPv4 routes. The
* panels are on a board whose layout is kept in the browser.
*/
export default function NetworkPanel() {
const { data: details, error, busy, refresh } = useRead(readDetails)
const board = useBoard(LAYOUT_KEY)
const network = details?.network
const router = details?.configuration.router?.enabled === true
// An interface holding an IPv4 default route is external, every other one internal.
const external = new Set(network?.routes?.filter((route) => route.dst === 'default').map((route) => route.dev))
const panels: BoardPanel[] = network ? [
{
id: 'network',
title: 'Network',
id: 'interfaces',
title: 'Interfaces',
content: (
<Grid
head={['Name', 'Type', 'State', 'IPv4 addresses', 'IPv6 addresses', 'MAC address']}
rows={network.interfaces?.map((link) => [
link.name,
external.has(link.name) ? 'external' : 'internal',
text(link.state),
text(link.ipv4),
text(link.ipv6),
text(link.mac),
])}
/>
),
},
...(router ? [{
id: 'router',
title: 'Router',
content: (
<Pairs
rows={[
['External interface', `${network.external_interface ?? '-'}: ${text(network.external_addresses)}`],
['Internal interface', `${network.internal_interface ?? '-'}: ${text(network.internal_address)}`],
['Internal gateway', text(network.internal_gateway)],
['Local CIDRs', text(network.local_cidrs)],
]}
/>
),
},
}] : []),
{
id: 'routes',
title: 'Routes',