feature: the package installs the Router Manager, which is no longer a package of its own.
Release / release (push) Failing after 4s
Release / release (push) Failing after 4s
This commit is contained in:
1 parent
6d90441bee
commit
8efe21bfa6
129 files changed
+17381
-104
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import Refresh from '@mui/icons-material/Refresh'
|
||||
import { Alert, Box, Button } from '@mui/material'
|
||||
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
|
||||
import { Grid, Pairs, text } from './RouterPanel.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import { DETAILS_SHAPE, request, type RouterDetails } from './api.ts'
|
||||
import { useRead } from './useRead.ts'
|
||||
|
||||
/** The localStorage key of the tab's layout. */
|
||||
const LAYOUT_KEY = 'vpn-router-manager.network-layout'
|
||||
|
||||
/** Reads the router's /config. */
|
||||
const readDetails = () => request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
|
||||
/**
|
||||
* The router'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.
|
||||
*/
|
||||
export default function NetworkPanel() {
|
||||
const { data: details, error, busy, refresh } = useRead(readDetails)
|
||||
const board = useBoard(LAYOUT_KEY)
|
||||
|
||||
const network = details?.network
|
||||
const panels: BoardPanel[] = network ? [
|
||||
{
|
||||
id: 'network',
|
||||
title: 'Network',
|
||||
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',
|
||||
content: (
|
||||
<Grid
|
||||
head={['Destination', 'Gateway', 'Device', 'Source', 'Protocol', 'Metric']}
|
||||
rows={network.routes?.map((route) => [
|
||||
route.dst,
|
||||
text(route.gateway),
|
||||
route.flags.length > 0 ? `${route.dev} (${route.flags.join(', ')})` : route.dev,
|
||||
text(route.prefsrc),
|
||||
text(route.protocol),
|
||||
text(route.metric),
|
||||
])}
|
||||
/>
|
||||
),
|
||||
},
|
||||
] : []
|
||||
|
||||
return (
|
||||
<Box component="section">
|
||||
<Toolbar description="Interfaces, addresses and routes.">
|
||||
<BoardButtons board={board} />
|
||||
<Button variant="outlined" startIcon={<Refresh />} disabled={busy} onClick={() => void refresh()}>Refresh</Button>
|
||||
</Toolbar>
|
||||
{error && <Alert severity="error" sx={{ mb: 2, whiteSpace: 'pre-line' }}>{error}</Alert>}
|
||||
<Board board={board} panels={panels} />
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user