Add config file and text editor + update server
This commit is contained in:
208
src/App.tsx
208
src/App.tsx
@@ -5,18 +5,13 @@ import { Moon, Sun, Monitor} from "lucide-react"
|
||||
import * as LucideIcons from "lucide-react"
|
||||
import { useTheme } from "@/components/theme-provider"
|
||||
import { useMetrics } from "./hooks/useMetrics"
|
||||
import { useConfig } from "./hooks/useConfig"
|
||||
import { ServiceStatus } from "./types/metrics"
|
||||
import { ServiceCard } from "./types/services"
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
|
||||
|
||||
interface ServiceCard {
|
||||
name: string
|
||||
description: string
|
||||
url: string
|
||||
icon?: React.ReactNode
|
||||
iconName?: string
|
||||
category: 'system' | 'media' | 'monitoring' | 'tools' | 'acot' | 'home'
|
||||
monitorName?: string
|
||||
}
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { ConfigEditor } from './components/config-editor'
|
||||
|
||||
const getIconUrl = (name: string | undefined, isDark: boolean = false): string => {
|
||||
if (!name) return ''
|
||||
@@ -75,149 +70,6 @@ function ServiceIcon({ service, isDark }: { service: ServiceCard, isDark: boolea
|
||||
return <Icon className="h-6 w-6" />
|
||||
}
|
||||
|
||||
const services: ServiceCard[] = [
|
||||
{
|
||||
name: "Portainer",
|
||||
description: "Container Management",
|
||||
url: "https://portainer.kent.pw",
|
||||
iconName: "portainer",
|
||||
category: "system"
|
||||
},
|
||||
{
|
||||
name: "Gitea",
|
||||
description: "Git Server",
|
||||
url: "https://gitea.kent.pw",
|
||||
iconName: "gitea",
|
||||
category: "system"
|
||||
},
|
||||
{
|
||||
name: "Cockpit",
|
||||
description: "Server Management",
|
||||
url: "https://cockpit.kent.pw",
|
||||
iconName: "cockpit",
|
||||
category: "system"
|
||||
},
|
||||
{
|
||||
name: "DiskStation",
|
||||
description: "Synology NAS",
|
||||
url: "https://diskstation.kent.pw",
|
||||
iconName: "synology",
|
||||
category: "system",
|
||||
monitorName: "Synology Diskstation"
|
||||
},
|
||||
{
|
||||
name: "Plex",
|
||||
description: "Media Server",
|
||||
url: "https://plex.kent.pw",
|
||||
iconName: "plex",
|
||||
category: "media"
|
||||
},
|
||||
{
|
||||
name: "Sonarr",
|
||||
description: "TV Show Management",
|
||||
url: "https://sonarr.kent.pw",
|
||||
iconName: "sonarr",
|
||||
category: "media"
|
||||
},
|
||||
{
|
||||
name: "Jackett",
|
||||
description: "Torrent Indexer",
|
||||
url: "https://jackett.kent.pw",
|
||||
iconName: "jackett",
|
||||
category: "media"
|
||||
},
|
||||
{
|
||||
name: "Deluge",
|
||||
description: "Torrent Client",
|
||||
url: "https://deluge.kent.pw",
|
||||
iconName: "deluge",
|
||||
category: "media"
|
||||
},
|
||||
{
|
||||
name: "Uptime",
|
||||
description: "Service Monitoring",
|
||||
url: "https://uptime.kent.pw",
|
||||
iconName: "uptime-kuma",
|
||||
category: "monitoring",
|
||||
monitorName: "Uptime Kuma"
|
||||
},
|
||||
{
|
||||
name: "AdGuard",
|
||||
description: "Network Ad Blocking",
|
||||
url: "https://adguard.kent.pw",
|
||||
iconName: "adguard-home",
|
||||
category: "system",
|
||||
monitorName: "Adguard Home"
|
||||
},
|
||||
{
|
||||
name: "NocoDB",
|
||||
description: "Database Platform",
|
||||
url: "https://noco.kent.pw",
|
||||
iconName: "nocodb",
|
||||
category: "tools",
|
||||
monitorName: "NocoDB"
|
||||
},
|
||||
{
|
||||
name: "IT Tools",
|
||||
description: "Developer Utilities",
|
||||
url: "https://ittools.kent.pw",
|
||||
iconName: "it-tools",
|
||||
category: "tools",
|
||||
monitorName: "IT Tools"
|
||||
},
|
||||
{
|
||||
name: "Firefox",
|
||||
description: "Browser Instance",
|
||||
url: "https://firefox.kent.pw",
|
||||
iconName: "firefox",
|
||||
category: "tools"
|
||||
},
|
||||
{
|
||||
name: "Speedtest",
|
||||
description: "Network Speed Monitor",
|
||||
url: "https://speedtest.kent.pw",
|
||||
iconName: "speedtest-tracker",
|
||||
category: "monitoring",
|
||||
monitorName: "Speedtest Tracker"
|
||||
},
|
||||
{
|
||||
name: "Drive",
|
||||
description: "File Storage",
|
||||
url: "https://drive.kent.pw",
|
||||
iconName: "synology",
|
||||
category: "tools",
|
||||
monitorName: "Synology Drive"
|
||||
},
|
||||
{
|
||||
name: "Dashboard",
|
||||
description: "ACOT Dashboard",
|
||||
url: "https://dashboard.kent.pw",
|
||||
iconName: "lucide-layout-dashboard",
|
||||
category: "acot"
|
||||
},
|
||||
{
|
||||
name: "Inventory",
|
||||
description: "ACOT Inventory",
|
||||
url: "https://inventory.kent.pw",
|
||||
iconName: "lucide-box",
|
||||
category: "acot"
|
||||
},
|
||||
{
|
||||
name: "Homebridge",
|
||||
description: "HomeKit Bridge",
|
||||
url: "https://homebridge.kent.pw",
|
||||
iconName: "homebridge",
|
||||
category: "home"
|
||||
},
|
||||
{
|
||||
name: "Scrypted",
|
||||
description: "Smart Home Integration",
|
||||
url: "https://scrypted.kent.pw",
|
||||
iconName: "scrypted",
|
||||
category: "home"
|
||||
}
|
||||
]
|
||||
|
||||
function ThemeToggle() {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
@@ -341,6 +193,8 @@ function ServiceSection({ title, services, metrics }: {
|
||||
return "bg-emerald-50 dark:bg-emerald-950/30"
|
||||
case "Speedtest":
|
||||
return "bg-blue-50 dark:bg-blue-950/30"
|
||||
case "Netdata":
|
||||
return "bg-purple-50 dark:bg-purple-950/30"
|
||||
default:
|
||||
return "bg-gray-50 dark:bg-gray-950/30"
|
||||
}
|
||||
@@ -375,6 +229,8 @@ function ServiceSection({ title, services, metrics }: {
|
||||
return "text-emerald-600 dark:text-emerald-400"
|
||||
case "Speedtest":
|
||||
return "text-blue-600 dark:text-blue-400"
|
||||
case "Netdata":
|
||||
return "text-purple-600 dark:text-purple-400"
|
||||
default:
|
||||
return "text-gray-600 dark:text-gray-400"
|
||||
}
|
||||
@@ -413,8 +269,12 @@ function ServiceSection({ title, services, metrics }: {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const { metrics } = useMetrics()
|
||||
const { config, error, saveConfig } = useConfig()
|
||||
const services = config.services
|
||||
|
||||
const systemServices = services.filter(s => s.category === 'system')
|
||||
const mediaServices = services.filter(s => s.category === 'media')
|
||||
const monitoringServices = services.filter(s => s.category === 'monitoring')
|
||||
@@ -426,15 +286,41 @@ function App() {
|
||||
<div className="min-h-screen p-8 space-y-8">
|
||||
<div className="flex justify-between items-center">
|
||||
<h1 className="text-4xl font-bold">Kent.pw Homepage</h1>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
<ServiceSection title="System" services={systemServices} metrics={metrics} />
|
||||
<ServiceSection title="Media" services={mediaServices} metrics={metrics} />
|
||||
<ServiceSection title="Monitoring" services={monitoringServices} metrics={metrics} />
|
||||
<ServiceSection title="Tools" services={toolServices} metrics={metrics} />
|
||||
<ServiceSection title="ACOT" services={acotServices} metrics={metrics} />
|
||||
<ServiceSection title="Home" services={homeServices} metrics={metrics} />
|
||||
<div className="flex items-center gap-2">
|
||||
<ConfigEditor currentConfig={config} onSave={saveConfig} />
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<Alert variant="destructive">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
<AlertDescription>
|
||||
Failed to load configuration: {error}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{services.length > 0 ? (
|
||||
<>
|
||||
<ServiceSection title="System" services={systemServices} metrics={metrics} />
|
||||
<ServiceSection title="Media" services={mediaServices} metrics={metrics} />
|
||||
<ServiceSection title="Monitoring" services={monitoringServices} metrics={metrics} />
|
||||
<ServiceSection title="Tools" services={toolServices} metrics={metrics} />
|
||||
<ServiceSection title="ACOT" services={acotServices} metrics={metrics} />
|
||||
<ServiceSection title="Home" services={homeServices} metrics={metrics} />
|
||||
</>
|
||||
) : !error && (
|
||||
<Alert>
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertTitle>Loading</AlertTitle>
|
||||
<AlertDescription>
|
||||
Loading service configuration...
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user