feat(dashboard): UI refinements - density, flat agents table, history log
- Reduce layout density ~20% (tighter padding, margins, fonts) - Flatten Agents table view with Client/Site columns (no grouping) - Add version info to sidebar footer (UI v0.2.0, API v0.1.0) - Replace Commands nav with sidebar History log - Add /history page with full command list - Add /history/:id detail view with output display - Apply Mission Control styling to all new components Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
import { ReactNode } from "react";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { commandsApi, Command } from "../api/client";
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Server,
|
||||
Terminal,
|
||||
Settings,
|
||||
LogOut,
|
||||
Menu,
|
||||
X,
|
||||
Building2,
|
||||
MapPin,
|
||||
History,
|
||||
CheckCircle,
|
||||
XCircle,
|
||||
Clock,
|
||||
Loader2,
|
||||
} from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "../hooks/useAuth";
|
||||
import { Button } from "./Button";
|
||||
|
||||
@@ -24,16 +29,37 @@ const navItems = [
|
||||
{ path: "/clients", label: "Clients", icon: Building2 },
|
||||
{ path: "/sites", label: "Sites", icon: MapPin },
|
||||
{ path: "/agents", label: "Agents", icon: Server },
|
||||
{ path: "/commands", label: "Commands", icon: Terminal },
|
||||
{ path: "/settings", label: "Settings", icon: Settings },
|
||||
];
|
||||
|
||||
const APP_VERSION = "0.2.0";
|
||||
const SERVER_VERSION = "0.1.0";
|
||||
|
||||
function CommandStatusIcon({ status }: { status: Command["status"] }) {
|
||||
const config = {
|
||||
pending: { icon: Clock, color: "text-amber-500" },
|
||||
running: { icon: Loader2, color: "text-cyan-500 animate-spin" },
|
||||
completed: { icon: CheckCircle, color: "text-emerald-500" },
|
||||
failed: { icon: XCircle, color: "text-rose-500" },
|
||||
};
|
||||
const { icon: Icon, color } = config[status];
|
||||
return <Icon className={`h-3 w-3 ${color}`} />;
|
||||
}
|
||||
|
||||
export function Layout({ children }: LayoutProps) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { user, logout } = useAuth();
|
||||
|
||||
const { data: commands = [] } = useQuery({
|
||||
queryKey: ["commands"],
|
||||
queryFn: () => commandsApi.list().then((res) => res.data),
|
||||
refetchInterval: 15000,
|
||||
});
|
||||
|
||||
const recentCommands = commands.slice(0, 4);
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
navigate("/login");
|
||||
@@ -85,7 +111,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
<div className="flex relative">
|
||||
{/* Sidebar - Mission Control Aesthetic */}
|
||||
<aside
|
||||
className={`fixed inset-y-0 left-0 z-50 w-72 transform transition-all duration-300 ease-out lg:translate-x-0 lg:static ${
|
||||
className={`fixed inset-y-0 left-0 z-50 w-60 transform transition-all duration-300 ease-out lg:translate-x-0 lg:static ${
|
||||
sidebarOpen ? "translate-x-0" : "-translate-x-full"
|
||||
}`}
|
||||
>
|
||||
@@ -95,18 +121,18 @@ export function Layout({ children }: LayoutProps) {
|
||||
<div className="absolute left-0 top-0 bottom-0 w-[2px] bg-gradient-to-b from-transparent via-cyan-500/50 to-transparent" />
|
||||
|
||||
{/* Logo section */}
|
||||
<div className="p-6 hidden lg:block">
|
||||
<div className="p-4 hidden lg:block">
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Logo icon with glow */}
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 bg-cyan-500/30 blur-lg rounded-lg" />
|
||||
<div className="relative h-10 w-10 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center shadow-lg shadow-cyan-500/20">
|
||||
<LayoutDashboard className="h-5 w-5 text-white" />
|
||||
<div className="relative h-8 w-8 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center shadow-lg shadow-cyan-500/20">
|
||||
<LayoutDashboard className="h-4 w-4 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
{/* Logo text with gradient */}
|
||||
<div>
|
||||
<h1 className="text-xl font-bold tracking-wider">
|
||||
<h1 className="text-lg font-bold tracking-wider">
|
||||
<span className="bg-gradient-to-r from-cyan-400 via-cyan-300 to-blue-400 bg-clip-text text-transparent">
|
||||
GURU
|
||||
</span>
|
||||
@@ -120,7 +146,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex-1 px-3 space-y-1 mt-4 lg:mt-2 pt-16 lg:pt-0">
|
||||
<nav className="flex-1 px-2 space-y-0.5 mt-4 lg:mt-2 pt-16 lg:pt-0">
|
||||
{navItems.map((item) => {
|
||||
const isActive = location.pathname === item.path;
|
||||
return (
|
||||
@@ -128,7 +154,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
className={`group relative flex items-center gap-3 px-4 py-3 rounded-lg text-xs font-semibold uppercase tracking-wider transition-all duration-300 ${
|
||||
className={`group relative flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-semibold uppercase tracking-wider transition-all duration-300 ${
|
||||
isActive
|
||||
? "text-cyan-400"
|
||||
: "text-slate-400 hover:text-slate-200"
|
||||
@@ -155,7 +181,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
{/* Icon with conditional glow */}
|
||||
<div className="relative z-10">
|
||||
<item.icon
|
||||
className={`h-5 w-5 transition-all duration-300 ${
|
||||
className={`h-4 w-4 transition-all duration-300 ${
|
||||
isActive
|
||||
? "text-cyan-400 drop-shadow-[0_0_8px_rgba(6,182,212,0.8)]"
|
||||
: "text-slate-500 group-hover:text-slate-300"
|
||||
@@ -176,14 +202,14 @@ export function Layout({ children }: LayoutProps) {
|
||||
</nav>
|
||||
|
||||
{/* User profile section */}
|
||||
<div className="p-4 border-t border-cyan-500/10">
|
||||
<div className="flex items-center gap-3 mb-4 p-3 rounded-lg bg-slate-800/30">
|
||||
<div className="p-3 border-t border-cyan-500/10">
|
||||
<div className="flex items-center gap-2 mb-3 p-2 rounded-lg bg-slate-800/30">
|
||||
{/* Avatar with cyan ring glow */}
|
||||
<div className="relative">
|
||||
{/* Glow ring */}
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-cyan-500 to-blue-500 rounded-full opacity-50 blur-sm" />
|
||||
{/* Avatar */}
|
||||
<div className="relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-700 to-slate-800 ring-2 ring-cyan-500/50 flex items-center justify-center text-cyan-400 text-sm font-bold shadow-lg">
|
||||
<div className="relative h-8 w-8 rounded-full bg-gradient-to-br from-slate-700 to-slate-800 ring-2 ring-cyan-500/50 flex items-center justify-center text-cyan-400 text-sm font-bold shadow-lg">
|
||||
{user?.name?.[0] || user?.email?.[0] || "U"}
|
||||
</div>
|
||||
{/* Online indicator */}
|
||||
@@ -204,19 +230,58 @@ export function Layout({ children }: LayoutProps) {
|
||||
{/* Sign out button */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-full justify-start gap-3 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-slate-400 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all duration-300 group"
|
||||
className="w-full justify-start gap-2 px-3 py-2 text-xs font-semibold uppercase tracking-wider text-slate-400 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all duration-300 group"
|
||||
onClick={handleLogout}
|
||||
>
|
||||
<LogOut className="h-4 w-4 transition-all duration-300 group-hover:text-red-400 group-hover:drop-shadow-[0_0_6px_rgba(239,68,68,0.6)]" />
|
||||
Sign Out
|
||||
</Button>
|
||||
|
||||
{/* History log */}
|
||||
<div className="mt-2 pt-2 border-t border-slate-800/50">
|
||||
<Link
|
||||
to="/history"
|
||||
className="flex items-center gap-1.5 px-1 py-1 text-[10px] font-mono text-slate-500 hover:text-cyan-400 transition-colors"
|
||||
>
|
||||
<History className="h-3 w-3" />
|
||||
<span>History</span>
|
||||
</Link>
|
||||
|
||||
<div className="mt-1 space-y-0.5">
|
||||
{recentCommands.length === 0 ? (
|
||||
<p className="text-[10px] text-slate-600 px-1">No recent activity</p>
|
||||
) : (
|
||||
recentCommands.map((cmd: Command) => (
|
||||
<Link
|
||||
key={cmd.id}
|
||||
to={`/history/${cmd.id}`}
|
||||
className="flex items-center gap-1.5 px-1 py-0.5 rounded text-[10px] hover:bg-slate-800/50 transition-colors"
|
||||
title={cmd.command_text}
|
||||
>
|
||||
<CommandStatusIcon status={cmd.status} />
|
||||
<span className="text-slate-500 hover:text-slate-400 truncate flex-1 font-mono">
|
||||
{cmd.command_text.length > 18
|
||||
? cmd.command_text.slice(0, 18) + "..."
|
||||
: cmd.command_text}
|
||||
</span>
|
||||
</Link>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Version info */}
|
||||
<div className="mt-2 pt-2 border-t border-slate-800/50 text-[10px] font-mono text-slate-600 flex justify-between px-1">
|
||||
<span>UI v{APP_VERSION}</span>
|
||||
<span>API v{SERVER_VERSION}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Main content area */}
|
||||
<main className="flex-1 min-h-screen pt-16 lg:pt-0">
|
||||
<div className="p-6 lg:p-8 transition-all duration-300">
|
||||
<div className="p-4 lg:p-6 transition-all duration-300">
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user