import { createSignal, onMount, For, Show } from 'solid-js'; interface DashboardStats { total_users: number; total_courses: number; total_instances: number; active_courses: number; total_progress: number; } interface Course { id: number; title: string; category: string; difficulty: string; duration: number; thumbnail: string; created_at: string; is_active: boolean; } interface Instance { id: number; name: string; url: string; version: string; is_active: boolean; created_at: string; last_sync: string; api_key: string; } export const Dashboard = () => { const [stats, setStats] = createSignal({ total_users: 0, total_courses: 0, total_instances: 0, active_courses: 0, total_progress: 0 }); const [courses, setCourses] = createSignal([]); const [instances, setInstances] = createSignal([]); const [loading, setLoading] = createSignal(true); onMount(async () => { await Promise.all([ loadStats(), loadCourses(), loadInstances() ]); setLoading(false); }); const loadStats = async () => { try { const response = await fetch('/api/v1/dashboard/stats'); const data = await response.json(); setStats(data); } catch (error) { console.error('Error loading stats:', error); } }; const loadCourses = async () => { try { const response = await fetch('/api/v1/dashboard/courses'); const data = await response.json(); setCourses(data.courses || []); } catch (error) { console.error('Error loading courses:', error); } }; const loadInstances = async () => { try { const response = await fetch('/api/v1/instances'); const data = await response.json(); setInstances(data.instances || []); } catch (error) { console.error('Error loading instances:', error); } }; const formatDate = (dateString: string) => { if (!dateString) return 'Never'; const date = new Date(dateString); return date.toLocaleDateString() + ' ' + date.toLocaleTimeString(); }; const getDifficultyColor = (difficulty: string) => { switch (difficulty) { case 'beginner': return 'bg-green-100 text-green-800'; case 'intermediate': return 'bg-orange-100 text-orange-800'; case 'advanced': return 'bg-red-100 text-red-800'; default: return 'bg-gray-100 text-gray-800'; } }; return (
{/* Header */}
T

Trackeep Controller

{/* Stats Grid */}
👥
{stats().total_users}
Total Users
📚
{stats().active_courses}
Active Courses
🖥️
{stats().total_instances}
Connected Instances
📈
{stats().total_progress}
Learning Progress
{/* Main Content */}
{/* Recent Courses */}

Recent Courses

Manage Courses
0} fallback={
📚
No courses yet

Create your first course to get started!

}>
{(course) => (
{course.title.charAt(0).toUpperCase()}
{course.title}
{course.category} • {course.difficulty} • {course.duration}h
)}
}>
Loading courses...
{/* Active Instances */}

Active Instances

View All
0} fallback={
🖥️
No instances

Register your first instance to get started!

}>
{(instance) => (
{instance.name}
{instance.version}
)}
}>
Loading instances...
); };