feature: the VPN, the router, the name server and WebDAV are components switched on the System tab and installed on demand, Caddy from the Ubuntu archive is a dependency and serves every HTTP and HTTPS port, HTTPS is chosen at install, its certificate is of the Servers Issuing CA or self-signed by default, of ACME or of another CA, the issuing CAs are in one tab, a locked account is unlocked again, the name of a CA is fixed once the CA exists, and a run of setup is no longer cut short by a change.
Release / release (push) Failing after 8s

This commit is contained in:
slawek committed 2026-11-24 05:51:27 +01:00
1 parent a649331aa2
commit a7bfabcb89
97 files changed
+4498 -1834

No files matched your search

+104 -90
View File
@@ -9,7 +9,8 @@ import Settings from '@mui/icons-material/Settings'
import { Alert, Box, Button, Checkbox, Chip, FormControlLabel, IconButton, Link, Stack, Table, TableBody, TableCell, TableHead, TableRow, Tooltip } from '@mui/material'
import { useCallback, useEffect, useState, type ReactNode } from 'react'
import ConfirmDialog, { type ConfirmDialogProps } from './ConfirmDialog.tsx'
import { Copyable, Pairs, Section } from './ServerPanel.tsx'
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
import { Copyable, Pairs } from './ServerPanel.tsx'
import SearchField, { matches } from './SearchField.tsx'
import SiteDialog, { type SiteSettings } from './SiteDialog.tsx'
import SitesSettingsDialog from './SitesSettingsDialog.tsx'
@@ -19,6 +20,9 @@ import {
SITE_DNS_LABELS, SITE_SHAPE, SITE_TLS_LABELS, request, type Group, type RouterDetails, type Site, type Sites,
} from './api.ts'
/** The localStorage key of the tab's layout. */
const LAYOUT_KEY = 'linux-manager-ui.sites-layout'
/** The URLs of a site: its scheme, each host name and its port when it is not the scheme's default. */
function siteUrls(site: Site) {
const scheme = site.tls === 'none' ? 'http' : 'https'
@@ -30,7 +34,8 @@ function siteUrls(site: Site) {
* The web sites of the server's /sites, which Caddy serves from folders on the server. The Settings panel shows the
* sites section, whether they are served, the largest upload and WebDAV with its URL, edited with Settings. The list
* shows each site with its URLs, port, interfaces, TLS, editors group, DNS and state: add, edit, enable, disable,
* remove, with its folder when asked, and open its files on the Files tab with onOpenFiles.
* remove, with its folder when asked, and open its files on the Files tab with onOpenFiles. The panels are on a
* PanelBoard whose layout is kept in the browser.
*/
export default function SitesPanel(props: { onOpenFiles: (name: string) => void }) {
const [sites, setSites] = useState<Sites | null>(null)
@@ -45,6 +50,7 @@ export default function SitesPanel(props: { onOpenFiles: (name: string) => void
const [settings, setSettings] = useState(false)
const [confirm, setConfirm] = useState<ConfirmDialogProps | null>(null)
const [search, setSearch] = useState('')
const board = useBoard(LAYOUT_KEY)
const refresh = useCallback(async () => {
setBusy(true)
@@ -115,6 +121,100 @@ export default function SitesPanel(props: { onOpenFiles: (name: string) => void
const section = sites?.settings
const shown = (sites?.sites ?? []).filter((site) => matches(search, [site.name, ...site.hosts, site.editors]))
const panels: BoardPanel[] = [
...(section ? [{
id: 'settings',
title: 'Settings',
wide: true,
content: (
<Pairs
rows={[
['State', <Chip key="state" size="small" label={section.enabled ? 'served' : 'not served'} color={section.enabled ? 'success' : 'default'} />],
['Largest upload', `${section.upload_max_mb} MiB`],
['WebDAV', <Chip key="webdav" size="small" label={section.webdav ? 'enabled' : 'disabled'} color={section.webdav ? 'success' : 'default'} />],
...(section.webdav && fqdn
? [['WebDAV URL', <Copyable key="url" value={`https://${fqdn}:${section.webdav_port}/`} label="WebDAV URL" />]] as [string, ReactNode][]
: []),
]}
/>
),
}] : []),
...(sites ? [{
id: 'sites',
title: 'Sites',
wide: true,
content: (
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>URLs</TableCell>
<TableCell>Port</TableCell>
<TableCell>Listen</TableCell>
<TableCell>TLS</TableCell>
<TableCell>Editors</TableCell>
<TableCell>DNS</TableCell>
<TableCell>State</TableCell>
<TableCell align="right">Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{shown.length === 0 && (
<TableRow>
<TableCell colSpan={9} sx={{ color: 'text.secondary' }}>None.</TableCell>
</TableRow>
)}
{shown.map((site) => (
<TableRow key={site.name} hover>
<TableCell>{site.name}</TableCell>
<TableCell>
<Stack>
{siteUrls(site).map((url) => <Link key={url} href={url} target="_blank" rel="noreferrer">{url}</Link>)}
{site.hosts.length === 0 && 'any host name'}
</Stack>
</TableCell>
<TableCell>{site.port}</TableCell>
<TableCell>{site.listen}</TableCell>
<TableCell>{SITE_TLS_LABELS[site.tls]}{site.tls === 'ca' ? ` (${site.ca})` : ''}</TableCell>
<TableCell>{site.editors || '-'}</TableCell>
<TableCell>{SITE_DNS_LABELS[site.dns]}{site.dns === 'router' ? `, ${SITE_DNS_ADDRESS_LABELS[site.dns_address]}` : ''}</TableCell>
<TableCell sx={{ color: site.enabled ? 'success.main' : 'text.secondary' }}>{site.enabled ? 'enabled' : 'disabled'}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
<Tooltip title="Files">
<span>
<IconButton size="small" onClick={() => props.onOpenFiles(site.name)}><FolderOpen fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title="Edit">
<span>
<IconButton size="small" disabled={busy} onClick={() => setEditing(site)}><Edit fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title={site.enabled ? 'Disable' : 'Enable'}>
<span>
<IconButton
size="small"
disabled={busy}
onClick={() => void change(() => request('PUT', `/sites/${site.name}`, SITE_SHAPE, { enabled: !site.enabled }))}
>
{site.enabled ? <Block fontSize="small" /> : <CheckCircle fontSize="small" />}
</IconButton>
</span>
</Tooltip>
<Tooltip title="Remove">
<span>
<IconButton size="small" color="error" disabled={busy} onClick={() => remove(site)}><Delete fontSize="small" /></IconButton>
</span>
</Tooltip>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
),
}] : []),
]
return (
<Box component="section">
<Toolbar description="Static web sites Caddy serves from folders on the server.">
@@ -125,6 +225,7 @@ export default function SitesPanel(props: { onOpenFiles: (name: string) => void
<Button variant="contained" startIcon={<Add />} disabled={busy || sites === null} onClick={() => setAdding(true)}>
Add
</Button>
<BoardButtons board={board} />
<Button variant="outlined" startIcon={<Refresh />} disabled={busy} onClick={() => void refresh()}>
Refresh
</Button>
@@ -132,94 +233,7 @@ export default function SitesPanel(props: { onOpenFiles: (name: string) => void
{error && <Alert severity={unavailable ? 'info' : 'error'} sx={{ mb: 2, whiteSpace: 'pre-line' }}>{error}</Alert>}
{section && (
<Box sx={{ mb: 2 }}>
<Section title="Settings">
<Pairs
rows={[
['State', <Chip key="state" size="small" label={section.enabled ? 'served' : 'not served'} color={section.enabled ? 'success' : 'default'} />],
['Largest upload', `${section.upload_max_mb} MiB`],
['WebDAV', <Chip key="webdav" size="small" label={section.webdav ? 'enabled' : 'disabled'} color={section.webdav ? 'success' : 'default'} />],
...(section.webdav && fqdn
? [['WebDAV URL', <Copyable key="url" value={`https://${fqdn}:${section.webdav_port}/`} label="WebDAV URL" />]] as [string, ReactNode][]
: []),
]}
/>
</Section>
</Box>
)}
{sites && (
<Section title="Sites">
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>URLs</TableCell>
<TableCell>Port</TableCell>
<TableCell>Listen</TableCell>
<TableCell>TLS</TableCell>
<TableCell>Editors</TableCell>
<TableCell>DNS</TableCell>
<TableCell>State</TableCell>
<TableCell align="right">Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{shown.length === 0 && (
<TableRow>
<TableCell colSpan={9} sx={{ color: 'text.secondary' }}>None.</TableCell>
</TableRow>
)}
{shown.map((site) => (
<TableRow key={site.name} hover>
<TableCell>{site.name}</TableCell>
<TableCell>
<Stack>
{siteUrls(site).map((url) => <Link key={url} href={url} target="_blank" rel="noreferrer">{url}</Link>)}
{site.hosts.length === 0 && 'any host name'}
</Stack>
</TableCell>
<TableCell>{site.port}</TableCell>
<TableCell>{site.listen}</TableCell>
<TableCell>{SITE_TLS_LABELS[site.tls]}{site.tls === 'ca' ? ` (${site.ca})` : ''}</TableCell>
<TableCell>{site.editors || '-'}</TableCell>
<TableCell>{SITE_DNS_LABELS[site.dns]}{site.dns === 'router' ? `, ${SITE_DNS_ADDRESS_LABELS[site.dns_address]}` : ''}</TableCell>
<TableCell sx={{ color: site.enabled ? 'success.main' : 'text.secondary' }}>{site.enabled ? 'enabled' : 'disabled'}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
<Tooltip title="Files">
<span>
<IconButton size="small" onClick={() => props.onOpenFiles(site.name)}><FolderOpen fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title="Edit">
<span>
<IconButton size="small" disabled={busy} onClick={() => setEditing(site)}><Edit fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title={site.enabled ? 'Disable' : 'Enable'}>
<span>
<IconButton
size="small"
disabled={busy}
onClick={() => void change(() => request('PUT', `/sites/${site.name}`, SITE_SHAPE, { enabled: !site.enabled }))}
>
{site.enabled ? <Block fontSize="small" /> : <CheckCircle fontSize="small" />}
</IconButton>
</span>
</Tooltip>
<Tooltip title="Remove">
<span>
<IconButton size="small" color="error" disabled={busy} onClick={() => remove(site)}><Delete fontSize="small" /></IconButton>
</span>
</Tooltip>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Section>
)}
<Board board={board} panels={panels} />
{adding && (
<SiteDialog