|
1 | | -'use client'; |
| 1 | +import { notFound } from 'next/navigation'; |
| 2 | +import DemoDashboardClient from './DemoDashboardClient'; |
2 | 3 |
|
3 | | -import { useEffect, useState } from 'react'; |
4 | | -import { Loader2 } from 'lucide-react'; |
5 | | -import DashboardWithFilters from '@/components/dashboard/DashboardWithFilters'; |
6 | | -import { DashboardShell } from '@/components/layout/DashboardShell'; |
7 | | -import { generateTimeSeriesLogs } from '@/lib/demo'; |
8 | | -import { TraefikLog } from '@/lib/types'; |
9 | | -import { ErrorBoundary } from '@/components/ErrorBoundary'; |
10 | | -import { Badge } from '@/components/ui/badge'; |
| 4 | +export const dynamic = 'force-dynamic'; |
11 | 5 |
|
12 | 6 | export default function DemoDashboardPage() { |
13 | | - const [logs, setLogs] = useState<TraefikLog[]>([]); |
14 | | - const [loading, setLoading] = useState(true); |
15 | | - const [lastUpdate, setLastUpdate] = useState<Date>(new Date()); |
| 7 | + const showDemoPage = |
| 8 | + (process.env.NEXT_PUBLIC_SHOW_DEMO_PAGE ?? process.env.SHOW_DEMO_PAGE ?? 'true') !== 'false'; |
16 | 9 |
|
17 | | - useEffect(() => { |
18 | | - const initialLogs = generateTimeSeriesLogs(60, 10); |
19 | | - setLogs(initialLogs); |
20 | | - setLoading(false); |
21 | | - |
22 | | - const interval = setInterval(() => { |
23 | | - setLogs(prevLogs => { |
24 | | - const newLogs = generateTimeSeriesLogs(1, 10); |
25 | | - const updatedLogs = [...newLogs, ...prevLogs].slice(0, 1000); |
26 | | - setLastUpdate(new Date()); |
27 | | - return updatedLogs; |
28 | | - }); |
29 | | - }, 5000); |
30 | | - |
31 | | - return () => clearInterval(interval); |
32 | | - }, []); |
33 | | - |
34 | | - if (loading) { |
35 | | - return ( |
36 | | - <DashboardShell title="Demo Mode" showControls={false}> |
37 | | - <div className="flex items-center justify-center h-[60vh]"> |
38 | | - <div className="text-center"> |
39 | | - <Loader2 className="h-12 w-12 animate-spin text-primary mx-auto mb-4" /> |
40 | | - <p className="text-muted-foreground">Loading demo dashboard...</p> |
41 | | - </div> |
42 | | - </div> |
43 | | - </DashboardShell> |
44 | | - ); |
| 10 | + if (!showDemoPage) { |
| 11 | + // Hide demo route completely when disabled |
| 12 | + return notFound(); |
45 | 13 | } |
46 | 14 |
|
47 | | - return ( |
48 | | - <DashboardShell |
49 | | - title="Demo Mode" |
50 | | - connected={true} |
51 | | - lastUpdate={lastUpdate} |
52 | | - logsCount={logs.length} |
53 | | - showControls={true} |
54 | | - agentName="Demo Agent" |
55 | | - > |
56 | | - <div className="mb-4"> |
57 | | - <Badge variant="secondary" className="gap-2"> |
58 | | - <span className="w-2 h-2 bg-yellow-500 rounded-full animate-pulse" /> |
59 | | - Demo Mode - Using simulated data |
60 | | - </Badge> |
61 | | - </div> |
62 | | - <ErrorBoundary> |
63 | | - <DashboardWithFilters logs={logs} demoMode={true} /> |
64 | | - </ErrorBoundary> |
65 | | - </DashboardShell> |
66 | | - ); |
| 15 | + return <DemoDashboardClient />; |
67 | 16 | } |
0 commit comments