refactor: improve auth defaults, update UI, and docs

- Provide fallback values for auth environment variables
- Refine global CSS styles and typography
- Update application metadata descriptions
- Add toast error handling to clients page
- Formalize phase implementation guidelines in AGENTS.md
This commit is contained in:
Team Dark Devil committed 2026-11-16 21:58:18 +06:00
1 parent df14ee1a9a
commit fde2c86b1e
48 files changed
+1062 -1665

No files matched your search

+4 -8
View File
@@ -2,18 +2,14 @@ import React from 'react';
interface AdminPageHeaderProps {
title: string;
subtitle?: string;
actions?: React.ReactNode;
}
export function AdminPageHeader({ title, subtitle, actions }: AdminPageHeaderProps) {
export function AdminPageHeader({ title, actions }: AdminPageHeaderProps) {
return (
<header className="mb-4 flex flex-wrap items-center justify-between gap-3">
<div>
<h1 className="text-base font-medium tracking-tight text-[var(--text)]">{title}</h1>
{subtitle && <p className="mt-0.5 text-xs text-[var(--text-muted)]">{subtitle}</p>}
</div>
{actions && <div className="flex items-center gap-2">{actions}</div>}
<header className="mb-3 flex flex-wrap items-center justify-between gap-2">
<h1 className="text-[14px] font-medium tracking-tight text-[var(--text)]">{title}</h1>
{actions && <div className="flex items-center gap-1.5">{actions}</div>}
</header>
);
}
+9 -32
View File
@@ -6,39 +6,16 @@ interface FooterProps {
}
export const Footer: React.FC<FooterProps> = ({ isAdmin = false }) => {
if (isAdmin) return null;
return (
<footer className="shrink-0 min-h-10 bg-[var(--bg-activity)] border-t border-[var(--border)] px-4 sm:px-6 py-2 flex flex-wrap items-center justify-between gap-2 text-[11px] text-[var(--text-dim)] select-none">
{isAdmin ? (
<>
<div className="flex items-center gap-1.5 truncate min-w-0 pr-2">
<span className="font-semibold text-[var(--text-muted)] tracking-tight">DataStack</span>
<span className="text-[var(--border-strong)]">/</span>
<span className="hidden sm:inline font-mono text-[10px] truncate">
storage/data/&#123;clientId&#125;/&#123;YYYY-MM-DD&#125;.csv
</span>
</div>
<div className="flex items-center gap-2 font-mono text-[10.5px] shrink-0 ml-auto">
<span className="flex items-center gap-1">
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
<span className="text-[var(--text-muted)]">:4000</span>
</span>
<span className="text-[var(--border-strong)]">|</span>
<span className="flex items-center gap-1">
<span className="w-1.5 h-1.5 bg-[var(--accent)] inline-block" />
<span className="text-[var(--text-muted)]">:3000</span>
</span>
</div>
</>
) : (
<>
<span>DataStack · Self-hosted</span>
<nav aria-label="Footer navigation" className="flex items-center gap-5">
<Link href="#features" className="hover:text-[var(--text-muted)]">Features</Link>
<Link href="#sdk" className="hover:text-[var(--text-muted)]">SDK</Link>
<Link href="#about" className="hover:text-[var(--text-muted)]">About</Link>
</nav>
</>
)}
<footer className="shrink-0 min-h-9 bg-[var(--bg-activity)] border-t border-[var(--border)] px-4 sm:px-6 py-2 flex flex-wrap items-center justify-between gap-2 text-[11px] text-[var(--text-dim)] select-none">
<span>DataStack</span>
<nav aria-label="Footer navigation" className="flex items-center gap-5">
<Link href="#features" className="hover:text-[var(--text-muted)]">Features</Link>
<Link href="#sdk" className="hover:text-[var(--text-muted)]">SDK</Link>
<Link href="#about" className="hover:text-[var(--text-muted)]">About</Link>
</nav>
</footer>
);
};
+1 -1
View File
@@ -35,7 +35,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
<div className={cn(
'flex-1 min-w-0 w-full mx-auto',
showSidebar
? 'max-w-[1600px] px-4 py-4 sm:px-6 sm:py-6 xl:px-8 xl:py-7'
? 'max-w-[var(--console-width)] px-3.5 py-3 sm:px-5 sm:py-4'
: 'max-w-[var(--container-width)] px-6 py-0'
)}>
{children}
+41 -58
View File
@@ -1,7 +1,6 @@
'use client';
import { Button } from '@/components/ui/Button';
import { Icon } from '@/components/ui/Icon';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import React, { useEffect, useState } from 'react';
@@ -20,119 +19,103 @@ export const Navbar: React.FC<NavbarProps> = ({
useEffect(() => {
const saved = localStorage.getItem('datastack-theme') as 'dark' | 'light' | null;
const initial = saved || 'dark';
const initial = saved === 'light' ? 'light' : 'dark';
setTheme(initial);
if (initial === 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else {
document.documentElement.classList.add('dark');
document.documentElement.classList.remove('light');
}
document.documentElement.classList.toggle('light', initial === 'light');
document.documentElement.classList.toggle('dark', initial === 'dark');
}, []);
const toggleTheme = () => {
const nextTheme = theme === 'dark' ? 'light' : 'dark';
setTheme(nextTheme);
localStorage.setItem('datastack-theme', nextTheme);
if (nextTheme === 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else {
document.documentElement.classList.add('dark');
document.documentElement.classList.remove('light');
}
document.documentElement.classList.toggle('light', nextTheme === 'light');
document.documentElement.classList.toggle('dark', nextTheme === 'dark');
};
const isVcon = pathname?.startsWith('/vcon');
return (
<header className="h-14 shrink-0 bg-[var(--bg-activity)] border-b border-[var(--border)] px-4 sm:px-6 flex items-center justify-between gap-3 z-40 select-none">
<header className="h-11 shrink-0 bg-[var(--bg-activity)] border-b border-[var(--border)] px-3.5 sm:px-5 flex items-center justify-between gap-4 z-40 select-none">
{/* Left: Mobile hamburger + Brand */}
<div className="flex items-center gap-3 min-w-0">
<div className="flex items-center gap-2.5 min-w-0">
{showSidebarToggle && (
<button
<Button
type="button"
variant="icon"
size="icon"
icon="Menu"
onClick={onToggleSidebar}
className="lg:hidden w-9 h-9 shrink-0 flex items-center justify-center text-[var(--text-muted)] hover:text-[var(--text)] border border-[var(--border)] bg-[var(--bg-elevated)] cursor-pointer"
className="lg:hidden h-7 w-7 shrink-0 border border-[var(--border)] bg-[var(--bg-elevated)]"
aria-label="Toggle Navigation"
>
<Icon name="Menu" size={13} />
</button>
title="Toggle Navigation"
/>
)}
<Link href="/" className="flex items-center gap-2 min-w-0 text-[14px] font-medium">
<span className="grid h-4 w-4 shrink-0 place-items-center bg-[var(--accent)]">
<Link href="/" className="flex items-center gap-1.5 min-w-0 text-[13px] font-medium whitespace-nowrap shrink-0">
<span className="grid h-3.5 w-3.5 shrink-0 place-items-center bg-[var(--accent)]">
<span className="h-1.5 w-1.5 bg-[var(--bg)]" />
</span>
<span className="truncate text-[var(--text)]">
DataStack
</span>
{isVcon && (
<span className="hidden lg:inline text-[11px] text-[var(--text-dim)] font-mono border border-[var(--border)] px-1.5 py-1">
v2.4
</span>
)}
</Link>
</div>
{/* Middle: Links */}
<nav className="hidden sm:flex items-center gap-6 text-[13px]">
<nav className="hidden sm:flex items-center gap-5 text-[12px]">
{isVcon ? (
<>
<Link href="/" className="text-[var(--text-muted)] hover:text-[var(--text)]">
<Link href="/" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">
Overview
</Link>
<Link
href="/vcon/dashboard"
className="px-3 py-2 transition-colors border-b-2 flex items-center gap-2 border-[var(--accent)] text-[var(--text)] font-medium"
className={`px-2 py-1.5 transition-colors border-b-2 whitespace-nowrap shrink-0 ${
pathname !== '/vcon/export'
? 'border-[var(--accent)] text-[var(--text)] font-medium'
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
}`}
>
<span>Admin Console</span>
<span className="w-1.5 h-1.5 bg-[var(--success)] shrink-0" />
Console
</Link>
<Link
href="/vcon/export"
className={`px-3 py-2 transition-colors border-b-2 ${
className={`px-2 py-1.5 transition-colors border-b-2 whitespace-nowrap shrink-0 ${
pathname === '/vcon/export'
? 'border-[var(--accent)] text-[var(--text)] font-medium'
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
}`}
>
CSV Exporter
Export
</Link>
</>
) : (
<>
<Link href="#features" className="text-[var(--text-muted)] hover:text-[var(--text)]">Features</Link>
<Link href="#sdk" className="text-[var(--text-muted)] hover:text-[var(--text)]">SDK</Link>
<Link href="#about" className="text-[var(--text-muted)] hover:text-[var(--text)]">About</Link>
<Link href="#features" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">Features</Link>
<Link href="#sdk" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">SDK</Link>
<Link href="#about" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">About</Link>
</>
)}
</nav>
{/* Right: Admin runtime indicators or public feature action */}
{/* Right: Theme switcher or public CTA */}
<div className="flex items-center gap-2 shrink-0">
{isVcon && (
<div className="hidden xl:flex items-center gap-2 text-[11px] text-[var(--text-dim)] font-mono border border-[var(--border)] px-2.5 py-1.5 bg-[var(--bg-main)]">
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
<span>:4000</span>
<span className="text-[var(--border-strong)]">|</span>
<span className="w-1.5 h-1.5 bg-[var(--accent)] inline-block" />
<span>:3000</span>
</div>
)}
<button
<Button
type="button"
variant="icon"
size="icon"
icon={theme === 'dark' ? 'Sun' : 'Moon'}
onClick={toggleTheme}
aria-label="Toggle Theme"
className="w-9 h-9 flex items-center justify-center border border-[var(--border)] bg-[var(--bg-elevated)] text-[var(--text-muted)] hover:text-[var(--text)] cursor-pointer"
>
<Icon name={theme === 'dark' ? 'Sun' : 'Moon'} size={12} />
</button>
title="Toggle Theme"
className="h-7 w-7 border border-[var(--border)] bg-[var(--bg-elevated)]"
/>
{!isVcon && (
<Link href="#sdk">
<Button size="sm" variant="primary">
Read the SDK guide
<Button size="xs" variant="primary">
SDK Guide
</Button>
</Link>
)}
+61 -90
View File
@@ -26,28 +26,28 @@ export const Sidebar: React.FC<SidebarProps> = ({
group: 'Monitoring',
items: [
{ name: 'Dashboard', href: '/vcon/dashboard', icon: 'LayoutDashboard' },
{ name: 'Live Data Sync', href: '/vcon/data', icon: 'Activity', badge: 'Live' },
{ name: 'Events', href: '/vcon/data', icon: 'Activity' },
],
},
{
group: 'Data',
items: [
{ name: 'CSV Exporter', href: '/vcon/export', icon: 'Download' },
{ name: 'CSV Storage & Disk', href: '/vcon/storage', icon: 'HardDrive' },
{ name: 'Export', href: '/vcon/export', icon: 'Download' },
{ name: 'Storage', href: '/vcon/storage', icon: 'HardDrive' },
],
},
{
group: 'Administration',
items: [
{ name: 'Client SDKs', href: '/vcon/clients', icon: 'Key' },
{ name: 'Engine Settings', href: '/vcon/settings', icon: 'Sliders' },
{ name: 'Clients', href: '/vcon/clients', icon: 'Key' },
{ name: 'Settings', href: '/vcon/settings', icon: 'Sliders' },
],
},
{
group: 'Developer Tools',
group: 'Tools',
items: [
{ name: 'Python SDK Guide', href: '/vcon/sdk', icon: 'FileCode2' },
{ name: 'Live Simulator', href: '/vcon/simulator', icon: 'Play' },
{ name: 'Python SDK', href: '/vcon/sdk', icon: 'FileCode2' },
{ name: 'Simulator', href: '/vcon/simulator', icon: 'Play' },
],
},
];
@@ -83,36 +83,31 @@ export const Sidebar: React.FC<SidebarProps> = ({
{isOpen && (
<div
onClick={onClose}
className="fixed inset-x-0 top-14 bottom-0 z-40 bg-black/50 lg:hidden"
className="fixed inset-x-0 top-11 bottom-0 z-40 bg-black/50 lg:hidden"
/>
)}
{/* Sidebar Container */}
<aside
className={cn(
'fixed left-0 top-14 bottom-0 z-50 w-[264px] shrink-0 overflow-hidden bg-[var(--bg-sidebar)] border-r border-[var(--border)] flex flex-col transition-transform duration-150 ease-in-out lg:static lg:w-[264px] lg:translate-x-0',
'fixed left-0 top-11 bottom-0 z-50 w-[216px] shrink-0 overflow-hidden bg-[var(--bg-sidebar)] border-r border-[var(--border)] flex flex-col transition-transform duration-150 ease-in-out lg:static lg:w-[216px] lg:translate-x-0',
isOpen ? 'translate-x-0' : '-translate-x-full'
)}
>
{/* Top Header */}
<div className="h-[52px] px-4 flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-activity)] shrink-0">
<div className="flex items-center gap-2 min-w-0">
<span className="w-1.5 h-1.5 bg-[var(--accent)] shrink-0" />
<span className="text-[12px] font-semibold text-[var(--text)] uppercase truncate">
VCON ADMIN
</span>
</div>
{/* Mobile Close Header */}
<div className="h-9 px-3 flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-activity)] shrink-0 lg:hidden">
<span className="text-[11px] font-medium text-[var(--text-muted)]">Menu</span>
<button
onClick={onClose}
className="lg:hidden text-[var(--text-dim)] hover:text-[var(--text)] p-1 cursor-pointer"
className="text-[var(--text-dim)] hover:text-[var(--text)] p-1 cursor-pointer"
aria-label="Close menu"
>
<Icon name="X" size={13} />
<Icon name="X" size={12} />
</button>
</div>
{/* Navigation items */}
<nav aria-label="Admin navigation" className="flex-1 min-h-0 overflow-y-auto p-2.5 flex flex-col">
<nav aria-label="Admin navigation" className="flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col">
{navigation.map((section) => {
const isExpanded = openGroup === section.group;
const groupId = `nav-${section.group.toLowerCase().replaceAll(' ', '-')}`;
@@ -124,47 +119,40 @@ export const Sidebar: React.FC<SidebarProps> = ({
aria-expanded={isExpanded}
aria-controls={groupId}
onClick={() => setOpenGroup(isExpanded ? '' : section.group)}
className="w-full min-h-[42px] px-3 flex items-center justify-between gap-2 text-left text-[12px] font-medium text-[var(--text-muted)] hover:text-[var(--text)] transition-colors cursor-pointer"
className="w-full h-8 px-2.5 flex items-center justify-between gap-2 text-left text-[11px] font-medium text-[var(--text-muted)] hover:text-[var(--text)] transition-colors cursor-pointer"
>
<span className="truncate">{section.group}</span>
<Icon
name="ChevronDown"
size={12}
size={11}
className={cn('transition-transform', isExpanded && 'rotate-180')}
/>
</button>
{isExpanded && (
<div id={groupId} className="pb-1.5 flex flex-col gap-1">
{section.items.map((item) => {
const isActive = pathname === item.href;
return (
<Link
key={item.href}
href={item.href}
onClick={onClose}
className={cn(
'flex min-h-10 min-w-0 items-center justify-between gap-2 px-3 py-2 text-[13px] transition-colors border',
isActive
? 'bg-[var(--accent-soft)] text-[var(--accent-hover)] font-medium border-[var(--accent)]'
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--bg-hover)]'
)}
>
<div className="flex items-center gap-2 min-w-0">
<Icon
name={item.icon}
size={16}
className={isActive ? 'text-[var(--accent)]' : 'text-[var(--text-dim)]'}
/>
<span className="truncate">{item.name}</span>
</div>
{item.badge && (
<span className="text-[10px] px-1.5 py-0.5 bg-[var(--success-soft)] text-[var(--success)] font-mono border border-[var(--success)] shrink-0">
{item.badge}
</span>
)}
</Link>
);
})}
<div id={groupId} className="pb-1 flex flex-col gap-0.5">
{section.items.map((item) => {
const isActive = pathname === item.href;
return (
<Link
key={item.href}
href={item.href}
onClick={onClose}
className={cn(
'flex h-8 min-w-0 items-center gap-2 px-2.5 text-[12px] transition-colors border',
isActive
? 'bg-[var(--accent-soft)] text-[var(--accent-hover)] font-medium border-[var(--accent)]'
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--bg-hover)]'
)}
>
<Icon
name={item.icon}
size={13}
className={isActive ? 'text-[var(--accent)]' : 'text-[var(--text-dim)]'}
/>
<span className="truncate">{item.name}</span>
</Link>
);
})}
</div>
)}
</div>
@@ -172,43 +160,26 @@ export const Sidebar: React.FC<SidebarProps> = ({
})}
</nav>
{/* Footer info */}
<div className="p-3 border-t border-[var(--border)] bg-[var(--bg-main)] text-[11px] text-[var(--text-dim)] font-mono flex flex-col gap-1.5 shrink-0">
<div className="flex items-center justify-between">
<span>Buffer Worker</span>
<span className="text-[var(--success)] flex items-center gap-1 font-semibold">
<span className="w-1.5 h-1.5 bg-[var(--success)] inline-block" />
Active
</span>
{/* Sign out action */}
{pathname !== '/vcon/setup' && (
<div className="p-1.5 border-t border-[var(--border)] bg-[var(--bg-main)] shrink-0">
{signOutError && (
<p role="alert" className="px-2 pb-1 text-[11px] text-[var(--danger)]">{signOutError}</p>
)}
<Button
type="button"
variant="ghost"
size="xs"
icon="LogOut"
loading={isSigningOut}
disabled={isSigningOut}
onClick={signOut}
className="w-full justify-start px-2.5 text-[11.5px] h-7"
>
Sign out
</Button>
</div>
<div className="flex items-center justify-between">
<span>Storage Engine</span>
<span className="text-[var(--text-muted)]">json2csv</span>
</div>
<div className="flex items-center justify-between">
<span>Auth Handshake</span>
<span className="text-[var(--text-muted)]">JWT</span>
</div>
{pathname !== '/vcon/setup' && (
<>
{signOutError && (
<p role="alert" className="text-[var(--danger)]">{signOutError}</p>
)}
<Button
type="button"
variant="ghost"
size="sm"
icon="LogOut"
loading={isSigningOut}
disabled={isSigningOut}
onClick={signOut}
className="mt-1 w-full justify-start px-2 text-[11px]"
>
Sign out
</Button>
</>
)}
</div>
)}
</aside>
</>
);