2025-04-11 14:48:12 +02:00
|
|
|
import * as React from "react"
|
|
|
|
|
import Image from "next/image"
|
2025-04-15 12:17:14 +02:00
|
|
|
import { AppWindow, Settings, LayoutDashboardIcon, Briefcase, Server, Network, Activity } from "lucide-react"
|
2025-04-11 14:48:12 +02:00
|
|
|
import {
|
|
|
|
|
Sidebar,
|
|
|
|
|
SidebarContent,
|
|
|
|
|
SidebarGroup,
|
|
|
|
|
SidebarHeader,
|
|
|
|
|
SidebarMenu,
|
|
|
|
|
SidebarMenuButton,
|
|
|
|
|
SidebarMenuItem,
|
|
|
|
|
SidebarMenuSub,
|
|
|
|
|
SidebarMenuSubButton,
|
|
|
|
|
SidebarMenuSubItem,
|
|
|
|
|
SidebarRail,
|
|
|
|
|
} from "@/components/ui/sidebar"
|
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
|
import Link from "next/link"
|
2025-04-13 21:10:17 +02:00
|
|
|
import Cookies from "js-cookie"
|
|
|
|
|
import { useRouter } from "next/navigation"
|
2025-04-14 14:55:16 +02:00
|
|
|
import packageJson from "@/package.json"
|
2025-04-13 21:10:17 +02:00
|
|
|
|
|
|
|
|
interface NavItem {
|
|
|
|
|
title: string
|
|
|
|
|
icon?: React.ComponentType<any>
|
|
|
|
|
url: string
|
|
|
|
|
isActive?: boolean
|
|
|
|
|
items?: NavItem[]
|
|
|
|
|
}
|
2025-04-11 14:48:12 +02:00
|
|
|
|
2025-04-13 21:10:17 +02:00
|
|
|
const data: { navMain: NavItem[] } = {
|
2025-04-11 14:48:12 +02:00
|
|
|
navMain: [
|
|
|
|
|
{
|
2025-04-13 21:10:17 +02:00
|
|
|
title: "Dashboard",
|
|
|
|
|
icon: LayoutDashboardIcon,
|
|
|
|
|
url: "/dashboard"
|
2025-04-11 14:48:12 +02:00
|
|
|
},
|
|
|
|
|
{
|
2025-04-13 21:10:17 +02:00
|
|
|
title: "My Infrastructure",
|
|
|
|
|
url: "#",
|
|
|
|
|
icon: Briefcase,
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
title: "Servers",
|
|
|
|
|
icon: Server,
|
|
|
|
|
url: "/dashboard/servers",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Applications",
|
|
|
|
|
icon: AppWindow,
|
|
|
|
|
url: "/dashboard/applications",
|
|
|
|
|
},
|
2025-04-15 12:17:14 +02:00
|
|
|
{
|
|
|
|
|
title: "Activity",
|
|
|
|
|
icon: Activity,
|
|
|
|
|
url: "/dashboard/activity",
|
|
|
|
|
},
|
2025-04-13 21:10:17 +02:00
|
|
|
{
|
|
|
|
|
title: "Network",
|
|
|
|
|
icon: Network,
|
|
|
|
|
url: "/dashboard/network",
|
|
|
|
|
},
|
2025-04-11 14:48:12 +02:00
|
|
|
],
|
2025-04-12 13:21:03 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Settings",
|
|
|
|
|
icon: Settings,
|
2025-04-12 20:01:43 +02:00
|
|
|
url: "/dashboard/settings",
|
2025-04-11 14:48:12 +02:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
2025-04-13 21:10:17 +02:00
|
|
|
|
2025-04-11 14:48:12 +02:00
|
|
|
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
2025-04-13 21:10:17 +02:00
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
const logout = async () => {
|
|
|
|
|
Cookies.remove('token')
|
|
|
|
|
router.push("/")
|
|
|
|
|
}
|
2025-04-11 14:50:26 +02:00
|
|
|
|
2025-04-13 21:10:17 +02:00
|
|
|
return (
|
2025-04-11 14:48:12 +02:00
|
|
|
<Sidebar {...props}>
|
|
|
|
|
<SidebarHeader>
|
|
|
|
|
<SidebarMenu>
|
|
|
|
|
<SidebarMenuItem>
|
|
|
|
|
<SidebarMenuButton size="lg" asChild>
|
2025-04-12 22:05:42 +02:00
|
|
|
<a href="https://github.com/crocofied/corecontrol">
|
2025-04-11 14:48:12 +02:00
|
|
|
<Image src="/logo.png" width={48} height={48} alt="Logo"/>
|
|
|
|
|
<div className="flex flex-col gap-0.5 leading-none">
|
|
|
|
|
<span className="font-semibold">CoreControl</span>
|
2025-04-14 14:55:16 +02:00
|
|
|
<span className="">v{packageJson.version}</span>
|
2025-04-11 14:48:12 +02:00
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
</SidebarMenuButton>
|
|
|
|
|
</SidebarMenuItem>
|
|
|
|
|
</SidebarMenu>
|
|
|
|
|
</SidebarHeader>
|
2025-04-13 21:10:17 +02:00
|
|
|
|
2025-04-11 14:48:12 +02:00
|
|
|
<SidebarContent className="flex flex-col h-full">
|
|
|
|
|
<SidebarGroup className="flex-grow">
|
2025-04-13 21:10:17 +02:00
|
|
|
<SidebarMenu>
|
2025-04-11 14:48:12 +02:00
|
|
|
{data.navMain.map((item) => (
|
2025-04-13 21:10:17 +02:00
|
|
|
<SidebarMenuItem key={item.title}>
|
2025-04-11 14:48:12 +02:00
|
|
|
<SidebarMenuButton asChild>
|
2025-04-13 21:10:17 +02:00
|
|
|
<Link href={item.url} className="font-medium">
|
2025-04-11 14:48:12 +02:00
|
|
|
{item.icon && <item.icon className="mr-2" />}
|
|
|
|
|
{item.title}
|
2025-04-13 21:10:17 +02:00
|
|
|
</Link>
|
2025-04-11 14:48:12 +02:00
|
|
|
</SidebarMenuButton>
|
2025-04-13 21:10:17 +02:00
|
|
|
{item.items?.length && (
|
|
|
|
|
<SidebarMenuSub>
|
2025-04-11 14:48:12 +02:00
|
|
|
{item.items.map((subItem) => (
|
2025-04-13 21:10:17 +02:00
|
|
|
<SidebarMenuSubItem key={subItem.title}>
|
|
|
|
|
<SidebarMenuSubButton
|
|
|
|
|
asChild
|
|
|
|
|
isActive={subItem.isActive ?? false}
|
|
|
|
|
>
|
|
|
|
|
<Link href={subItem.url}>
|
2025-04-11 14:48:12 +02:00
|
|
|
{subItem.icon && <subItem.icon className="mr-2" />}
|
|
|
|
|
{subItem.title}
|
2025-04-13 21:10:17 +02:00
|
|
|
</Link>
|
2025-04-11 14:48:12 +02:00
|
|
|
</SidebarMenuSubButton>
|
2025-04-13 21:10:17 +02:00
|
|
|
</SidebarMenuSubItem>
|
2025-04-11 14:48:12 +02:00
|
|
|
))}
|
2025-04-13 21:10:17 +02:00
|
|
|
</SidebarMenuSub>
|
|
|
|
|
)}
|
|
|
|
|
</SidebarMenuItem>
|
2025-04-11 14:48:12 +02:00
|
|
|
))}
|
2025-04-13 21:10:17 +02:00
|
|
|
</SidebarMenu>
|
2025-04-11 14:48:12 +02:00
|
|
|
</SidebarGroup>
|
|
|
|
|
|
|
|
|
|
<div className="p-4">
|
2025-04-13 21:10:17 +02:00
|
|
|
<Button variant="destructive" className="w-full" onClick={logout}>
|
2025-04-11 14:48:12 +02:00
|
|
|
Logout
|
2025-04-13 21:10:17 +02:00
|
|
|
</Button>
|
2025-04-11 14:48:12 +02:00
|
|
|
</div>
|
2025-04-13 21:10:17 +02:00
|
|
|
</SidebarContent>
|
2025-04-11 14:48:12 +02:00
|
|
|
|
|
|
|
|
<SidebarRail />
|
|
|
|
|
</Sidebar>
|
|
|
|
|
)
|
2025-04-13 21:10:17 +02:00
|
|
|
}
|