mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-11 22:05:33 +00:00
- Add new /containers route with virtualized table showing all containers across systems - Implement container stats collection (CPU, memory, network usage) with health status tracking - Add container logs and info API endpoints with syntax highlighting using Shiki - Create detailed container views with fullscreen logs/info dialogs and refresh functionality - Add container table to individual system pages with lazy loading - Implement container record storage with automatic cleanup and historical averaging - Update navbar with container navigation icon - Extract reusable ActiveAlerts component from home page - Add FooterRepoLink component for consistent GitHub/version display - Enhance filtering and search capabilities across container tables
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
import { createRouter } from "@nanostores/router"
|
|
|
|
const routes = {
|
|
home: "/",
|
|
containers: "/containers",
|
|
system: `/system/:id`,
|
|
settings: `/settings/:name?`,
|
|
forgot_password: `/forgot-password`,
|
|
request_otp: `/request-otp`,
|
|
} as const
|
|
|
|
/**
|
|
* The base path of the application.
|
|
* This is used to prepend the base path to all routes.
|
|
*/
|
|
export const basePath = BESZEL?.BASE_PATH || ""
|
|
|
|
/**
|
|
* Prepends the base path to the given path.
|
|
* @param path The path to prepend the base path to.
|
|
* @returns The path with the base path prepended.
|
|
*/
|
|
export const prependBasePath = (path: string) => (basePath + path).replaceAll("//", "/")
|
|
|
|
// prepend base path to routes
|
|
for (const route in routes) {
|
|
// @ts-expect-error need as const above to get nanostores to parse types properly
|
|
routes[route] = prependBasePath(routes[route])
|
|
}
|
|
|
|
export const $router = createRouter(routes, { links: false })
|
|
|
|
/** Navigate to url using router
|
|
* Base path is automatically prepended if serving from subpath
|
|
*/
|
|
export const navigate = (urlString: string) => {
|
|
$router.open(urlString)
|
|
}
|
|
|
|
export function Link(props: React.AnchorHTMLAttributes<HTMLAnchorElement>) {
|
|
return (
|
|
<a
|
|
{...props}
|
|
onClick={(e) => {
|
|
e.preventDefault()
|
|
const href = props.href || ""
|
|
if (e.ctrlKey || e.metaKey) {
|
|
window.open(href, "_blank")
|
|
} else {
|
|
navigate(href)
|
|
props.onClick?.(e)
|
|
}
|
|
}}
|
|
></a>
|
|
)
|
|
}
|