import Refresh from '@mui/icons-material/Refresh' import { Alert, Box, Button, Typography } from '@mui/material' import { Board, BoardButtons, type BoardPanel } from './PanelBoard.tsx' import { useBoard } from './useBoard.ts' import { Pairs } from './ServerPanel.tsx' import { text } from './format.ts' import Toolbar from './Toolbar.tsx' import { DETAILS_SHAPE, STATUS_SHAPE, request, type RouterDetails, type RouterStatus } from './api.ts' import { useRead } from './useRead.ts' /** The localStorage key of the tab's layout. */ const LAYOUT_KEY = 'linux-manager-ui.docker-layout' /** Reads the server's /status/full and /config. */ const readDocker = async () => { const [status, details] = await Promise.all([ request('GET', '/status/full', STATUS_SHAPE), request('GET', '/config', DETAILS_SHAPE), ]) return { status, details } } /** * The state of Docker on the server: whether it is installed, the state of docker.service and of the server's Docker * rules, from /status/full, and the ports exposed on the external interface and the rules of the LINUX-MANAGER-DOCKER * chain, from /config. The panels are on a PanelBoard whose layout is kept in the browser. */ export default function DockerPanel() { const { data, error, busy, refresh } = useRead(readDocker) const status = data?.status const details = data?.details const docker = status?.docker const board = useBoard(LAYOUT_KEY) const panels: BoardPanel[] = status && details ? [ { id: 'status', title: 'Status', fixed: true, content: ( ), }, { id: 'rules', title: 'Rules of LINUX-MANAGER-DOCKER', content: details.docker.rules === null ? Not available. : ( {details.docker.rules.length === 0 ? '(none)' : details.docker.rules.join('\n')} ), }, ] : [] return ( {error && {error}} ) }