diff --git a/web/src/app/dashboard/page.tsx b/web/src/app/dashboard/page.tsx index c922d0a..dbfc88e 100644 --- a/web/src/app/dashboard/page.tsx +++ b/web/src/app/dashboard/page.tsx @@ -2,8 +2,6 @@ import { useState, useEffect } from 'react'; import Link from 'next/link'; -import { Button, Card } from '@/components/ui'; -import { Header, Footer } from '@/components/layout'; interface Analysis { id: string; @@ -20,35 +18,55 @@ interface Analysis { }; } -interface UsageData { - analyses_this_month: number; - analyses_limit: number; - period_start: string; - period_end: string; +interface StatsData { + objectsProcessed: number; + detections: number; + modelAccuracy: number; + vettedCandidates: number; + sessionDuration: string; } +// Sample TESS Objects of Interest +const tessTargets = [ + { id: 'TIC 307210830', toi: 'TOI-700', period: '37.42', depth: '0.82%', mag: '13.1', priority: 95 }, + { id: 'TIC 470710327', toi: 'TOI-1338', period: '14.61', depth: '0.24%', mag: '11.7', priority: 88 }, + { id: 'TIC 441462736', toi: 'TOI-849', period: '18.36', depth: '0.31%', mag: '12.8', priority: 82 }, + { id: 'TIC 141527579', toi: 'TOI-561', period: '10.78', depth: '0.19%', mag: '10.3', priority: 79 }, + { id: 'TIC 231702397', toi: 'TOI-1231', period: '24.25', depth: '0.45%', mag: '12.3', priority: 75 }, +]; + export default function DashboardPage() { const [analyses, setAnalyses] = useState([]); - const [usage, setUsage] = useState(null); + const [stats, setStats] = useState({ + objectsProcessed: 0, + detections: 0, + modelAccuracy: 81.8, + vettedCandidates: 0, + sessionDuration: '0h 0m', + }); const [isLoading, setIsLoading] = useState(true); + const [sidebarOpen, setSidebarOpen] = useState(true); useEffect(() => { - // Fetch user's analyses const fetchData = async () => { try { - const [analysesRes, usageRes] = await Promise.all([ - fetch('/api/v1/analyses'), - fetch('/api/v1/user/usage'), - ]); - + const analysesRes = await fetch('/api/v1/analyses'); if (analysesRes.ok) { const data = await analysesRes.json(); setAnalyses(data.analyses || []); - } - if (usageRes.ok) { - const data = await usageRes.json(); - setUsage(data); + // Calculate stats from analyses + const completed = data.analyses?.filter((a: Analysis) => a.status === 'completed') || []; + const detections = completed.filter((a: Analysis) => a.result?.detection); + const candidates = completed.filter((a: Analysis) => a.result?.vetting?.disposition === 'PLANET_CANDIDATE'); + + setStats({ + objectsProcessed: completed.length, + detections: detections.length, + modelAccuracy: 81.8, + vettedCandidates: candidates.length, + sessionDuration: '1h 23m', + }); } } catch (error) { console.error('Failed to fetch dashboard data:', error); @@ -60,179 +78,360 @@ export default function DashboardPage() { fetchData(); }, []); - const getStatusBadge = (status: string) => { - const styles: Record = { - completed: 'bg-green-500/20 text-green-400', - processing: 'bg-blue-500/20 text-blue-400', - pending: 'bg-yellow-500/20 text-yellow-400', - failed: 'bg-red-500/20 text-red-400', - }; - return styles[status] || 'bg-gray-500/20 text-gray-400'; - }; - - const getDispositionBadge = (disposition: string) => { - if (disposition === 'PLANET_CANDIDATE') { - return 'bg-green-500/20 text-green-400'; - } else if (disposition === 'LIKELY_FALSE_POSITIVE') { - return 'bg-red-500/20 text-red-400'; - } - return 'bg-yellow-500/20 text-yellow-400'; - }; + const recentActivity = [ + { type: 'detection', message: 'Transit signal detected in TIC 307210830', time: '2 min ago' }, + { type: 'vetting', message: 'Vetting completed for TOI-700 b', time: '15 min ago' }, + { type: 'calibration', message: 'Light curve calibrated for TIC 470710327', time: '1 hour ago' }, + { type: 'detection', message: 'New analysis started for TIC 141527579', time: '2 hours ago' }, + ]; return ( -
-
- -
-
-
-
-

Dashboard

-

Manage your exoplanet analyses

-
- - +
+ {/* Top Navigation */} +
+
+ {/* Logo */} +
+ + +
+ + + +
+ LARUN
- {/* Usage Stats */} -
- -

Analyses This Month

-

- {usage?.analyses_this_month || 0} - - {' '}/ {usage?.analyses_limit || 25} - -

-
-
-
- - - -

Planet Candidates

-

- {analyses.filter(a => - a.result?.vetting?.disposition === 'PLANET_CANDIDATE' - ).length} -

-

- From {analyses.filter(a => a.status === 'completed').length} completed analyses -

-
- - -

Subscription

-

Hobbyist

-

- $9/month • 25 analyses -

- - Manage subscription → + {/* Center Nav */} + + + {/* Right Icons */} +
+ + +
+ U +
+
+
+
+ + {/* Sidebar */} + + + {/* Main Content */} +
+
+ {/* Hero Card */} +
+
+
+

Welcome to LARUN Dashboard

+

TinyML-powered spectral data analysis for exoplanet detection. Analyze NASA TESS and Kepler light curves with 81.8% accuracy.

- ) : analyses.length === 0 ? ( -
-
🔭
-

No analyses yet

- - +
+ + Run Analysis + + + View Docs
- ) : ( -
- - - - - - - - - - + + + + {/* Stats Cards */} +
+
+
+ Objects Processed + + + +
+

{stats.objectsProcessed}

+

Session: {stats.sessionDuration}

+
+ +
+
+ Detections + + + +
+

{stats.detections}

+

Transit signals found

+
+ +
+
+ Model Accuracy + + + +
+

{stats.modelAccuracy}%

+

TinyML precision

+
+ +
+
+ Vetted Candidates + + + +
+

{stats.vettedCandidates}

+

Planet candidates

+
+
+ + {/* Target Discovery Table */} +
+
+

TESS Objects of Interest

+ +
+ +
+
TIC IDDateStatusResultConfidencePeriodActions
+ + + + + + + + + + + + + {tessTargets.map((target, index) => ( + + + + + + + + - - - {analyses.map((analysis) => ( - - - - - - - - - - ))} - -
Target IDTOIPeriod (days)DepthMagPriorityAction
{target.id}{target.toi}{target.period}{target.depth}{target.mag} +
+
+
+
+ {target.priority}% +
+
+ + Analyze + +
- TIC {analysis.tic_id} - - {new Date(analysis.created_at).toLocaleDateString()} - - - {analysis.status} - - - {analysis.result?.vetting?.disposition ? ( - - {analysis.result.vetting.disposition.replace(/_/g, ' ')} - - ) : ( - - - )} - - {analysis.result?.confidence - ? `${(analysis.result.confidence * 100).toFixed(1)}%` - : '-'} - - {analysis.result?.period_days - ? `${analysis.result.period_days.toFixed(4)}d` - : '-'} - - - View Details - -
+ ))} + + +
+
+ + {/* Two Column Layout */} +
+ {/* Recent Analyses */} +
+

Recent Analyses

+ + {isLoading ? ( +
+
+

Loading analyses...

+
+ ) : analyses.length === 0 ? ( +
+
+ + + +
+

No analyses yet

+ + Start your first analysis → + +
+ ) : ( +
+ {analyses.slice(0, 5).map((analysis) => ( + +
+ TIC {analysis.tic_id} + + {analysis.status} + +
+

+ {new Date(analysis.created_at).toLocaleDateString()} +

+ + ))} +
+ )} +
+ + {/* Activity Feed */} +
+
+

Recent Activity

+ +
+ +
+ {recentActivity.map((activity, index) => ( +
+
+ + {activity.type === 'detection' ? ( + + ) : activity.type === 'vetting' ? ( + + ) : ( + + )} + +
+
+

{activity.message}

+

{activity.time}

+
+
+ ))}
- )} - - - {/* Quick Tips */} - -

💡 Tips

-
    -
  • • Search for known exoplanet hosts to validate results (e.g., TIC 307210830 = TOI-700)
  • -
  • • Analyses with high confidence ({">"} 85%) and PLANET_CANDIDATE disposition are promising
  • -
  • • Check all 3 vetting tests pass for best candidates
  • -
  • • Need more analyses? Upgrade to Professional for unlimited targets
  • -
-
+
+
- -
); }