Skip to content

A modern and elegant dashboard for network traffic visualization and analysis.

feat: Implement auto-refresh spinning animation, refine tooltip styles, and conditionally display the manual refresh button.

luolei1c01c965eb7f
diff --git a/apps/web/app/[locale]/page.tsx b/apps/web/app/[locale]/page.tsx
index 4afdfc9..258e9ff 100644
--- a/apps/web/app/[locale]/page.tsx
+++ b/apps/web/app/[locale]/page.tsx
@@ -305,6 +305,7 @@ export default function DashboardPage() {
const [timePreset, setTimePreset] = useState<TimePreset>("24h");
const [isManualRefreshing, setIsManualRefreshing] = useState(false);
const [autoRefresh, setAutoRefresh] = useState(true);
+ const [autoRefreshTick, setAutoRefreshTick] = useState(0);
const [showBackendDialog, setShowBackendDialog] = useState(false);
const [isFirstTime, setIsFirstTime] = useState(false);
const [showAboutDialog, setShowAboutDialog] = useState(false);
@@ -443,6 +444,7 @@ export default function DashboardPage() {
useEffect(() => {
if (!autoRefresh || !isRollingTimePreset(timePreset)) return;
const interval = setInterval(() => {
+ setAutoRefreshTick((tick) => tick + 1);
setTimeRange(getPresetTimeRange(timePreset));
queryClient.removeQueries({ queryKey: ["stats"], type: "inactive" });
}, 5000);
@@ -453,6 +455,7 @@ export default function DashboardPage() {
useEffect(() => {
if (!autoRefresh || isRollingTimePreset(timePreset)) return;
const interval = setInterval(() => {
+ setAutoRefreshTick((tick) => tick + 1);
queryClient.invalidateQueries({ queryKey: ["stats"] });
}, 5000);
return () => clearInterval(interval);
@@ -529,7 +532,7 @@ export default function DashboardPage() {
/>
<main className="flex-1 min-w-0 lg:ml-0">
- <header className="sticky top-0 z-40 lg:static border-b border-border/40 bg-background/80 backdrop-blur-md">
+ <header className="sticky top-0 z-40 border-b border-border/40 bg-background/80 backdrop-blur-md">
<div className="flex items-center justify-between h-14 px-4 lg:px-6">
<div className="flex items-center gap-3">
{/* Mobile: Logo, Desktop: Page Title */}
@@ -647,7 +650,17 @@ export default function DashboardPage() {
? "text-emerald-600 hover:bg-emerald-500/10"
: "text-muted-foreground hover:bg-muted",
)}>
- <RefreshCw className={cn("w-4 h-4", autoRefresh && "text-emerald-500")} />
+ <RefreshCw
+ className={cn("w-4 h-4", autoRefresh && "text-emerald-500")}
+ style={
+ autoRefresh
+ ? {
+ transform: `rotate(${autoRefreshTick * 360}deg)`,
+ transition: "transform 650ms linear",
+ }
+ : undefined
+ }
+ />
</Button>
</TooltipTrigger>
<TooltipContent side="bottom">
@@ -822,17 +835,19 @@ export default function DashboardPage() {
</DropdownMenu>
</div>
- {/* Refresh Button - Both Desktop & Mobile */}
- <Button
- variant="outline"
- size="icon"
- onClick={() => refreshNow(true)}
- disabled={isLoading}
- className="h-9 w-9">
- <RefreshCw
- className={cn("w-4 h-4", isLoading && "animate-spin")}
- />
- </Button>
+ {/* Refresh Button - show when auto refresh is off or backend is unhealthy */}
+ {(!autoRefresh || backendStatus === "unhealthy") && (
+ <Button
+ variant="outline"
+ size="icon"
+ onClick={() => refreshNow(true)}
+ disabled={isLoading}
+ className="h-9 w-9">
+ <RefreshCw
+ className={cn("w-4 h-4", isLoading && "animate-spin")}
+ />
+ </Button>
+ )}
</div>
</div>
</header>
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index c7154a7..76ea37a 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -308,4 +308,3 @@
.chain-flow-graph .react-flow__node {
transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
-
diff --git a/apps/web/components/ui/tooltip.tsx b/apps/web/components/ui/tooltip.tsx
index d80a144..00b1644 100644
--- a/apps/web/components/ui/tooltip.tsx
+++ b/apps/web/components/ui/tooltip.tsx
@@ -42,13 +42,13 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
+ "bg-popover text-popover-foreground border border-border animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance shadow-md overflow-visible",
className
)}
{...props}
>
{children}
- <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
+ <TooltipPrimitive.Arrow className="fill-popover stroke-border [stroke-width:1] drop-shadow-[0_1px_2px_rgba(15,23,42,0.10)] z-50" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
)