OpenClawDashboard/dashboard/src/components/app-sidebar.tsx
Mannu 6127b6de24 feat: add /positions dashboard page with live P&L stats and table
- New /api/positions route proxies to angel.manohargupta.com (positions + pnl-history)
- Positions page: 4 stat cards (total/unrealised/realised/open count), open table, closed-today table
- Auto-refreshes every 30s; manual refresh triggers force-poll on tracker
- Add Positions nav item to app-sidebar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 09:40:56 +05:30

130 lines
No EOL
3.1 KiB
TypeScript

"use client"
import * as React from "react"
import {
Bot,
Settings2,
LayoutDashboard,
ScrollText,
CheckSquare,
DollarSign,
FolderOpen,
Briefcase,
BarChart2,
} from "lucide-react"
import { useTigerLogs } from "@/hooks/use-bridge"
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarRail,
} from "@/components/ui/sidebar"
// Tiger-specific navigation - no more old clawdbot pages
const navMain = [
{
title: "Dashboard",
url: "/",
icon: LayoutDashboard,
},
{
title: "Projects",
url: "/projects",
icon: Briefcase,
},
{
title: "Workspace",
url: "/workspace",
icon: FolderOpen,
},
{
title: "Tasks",
url: "/tasks",
icon: CheckSquare,
},
{
title: "Positions",
url: "/positions",
icon: BarChart2,
},
{
title: "Cost Monitor",
url: "/cost",
icon: DollarSign,
},
{
title: "Logs",
url: "/logs",
icon: ScrollText,
},
]
const navSecondary = [
{
title: "Settings",
url: "/settings",
icon: Settings2,
},
]
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
// Use Tiger logs SSE for connection status
// connected means the bridge is reachable
const { connected } = useTigerLogs({ lines: 1, maxLines: 1 })
return (
<Sidebar collapsible="icon" {...props}>
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<a href="/">
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<Bot className="size-4" />
</div>
<div className="flex items-center gap-2">
<span className={`h-2 w-2 rounded-full ${connected ? 'bg-green-500' : 'bg-red-500'}`} />
<span className="text-xs text-muted-foreground">{connected ? "Live" : "Offline"}</span>
</div>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<SidebarMenu className="gap-2 p-2">
{navMain.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton asChild tooltip={item.title}>
<a href={item.url}>
<item.icon />
<span>{item.title}</span>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</SidebarContent>
<SidebarFooter>
<SidebarMenu>
{navSecondary.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton asChild size="sm">
<a href={item.url}>
<item.icon />
<span>{item.title}</span>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</SidebarFooter>
<SidebarRail />
</Sidebar>
)
}