persee-tech commited on
Commit
84e44c2
·
1 Parent(s): bb45425
Files changed (1) hide show
  1. app/page.tsx +16 -25
app/page.tsx CHANGED
@@ -11,9 +11,6 @@ import { Play, Square, RotateCcw, Zap, User, Fingerprint, Shield, Target } from
11
  import { io, Socket } from "socket.io-client"
12
  import Link from "next/link"
13
 
14
- // --- CONFIGURATION CLOUD (Indispensable pour Vercel) ---
15
- const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
16
-
17
  interface MetricData { timestamp: number; value: number; engagement: number; satisfaction: number; trust: number; }
18
  interface UserInfo { firstName: string; lastName: string; clientId: string }
19
 
@@ -44,7 +41,7 @@ export default function Dashboard() {
44
  // 2. Logique Socket & Envoi d'images
45
  useEffect(() => {
46
  if (!userInfo) return;
47
- const newSocket = io(API_URL, { transports: ["websocket", "polling"] })
48
  newSocket.on("connect", () => setIsConnected(true))
49
  newSocket.on("disconnect", () => setIsConnected(false))
50
 
@@ -117,11 +114,10 @@ export default function Dashboard() {
117
  return (
118
  <div className="min-h-screen bg-slate-50 text-slate-900 flex flex-col font-sans">
119
  <header className="border-b border-slate-200 bg-white/80 backdrop-blur-md sticky top-0 z-50 shadow-sm">
120
- <div className="flex h-16 items-center px-4 md:px-6 justify-between">
121
  <div className="flex items-center gap-3 font-bold text-xl tracking-tight text-slate-900"><div className="w-3 h-3 rounded-full bg-green-500 shadow-[0_0_15px_#22c55e] animate-pulse" />STARTECH <span className="text-slate-400 font-normal">VISION</span></div>
122
  <div className="flex items-center gap-4">
123
- {/* Le badge utilisateur : caché sur mobile, visible sur PC (hidden md:flex) */}
124
- <div className="hidden md:flex items-center gap-3 px-4 py-1.5 bg-slate-100 rounded-full border border-slate-200">
125
  <div className="w-8 h-8 rounded-full bg-gradient-to-br from-green-500 to-emerald-700 flex items-center justify-center text-xs font-bold text-white">{userInfo.firstName.charAt(0)}{userInfo.lastName.charAt(0)}</div>
126
  <div className="flex flex-col"><span className="text-sm font-bold text-slate-900 leading-none">{userInfo.firstName} {userInfo.lastName}</span><span className="text-[10px] text-slate-500 leading-none mt-1">{userInfo.clientId || "ID: GUEST"}</span></div>
127
  </div>
@@ -129,12 +125,9 @@ export default function Dashboard() {
129
  </div>
130
  </div>
131
  </header>
132
- <main className="flex-1 p-4 md:p-6 lg:p-8 overflow-y-auto overflow-x-hidden flex flex-col gap-6">
133
- {/* GRILLE RESPONSIVE : 1 colonne par défaut (mobile), 12 colonnes sur grand écran (lg) */}
134
- <div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-auto lg:h-full lg:min-h-[600px]">
135
-
136
- {/* ZONE CAMERA : 7 colonnes sur PC, toute la largeur sur mobile */}
137
- <div className="lg:col-span-7 flex flex-col h-[500px] lg:h-full min-h-[400px]">
138
  <Card className="border-slate-300 bg-white shadow-xl relative overflow-hidden transition-all duration-500 flex-1 flex flex-col group">
139
  <div className="absolute top-4 left-4 w-16 h-16 border-l-4 border-t-4 border-green-500 z-20 rounded-tl-lg opacity-80" />
140
  <div className="absolute top-4 right-4 w-16 h-16 border-r-4 border-t-4 border-green-500 z-20 rounded-tr-lg opacity-80" />
@@ -154,30 +147,28 @@ export default function Dashboard() {
154
  <div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0)_50%,rgba(0,0,0,0.1)_50%),linear-gradient(90deg,rgba(255,0,0,0.06),rgba(0,255,0,0.02),rgba(0,0,255,0.06))] z-10 bg-[length:100%_4px,6px_100%] pointer-events-none" />
155
  </div>
156
  <div className="absolute inset-0 flex items-center justify-center pointer-events-none z-10 opacity-30"><Target className="w-64 h-64 text-white stroke-1" /></div>
157
- <div className="z-20 w-full px-4 md:px-8 pb-4 md:pb-8 mt-auto absolute bottom-0">
158
- <div className="flex flex-col md:flex-row justify-between items-end mb-4 md:mb-8 gap-4">
159
  <div>
160
  <div className="flex items-center gap-2 mb-2"><Badge variant="outline" className={`px-3 py-1 border-none backdrop-blur-md ${isRecording ? "bg-red-600 text-white animate-pulse" : "bg-white/20 text-white"}`}><div className={`w-2 h-2 rounded-full mr-2 ${isRecording ? "bg-white" : "bg-slate-300"}`} />{isRecording ? "ENREGISTREMENT" : "PRÊT"}</Badge></div>
161
- <div className="text-5xl md:text-7xl font-mono font-bold text-white tabular-nums tracking-tighter drop-shadow-lg">{formatTime(sessionTime)}</div>
162
  </div>
163
- <div className="text-right w-full md:w-auto">
164
- <div className="bg-white/90 backdrop-blur-xl px-4 md:px-6 py-2 md:py-4 rounded-xl border border-white shadow-2xl">
165
  <span className="block text-[10px] text-slate-500 uppercase tracking-widest mb-1 font-bold">Emotion Dominante</span>
166
- <span className="text-2xl md:text-3xl font-bold text-slate-900 flex items-center justify-end gap-3">{getEmotionDisplay(currentMetrics.emotion)}</span>
167
  </div>
168
  </div>
169
  </div>
170
- <div className="flex items-center justify-center gap-4 md:gap-8 pt-4 md:pt-6 border-t border-white/20">
171
- <Button size="icon" variant="outline" onClick={handleReset} className="h-12 w-12 md:h-14 md:w-14 rounded-full border border-white/20 bg-white/10 text-white hover:bg-white hover:text-black backdrop-blur-md transition-all"><RotateCcw className="h-5 w-5" /></Button>
172
- {!isRecording ? (<Button onClick={handleStartStop} className="bg-green-600 hover:bg-green-500 text-white px-6 md:px-10 h-12 md:h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(34,197,94,0.4)] transition-all hover:scale-105 w-full md:w-auto"><Play className="mr-2 h-5 w-5 fill-current" /> DÉMARRER</Button>) : (<Button onClick={handleStartStop} variant="destructive" className="px-6 md:px-10 h-12 md:h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(239,68,68,0.4)] transition-all hover:scale-105 w-full md:w-auto"><Square className="mr-2 h-5 w-5 fill-current" /> STOP</Button>)}
173
  </div>
174
  </div>
175
  </CardContent>
176
  </Card>
177
  </div>
178
-
179
- {/* ZONE METRIQUES : 5 colonnes sur PC, toute la largeur sur mobile */}
180
- <div className="lg:col-span-5 flex flex-col h-auto lg:h-full gap-4 pb-8 lg:pb-0">
181
  <MetricsPanel metrics={currentMetrics} />
182
  <div className="p-4 rounded-xl bg-white border border-slate-200 shadow-sm flex justify-between items-center text-xs font-mono text-slate-500 mt-auto">
183
  <div className="flex items-center gap-2"><Zap className={`w-3 h-3 ${isConnected ? "text-green-500" : "text-red-500"}`} />SERVEUR STARTECH</div>
 
11
  import { io, Socket } from "socket.io-client"
12
  import Link from "next/link"
13
 
 
 
 
14
  interface MetricData { timestamp: number; value: number; engagement: number; satisfaction: number; trust: number; }
15
  interface UserInfo { firstName: string; lastName: string; clientId: string }
16
 
 
41
  // 2. Logique Socket & Envoi d'images
42
  useEffect(() => {
43
  if (!userInfo) return;
44
+ const newSocket = io("http://localhost:8000")
45
  newSocket.on("connect", () => setIsConnected(true))
46
  newSocket.on("disconnect", () => setIsConnected(false))
47
 
 
114
  return (
115
  <div className="min-h-screen bg-slate-50 text-slate-900 flex flex-col font-sans">
116
  <header className="border-b border-slate-200 bg-white/80 backdrop-blur-md sticky top-0 z-50 shadow-sm">
117
+ <div className="flex h-16 items-center px-6 justify-between">
118
  <div className="flex items-center gap-3 font-bold text-xl tracking-tight text-slate-900"><div className="w-3 h-3 rounded-full bg-green-500 shadow-[0_0_15px_#22c55e] animate-pulse" />STARTECH <span className="text-slate-400 font-normal">VISION</span></div>
119
  <div className="flex items-center gap-4">
120
+ <div className="flex items-center gap-3 px-4 py-1.5 bg-slate-100 rounded-full border border-slate-200">
 
121
  <div className="w-8 h-8 rounded-full bg-gradient-to-br from-green-500 to-emerald-700 flex items-center justify-center text-xs font-bold text-white">{userInfo.firstName.charAt(0)}{userInfo.lastName.charAt(0)}</div>
122
  <div className="flex flex-col"><span className="text-sm font-bold text-slate-900 leading-none">{userInfo.firstName} {userInfo.lastName}</span><span className="text-[10px] text-slate-500 leading-none mt-1">{userInfo.clientId || "ID: GUEST"}</span></div>
123
  </div>
 
125
  </div>
126
  </div>
127
  </header>
128
+ <main className="flex-1 p-4 md:p-6 lg:p-8 overflow-hidden flex flex-col gap-6">
129
+ <div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-full min-h-[600px]">
130
+ <div className="lg:col-span-7 flex flex-col h-full">
 
 
 
131
  <Card className="border-slate-300 bg-white shadow-xl relative overflow-hidden transition-all duration-500 flex-1 flex flex-col group">
132
  <div className="absolute top-4 left-4 w-16 h-16 border-l-4 border-t-4 border-green-500 z-20 rounded-tl-lg opacity-80" />
133
  <div className="absolute top-4 right-4 w-16 h-16 border-r-4 border-t-4 border-green-500 z-20 rounded-tr-lg opacity-80" />
 
147
  <div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0)_50%,rgba(0,0,0,0.1)_50%),linear-gradient(90deg,rgba(255,0,0,0.06),rgba(0,255,0,0.02),rgba(0,0,255,0.06))] z-10 bg-[length:100%_4px,6px_100%] pointer-events-none" />
148
  </div>
149
  <div className="absolute inset-0 flex items-center justify-center pointer-events-none z-10 opacity-30"><Target className="w-64 h-64 text-white stroke-1" /></div>
150
+ <div className="z-20 w-full px-8 pb-8 mt-auto absolute bottom-0">
151
+ <div className="flex justify-between items-end mb-8">
152
  <div>
153
  <div className="flex items-center gap-2 mb-2"><Badge variant="outline" className={`px-3 py-1 border-none backdrop-blur-md ${isRecording ? "bg-red-600 text-white animate-pulse" : "bg-white/20 text-white"}`}><div className={`w-2 h-2 rounded-full mr-2 ${isRecording ? "bg-white" : "bg-slate-300"}`} />{isRecording ? "ENREGISTREMENT" : "PRÊT"}</Badge></div>
154
+ <div className="text-7xl font-mono font-bold text-white tabular-nums tracking-tighter drop-shadow-lg">{formatTime(sessionTime)}</div>
155
  </div>
156
+ <div className="text-right">
157
+ <div className="bg-white/90 backdrop-blur-xl px-6 py-4 rounded-xl border border-white shadow-2xl">
158
  <span className="block text-[10px] text-slate-500 uppercase tracking-widest mb-1 font-bold">Emotion Dominante</span>
159
+ <span className="text-3xl font-bold text-slate-900 flex items-center justify-end gap-3">{getEmotionDisplay(currentMetrics.emotion)}</span>
160
  </div>
161
  </div>
162
  </div>
163
+ <div className="flex items-center justify-center gap-8 pt-6 border-t border-white/20">
164
+ <Button size="icon" variant="outline" onClick={handleReset} className="h-14 w-14 rounded-full border border-white/20 bg-white/10 text-white hover:bg-white hover:text-black backdrop-blur-md transition-all"><RotateCcw className="h-5 w-5" /></Button>
165
+ {!isRecording ? (<Button onClick={handleStartStop} className="bg-green-600 hover:bg-green-500 text-white px-10 h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(34,197,94,0.4)] transition-all hover:scale-105"><Play className="mr-2 h-5 w-5 fill-current" /> DÉMARRER</Button>) : (<Button onClick={handleStartStop} variant="destructive" className="px-10 h-14 text-lg font-bold rounded-full shadow-[0_0_20px_rgba(239,68,68,0.4)] transition-all hover:scale-105"><Square className="mr-2 h-5 w-5 fill-current" /> STOP</Button>)}
166
  </div>
167
  </div>
168
  </CardContent>
169
  </Card>
170
  </div>
171
+ <div className="lg:col-span-5 flex flex-col h-full gap-4">
 
 
172
  <MetricsPanel metrics={currentMetrics} />
173
  <div className="p-4 rounded-xl bg-white border border-slate-200 shadow-sm flex justify-between items-center text-xs font-mono text-slate-500 mt-auto">
174
  <div className="flex items-center gap-2"><Zap className={`w-3 h-3 ${isConnected ? "text-green-500" : "text-red-500"}`} />SERVEUR STARTECH</div>