feat: rebranded from vpn-router to linux-manager.
This commit is contained in:
1 parent
8efe21bfa6
commit
85a1ffa21f
238 files changed
+5010
-3761
No files matched your search
+39
-17
@@ -17,7 +17,7 @@ import DnsPanel from './DnsPanel.tsx'
|
||||
import PageMenu, { CA_PATH, DOCKER_PATH, REMOTE_ACCESS_PATH, SHELL_PATH, SITES_PATH, SITE_TO_SITE_PATH, USERS_PATH, USER_PATH } from './PageMenu.tsx'
|
||||
import NetworkPanel from './NetworkPanel.tsx'
|
||||
import RemoteAccessPanel from './RemoteAccessPanel.tsx'
|
||||
import RouterPanel from './RouterPanel.tsx'
|
||||
import ServerPanel from './ServerPanel.tsx'
|
||||
import ServiceAccountsPanel from './ServiceAccountsPanel.tsx'
|
||||
import SettingsButton from './SettingsButton.tsx'
|
||||
import ShellPanel from './ShellPanel.tsx'
|
||||
@@ -30,7 +30,8 @@ import SiteToSiteStatusPanel from './SiteToSiteStatusPanel.tsx'
|
||||
import ThemeMenu from './ThemeMenu.tsx'
|
||||
import UsersPanel from './UsersPanel.tsx'
|
||||
import {
|
||||
ACCOUNT_SHAPE, SESSION_EXPIRED, SESSION_SHAPE, request, type Account, type Info, type RemoteAccessSystem, type Session,
|
||||
ACCOUNT_SHAPE, DETAILS_SHAPE, SESSION_EXPIRED, SESSION_SHAPE, request, type Account, type Info, type RemoteAccessSystem,
|
||||
type RouterDetails, type Session,
|
||||
} from './api.ts'
|
||||
|
||||
/** The tabs of the Router page, router being the Overview tab, of the Identities page, of the Connectivity page and of the Web Sites page. */
|
||||
@@ -43,7 +44,7 @@ type SitesView = 'sites' | 'files' | 'dns'
|
||||
const SITES_TOPICS: Record<SitesView, string> = { sites: 'sites.md', files: 'site-files.md', dns: 'dns.md' }
|
||||
|
||||
/** The prefix of the sessionStorage keys of the pages the account and the shell page were opened from, by their paths. */
|
||||
const RETURN_KEY = 'vpn-router-manager.return:'
|
||||
const RETURN_KEY = 'linux-manager-ui.return:'
|
||||
|
||||
/** The pages of an administrator besides Router, which every other path shows. */
|
||||
const PAGE_PATHS = [USER_PATH, USERS_PATH, SITE_TO_SITE_PATH, REMOTE_ACCESS_PATH, CA_PATH, SITES_PATH, DOCKER_PATH, SHELL_PATH]
|
||||
@@ -59,14 +60,14 @@ const HELP_TOPICS: Record<string, string> = {
|
||||
}
|
||||
|
||||
/** The localStorage key of whether the help is open. */
|
||||
const HELP_KEY = 'vpn-router-manager.help'
|
||||
const HELP_KEY = 'linux-manager-ui.help'
|
||||
|
||||
/**
|
||||
* The page asks for a sign-in until a session exists. At USER_PATH, and for a user who is not a member of admins at
|
||||
* every path, it then shows the user's own account; at USERS_PATH the router's users, groups or service accounts; at
|
||||
* every path, it then shows the user's own account; at USERS_PATH the server's users, groups or service accounts; at
|
||||
* SITE_TO_SITE_PATH its site-to-site connections, their state and its network with its routes; at REMOTE_ACCESS_PATH its IKEv2, OpenVPN and
|
||||
* WireGuard access; at CA_PATH its certificates; at SITES_PATH its web
|
||||
* sites, the files of a site, opened from the sites too, and its name server; at DOCKER_PATH the state of Docker; at SHELL_PATH a shell on the router; otherwise the state of the router, with the update information of its packages in
|
||||
* sites, the files of a site, opened from the sites too, and its name server; at DOCKER_PATH the state of Docker; at SHELL_PATH a shell on the server; otherwise the state of the server, with the update information of its packages in
|
||||
* the Status panel, its metrics, its logs, its backups or the updates of its system's packages. A page shows one tab at a time, each read only while shown. An
|
||||
* administrator switches pages with the page menu at the right end of the header; the button with the user's name,
|
||||
* left of Sign out, opens the user's own account, and an administrator's shell button, left of it, the shell; pressed
|
||||
@@ -84,6 +85,10 @@ export default function App(props: { info: Info }) {
|
||||
const [filesSite, setFilesSite] = useState<string | null>(null)
|
||||
const [session, setSession] = useState<Session | null | undefined>(undefined)
|
||||
const [role, setRole] = useState<{ name: string; admin: boolean } | null>(null)
|
||||
// The router and the VPN components as router.enabled and vpn.enabled of /config; null while not known, when every page shows.
|
||||
const [components, setComponents] = useState<{ router: boolean; vpn: boolean } | null>(null)
|
||||
const routerOff = components?.router === false
|
||||
const vpnOff = components?.vpn === false
|
||||
const page = PAGE_PATHS.find((path) => path === window.location.pathname) ?? '/'
|
||||
const userPage = page === USER_PATH
|
||||
const admin = session && role?.name === session.name ? role.admin : undefined
|
||||
@@ -129,6 +134,18 @@ export default function App(props: { info: Info }) {
|
||||
.catch(() => setRole({ name: session.name, admin: false }))
|
||||
}, [session])
|
||||
|
||||
useEffect(() => {
|
||||
if (!admin) {
|
||||
return
|
||||
}
|
||||
request<RouterDetails>('GET', '/config', DETAILS_SHAPE)
|
||||
.then((details) => setComponents({
|
||||
router: details.configuration.router?.enabled === true,
|
||||
vpn: details.configuration.vpn?.enabled === true,
|
||||
}))
|
||||
.catch(() => setComponents(null))
|
||||
}, [admin])
|
||||
|
||||
/** Opens the page of the path, keeping the page it was opened from in sessionStorage, or returns to that page from it. */
|
||||
function toggle(path: string) {
|
||||
if (page === path) {
|
||||
@@ -159,14 +176,14 @@ export default function App(props: { info: Info }) {
|
||||
<Box>
|
||||
<Stack direction="row" sx={{ alignItems: 'baseline', gap: 1 }}>
|
||||
<Typography variant="h5" component="h1">
|
||||
VPN Router Manager
|
||||
Ubuntu Linux Manager
|
||||
</Typography>
|
||||
<Typography variant="caption" color="text.secondary" sx={{ fontFamily: 'monospace' }}>
|
||||
{props.info.version ?? 'development'}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
|
||||
Router status page:{' '}
|
||||
Server status page:{' '}
|
||||
{props.info.status_url
|
||||
? <Link href={props.info.status_url} target="_blank" rel="noreferrer">{props.info.status_url}</Link>
|
||||
: <b>not configured</b>}
|
||||
@@ -220,7 +237,7 @@ export default function App(props: { info: Info }) {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
{session && admin && <PageMenu path={page} />}
|
||||
{session && admin && <PageMenu path={page} hidden={vpnOff ? [REMOTE_ACCESS_PATH] : []} />}
|
||||
</Stack>
|
||||
</Stack>
|
||||
{session === undefined && <CircularProgress />}
|
||||
@@ -264,7 +281,12 @@ export default function App(props: { info: Info }) {
|
||||
<ShellPanel editorShown={editorShown} onFiles={showFiles} onOpened={showEditor} />
|
||||
</>
|
||||
)}
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && (
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && vpnOff && (
|
||||
<Typography color="text.secondary">
|
||||
The VPN is off on this server: IKEv2, OpenVPN and WireGuard need vpn.enabled in the configuration.
|
||||
</Typography>
|
||||
)}
|
||||
{session && admin && page === REMOTE_ACCESS_PATH && !vpnOff && (
|
||||
<>
|
||||
<Tabs value={remoteAccessView} onChange={(_event, next: RemoteAccessSystem) => setRemoteAccessView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tab value="p2s" label="IKEv2" />
|
||||
@@ -276,14 +298,14 @@ export default function App(props: { info: Info }) {
|
||||
)}
|
||||
{session && admin && page === SITE_TO_SITE_PATH && (
|
||||
<>
|
||||
<Tabs value={siteToSiteView} onChange={(_event, next: SiteToSiteView) => setSiteToSiteView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tab value="status" label="Status" />
|
||||
<Tabs value={routerOff ? 'network' : siteToSiteView} onChange={(_event, next: SiteToSiteView) => setSiteToSiteView(next)} sx={{ mb: 3, borderBottom: 1, borderColor: 'divider' }}>
|
||||
{!routerOff && <Tab value="status" label="Status" />}
|
||||
<Tab value="network" label="Network" />
|
||||
<Tab value="connections" label="Connections" />
|
||||
{!routerOff && <Tab value="connections" label="Connections" />}
|
||||
</Tabs>
|
||||
{siteToSiteView === 'connections' && <SiteToSitePanel />}
|
||||
{siteToSiteView === 'status' && <SiteToSiteStatusPanel />}
|
||||
{siteToSiteView === 'network' && <NetworkPanel />}
|
||||
{!routerOff && siteToSiteView === 'connections' && <SiteToSitePanel />}
|
||||
{!routerOff && siteToSiteView === 'status' && <SiteToSiteStatusPanel />}
|
||||
{(routerOff || siteToSiteView === 'network') && <NetworkPanel />}
|
||||
</>
|
||||
)}
|
||||
{session && admin && page === USERS_PATH && (
|
||||
@@ -307,7 +329,7 @@ export default function App(props: { info: Info }) {
|
||||
<Tab value="backup" label="Backup" />
|
||||
<Tab value="system" label="System" />
|
||||
</Tabs>
|
||||
{view === 'router' && <RouterPanel />}
|
||||
{view === 'router' && <ServerPanel />}
|
||||
{view === 'metrics' && <MetricsPanel />}
|
||||
{view === 'logs' && <LogsPanel />}
|
||||
{view === 'backup' && <BackupPanel />}
|
||||
|
||||
Reference in new issue
Block a user