Files
trading_bot_v3/components/StatusOverview.js
mindesbunister de45349baa Restore working dashboard and TradingView analysis
- Fixed layout conflicts by removing minimal layout.tsx in favor of complete layout.js
- Restored original AI Analysis page with full TradingView integration
- Connected enhanced screenshot API to real TradingView automation service
- Fixed screenshot gallery to handle both string and object formats
- Added image serving API route for screenshot display
- Resolved hydration mismatch issues with suppressHydrationWarning
- All navigation pages working (Analysis, Trading, Automation, Settings)
- TradingView automation successfully capturing screenshots from AI and DIY layouts
- Docker Compose v2 compatibility ensured

Working features:
- Homepage with hero section and status cards
- Navigation menu with Trading Bot branding
- Real TradingView screenshot capture
- AI-powered chart analysis
- Multi-layout support (AI + DIY module)
- Screenshot gallery with image serving
- API endpoints for balance, status, screenshots, trading
2025-07-14 14:21:19 +02:00

125 lines
4.0 KiB
JavaScript

"use client"
import React, { useEffect, useState } from 'react'
export default function StatusOverview() {
const [status, setStatus] = useState({
driftBalance: 0,
activeTrades: 0,
dailyPnL: 0,
systemStatus: 'offline'
})
const [loading, setLoading] = useState(true)
useEffect(() => {
async function fetchStatus() {
try {
setLoading(true)
// Get balance from Bitquery
let balance = 0
try {
const balanceRes = await fetch('/api/balance')
if (balanceRes.ok) {
const balanceData = await balanceRes.json()
balance = balanceData.usd || 0
}
} catch (e) {
console.warn('Could not fetch balance:', e)
}
// Get system status
let systemStatus = 'online'
try {
const statusRes = await fetch('/api/status')
if (!statusRes.ok) {
systemStatus = 'error'
}
} catch (e) {
systemStatus = 'error'
}
setStatus({
driftBalance: balance,
activeTrades: Math.floor(Math.random() * 5), // Demo active trades
dailyPnL: balance * 0.02, // 2% daily P&L for demo
systemStatus: systemStatus
})
} catch (error) {
console.error('Error fetching status:', error)
setStatus(prev => ({ ...prev, systemStatus: 'error' }))
}
setLoading(false)
}
fetchStatus()
// Refresh every 30 seconds
const interval = setInterval(fetchStatus, 30000)
return () => clearInterval(interval)
}, [])
const statusColor = {
online: 'text-green-400',
offline: 'text-yellow-400',
error: 'text-red-400'
}
const statusIcon = {
online: '🟢',
offline: '🟡',
error: '🔴'
}
return (
<div className="card card-gradient">
<div className="flex items-center justify-between mb-6">
<h2 className="text-xl font-bold text-white">System Status</h2>
<div className="flex items-center space-x-2">
<span className="text-lg">{statusIcon[status.systemStatus]}</span>
<span className={`text-sm font-medium ${statusColor[status.systemStatus]}`}>
{status.systemStatus.toUpperCase()}
</span>
</div>
</div>
{loading ? (
<div className="flex items-center justify-center py-8">
<div className="spinner"></div>
<span className="ml-2 text-gray-400">Loading status...</span>
</div>
) : (
<div className="grid grid-cols-1 sm:grid-cols-3 gap-6">
<div className="text-center">
<div className="w-16 h-16 bg-blue-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
<span className="text-blue-400 text-2xl">💎</span>
</div>
<p className="text-2xl font-bold text-blue-400">
${status.driftBalance.toFixed(2)}
</p>
<p className="text-gray-400 text-sm">Bitquery Balance</p>
</div>
<div className="text-center">
<div className="w-16 h-16 bg-purple-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
<span className="text-purple-400 text-2xl">🔄</span>
</div>
<p className="text-2xl font-bold text-purple-400">
{status.activeTrades}
</p>
<p className="text-gray-400 text-sm">Active Trades</p>
</div>
<div className="text-center">
<div className="w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
<span className="text-green-400 text-2xl">📈</span>
</div>
<p className={`text-2xl font-bold ${status.dailyPnL >= 0 ? 'text-green-400' : 'text-red-400'}`}>
{status.dailyPnL >= 0 ? '+' : ''}${status.dailyPnL.toFixed(2)}
</p>
<p className="text-gray-400 text-sm">Daily P&L</p>
</div>
</div>
)}
</div>
)
}