diff --git a/ui/src/components/AgentCard.tsx b/ui/src/components/AgentCard.tsx index 68c4c39..f006b79 100644 --- a/ui/src/components/AgentCard.tsx +++ b/ui/src/components/AgentCard.tsx @@ -1,6 +1,6 @@ import { UptimeMessage } from "@/services/types"; import { formatRelativeTime, isAgentOnline } from "@/services/utils"; -import { DottedProgressBar } from "./Progressbar"; +import { Progressbar } from "./Progressbar"; export type AgentOverviewCardProps = { count: number; @@ -69,24 +69,23 @@ export function AgentCard({ props }: { props: AgentCardProps }) { onClick={() => props.onClick?.()} className="bg-[#111111] border border-[#262626] rounded-lg p-6 hover:bg-[#151515] transition-all cursor-pointer group" > -
+
{status.name.toUpperCase()}
-

+

{props.data.agent}

-
diff --git a/ui/src/components/Header.tsx b/ui/src/components/Header.tsx index b2b86eb..c8a0a23 100644 --- a/ui/src/components/Header.tsx +++ b/ui/src/components/Header.tsx @@ -9,7 +9,7 @@ export type HeaderProps = { export function Header({ props }: { props: HeaderProps }) { return ( -
+
diff --git a/ui/src/components/Progressbar.tsx b/ui/src/components/Progressbar.tsx index 5c797ce..d5d91a6 100644 --- a/ui/src/components/Progressbar.tsx +++ b/ui/src/components/Progressbar.tsx @@ -1,20 +1,54 @@ -export function DottedProgressBar({ +"use client"; + +import { useEffect, useRef, useState } from "react"; + +export function Progressbar({ color, percentage, - totalDots = 10, }: { color: string; percentage: number; - totalDots?: number; }) { + const containerRef = useRef(null); + const [totalDots, setTotalDots] = useState(0); + + useEffect(() => { + const calculateDots = () => { + if (!containerRef.current) return; + + const parent = + containerRef.current.parentElement?.parentElement + ?.parentElement; + + if (!parent) return; + + const availableWidth = parent.clientWidth; + const dotCount = Math.floor(availableWidth / 48); + + setTotalDots(Math.max(5, Math.min(20, dotCount))); + }; + + calculateDots(); + + const resizeObserver = new ResizeObserver(calculateDots); + if (containerRef.current) { + resizeObserver.observe(containerRef.current); + } + + return () => resizeObserver.disconnect(); + }); + const filledDots = Math.round((percentage / 100) * totalDots); return ( -
+
{Array.from({ length: totalDots }).map((_, index) => (
diff --git a/ui/src/pages/home.tsx b/ui/src/pages/home.tsx index 4c09a48..7077c95 100644 --- a/ui/src/pages/home.tsx +++ b/ui/src/pages/home.tsx @@ -32,55 +32,60 @@ export function HomePage() { }} />
-

Overview

+
+

Overview

-
- , - color: "rgb(96, 165, 250)", - bgColor: "rgba(59, 130, 246, 0.2)", - }, - }} - /> - - ), - color: "rgb(34, 197, 94)", - bgColor: "rgba(34, 197, 94, 0.2)", - }, - }} - /> - - ), - color: "rgb(239, 68, 68)", - bgColor: "rgba(239, 68, 68, 0.2)", - }, - }} - /> -
+
+ , + color: "rgb(96, 165, 250)", + bgColor: "rgba(59, 130, 246, 0.2)", + }, + }} + /> + + ), + color: "rgb(34, 197, 94)", + bgColor: "rgba(34, 197, 94, 0.2)", + }, + }} + /> + + ), + color: "rgb(239, 68, 68)", + bgColor: "rgba(239, 68, 68, 0.2)", + }, + }} + /> +
-
-

Agents

+
+

Agents

-
- {agents.map((agent, index) => ( - - ))} +
+ {agents.map((agent, index) => ( + + ))} +