mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 10:46:16 +01:00
add prettier config and format files site files
This commit is contained in:
@@ -1,30 +1,21 @@
|
||||
import './index.css'
|
||||
import { Suspense, lazy, useEffect, StrictMode } from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import Home from './components/routes/home.tsx'
|
||||
import { ThemeProvider } from './components/theme-provider.tsx'
|
||||
import {
|
||||
$authenticated,
|
||||
$systems,
|
||||
pb,
|
||||
$publicKey,
|
||||
$hubVersion,
|
||||
$copyContent,
|
||||
} from './lib/stores.ts'
|
||||
import { updateUserSettings, updateAlerts, updateFavicon, updateSystemList } from './lib/utils.ts'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { Toaster } from './components/ui/toaster.tsx'
|
||||
import { $router } from './components/router.tsx'
|
||||
import SystemDetail from './components/routes/system.tsx'
|
||||
|
||||
import './lib/i18n.ts'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Navbar from './components/navbar.tsx'
|
||||
import "./index.css"
|
||||
import { Suspense, lazy, useEffect, StrictMode } from "react"
|
||||
import ReactDOM from "react-dom/client"
|
||||
import Home from "./components/routes/home.tsx"
|
||||
import { ThemeProvider } from "./components/theme-provider.tsx"
|
||||
import { $authenticated, $systems, pb, $publicKey, $hubVersion, $copyContent } from "./lib/stores.ts"
|
||||
import { updateUserSettings, updateAlerts, updateFavicon, updateSystemList } from "./lib/utils.ts"
|
||||
import { useStore } from "@nanostores/react"
|
||||
import { Toaster } from "./components/ui/toaster.tsx"
|
||||
import { $router } from "./components/router.tsx"
|
||||
import SystemDetail from "./components/routes/system.tsx"
|
||||
import Navbar from "./components/navbar.tsx"
|
||||
import "./lib/i18n.ts"
|
||||
|
||||
// const ServerDetail = lazy(() => import('./components/routes/system.tsx'))
|
||||
const LoginPage = lazy(() => import('./components/login/login.tsx'))
|
||||
const CopyToClipboardDialog = lazy(() => import('./components/copy-to-clipboard.tsx'))
|
||||
const Settings = lazy(() => import('./components/routes/settings/layout.tsx'))
|
||||
const LoginPage = lazy(() => import("./components/login/login.tsx"))
|
||||
const CopyToClipboardDialog = lazy(() => import("./components/copy-to-clipboard.tsx"))
|
||||
const Settings = lazy(() => import("./components/routes/settings/layout.tsx"))
|
||||
|
||||
const App = () => {
|
||||
const page = useStore($router)
|
||||
@@ -37,7 +28,7 @@ const App = () => {
|
||||
$authenticated.set(pb.authStore.isValid)
|
||||
})
|
||||
// get version / public key
|
||||
pb.send('/api/beszel/getkey', {}).then((data) => {
|
||||
pb.send("/api/beszel/getkey", {}).then((data) => {
|
||||
$publicKey.set(data.key)
|
||||
$hubVersion.set(data.v)
|
||||
})
|
||||
@@ -46,34 +37,34 @@ const App = () => {
|
||||
// get alerts after system list is loaded
|
||||
updateSystemList().then(updateAlerts)
|
||||
|
||||
return () => updateFavicon('favicon.svg')
|
||||
return () => updateFavicon("favicon.svg")
|
||||
}, [])
|
||||
|
||||
// update favicon
|
||||
useEffect(() => {
|
||||
if (!systems.length || !authenticated) {
|
||||
updateFavicon('favicon.svg')
|
||||
updateFavicon("favicon.svg")
|
||||
} else {
|
||||
let up = false
|
||||
for (const system of systems) {
|
||||
if (system.status === 'down') {
|
||||
updateFavicon('favicon-red.svg')
|
||||
if (system.status === "down") {
|
||||
updateFavicon("favicon-red.svg")
|
||||
return
|
||||
} else if (system.status === 'up') {
|
||||
} else if (system.status === "up") {
|
||||
up = true
|
||||
}
|
||||
}
|
||||
updateFavicon(up ? 'favicon-green.svg' : 'favicon.svg')
|
||||
updateFavicon(up ? "favicon-green.svg" : "favicon.svg")
|
||||
}
|
||||
}, [systems])
|
||||
|
||||
if (!page) {
|
||||
return <h1 className="text-3xl text-center my-14">404</h1>
|
||||
} else if (page.path === '/') {
|
||||
} else if (page.path === "/") {
|
||||
return <Home />
|
||||
} else if (page.route === 'server') {
|
||||
} else if (page.route === "server") {
|
||||
return <SystemDetail name={page.params.name} />
|
||||
} else if (page.route === 'settings') {
|
||||
} else if (page.route === "settings") {
|
||||
return (
|
||||
<Suspense>
|
||||
<Settings />
|
||||
@@ -83,8 +74,6 @@ const App = () => {
|
||||
}
|
||||
|
||||
const Layout = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const authenticated = useStore($authenticated)
|
||||
const copyContent = useStore($copyContent)
|
||||
|
||||
@@ -98,7 +87,7 @@ const Layout = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="container">{Navbar(t)}</div>
|
||||
<div className="container">{Navbar()}</div>
|
||||
<div className="container mb-14 relative">
|
||||
<App />
|
||||
{copyContent && (
|
||||
@@ -111,7 +100,7 @@ const Layout = () => {
|
||||
)
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('app')!).render(
|
||||
ReactDOM.createRoot(document.getElementById("app")!).render(
|
||||
// strict mode in dev mounts / unmounts components twice
|
||||
// and breaks the clipboard dialog
|
||||
//<StrictMode>
|
||||
|
||||
Reference in New Issue
Block a user