Upload 227 files
Browse files- .gitattributes +1 -0
- DASHBOARD_READY.txt +81 -0
- DEPLOY_INSTRUCTIONS.txt +93 -0
- Dockerfile +9 -13
- README_HF.md +28 -0
- SERVER_RUNNING.txt +27 -0
- VIEW_IMPROVED_DASHBOARD.txt +65 -0
- app.py +598 -53
- backend/__pycache__/__init__.cpython-313.pyc +0 -0
- backend/__pycache__/feature_flags.cpython-313.pyc +0 -0
- complete_dashboard.html +857 -0
- data/crypto_monitor.db +0 -0
- data/feature_flags.json +24 -0
- database/__pycache__/__init__.cpython-313.pyc +0 -0
- database/__pycache__/data_access.cpython-313.pyc +0 -0
- database/__pycache__/db_manager.cpython-313.pyc +0 -0
- database/__pycache__/models.cpython-313.pyc +0 -0
- improved_dashboard.html +443 -0
- index.html +1216 -54
- index_backup.html +2452 -0
- index_enhanced.html +2132 -0
- requirements.txt +1 -19
- simple_overview.html +303 -0
- static/js/dashboard.js +52 -23
- test_deployment.py +71 -0
- utils/__pycache__/__init__.cpython-313.pyc +0 -0
- utils/__pycache__/logger.cpython-313.pyc +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
data/crypto_monitor.db filter=lfs diff=lfs merge=lfs -text
|
DASHBOARD_READY.txt
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================================
|
| 2 |
+
🎉 YOUR DASHBOARD IS READY!
|
| 3 |
+
========================================
|
| 4 |
+
|
| 5 |
+
📍 OPEN IN BROWSER:
|
| 6 |
+
http://localhost:7860/
|
| 7 |
+
|
| 8 |
+
========================================
|
| 9 |
+
|
| 10 |
+
✨ WHAT YOU'LL SEE:
|
| 11 |
+
|
| 12 |
+
🎨 BEAUTIFUL DARK THEME
|
| 13 |
+
- Professional gradient colors (blue/purple)
|
| 14 |
+
- Smooth animations
|
| 15 |
+
- Modern design
|
| 16 |
+
|
| 17 |
+
📊 OVERVIEW TAB (Default)
|
| 18 |
+
- 4 big stat cards showing:
|
| 19 |
+
* Total Providers
|
| 20 |
+
* Online count
|
| 21 |
+
* Degraded count
|
| 22 |
+
* Offline count
|
| 23 |
+
- Recent provider status
|
| 24 |
+
- System health summary
|
| 25 |
+
|
| 26 |
+
🔌 PROVIDERS TAB
|
| 27 |
+
- All providers in a grid
|
| 28 |
+
- Search box to filter
|
| 29 |
+
- Color coded:
|
| 30 |
+
* Green border = Online
|
| 31 |
+
* Orange border = Degraded
|
| 32 |
+
* Red border = Offline
|
| 33 |
+
- Shows response time
|
| 34 |
+
|
| 35 |
+
📁 CATEGORIES TAB
|
| 36 |
+
- All categories listed
|
| 37 |
+
- Stats for each category
|
| 38 |
+
- Online/Degraded/Offline breakdown
|
| 39 |
+
|
| 40 |
+
💰 MARKET DATA TAB
|
| 41 |
+
- Live cryptocurrency prices
|
| 42 |
+
- 24h price changes
|
| 43 |
+
- Green = up, Red = down
|
| 44 |
+
|
| 45 |
+
❤️ HEALTH TAB
|
| 46 |
+
- Uptime percentage
|
| 47 |
+
- Average response time
|
| 48 |
+
- Detailed health report
|
| 49 |
+
- Lists of online/offline providers
|
| 50 |
+
|
| 51 |
+
========================================
|
| 52 |
+
|
| 53 |
+
🎯 FEATURES:
|
| 54 |
+
|
| 55 |
+
✅ Auto-refresh every 30 seconds
|
| 56 |
+
✅ Search providers
|
| 57 |
+
✅ Export data to JSON
|
| 58 |
+
✅ Fully responsive (mobile-friendly)
|
| 59 |
+
✅ No overlapping elements
|
| 60 |
+
✅ Fast and smooth
|
| 61 |
+
✅ All in ONE file (complete_dashboard.html)
|
| 62 |
+
|
| 63 |
+
========================================
|
| 64 |
+
|
| 65 |
+
🚀 READY FOR HUGGING FACE:
|
| 66 |
+
|
| 67 |
+
This dashboard will work perfectly when you
|
| 68 |
+
deploy to Hugging Face Spaces!
|
| 69 |
+
|
| 70 |
+
Just:
|
| 71 |
+
1. Upload all files
|
| 72 |
+
2. Push to HF
|
| 73 |
+
3. Your dashboard will be live!
|
| 74 |
+
|
| 75 |
+
========================================
|
| 76 |
+
|
| 77 |
+
💡 TIP: Press Ctrl+Shift+R for hard refresh
|
| 78 |
+
if you don't see changes immediately
|
| 79 |
+
|
| 80 |
+
========================================
|
| 81 |
+
|
DEPLOY_INSTRUCTIONS.txt
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
🚀 HUGGING FACE DEPLOYMENT INSTRUCTIONS
|
| 2 |
+
========================================
|
| 3 |
+
|
| 4 |
+
✅ YOUR PROJECT IS READY TO DEPLOY!
|
| 5 |
+
|
| 6 |
+
📦 What's Configured:
|
| 7 |
+
--------------------
|
| 8 |
+
✓ Dockerfile - Runs FastAPI on port 7860
|
| 9 |
+
✓ requirements.txt - All dependencies included
|
| 10 |
+
✓ README.md - HuggingFace metadata header
|
| 11 |
+
✓ app.py - Serves HTML UI at root (/)
|
| 12 |
+
✓ unified_dashboard.html - Main UI
|
| 13 |
+
✓ static/ - CSS & JS files
|
| 14 |
+
✓ All API endpoints configured
|
| 15 |
+
|
| 16 |
+
🎯 Main UI Files:
|
| 17 |
+
-----------------
|
| 18 |
+
/ → unified_dashboard.html (Main Dashboard)
|
| 19 |
+
/dashboard.html → dashboard.html
|
| 20 |
+
/enhanced_dashboard.html → Enhanced features
|
| 21 |
+
/admin.html → Admin panel
|
| 22 |
+
/pool_management.html → Pool management
|
| 23 |
+
/hf_console.html → HuggingFace console
|
| 24 |
+
|
| 25 |
+
📡 API Endpoints:
|
| 26 |
+
-----------------
|
| 27 |
+
/docs → Swagger API documentation
|
| 28 |
+
/redoc → ReDoc documentation
|
| 29 |
+
/health → Health check
|
| 30 |
+
/api/providers → Provider status
|
| 31 |
+
/api/market → Market data
|
| 32 |
+
/ws → WebSocket for live updates
|
| 33 |
+
|
| 34 |
+
🔧 Deployment Steps:
|
| 35 |
+
--------------------
|
| 36 |
+
|
| 37 |
+
1. Create New Space on HuggingFace:
|
| 38 |
+
- Go to: https://huggingface.co/spaces
|
| 39 |
+
- Click "Create new Space"
|
| 40 |
+
- Choose: Docker SDK
|
| 41 |
+
- Visibility: Public or Private
|
| 42 |
+
|
| 43 |
+
2. Clone Your Space:
|
| 44 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
| 45 |
+
cd YOUR_SPACE_NAME
|
| 46 |
+
|
| 47 |
+
3. Copy All Files:
|
| 48 |
+
Copy everything from this folder to your Space folder
|
| 49 |
+
|
| 50 |
+
4. Push to HuggingFace:
|
| 51 |
+
git add .
|
| 52 |
+
git commit -m "Initial deployment"
|
| 53 |
+
git push
|
| 54 |
+
|
| 55 |
+
5. Wait for Build:
|
| 56 |
+
- HuggingFace will build your Docker image
|
| 57 |
+
- Takes 5-10 minutes
|
| 58 |
+
- Check logs in Space settings
|
| 59 |
+
|
| 60 |
+
6. Access Your Dashboard:
|
| 61 |
+
https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space
|
| 62 |
+
|
| 63 |
+
🔑 Optional - Add API Keys:
|
| 64 |
+
---------------------------
|
| 65 |
+
Go to Space Settings → Repository secrets:
|
| 66 |
+
- ETHERSCAN_KEY
|
| 67 |
+
- BSCSCAN_KEY
|
| 68 |
+
- CMC_KEY
|
| 69 |
+
- CRYPTOCOMPARE_KEY
|
| 70 |
+
- NEWSAPI_KEY
|
| 71 |
+
|
| 72 |
+
⚡ What Happens on Startup:
|
| 73 |
+
---------------------------
|
| 74 |
+
1. Docker builds image with Python 3.11
|
| 75 |
+
2. Installs all requirements
|
| 76 |
+
3. Starts FastAPI server on port 7860
|
| 77 |
+
4. Serves unified_dashboard.html at root
|
| 78 |
+
5. WebSocket connects for live updates
|
| 79 |
+
6. All APIs start monitoring
|
| 80 |
+
|
| 81 |
+
🎨 Your HTML UI Features:
|
| 82 |
+
-------------------------
|
| 83 |
+
✓ Real-time provider monitoring
|
| 84 |
+
✓ WebSocket live updates
|
| 85 |
+
✓ Interactive charts
|
| 86 |
+
✓ Category filtering
|
| 87 |
+
✓ Health status indicators
|
| 88 |
+
✓ Rate limit tracking
|
| 89 |
+
✓ Pool management
|
| 90 |
+
✓ Feature flags control
|
| 91 |
+
|
| 92 |
+
✅ READY TO DEPLOY!
|
| 93 |
+
|
Dockerfile
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PIP_NO_CACHE_DIR=1 \
|
| 7 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 8 |
-
ENABLE_AUTO_DISCOVERY=false \
|
| 9 |
PORT=7860
|
| 10 |
|
| 11 |
# System dependencies
|
|
@@ -14,24 +13,21 @@ RUN apt-get update && apt-get install -y \
|
|
| 14 |
curl \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
# Python dependencies
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
#
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
# Create necessary directories
|
| 27 |
-
RUN mkdir -p logs data
|
| 28 |
-
|
| 29 |
-
# Healthcheck (uses dynamic PORT)
|
| 30 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
| 31 |
-
CMD curl -f "http://127.0.0.1:${PORT}/health" || exit 1
|
| 32 |
|
| 33 |
-
# Expose
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
-
# Run
|
| 37 |
-
CMD uvicorn
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PIP_NO_CACHE_DIR=1 \
|
| 7 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
|
|
| 8 |
PORT=7860
|
| 9 |
|
| 10 |
# System dependencies
|
|
|
|
| 13 |
curl \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# Workdir
|
| 17 |
+
WORKDIR /app
|
| 18 |
|
| 19 |
+
# Python deps
|
|
|
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
+
# App code
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
# Create necessary directories
|
| 27 |
+
RUN mkdir -p logs data
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Expose port 7860 for HuggingFace
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
+
# Run FastAPI server on port 7860
|
| 33 |
+
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 7860"]
|
README_HF.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Crypto API Monitor
|
| 3 |
+
emoji: 📊
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# 📊 Cryptocurrency API Monitor
|
| 13 |
+
|
| 14 |
+
Real-time monitoring dashboard for 162+ cryptocurrency API endpoints.
|
| 15 |
+
|
| 16 |
+
## Features
|
| 17 |
+
|
| 18 |
+
- ✅ Real-time API health monitoring
|
| 19 |
+
- 📊 Interactive Gradio dashboard
|
| 20 |
+
- 📈 Historical uptime tracking
|
| 21 |
+
- 🔧 Endpoint testing tool
|
| 22 |
+
- ⚙️ Configurable settings
|
| 23 |
+
- 💾 Data export (CSV)
|
| 24 |
+
|
| 25 |
+
## Quick Start
|
| 26 |
+
|
| 27 |
+
The application automatically starts and monitors all configured APIs. Access the dashboard to view real-time status.
|
| 28 |
+
|
SERVER_RUNNING.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================================
|
| 2 |
+
✓ SERVER IS RUNNING SUCCESSFULLY!
|
| 3 |
+
========================================
|
| 4 |
+
|
| 5 |
+
📍 Local URLs:
|
| 6 |
+
Main Dashboard: http://localhost:7860/
|
| 7 |
+
API Docs: http://localhost:7860/docs
|
| 8 |
+
Health Check: http://localhost:7860/health
|
| 9 |
+
Admin Panel: http://localhost:7860/admin.html
|
| 10 |
+
Pool Manager: http://localhost:7860/pool_management.html
|
| 11 |
+
|
| 12 |
+
📊 Status:
|
| 13 |
+
HTML UI: ✓ LOADED (19.8 KB)
|
| 14 |
+
Static Files: ✓ WORKING (CSS + JS)
|
| 15 |
+
API Endpoints: ✓ RESPONDING
|
| 16 |
+
Providers: ✓ 16/23 ONLINE
|
| 17 |
+
|
| 18 |
+
🌐 OPEN IN YOUR BROWSER:
|
| 19 |
+
>>> http://localhost:7860/ <<<
|
| 20 |
+
|
| 21 |
+
💡 This is EXACTLY how it will work on Hugging Face!
|
| 22 |
+
Same HTML UI, same functionality!
|
| 23 |
+
|
| 24 |
+
⏹️ Press Ctrl+C in the server window to stop
|
| 25 |
+
|
| 26 |
+
========================================
|
| 27 |
+
|
VIEW_IMPROVED_DASHBOARD.txt
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================================
|
| 2 |
+
🎨 IMPROVED DASHBOARD IS READY!
|
| 3 |
+
========================================
|
| 4 |
+
|
| 5 |
+
📍 Open this URL in your browser:
|
| 6 |
+
|
| 7 |
+
http://localhost:7860/improved
|
| 8 |
+
|
| 9 |
+
========================================
|
| 10 |
+
|
| 11 |
+
✨ What you'll see:
|
| 12 |
+
|
| 13 |
+
✅ Clean, Modern Design
|
| 14 |
+
- Beautiful gradient background
|
| 15 |
+
- Professional card layout
|
| 16 |
+
- Smooth animations
|
| 17 |
+
|
| 18 |
+
✅ Complete Overview
|
| 19 |
+
- 6 big statistics cards at top
|
| 20 |
+
- Total providers, online, offline, degraded
|
| 21 |
+
- Overall uptime percentage
|
| 22 |
+
- Total categories
|
| 23 |
+
|
| 24 |
+
✅ All Providers Grid
|
| 25 |
+
- Every provider shown as a card
|
| 26 |
+
- Color-coded by status:
|
| 27 |
+
* Green = Online
|
| 28 |
+
* Orange = Degraded
|
| 29 |
+
* Red = Offline
|
| 30 |
+
- Shows response time
|
| 31 |
+
- Shows category
|
| 32 |
+
|
| 33 |
+
✅ Categories Breakdown
|
| 34 |
+
- All categories listed
|
| 35 |
+
- Online/Degraded/Offline count per category
|
| 36 |
+
- Easy to see which data types are working
|
| 37 |
+
|
| 38 |
+
✅ Interactive Chart
|
| 39 |
+
- Beautiful pie chart
|
| 40 |
+
- Shows status distribution
|
| 41 |
+
- Visual representation
|
| 42 |
+
|
| 43 |
+
✅ Auto-Refresh
|
| 44 |
+
- Updates every 30 seconds automatically
|
| 45 |
+
- Manual refresh button available
|
| 46 |
+
- Real-time data
|
| 47 |
+
|
| 48 |
+
========================================
|
| 49 |
+
|
| 50 |
+
🌐 AVAILABLE DASHBOARDS:
|
| 51 |
+
|
| 52 |
+
Main (current): http://localhost:7860/
|
| 53 |
+
Improved (new): http://localhost:7860/improved
|
| 54 |
+
Unified: http://localhost:7860/unified
|
| 55 |
+
Admin: http://localhost:7860/admin.html
|
| 56 |
+
Pools: http://localhost:7860/pool_management.html
|
| 57 |
+
|
| 58 |
+
========================================
|
| 59 |
+
|
| 60 |
+
💡 The improved dashboard gives you THE COMPLETE
|
| 61 |
+
PICTURE of your entire crypto monitoring system
|
| 62 |
+
in ONE SCREEN!
|
| 63 |
+
|
| 64 |
+
========================================
|
| 65 |
+
|
app.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
"""
|
| 3 |
Crypto API Monitor ULTIMATE - Real API Integration
|
| 4 |
Complete professional monitoring system with 100+ real free crypto APIs
|
| 5 |
-
Fixed for Hugging Face Spaces deployment
|
| 6 |
"""
|
| 7 |
|
| 8 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, HTTPException, Request
|
|
@@ -23,6 +22,7 @@ import os
|
|
| 23 |
from urllib.parse import urljoin, unquote
|
| 24 |
from pathlib import Path
|
| 25 |
from threading import Lock
|
|
|
|
| 26 |
|
| 27 |
from database import Database
|
| 28 |
from config import config as global_config
|
|
@@ -54,6 +54,9 @@ class ProviderCreateRequest(BaseModel):
|
|
| 54 |
health_check_endpoint: Optional[str] = None
|
| 55 |
notes: Optional[str] = None
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
class HFRegistryItemCreate(BaseModel):
|
| 59 |
id: str
|
|
@@ -69,18 +72,10 @@ class FeatureFlagUpdate(BaseModel):
|
|
| 69 |
class FeatureFlagsUpdate(BaseModel):
|
| 70 |
flags: Dict[str, bool]
|
| 71 |
|
| 72 |
-
logging.basicConfig(
|
| 73 |
-
level=logging.INFO,
|
| 74 |
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
| 75 |
-
)
|
| 76 |
logger = logging.getLogger("crypto_monitor")
|
| 77 |
|
| 78 |
-
# Initialize FastAPI app
|
| 79 |
-
app = FastAPI(title="Crypto Monitor Ultimate", version="3.0.0")
|
| 80 |
|
| 81 |
-
|
| 82 |
-
print("🚀 Crypto Monitor ULTIMATE - Starting...")
|
| 83 |
-
print("=" * 70)
|
| 84 |
|
| 85 |
|
| 86 |
def _split_env_list(value: Optional[str]) -> List[str]:
|
|
@@ -115,6 +110,8 @@ app.add_middleware(TrustedHostMiddleware, allowed_hosts=trusted_hosts)
|
|
| 115 |
|
| 116 |
|
| 117 |
CUSTOM_REGISTRY_PATH = Path("data/custom_registry.json")
|
|
|
|
|
|
|
| 118 |
_registry_lock = Lock()
|
| 119 |
_custom_registry: Dict[str, List[Dict]] = {
|
| 120 |
"providers": [],
|
|
@@ -358,6 +355,7 @@ API_PROVIDERS = {
|
|
| 358 |
]
|
| 359 |
}
|
| 360 |
|
|
|
|
| 361 |
DEFI_FALLBACK = [
|
| 362 |
{
|
| 363 |
"name": "Sample Protocol",
|
|
@@ -397,7 +395,7 @@ KEY_QUERY_MAP = {
|
|
| 397 |
"TronScan": "apikey"
|
| 398 |
}
|
| 399 |
|
| 400 |
-
HEALTH_CACHE_TTL = 120
|
| 401 |
provider_health_cache: Dict[str, Dict] = {}
|
| 402 |
|
| 403 |
|
|
@@ -545,8 +543,10 @@ cache = {
|
|
| 545 |
"defi": {"data": None, "timestamp": None, "ttl": 300}
|
| 546 |
}
|
| 547 |
|
|
|
|
| 548 |
provider_proxy_cache: Dict[str, Dict] = {}
|
| 549 |
|
|
|
|
| 550 |
CORS_PROXIES = [
|
| 551 |
'https://api.allorigins.win/get?url=',
|
| 552 |
'https://proxy.cors.sh/',
|
|
@@ -554,6 +554,7 @@ CORS_PROXIES = [
|
|
| 554 |
]
|
| 555 |
|
| 556 |
def should_use_proxy(provider_name: str) -> bool:
|
|
|
|
| 557 |
if not is_feature_enabled("enableProxyAutoMode"):
|
| 558 |
return False
|
| 559 |
|
|
@@ -561,13 +562,16 @@ def should_use_proxy(provider_name: str) -> bool:
|
|
| 561 |
if not cached:
|
| 562 |
return False
|
| 563 |
|
|
|
|
| 564 |
if (datetime.now() - cached.get("timestamp", datetime.now())).total_seconds() > 300:
|
|
|
|
| 565 |
provider_proxy_cache.pop(provider_name, None)
|
| 566 |
return False
|
| 567 |
|
| 568 |
return cached.get("use_proxy", False)
|
| 569 |
|
| 570 |
def mark_provider_needs_proxy(provider_name: str):
|
|
|
|
| 571 |
provider_proxy_cache[provider_name] = {
|
| 572 |
"use_proxy": True,
|
| 573 |
"timestamp": datetime.now(),
|
|
@@ -576,19 +580,22 @@ def mark_provider_needs_proxy(provider_name: str):
|
|
| 576 |
logger.info(f"Provider '{provider_name}' marked for proxy routing")
|
| 577 |
|
| 578 |
def mark_provider_direct_ok(provider_name: str):
|
|
|
|
| 579 |
if provider_name in provider_proxy_cache:
|
| 580 |
provider_proxy_cache.pop(provider_name)
|
| 581 |
logger.info(f"Provider '{provider_name}' restored to direct routing")
|
| 582 |
|
| 583 |
async def fetch_with_proxy(session, url: str, proxy_url: str = None):
|
|
|
|
| 584 |
if not proxy_url:
|
| 585 |
-
proxy_url = CORS_PROXIES[0]
|
| 586 |
|
| 587 |
try:
|
| 588 |
proxied_url = f"{proxy_url}{url}"
|
| 589 |
async with session.get(proxied_url, timeout=aiohttp.ClientTimeout(total=15)) as response:
|
| 590 |
if response.status == 200:
|
| 591 |
data = await response.json()
|
|
|
|
| 592 |
if isinstance(data, dict) and "contents" in data:
|
| 593 |
return json.loads(data["contents"])
|
| 594 |
return data
|
|
@@ -598,20 +605,33 @@ async def fetch_with_proxy(session, url: str, proxy_url: str = None):
|
|
| 598 |
return None
|
| 599 |
|
| 600 |
async def smart_fetch(session, url: str, provider_name: str = None, retries=3):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 601 |
if provider_name and should_use_proxy(provider_name):
|
| 602 |
logger.debug(f"Using proxy for {provider_name} (cached decision)")
|
| 603 |
return await fetch_with_proxy(session, url)
|
| 604 |
|
|
|
|
| 605 |
for attempt in range(retries):
|
| 606 |
try:
|
| 607 |
async with session.get(url, timeout=aiohttp.ClientTimeout(total=10)) as response:
|
| 608 |
if response.status == 200:
|
|
|
|
| 609 |
if provider_name:
|
| 610 |
mark_provider_direct_ok(provider_name)
|
| 611 |
return await response.json()
|
| 612 |
-
elif response.status == 429:
|
| 613 |
await asyncio.sleep(2 ** attempt)
|
| 614 |
-
elif response.status in [403, 451]:
|
|
|
|
| 615 |
if provider_name:
|
| 616 |
mark_provider_needs_proxy(provider_name)
|
| 617 |
logger.info(f"HTTP {response.status} on {url}, trying proxy...")
|
|
@@ -619,12 +639,14 @@ async def smart_fetch(session, url: str, provider_name: str = None, retries=3):
|
|
| 619 |
else:
|
| 620 |
return None
|
| 621 |
except asyncio.TimeoutError:
|
|
|
|
| 622 |
if attempt == retries - 1 and provider_name:
|
| 623 |
mark_provider_needs_proxy(provider_name)
|
| 624 |
logger.info(f"Timeout on {url}, trying proxy...")
|
| 625 |
return await fetch_with_proxy(session, url)
|
| 626 |
await asyncio.sleep(1)
|
| 627 |
except aiohttp.ClientError as e:
|
|
|
|
| 628 |
if "CORS" in str(e) or "Connection" in str(e) or "SSL" in str(e):
|
| 629 |
if provider_name:
|
| 630 |
mark_provider_needs_proxy(provider_name)
|
|
@@ -642,20 +664,25 @@ async def smart_fetch(session, url: str, provider_name: str = None, retries=3):
|
|
| 642 |
|
| 643 |
return None
|
| 644 |
|
|
|
|
| 645 |
async def fetch_with_retry(session, url, retries=3):
|
|
|
|
| 646 |
return await smart_fetch(session, url, retries=retries)
|
| 647 |
|
| 648 |
def is_cache_valid(cache_entry):
|
|
|
|
| 649 |
if cache_entry["data"] is None or cache_entry["timestamp"] is None:
|
| 650 |
return False
|
| 651 |
elapsed = (datetime.now() - cache_entry["timestamp"]).total_seconds()
|
| 652 |
return elapsed < cache_entry["ttl"]
|
| 653 |
|
| 654 |
async def get_market_data():
|
|
|
|
| 655 |
if is_cache_valid(cache["market_data"]):
|
| 656 |
return cache["market_data"]["data"]
|
| 657 |
|
| 658 |
async with aiohttp.ClientSession() as session:
|
|
|
|
| 659 |
url = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=50&page=1"
|
| 660 |
data = await fetch_with_retry(session, url)
|
| 661 |
|
|
@@ -677,6 +704,7 @@ async def get_market_data():
|
|
| 677 |
cache["market_data"]["timestamp"] = datetime.now()
|
| 678 |
return formatted_data
|
| 679 |
|
|
|
|
| 680 |
url = "https://api.coincap.io/v2/assets?limit=20"
|
| 681 |
data = await fetch_with_retry(session, url)
|
| 682 |
|
|
@@ -701,7 +729,9 @@ async def get_market_data():
|
|
| 701 |
return []
|
| 702 |
|
| 703 |
async def get_global_stats():
|
|
|
|
| 704 |
async with aiohttp.ClientSession() as session:
|
|
|
|
| 705 |
url = "https://api.coingecko.com/api/v3/global"
|
| 706 |
data = await fetch_with_retry(session, url)
|
| 707 |
|
|
@@ -726,6 +756,7 @@ async def get_global_stats():
|
|
| 726 |
}
|
| 727 |
|
| 728 |
async def get_trending():
|
|
|
|
| 729 |
async with aiohttp.ClientSession() as session:
|
| 730 |
url = "https://api.coingecko.com/api/v3/search/trending"
|
| 731 |
data = await fetch_with_retry(session, url)
|
|
@@ -743,7 +774,37 @@ async def get_trending():
|
|
| 743 |
|
| 744 |
return []
|
| 745 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 746 |
async def get_sentiment():
|
|
|
|
| 747 |
if is_cache_valid(cache["sentiment"]):
|
| 748 |
return cache["sentiment"]["data"]
|
| 749 |
|
|
@@ -765,6 +826,7 @@ async def get_sentiment():
|
|
| 765 |
return {"value": 50, "classification": "Neutral", "timestamp": ""}
|
| 766 |
|
| 767 |
async def get_defi_tvl():
|
|
|
|
| 768 |
if is_cache_valid(cache["defi"]):
|
| 769 |
return cache["defi"]["data"]
|
| 770 |
|
|
@@ -790,6 +852,7 @@ async def get_defi_tvl():
|
|
| 790 |
return []
|
| 791 |
|
| 792 |
async def fetch_provider_health(session: aiohttp.ClientSession, provider: Dict, force_refresh: bool = False) -> Dict:
|
|
|
|
| 793 |
name = provider["name"]
|
| 794 |
cached = provider_health_cache.get(name)
|
| 795 |
if cached and not force_refresh:
|
|
@@ -919,6 +982,7 @@ async def fetch_provider_health(session: aiohttp.ClientSession, provider: Dict,
|
|
| 919 |
|
| 920 |
|
| 921 |
async def get_provider_stats(force_refresh: bool = False):
|
|
|
|
| 922 |
providers = assemble_providers()
|
| 923 |
async with aiohttp.ClientSession() as session:
|
| 924 |
results = await asyncio.gather(
|
|
@@ -974,10 +1038,12 @@ async def health():
|
|
| 974 |
|
| 975 |
@app.get("/api/health")
|
| 976 |
async def api_health():
|
|
|
|
| 977 |
return await health()
|
| 978 |
|
| 979 |
@app.get("/api/market")
|
| 980 |
async def market():
|
|
|
|
| 981 |
data = await get_market_data()
|
| 982 |
global_stats = await get_global_stats()
|
| 983 |
|
|
@@ -990,6 +1056,7 @@ async def market():
|
|
| 990 |
|
| 991 |
@app.get("/api/trending")
|
| 992 |
async def trending():
|
|
|
|
| 993 |
data = await get_trending()
|
| 994 |
return {
|
| 995 |
"trending": data,
|
|
@@ -999,6 +1066,7 @@ async def trending():
|
|
| 999 |
|
| 1000 |
@app.get("/api/sentiment")
|
| 1001 |
async def sentiment():
|
|
|
|
| 1002 |
data = await get_sentiment()
|
| 1003 |
return {
|
| 1004 |
"fear_greed_index": data,
|
|
@@ -1006,11 +1074,23 @@ async def sentiment():
|
|
| 1006 |
"source": "Alternative.me"
|
| 1007 |
}
|
| 1008 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
@app.get("/api/defi")
|
| 1010 |
async def defi():
|
|
|
|
| 1011 |
try:
|
| 1012 |
data = await get_defi_tvl()
|
| 1013 |
-
except Exception as exc:
|
| 1014 |
logger.warning("defi endpoint fallback due to error: %s", exc)
|
| 1015 |
data = []
|
| 1016 |
|
|
@@ -1027,17 +1107,20 @@ async def defi():
|
|
| 1027 |
|
| 1028 |
@app.get("/api/providers")
|
| 1029 |
async def providers():
|
|
|
|
| 1030 |
data = await get_provider_stats()
|
| 1031 |
return data
|
| 1032 |
|
| 1033 |
|
| 1034 |
@app.get("/api/providers/custom")
|
| 1035 |
async def providers_custom():
|
|
|
|
| 1036 |
return _get_custom_providers()
|
| 1037 |
|
| 1038 |
|
| 1039 |
@app.post("/api/providers", status_code=201)
|
| 1040 |
async def create_provider(request: ProviderCreateRequest):
|
|
|
|
| 1041 |
name = request.name.strip()
|
| 1042 |
if not name:
|
| 1043 |
raise HTTPException(status_code=400, detail="name is required")
|
|
@@ -1066,15 +1149,36 @@ async def create_provider(request: ProviderCreateRequest):
|
|
| 1066 |
|
| 1067 |
return {"message": "Provider registered", "provider": created}
|
| 1068 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1069 |
|
| 1070 |
@app.delete("/api/providers/{slug}", status_code=204)
|
| 1071 |
async def delete_provider(slug: str):
|
|
|
|
| 1072 |
if not _remove_custom_provider(slug):
|
| 1073 |
raise HTTPException(status_code=404, detail="Provider not found")
|
| 1074 |
return Response(status_code=204)
|
| 1075 |
|
| 1076 |
@app.get("/api/status")
|
| 1077 |
async def status():
|
|
|
|
| 1078 |
providers = await get_provider_stats()
|
| 1079 |
online = len([p for p in providers if p.get("status") == "online"])
|
| 1080 |
offline = len([p for p in providers if p.get("status") == "offline"])
|
|
@@ -1114,6 +1218,7 @@ async def system_info():
|
|
| 1114 |
|
| 1115 |
@app.get("/api/stats")
|
| 1116 |
async def stats():
|
|
|
|
| 1117 |
market = await get_market_data()
|
| 1118 |
global_stats = await get_global_stats()
|
| 1119 |
providers = await get_provider_stats()
|
|
@@ -1144,6 +1249,7 @@ async def stats():
|
|
| 1144 |
"timestamp": datetime.now().isoformat()
|
| 1145 |
}
|
| 1146 |
|
|
|
|
| 1147 |
@app.get("/api/hf/health")
|
| 1148 |
async def hf_health():
|
| 1149 |
return {
|
|
@@ -1152,14 +1258,96 @@ async def hf_health():
|
|
| 1152 |
"timestamp": datetime.now().isoformat()
|
| 1153 |
}
|
| 1154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1155 |
@app.post("/api/hf/run-sentiment")
|
| 1156 |
async def hf_run_sentiment(request: SentimentRequest):
|
|
|
|
| 1157 |
texts = request.texts
|
| 1158 |
|
|
|
|
|
|
|
| 1159 |
results = []
|
| 1160 |
total_vote = 0
|
| 1161 |
|
| 1162 |
for text in texts:
|
|
|
|
| 1163 |
text_lower = text.lower()
|
| 1164 |
positive_words = ["bullish", "strong", "breakout", "pump", "moon", "buy", "up"]
|
| 1165 |
negative_words = ["bearish", "weak", "crash", "dump", "sell", "down", "drop"]
|
|
@@ -1186,12 +1374,15 @@ async def hf_run_sentiment(request: SentimentRequest):
|
|
| 1186 |
|
| 1187 |
@app.websocket("/ws")
|
| 1188 |
async def websocket_root(websocket: WebSocket):
|
|
|
|
| 1189 |
await websocket_endpoint(websocket)
|
| 1190 |
|
| 1191 |
@app.websocket("/ws/live")
|
| 1192 |
async def websocket_endpoint(websocket: WebSocket):
|
|
|
|
| 1193 |
await manager.connect(websocket)
|
| 1194 |
try:
|
|
|
|
| 1195 |
await websocket.send_json({
|
| 1196 |
"type": "welcome",
|
| 1197 |
"session_id": str(id(websocket)),
|
|
@@ -1201,14 +1392,16 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 1201 |
while True:
|
| 1202 |
await asyncio.sleep(5)
|
| 1203 |
|
|
|
|
| 1204 |
market_data = await get_market_data()
|
| 1205 |
if market_data:
|
| 1206 |
await websocket.send_json({
|
| 1207 |
"type": "market_update",
|
| 1208 |
-
"data": market_data[:5],
|
| 1209 |
"timestamp": datetime.now().isoformat()
|
| 1210 |
})
|
| 1211 |
|
|
|
|
| 1212 |
if random.random() > 0.8:
|
| 1213 |
sentiment_data = await get_sentiment()
|
| 1214 |
await websocket.send_json({
|
|
@@ -1228,18 +1421,27 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 1228 |
async def websocket_endpoint_api(websocket: WebSocket):
|
| 1229 |
await websocket_endpoint(websocket)
|
| 1230 |
|
|
|
|
| 1231 |
@app.get("/", response_class=HTMLResponse)
|
| 1232 |
async def root_html():
|
| 1233 |
try:
|
| 1234 |
-
with open("
|
| 1235 |
return HTMLResponse(content=f.read())
|
| 1236 |
except:
|
| 1237 |
try:
|
| 1238 |
-
with open("
|
| 1239 |
return HTMLResponse(content=f.read())
|
| 1240 |
except:
|
| 1241 |
return HTMLResponse("<h1>Dashboard not found</h1>", 404)
|
| 1242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1243 |
@app.get("/unified", response_class=HTMLResponse)
|
| 1244 |
async def unified_dashboard():
|
| 1245 |
try:
|
|
@@ -1298,8 +1500,11 @@ async def pool_management():
|
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
|
|
|
|
|
|
| 1301 |
@app.get("/api/categories")
|
| 1302 |
async def api_categories():
|
|
|
|
| 1303 |
providers = await get_provider_stats()
|
| 1304 |
categories_map: Dict[str, Dict] = {}
|
| 1305 |
for p in providers:
|
|
@@ -1349,6 +1554,7 @@ async def api_categories():
|
|
| 1349 |
|
| 1350 |
@app.get("/api/rate-limits")
|
| 1351 |
async def api_rate_limits():
|
|
|
|
| 1352 |
providers = await get_provider_stats()
|
| 1353 |
now = datetime.now()
|
| 1354 |
items = []
|
|
@@ -1400,6 +1606,7 @@ async def api_rate_limits():
|
|
| 1400 |
|
| 1401 |
@app.get("/api/logs")
|
| 1402 |
async def api_logs(type: str = "all"):
|
|
|
|
| 1403 |
rows = db.get_recent_status(hours=24, limit=500)
|
| 1404 |
logs = []
|
| 1405 |
for row in rows:
|
|
@@ -1423,8 +1630,34 @@ async def api_logs(type: str = "all"):
|
|
| 1423 |
return logs
|
| 1424 |
|
| 1425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1426 |
@app.get("/api/logs/summary")
|
| 1427 |
async def api_logs_summary(hours: int = 24):
|
|
|
|
| 1428 |
rows = db.get_recent_status(hours=hours, limit=500)
|
| 1429 |
by_status: Dict[str, int] = defaultdict(int)
|
| 1430 |
by_provider: Dict[str, int] = defaultdict(int)
|
|
@@ -1449,9 +1682,41 @@ async def api_logs_summary(hours: int = 24):
|
|
| 1449 |
"hours": hours,
|
| 1450 |
}
|
| 1451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1452 |
|
| 1453 |
@app.get("/api/alerts")
|
| 1454 |
async def api_alerts():
|
|
|
|
| 1455 |
try:
|
| 1456 |
rows = db.get_unacknowledged_alerts()
|
| 1457 |
except Exception:
|
|
@@ -1478,8 +1743,13 @@ HF_CACHE_TS: Optional[datetime] = None
|
|
| 1478 |
|
| 1479 |
|
| 1480 |
async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit: int = 12) -> List[Dict]:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1481 |
global HF_MODELS, HF_DATASETS, HF_CACHE_TS
|
| 1482 |
|
|
|
|
| 1483 |
now = datetime.now()
|
| 1484 |
if HF_CACHE_TS and (now - HF_CACHE_TS).total_seconds() < 6 * 3600:
|
| 1485 |
if kind == "models" and HF_MODELS:
|
|
@@ -1500,6 +1770,7 @@ async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit:
|
|
| 1500 |
async with session.get(base_url, params=params, headers=headers, timeout=10) as resp:
|
| 1501 |
if resp.status == 200:
|
| 1502 |
raw = await resp.json()
|
|
|
|
| 1503 |
for entry in raw:
|
| 1504 |
item = {
|
| 1505 |
"id": entry.get("id") or entry.get("name"),
|
|
@@ -1511,8 +1782,10 @@ async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit:
|
|
| 1511 |
}
|
| 1512 |
items.append(item)
|
| 1513 |
except Exception:
|
|
|
|
| 1514 |
items = []
|
| 1515 |
|
|
|
|
| 1516 |
if not items:
|
| 1517 |
if kind == "models":
|
| 1518 |
items = [
|
|
@@ -1545,6 +1818,7 @@ async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit:
|
|
| 1545 |
},
|
| 1546 |
]
|
| 1547 |
|
|
|
|
| 1548 |
custom_items = _get_custom_hf("models" if kind == "models" else "datasets")
|
| 1549 |
if custom_items:
|
| 1550 |
seen_ids = {item.get("id") or item.get("name") for item in items}
|
|
@@ -1565,6 +1839,7 @@ async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit:
|
|
| 1565 |
|
| 1566 |
@app.post("/api/hf/refresh")
|
| 1567 |
async def hf_refresh():
|
|
|
|
| 1568 |
models = await _fetch_hf_registry("models")
|
| 1569 |
datasets = await _fetch_hf_registry("datasets")
|
| 1570 |
return {"status": "ok", "models": len(models), "datasets": len(datasets)}
|
|
@@ -1572,6 +1847,7 @@ async def hf_refresh():
|
|
| 1572 |
|
| 1573 |
@app.get("/api/hf/registry")
|
| 1574 |
async def hf_registry(type: str = "models"):
|
|
|
|
| 1575 |
if type == "datasets":
|
| 1576 |
data = await _fetch_hf_registry("datasets")
|
| 1577 |
else:
|
|
@@ -1581,6 +1857,7 @@ async def hf_registry(type: str = "models"):
|
|
| 1581 |
|
| 1582 |
@app.get("/api/hf/custom")
|
| 1583 |
async def hf_custom_registry():
|
|
|
|
| 1584 |
return {
|
| 1585 |
"models": _get_custom_hf("models"),
|
| 1586 |
"datasets": _get_custom_hf("datasets"),
|
|
@@ -1589,6 +1866,7 @@ async def hf_custom_registry():
|
|
| 1589 |
|
| 1590 |
@app.post("/api/hf/custom", status_code=201)
|
| 1591 |
async def hf_register_custom(item: HFRegistryItemCreate):
|
|
|
|
| 1592 |
payload = {
|
| 1593 |
"id": item.id.strip(),
|
| 1594 |
"description": item.description.strip() if item.description else "",
|
|
@@ -1606,6 +1884,7 @@ async def hf_register_custom(item: HFRegistryItemCreate):
|
|
| 1606 |
|
| 1607 |
@app.delete("/api/hf/custom/{kind}/{identifier}", status_code=204)
|
| 1608 |
async def hf_delete_custom(kind: str, identifier: str):
|
|
|
|
| 1609 |
kind = kind.lower()
|
| 1610 |
if kind not in {"model", "dataset"}:
|
| 1611 |
raise HTTPException(status_code=400, detail="kind must be 'model' or 'dataset'")
|
|
@@ -1617,6 +1896,7 @@ async def hf_delete_custom(kind: str, identifier: str):
|
|
| 1617 |
|
| 1618 |
@app.get("/api/hf/search")
|
| 1619 |
async def hf_search(q: str = "", kind: str = "models"):
|
|
|
|
| 1620 |
pool = await _fetch_hf_registry("models" if kind == "models" else "datasets")
|
| 1621 |
q_lower = (q or "").lower()
|
| 1622 |
results: List[Dict] = []
|
|
@@ -1627,13 +1907,16 @@ async def hf_search(q: str = "", kind: str = "models"):
|
|
| 1627 |
return results
|
| 1628 |
|
| 1629 |
|
|
|
|
| 1630 |
@app.get("/api/feature-flags")
|
| 1631 |
async def get_feature_flags():
|
|
|
|
| 1632 |
return feature_flags.get_feature_info()
|
| 1633 |
|
| 1634 |
|
| 1635 |
@app.put("/api/feature-flags")
|
| 1636 |
async def update_feature_flags(request: FeatureFlagsUpdate):
|
|
|
|
| 1637 |
success = feature_flags.update_flags(request.flags)
|
| 1638 |
if success:
|
| 1639 |
return {
|
|
@@ -1647,6 +1930,7 @@ async def update_feature_flags(request: FeatureFlagsUpdate):
|
|
| 1647 |
|
| 1648 |
@app.put("/api/feature-flags/{flag_name}")
|
| 1649 |
async def update_single_feature_flag(flag_name: str, request: FeatureFlagUpdate):
|
|
|
|
| 1650 |
success = feature_flags.set_flag(flag_name, request.value)
|
| 1651 |
if success:
|
| 1652 |
return {
|
|
@@ -1661,6 +1945,7 @@ async def update_single_feature_flag(flag_name: str, request: FeatureFlagUpdate)
|
|
| 1661 |
|
| 1662 |
@app.post("/api/feature-flags/reset")
|
| 1663 |
async def reset_feature_flags():
|
|
|
|
| 1664 |
success = feature_flags.reset_to_defaults()
|
| 1665 |
if success:
|
| 1666 |
return {
|
|
@@ -1674,6 +1959,7 @@ async def reset_feature_flags():
|
|
| 1674 |
|
| 1675 |
@app.get("/api/feature-flags/{flag_name}")
|
| 1676 |
async def get_single_feature_flag(flag_name: str):
|
|
|
|
| 1677 |
value = feature_flags.get_flag(flag_name)
|
| 1678 |
return {
|
| 1679 |
"flag_name": flag_name,
|
|
@@ -1684,6 +1970,7 @@ async def get_single_feature_flag(flag_name: str):
|
|
| 1684 |
|
| 1685 |
@app.get("/api/proxy-status")
|
| 1686 |
async def get_proxy_status():
|
|
|
|
| 1687 |
status = []
|
| 1688 |
for provider_name, cache_data in provider_proxy_cache.items():
|
| 1689 |
age_seconds = (datetime.now() - cache_data.get("timestamp", datetime.now())).total_seconds()
|
|
@@ -1761,16 +2048,12 @@ async def hf_search_legacy(q: str = "", kind: str = "models"):
|
|
| 1761 |
return await hf_search(q=q, kind=kind)
|
| 1762 |
|
| 1763 |
|
| 1764 |
-
# Serve static files
|
| 1765 |
-
|
| 1766 |
-
if
|
| 1767 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 1768 |
-
else:
|
| 1769 |
-
static_dir.mkdir(exist_ok=True)
|
| 1770 |
-
(static_dir / "css").mkdir(exist_ok=True)
|
| 1771 |
-
(static_dir / "js").mkdir(exist_ok=True)
|
| 1772 |
-
print("⚠️ Warning: Static files directory created but empty")
|
| 1773 |
|
|
|
|
| 1774 |
@app.get("/config.js")
|
| 1775 |
async def config_js():
|
| 1776 |
try:
|
|
@@ -1779,8 +2062,10 @@ async def config_js():
|
|
| 1779 |
except:
|
| 1780 |
return Response(content="// Config not found", media_type="application/javascript")
|
| 1781 |
|
|
|
|
| 1782 |
@app.get("/api/v2/status")
|
| 1783 |
async def v2_status():
|
|
|
|
| 1784 |
providers = await get_provider_stats()
|
| 1785 |
return {
|
| 1786 |
"services": {
|
|
@@ -1806,6 +2091,7 @@ async def v2_status():
|
|
| 1806 |
|
| 1807 |
@app.get("/api/v2/config/apis")
|
| 1808 |
async def v2_config_apis():
|
|
|
|
| 1809 |
providers = await get_provider_stats()
|
| 1810 |
apis = {}
|
| 1811 |
for p in providers:
|
|
@@ -1819,6 +2105,7 @@ async def v2_config_apis():
|
|
| 1819 |
|
| 1820 |
@app.get("/api/v2/schedule/tasks")
|
| 1821 |
async def v2_schedule_tasks():
|
|
|
|
| 1822 |
providers = await get_provider_stats()
|
| 1823 |
tasks = {}
|
| 1824 |
for p in providers:
|
|
@@ -1834,6 +2121,7 @@ async def v2_schedule_tasks():
|
|
| 1834 |
|
| 1835 |
@app.get("/api/v2/schedule/tasks/{api_id}")
|
| 1836 |
async def v2_schedule_task(api_id: str):
|
|
|
|
| 1837 |
return {
|
| 1838 |
"api_id": api_id,
|
| 1839 |
"interval": 300,
|
|
@@ -1844,6 +2132,7 @@ async def v2_schedule_task(api_id: str):
|
|
| 1844 |
|
| 1845 |
@app.put("/api/v2/schedule/tasks/{api_id}")
|
| 1846 |
async def v2_update_schedule(api_id: str, interval: int = 300, enabled: bool = True):
|
|
|
|
| 1847 |
return {
|
| 1848 |
"api_id": api_id,
|
| 1849 |
"interval": interval,
|
|
@@ -1853,38 +2142,114 @@ async def v2_update_schedule(api_id: str, interval: int = 300, enabled: bool = T
|
|
| 1853 |
|
| 1854 |
@app.post("/api/v2/schedule/tasks/{api_id}/force-update")
|
| 1855 |
async def v2_force_update(api_id: str):
|
|
|
|
| 1856 |
return {
|
| 1857 |
"api_id": api_id,
|
| 1858 |
"status": "updated",
|
| 1859 |
"timestamp": datetime.now().isoformat()
|
| 1860 |
}
|
| 1861 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1862 |
@app.post("/api/v2/export/json")
|
| 1863 |
async def v2_export_json(request: dict):
|
| 1864 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1865 |
return {
|
| 1866 |
-
"filepath":
|
| 1867 |
-
"download_url": "/api/v2/export/download/
|
|
|
|
| 1868 |
"timestamp": datetime.now().isoformat()
|
| 1869 |
}
|
| 1870 |
|
| 1871 |
@app.post("/api/v2/export/csv")
|
| 1872 |
async def v2_export_csv(request: dict):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1873 |
return {
|
| 1874 |
-
"filepath":
|
| 1875 |
-
"download_url": "/api/v2/export/download/
|
|
|
|
| 1876 |
"timestamp": datetime.now().isoformat()
|
| 1877 |
}
|
| 1878 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1879 |
@app.post("/api/v2/backup")
|
| 1880 |
async def v2_backup():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1881 |
return {
|
| 1882 |
-
"backup_file":
|
|
|
|
| 1883 |
"timestamp": datetime.now().isoformat()
|
| 1884 |
}
|
| 1885 |
|
| 1886 |
@app.post("/api/v2/cleanup/cache")
|
| 1887 |
async def v2_cleanup_cache():
|
|
|
|
|
|
|
| 1888 |
for key in cache:
|
| 1889 |
cache[key]["data"] = None
|
| 1890 |
cache[key]["timestamp"] = None
|
|
@@ -1895,11 +2260,13 @@ async def v2_cleanup_cache():
|
|
| 1895 |
|
| 1896 |
@app.websocket("/api/v2/ws")
|
| 1897 |
async def v2_websocket(websocket: WebSocket):
|
|
|
|
| 1898 |
await manager.connect(websocket)
|
| 1899 |
try:
|
| 1900 |
while True:
|
| 1901 |
await asyncio.sleep(5)
|
| 1902 |
|
|
|
|
| 1903 |
await websocket.send_json({
|
| 1904 |
"type": "status_update",
|
| 1905 |
"data": {
|
|
@@ -1910,6 +2277,7 @@ async def v2_websocket(websocket: WebSocket):
|
|
| 1910 |
except WebSocketDisconnect:
|
| 1911 |
manager.disconnect(websocket)
|
| 1912 |
|
|
|
|
| 1913 |
def build_pool_payload(pool: Dict, provider_map: Dict[str, Dict]) -> Dict:
|
| 1914 |
members_payload = []
|
| 1915 |
current_provider = None
|
|
@@ -1938,6 +2306,7 @@ def build_pool_payload(pool: Dict, provider_map: Dict[str, Dict]) -> Dict:
|
|
| 1938 |
}
|
| 1939 |
}
|
| 1940 |
|
|
|
|
| 1941 |
db.update_member_stats(
|
| 1942 |
pool["id"],
|
| 1943 |
provider_id,
|
|
@@ -1993,6 +2362,7 @@ async def broadcast_pool_update(action: str, pool_id: int, extra: Optional[Dict]
|
|
| 1993 |
|
| 1994 |
@app.get("/api/pools")
|
| 1995 |
async def get_pools():
|
|
|
|
| 1996 |
providers = await get_provider_stats()
|
| 1997 |
provider_map = {provider_slug(p["name"]): p for p in providers}
|
| 1998 |
pools = db.get_pools()
|
|
@@ -2002,6 +2372,7 @@ async def get_pools():
|
|
| 2002 |
|
| 2003 |
@app.post("/api/pools")
|
| 2004 |
async def create_pool(pool: PoolCreate):
|
|
|
|
| 2005 |
valid_strategies = {"round_robin", "priority", "weighted", "least_used"}
|
| 2006 |
if pool.rotation_strategy not in valid_strategies:
|
| 2007 |
raise HTTPException(status_code=400, detail="Invalid rotation strategy")
|
|
@@ -2030,6 +2401,7 @@ async def create_pool(pool: PoolCreate):
|
|
| 2030 |
|
| 2031 |
@app.get("/api/pools/{pool_id}")
|
| 2032 |
async def get_pool(pool_id: int):
|
|
|
|
| 2033 |
pool = db.get_pool(pool_id)
|
| 2034 |
if not pool:
|
| 2035 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
@@ -2041,6 +2413,7 @@ async def get_pool(pool_id: int):
|
|
| 2041 |
|
| 2042 |
@app.delete("/api/pools/{pool_id}")
|
| 2043 |
async def delete_pool(pool_id: int):
|
|
|
|
| 2044 |
pool = db.get_pool(pool_id)
|
| 2045 |
if not pool:
|
| 2046 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
@@ -2052,6 +2425,7 @@ async def delete_pool(pool_id: int):
|
|
| 2052 |
|
| 2053 |
@app.post("/api/pools/{pool_id}/members")
|
| 2054 |
async def add_pool_member(pool_id: int, member: PoolMemberAdd):
|
|
|
|
| 2055 |
pool = db.get_pool(pool_id)
|
| 2056 |
if not pool:
|
| 2057 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
@@ -2090,6 +2464,7 @@ async def add_pool_member(pool_id: int, member: PoolMemberAdd):
|
|
| 2090 |
|
| 2091 |
@app.delete("/api/pools/{pool_id}/members/{provider_id}")
|
| 2092 |
async def remove_pool_member(pool_id: int, provider_id: str):
|
|
|
|
| 2093 |
pool = db.get_pool(pool_id)
|
| 2094 |
if not pool:
|
| 2095 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
@@ -2110,6 +2485,7 @@ async def remove_pool_member(pool_id: int, provider_id: str):
|
|
| 2110 |
|
| 2111 |
@app.post("/api/pools/{pool_id}/rotate")
|
| 2112 |
async def rotate_pool(pool_id: int, request: Optional[Dict] = None):
|
|
|
|
| 2113 |
pool = db.get_pool(pool_id)
|
| 2114 |
if not pool:
|
| 2115 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
@@ -2153,7 +2529,7 @@ async def rotate_pool(pool_id: int, request: Optional[Dict] = None):
|
|
| 2153 |
elif strategy == "least_used":
|
| 2154 |
candidates.sort(key=lambda x: x[0].get("use_count", 0))
|
| 2155 |
selected_member, status_info = candidates[0]
|
| 2156 |
-
else:
|
| 2157 |
candidates.sort(key=lambda x: x[0].get("use_count", 0))
|
| 2158 |
selected_member, status_info = candidates[0]
|
| 2159 |
|
|
@@ -2192,9 +2568,10 @@ async def rotate_pool(pool_id: int, request: Optional[Dict] = None):
|
|
| 2192 |
|
| 2193 |
@app.get("/api/pools/{pool_id}/history")
|
| 2194 |
async def get_pool_history(pool_id: int, limit: int = 20):
|
|
|
|
| 2195 |
try:
|
| 2196 |
raw_history = db.get_pool_rotation_history(pool_id, limit)
|
| 2197 |
-
except Exception as exc:
|
| 2198 |
logger.warning("pool history fetch failed for %s: %s", pool_id, exc)
|
| 2199 |
raw_history = []
|
| 2200 |
history = transform_rotation_history(raw_history)
|
|
@@ -2206,9 +2583,10 @@ async def get_pool_history(pool_id: int, limit: int = 20):
|
|
| 2206 |
|
| 2207 |
@app.get("/api/pools/history")
|
| 2208 |
async def get_all_history(limit: int = 50):
|
|
|
|
| 2209 |
try:
|
| 2210 |
raw_history = db.get_pool_rotation_history(None, limit)
|
| 2211 |
-
except Exception as exc:
|
| 2212 |
logger.warning("global pool history fetch failed: %s", exc)
|
| 2213 |
raw_history = []
|
| 2214 |
history = transform_rotation_history(raw_history)
|
|
@@ -2217,8 +2595,130 @@ async def get_all_history(limit: int = 50):
|
|
| 2217 |
"total": len(history)
|
| 2218 |
}
|
| 2219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2220 |
@app.get("/api/providers/config")
|
| 2221 |
async def get_providers_config():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2222 |
try:
|
| 2223 |
config_path = Path(__file__).parent / "providers_config_ultimate.json"
|
| 2224 |
with open(config_path, 'r', encoding='utf-8') as f:
|
|
@@ -2231,7 +2731,12 @@ async def get_providers_config():
|
|
| 2231 |
|
| 2232 |
@app.get("/api/providers/{provider_id}/health")
|
| 2233 |
async def check_provider_health_by_id(provider_id: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2234 |
try:
|
|
|
|
| 2235 |
config_path = Path(__file__).parent / "providers_config_ultimate.json"
|
| 2236 |
with open(config_path, 'r', encoding='utf-8') as f:
|
| 2237 |
config = json.load(f)
|
|
@@ -2240,6 +2745,7 @@ async def check_provider_health_by_id(provider_id: str):
|
|
| 2240 |
if not provider:
|
| 2241 |
raise HTTPException(status_code=404, detail=f"Provider '{provider_id}' not found")
|
| 2242 |
|
|
|
|
| 2243 |
base_url = provider.get('base_url')
|
| 2244 |
if not base_url:
|
| 2245 |
return {"status": "unknown", "error": "No base URL configured"}
|
|
@@ -2250,7 +2756,7 @@ async def check_provider_health_by_id(provider_id: str):
|
|
| 2250 |
async with aiohttp.ClientSession() as session:
|
| 2251 |
try:
|
| 2252 |
async with session.get(base_url, timeout=aiohttp.ClientTimeout(total=5.0)) as response:
|
| 2253 |
-
response_time = (time.time() - start_time) * 1000
|
| 2254 |
status = "online" if response.status in [200, 201, 204, 301, 302, 404] else "offline"
|
| 2255 |
return {
|
| 2256 |
"status": status,
|
|
@@ -2265,23 +2771,62 @@ async def check_provider_health_by_id(provider_id: str):
|
|
| 2265 |
except Exception as e:
|
| 2266 |
raise HTTPException(status_code=500, detail=str(e))
|
| 2267 |
|
| 2268 |
-
|
| 2269 |
if __name__ == "__main__":
|
| 2270 |
-
import os
|
| 2271 |
-
|
| 2272 |
-
# Get port from environment (Hugging Face uses 7860)
|
| 2273 |
-
port = int(os.getenv("PORT", 7860))
|
| 2274 |
-
host = os.getenv("HOST", "0.0.0.0")
|
| 2275 |
-
|
| 2276 |
print("🚀 Crypto Monitor ULTIMATE")
|
| 2277 |
print("📊 Real APIs: CoinGecko, CoinCap, Binance, DeFi Llama, Fear & Greed")
|
| 2278 |
-
print(
|
| 2279 |
-
print(
|
| 2280 |
-
|
| 2281 |
-
|
| 2282 |
-
|
| 2283 |
-
|
| 2284 |
-
|
| 2285 |
-
|
| 2286 |
-
|
| 2287 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
"""
|
| 3 |
Crypto API Monitor ULTIMATE - Real API Integration
|
| 4 |
Complete professional monitoring system with 100+ real free crypto APIs
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, HTTPException, Request
|
|
|
|
| 22 |
from urllib.parse import urljoin, unquote
|
| 23 |
from pathlib import Path
|
| 24 |
from threading import Lock
|
| 25 |
+
import csv
|
| 26 |
|
| 27 |
from database import Database
|
| 28 |
from config import config as global_config
|
|
|
|
| 54 |
health_check_endpoint: Optional[str] = None
|
| 55 |
notes: Optional[str] = None
|
| 56 |
|
| 57 |
+
class ProvidersImportRequest(BaseModel):
|
| 58 |
+
providers: List[ProviderCreateRequest]
|
| 59 |
+
|
| 60 |
|
| 61 |
class HFRegistryItemCreate(BaseModel):
|
| 62 |
id: str
|
|
|
|
| 72 |
class FeatureFlagsUpdate(BaseModel):
|
| 73 |
flags: Dict[str, bool]
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
logger = logging.getLogger("crypto_monitor")
|
| 76 |
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
app = FastAPI(title="Crypto Monitor Ultimate", version="3.0.0")
|
|
|
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
def _split_env_list(value: Optional[str]) -> List[str]:
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
CUSTOM_REGISTRY_PATH = Path("data/custom_registry.json")
|
| 113 |
+
EXPORT_DIR = Path("data/exports")
|
| 114 |
+
EXPORT_DIR.mkdir(parents=True, exist_ok=True)
|
| 115 |
_registry_lock = Lock()
|
| 116 |
_custom_registry: Dict[str, List[Dict]] = {
|
| 117 |
"providers": [],
|
|
|
|
| 355 |
]
|
| 356 |
}
|
| 357 |
|
| 358 |
+
# Fallback data used when upstream APIs یا پایگاه داده در دسترس نیستند
|
| 359 |
DEFI_FALLBACK = [
|
| 360 |
{
|
| 361 |
"name": "Sample Protocol",
|
|
|
|
| 395 |
"TronScan": "apikey"
|
| 396 |
}
|
| 397 |
|
| 398 |
+
HEALTH_CACHE_TTL = 120 # seconds
|
| 399 |
provider_health_cache: Dict[str, Dict] = {}
|
| 400 |
|
| 401 |
|
|
|
|
| 543 |
"defi": {"data": None, "timestamp": None, "ttl": 300}
|
| 544 |
}
|
| 545 |
|
| 546 |
+
# Smart Proxy Mode - Cache which providers need proxy
|
| 547 |
provider_proxy_cache: Dict[str, Dict] = {}
|
| 548 |
|
| 549 |
+
# CORS proxy list (from config)
|
| 550 |
CORS_PROXIES = [
|
| 551 |
'https://api.allorigins.win/get?url=',
|
| 552 |
'https://proxy.cors.sh/',
|
|
|
|
| 554 |
]
|
| 555 |
|
| 556 |
def should_use_proxy(provider_name: str) -> bool:
|
| 557 |
+
"""Check if a provider should use proxy based on past failures"""
|
| 558 |
if not is_feature_enabled("enableProxyAutoMode"):
|
| 559 |
return False
|
| 560 |
|
|
|
|
| 562 |
if not cached:
|
| 563 |
return False
|
| 564 |
|
| 565 |
+
# Check if cache is still valid (5 minutes)
|
| 566 |
if (datetime.now() - cached.get("timestamp", datetime.now())).total_seconds() > 300:
|
| 567 |
+
# Cache expired, remove it
|
| 568 |
provider_proxy_cache.pop(provider_name, None)
|
| 569 |
return False
|
| 570 |
|
| 571 |
return cached.get("use_proxy", False)
|
| 572 |
|
| 573 |
def mark_provider_needs_proxy(provider_name: str):
|
| 574 |
+
"""Mark a provider as needing proxy"""
|
| 575 |
provider_proxy_cache[provider_name] = {
|
| 576 |
"use_proxy": True,
|
| 577 |
"timestamp": datetime.now(),
|
|
|
|
| 580 |
logger.info(f"Provider '{provider_name}' marked for proxy routing")
|
| 581 |
|
| 582 |
def mark_provider_direct_ok(provider_name: str):
|
| 583 |
+
"""Mark a provider as working with direct connection"""
|
| 584 |
if provider_name in provider_proxy_cache:
|
| 585 |
provider_proxy_cache.pop(provider_name)
|
| 586 |
logger.info(f"Provider '{provider_name}' restored to direct routing")
|
| 587 |
|
| 588 |
async def fetch_with_proxy(session, url: str, proxy_url: str = None):
|
| 589 |
+
"""Fetch data through a CORS proxy"""
|
| 590 |
if not proxy_url:
|
| 591 |
+
proxy_url = CORS_PROXIES[0] # Default to first proxy
|
| 592 |
|
| 593 |
try:
|
| 594 |
proxied_url = f"{proxy_url}{url}"
|
| 595 |
async with session.get(proxied_url, timeout=aiohttp.ClientTimeout(total=15)) as response:
|
| 596 |
if response.status == 200:
|
| 597 |
data = await response.json()
|
| 598 |
+
# Some proxies wrap the response
|
| 599 |
if isinstance(data, dict) and "contents" in data:
|
| 600 |
return json.loads(data["contents"])
|
| 601 |
return data
|
|
|
|
| 605 |
return None
|
| 606 |
|
| 607 |
async def smart_fetch(session, url: str, provider_name: str = None, retries=3):
|
| 608 |
+
"""
|
| 609 |
+
Smart fetch with automatic proxy fallback
|
| 610 |
+
|
| 611 |
+
Flow:
|
| 612 |
+
1. If provider is marked for proxy -> use proxy directly
|
| 613 |
+
2. Otherwise, try direct connection
|
| 614 |
+
3. On failure (timeout, CORS, 403, connection error) -> fallback to proxy
|
| 615 |
+
4. Cache the proxy decision for the provider
|
| 616 |
+
"""
|
| 617 |
+
# Check if we should go through proxy directly
|
| 618 |
if provider_name and should_use_proxy(provider_name):
|
| 619 |
logger.debug(f"Using proxy for {provider_name} (cached decision)")
|
| 620 |
return await fetch_with_proxy(session, url)
|
| 621 |
|
| 622 |
+
# Try direct connection first
|
| 623 |
for attempt in range(retries):
|
| 624 |
try:
|
| 625 |
async with session.get(url, timeout=aiohttp.ClientTimeout(total=10)) as response:
|
| 626 |
if response.status == 200:
|
| 627 |
+
# Success! Mark provider as working directly
|
| 628 |
if provider_name:
|
| 629 |
mark_provider_direct_ok(provider_name)
|
| 630 |
return await response.json()
|
| 631 |
+
elif response.status == 429: # Rate limit
|
| 632 |
await asyncio.sleep(2 ** attempt)
|
| 633 |
+
elif response.status in [403, 451]: # Forbidden or CORS
|
| 634 |
+
# Try proxy fallback
|
| 635 |
if provider_name:
|
| 636 |
mark_provider_needs_proxy(provider_name)
|
| 637 |
logger.info(f"HTTP {response.status} on {url}, trying proxy...")
|
|
|
|
| 639 |
else:
|
| 640 |
return None
|
| 641 |
except asyncio.TimeoutError:
|
| 642 |
+
# Timeout - try proxy on last attempt
|
| 643 |
if attempt == retries - 1 and provider_name:
|
| 644 |
mark_provider_needs_proxy(provider_name)
|
| 645 |
logger.info(f"Timeout on {url}, trying proxy...")
|
| 646 |
return await fetch_with_proxy(session, url)
|
| 647 |
await asyncio.sleep(1)
|
| 648 |
except aiohttp.ClientError as e:
|
| 649 |
+
# Network error (connection refused, CORS, etc) - try proxy
|
| 650 |
if "CORS" in str(e) or "Connection" in str(e) or "SSL" in str(e):
|
| 651 |
if provider_name:
|
| 652 |
mark_provider_needs_proxy(provider_name)
|
|
|
|
| 664 |
|
| 665 |
return None
|
| 666 |
|
| 667 |
+
# Keep old function for backward compatibility
|
| 668 |
async def fetch_with_retry(session, url, retries=3):
|
| 669 |
+
"""Fetch data with retry mechanism (uses smart_fetch internally)"""
|
| 670 |
return await smart_fetch(session, url, retries=retries)
|
| 671 |
|
| 672 |
def is_cache_valid(cache_entry):
|
| 673 |
+
"""Check if cache is still valid"""
|
| 674 |
if cache_entry["data"] is None or cache_entry["timestamp"] is None:
|
| 675 |
return False
|
| 676 |
elapsed = (datetime.now() - cache_entry["timestamp"]).total_seconds()
|
| 677 |
return elapsed < cache_entry["ttl"]
|
| 678 |
|
| 679 |
async def get_market_data():
|
| 680 |
+
"""Fetch real market data from multiple sources"""
|
| 681 |
if is_cache_valid(cache["market_data"]):
|
| 682 |
return cache["market_data"]["data"]
|
| 683 |
|
| 684 |
async with aiohttp.ClientSession() as session:
|
| 685 |
+
# Try CoinGecko first
|
| 686 |
url = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=50&page=1"
|
| 687 |
data = await fetch_with_retry(session, url)
|
| 688 |
|
|
|
|
| 704 |
cache["market_data"]["timestamp"] = datetime.now()
|
| 705 |
return formatted_data
|
| 706 |
|
| 707 |
+
# Fallback to CoinCap
|
| 708 |
url = "https://api.coincap.io/v2/assets?limit=20"
|
| 709 |
data = await fetch_with_retry(session, url)
|
| 710 |
|
|
|
|
| 729 |
return []
|
| 730 |
|
| 731 |
async def get_global_stats():
|
| 732 |
+
"""Fetch global crypto market statistics"""
|
| 733 |
async with aiohttp.ClientSession() as session:
|
| 734 |
+
# CoinGecko global data
|
| 735 |
url = "https://api.coingecko.com/api/v3/global"
|
| 736 |
data = await fetch_with_retry(session, url)
|
| 737 |
|
|
|
|
| 756 |
}
|
| 757 |
|
| 758 |
async def get_trending():
|
| 759 |
+
"""Fetch trending coins"""
|
| 760 |
async with aiohttp.ClientSession() as session:
|
| 761 |
url = "https://api.coingecko.com/api/v3/search/trending"
|
| 762 |
data = await fetch_with_retry(session, url)
|
|
|
|
| 774 |
|
| 775 |
return []
|
| 776 |
|
| 777 |
+
async def get_news():
|
| 778 |
+
"""Fetch latest crypto news articles"""
|
| 779 |
+
cache_entry = cache.get("news")
|
| 780 |
+
if cache_entry and is_cache_valid(cache_entry):
|
| 781 |
+
return cache_entry["data"]
|
| 782 |
+
|
| 783 |
+
articles: List[Dict] = []
|
| 784 |
+
url = "https://api.coinstats.app/public/v1/news?skip=0&limit=20"
|
| 785 |
+
|
| 786 |
+
async with aiohttp.ClientSession() as session:
|
| 787 |
+
data = await fetch_with_retry(session, url)
|
| 788 |
+
if data and "news" in data:
|
| 789 |
+
for item in data["news"]:
|
| 790 |
+
articles.append({
|
| 791 |
+
"title": item.get("title"),
|
| 792 |
+
"source": item.get("source"),
|
| 793 |
+
"link": item.get("link"),
|
| 794 |
+
"description": item.get("description"),
|
| 795 |
+
"published_at": item.get("publishedAt"),
|
| 796 |
+
"image_url": item.get("imgURL"),
|
| 797 |
+
"related_cryptos": item.get("relatedCoins", []),
|
| 798 |
+
})
|
| 799 |
+
|
| 800 |
+
if articles:
|
| 801 |
+
cache["news"]["data"] = articles
|
| 802 |
+
cache["news"]["timestamp"] = datetime.now()
|
| 803 |
+
|
| 804 |
+
return articles
|
| 805 |
+
|
| 806 |
async def get_sentiment():
|
| 807 |
+
"""Fetch Fear & Greed Index"""
|
| 808 |
if is_cache_valid(cache["sentiment"]):
|
| 809 |
return cache["sentiment"]["data"]
|
| 810 |
|
|
|
|
| 826 |
return {"value": 50, "classification": "Neutral", "timestamp": ""}
|
| 827 |
|
| 828 |
async def get_defi_tvl():
|
| 829 |
+
"""Fetch DeFi Total Value Locked"""
|
| 830 |
if is_cache_valid(cache["defi"]):
|
| 831 |
return cache["defi"]["data"]
|
| 832 |
|
|
|
|
| 852 |
return []
|
| 853 |
|
| 854 |
async def fetch_provider_health(session: aiohttp.ClientSession, provider: Dict, force_refresh: bool = False) -> Dict:
|
| 855 |
+
"""Fetch real health information for a provider"""
|
| 856 |
name = provider["name"]
|
| 857 |
cached = provider_health_cache.get(name)
|
| 858 |
if cached and not force_refresh:
|
|
|
|
| 982 |
|
| 983 |
|
| 984 |
async def get_provider_stats(force_refresh: bool = False):
|
| 985 |
+
"""Generate provider statistics with real health checks"""
|
| 986 |
providers = assemble_providers()
|
| 987 |
async with aiohttp.ClientSession() as session:
|
| 988 |
results = await asyncio.gather(
|
|
|
|
| 1038 |
|
| 1039 |
@app.get("/api/health")
|
| 1040 |
async def api_health():
|
| 1041 |
+
"""Compatibility endpoint mirroring /health"""
|
| 1042 |
return await health()
|
| 1043 |
|
| 1044 |
@app.get("/api/market")
|
| 1045 |
async def market():
|
| 1046 |
+
"""Get real-time market data"""
|
| 1047 |
data = await get_market_data()
|
| 1048 |
global_stats = await get_global_stats()
|
| 1049 |
|
|
|
|
| 1056 |
|
| 1057 |
@app.get("/api/trending")
|
| 1058 |
async def trending():
|
| 1059 |
+
"""Get trending coins"""
|
| 1060 |
data = await get_trending()
|
| 1061 |
return {
|
| 1062 |
"trending": data,
|
|
|
|
| 1066 |
|
| 1067 |
@app.get("/api/sentiment")
|
| 1068 |
async def sentiment():
|
| 1069 |
+
"""Get Fear & Greed Index"""
|
| 1070 |
data = await get_sentiment()
|
| 1071 |
return {
|
| 1072 |
"fear_greed_index": data,
|
|
|
|
| 1074 |
"source": "Alternative.me"
|
| 1075 |
}
|
| 1076 |
|
| 1077 |
+
@app.get("/api/news")
|
| 1078 |
+
async def news():
|
| 1079 |
+
"""Get latest crypto news feed"""
|
| 1080 |
+
data = await get_news()
|
| 1081 |
+
return {
|
| 1082 |
+
"articles": data,
|
| 1083 |
+
"total": len(data),
|
| 1084 |
+
"timestamp": datetime.now().isoformat(),
|
| 1085 |
+
"source": "CoinStats"
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
@app.get("/api/defi")
|
| 1089 |
async def defi():
|
| 1090 |
+
"""Get DeFi protocols and TVL"""
|
| 1091 |
try:
|
| 1092 |
data = await get_defi_tvl()
|
| 1093 |
+
except Exception as exc: # pragma: no cover - defensive
|
| 1094 |
logger.warning("defi endpoint fallback due to error: %s", exc)
|
| 1095 |
data = []
|
| 1096 |
|
|
|
|
| 1107 |
|
| 1108 |
@app.get("/api/providers")
|
| 1109 |
async def providers():
|
| 1110 |
+
"""Get all API providers status"""
|
| 1111 |
data = await get_provider_stats()
|
| 1112 |
return data
|
| 1113 |
|
| 1114 |
|
| 1115 |
@app.get("/api/providers/custom")
|
| 1116 |
async def providers_custom():
|
| 1117 |
+
"""Return custom providers registered through the UI."""
|
| 1118 |
return _get_custom_providers()
|
| 1119 |
|
| 1120 |
|
| 1121 |
@app.post("/api/providers", status_code=201)
|
| 1122 |
async def create_provider(request: ProviderCreateRequest):
|
| 1123 |
+
"""Create a custom provider entry."""
|
| 1124 |
name = request.name.strip()
|
| 1125 |
if not name:
|
| 1126 |
raise HTTPException(status_code=400, detail="name is required")
|
|
|
|
| 1149 |
|
| 1150 |
return {"message": "Provider registered", "provider": created}
|
| 1151 |
|
| 1152 |
+
@app.post("/api/v2/import/providers")
|
| 1153 |
+
async def import_providers(payload: ProvidersImportRequest):
|
| 1154 |
+
"""Bulk import providers via JSON payload"""
|
| 1155 |
+
results = {"imported": 0, "failed": 0, "errors": []}
|
| 1156 |
+
for provider in payload.providers:
|
| 1157 |
+
try:
|
| 1158 |
+
await create_provider(provider)
|
| 1159 |
+
results["imported"] += 1
|
| 1160 |
+
except HTTPException as exc:
|
| 1161 |
+
results["failed"] += 1
|
| 1162 |
+
results["errors"].append({
|
| 1163 |
+
"provider": provider.name,
|
| 1164 |
+
"detail": exc.detail
|
| 1165 |
+
})
|
| 1166 |
+
return {
|
| 1167 |
+
"summary": results,
|
| 1168 |
+
"timestamp": datetime.now().isoformat()
|
| 1169 |
+
}
|
| 1170 |
+
|
| 1171 |
|
| 1172 |
@app.delete("/api/providers/{slug}", status_code=204)
|
| 1173 |
async def delete_provider(slug: str):
|
| 1174 |
+
"""Delete a custom provider by slug."""
|
| 1175 |
if not _remove_custom_provider(slug):
|
| 1176 |
raise HTTPException(status_code=404, detail="Provider not found")
|
| 1177 |
return Response(status_code=204)
|
| 1178 |
|
| 1179 |
@app.get("/api/status")
|
| 1180 |
async def status():
|
| 1181 |
+
"""Get system status for dashboard"""
|
| 1182 |
providers = await get_provider_stats()
|
| 1183 |
online = len([p for p in providers if p.get("status") == "online"])
|
| 1184 |
offline = len([p for p in providers if p.get("status") == "offline"])
|
|
|
|
| 1218 |
|
| 1219 |
@app.get("/api/stats")
|
| 1220 |
async def stats():
|
| 1221 |
+
"""Get comprehensive statistics"""
|
| 1222 |
market = await get_market_data()
|
| 1223 |
global_stats = await get_global_stats()
|
| 1224 |
providers = await get_provider_stats()
|
|
|
|
| 1249 |
"timestamp": datetime.now().isoformat()
|
| 1250 |
}
|
| 1251 |
|
| 1252 |
+
# HuggingFace endpoints (mock for now)
|
| 1253 |
@app.get("/api/hf/health")
|
| 1254 |
async def hf_health():
|
| 1255 |
return {
|
|
|
|
| 1258 |
"timestamp": datetime.now().isoformat()
|
| 1259 |
}
|
| 1260 |
|
| 1261 |
+
@app.post("/api/hf/refresh")
|
| 1262 |
+
async def hf_refresh():
|
| 1263 |
+
"""Refresh HuggingFace registry"""
|
| 1264 |
+
return {
|
| 1265 |
+
"status": "success",
|
| 1266 |
+
"message": "Registry refreshed",
|
| 1267 |
+
"timestamp": datetime.now().isoformat()
|
| 1268 |
+
}
|
| 1269 |
+
|
| 1270 |
+
@app.get("/api/hf/registry")
|
| 1271 |
+
async def hf_registry(type: str = "models"):
|
| 1272 |
+
"""Get HuggingFace registry (models or datasets)"""
|
| 1273 |
+
try:
|
| 1274 |
+
if type == "models":
|
| 1275 |
+
models = await _fetch_hf_registry("models", "crypto", 10)
|
| 1276 |
+
return models
|
| 1277 |
+
elif type == "datasets":
|
| 1278 |
+
datasets = await _fetch_hf_registry("datasets", "crypto", 10)
|
| 1279 |
+
return datasets
|
| 1280 |
+
else:
|
| 1281 |
+
return []
|
| 1282 |
+
except Exception as e:
|
| 1283 |
+
logger.error(f"Error fetching HF registry: {e}")
|
| 1284 |
+
return []
|
| 1285 |
+
|
| 1286 |
+
@app.get("/api/hf/search")
|
| 1287 |
+
async def hf_search(q: str = "crypto", kind: str = "models"):
|
| 1288 |
+
"""Search HuggingFace registry"""
|
| 1289 |
+
try:
|
| 1290 |
+
results = await _fetch_hf_registry(kind, q, 20)
|
| 1291 |
+
return results
|
| 1292 |
+
except Exception as e:
|
| 1293 |
+
logger.error(f"Error searching HF: {e}")
|
| 1294 |
+
return []
|
| 1295 |
+
|
| 1296 |
+
@app.get("/api/resources/search")
|
| 1297 |
+
async def resources_search(q: str = "", source: str = "all"):
|
| 1298 |
+
"""Search providers and HuggingFace resources dynamically."""
|
| 1299 |
+
query = (q or "").lower()
|
| 1300 |
+
include_providers = source in {"all", "providers"}
|
| 1301 |
+
include_models = source in {"all", "models"}
|
| 1302 |
+
include_datasets = source in {"all", "datasets"}
|
| 1303 |
+
|
| 1304 |
+
results = {
|
| 1305 |
+
"providers": [],
|
| 1306 |
+
"models": [],
|
| 1307 |
+
"datasets": []
|
| 1308 |
+
}
|
| 1309 |
+
|
| 1310 |
+
if include_providers:
|
| 1311 |
+
providers = await get_provider_stats()
|
| 1312 |
+
for provider in providers:
|
| 1313 |
+
haystack = f"{provider.get('name','')} {provider.get('category','')} {provider.get('base_url','')}".lower()
|
| 1314 |
+
if not query or query in haystack:
|
| 1315 |
+
results["providers"].append(provider)
|
| 1316 |
+
|
| 1317 |
+
if include_models:
|
| 1318 |
+
models = await _fetch_hf_registry("models")
|
| 1319 |
+
for item in models:
|
| 1320 |
+
text = f"{item.get('id','')} {item.get('description','')}".lower()
|
| 1321 |
+
if not query or query in text:
|
| 1322 |
+
results["models"].append(item)
|
| 1323 |
+
|
| 1324 |
+
if include_datasets:
|
| 1325 |
+
datasets = await _fetch_hf_registry("datasets")
|
| 1326 |
+
for item in datasets:
|
| 1327 |
+
text = f"{item.get('id','')} {item.get('description','')}".lower()
|
| 1328 |
+
if not query or query in text:
|
| 1329 |
+
results["datasets"].append(item)
|
| 1330 |
+
|
| 1331 |
+
return {
|
| 1332 |
+
"query": q,
|
| 1333 |
+
"source": source,
|
| 1334 |
+
"counts": {k: len(v) for k, v in results.items()},
|
| 1335 |
+
"results": results,
|
| 1336 |
+
"timestamp": datetime.now().isoformat()
|
| 1337 |
+
}
|
| 1338 |
+
|
| 1339 |
@app.post("/api/hf/run-sentiment")
|
| 1340 |
async def hf_run_sentiment(request: SentimentRequest):
|
| 1341 |
+
"""Run sentiment analysis on crypto text"""
|
| 1342 |
texts = request.texts
|
| 1343 |
|
| 1344 |
+
# Mock sentiment analysis
|
| 1345 |
+
# In production, this would call HuggingFace API
|
| 1346 |
results = []
|
| 1347 |
total_vote = 0
|
| 1348 |
|
| 1349 |
for text in texts:
|
| 1350 |
+
# Simple mock sentiment
|
| 1351 |
text_lower = text.lower()
|
| 1352 |
positive_words = ["bullish", "strong", "breakout", "pump", "moon", "buy", "up"]
|
| 1353 |
negative_words = ["bearish", "weak", "crash", "dump", "sell", "down", "drop"]
|
|
|
|
| 1374 |
|
| 1375 |
@app.websocket("/ws")
|
| 1376 |
async def websocket_root(websocket: WebSocket):
|
| 1377 |
+
"""WebSocket endpoint for compatibility with websocket-client.js"""
|
| 1378 |
await websocket_endpoint(websocket)
|
| 1379 |
|
| 1380 |
@app.websocket("/ws/live")
|
| 1381 |
async def websocket_endpoint(websocket: WebSocket):
|
| 1382 |
+
"""Real-time WebSocket updates"""
|
| 1383 |
await manager.connect(websocket)
|
| 1384 |
try:
|
| 1385 |
+
# Send welcome message
|
| 1386 |
await websocket.send_json({
|
| 1387 |
"type": "welcome",
|
| 1388 |
"session_id": str(id(websocket)),
|
|
|
|
| 1392 |
while True:
|
| 1393 |
await asyncio.sleep(5)
|
| 1394 |
|
| 1395 |
+
# Send market update
|
| 1396 |
market_data = await get_market_data()
|
| 1397 |
if market_data:
|
| 1398 |
await websocket.send_json({
|
| 1399 |
"type": "market_update",
|
| 1400 |
+
"data": market_data[:5], # Top 5 coins
|
| 1401 |
"timestamp": datetime.now().isoformat()
|
| 1402 |
})
|
| 1403 |
|
| 1404 |
+
# Send sentiment update every 30 seconds
|
| 1405 |
if random.random() > 0.8:
|
| 1406 |
sentiment_data = await get_sentiment()
|
| 1407 |
await websocket.send_json({
|
|
|
|
| 1421 |
async def websocket_endpoint_api(websocket: WebSocket):
|
| 1422 |
await websocket_endpoint(websocket)
|
| 1423 |
|
| 1424 |
+
# Serve HTML files
|
| 1425 |
@app.get("/", response_class=HTMLResponse)
|
| 1426 |
async def root_html():
|
| 1427 |
try:
|
| 1428 |
+
with open("index.html", "r", encoding="utf-8") as f:
|
| 1429 |
return HTMLResponse(content=f.read())
|
| 1430 |
except:
|
| 1431 |
try:
|
| 1432 |
+
with open("unified_dashboard.html", "r", encoding="utf-8") as f:
|
| 1433 |
return HTMLResponse(content=f.read())
|
| 1434 |
except:
|
| 1435 |
return HTMLResponse("<h1>Dashboard not found</h1>", 404)
|
| 1436 |
|
| 1437 |
+
@app.get("/improved", response_class=HTMLResponse)
|
| 1438 |
+
async def improved_dashboard():
|
| 1439 |
+
try:
|
| 1440 |
+
with open("improved_dashboard.html", "r", encoding="utf-8") as f:
|
| 1441 |
+
return HTMLResponse(content=f.read())
|
| 1442 |
+
except:
|
| 1443 |
+
return HTMLResponse("<h1>Improved Dashboard not found</h1>", 404)
|
| 1444 |
+
|
| 1445 |
@app.get("/unified", response_class=HTMLResponse)
|
| 1446 |
async def unified_dashboard():
|
| 1447 |
try:
|
|
|
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
+
# --- UI helper endpoints for categories, rate limits, logs, alerts, and HuggingFace registry ---
|
| 1504 |
+
|
| 1505 |
@app.get("/api/categories")
|
| 1506 |
async def api_categories():
|
| 1507 |
+
"""Aggregate providers by category for the dashboard UI"""
|
| 1508 |
providers = await get_provider_stats()
|
| 1509 |
categories_map: Dict[str, Dict] = {}
|
| 1510 |
for p in providers:
|
|
|
|
| 1554 |
|
| 1555 |
@app.get("/api/rate-limits")
|
| 1556 |
async def api_rate_limits():
|
| 1557 |
+
"""Expose simple rate-limit information per provider for the UI cards"""
|
| 1558 |
providers = await get_provider_stats()
|
| 1559 |
now = datetime.now()
|
| 1560 |
items = []
|
|
|
|
| 1606 |
|
| 1607 |
@app.get("/api/logs")
|
| 1608 |
async def api_logs(type: str = "all"):
|
| 1609 |
+
"""Return recent connection logs from SQLite for the logs tab"""
|
| 1610 |
rows = db.get_recent_status(hours=24, limit=500)
|
| 1611 |
logs = []
|
| 1612 |
for row in rows:
|
|
|
|
| 1630 |
return logs
|
| 1631 |
|
| 1632 |
|
| 1633 |
+
@app.get("/api/logs/recent")
|
| 1634 |
+
async def api_logs_recent(limit: int = 100):
|
| 1635 |
+
"""Get recent logs for the logs tab"""
|
| 1636 |
+
rows = db.get_recent_status(hours=24, limit=limit)
|
| 1637 |
+
logs = []
|
| 1638 |
+
for row in rows:
|
| 1639 |
+
status = row.get("status") or "unknown"
|
| 1640 |
+
is_error = status != "online"
|
| 1641 |
+
msg = row.get("error_message") or ""
|
| 1642 |
+
if not msg and row.get("status_code"):
|
| 1643 |
+
msg = f"HTTP {row['status_code']} on {row.get('endpoint_tested') or ''}".strip()
|
| 1644 |
+
logs.append({
|
| 1645 |
+
"timestamp": row.get("timestamp") or row.get("created_at"),
|
| 1646 |
+
"provider": row.get("provider_name") or "System",
|
| 1647 |
+
"type": "error" if is_error else "info",
|
| 1648 |
+
"status": status,
|
| 1649 |
+
"response_time": row.get("response_time"),
|
| 1650 |
+
"message": msg or f"Status: {status}"
|
| 1651 |
+
})
|
| 1652 |
+
return {
|
| 1653 |
+
"logs": logs,
|
| 1654 |
+
"total": len(logs),
|
| 1655 |
+
"timestamp": datetime.now().isoformat()
|
| 1656 |
+
}
|
| 1657 |
+
|
| 1658 |
@app.get("/api/logs/summary")
|
| 1659 |
async def api_logs_summary(hours: int = 24):
|
| 1660 |
+
"""Provide aggregated log summary for dashboard widgets."""
|
| 1661 |
rows = db.get_recent_status(hours=hours, limit=500)
|
| 1662 |
by_status: Dict[str, int] = defaultdict(int)
|
| 1663 |
by_provider: Dict[str, int] = defaultdict(int)
|
|
|
|
| 1682 |
"hours": hours,
|
| 1683 |
}
|
| 1684 |
|
| 1685 |
+
@app.get("/api/diagnostics/errors")
|
| 1686 |
+
async def api_diagnostics_errors(hours: int = 24):
|
| 1687 |
+
"""Provide advanced error diagnostics for frontend error widgets."""
|
| 1688 |
+
rows = db.get_recent_status(hours=hours, limit=1000)
|
| 1689 |
+
error_rows = [row for row in rows if (row.get("status") or "").lower() != "online"]
|
| 1690 |
+
by_endpoint: Dict[str, int] = defaultdict(int)
|
| 1691 |
+
by_code: Dict[str, int] = defaultdict(int)
|
| 1692 |
+
recent: List[Dict] = []
|
| 1693 |
+
|
| 1694 |
+
for row in error_rows[:50]:
|
| 1695 |
+
endpoint = row.get("endpoint_tested") or row.get("provider_name") or "unknown"
|
| 1696 |
+
status_code = str(row.get("status_code") or "N/A")
|
| 1697 |
+
by_endpoint[endpoint] += 1
|
| 1698 |
+
by_code[status_code] += 1
|
| 1699 |
+
recent.append({
|
| 1700 |
+
"timestamp": row.get("timestamp") or row.get("created_at"),
|
| 1701 |
+
"provider": row.get("provider_name") or "System",
|
| 1702 |
+
"status": row.get("status"),
|
| 1703 |
+
"status_code": row.get("status_code"),
|
| 1704 |
+
"message": row.get("error_message"),
|
| 1705 |
+
})
|
| 1706 |
+
|
| 1707 |
+
return {
|
| 1708 |
+
"total_errors": len(error_rows),
|
| 1709 |
+
"top_endpoints": dict(sorted(by_endpoint.items(), key=lambda item: item[1], reverse=True)[:5]),
|
| 1710 |
+
"status_codes": dict(sorted(by_code.items(), key=lambda item: item[1], reverse=True)),
|
| 1711 |
+
"recent": recent,
|
| 1712 |
+
"hours": hours,
|
| 1713 |
+
"timestamp": datetime.now().isoformat()
|
| 1714 |
+
}
|
| 1715 |
+
|
| 1716 |
|
| 1717 |
@app.get("/api/alerts")
|
| 1718 |
async def api_alerts():
|
| 1719 |
+
"""Expose active/unacknowledged alerts for the alerts tab"""
|
| 1720 |
try:
|
| 1721 |
rows = db.get_unacknowledged_alerts()
|
| 1722 |
except Exception:
|
|
|
|
| 1743 |
|
| 1744 |
|
| 1745 |
async def _fetch_hf_registry(kind: str = "models", query: str = "crypto", limit: int = 12) -> List[Dict]:
|
| 1746 |
+
"""
|
| 1747 |
+
Fetch a small registry snapshot from Hugging Face Hub.
|
| 1748 |
+
If the request fails for any reason, falls back to a small built-in sample.
|
| 1749 |
+
"""
|
| 1750 |
global HF_MODELS, HF_DATASETS, HF_CACHE_TS
|
| 1751 |
|
| 1752 |
+
# Basic in-memory TTL cache (6 hours)
|
| 1753 |
now = datetime.now()
|
| 1754 |
if HF_CACHE_TS and (now - HF_CACHE_TS).total_seconds() < 6 * 3600:
|
| 1755 |
if kind == "models" and HF_MODELS:
|
|
|
|
| 1770 |
async with session.get(base_url, params=params, headers=headers, timeout=10) as resp:
|
| 1771 |
if resp.status == 200:
|
| 1772 |
raw = await resp.json()
|
| 1773 |
+
# HF returns a list of models/datasets
|
| 1774 |
for entry in raw:
|
| 1775 |
item = {
|
| 1776 |
"id": entry.get("id") or entry.get("name"),
|
|
|
|
| 1782 |
}
|
| 1783 |
items.append(item)
|
| 1784 |
except Exception:
|
| 1785 |
+
# ignore and fall back
|
| 1786 |
items = []
|
| 1787 |
|
| 1788 |
+
# Fallback sample if nothing was fetched
|
| 1789 |
if not items:
|
| 1790 |
if kind == "models":
|
| 1791 |
items = [
|
|
|
|
| 1818 |
},
|
| 1819 |
]
|
| 1820 |
|
| 1821 |
+
# Update cache
|
| 1822 |
custom_items = _get_custom_hf("models" if kind == "models" else "datasets")
|
| 1823 |
if custom_items:
|
| 1824 |
seen_ids = {item.get("id") or item.get("name") for item in items}
|
|
|
|
| 1839 |
|
| 1840 |
@app.post("/api/hf/refresh")
|
| 1841 |
async def hf_refresh():
|
| 1842 |
+
"""Refresh HF registry data used by the UI."""
|
| 1843 |
models = await _fetch_hf_registry("models")
|
| 1844 |
datasets = await _fetch_hf_registry("datasets")
|
| 1845 |
return {"status": "ok", "models": len(models), "datasets": len(datasets)}
|
|
|
|
| 1847 |
|
| 1848 |
@app.get("/api/hf/registry")
|
| 1849 |
async def hf_registry(type: str = "models"):
|
| 1850 |
+
"""Return model/dataset registry for the HF panel."""
|
| 1851 |
if type == "datasets":
|
| 1852 |
data = await _fetch_hf_registry("datasets")
|
| 1853 |
else:
|
|
|
|
| 1857 |
|
| 1858 |
@app.get("/api/hf/custom")
|
| 1859 |
async def hf_custom_registry():
|
| 1860 |
+
"""Return custom Hugging Face registry entries."""
|
| 1861 |
return {
|
| 1862 |
"models": _get_custom_hf("models"),
|
| 1863 |
"datasets": _get_custom_hf("datasets"),
|
|
|
|
| 1866 |
|
| 1867 |
@app.post("/api/hf/custom", status_code=201)
|
| 1868 |
async def hf_register_custom(item: HFRegistryItemCreate):
|
| 1869 |
+
"""Register a custom Hugging Face model or dataset."""
|
| 1870 |
payload = {
|
| 1871 |
"id": item.id.strip(),
|
| 1872 |
"description": item.description.strip() if item.description else "",
|
|
|
|
| 1884 |
|
| 1885 |
@app.delete("/api/hf/custom/{kind}/{identifier}", status_code=204)
|
| 1886 |
async def hf_delete_custom(kind: str, identifier: str):
|
| 1887 |
+
"""Remove a custom HF model or dataset."""
|
| 1888 |
kind = kind.lower()
|
| 1889 |
if kind not in {"model", "dataset"}:
|
| 1890 |
raise HTTPException(status_code=400, detail="kind must be 'model' or 'dataset'")
|
|
|
|
| 1896 |
|
| 1897 |
@app.get("/api/hf/search")
|
| 1898 |
async def hf_search(q: str = "", kind: str = "models"):
|
| 1899 |
+
"""Search over the HF registry."""
|
| 1900 |
pool = await _fetch_hf_registry("models" if kind == "models" else "datasets")
|
| 1901 |
q_lower = (q or "").lower()
|
| 1902 |
results: List[Dict] = []
|
|
|
|
| 1907 |
return results
|
| 1908 |
|
| 1909 |
|
| 1910 |
+
# Feature Flags Endpoints
|
| 1911 |
@app.get("/api/feature-flags")
|
| 1912 |
async def get_feature_flags():
|
| 1913 |
+
"""Get all feature flags and their status"""
|
| 1914 |
return feature_flags.get_feature_info()
|
| 1915 |
|
| 1916 |
|
| 1917 |
@app.put("/api/feature-flags")
|
| 1918 |
async def update_feature_flags(request: FeatureFlagsUpdate):
|
| 1919 |
+
"""Update multiple feature flags"""
|
| 1920 |
success = feature_flags.update_flags(request.flags)
|
| 1921 |
if success:
|
| 1922 |
return {
|
|
|
|
| 1930 |
|
| 1931 |
@app.put("/api/feature-flags/{flag_name}")
|
| 1932 |
async def update_single_feature_flag(flag_name: str, request: FeatureFlagUpdate):
|
| 1933 |
+
"""Update a single feature flag"""
|
| 1934 |
success = feature_flags.set_flag(flag_name, request.value)
|
| 1935 |
if success:
|
| 1936 |
return {
|
|
|
|
| 1945 |
|
| 1946 |
@app.post("/api/feature-flags/reset")
|
| 1947 |
async def reset_feature_flags():
|
| 1948 |
+
"""Reset all feature flags to default values"""
|
| 1949 |
success = feature_flags.reset_to_defaults()
|
| 1950 |
if success:
|
| 1951 |
return {
|
|
|
|
| 1959 |
|
| 1960 |
@app.get("/api/feature-flags/{flag_name}")
|
| 1961 |
async def get_single_feature_flag(flag_name: str):
|
| 1962 |
+
"""Get a single feature flag value"""
|
| 1963 |
value = feature_flags.get_flag(flag_name)
|
| 1964 |
return {
|
| 1965 |
"flag_name": flag_name,
|
|
|
|
| 1970 |
|
| 1971 |
@app.get("/api/proxy-status")
|
| 1972 |
async def get_proxy_status():
|
| 1973 |
+
"""Get provider proxy routing status"""
|
| 1974 |
status = []
|
| 1975 |
for provider_name, cache_data in provider_proxy_cache.items():
|
| 1976 |
age_seconds = (datetime.now() - cache_data.get("timestamp", datetime.now())).total_seconds()
|
|
|
|
| 2048 |
return await hf_search(q=q, kind=kind)
|
| 2049 |
|
| 2050 |
|
| 2051 |
+
# Serve static files (JS, CSS, etc.)
|
| 2052 |
+
# Serve static files (JS, CSS, etc.)
|
| 2053 |
+
if os.path.exists("static"):
|
| 2054 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2055 |
|
| 2056 |
+
# Serve config.js
|
| 2057 |
@app.get("/config.js")
|
| 2058 |
async def config_js():
|
| 2059 |
try:
|
|
|
|
| 2062 |
except:
|
| 2063 |
return Response(content="// Config not found", media_type="application/javascript")
|
| 2064 |
|
| 2065 |
+
# API v2 endpoints for enhanced dashboard
|
| 2066 |
@app.get("/api/v2/status")
|
| 2067 |
async def v2_status():
|
| 2068 |
+
"""Enhanced status endpoint"""
|
| 2069 |
providers = await get_provider_stats()
|
| 2070 |
return {
|
| 2071 |
"services": {
|
|
|
|
| 2091 |
|
| 2092 |
@app.get("/api/v2/config/apis")
|
| 2093 |
async def v2_config_apis():
|
| 2094 |
+
"""Get API configuration"""
|
| 2095 |
providers = await get_provider_stats()
|
| 2096 |
apis = {}
|
| 2097 |
for p in providers:
|
|
|
|
| 2105 |
|
| 2106 |
@app.get("/api/v2/schedule/tasks")
|
| 2107 |
async def v2_schedule_tasks():
|
| 2108 |
+
"""Get scheduled tasks"""
|
| 2109 |
providers = await get_provider_stats()
|
| 2110 |
tasks = {}
|
| 2111 |
for p in providers:
|
|
|
|
| 2121 |
|
| 2122 |
@app.get("/api/v2/schedule/tasks/{api_id}")
|
| 2123 |
async def v2_schedule_task(api_id: str):
|
| 2124 |
+
"""Get specific scheduled task"""
|
| 2125 |
return {
|
| 2126 |
"api_id": api_id,
|
| 2127 |
"interval": 300,
|
|
|
|
| 2132 |
|
| 2133 |
@app.put("/api/v2/schedule/tasks/{api_id}")
|
| 2134 |
async def v2_update_schedule(api_id: str, interval: int = 300, enabled: bool = True):
|
| 2135 |
+
"""Update schedule"""
|
| 2136 |
return {
|
| 2137 |
"api_id": api_id,
|
| 2138 |
"interval": interval,
|
|
|
|
| 2142 |
|
| 2143 |
@app.post("/api/v2/schedule/tasks/{api_id}/force-update")
|
| 2144 |
async def v2_force_update(api_id: str):
|
| 2145 |
+
"""Force update for specific API"""
|
| 2146 |
return {
|
| 2147 |
"api_id": api_id,
|
| 2148 |
"status": "updated",
|
| 2149 |
"timestamp": datetime.now().isoformat()
|
| 2150 |
}
|
| 2151 |
|
| 2152 |
+
async def _gather_export_snapshot() -> Dict:
|
| 2153 |
+
"""Collects a rich snapshot combining providers, market, and diagnostics."""
|
| 2154 |
+
providers = await get_provider_stats()
|
| 2155 |
+
market = await get_market_data()
|
| 2156 |
+
global_stats = await get_global_stats()
|
| 2157 |
+
sentiment_data = await get_sentiment()
|
| 2158 |
+
defi_data = await get_defi_tvl()
|
| 2159 |
+
logs = db.get_recent_status(hours=24, limit=200)
|
| 2160 |
+
alerts = db.get_unacknowledged_alerts()
|
| 2161 |
+
|
| 2162 |
+
return {
|
| 2163 |
+
"generated_at": datetime.utcnow().isoformat(),
|
| 2164 |
+
"providers": providers,
|
| 2165 |
+
"market": {
|
| 2166 |
+
"cryptocurrencies": market,
|
| 2167 |
+
"global": global_stats
|
| 2168 |
+
},
|
| 2169 |
+
"sentiment": sentiment_data,
|
| 2170 |
+
"defi": defi_data,
|
| 2171 |
+
"logs": logs,
|
| 2172 |
+
"alerts": alerts,
|
| 2173 |
+
}
|
| 2174 |
+
|
| 2175 |
+
def _write_providers_csv(path: Path, providers: List[Dict]) -> None:
|
| 2176 |
+
fieldnames = [
|
| 2177 |
+
"name", "category", "status", "uptime", "response_time_ms",
|
| 2178 |
+
"avg_response_time_ms", "rate_limit", "last_check", "base_url"
|
| 2179 |
+
]
|
| 2180 |
+
with path.open("w", newline="", encoding="utf-8") as csvfile:
|
| 2181 |
+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
| 2182 |
+
writer.writeheader()
|
| 2183 |
+
for provider in providers:
|
| 2184 |
+
writer.writerow({
|
| 2185 |
+
"name": provider.get("name"),
|
| 2186 |
+
"category": provider.get("category"),
|
| 2187 |
+
"status": provider.get("status"),
|
| 2188 |
+
"uptime": provider.get("uptime"),
|
| 2189 |
+
"response_time_ms": provider.get("response_time_ms"),
|
| 2190 |
+
"avg_response_time_ms": provider.get("avg_response_time_ms"),
|
| 2191 |
+
"rate_limit": provider.get("rate_limit"),
|
| 2192 |
+
"last_check": provider.get("last_check"),
|
| 2193 |
+
"base_url": provider.get("base_url"),
|
| 2194 |
+
})
|
| 2195 |
+
|
| 2196 |
@app.post("/api/v2/export/json")
|
| 2197 |
async def v2_export_json(request: dict):
|
| 2198 |
+
"""Export a complete JSON snapshot and persist it for download."""
|
| 2199 |
+
snapshot = await _gather_export_snapshot()
|
| 2200 |
+
filename = f"snapshot_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 2201 |
+
filepath = EXPORT_DIR / filename
|
| 2202 |
+
with filepath.open("w", encoding="utf-8") as f:
|
| 2203 |
+
json.dump(snapshot, f, ensure_ascii=False, indent=2)
|
| 2204 |
return {
|
| 2205 |
+
"filepath": str(filepath),
|
| 2206 |
+
"download_url": f"/api/v2/export/download/{filename}",
|
| 2207 |
+
"records": len(snapshot["providers"]),
|
| 2208 |
"timestamp": datetime.now().isoformat()
|
| 2209 |
}
|
| 2210 |
|
| 2211 |
@app.post("/api/v2/export/csv")
|
| 2212 |
async def v2_export_csv(request: dict):
|
| 2213 |
+
"""Export provider status table as CSV."""
|
| 2214 |
+
providers = await get_provider_stats()
|
| 2215 |
+
filename = f"providers_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
|
| 2216 |
+
filepath = EXPORT_DIR / filename
|
| 2217 |
+
_write_providers_csv(filepath, providers)
|
| 2218 |
return {
|
| 2219 |
+
"filepath": str(filepath),
|
| 2220 |
+
"download_url": f"/api/v2/export/download/{filename}",
|
| 2221 |
+
"records": len(providers),
|
| 2222 |
"timestamp": datetime.now().isoformat()
|
| 2223 |
}
|
| 2224 |
|
| 2225 |
+
@app.get("/api/v2/export/download/{filename}")
|
| 2226 |
+
async def v2_export_download(filename: str):
|
| 2227 |
+
"""Serve exported files securely."""
|
| 2228 |
+
safe_path = (EXPORT_DIR / filename).resolve()
|
| 2229 |
+
if not str(safe_path).startswith(str(EXPORT_DIR.resolve())):
|
| 2230 |
+
raise HTTPException(status_code=400, detail="Invalid file path")
|
| 2231 |
+
if not safe_path.exists():
|
| 2232 |
+
raise HTTPException(status_code=404, detail="File not found")
|
| 2233 |
+
return FileResponse(path=safe_path, filename=filename)
|
| 2234 |
+
|
| 2235 |
@app.post("/api/v2/backup")
|
| 2236 |
async def v2_backup():
|
| 2237 |
+
"""Create a backup JSON file identical to export but tagged for backups."""
|
| 2238 |
+
snapshot = await _gather_export_snapshot()
|
| 2239 |
+
filename = f"backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 2240 |
+
filepath = EXPORT_DIR / filename
|
| 2241 |
+
with filepath.open("w", encoding="utf-8") as f:
|
| 2242 |
+
json.dump(snapshot, f, ensure_ascii=False, indent=2)
|
| 2243 |
return {
|
| 2244 |
+
"backup_file": filename,
|
| 2245 |
+
"download_url": f"/api/v2/export/download/{filename}",
|
| 2246 |
"timestamp": datetime.now().isoformat()
|
| 2247 |
}
|
| 2248 |
|
| 2249 |
@app.post("/api/v2/cleanup/cache")
|
| 2250 |
async def v2_cleanup_cache():
|
| 2251 |
+
"""Clear cache"""
|
| 2252 |
+
# Clear all caches
|
| 2253 |
for key in cache:
|
| 2254 |
cache[key]["data"] = None
|
| 2255 |
cache[key]["timestamp"] = None
|
|
|
|
| 2260 |
|
| 2261 |
@app.websocket("/api/v2/ws")
|
| 2262 |
async def v2_websocket(websocket: WebSocket):
|
| 2263 |
+
"""Enhanced WebSocket endpoint"""
|
| 2264 |
await manager.connect(websocket)
|
| 2265 |
try:
|
| 2266 |
while True:
|
| 2267 |
await asyncio.sleep(5)
|
| 2268 |
|
| 2269 |
+
# Send status update
|
| 2270 |
await websocket.send_json({
|
| 2271 |
"type": "status_update",
|
| 2272 |
"data": {
|
|
|
|
| 2277 |
except WebSocketDisconnect:
|
| 2278 |
manager.disconnect(websocket)
|
| 2279 |
|
| 2280 |
+
# Pool Management Helpers and Endpoints
|
| 2281 |
def build_pool_payload(pool: Dict, provider_map: Dict[str, Dict]) -> Dict:
|
| 2282 |
members_payload = []
|
| 2283 |
current_provider = None
|
|
|
|
| 2306 |
}
|
| 2307 |
}
|
| 2308 |
|
| 2309 |
+
# keep database stats in sync
|
| 2310 |
db.update_member_stats(
|
| 2311 |
pool["id"],
|
| 2312 |
provider_id,
|
|
|
|
| 2362 |
|
| 2363 |
@app.get("/api/pools")
|
| 2364 |
async def get_pools():
|
| 2365 |
+
"""Get all pools"""
|
| 2366 |
providers = await get_provider_stats()
|
| 2367 |
provider_map = {provider_slug(p["name"]): p for p in providers}
|
| 2368 |
pools = db.get_pools()
|
|
|
|
| 2372 |
|
| 2373 |
@app.post("/api/pools")
|
| 2374 |
async def create_pool(pool: PoolCreate):
|
| 2375 |
+
"""Create a new pool"""
|
| 2376 |
valid_strategies = {"round_robin", "priority", "weighted", "least_used"}
|
| 2377 |
if pool.rotation_strategy not in valid_strategies:
|
| 2378 |
raise HTTPException(status_code=400, detail="Invalid rotation strategy")
|
|
|
|
| 2401 |
|
| 2402 |
@app.get("/api/pools/{pool_id}")
|
| 2403 |
async def get_pool(pool_id: int):
|
| 2404 |
+
"""Get specific pool"""
|
| 2405 |
pool = db.get_pool(pool_id)
|
| 2406 |
if not pool:
|
| 2407 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
|
|
| 2413 |
|
| 2414 |
@app.delete("/api/pools/{pool_id}")
|
| 2415 |
async def delete_pool(pool_id: int):
|
| 2416 |
+
"""Delete a pool"""
|
| 2417 |
pool = db.get_pool(pool_id)
|
| 2418 |
if not pool:
|
| 2419 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
|
|
| 2425 |
|
| 2426 |
@app.post("/api/pools/{pool_id}/members")
|
| 2427 |
async def add_pool_member(pool_id: int, member: PoolMemberAdd):
|
| 2428 |
+
"""Add a member to a pool"""
|
| 2429 |
pool = db.get_pool(pool_id)
|
| 2430 |
if not pool:
|
| 2431 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
|
|
| 2464 |
|
| 2465 |
@app.delete("/api/pools/{pool_id}/members/{provider_id}")
|
| 2466 |
async def remove_pool_member(pool_id: int, provider_id: str):
|
| 2467 |
+
"""Remove a member from a pool"""
|
| 2468 |
pool = db.get_pool(pool_id)
|
| 2469 |
if not pool:
|
| 2470 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
|
|
| 2485 |
|
| 2486 |
@app.post("/api/pools/{pool_id}/rotate")
|
| 2487 |
async def rotate_pool(pool_id: int, request: Optional[Dict] = None):
|
| 2488 |
+
"""Rotate pool to next provider"""
|
| 2489 |
pool = db.get_pool(pool_id)
|
| 2490 |
if not pool:
|
| 2491 |
raise HTTPException(status_code=404, detail="Pool not found")
|
|
|
|
| 2529 |
elif strategy == "least_used":
|
| 2530 |
candidates.sort(key=lambda x: x[0].get("use_count", 0))
|
| 2531 |
selected_member, status_info = candidates[0]
|
| 2532 |
+
else: # round_robin or default
|
| 2533 |
candidates.sort(key=lambda x: x[0].get("use_count", 0))
|
| 2534 |
selected_member, status_info = candidates[0]
|
| 2535 |
|
|
|
|
| 2568 |
|
| 2569 |
@app.get("/api/pools/{pool_id}/history")
|
| 2570 |
async def get_pool_history(pool_id: int, limit: int = 20):
|
| 2571 |
+
"""Get rotation history for a pool"""
|
| 2572 |
try:
|
| 2573 |
raw_history = db.get_pool_rotation_history(pool_id, limit)
|
| 2574 |
+
except Exception as exc: # pragma: no cover - defensive
|
| 2575 |
logger.warning("pool history fetch failed for %s: %s", pool_id, exc)
|
| 2576 |
raw_history = []
|
| 2577 |
history = transform_rotation_history(raw_history)
|
|
|
|
| 2583 |
|
| 2584 |
@app.get("/api/pools/history")
|
| 2585 |
async def get_all_history(limit: int = 50):
|
| 2586 |
+
"""Get all rotation history"""
|
| 2587 |
try:
|
| 2588 |
raw_history = db.get_pool_rotation_history(None, limit)
|
| 2589 |
+
except Exception as exc: # pragma: no cover - defensive
|
| 2590 |
logger.warning("global pool history fetch failed: %s", exc)
|
| 2591 |
raw_history = []
|
| 2592 |
history = transform_rotation_history(raw_history)
|
|
|
|
| 2595 |
"total": len(history)
|
| 2596 |
}
|
| 2597 |
|
| 2598 |
+
@app.get("/api/reports/discovery")
|
| 2599 |
+
async def get_discovery_report():
|
| 2600 |
+
"""Get provider discovery report"""
|
| 2601 |
+
providers = await get_provider_stats()
|
| 2602 |
+
categories = {}
|
| 2603 |
+
for p in providers:
|
| 2604 |
+
cat = p.get('category', 'unknown')
|
| 2605 |
+
if cat not in categories:
|
| 2606 |
+
categories[cat] = {'total': 0, 'online': 0, 'offline': 0, 'degraded': 0}
|
| 2607 |
+
categories[cat]['total'] += 1
|
| 2608 |
+
categories[cat][p.get('status', 'unknown')] += 1
|
| 2609 |
+
|
| 2610 |
+
return {
|
| 2611 |
+
"total_providers": len(providers),
|
| 2612 |
+
"categories": categories,
|
| 2613 |
+
"timestamp": datetime.now().isoformat(),
|
| 2614 |
+
"providers": providers[:10] # First 10 for preview
|
| 2615 |
+
}
|
| 2616 |
+
|
| 2617 |
+
@app.get("/api/reports/health")
|
| 2618 |
+
async def get_health_report():
|
| 2619 |
+
"""Get system health report"""
|
| 2620 |
+
providers = await get_provider_stats()
|
| 2621 |
+
online = len([p for p in providers if p.get('status') == 'online'])
|
| 2622 |
+
|
| 2623 |
+
return {
|
| 2624 |
+
"status": "healthy" if online >= len(providers) * 0.7 else "degraded",
|
| 2625 |
+
"total_providers": len(providers),
|
| 2626 |
+
"online": online,
|
| 2627 |
+
"offline": len([p for p in providers if p.get('status') == 'offline']),
|
| 2628 |
+
"degraded": len([p for p in providers if p.get('status') == 'degraded']),
|
| 2629 |
+
"uptime_percentage": round((online / len(providers)) * 100, 2) if providers else 0,
|
| 2630 |
+
"timestamp": datetime.now().isoformat()
|
| 2631 |
+
}
|
| 2632 |
+
|
| 2633 |
+
@app.get("/api/reports/performance")
|
| 2634 |
+
async def get_performance_report():
|
| 2635 |
+
"""Get performance metrics report"""
|
| 2636 |
+
providers = await get_provider_stats()
|
| 2637 |
+
response_times = [p.get('response_time_ms', 0) for p in providers if p.get('response_time_ms')]
|
| 2638 |
+
|
| 2639 |
+
return {
|
| 2640 |
+
"avg_response_time": round(sum(response_times) / len(response_times), 2) if response_times else 0,
|
| 2641 |
+
"min_response_time": min(response_times) if response_times else 0,
|
| 2642 |
+
"max_response_time": max(response_times) if response_times else 0,
|
| 2643 |
+
"total_providers": len(providers),
|
| 2644 |
+
"timestamp": datetime.now().isoformat()
|
| 2645 |
+
}
|
| 2646 |
+
|
| 2647 |
+
@app.get("/api/reports/models")
|
| 2648 |
+
async def get_models_report():
|
| 2649 |
+
"""Get HuggingFace models report"""
|
| 2650 |
+
try:
|
| 2651 |
+
models = await _fetch_hf_registry("models", "crypto", 20)
|
| 2652 |
+
return {
|
| 2653 |
+
"total": len(models),
|
| 2654 |
+
"models": models,
|
| 2655 |
+
"timestamp": datetime.now().isoformat()
|
| 2656 |
+
}
|
| 2657 |
+
except Exception as e:
|
| 2658 |
+
logger.error(f"Error fetching models: {e}")
|
| 2659 |
+
return {
|
| 2660 |
+
"total": 0,
|
| 2661 |
+
"models": [],
|
| 2662 |
+
"timestamp": datetime.now().isoformat(),
|
| 2663 |
+
"error": str(e)
|
| 2664 |
+
}
|
| 2665 |
+
|
| 2666 |
+
@app.get("/api/reports/datasets")
|
| 2667 |
+
async def get_datasets_report():
|
| 2668 |
+
"""Get HuggingFace datasets report"""
|
| 2669 |
+
try:
|
| 2670 |
+
datasets = await _fetch_hf_registry("datasets", "crypto", 20)
|
| 2671 |
+
return {
|
| 2672 |
+
"total": len(datasets),
|
| 2673 |
+
"datasets": datasets,
|
| 2674 |
+
"timestamp": datetime.now().isoformat()
|
| 2675 |
+
}
|
| 2676 |
+
except Exception as e:
|
| 2677 |
+
logger.error(f"Error fetching datasets: {e}")
|
| 2678 |
+
return {
|
| 2679 |
+
"total": 0,
|
| 2680 |
+
"datasets": [],
|
| 2681 |
+
"timestamp": datetime.now().isoformat(),
|
| 2682 |
+
"error": str(e)
|
| 2683 |
+
}
|
| 2684 |
+
|
| 2685 |
+
@app.get("/api/reports/summary")
|
| 2686 |
+
async def get_reports_summary():
|
| 2687 |
+
"""Get complete reports summary"""
|
| 2688 |
+
providers = await get_provider_stats()
|
| 2689 |
+
online = len([p for p in providers if p.get('status') == 'online'])
|
| 2690 |
+
|
| 2691 |
+
try:
|
| 2692 |
+
models = await _fetch_hf_registry("models", "crypto", 5)
|
| 2693 |
+
datasets = await _fetch_hf_registry("datasets", "crypto", 5)
|
| 2694 |
+
except:
|
| 2695 |
+
models = []
|
| 2696 |
+
datasets = []
|
| 2697 |
+
|
| 2698 |
+
return {
|
| 2699 |
+
"providers": {
|
| 2700 |
+
"total": len(providers),
|
| 2701 |
+
"online": online,
|
| 2702 |
+
"offline": len([p for p in providers if p.get('status') == 'offline']),
|
| 2703 |
+
"degraded": len([p for p in providers if p.get('status') == 'degraded'])
|
| 2704 |
+
},
|
| 2705 |
+
"models": {
|
| 2706 |
+
"total": len(models),
|
| 2707 |
+
"recent": models[:5]
|
| 2708 |
+
},
|
| 2709 |
+
"datasets": {
|
| 2710 |
+
"total": len(datasets),
|
| 2711 |
+
"recent": datasets[:5]
|
| 2712 |
+
},
|
| 2713 |
+
"timestamp": datetime.now().isoformat()
|
| 2714 |
+
}
|
| 2715 |
+
|
| 2716 |
@app.get("/api/providers/config")
|
| 2717 |
async def get_providers_config():
|
| 2718 |
+
"""
|
| 2719 |
+
Return complete provider configuration from providers_config_ultimate.json
|
| 2720 |
+
This endpoint is used by the Provider Auto-Discovery Engine
|
| 2721 |
+
"""
|
| 2722 |
try:
|
| 2723 |
config_path = Path(__file__).parent / "providers_config_ultimate.json"
|
| 2724 |
with open(config_path, 'r', encoding='utf-8') as f:
|
|
|
|
| 2731 |
|
| 2732 |
@app.get("/api/providers/{provider_id}/health")
|
| 2733 |
async def check_provider_health_by_id(provider_id: str):
|
| 2734 |
+
"""
|
| 2735 |
+
Check health status of a specific provider
|
| 2736 |
+
Returns: { status: 'online'|'offline', response_time: number, error?: string }
|
| 2737 |
+
"""
|
| 2738 |
try:
|
| 2739 |
+
# Load provider config
|
| 2740 |
config_path = Path(__file__).parent / "providers_config_ultimate.json"
|
| 2741 |
with open(config_path, 'r', encoding='utf-8') as f:
|
| 2742 |
config = json.load(f)
|
|
|
|
| 2745 |
if not provider:
|
| 2746 |
raise HTTPException(status_code=404, detail=f"Provider '{provider_id}' not found")
|
| 2747 |
|
| 2748 |
+
# Try to ping the provider's base URL
|
| 2749 |
base_url = provider.get('base_url')
|
| 2750 |
if not base_url:
|
| 2751 |
return {"status": "unknown", "error": "No base URL configured"}
|
|
|
|
| 2756 |
async with aiohttp.ClientSession() as session:
|
| 2757 |
try:
|
| 2758 |
async with session.get(base_url, timeout=aiohttp.ClientTimeout(total=5.0)) as response:
|
| 2759 |
+
response_time = (time.time() - start_time) * 1000 # Convert to milliseconds
|
| 2760 |
status = "online" if response.status in [200, 201, 204, 301, 302, 404] else "offline"
|
| 2761 |
return {
|
| 2762 |
"status": status,
|
|
|
|
| 2771 |
except Exception as e:
|
| 2772 |
raise HTTPException(status_code=500, detail=str(e))
|
| 2773 |
|
|
|
|
| 2774 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2775 |
print("🚀 Crypto Monitor ULTIMATE")
|
| 2776 |
print("📊 Real APIs: CoinGecko, CoinCap, Binance, DeFi Llama, Fear & Greed")
|
| 2777 |
+
print("🌐 http://localhost:8000/dashboard")
|
| 2778 |
+
print("📡 API Docs: http://localhost:8000/docs")
|
| 2779 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
| 2780 |
+
|
| 2781 |
+
# === Compatibility routes without /api prefix for frontend fallbacks ===
|
| 2782 |
+
|
| 2783 |
+
@app.get("/providers")
|
| 2784 |
+
async def providers_root():
|
| 2785 |
+
"""Compatibility: mirror /api/providers at /providers"""
|
| 2786 |
+
return await providers()
|
| 2787 |
+
|
| 2788 |
+
@app.get("/providers/health")
|
| 2789 |
+
async def providers_health_root():
|
| 2790 |
+
"""Compatibility: health-style endpoint for providers"""
|
| 2791 |
+
data = await get_provider_stats(force_refresh=True)
|
| 2792 |
+
return data
|
| 2793 |
+
|
| 2794 |
+
@app.get("/categories")
|
| 2795 |
+
async def categories_root():
|
| 2796 |
+
"""Compatibility: mirror /api/categories at /categories"""
|
| 2797 |
+
return await api_categories()
|
| 2798 |
+
|
| 2799 |
+
@app.get("/rate-limits")
|
| 2800 |
+
async def rate_limits_root():
|
| 2801 |
+
"""Compatibility: mirror /api/rate-limits at /rate-limits"""
|
| 2802 |
+
return await api_rate_limits()
|
| 2803 |
+
|
| 2804 |
+
@app.get("/logs")
|
| 2805 |
+
async def logs_root(type: str = "all"):
|
| 2806 |
+
"""Compatibility: mirror /api/logs at /logs"""
|
| 2807 |
+
return await api_logs(type=type)
|
| 2808 |
+
|
| 2809 |
+
@app.get("/alerts")
|
| 2810 |
+
async def alerts_root():
|
| 2811 |
+
"""Compatibility: mirror /api/alerts at /alerts"""
|
| 2812 |
+
return await api_alerts()
|
| 2813 |
+
|
| 2814 |
+
@app.get("/hf/health")
|
| 2815 |
+
async def hf_health_root():
|
| 2816 |
+
"""Compatibility: mirror /api/hf/health at /hf/health"""
|
| 2817 |
+
return await hf_health()
|
| 2818 |
+
|
| 2819 |
+
@app.get("/hf/registry")
|
| 2820 |
+
async def hf_registry_root(type: str = "models"):
|
| 2821 |
+
"""Compatibility: mirror /api/hf/registry at /hf/registry"""
|
| 2822 |
+
return await hf_registry(type=type)
|
| 2823 |
+
|
| 2824 |
+
@app.get("/hf/search")
|
| 2825 |
+
async def hf_search_root(q: str = "", kind: str = "models"):
|
| 2826 |
+
"""Compatibility: mirror /api/hf/search at /hf/search"""
|
| 2827 |
+
return await hf_search(q=q, kind=kind)
|
| 2828 |
+
|
| 2829 |
+
@app.post("/hf/run-sentiment")
|
| 2830 |
+
async def hf_run_sentiment_root(request: SentimentRequest):
|
| 2831 |
+
"""Compatibility: mirror /api/hf/run-sentiment at /hf/run-sentiment"""
|
| 2832 |
+
return await hf_run_sentiment(request)
|
backend/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/backend/__pycache__/__init__.cpython-313.pyc and b/backend/__pycache__/__init__.cpython-313.pyc differ
|
|
|
backend/__pycache__/feature_flags.cpython-313.pyc
ADDED
|
Binary file (11.2 kB). View file
|
|
|
complete_dashboard.html
ADDED
|
@@ -0,0 +1,857 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Crypto API Monitor - Complete Dashboard</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: #0f172a;
|
| 17 |
+
color: #e2e8f0;
|
| 18 |
+
overflow-x: hidden;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.header {
|
| 22 |
+
background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
|
| 23 |
+
padding: 20px 40px;
|
| 24 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
| 25 |
+
position: sticky;
|
| 26 |
+
top: 0;
|
| 27 |
+
z-index: 1000;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.header-content {
|
| 31 |
+
max-width: 1600px;
|
| 32 |
+
margin: 0 auto;
|
| 33 |
+
display: flex;
|
| 34 |
+
justify-content: space-between;
|
| 35 |
+
align-items: center;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.logo {
|
| 39 |
+
font-size: 24px;
|
| 40 |
+
font-weight: bold;
|
| 41 |
+
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
|
| 42 |
+
-webkit-background-clip: text;
|
| 43 |
+
-webkit-text-fill-color: transparent;
|
| 44 |
+
display: flex;
|
| 45 |
+
align-items: center;
|
| 46 |
+
gap: 10px;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.header-actions {
|
| 50 |
+
display: flex;
|
| 51 |
+
gap: 15px;
|
| 52 |
+
align-items: center;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.btn {
|
| 56 |
+
padding: 10px 20px;
|
| 57 |
+
border: none;
|
| 58 |
+
border-radius: 8px;
|
| 59 |
+
font-weight: 600;
|
| 60 |
+
cursor: pointer;
|
| 61 |
+
transition: all 0.3s ease;
|
| 62 |
+
font-size: 14px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.btn-primary {
|
| 66 |
+
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
|
| 67 |
+
color: white;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.btn-primary:hover {
|
| 71 |
+
transform: translateY(-2px);
|
| 72 |
+
box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.btn-secondary {
|
| 76 |
+
background: #334155;
|
| 77 |
+
color: #e2e8f0;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.btn-secondary:hover {
|
| 81 |
+
background: #475569;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.container {
|
| 85 |
+
max-width: 1600px;
|
| 86 |
+
margin: 0 auto;
|
| 87 |
+
padding: 30px;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.tabs {
|
| 91 |
+
display: flex;
|
| 92 |
+
gap: 5px;
|
| 93 |
+
margin-bottom: 30px;
|
| 94 |
+
background: #1e293b;
|
| 95 |
+
padding: 10px;
|
| 96 |
+
border-radius: 12px;
|
| 97 |
+
overflow-x: auto;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.tab {
|
| 101 |
+
padding: 12px 24px;
|
| 102 |
+
border: none;
|
| 103 |
+
background: transparent;
|
| 104 |
+
color: #94a3b8;
|
| 105 |
+
cursor: pointer;
|
| 106 |
+
border-radius: 8px;
|
| 107 |
+
font-weight: 600;
|
| 108 |
+
transition: all 0.3s ease;
|
| 109 |
+
white-space: nowrap;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.tab:hover {
|
| 113 |
+
background: #334155;
|
| 114 |
+
color: #e2e8f0;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.tab.active {
|
| 118 |
+
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
|
| 119 |
+
color: white;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.tab-content {
|
| 123 |
+
display: none;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.tab-content.active {
|
| 127 |
+
display: block;
|
| 128 |
+
animation: fadeIn 0.3s ease;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
@keyframes fadeIn {
|
| 132 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 133 |
+
to { opacity: 1; transform: translateY(0); }
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.stats-grid {
|
| 137 |
+
display: grid;
|
| 138 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
| 139 |
+
gap: 20px;
|
| 140 |
+
margin-bottom: 30px;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.stat-card {
|
| 144 |
+
background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
|
| 145 |
+
padding: 25px;
|
| 146 |
+
border-radius: 12px;
|
| 147 |
+
border: 1px solid #334155;
|
| 148 |
+
transition: all 0.3s ease;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.stat-card:hover {
|
| 152 |
+
transform: translateY(-5px);
|
| 153 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
| 154 |
+
border-color: #3b82f6;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
.stat-card h3 {
|
| 158 |
+
color: #94a3b8;
|
| 159 |
+
font-size: 14px;
|
| 160 |
+
text-transform: uppercase;
|
| 161 |
+
margin-bottom: 10px;
|
| 162 |
+
font-weight: 600;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.stat-card .value {
|
| 166 |
+
font-size: 36px;
|
| 167 |
+
font-weight: bold;
|
| 168 |
+
margin-bottom: 5px;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.stat-card .label {
|
| 172 |
+
color: #64748b;
|
| 173 |
+
font-size: 13px;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.stat-card.green .value { color: #10b981; }
|
| 177 |
+
.stat-card.blue .value { color: #3b82f6; }
|
| 178 |
+
.stat-card.purple .value { color: #8b5cf6; }
|
| 179 |
+
.stat-card.orange .value { color: #f59e0b; }
|
| 180 |
+
.stat-card.red .value { color: #ef4444; }
|
| 181 |
+
|
| 182 |
+
.card {
|
| 183 |
+
background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
|
| 184 |
+
border-radius: 12px;
|
| 185 |
+
padding: 25px;
|
| 186 |
+
border: 1px solid #334155;
|
| 187 |
+
margin-bottom: 20px;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.card h2 {
|
| 191 |
+
color: #e2e8f0;
|
| 192 |
+
margin-bottom: 20px;
|
| 193 |
+
font-size: 20px;
|
| 194 |
+
display: flex;
|
| 195 |
+
align-items: center;
|
| 196 |
+
gap: 10px;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.providers-grid {
|
| 200 |
+
display: grid;
|
| 201 |
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
| 202 |
+
gap: 15px;
|
| 203 |
+
max-height: 600px;
|
| 204 |
+
overflow-y: auto;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.provider-card {
|
| 208 |
+
background: #0f172a;
|
| 209 |
+
border-radius: 8px;
|
| 210 |
+
padding: 15px;
|
| 211 |
+
border-left: 4px solid #334155;
|
| 212 |
+
transition: all 0.3s ease;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.provider-card:hover {
|
| 216 |
+
transform: translateX(5px);
|
| 217 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.provider-card.online {
|
| 221 |
+
border-left-color: #10b981;
|
| 222 |
+
background: linear-gradient(to right, rgba(16, 185, 129, 0.1), #0f172a);
|
| 223 |
+
}
|
| 224 |
+
.provider-card.offline {
|
| 225 |
+
border-left-color: #ef4444;
|
| 226 |
+
background: linear-gradient(to right, rgba(239, 68, 68, 0.1), #0f172a);
|
| 227 |
+
}
|
| 228 |
+
.provider-card.degraded {
|
| 229 |
+
border-left-color: #f59e0b;
|
| 230 |
+
background: linear-gradient(to right, rgba(245, 158, 11, 0.1), #0f172a);
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.provider-card .name {
|
| 234 |
+
font-weight: 600;
|
| 235 |
+
color: #e2e8f0;
|
| 236 |
+
margin-bottom: 8px;
|
| 237 |
+
font-size: 15px;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
.provider-card .category {
|
| 241 |
+
font-size: 12px;
|
| 242 |
+
color: #94a3b8;
|
| 243 |
+
margin-bottom: 8px;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.provider-card .status {
|
| 247 |
+
display: inline-block;
|
| 248 |
+
padding: 4px 10px;
|
| 249 |
+
border-radius: 6px;
|
| 250 |
+
font-size: 11px;
|
| 251 |
+
font-weight: 600;
|
| 252 |
+
text-transform: uppercase;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.status.online { background: rgba(16, 185, 129, 0.2); color: #10b981; }
|
| 256 |
+
.status.offline { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
|
| 257 |
+
.status.degraded { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
|
| 258 |
+
|
| 259 |
+
.provider-card .response-time {
|
| 260 |
+
font-size: 12px;
|
| 261 |
+
color: #64748b;
|
| 262 |
+
margin-top: 8px;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.category-list {
|
| 266 |
+
display: grid;
|
| 267 |
+
gap: 15px;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.category-item {
|
| 271 |
+
background: #0f172a;
|
| 272 |
+
border-radius: 8px;
|
| 273 |
+
padding: 20px;
|
| 274 |
+
border-left: 4px solid #3b82f6;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
.category-item .name {
|
| 278 |
+
font-weight: 600;
|
| 279 |
+
color: #e2e8f0;
|
| 280 |
+
margin-bottom: 12px;
|
| 281 |
+
font-size: 16px;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.category-item .stats {
|
| 285 |
+
display: flex;
|
| 286 |
+
gap: 20px;
|
| 287 |
+
font-size: 14px;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.category-item .stat {
|
| 291 |
+
display: flex;
|
| 292 |
+
align-items: center;
|
| 293 |
+
gap: 6px;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.loading {
|
| 297 |
+
text-align: center;
|
| 298 |
+
padding: 60px;
|
| 299 |
+
color: #64748b;
|
| 300 |
+
font-size: 16px;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
.spinner {
|
| 304 |
+
border: 3px solid #334155;
|
| 305 |
+
border-top: 3px solid #3b82f6;
|
| 306 |
+
border-radius: 50%;
|
| 307 |
+
width: 40px;
|
| 308 |
+
height: 40px;
|
| 309 |
+
animation: spin 1s linear infinite;
|
| 310 |
+
margin: 20px auto;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
@keyframes spin {
|
| 314 |
+
0% { transform: rotate(0deg); }
|
| 315 |
+
100% { transform: rotate(360deg); }
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
.grid-2 {
|
| 319 |
+
display: grid;
|
| 320 |
+
grid-template-columns: 2fr 1fr;
|
| 321 |
+
gap: 20px;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
.market-item {
|
| 325 |
+
display: flex;
|
| 326 |
+
justify-content: space-between;
|
| 327 |
+
align-items: center;
|
| 328 |
+
padding: 15px;
|
| 329 |
+
background: #0f172a;
|
| 330 |
+
border-radius: 8px;
|
| 331 |
+
margin-bottom: 10px;
|
| 332 |
+
border: 1px solid #334155;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
.market-item:hover {
|
| 336 |
+
border-color: #3b82f6;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
.market-item .coin-info {
|
| 340 |
+
display: flex;
|
| 341 |
+
align-items: center;
|
| 342 |
+
gap: 15px;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
.market-item .coin-name {
|
| 346 |
+
font-weight: 600;
|
| 347 |
+
color: #e2e8f0;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.market-item .coin-symbol {
|
| 351 |
+
color: #94a3b8;
|
| 352 |
+
font-size: 14px;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.market-item .price {
|
| 356 |
+
font-size: 18px;
|
| 357 |
+
font-weight: 600;
|
| 358 |
+
color: #3b82f6;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
.market-item .change {
|
| 362 |
+
padding: 4px 10px;
|
| 363 |
+
border-radius: 6px;
|
| 364 |
+
font-weight: 600;
|
| 365 |
+
font-size: 14px;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.market-item .change.positive {
|
| 369 |
+
background: rgba(16, 185, 129, 0.2);
|
| 370 |
+
color: #10b981;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.market-item .change.negative {
|
| 374 |
+
background: rgba(239, 68, 68, 0.2);
|
| 375 |
+
color: #ef4444;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
.search-box {
|
| 379 |
+
width: 100%;
|
| 380 |
+
padding: 12px 20px;
|
| 381 |
+
background: #0f172a;
|
| 382 |
+
border: 1px solid #334155;
|
| 383 |
+
border-radius: 8px;
|
| 384 |
+
color: #e2e8f0;
|
| 385 |
+
font-size: 14px;
|
| 386 |
+
margin-bottom: 20px;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.search-box:focus {
|
| 390 |
+
outline: none;
|
| 391 |
+
border-color: #3b82f6;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
::-webkit-scrollbar {
|
| 395 |
+
width: 8px;
|
| 396 |
+
height: 8px;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
::-webkit-scrollbar-track {
|
| 400 |
+
background: #1e293b;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
::-webkit-scrollbar-thumb {
|
| 404 |
+
background: #334155;
|
| 405 |
+
border-radius: 4px;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
::-webkit-scrollbar-thumb:hover {
|
| 409 |
+
background: #475569;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
@media (max-width: 768px) {
|
| 413 |
+
.grid-2 {
|
| 414 |
+
grid-template-columns: 1fr;
|
| 415 |
+
}
|
| 416 |
+
.stats-grid {
|
| 417 |
+
grid-template-columns: 1fr;
|
| 418 |
+
}
|
| 419 |
+
.header-content {
|
| 420 |
+
flex-direction: column;
|
| 421 |
+
gap: 15px;
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
.status-indicator {
|
| 426 |
+
display: inline-block;
|
| 427 |
+
width: 8px;
|
| 428 |
+
height: 8px;
|
| 429 |
+
border-radius: 50%;
|
| 430 |
+
margin-right: 8px;
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
.status-indicator.online { background: #10b981; }
|
| 434 |
+
.status-indicator.offline { background: #ef4444; }
|
| 435 |
+
.status-indicator.degraded { background: #f59e0b; }
|
| 436 |
+
|
| 437 |
+
.empty-state {
|
| 438 |
+
text-align: center;
|
| 439 |
+
padding: 60px 20px;
|
| 440 |
+
color: #64748b;
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
.empty-state h3 {
|
| 444 |
+
color: #94a3b8;
|
| 445 |
+
margin-bottom: 10px;
|
| 446 |
+
}
|
| 447 |
+
</style>
|
| 448 |
+
</head>
|
| 449 |
+
<body>
|
| 450 |
+
<div class="header">
|
| 451 |
+
<div class="header-content">
|
| 452 |
+
<div class="logo">
|
| 453 |
+
<span>🚀</span>
|
| 454 |
+
<span>Crypto API Monitor</span>
|
| 455 |
+
</div>
|
| 456 |
+
<div class="header-actions">
|
| 457 |
+
<span id="connectionStatus" style="color: #64748b; font-size: 14px;">
|
| 458 |
+
<span class="status-indicator online"></span>
|
| 459 |
+
Connected
|
| 460 |
+
</span>
|
| 461 |
+
<button class="btn btn-secondary" onclick="refreshData()">🔄 Refresh</button>
|
| 462 |
+
<button class="btn btn-primary" onclick="exportData()">💾 Export</button>
|
| 463 |
+
</div>
|
| 464 |
+
</div>
|
| 465 |
+
</div>
|
| 466 |
+
|
| 467 |
+
<div class="container">
|
| 468 |
+
<div class="tabs">
|
| 469 |
+
<button class="tab active" onclick="switchTab('overview')">📊 Overview</button>
|
| 470 |
+
<button class="tab" onclick="switchTab('providers')">🔌 Providers</button>
|
| 471 |
+
<button class="tab" onclick="switchTab('categories')">📁 Categories</button>
|
| 472 |
+
<button class="tab" onclick="switchTab('market')">💰 Market Data</button>
|
| 473 |
+
<button class="tab" onclick="switchTab('health')">❤️ Health</button>
|
| 474 |
+
</div>
|
| 475 |
+
|
| 476 |
+
<!-- Overview Tab -->
|
| 477 |
+
<div id="overview" class="tab-content active">
|
| 478 |
+
<div class="stats-grid">
|
| 479 |
+
<div class="stat-card blue">
|
| 480 |
+
<h3>Total Providers</h3>
|
| 481 |
+
<div class="value" id="totalProviders">-</div>
|
| 482 |
+
<div class="label">API Sources</div>
|
| 483 |
+
</div>
|
| 484 |
+
<div class="stat-card green">
|
| 485 |
+
<h3>Online</h3>
|
| 486 |
+
<div class="value" id="onlineProviders">-</div>
|
| 487 |
+
<div class="label">Working Perfectly</div>
|
| 488 |
+
</div>
|
| 489 |
+
<div class="stat-card orange">
|
| 490 |
+
<h3>Degraded</h3>
|
| 491 |
+
<div class="value" id="degradedProviders">-</div>
|
| 492 |
+
<div class="label">Slow Response</div>
|
| 493 |
+
</div>
|
| 494 |
+
<div class="stat-card red">
|
| 495 |
+
<h3>Offline</h3>
|
| 496 |
+
<div class="value" id="offlineProviders">-</div>
|
| 497 |
+
<div class="label">Not Responding</div>
|
| 498 |
+
</div>
|
| 499 |
+
</div>
|
| 500 |
+
|
| 501 |
+
<div class="grid-2">
|
| 502 |
+
<div class="card">
|
| 503 |
+
<h2>🔌 Recent Provider Status</h2>
|
| 504 |
+
<div id="recentProviders">
|
| 505 |
+
<div class="loading">
|
| 506 |
+
<div class="spinner"></div>
|
| 507 |
+
Loading providers...
|
| 508 |
+
</div>
|
| 509 |
+
</div>
|
| 510 |
+
</div>
|
| 511 |
+
|
| 512 |
+
<div class="card">
|
| 513 |
+
<h2>📈 System Health</h2>
|
| 514 |
+
<div id="systemHealth">
|
| 515 |
+
<div class="loading">
|
| 516 |
+
<div class="spinner"></div>
|
| 517 |
+
Loading health data...
|
| 518 |
+
</div>
|
| 519 |
+
</div>
|
| 520 |
+
</div>
|
| 521 |
+
</div>
|
| 522 |
+
</div>
|
| 523 |
+
|
| 524 |
+
<!-- Providers Tab -->
|
| 525 |
+
<div id="providers" class="tab-content">
|
| 526 |
+
<div class="card">
|
| 527 |
+
<h2>🔌 All Providers</h2>
|
| 528 |
+
<input type="text" class="search-box" id="providerSearch" placeholder="Search providers..." onkeyup="filterProviders()">
|
| 529 |
+
<div class="providers-grid" id="allProviders">
|
| 530 |
+
<div class="loading">
|
| 531 |
+
<div class="spinner"></div>
|
| 532 |
+
Loading providers...
|
| 533 |
+
</div>
|
| 534 |
+
</div>
|
| 535 |
+
</div>
|
| 536 |
+
</div>
|
| 537 |
+
|
| 538 |
+
<!-- Categories Tab -->
|
| 539 |
+
<div id="categories" class="tab-content">
|
| 540 |
+
<div class="card">
|
| 541 |
+
<h2>📁 Categories Breakdown</h2>
|
| 542 |
+
<div class="category-list" id="categoriesList">
|
| 543 |
+
<div class="loading">
|
| 544 |
+
<div class="spinner"></div>
|
| 545 |
+
Loading categories...
|
| 546 |
+
</div>
|
| 547 |
+
</div>
|
| 548 |
+
</div>
|
| 549 |
+
</div>
|
| 550 |
+
|
| 551 |
+
<!-- Market Tab -->
|
| 552 |
+
<div id="market" class="tab-content">
|
| 553 |
+
<div class="card">
|
| 554 |
+
<h2>💰 Market Data</h2>
|
| 555 |
+
<div id="marketData">
|
| 556 |
+
<div class="loading">
|
| 557 |
+
<div class="spinner"></div>
|
| 558 |
+
Loading market data...
|
| 559 |
+
</div>
|
| 560 |
+
</div>
|
| 561 |
+
</div>
|
| 562 |
+
</div>
|
| 563 |
+
|
| 564 |
+
<!-- Health Tab -->
|
| 565 |
+
<div id="health" class="tab-content">
|
| 566 |
+
<div class="stats-grid">
|
| 567 |
+
<div class="stat-card purple">
|
| 568 |
+
<h3>Uptime</h3>
|
| 569 |
+
<div class="value" id="uptimePercent">-</div>
|
| 570 |
+
<div class="label">Overall Health</div>
|
| 571 |
+
</div>
|
| 572 |
+
<div class="stat-card blue">
|
| 573 |
+
<h3>Avg Response</h3>
|
| 574 |
+
<div class="value" id="avgResponse">-</div>
|
| 575 |
+
<div class="label">Milliseconds</div>
|
| 576 |
+
</div>
|
| 577 |
+
<div class="stat-card green">
|
| 578 |
+
<h3>Categories</h3>
|
| 579 |
+
<div class="value" id="totalCategories">-</div>
|
| 580 |
+
<div class="label">Data Types</div>
|
| 581 |
+
</div>
|
| 582 |
+
<div class="stat-card orange">
|
| 583 |
+
<h3>Last Check</h3>
|
| 584 |
+
<div class="value" id="lastCheck" style="font-size: 18px;">-</div>
|
| 585 |
+
<div class="label">Timestamp</div>
|
| 586 |
+
</div>
|
| 587 |
+
</div>
|
| 588 |
+
|
| 589 |
+
<div class="card">
|
| 590 |
+
<h2>📊 Detailed Health Report</h2>
|
| 591 |
+
<div id="healthDetails">
|
| 592 |
+
<div class="loading">
|
| 593 |
+
<div class="spinner"></div>
|
| 594 |
+
Loading health details...
|
| 595 |
+
</div>
|
| 596 |
+
</div>
|
| 597 |
+
</div>
|
| 598 |
+
</div>
|
| 599 |
+
</div>
|
| 600 |
+
|
| 601 |
+
<script>
|
| 602 |
+
let allProvidersData = [];
|
| 603 |
+
let currentTab = 'overview';
|
| 604 |
+
|
| 605 |
+
function switchTab(tabName) {
|
| 606 |
+
// Hide all tabs
|
| 607 |
+
document.querySelectorAll('.tab-content').forEach(tab => {
|
| 608 |
+
tab.classList.remove('active');
|
| 609 |
+
});
|
| 610 |
+
document.querySelectorAll('.tab').forEach(tab => {
|
| 611 |
+
tab.classList.remove('active');
|
| 612 |
+
});
|
| 613 |
+
|
| 614 |
+
// Show selected tab
|
| 615 |
+
document.getElementById(tabName).classList.add('active');
|
| 616 |
+
event.target.classList.add('active');
|
| 617 |
+
currentTab = tabName;
|
| 618 |
+
|
| 619 |
+
// Load data for specific tabs
|
| 620 |
+
if (tabName === 'market') {
|
| 621 |
+
loadMarketData();
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
async function loadProviders() {
|
| 626 |
+
try {
|
| 627 |
+
const response = await fetch('/api/providers');
|
| 628 |
+
const providers = await response.json();
|
| 629 |
+
allProvidersData = providers;
|
| 630 |
+
|
| 631 |
+
// Calculate stats
|
| 632 |
+
const online = providers.filter(p => p.status === 'online').length;
|
| 633 |
+
const offline = providers.filter(p => p.status === 'offline').length;
|
| 634 |
+
const degraded = providers.filter(p => p.status === 'degraded').length;
|
| 635 |
+
const uptime = ((online / providers.length) * 100).toFixed(1);
|
| 636 |
+
|
| 637 |
+
// Update stats
|
| 638 |
+
document.getElementById('totalProviders').textContent = providers.length;
|
| 639 |
+
document.getElementById('onlineProviders').textContent = online;
|
| 640 |
+
document.getElementById('degradedProviders').textContent = degraded;
|
| 641 |
+
document.getElementById('offlineProviders').textContent = offline;
|
| 642 |
+
document.getElementById('uptimePercent').textContent = uptime + '%';
|
| 643 |
+
|
| 644 |
+
// Calculate average response time
|
| 645 |
+
const responseTimes = providers.filter(p => p.response_time_ms).map(p => p.response_time_ms);
|
| 646 |
+
const avgResp = responseTimes.length > 0 ?
|
| 647 |
+
Math.round(responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length) : 0;
|
| 648 |
+
document.getElementById('avgResponse').textContent = avgResp + 'ms';
|
| 649 |
+
|
| 650 |
+
// Group by category
|
| 651 |
+
const categories = {};
|
| 652 |
+
providers.forEach(p => {
|
| 653 |
+
if (!categories[p.category]) {
|
| 654 |
+
categories[p.category] = { total: 0, online: 0, offline: 0, degraded: 0 };
|
| 655 |
+
}
|
| 656 |
+
categories[p.category].total++;
|
| 657 |
+
categories[p.category][p.status]++;
|
| 658 |
+
});
|
| 659 |
+
|
| 660 |
+
document.getElementById('totalCategories').textContent = Object.keys(categories).length;
|
| 661 |
+
document.getElementById('lastCheck').textContent = new Date().toLocaleTimeString();
|
| 662 |
+
|
| 663 |
+
// Display recent providers (first 10)
|
| 664 |
+
displayRecentProviders(providers.slice(0, 10));
|
| 665 |
+
|
| 666 |
+
// Display all providers
|
| 667 |
+
displayAllProviders(providers);
|
| 668 |
+
|
| 669 |
+
// Display categories
|
| 670 |
+
displayCategories(categories);
|
| 671 |
+
|
| 672 |
+
// Display health details
|
| 673 |
+
displayHealthDetails(providers);
|
| 674 |
+
|
| 675 |
+
} catch (error) {
|
| 676 |
+
console.error('Error loading providers:', error);
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
function displayRecentProviders(providers) {
|
| 681 |
+
const html = providers.map(p => `
|
| 682 |
+
<div class="provider-card ${p.status}">
|
| 683 |
+
<div class="name">${p.name}</div>
|
| 684 |
+
<div class="category">${p.category}</div>
|
| 685 |
+
<span class="status ${p.status}">${p.status}</span>
|
| 686 |
+
${p.response_time_ms ? `<div class="response-time">${Math.round(p.response_time_ms)}ms</div>` : ''}
|
| 687 |
+
</div>
|
| 688 |
+
`).join('');
|
| 689 |
+
document.getElementById('recentProviders').innerHTML = `<div class="providers-grid" style="max-height: 400px;">${html}</div>`;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
function displayAllProviders(providers) {
|
| 693 |
+
const html = providers.map(p => `
|
| 694 |
+
<div class="provider-card ${p.status}" data-name="${p.name.toLowerCase()}" data-category="${p.category.toLowerCase()}">
|
| 695 |
+
<div class="name">${p.name}</div>
|
| 696 |
+
<div class="category">${p.category}</div>
|
| 697 |
+
<span class="status ${p.status}">${p.status}</span>
|
| 698 |
+
${p.response_time_ms ? `<div class="response-time">⚡ ${Math.round(p.response_time_ms)}ms</div>` : ''}
|
| 699 |
+
</div>
|
| 700 |
+
`).join('');
|
| 701 |
+
document.getElementById('allProviders').innerHTML = html;
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
function displayCategories(categories) {
|
| 705 |
+
const html = Object.entries(categories).map(([name, stats]) => `
|
| 706 |
+
<div class="category-item">
|
| 707 |
+
<div class="name">${name}</div>
|
| 708 |
+
<div class="stats">
|
| 709 |
+
<div class="stat">
|
| 710 |
+
<span class="status-indicator online"></span>
|
| 711 |
+
<span>${stats.online} online</span>
|
| 712 |
+
</div>
|
| 713 |
+
<div class="stat">
|
| 714 |
+
<span class="status-indicator degraded"></span>
|
| 715 |
+
<span>${stats.degraded} degraded</span>
|
| 716 |
+
</div>
|
| 717 |
+
<div class="stat">
|
| 718 |
+
<span class="status-indicator offline"></span>
|
| 719 |
+
<span>${stats.offline} offline</span>
|
| 720 |
+
</div>
|
| 721 |
+
<div class="stat" style="margin-left: auto; color: #3b82f6; font-weight: 600;">
|
| 722 |
+
${stats.total} total
|
| 723 |
+
</div>
|
| 724 |
+
</div>
|
| 725 |
+
</div>
|
| 726 |
+
`).join('');
|
| 727 |
+
document.getElementById('categoriesList').innerHTML = html;
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
function displayHealthDetails(providers) {
|
| 731 |
+
const online = providers.filter(p => p.status === 'online');
|
| 732 |
+
const degraded = providers.filter(p => p.status === 'degraded');
|
| 733 |
+
const offline = providers.filter(p => p.status === 'offline');
|
| 734 |
+
|
| 735 |
+
const html = `
|
| 736 |
+
<div style="display: grid; gap: 20px;">
|
| 737 |
+
<div class="category-item" style="border-left-color: #10b981;">
|
| 738 |
+
<div class="name">✅ Online Providers (${online.length})</div>
|
| 739 |
+
<div style="color: #94a3b8; margin-top: 10px;">
|
| 740 |
+
${online.slice(0, 5).map(p => p.name).join(', ')}
|
| 741 |
+
${online.length > 5 ? ` and ${online.length - 5} more...` : ''}
|
| 742 |
+
</div>
|
| 743 |
+
</div>
|
| 744 |
+
<div class="category-item" style="border-left-color: #f59e0b;">
|
| 745 |
+
<div class="name">⚠️ Degraded Providers (${degraded.length})</div>
|
| 746 |
+
<div style="color: #94a3b8; margin-top: 10px;">
|
| 747 |
+
${degraded.length > 0 ? degraded.map(p => p.name).join(', ') : 'None'}
|
| 748 |
+
</div>
|
| 749 |
+
</div>
|
| 750 |
+
<div class="category-item" style="border-left-color: #ef4444;">
|
| 751 |
+
<div class="name">❌ Offline Providers (${offline.length})</div>
|
| 752 |
+
<div style="color: #94a3b8; margin-top: 10px;">
|
| 753 |
+
${offline.length > 0 ? offline.map(p => p.name).join(', ') : 'None'}
|
| 754 |
+
</div>
|
| 755 |
+
</div>
|
| 756 |
+
</div>
|
| 757 |
+
`;
|
| 758 |
+
document.getElementById('healthDetails').innerHTML = html;
|
| 759 |
+
|
| 760 |
+
const systemHealthHtml = `
|
| 761 |
+
<div style="display: grid; gap: 15px;">
|
| 762 |
+
<div style="padding: 15px; background: #0f172a; border-radius: 8px;">
|
| 763 |
+
<div style="color: #94a3b8; font-size: 14px; margin-bottom: 5px;">System Status</div>
|
| 764 |
+
<div style="font-size: 24px; font-weight: 600; color: ${online.length >= providers.length * 0.7 ? '#10b981' : '#f59e0b'};">
|
| 765 |
+
${online.length >= providers.length * 0.7 ? '✅ Healthy' : '⚠️ Degraded'}
|
| 766 |
+
</div>
|
| 767 |
+
</div>
|
| 768 |
+
<div style="padding: 15px; background: #0f172a; border-radius: 8px;">
|
| 769 |
+
<div style="color: #94a3b8; font-size: 14px; margin-bottom: 5px;">Availability</div>
|
| 770 |
+
<div style="font-size: 24px; font-weight: 600; color: #3b82f6;">
|
| 771 |
+
${((online.length / providers.length) * 100).toFixed(1)}%
|
| 772 |
+
</div>
|
| 773 |
+
</div>
|
| 774 |
+
<div style="padding: 15px; background: #0f172a; border-radius: 8px;">
|
| 775 |
+
<div style="color: #94a3b8; font-size: 14px; margin-bottom: 5px;">Total Checks</div>
|
| 776 |
+
<div style="font-size: 24px; font-weight: 600; color: #8b5cf6;">
|
| 777 |
+
${providers.length}
|
| 778 |
+
</div>
|
| 779 |
+
</div>
|
| 780 |
+
</div>
|
| 781 |
+
`;
|
| 782 |
+
document.getElementById('systemHealth').innerHTML = systemHealthHtml;
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
async function loadMarketData() {
|
| 786 |
+
try {
|
| 787 |
+
const response = await fetch('/api/market');
|
| 788 |
+
const data = await response.json();
|
| 789 |
+
|
| 790 |
+
if (data.cryptocurrencies && data.cryptocurrencies.length > 0) {
|
| 791 |
+
const html = data.cryptocurrencies.map(coin => `
|
| 792 |
+
<div class="market-item">
|
| 793 |
+
<div class="coin-info">
|
| 794 |
+
<div>
|
| 795 |
+
<div class="coin-name">${coin.name}</div>
|
| 796 |
+
<div class="coin-symbol">${coin.symbol}</div>
|
| 797 |
+
</div>
|
| 798 |
+
</div>
|
| 799 |
+
<div style="display: flex; align-items: center; gap: 20px;">
|
| 800 |
+
<div class="price">$${coin.price.toLocaleString()}</div>
|
| 801 |
+
<div class="change ${coin.change_24h >= 0 ? 'positive' : 'negative'}">
|
| 802 |
+
${coin.change_24h >= 0 ? '↑' : '↓'} ${Math.abs(coin.change_24h).toFixed(2)}%
|
| 803 |
+
</div>
|
| 804 |
+
</div>
|
| 805 |
+
</div>
|
| 806 |
+
`).join('');
|
| 807 |
+
document.getElementById('marketData').innerHTML = html;
|
| 808 |
+
} else {
|
| 809 |
+
document.getElementById('marketData').innerHTML = '<div class="empty-state"><h3>No market data available</h3><p>Market data providers may be offline</p></div>';
|
| 810 |
+
}
|
| 811 |
+
} catch (error) {
|
| 812 |
+
console.error('Error loading market data:', error);
|
| 813 |
+
document.getElementById('marketData').innerHTML = '<div class="empty-state"><h3>Error loading market data</h3></div>';
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
function filterProviders() {
|
| 818 |
+
const search = document.getElementById('providerSearch').value.toLowerCase();
|
| 819 |
+
const cards = document.querySelectorAll('#allProviders .provider-card');
|
| 820 |
+
|
| 821 |
+
cards.forEach(card => {
|
| 822 |
+
const name = card.getAttribute('data-name');
|
| 823 |
+
const category = card.getAttribute('data-category');
|
| 824 |
+
if (name.includes(search) || category.includes(search)) {
|
| 825 |
+
card.style.display = 'block';
|
| 826 |
+
} else {
|
| 827 |
+
card.style.display = 'none';
|
| 828 |
+
}
|
| 829 |
+
});
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
function refreshData() {
|
| 833 |
+
loadProviders();
|
| 834 |
+
if (currentTab === 'market') {
|
| 835 |
+
loadMarketData();
|
| 836 |
+
}
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
function exportData() {
|
| 840 |
+
const dataStr = JSON.stringify(allProvidersData, null, 2);
|
| 841 |
+
const dataBlob = new Blob([dataStr], {type: 'application/json'});
|
| 842 |
+
const url = URL.createObjectURL(dataBlob);
|
| 843 |
+
const link = document.createElement('a');
|
| 844 |
+
link.href = url;
|
| 845 |
+
link.download = `crypto-monitor-${new Date().toISOString()}.json`;
|
| 846 |
+
link.click();
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
// Load data on start
|
| 850 |
+
loadProviders();
|
| 851 |
+
|
| 852 |
+
// Auto-refresh every 30 seconds
|
| 853 |
+
setInterval(refreshData, 30000);
|
| 854 |
+
</script>
|
| 855 |
+
</body>
|
| 856 |
+
</html>
|
| 857 |
+
|
data/crypto_monitor.db
CHANGED
|
Binary files a/data/crypto_monitor.db and b/data/crypto_monitor.db differ
|
|
|
data/feature_flags.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"flags": {
|
| 3 |
+
"enableWhaleTracking": true,
|
| 4 |
+
"enableMarketOverview": true,
|
| 5 |
+
"enableFearGreedIndex": true,
|
| 6 |
+
"enableNewsFeed": true,
|
| 7 |
+
"enableSentimentAnalysis": true,
|
| 8 |
+
"enableMlPredictions": false,
|
| 9 |
+
"enableProxyAutoMode": true,
|
| 10 |
+
"enableDefiProtocols": true,
|
| 11 |
+
"enableTrendingCoins": true,
|
| 12 |
+
"enableGlobalStats": true,
|
| 13 |
+
"enableProviderRotation": true,
|
| 14 |
+
"enableWebSocketStreaming": true,
|
| 15 |
+
"enableDatabaseLogging": true,
|
| 16 |
+
"enableRealTimeAlerts": false,
|
| 17 |
+
"enableAdvancedCharts": true,
|
| 18 |
+
"enableExportFeatures": true,
|
| 19 |
+
"enableCustomProviders": true,
|
| 20 |
+
"enablePoolManagement": true,
|
| 21 |
+
"enableHFIntegration": true
|
| 22 |
+
},
|
| 23 |
+
"last_updated": "2025-11-14T09:54:35.418754"
|
| 24 |
+
}
|
database/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/database/__pycache__/__init__.cpython-313.pyc and b/database/__pycache__/__init__.cpython-313.pyc differ
|
|
|
database/__pycache__/data_access.cpython-313.pyc
CHANGED
|
Binary files a/database/__pycache__/data_access.cpython-313.pyc and b/database/__pycache__/data_access.cpython-313.pyc differ
|
|
|
database/__pycache__/db_manager.cpython-313.pyc
CHANGED
|
Binary files a/database/__pycache__/db_manager.cpython-313.pyc and b/database/__pycache__/db_manager.cpython-313.pyc differ
|
|
|
database/__pycache__/models.cpython-313.pyc
CHANGED
|
Binary files a/database/__pycache__/models.cpython-313.pyc and b/database/__pycache__/models.cpython-313.pyc differ
|
|
|
improved_dashboard.html
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Crypto Monitor - Complete Overview</title>
|
| 7 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 17 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
padding: 20px;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.container {
|
| 23 |
+
max-width: 1600px;
|
| 24 |
+
margin: 0 auto;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.header {
|
| 28 |
+
background: white;
|
| 29 |
+
border-radius: 15px;
|
| 30 |
+
padding: 30px;
|
| 31 |
+
margin-bottom: 20px;
|
| 32 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.header h1 {
|
| 36 |
+
color: #667eea;
|
| 37 |
+
font-size: 2.5em;
|
| 38 |
+
margin-bottom: 10px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.header p {
|
| 42 |
+
color: #666;
|
| 43 |
+
font-size: 1.1em;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.stats-grid {
|
| 47 |
+
display: grid;
|
| 48 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
| 49 |
+
gap: 20px;
|
| 50 |
+
margin-bottom: 20px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.stat-card {
|
| 54 |
+
background: white;
|
| 55 |
+
border-radius: 15px;
|
| 56 |
+
padding: 25px;
|
| 57 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
| 58 |
+
transition: transform 0.3s ease;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.stat-card:hover {
|
| 62 |
+
transform: translateY(-5px);
|
| 63 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.stat-card h3 {
|
| 67 |
+
color: #999;
|
| 68 |
+
font-size: 0.9em;
|
| 69 |
+
text-transform: uppercase;
|
| 70 |
+
margin-bottom: 10px;
|
| 71 |
+
font-weight: 600;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.stat-card .value {
|
| 75 |
+
font-size: 2.5em;
|
| 76 |
+
font-weight: bold;
|
| 77 |
+
margin-bottom: 5px;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.stat-card .label {
|
| 81 |
+
color: #666;
|
| 82 |
+
font-size: 0.9em;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.stat-card.green .value { color: #10b981; }
|
| 86 |
+
.stat-card.blue .value { color: #3b82f6; }
|
| 87 |
+
.stat-card.purple .value { color: #8b5cf6; }
|
| 88 |
+
.stat-card.orange .value { color: #f59e0b; }
|
| 89 |
+
.stat-card.red .value { color: #ef4444; }
|
| 90 |
+
|
| 91 |
+
.main-grid {
|
| 92 |
+
display: grid;
|
| 93 |
+
grid-template-columns: 2fr 1fr;
|
| 94 |
+
gap: 20px;
|
| 95 |
+
margin-bottom: 20px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.card {
|
| 99 |
+
background: white;
|
| 100 |
+
border-radius: 15px;
|
| 101 |
+
padding: 25px;
|
| 102 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.card h2 {
|
| 106 |
+
color: #333;
|
| 107 |
+
margin-bottom: 20px;
|
| 108 |
+
font-size: 1.5em;
|
| 109 |
+
border-bottom: 3px solid #667eea;
|
| 110 |
+
padding-bottom: 10px;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.providers-grid {
|
| 114 |
+
display: grid;
|
| 115 |
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
| 116 |
+
gap: 15px;
|
| 117 |
+
max-height: 500px;
|
| 118 |
+
overflow-y: auto;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.provider-card {
|
| 122 |
+
background: #f8f9fa;
|
| 123 |
+
border-radius: 10px;
|
| 124 |
+
padding: 15px;
|
| 125 |
+
border-left: 4px solid #ddd;
|
| 126 |
+
transition: all 0.3s ease;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.provider-card:hover {
|
| 130 |
+
transform: translateX(5px);
|
| 131 |
+
box-shadow: 0 3px 10px rgba(0,0,0,0.1);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.provider-card.online { border-left-color: #10b981; background: #f0fdf4; }
|
| 135 |
+
.provider-card.offline { border-left-color: #ef4444; background: #fef2f2; }
|
| 136 |
+
.provider-card.degraded { border-left-color: #f59e0b; background: #fffbeb; }
|
| 137 |
+
|
| 138 |
+
.provider-card .name {
|
| 139 |
+
font-weight: 600;
|
| 140 |
+
color: #333;
|
| 141 |
+
margin-bottom: 5px;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.provider-card .category {
|
| 145 |
+
font-size: 0.85em;
|
| 146 |
+
color: #666;
|
| 147 |
+
margin-bottom: 5px;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
.provider-card .status {
|
| 151 |
+
font-size: 0.8em;
|
| 152 |
+
padding: 3px 8px;
|
| 153 |
+
border-radius: 5px;
|
| 154 |
+
display: inline-block;
|
| 155 |
+
font-weight: 600;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.status.online { background: #10b981; color: white; }
|
| 159 |
+
.status.offline { background: #ef4444; color: white; }
|
| 160 |
+
.status.degraded { background: #f59e0b; color: white; }
|
| 161 |
+
|
| 162 |
+
.category-list {
|
| 163 |
+
display: flex;
|
| 164 |
+
flex-direction: column;
|
| 165 |
+
gap: 15px;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.category-item {
|
| 169 |
+
background: #f8f9fa;
|
| 170 |
+
border-radius: 10px;
|
| 171 |
+
padding: 15px;
|
| 172 |
+
border-left: 4px solid #667eea;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.category-item .cat-name {
|
| 176 |
+
font-weight: 600;
|
| 177 |
+
color: #333;
|
| 178 |
+
margin-bottom: 10px;
|
| 179 |
+
font-size: 1.1em;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.category-item .cat-stats {
|
| 183 |
+
display: flex;
|
| 184 |
+
gap: 15px;
|
| 185 |
+
font-size: 0.9em;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.category-item .cat-stat {
|
| 189 |
+
display: flex;
|
| 190 |
+
align-items: center;
|
| 191 |
+
gap: 5px;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.chart-container {
|
| 195 |
+
position: relative;
|
| 196 |
+
height: 300px;
|
| 197 |
+
margin-top: 20px;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.loading {
|
| 201 |
+
text-align: center;
|
| 202 |
+
padding: 40px;
|
| 203 |
+
color: #666;
|
| 204 |
+
font-size: 1.2em;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.refresh-btn {
|
| 208 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 209 |
+
color: white;
|
| 210 |
+
border: none;
|
| 211 |
+
padding: 12px 30px;
|
| 212 |
+
border-radius: 10px;
|
| 213 |
+
font-size: 1em;
|
| 214 |
+
font-weight: 600;
|
| 215 |
+
cursor: pointer;
|
| 216 |
+
transition: all 0.3s ease;
|
| 217 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.refresh-btn:hover {
|
| 221 |
+
transform: translateY(-2px);
|
| 222 |
+
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
.refresh-btn:active {
|
| 226 |
+
transform: translateY(0);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
@keyframes pulse {
|
| 230 |
+
0%, 100% { opacity: 1; }
|
| 231 |
+
50% { opacity: 0.5; }
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.updating {
|
| 235 |
+
animation: pulse 1.5s ease-in-out infinite;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.full-width {
|
| 239 |
+
grid-column: 1 / -1;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
@media (max-width: 768px) {
|
| 243 |
+
.main-grid {
|
| 244 |
+
grid-template-columns: 1fr;
|
| 245 |
+
}
|
| 246 |
+
.stats-grid {
|
| 247 |
+
grid-template-columns: 1fr;
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
</style>
|
| 251 |
+
</head>
|
| 252 |
+
<body>
|
| 253 |
+
<div class="container">
|
| 254 |
+
<div class="header">
|
| 255 |
+
<h1>🚀 Crypto API Monitor</h1>
|
| 256 |
+
<p>Complete Real-Time Overview of All Cryptocurrency Data Sources</p>
|
| 257 |
+
<button class="refresh-btn" onclick="refreshAll()">🔄 Refresh Data</button>
|
| 258 |
+
</div>
|
| 259 |
+
|
| 260 |
+
<div class="stats-grid">
|
| 261 |
+
<div class="stat-card green">
|
| 262 |
+
<h3>Total Providers</h3>
|
| 263 |
+
<div class="value" id="totalProviders">-</div>
|
| 264 |
+
<div class="label">API Sources</div>
|
| 265 |
+
</div>
|
| 266 |
+
<div class="stat-card blue">
|
| 267 |
+
<h3>Online</h3>
|
| 268 |
+
<div class="value" id="onlineProviders">-</div>
|
| 269 |
+
<div class="label">Active & Working</div>
|
| 270 |
+
</div>
|
| 271 |
+
<div class="stat-card orange">
|
| 272 |
+
<h3>Degraded</h3>
|
| 273 |
+
<div class="value" id="degradedProviders">-</div>
|
| 274 |
+
<div class="label">Slow Response</div>
|
| 275 |
+
</div>
|
| 276 |
+
<div class="stat-card red">
|
| 277 |
+
<h3>Offline</h3>
|
| 278 |
+
<div class="value" id="offlineProviders">-</div>
|
| 279 |
+
<div class="label">Not Responding</div>
|
| 280 |
+
</div>
|
| 281 |
+
<div class="stat-card purple">
|
| 282 |
+
<h3>Categories</h3>
|
| 283 |
+
<div class="value" id="totalCategories">-</div>
|
| 284 |
+
<div class="label">Data Types</div>
|
| 285 |
+
</div>
|
| 286 |
+
<div class="stat-card green">
|
| 287 |
+
<h3>Uptime</h3>
|
| 288 |
+
<div class="value" id="uptimePercent">-</div>
|
| 289 |
+
<div class="label">Overall Health</div>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
|
| 293 |
+
<div class="main-grid">
|
| 294 |
+
<div class="card">
|
| 295 |
+
<h2>📊 All Providers Status</h2>
|
| 296 |
+
<div class="providers-grid" id="providersGrid">
|
| 297 |
+
<div class="loading">Loading providers...</div>
|
| 298 |
+
</div>
|
| 299 |
+
</div>
|
| 300 |
+
|
| 301 |
+
<div class="card">
|
| 302 |
+
<h2>📁 Categories</h2>
|
| 303 |
+
<div class="category-list" id="categoryList">
|
| 304 |
+
<div class="loading">Loading categories...</div>
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
</div>
|
| 308 |
+
|
| 309 |
+
<div class="card full-width">
|
| 310 |
+
<h2>📈 Status Distribution</h2>
|
| 311 |
+
<div class="chart-container">
|
| 312 |
+
<canvas id="statusChart"></canvas>
|
| 313 |
+
</div>
|
| 314 |
+
</div>
|
| 315 |
+
</div>
|
| 316 |
+
|
| 317 |
+
<script>
|
| 318 |
+
let statusChart = null;
|
| 319 |
+
|
| 320 |
+
async function loadProviders() {
|
| 321 |
+
try {
|
| 322 |
+
const response = await fetch('/api/providers');
|
| 323 |
+
const providers = await response.json();
|
| 324 |
+
|
| 325 |
+
// Update stats
|
| 326 |
+
const online = providers.filter(p => p.status === 'online').length;
|
| 327 |
+
const offline = providers.filter(p => p.status === 'offline').length;
|
| 328 |
+
const degraded = providers.filter(p => p.status === 'degraded').length;
|
| 329 |
+
const uptime = ((online / providers.length) * 100).toFixed(1);
|
| 330 |
+
|
| 331 |
+
document.getElementById('totalProviders').textContent = providers.length;
|
| 332 |
+
document.getElementById('onlineProviders').textContent = online;
|
| 333 |
+
document.getElementById('degradedProviders').textContent = degraded;
|
| 334 |
+
document.getElementById('offlineProviders').textContent = offline;
|
| 335 |
+
document.getElementById('uptimePercent').textContent = uptime + '%';
|
| 336 |
+
|
| 337 |
+
// Group by category
|
| 338 |
+
const categories = {};
|
| 339 |
+
providers.forEach(p => {
|
| 340 |
+
if (!categories[p.category]) {
|
| 341 |
+
categories[p.category] = { total: 0, online: 0, offline: 0, degraded: 0 };
|
| 342 |
+
}
|
| 343 |
+
categories[p.category].total++;
|
| 344 |
+
categories[p.category][p.status]++;
|
| 345 |
+
});
|
| 346 |
+
|
| 347 |
+
document.getElementById('totalCategories').textContent = Object.keys(categories).length;
|
| 348 |
+
|
| 349 |
+
// Display providers
|
| 350 |
+
const providersGrid = document.getElementById('providersGrid');
|
| 351 |
+
providersGrid.innerHTML = providers.map(p => `
|
| 352 |
+
<div class="provider-card ${p.status}">
|
| 353 |
+
<div class="name">${p.name}</div>
|
| 354 |
+
<div class="category">${p.category}</div>
|
| 355 |
+
<span class="status ${p.status}">${p.status.toUpperCase()}</span>
|
| 356 |
+
${p.response_time_ms ? `<div style="font-size: 0.8em; color: #666; margin-top: 5px;">${Math.round(p.response_time_ms)}ms</div>` : ''}
|
| 357 |
+
</div>
|
| 358 |
+
`).join('');
|
| 359 |
+
|
| 360 |
+
// Display categories
|
| 361 |
+
const categoryList = document.getElementById('categoryList');
|
| 362 |
+
categoryList.innerHTML = Object.entries(categories).map(([name, stats]) => `
|
| 363 |
+
<div class="category-item">
|
| 364 |
+
<div class="cat-name">${name}</div>
|
| 365 |
+
<div class="cat-stats">
|
| 366 |
+
<div class="cat-stat">
|
| 367 |
+
<span style="color: #10b981;">●</span>
|
| 368 |
+
<span>${stats.online} online</span>
|
| 369 |
+
</div>
|
| 370 |
+
<div class="cat-stat">
|
| 371 |
+
<span style="color: #f59e0b;">●</span>
|
| 372 |
+
<span>${stats.degraded} degraded</span>
|
| 373 |
+
</div>
|
| 374 |
+
<div class="cat-stat">
|
| 375 |
+
<span style="color: #ef4444;">●</span>
|
| 376 |
+
<span>${stats.offline} offline</span>
|
| 377 |
+
</div>
|
| 378 |
+
</div>
|
| 379 |
+
</div>
|
| 380 |
+
`).join('');
|
| 381 |
+
|
| 382 |
+
// Update chart
|
| 383 |
+
updateChart(online, degraded, offline);
|
| 384 |
+
|
| 385 |
+
} catch (error) {
|
| 386 |
+
console.error('Error loading providers:', error);
|
| 387 |
+
document.getElementById('providersGrid').innerHTML = '<div class="loading">Error loading data</div>';
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
function updateChart(online, degraded, offline) {
|
| 392 |
+
const ctx = document.getElementById('statusChart').getContext('2d');
|
| 393 |
+
|
| 394 |
+
if (statusChart) {
|
| 395 |
+
statusChart.destroy();
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
statusChart = new Chart(ctx, {
|
| 399 |
+
type: 'doughnut',
|
| 400 |
+
data: {
|
| 401 |
+
labels: ['Online', 'Degraded', 'Offline'],
|
| 402 |
+
datasets: [{
|
| 403 |
+
data: [online, degraded, offline],
|
| 404 |
+
backgroundColor: ['#10b981', '#f59e0b', '#ef4444'],
|
| 405 |
+
borderWidth: 0
|
| 406 |
+
}]
|
| 407 |
+
},
|
| 408 |
+
options: {
|
| 409 |
+
responsive: true,
|
| 410 |
+
maintainAspectRatio: false,
|
| 411 |
+
plugins: {
|
| 412 |
+
legend: {
|
| 413 |
+
position: 'bottom',
|
| 414 |
+
labels: {
|
| 415 |
+
font: { size: 14 },
|
| 416 |
+
padding: 20
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
});
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
async function refreshAll() {
|
| 425 |
+
const btn = document.querySelector('.refresh-btn');
|
| 426 |
+
btn.classList.add('updating');
|
| 427 |
+
btn.textContent = '⏳ Refreshing...';
|
| 428 |
+
|
| 429 |
+
await loadProviders();
|
| 430 |
+
|
| 431 |
+
btn.classList.remove('updating');
|
| 432 |
+
btn.textContent = '🔄 Refresh Data';
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
// Load on page load
|
| 436 |
+
loadProviders();
|
| 437 |
+
|
| 438 |
+
// Auto-refresh every 30 seconds
|
| 439 |
+
setInterval(loadProviders, 30000);
|
| 440 |
+
</script>
|
| 441 |
+
</body>
|
| 442 |
+
</html>
|
| 443 |
+
|
index.html
CHANGED
|
@@ -1,54 +1,1216 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Crypto API Monitor</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
* { box-sizing: border-box; }
|
| 11 |
+
:root {
|
| 12 |
+
--bg: #f5f6fb;
|
| 13 |
+
--card: #ffffff;
|
| 14 |
+
--muted: #6b7280;
|
| 15 |
+
--text: #1f2937;
|
| 16 |
+
--primary: #2563eb;
|
| 17 |
+
--success: #16a34a;
|
| 18 |
+
--danger: #dc2626;
|
| 19 |
+
--warning: #d97706;
|
| 20 |
+
--border: #e5e7eb;
|
| 21 |
+
}
|
| 22 |
+
body {
|
| 23 |
+
margin: 0;
|
| 24 |
+
font-family: 'Inter', sans-serif;
|
| 25 |
+
background: var(--bg);
|
| 26 |
+
color: var(--text);
|
| 27 |
+
}
|
| 28 |
+
.container {
|
| 29 |
+
max-width: 1400px;
|
| 30 |
+
margin: 0 auto;
|
| 31 |
+
padding: 20px;
|
| 32 |
+
}
|
| 33 |
+
.header {
|
| 34 |
+
background: var(--card);
|
| 35 |
+
padding: 18px 24px;
|
| 36 |
+
border-radius: 10px;
|
| 37 |
+
box-shadow: 0 1px 3px rgba(15,23,42,0.08);
|
| 38 |
+
display: flex;
|
| 39 |
+
justify-content: space-between;
|
| 40 |
+
align-items: center;
|
| 41 |
+
flex-wrap: wrap;
|
| 42 |
+
gap: 16px;
|
| 43 |
+
}
|
| 44 |
+
.logo h1 { margin: 0; font-size: 20px; color: var(--primary); }
|
| 45 |
+
.header-actions { display: flex; gap: 12px; align-items: center; }
|
| 46 |
+
.status-pill {
|
| 47 |
+
padding: 6px 12px;
|
| 48 |
+
border-radius: 999px;
|
| 49 |
+
font-size: 12px;
|
| 50 |
+
font-weight: 600;
|
| 51 |
+
background: #fee2e2;
|
| 52 |
+
color: var(--danger);
|
| 53 |
+
}
|
| 54 |
+
.btn {
|
| 55 |
+
padding: 10px 18px;
|
| 56 |
+
border-radius: 8px;
|
| 57 |
+
border: none;
|
| 58 |
+
font-weight: 600;
|
| 59 |
+
font-size: 13px;
|
| 60 |
+
cursor: pointer;
|
| 61 |
+
background: var(--primary);
|
| 62 |
+
color: #fff;
|
| 63 |
+
transition: all 0.2s ease;
|
| 64 |
+
display: inline-flex;
|
| 65 |
+
align-items: center;
|
| 66 |
+
gap: 6px;
|
| 67 |
+
box-shadow: 0 2px 4px rgba(37,99,235,0.2);
|
| 68 |
+
}
|
| 69 |
+
.btn:hover {
|
| 70 |
+
background: #1d4ed8;
|
| 71 |
+
transform: translateY(-1px);
|
| 72 |
+
box-shadow: 0 4px 8px rgba(37,99,235,0.3);
|
| 73 |
+
}
|
| 74 |
+
.btn:active {
|
| 75 |
+
transform: translateY(0);
|
| 76 |
+
box-shadow: 0 1px 2px rgba(37,99,235,0.2);
|
| 77 |
+
}
|
| 78 |
+
.btn.secondary {
|
| 79 |
+
background: var(--card);
|
| 80 |
+
border: 1px solid var(--border);
|
| 81 |
+
color: var(--text);
|
| 82 |
+
box-shadow: 0 1px 2px rgba(15,23,42,0.1);
|
| 83 |
+
}
|
| 84 |
+
.btn.secondary:hover {
|
| 85 |
+
background: #f9fafb;
|
| 86 |
+
border-color: var(--primary);
|
| 87 |
+
color: var(--primary);
|
| 88 |
+
box-shadow: 0 2px 4px rgba(37,99,235,0.15);
|
| 89 |
+
}
|
| 90 |
+
.kpi-grid {
|
| 91 |
+
display: grid;
|
| 92 |
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
| 93 |
+
gap: 10px;
|
| 94 |
+
margin: 16px 0;
|
| 95 |
+
}
|
| 96 |
+
.kpi-card {
|
| 97 |
+
background: var(--card);
|
| 98 |
+
padding: 14px;
|
| 99 |
+
border-radius: 8px;
|
| 100 |
+
box-shadow: 0 1px 3px rgba(15,23,42,0.08);
|
| 101 |
+
border: 1px solid var(--border);
|
| 102 |
+
transition: all 0.2s ease;
|
| 103 |
+
display: flex;
|
| 104 |
+
flex-direction: column;
|
| 105 |
+
gap: 8px;
|
| 106 |
+
}
|
| 107 |
+
.kpi-card:hover {
|
| 108 |
+
box-shadow: 0 4px 12px rgba(37,99,235,0.15);
|
| 109 |
+
transform: translateY(-2px);
|
| 110 |
+
border-color: var(--primary);
|
| 111 |
+
}
|
| 112 |
+
.kpi-header {
|
| 113 |
+
display: flex;
|
| 114 |
+
align-items: center;
|
| 115 |
+
justify-content: space-between;
|
| 116 |
+
gap: 8px;
|
| 117 |
+
}
|
| 118 |
+
.kpi-icon {
|
| 119 |
+
width: 32px;
|
| 120 |
+
height: 32px;
|
| 121 |
+
padding: 6px;
|
| 122 |
+
border-radius: 6px;
|
| 123 |
+
display: flex;
|
| 124 |
+
align-items: center;
|
| 125 |
+
justify-content: center;
|
| 126 |
+
flex-shrink: 0;
|
| 127 |
+
}
|
| 128 |
+
.kpi-icon svg {
|
| 129 |
+
width: 20px;
|
| 130 |
+
height: 20px;
|
| 131 |
+
stroke-width: 2;
|
| 132 |
+
}
|
| 133 |
+
.kpi-icon.blue { background: #dbeafe; color: #2563eb; }
|
| 134 |
+
.kpi-icon.green { background: #dcfce7; color: #16a34a; }
|
| 135 |
+
.kpi-icon.orange { background: #fed7aa; color: #ea580c; }
|
| 136 |
+
.kpi-icon.purple { background: #e9d5ff; color: #9333ea; }
|
| 137 |
+
.kpi-label {
|
| 138 |
+
font-size: 11px;
|
| 139 |
+
color: var(--muted);
|
| 140 |
+
letter-spacing: 0.3px;
|
| 141 |
+
text-transform: uppercase;
|
| 142 |
+
font-weight: 600;
|
| 143 |
+
flex: 1;
|
| 144 |
+
}
|
| 145 |
+
.kpi-value {
|
| 146 |
+
font-size: 24px;
|
| 147 |
+
font-weight: 700;
|
| 148 |
+
color: var(--text);
|
| 149 |
+
line-height: 1.2;
|
| 150 |
+
}
|
| 151 |
+
.kpi-trend {
|
| 152 |
+
font-size: 11px;
|
| 153 |
+
color: var(--muted);
|
| 154 |
+
display: flex;
|
| 155 |
+
align-items: center;
|
| 156 |
+
gap: 4px;
|
| 157 |
+
}
|
| 158 |
+
.tabs {
|
| 159 |
+
background: var(--card);
|
| 160 |
+
border-radius: 10px;
|
| 161 |
+
padding: 8px;
|
| 162 |
+
display: flex;
|
| 163 |
+
gap: 6px;
|
| 164 |
+
overflow-x: auto;
|
| 165 |
+
box-shadow: 0 1px 3px rgba(15,23,42,0.08);
|
| 166 |
+
}
|
| 167 |
+
.tab {
|
| 168 |
+
border: none;
|
| 169 |
+
background: transparent;
|
| 170 |
+
padding: 8px 16px;
|
| 171 |
+
border-radius: 6px;
|
| 172 |
+
font-weight: 600;
|
| 173 |
+
color: var(--muted);
|
| 174 |
+
cursor: pointer;
|
| 175 |
+
}
|
| 176 |
+
.tab.active { background: var(--primary); color: #fff; }
|
| 177 |
+
.tab-content { margin-top: 16px; display: none; }
|
| 178 |
+
.tab-content.active { display: block; }
|
| 179 |
+
.card {
|
| 180 |
+
background: var(--card);
|
| 181 |
+
border-radius: 12px;
|
| 182 |
+
padding: 20px;
|
| 183 |
+
box-shadow: 0 1px 3px rgba(15,23,42,0.08);
|
| 184 |
+
border: 1px solid var(--border);
|
| 185 |
+
margin-bottom: 16px;
|
| 186 |
+
transition: all 0.2s ease;
|
| 187 |
+
}
|
| 188 |
+
.card:hover {
|
| 189 |
+
box-shadow: 0 4px 12px rgba(15,23,42,0.12);
|
| 190 |
+
border-color: rgba(37,99,235,0.2);
|
| 191 |
+
}
|
| 192 |
+
.card-header {
|
| 193 |
+
display: flex;
|
| 194 |
+
justify-content: space-between;
|
| 195 |
+
align-items: center;
|
| 196 |
+
margin-bottom: 16px;
|
| 197 |
+
padding-bottom: 12px;
|
| 198 |
+
border-bottom: 2px solid var(--border);
|
| 199 |
+
}
|
| 200 |
+
.card-title {
|
| 201 |
+
font-size: 16px;
|
| 202 |
+
font-weight: 700;
|
| 203 |
+
color: var(--text);
|
| 204 |
+
display: flex;
|
| 205 |
+
align-items: center;
|
| 206 |
+
gap: 8px;
|
| 207 |
+
}
|
| 208 |
+
.grid { display: grid; gap: 16px; }
|
| 209 |
+
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
|
| 210 |
+
.table-wrapper {
|
| 211 |
+
overflow-x: auto;
|
| 212 |
+
border-radius: 8px;
|
| 213 |
+
border: 1px solid var(--border);
|
| 214 |
+
}
|
| 215 |
+
table {
|
| 216 |
+
width: 100%;
|
| 217 |
+
border-collapse: separate;
|
| 218 |
+
border-spacing: 0;
|
| 219 |
+
font-size: 13px;
|
| 220 |
+
}
|
| 221 |
+
thead {
|
| 222 |
+
background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
|
| 223 |
+
position: sticky;
|
| 224 |
+
top: 0;
|
| 225 |
+
z-index: 10;
|
| 226 |
+
}
|
| 227 |
+
thead th {
|
| 228 |
+
padding: 14px 16px;
|
| 229 |
+
text-align: left;
|
| 230 |
+
font-weight: 700;
|
| 231 |
+
font-size: 11px;
|
| 232 |
+
text-transform: uppercase;
|
| 233 |
+
letter-spacing: 0.5px;
|
| 234 |
+
color: var(--muted);
|
| 235 |
+
border-bottom: 2px solid var(--border);
|
| 236 |
+
white-space: nowrap;
|
| 237 |
+
}
|
| 238 |
+
thead th:first-child { border-top-left-radius: 8px; }
|
| 239 |
+
thead th:last-child { border-top-right-radius: 8px; }
|
| 240 |
+
tbody tr {
|
| 241 |
+
transition: all 0.15s ease;
|
| 242 |
+
border-bottom: 1px solid #f3f4f6;
|
| 243 |
+
}
|
| 244 |
+
tbody tr:hover {
|
| 245 |
+
background: #f9fafb;
|
| 246 |
+
transform: scale(1.001);
|
| 247 |
+
box-shadow: 0 2px 8px rgba(37,99,235,0.08);
|
| 248 |
+
}
|
| 249 |
+
tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
|
| 250 |
+
tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
|
| 251 |
+
tbody td {
|
| 252 |
+
padding: 14px 16px;
|
| 253 |
+
color: var(--text);
|
| 254 |
+
vertical-align: middle;
|
| 255 |
+
}
|
| 256 |
+
tbody td strong {
|
| 257 |
+
font-weight: 600;
|
| 258 |
+
color: var(--text);
|
| 259 |
+
}
|
| 260 |
+
tbody td:first-child {
|
| 261 |
+
font-weight: 600;
|
| 262 |
+
}
|
| 263 |
+
.badge {
|
| 264 |
+
padding: 5px 12px;
|
| 265 |
+
border-radius: 6px;
|
| 266 |
+
font-size: 11px;
|
| 267 |
+
font-weight: 700;
|
| 268 |
+
display: inline-flex;
|
| 269 |
+
align-items: center;
|
| 270 |
+
gap: 5px;
|
| 271 |
+
text-transform: uppercase;
|
| 272 |
+
letter-spacing: 0.3px;
|
| 273 |
+
border: 1px solid transparent;
|
| 274 |
+
transition: all 0.2s ease;
|
| 275 |
+
}
|
| 276 |
+
.badge.success {
|
| 277 |
+
background: #dcfce7;
|
| 278 |
+
color: #15803d;
|
| 279 |
+
border-color: #86efac;
|
| 280 |
+
}
|
| 281 |
+
.badge.warn {
|
| 282 |
+
background: #fef3c7;
|
| 283 |
+
color: #d97706;
|
| 284 |
+
border-color: #fde047;
|
| 285 |
+
}
|
| 286 |
+
.badge.danger {
|
| 287 |
+
background: #fee2e2;
|
| 288 |
+
color: #b91c1c;
|
| 289 |
+
border-color: #fca5a5;
|
| 290 |
+
}
|
| 291 |
+
.badge.info {
|
| 292 |
+
background: #dbeafe;
|
| 293 |
+
color: #1e40af;
|
| 294 |
+
border-color: #93c5fd;
|
| 295 |
+
}
|
| 296 |
+
.list {
|
| 297 |
+
display: flex;
|
| 298 |
+
flex-direction: column;
|
| 299 |
+
gap: 10px;
|
| 300 |
+
}
|
| 301 |
+
.list-item {
|
| 302 |
+
padding: 12px;
|
| 303 |
+
border-radius: 8px;
|
| 304 |
+
border: 1px solid var(--border);
|
| 305 |
+
background: var(--card);
|
| 306 |
+
transition: all 0.15s ease;
|
| 307 |
+
}
|
| 308 |
+
.list-item:hover {
|
| 309 |
+
background: #f9fafb;
|
| 310 |
+
border-color: var(--primary);
|
| 311 |
+
transform: translateX(2px);
|
| 312 |
+
box-shadow: 0 2px 8px rgba(37,99,235,0.1);
|
| 313 |
+
}
|
| 314 |
+
.list-item:last-child {
|
| 315 |
+
margin-bottom: 0;
|
| 316 |
+
}
|
| 317 |
+
.resource-search { display: flex; gap: 12px; }
|
| 318 |
+
.resource-search input {
|
| 319 |
+
flex: 1;
|
| 320 |
+
padding: 10px 12px;
|
| 321 |
+
border-radius: 6px;
|
| 322 |
+
border: 1px solid var(--border);
|
| 323 |
+
font-size: 14px;
|
| 324 |
+
}
|
| 325 |
+
.resource-columns {
|
| 326 |
+
display: grid;
|
| 327 |
+
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
| 328 |
+
gap: 12px;
|
| 329 |
+
margin-top: 16px;
|
| 330 |
+
}
|
| 331 |
+
.resource-item {
|
| 332 |
+
padding: 10px;
|
| 333 |
+
border: 1px solid var(--border);
|
| 334 |
+
border-radius: 6px;
|
| 335 |
+
margin-bottom: 8px;
|
| 336 |
+
font-size: 13px;
|
| 337 |
+
}
|
| 338 |
+
.form-grid {
|
| 339 |
+
display: grid;
|
| 340 |
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
| 341 |
+
gap: 10px;
|
| 342 |
+
}
|
| 343 |
+
label { font-size: 12px; font-weight: 600; color: var(--muted); }
|
| 344 |
+
input, textarea, select {
|
| 345 |
+
width: 100%;
|
| 346 |
+
padding: 10px 14px;
|
| 347 |
+
border: 1px solid var(--border);
|
| 348 |
+
border-radius: 8px;
|
| 349 |
+
font-size: 14px;
|
| 350 |
+
font-family: inherit;
|
| 351 |
+
background: var(--card);
|
| 352 |
+
color: var(--text);
|
| 353 |
+
transition: all 0.2s ease;
|
| 354 |
+
}
|
| 355 |
+
input:focus, textarea:focus, select:focus {
|
| 356 |
+
outline: none;
|
| 357 |
+
border-color: var(--primary);
|
| 358 |
+
box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
|
| 359 |
+
}
|
| 360 |
+
input:hover, textarea:hover, select:hover {
|
| 361 |
+
border-color: rgba(37,99,235,0.3);
|
| 362 |
+
}
|
| 363 |
+
textarea {
|
| 364 |
+
min-height: 120px;
|
| 365 |
+
resize: vertical;
|
| 366 |
+
font-family: 'Monaco', 'Courier New', monospace;
|
| 367 |
+
font-size: 13px;
|
| 368 |
+
}
|
| 369 |
+
.toast-container {
|
| 370 |
+
position: fixed;
|
| 371 |
+
bottom: 20px;
|
| 372 |
+
right: 20px;
|
| 373 |
+
display: flex;
|
| 374 |
+
flex-direction: column;
|
| 375 |
+
gap: 10px;
|
| 376 |
+
}
|
| 377 |
+
.toast {
|
| 378 |
+
background: #111827;
|
| 379 |
+
color: white;
|
| 380 |
+
padding: 12px 16px;
|
| 381 |
+
border-radius: 6px;
|
| 382 |
+
min-width: 240px;
|
| 383 |
+
box-shadow: 0 8px 20px rgba(15,23,42,0.25);
|
| 384 |
+
}
|
| 385 |
+
@media (max-width: 720px) {
|
| 386 |
+
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
|
| 387 |
+
.grid-2 { grid-template-columns: 1fr; }
|
| 388 |
+
.resource-search { flex-direction: column; }
|
| 389 |
+
}
|
| 390 |
+
</style>
|
| 391 |
+
</head>
|
| 392 |
+
<body>
|
| 393 |
+
<div class="toast-container" id="toastContainer"></div>
|
| 394 |
+
<div class="container">
|
| 395 |
+
<div class="header">
|
| 396 |
+
<div class="logo">
|
| 397 |
+
<h1>🚀 Crypto API Monitor</h1>
|
| 398 |
+
<div style="font-size:12px; color:var(--muted);">Real API diagnostics + market intelligence</div>
|
| 399 |
+
</div>
|
| 400 |
+
<div class="header-actions">
|
| 401 |
+
<div class="status-pill" id="wsStatus">Connecting...</div>
|
| 402 |
+
<button class="btn secondary" onclick="refreshAll()">Refresh</button>
|
| 403 |
+
<button class="btn" onclick="loadErrorSummary()">Diagnostics</button>
|
| 404 |
+
</div>
|
| 405 |
+
</div>
|
| 406 |
+
|
| 407 |
+
<div class="kpi-grid">
|
| 408 |
+
<div class="kpi-card">
|
| 409 |
+
<div class="kpi-header">
|
| 410 |
+
<div class="kpi-label">Total APIs</div>
|
| 411 |
+
<div class="kpi-icon blue">
|
| 412 |
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 413 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
| 414 |
+
</svg>
|
| 415 |
+
</div>
|
| 416 |
+
</div>
|
| 417 |
+
<div class="kpi-value" id="kpiTotalAPIs">--</div>
|
| 418 |
+
<div class="kpi-trend" id="kpiTotalTrend">Loading…</div>
|
| 419 |
+
</div>
|
| 420 |
+
<div class="kpi-card">
|
| 421 |
+
<div class="kpi-header">
|
| 422 |
+
<div class="kpi-label">Online</div>
|
| 423 |
+
<div class="kpi-icon green">
|
| 424 |
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 425 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
| 426 |
+
</svg>
|
| 427 |
+
</div>
|
| 428 |
+
</div>
|
| 429 |
+
<div class="kpi-value" id="kpiOnline">--</div>
|
| 430 |
+
<div class="kpi-trend" id="kpiOnlineTrend">Loading…</div>
|
| 431 |
+
</div>
|
| 432 |
+
<div class="kpi-card">
|
| 433 |
+
<div class="kpi-header">
|
| 434 |
+
<div class="kpi-label">Avg Response</div>
|
| 435 |
+
<div class="kpi-icon orange">
|
| 436 |
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 437 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z"/>
|
| 438 |
+
</svg>
|
| 439 |
+
</div>
|
| 440 |
+
</div>
|
| 441 |
+
<div class="kpi-value" id="kpiAvgResponse">--</div>
|
| 442 |
+
<div class="kpi-trend" id="kpiResponseTrend">Loading…</div>
|
| 443 |
+
</div>
|
| 444 |
+
<div class="kpi-card">
|
| 445 |
+
<div class="kpi-header">
|
| 446 |
+
<div class="kpi-label">Last Update</div>
|
| 447 |
+
<div class="kpi-icon purple">
|
| 448 |
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 449 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
| 450 |
+
</svg>
|
| 451 |
+
</div>
|
| 452 |
+
</div>
|
| 453 |
+
<div class="kpi-value" id="kpiLastUpdate" style="font-size:16px;">--</div>
|
| 454 |
+
<div class="kpi-trend">Auto-refresh</div>
|
| 455 |
+
</div>
|
| 456 |
+
</div>
|
| 457 |
+
|
| 458 |
+
<div class="tabs" id="tabBar">
|
| 459 |
+
<button class="tab active" data-tab="dashboard" onclick="switchTab(event, 'dashboard')">Dashboard</button>
|
| 460 |
+
<button class="tab" data-tab="providers" onclick="switchTab(event, 'providers')">Providers</button>
|
| 461 |
+
<button class="tab" data-tab="market" onclick="switchTab(event, 'market')">Market</button>
|
| 462 |
+
<button class="tab" data-tab="sentiment" onclick="switchTab(event, 'sentiment')">Sentiment</button>
|
| 463 |
+
<button class="tab" data-tab="news" onclick="switchTab(event, 'news')">News</button>
|
| 464 |
+
<button class="tab" data-tab="resources" onclick="switchTab(event, 'resources')">Resources & Tools</button>
|
| 465 |
+
</div>
|
| 466 |
+
|
| 467 |
+
<div class="tab-content active" id="tab-dashboard">
|
| 468 |
+
<div class="grid grid-2">
|
| 469 |
+
<div class="card">
|
| 470 |
+
<div class="card-header">
|
| 471 |
+
<h3 class="card-title">Provider Overview</h3>
|
| 472 |
+
<button class="btn secondary" onclick="loadProviders()">Reload</button>
|
| 473 |
+
</div>
|
| 474 |
+
<div class="table-wrapper" style="overflow:auto;">
|
| 475 |
+
<table>
|
| 476 |
+
<thead>
|
| 477 |
+
<tr><th>Provider</th><th>Status</th><th>Response</th><th>Uptime</th></tr>
|
| 478 |
+
</thead>
|
| 479 |
+
<tbody id="providersTableBody">
|
| 480 |
+
<tr><td colspan="4" style="text-align:center; padding:40px; color:var(--muted);">Loading providers…</td></tr>
|
| 481 |
+
</tbody>
|
| 482 |
+
</table>
|
| 483 |
+
</div>
|
| 484 |
+
</div>
|
| 485 |
+
<div class="card">
|
| 486 |
+
<div class="card-header">
|
| 487 |
+
<h3 class="card-title">Error Monitor</h3>
|
| 488 |
+
<button class="btn secondary" onclick="loadErrorSummary()">Refresh</button>
|
| 489 |
+
</div>
|
| 490 |
+
<div id="errorSummaryCard" style="font-size:13px; color:var(--muted);">Gathering diagnostics…</div>
|
| 491 |
+
<div id="diagnosticsList" class="list" style="margin-top:12px;"></div>
|
| 492 |
+
</div>
|
| 493 |
+
</div>
|
| 494 |
+
<div class="grid grid-2">
|
| 495 |
+
<div class="card">
|
| 496 |
+
<div class="card-header"><h3 class="card-title">Health Trend</h3></div>
|
| 497 |
+
<div style="height:260px;"><canvas id="healthChart"></canvas></div>
|
| 498 |
+
</div>
|
| 499 |
+
<div class="card">
|
| 500 |
+
<div class="card-header"><h3 class="card-title">Status Distribution</h3></div>
|
| 501 |
+
<div style="height:260px;"><canvas id="statusChart"></canvas></div>
|
| 502 |
+
</div>
|
| 503 |
+
</div>
|
| 504 |
+
</div>
|
| 505 |
+
|
| 506 |
+
<div class="tab-content" id="tab-providers">
|
| 507 |
+
<div class="card">
|
| 508 |
+
<div class="card-header">
|
| 509 |
+
<h3 class="card-title">Providers Detail</h3>
|
| 510 |
+
<button class="btn secondary" onclick="loadProviders()">Reload</button>
|
| 511 |
+
</div>
|
| 512 |
+
<div id="providersDetail"></div>
|
| 513 |
+
</div>
|
| 514 |
+
</div>
|
| 515 |
+
|
| 516 |
+
<div class="tab-content" id="tab-market">
|
| 517 |
+
<div class="grid grid-2">
|
| 518 |
+
<div class="card">
|
| 519 |
+
<div class="card-header"><h3 class="card-title">Global Stats</h3></div>
|
| 520 |
+
<div id="marketGlobalStats" class="list"></div>
|
| 521 |
+
</div>
|
| 522 |
+
<div class="card">
|
| 523 |
+
<div class="card-header"><h3 class="card-title">Top Movers</h3></div>
|
| 524 |
+
<div style="height:260px;"><canvas id="marketChart"></canvas></div>
|
| 525 |
+
</div>
|
| 526 |
+
</div>
|
| 527 |
+
<div class="grid grid-2">
|
| 528 |
+
<div class="card">
|
| 529 |
+
<div class="card-header"><h3 class="card-title">Top Assets</h3></div>
|
| 530 |
+
<div class="table-wrapper" style="overflow:auto; max-height:320px;">
|
| 531 |
+
<table>
|
| 532 |
+
<thead><tr><th>Rank</th><th>Name</th><th>Price</th><th>24h</th><th>Market Cap</th></tr></thead>
|
| 533 |
+
<tbody id="marketTableBody"></tbody>
|
| 534 |
+
</table>
|
| 535 |
+
</div>
|
| 536 |
+
</div>
|
| 537 |
+
<div class="card">
|
| 538 |
+
<div class="card-header"><h3 class="card-title">Trending Now</h3></div>
|
| 539 |
+
<div id="trendingList" class="list"></div>
|
| 540 |
+
</div>
|
| 541 |
+
</div>
|
| 542 |
+
</div>
|
| 543 |
+
|
| 544 |
+
<div class="tab-content" id="tab-sentiment">
|
| 545 |
+
<div class="grid grid-2">
|
| 546 |
+
<div class="card">
|
| 547 |
+
<div class="card-header"><h3 class="card-title">Fear & Greed Index</h3></div>
|
| 548 |
+
<div id="sentimentCard" style="font-size:14px; color:var(--muted);">Loading sentiment…</div>
|
| 549 |
+
</div>
|
| 550 |
+
<div class="card">
|
| 551 |
+
<div class="card-header"><h3 class="card-title">DeFi TVL</h3></div>
|
| 552 |
+
<div class="table-wrapper" style="overflow:auto; max-height:280px;">
|
| 553 |
+
<table>
|
| 554 |
+
<thead><tr><th>Protocol</th><th>TVL</th><th>24h</th><th>Chain</th></tr></thead>
|
| 555 |
+
<tbody id="defiTableBody"></tbody>
|
| 556 |
+
</table>
|
| 557 |
+
</div>
|
| 558 |
+
</div>
|
| 559 |
+
</div>
|
| 560 |
+
</div>
|
| 561 |
+
|
| 562 |
+
<div class="tab-content" id="tab-news">
|
| 563 |
+
<div class="card">
|
| 564 |
+
<div class="card-header">
|
| 565 |
+
<h3 class="card-title">Latest Headlines</h3>
|
| 566 |
+
<button class="btn secondary" onclick="loadNews()">Reload</button>
|
| 567 |
+
</div>
|
| 568 |
+
<div id="newsList" class="list"></div>
|
| 569 |
+
</div>
|
| 570 |
+
</div>
|
| 571 |
+
|
| 572 |
+
<div class="tab-content" id="tab-resources">
|
| 573 |
+
<div class="card">
|
| 574 |
+
<div class="card-header">
|
| 575 |
+
<h3 class="card-title">Resource Search</h3>
|
| 576 |
+
<span style="font-size:12px;color:var(--muted);">Live search across providers + HuggingFace registry</span>
|
| 577 |
+
</div>
|
| 578 |
+
<div class="resource-search">
|
| 579 |
+
<input type="text" id="resourceSearch" placeholder="Search provider, model or dataset..." />
|
| 580 |
+
<select id="resourceFilter" onchange="loadResourceSearch()">
|
| 581 |
+
<option value="all">All sources</option>
|
| 582 |
+
<option value="providers">Providers</option>
|
| 583 |
+
<option value="models">Models</option>
|
| 584 |
+
<option value="datasets">Datasets</option>
|
| 585 |
+
</select>
|
| 586 |
+
</div>
|
| 587 |
+
<div class="resource-columns">
|
| 588 |
+
<div>
|
| 589 |
+
<h4>Providers <span id="resourceCountProviders" style="color:var(--muted);"></span></h4>
|
| 590 |
+
<div id="resourceResultsProviders"></div>
|
| 591 |
+
</div>
|
| 592 |
+
<div>
|
| 593 |
+
<h4>Models <span id="resourceCountModels" style="color:var(--muted);"></span></h4>
|
| 594 |
+
<div id="resourceResultsModels"></div>
|
| 595 |
+
</div>
|
| 596 |
+
<div>
|
| 597 |
+
<h4>Datasets <span id="resourceCountDatasets" style="color:var(--muted);"></span></h4>
|
| 598 |
+
<div id="resourceResultsDatasets"></div>
|
| 599 |
+
</div>
|
| 600 |
+
</div>
|
| 601 |
+
</div>
|
| 602 |
+
<div class="grid grid-2">
|
| 603 |
+
<div class="card">
|
| 604 |
+
<div class="card-header"><h3 class="card-title">Export & Backup</h3></div>
|
| 605 |
+
<div style="display:flex; gap:10px; flex-wrap:wrap;">
|
| 606 |
+
<button class="btn" onclick="handleExport('json')">Export JSON Snapshot</button>
|
| 607 |
+
<button class="btn" onclick="handleExport('csv')">Export CSV</button>
|
| 608 |
+
<button class="btn secondary" onclick="handleBackup()">Create Backup</button>
|
| 609 |
+
</div>
|
| 610 |
+
<div id="exportHistory" class="list" style="margin-top:12px;"></div>
|
| 611 |
+
</div>
|
| 612 |
+
<div class="card">
|
| 613 |
+
<div class="card-header"><h3 class="card-title">Import Provider</h3></div>
|
| 614 |
+
<form id="importForm" onsubmit="handleImportSingle(event)">
|
| 615 |
+
<div class="form-grid">
|
| 616 |
+
<div><label>Name</label><input name="name" required></div>
|
| 617 |
+
<div><label>Category</label><input name="category" required></div>
|
| 618 |
+
<div><label>Endpoint URL</label><input name="endpoint_url" required></div>
|
| 619 |
+
<div><label>Health Endpoint</label><input name="health_check_endpoint"></div>
|
| 620 |
+
<div><label>Rate Limit</label><input name="rate_limit"></div>
|
| 621 |
+
<div><label>Timeout (ms)</label><input name="timeout_ms" type="number" value="10000"></div>
|
| 622 |
+
</div>
|
| 623 |
+
<label style="margin-top:12px; display:block;">Notes<textarea name="notes"></textarea></label>
|
| 624 |
+
<div style="margin-top:12px; display:flex; gap:10px; align-items:center;">
|
| 625 |
+
<label style="display:flex; gap:6px; align-items:center; font-size:13px;">
|
| 626 |
+
<input type="checkbox" name="requires_key"> Requires API Key
|
| 627 |
+
</label>
|
| 628 |
+
<input name="api_key" placeholder="API Key (optional)" style="flex:1;">
|
| 629 |
+
</div>
|
| 630 |
+
<button class="btn" style="margin-top:12px;" type="submit">Import Provider</button>
|
| 631 |
+
</form>
|
| 632 |
+
<hr style="margin:20px 0; border:none; border-top:1px solid var(--border);">
|
| 633 |
+
<label style="display:block; font-size:13px; color:var(--muted); margin-bottom:6px;">Bulk JSON Import</label>
|
| 634 |
+
<textarea id="bulkImportTextarea" placeholder='[{"name":"Sample API","category":"market","endpoint_url":"https://..."}]'></textarea>
|
| 635 |
+
<button class="btn secondary" style="margin-top:10px;" onclick="handleImportBulk()">Run Bulk Import</button>
|
| 636 |
+
</div>
|
| 637 |
+
</div>
|
| 638 |
+
</div>
|
| 639 |
+
</div>
|
| 640 |
+
|
| 641 |
+
<script>
|
| 642 |
+
const config = {
|
| 643 |
+
apiBaseUrl: '',
|
| 644 |
+
wsUrl: (() => {
|
| 645 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 646 |
+
return `${protocol}//${window.location.host}/ws`;
|
| 647 |
+
})(),
|
| 648 |
+
autoRefreshInterval: 30000
|
| 649 |
+
};
|
| 650 |
+
|
| 651 |
+
const state = {
|
| 652 |
+
ws: null,
|
| 653 |
+
wsConnected: false,
|
| 654 |
+
providers: [],
|
| 655 |
+
market: { cryptocurrencies: [], global: {} },
|
| 656 |
+
trending: [],
|
| 657 |
+
sentiment: null,
|
| 658 |
+
defi: [],
|
| 659 |
+
news: [],
|
| 660 |
+
errorSummary: null,
|
| 661 |
+
diagnostics: null,
|
| 662 |
+
resources: { providers: [], models: [], datasets: [] },
|
| 663 |
+
exports: [],
|
| 664 |
+
charts: { health: null, status: null, market: null },
|
| 665 |
+
currentTab: 'dashboard',
|
| 666 |
+
resourceSearchTimeout: null,
|
| 667 |
+
lastUpdate: null
|
| 668 |
+
};
|
| 669 |
+
|
| 670 |
+
function showToast(message, type = 'info') {
|
| 671 |
+
const container = document.getElementById('toastContainer');
|
| 672 |
+
const toast = document.createElement('div');
|
| 673 |
+
toast.className = 'toast';
|
| 674 |
+
toast.style.background = type === 'error' ? '#b91c1c' : (type === 'success' ? '#065f46' : '#111827');
|
| 675 |
+
toast.textContent = message;
|
| 676 |
+
container.appendChild(toast);
|
| 677 |
+
setTimeout(() => toast.remove(), 3000);
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
async function apiCall(endpoint, options = {}) {
|
| 681 |
+
const response = await fetch(config.apiBaseUrl + endpoint, options);
|
| 682 |
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
| 683 |
+
return await response.json();
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
function initializeWebSocket() {
|
| 687 |
+
try {
|
| 688 |
+
state.ws = new WebSocket(config.wsUrl);
|
| 689 |
+
state.ws.onopen = () => {
|
| 690 |
+
state.wsConnected = true;
|
| 691 |
+
const pill = document.getElementById('wsStatus');
|
| 692 |
+
pill.textContent = 'Connected';
|
| 693 |
+
pill.style.background = '#dcfce7';
|
| 694 |
+
pill.style.color = '#15803d';
|
| 695 |
+
};
|
| 696 |
+
state.ws.onclose = () => {
|
| 697 |
+
state.wsConnected = false;
|
| 698 |
+
const pill = document.getElementById('wsStatus');
|
| 699 |
+
pill.textContent = 'Disconnected';
|
| 700 |
+
pill.style.background = '#fee2e2';
|
| 701 |
+
pill.style.color = '#b91c1c';
|
| 702 |
+
};
|
| 703 |
+
state.ws.onmessage = (event) => {
|
| 704 |
+
const data = JSON.parse(event.data);
|
| 705 |
+
if (data.type === 'status_update' && data.data?.providers) {
|
| 706 |
+
updateKPIs(data.data.providers);
|
| 707 |
+
}
|
| 708 |
+
if (data.type === 'market_update' && Array.isArray(data.data)) {
|
| 709 |
+
state.market.cryptocurrencies = data.data;
|
| 710 |
+
renderMarketTable();
|
| 711 |
+
updateMarketChart();
|
| 712 |
+
}
|
| 713 |
+
if (data.type === 'sentiment_update') {
|
| 714 |
+
state.sentiment = data.data;
|
| 715 |
+
renderSentiment();
|
| 716 |
+
}
|
| 717 |
+
};
|
| 718 |
+
} catch (err) {
|
| 719 |
+
console.error('WebSocket error', err);
|
| 720 |
+
}
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
async function loadInitialData() {
|
| 724 |
+
try {
|
| 725 |
+
await Promise.all([
|
| 726 |
+
loadProviders(),
|
| 727 |
+
loadMarket(),
|
| 728 |
+
loadTrending(),
|
| 729 |
+
loadSentimentData(),
|
| 730 |
+
loadDefi(),
|
| 731 |
+
loadErrorSummary(),
|
| 732 |
+
loadNews(),
|
| 733 |
+
loadResourceSearch()
|
| 734 |
+
]);
|
| 735 |
+
initializeCharts();
|
| 736 |
+
state.lastUpdate = new Date();
|
| 737 |
+
updateLastUpdateDisplay();
|
| 738 |
+
showToast('Dashboard ready', 'success');
|
| 739 |
+
} catch (err) {
|
| 740 |
+
console.error(err);
|
| 741 |
+
showToast('Failed to load initial data', 'error');
|
| 742 |
+
}
|
| 743 |
+
}
|
| 744 |
+
|
| 745 |
+
async function loadProviders() {
|
| 746 |
+
try {
|
| 747 |
+
const data = await apiCall('/api/providers');
|
| 748 |
+
state.providers = Array.isArray(data) ? data : [];
|
| 749 |
+
renderProvidersTable();
|
| 750 |
+
renderProvidersDetail();
|
| 751 |
+
updateStatusChart();
|
| 752 |
+
updateKPIs(state.providers);
|
| 753 |
+
} catch (err) {
|
| 754 |
+
console.error(err);
|
| 755 |
+
document.getElementById('providersTableBody').innerHTML = `<tr><td colspan="4" style="padding:40px; text-align:center;">${err.message}</td></tr>`;
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
function renderProvidersTable() {
|
| 760 |
+
const tbody = document.getElementById('providersTableBody');
|
| 761 |
+
if (!state.providers.length) {
|
| 762 |
+
tbody.innerHTML = '<tr><td colspan="4" style="text-align:center; padding:40px; color:var(--muted);">No providers available</td></tr>';
|
| 763 |
+
return;
|
| 764 |
+
}
|
| 765 |
+
tbody.innerHTML = state.providers.slice(0, 8).map(p => `
|
| 766 |
+
<tr>
|
| 767 |
+
<td>
|
| 768 |
+
<div style="font-weight:600;">${p.name || 'Unknown'}</div>
|
| 769 |
+
<div style="font-size:11px;color:var(--muted);">${p.category || 'general'}</div>
|
| 770 |
+
</td>
|
| 771 |
+
<td>${renderStatusBadge(p.status)}</td>
|
| 772 |
+
<td>${p.response_time_ms ? `${p.response_time_ms}ms` : '--'}</td>
|
| 773 |
+
<td>${p.uptime ? `${Math.round(p.uptime)}%` : '--'}</td>
|
| 774 |
+
</tr>
|
| 775 |
+
`).join('');
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
function renderProvidersDetail() {
|
| 779 |
+
const container = document.getElementById('providersDetail');
|
| 780 |
+
if (!state.providers.length) {
|
| 781 |
+
container.innerHTML = '<div style="padding:40px; text-align:center; color:var(--muted);">No providers data available</div>';
|
| 782 |
+
return;
|
| 783 |
+
}
|
| 784 |
+
container.innerHTML = `
|
| 785 |
+
<div class="table-wrapper">
|
| 786 |
+
<table>
|
| 787 |
+
<thead>
|
| 788 |
+
<tr>
|
| 789 |
+
<th>Name</th>
|
| 790 |
+
<th>Status</th>
|
| 791 |
+
<th>Response Time</th>
|
| 792 |
+
<th>Success Rate</th>
|
| 793 |
+
<th>Rate Limit</th>
|
| 794 |
+
</tr>
|
| 795 |
+
</thead>
|
| 796 |
+
<tbody>
|
| 797 |
+
${state.providers.map(p => `
|
| 798 |
+
<tr>
|
| 799 |
+
<td>
|
| 800 |
+
<strong>${p.name || 'Unknown'}</strong>
|
| 801 |
+
<div style="font-size:11px;color:var(--muted);margin-top:2px;">${p.category || 'general'}</div>
|
| 802 |
+
</td>
|
| 803 |
+
<td>${renderStatusBadge(p.status)}</td>
|
| 804 |
+
<td><strong>${p.avg_response_time_ms ? `${p.avg_response_time_ms}ms` : (p.response_time_ms ? `${p.response_time_ms}ms` : '--')}</strong></td>
|
| 805 |
+
<td><strong>${p.uptime ? `${Math.round(p.uptime)}%` : '--'}</strong></td>
|
| 806 |
+
<td style="font-size:12px;color:var(--muted);">${p.rate_limit || '—'}</td>
|
| 807 |
+
</tr>`).join('')}
|
| 808 |
+
</tbody>
|
| 809 |
+
</table>
|
| 810 |
+
</div>`;
|
| 811 |
+
}
|
| 812 |
+
|
| 813 |
+
function renderStatusBadge(status = 'unknown') {
|
| 814 |
+
const normalized = (status || '').toLowerCase();
|
| 815 |
+
let cls = 'badge warn';
|
| 816 |
+
if (['online', 'healthy'].includes(normalized)) cls = 'badge success';
|
| 817 |
+
if (['offline', 'error'].includes(normalized)) cls = 'badge danger';
|
| 818 |
+
return `<span class="${cls}">${status || 'unknown'}</span>`;
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
function updateKPIs(data) {
|
| 822 |
+
const providers = Array.isArray(data) ? data : (data?.providers || []);
|
| 823 |
+
const total = providers.length;
|
| 824 |
+
const online = providers.filter(p => ['online', 'healthy'].includes((p.status || '').toLowerCase())).length;
|
| 825 |
+
const responseTimes = providers.map(p => p.response_time_ms || p.avg_response_time_ms).filter(Boolean);
|
| 826 |
+
const avgResponse = responseTimes.length ? Math.round(responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length) : 0;
|
| 827 |
+
|
| 828 |
+
document.getElementById('kpiTotalAPIs').textContent = total;
|
| 829 |
+
document.getElementById('kpiTotalTrend').textContent = `${total} tracked providers`;
|
| 830 |
+
document.getElementById('kpiOnline').textContent = online;
|
| 831 |
+
document.getElementById('kpiOnlineTrend').textContent = total ? `${Math.round((online / total) * 100)}% uptime` : 'No data';
|
| 832 |
+
document.getElementById('kpiAvgResponse').textContent = avgResponse ? `${avgResponse}ms` : '--';
|
| 833 |
+
document.getElementById('kpiResponseTrend').textContent = avgResponse < 500 ? 'Optimal' : avgResponse < 1000 ? 'Acceptable' : 'Slow';
|
| 834 |
+
updateHealthChart(avgResponse);
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
function updateLastUpdateDisplay() {
|
| 838 |
+
if (!state.lastUpdate) return;
|
| 839 |
+
document.getElementById('kpiLastUpdate').textContent = state.lastUpdate.toLocaleTimeString();
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
function initializeCharts() {
|
| 843 |
+
const healthCtx = document.getElementById('healthChart').getContext('2d');
|
| 844 |
+
const statusCtx = document.getElementById('statusChart').getContext('2d');
|
| 845 |
+
const marketCtx = document.getElementById('marketChart').getContext('2d');
|
| 846 |
+
|
| 847 |
+
if (state.charts.health) state.charts.health.destroy();
|
| 848 |
+
if (state.charts.status) state.charts.status.destroy();
|
| 849 |
+
if (state.charts.market) state.charts.market.destroy();
|
| 850 |
+
|
| 851 |
+
state.charts.health = new Chart(healthCtx, {
|
| 852 |
+
type: 'line',
|
| 853 |
+
data: { labels: [], datasets: [{ label: 'Avg Response (ms)', data: [], borderColor: '#2563eb', fill: false }] },
|
| 854 |
+
options: { responsive: true, maintainAspectRatio: false }
|
| 855 |
+
});
|
| 856 |
+
|
| 857 |
+
state.charts.status = new Chart(statusCtx, {
|
| 858 |
+
type: 'doughnut',
|
| 859 |
+
data: { labels: ['Online', 'Degraded', 'Offline'], datasets: [{ data: [0, 0, 0], backgroundColor: ['#16a34a', '#fcd34d', '#f87171'] }] },
|
| 860 |
+
options: { responsive: true, maintainAspectRatio: false }
|
| 861 |
+
});
|
| 862 |
+
|
| 863 |
+
state.charts.market = new Chart(marketCtx, {
|
| 864 |
+
type: 'bar',
|
| 865 |
+
data: { labels: [], datasets: [{ label: 'Market Cap (B USD)', data: [], backgroundColor: '#93c5fd' }] },
|
| 866 |
+
options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true } } }
|
| 867 |
+
});
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
function updateHealthChart(value) {
|
| 871 |
+
if (!state.charts.health || !value) return;
|
| 872 |
+
const chart = state.charts.health;
|
| 873 |
+
chart.data.labels.push(new Date().toLocaleTimeString());
|
| 874 |
+
chart.data.datasets[0].data.push(value);
|
| 875 |
+
if (chart.data.labels.length > 12) {
|
| 876 |
+
chart.data.labels.shift();
|
| 877 |
+
chart.data.datasets[0].data.shift();
|
| 878 |
+
}
|
| 879 |
+
chart.update();
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
function updateStatusChart() {
|
| 883 |
+
if (!state.charts.status) return;
|
| 884 |
+
const online = state.providers.filter(p => (p.status || '').toLowerCase() === 'online').length;
|
| 885 |
+
const degraded = state.providers.filter(p => (p.status || '').toLowerCase() === 'degraded').length;
|
| 886 |
+
const offline = state.providers.length - online - degraded;
|
| 887 |
+
state.charts.status.data.datasets[0].data = [online, degraded, offline];
|
| 888 |
+
state.charts.status.update();
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
async function loadMarket() {
|
| 892 |
+
const data = await apiCall('/api/market');
|
| 893 |
+
state.market = data;
|
| 894 |
+
renderMarketCards();
|
| 895 |
+
renderMarketTable();
|
| 896 |
+
updateMarketChart();
|
| 897 |
+
}
|
| 898 |
+
|
| 899 |
+
function renderMarketCards() {
|
| 900 |
+
const stats = state.market.global || {};
|
| 901 |
+
const container = document.getElementById('marketGlobalStats');
|
| 902 |
+
container.innerHTML = `
|
| 903 |
+
<div><strong>Total Market Cap:</strong> $${formatNumber(stats.total_market_cap)}</div>
|
| 904 |
+
<div><strong>Total Volume:</strong> $${formatNumber(stats.total_volume)}</div>
|
| 905 |
+
<div><strong>BTC Dominance:</strong> ${stats.btc_dominance ? stats.btc_dominance.toFixed(2) + '%' : '--'}</div>
|
| 906 |
+
<div><strong>ETH Dominance:</strong> ${stats.eth_dominance ? stats.eth_dominance.toFixed(2) + '%' : '--'}</div>
|
| 907 |
+
<div><strong>Active Cryptos:</strong> ${stats.active_cryptocurrencies || '--'}</div>
|
| 908 |
+
<div><strong>Markets:</strong> ${stats.markets || '--'}</div>
|
| 909 |
+
`;
|
| 910 |
+
}
|
| 911 |
+
|
| 912 |
+
function renderMarketTable() {
|
| 913 |
+
const tbody = document.getElementById('marketTableBody');
|
| 914 |
+
const coins = state.market.cryptocurrencies || [];
|
| 915 |
+
if (!coins.length) {
|
| 916 |
+
tbody.innerHTML = '<tr><td colspan="5" style="text-align:center; padding:40px; color:var(--muted);">Market data unavailable</td></tr>';
|
| 917 |
+
return;
|
| 918 |
+
}
|
| 919 |
+
tbody.innerHTML = coins.slice(0, 12).map(coin => `
|
| 920 |
+
<tr>
|
| 921 |
+
<td>${coin.rank || coin.market_cap_rank || '-'}</td>
|
| 922 |
+
<td>${coin.name} <span style="color:var(--muted);">${coin.symbol}</span></td>
|
| 923 |
+
<td>$${formatNumber(coin.price)}</td>
|
| 924 |
+
<td style="color:${coin.change_24h >= 0 ? '#16a34a' : '#dc2626'};">${coin.change_24h ? coin.change_24h.toFixed(2) : '0'}%</td>
|
| 925 |
+
<td>$${formatNumber(coin.market_cap)}</td>
|
| 926 |
+
</tr>
|
| 927 |
+
`).join('');
|
| 928 |
+
}
|
| 929 |
+
|
| 930 |
+
function updateMarketChart() {
|
| 931 |
+
if (!state.charts.market) return;
|
| 932 |
+
const coins = state.market.cryptocurrencies || [];
|
| 933 |
+
const top = coins.slice(0, 5);
|
| 934 |
+
state.charts.market.data.labels = top.map(c => c.name);
|
| 935 |
+
state.charts.market.data.datasets[0].data = top.map(c => c.market_cap ? (c.market_cap / 1e9).toFixed(2) : 0);
|
| 936 |
+
state.charts.market.update();
|
| 937 |
+
}
|
| 938 |
+
|
| 939 |
+
async function loadTrending() {
|
| 940 |
+
const data = await apiCall('/api/trending');
|
| 941 |
+
state.trending = data.trending || [];
|
| 942 |
+
const list = document.getElementById('trendingList');
|
| 943 |
+
if (!state.trending.length) {
|
| 944 |
+
list.innerHTML = '<div class="list-item" style="color:var(--muted);">No trending assets</div>';
|
| 945 |
+
return;
|
| 946 |
+
}
|
| 947 |
+
list.innerHTML = state.trending.map(item => `
|
| 948 |
+
<div class="list-item">
|
| 949 |
+
<div style="font-weight:600;">${item.name} (${item.symbol})</div>
|
| 950 |
+
<div style="font-size:12px;color:var(--muted);">Rank: ${item.rank || '—'}</div>
|
| 951 |
+
</div>`).join('');
|
| 952 |
+
}
|
| 953 |
+
|
| 954 |
+
async function loadSentimentData() {
|
| 955 |
+
const data = await apiCall('/api/sentiment');
|
| 956 |
+
state.sentiment = data.fear_greed_index;
|
| 957 |
+
renderSentiment();
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
function renderSentiment() {
|
| 961 |
+
const container = document.getElementById('sentimentCard');
|
| 962 |
+
if (!state.sentiment) {
|
| 963 |
+
container.textContent = 'No sentiment data';
|
| 964 |
+
return;
|
| 965 |
+
}
|
| 966 |
+
const timestamp = Number(state.sentiment.timestamp);
|
| 967 |
+
container.innerHTML = `
|
| 968 |
+
<div style="font-size:32px; font-weight:700;">${state.sentiment.value}</div>
|
| 969 |
+
<div style="font-size:14px; text-transform:uppercase; letter-spacing:1px; margin-bottom:8px;">${state.sentiment.classification}</div>
|
| 970 |
+
<div style="font-size:12px; color:var(--muted);">Updated: ${timestamp ? new Date(timestamp * 1000).toLocaleString() : '--'}</div>
|
| 971 |
+
`;
|
| 972 |
+
}
|
| 973 |
+
|
| 974 |
+
async function loadDefi() {
|
| 975 |
+
const data = await apiCall('/api/defi');
|
| 976 |
+
state.defi = data.protocols || [];
|
| 977 |
+
const tbody = document.getElementById('defiTableBody');
|
| 978 |
+
if (!state.defi.length) {
|
| 979 |
+
tbody.innerHTML = '<tr><td colspan="4" style="text-align:center; padding:40px; color:var(--muted);">No DeFi data</td></tr>';
|
| 980 |
+
return;
|
| 981 |
+
}
|
| 982 |
+
tbody.innerHTML = state.defi.slice(0, 10).map(proto => `
|
| 983 |
+
<tr>
|
| 984 |
+
<td>${proto.name}</td>
|
| 985 |
+
<td>$${formatNumber(proto.tvl)}</td>
|
| 986 |
+
<td style="color:${proto.change_24h >= 0 ? '#16a34a' : '#dc2626'};">${proto.change_24h ? proto.change_24h.toFixed(2) : 0}%</td>
|
| 987 |
+
<td>${proto.chain || '—'}</td>
|
| 988 |
+
</tr>`).join('');
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
async function loadNews() {
|
| 992 |
+
const data = await apiCall('/api/news');
|
| 993 |
+
state.news = data.articles || [];
|
| 994 |
+
const list = document.getElementById('newsList');
|
| 995 |
+
if (!state.news.length) {
|
| 996 |
+
list.innerHTML = '<div class="list-item" style="color:var(--muted);">No news available</div>';
|
| 997 |
+
return;
|
| 998 |
+
}
|
| 999 |
+
list.innerHTML = state.news.slice(0, 12).map(article => `
|
| 1000 |
+
<div class="news-item list-item">
|
| 1001 |
+
<h4>${article.title}</h4>
|
| 1002 |
+
<div class="news-meta">${article.source || 'Unknown'} • ${article.published_at ? new Date(article.published_at).toLocaleString() : ''}</div>
|
| 1003 |
+
<p style="margin:6px 0;">${article.description || ''}</p>
|
| 1004 |
+
<a href="${article.link}" target="_blank" style="font-size:12px; color:var(--primary);">Read article →</a>
|
| 1005 |
+
</div>`).join('');
|
| 1006 |
+
}
|
| 1007 |
+
|
| 1008 |
+
async function loadErrorSummary() {
|
| 1009 |
+
try {
|
| 1010 |
+
const [summary, diagnostics] = await Promise.all([
|
| 1011 |
+
apiCall('/api/logs/summary'),
|
| 1012 |
+
apiCall('/api/diagnostics/errors')
|
| 1013 |
+
]);
|
| 1014 |
+
state.errorSummary = summary;
|
| 1015 |
+
state.diagnostics = diagnostics;
|
| 1016 |
+
renderErrorSummary();
|
| 1017 |
+
} catch (err) {
|
| 1018 |
+
console.error(err);
|
| 1019 |
+
document.getElementById('errorSummaryCard').textContent = 'Failed to load diagnostics';
|
| 1020 |
+
}
|
| 1021 |
+
}
|
| 1022 |
+
|
| 1023 |
+
function renderErrorSummary() {
|
| 1024 |
+
const summary = state.errorSummary;
|
| 1025 |
+
const card = document.getElementById('errorSummaryCard');
|
| 1026 |
+
if (!summary) {
|
| 1027 |
+
card.textContent = 'No diagnostics available';
|
| 1028 |
+
return;
|
| 1029 |
+
}
|
| 1030 |
+
card.innerHTML = `
|
| 1031 |
+
<div><strong>Total Logs:</strong> ${summary.total}</div>
|
| 1032 |
+
<div><strong>Last Error:</strong> ${summary.last_error ? summary.last_error.provider + ' @ ' + summary.last_error.timestamp : 'None'}</div>
|
| 1033 |
+
<div><strong>Top Offenders:</strong> ${Object.keys(summary.by_provider || {}).slice(0,3).join(', ') || '—'}</div>
|
| 1034 |
+
`;
|
| 1035 |
+
const diag = state.diagnostics || { recent: [] };
|
| 1036 |
+
const list = document.getElementById('diagnosticsList');
|
| 1037 |
+
list.innerHTML = diag.recent.slice(0,5).map(item => `
|
| 1038 |
+
<div class="list-item">
|
| 1039 |
+
<div style="font-weight:600;">${item.provider}</div>
|
| 1040 |
+
<div style="font-size:12px; color:var(--muted);">${item.timestamp}</div>
|
| 1041 |
+
<div style="font-size:13px; color:${item.status === 'offline' ? '#dc2626' : '#d97706'};">${item.message || 'No message'}</div>
|
| 1042 |
+
</div>`).join('');
|
| 1043 |
+
}
|
| 1044 |
+
|
| 1045 |
+
async function loadResourceSearch() {
|
| 1046 |
+
const query = document.getElementById('resourceSearch')?.value || '';
|
| 1047 |
+
const source = document.getElementById('resourceFilter').value;
|
| 1048 |
+
const data = await apiCall(`/api/resources/search?q=${encodeURIComponent(query)}&source=${source}`);
|
| 1049 |
+
state.resources = data.results;
|
| 1050 |
+
document.getElementById('resourceCountProviders').textContent = `(${data.counts.providers})`;
|
| 1051 |
+
document.getElementById('resourceCountModels').textContent = `(${data.counts.models})`;
|
| 1052 |
+
document.getElementById('resourceCountDatasets').textContent = `(${data.counts.datasets})`;
|
| 1053 |
+
renderResourceResults();
|
| 1054 |
+
}
|
| 1055 |
+
|
| 1056 |
+
function renderResourceResults() {
|
| 1057 |
+
const providersContainer = document.getElementById('resourceResultsProviders');
|
| 1058 |
+
const modelsContainer = document.getElementById('resourceResultsModels');
|
| 1059 |
+
const datasetsContainer = document.getElementById('resourceResultsDatasets');
|
| 1060 |
+
|
| 1061 |
+
providersContainer.innerHTML = state.resources.providers.slice(0,6).map(p => `
|
| 1062 |
+
<div class="resource-item">
|
| 1063 |
+
<strong>${p.name}</strong>
|
| 1064 |
+
<div style="font-size:12px;color:var(--muted);">${p.category}</div>
|
| 1065 |
+
<div style="font-size:12px;">Status: ${p.status}</div>
|
| 1066 |
+
</div>`).join('') || '<div class="resource-item" style="color:var(--muted);">No matches</div>';
|
| 1067 |
+
|
| 1068 |
+
modelsContainer.innerHTML = state.resources.models.slice(0,6).map(m => `
|
| 1069 |
+
<div class="resource-item">
|
| 1070 |
+
<strong>${m.id}</strong>
|
| 1071 |
+
<div style="font-size:12px;color:var(--muted);">${m.description || 'No description'}</div>
|
| 1072 |
+
</div>`).join('') || '<div class="resource-item" style="color:var(--muted);">No matches</div>';
|
| 1073 |
+
|
| 1074 |
+
datasetsContainer.innerHTML = state.resources.datasets.slice(0,6).map(d => `
|
| 1075 |
+
<div class="resource-item">
|
| 1076 |
+
<strong>${d.id}</strong>
|
| 1077 |
+
<div style="font-size:12px;color:var(--muted);">${d.description || 'No description'}</div>
|
| 1078 |
+
</div>`).join('') || '<div class="resource-item" style="color:var(--muted);">No matches</div>';
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
async function handleExport(type) {
|
| 1082 |
+
try {
|
| 1083 |
+
const res = await apiCall(`/api/v2/export/${type}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' });
|
| 1084 |
+
state.exports.unshift({ type, url: res.download_url, timestamp: res.timestamp });
|
| 1085 |
+
renderExportHistory();
|
| 1086 |
+
showToast(`${type.toUpperCase()} export ready`, 'success');
|
| 1087 |
+
} catch (err) {
|
| 1088 |
+
console.error(err);
|
| 1089 |
+
showToast('Export failed', 'error');
|
| 1090 |
+
}
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
async function handleBackup() {
|
| 1094 |
+
try {
|
| 1095 |
+
const res = await apiCall('/api/v2/backup', { method: 'POST' });
|
| 1096 |
+
state.exports.unshift({ type: 'backup', url: res.download_url, timestamp: res.timestamp });
|
| 1097 |
+
renderExportHistory();
|
| 1098 |
+
showToast('Backup created', 'success');
|
| 1099 |
+
} catch (err) {
|
| 1100 |
+
console.error(err);
|
| 1101 |
+
showToast('Backup failed', 'error');
|
| 1102 |
+
}
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
function renderExportHistory() {
|
| 1106 |
+
const container = document.getElementById('exportHistory');
|
| 1107 |
+
if (!state.exports.length) {
|
| 1108 |
+
container.innerHTML = '<div style="color:var(--muted); font-size:13px;">No exports yet</div>';
|
| 1109 |
+
return;
|
| 1110 |
+
}
|
| 1111 |
+
container.innerHTML = state.exports.slice(0,5).map(entry => `
|
| 1112 |
+
<div class="list-item" style="border-bottom:1px solid var(--border);">
|
| 1113 |
+
<div style="font-weight:600;">${entry.type.toUpperCase()}</div>
|
| 1114 |
+
<div style="font-size:12px; color:var(--muted);">${new Date(entry.timestamp).toLocaleString()}</div>
|
| 1115 |
+
<a href="${entry.url}" style="font-size:12px; color:var(--primary);" target="_blank">Download</a>
|
| 1116 |
+
</div>`).join('');
|
| 1117 |
+
}
|
| 1118 |
+
|
| 1119 |
+
async function handleImportSingle(event) {
|
| 1120 |
+
event.preventDefault();
|
| 1121 |
+
const form = event.target;
|
| 1122 |
+
const payload = Object.fromEntries(new FormData(form).entries());
|
| 1123 |
+
payload.requires_key = form.elements['requires_key'].checked;
|
| 1124 |
+
payload.timeout_ms = Number(payload.timeout_ms) || 10000;
|
| 1125 |
+
try {
|
| 1126 |
+
await apiCall('/api/providers', {
|
| 1127 |
+
method: 'POST',
|
| 1128 |
+
headers: { 'Content-Type': 'application/json' },
|
| 1129 |
+
body: JSON.stringify(payload)
|
| 1130 |
+
});
|
| 1131 |
+
showToast('Provider imported', 'success');
|
| 1132 |
+
form.reset();
|
| 1133 |
+
loadProviders();
|
| 1134 |
+
} catch (err) {
|
| 1135 |
+
console.error(err);
|
| 1136 |
+
showToast('Import failed', 'error');
|
| 1137 |
+
}
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
async function handleImportBulk() {
|
| 1141 |
+
const textarea = document.getElementById('bulkImportTextarea');
|
| 1142 |
+
if (!textarea.value.trim()) {
|
| 1143 |
+
showToast('Paste provider JSON first', 'error');
|
| 1144 |
+
return;
|
| 1145 |
+
}
|
| 1146 |
+
try {
|
| 1147 |
+
const providers = JSON.parse(textarea.value);
|
| 1148 |
+
await apiCall('/api/v2/import/providers', {
|
| 1149 |
+
method: 'POST',
|
| 1150 |
+
headers: { 'Content-Type': 'application/json' },
|
| 1151 |
+
body: JSON.stringify({ providers })
|
| 1152 |
+
});
|
| 1153 |
+
showToast('Bulk import complete', 'success');
|
| 1154 |
+
textarea.value = '';
|
| 1155 |
+
loadProviders();
|
| 1156 |
+
} catch (err) {
|
| 1157 |
+
console.error(err);
|
| 1158 |
+
showToast('Bulk import failed', 'error');
|
| 1159 |
+
}
|
| 1160 |
+
}
|
| 1161 |
+
|
| 1162 |
+
function switchTab(event, tabName) {
|
| 1163 |
+
document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active'));
|
| 1164 |
+
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
|
| 1165 |
+
event.currentTarget.classList.add('active');
|
| 1166 |
+
document.getElementById(`tab-${tabName}`).classList.add('active');
|
| 1167 |
+
state.currentTab = tabName;
|
| 1168 |
+
if (tabName === 'market') loadMarket();
|
| 1169 |
+
if (tabName === 'sentiment') { loadSentimentData(); loadDefi(); }
|
| 1170 |
+
if (tabName === 'news') loadNews();
|
| 1171 |
+
}
|
| 1172 |
+
|
| 1173 |
+
function startAutoRefresh() {
|
| 1174 |
+
setInterval(() => {
|
| 1175 |
+
if (state.wsConnected) {
|
| 1176 |
+
refreshAll();
|
| 1177 |
+
}
|
| 1178 |
+
}, config.autoRefreshInterval);
|
| 1179 |
+
}
|
| 1180 |
+
|
| 1181 |
+
function refreshAll() {
|
| 1182 |
+
loadProviders();
|
| 1183 |
+
loadMarket();
|
| 1184 |
+
loadTrending();
|
| 1185 |
+
loadSentimentData();
|
| 1186 |
+
loadDefi();
|
| 1187 |
+
loadErrorSummary();
|
| 1188 |
+
loadNews();
|
| 1189 |
+
loadResourceSearch();
|
| 1190 |
+
}
|
| 1191 |
+
|
| 1192 |
+
function formatNumber(value) {
|
| 1193 |
+
if (!value && value !== 0) return '--';
|
| 1194 |
+
if (value >= 1e12) return (value / 1e12).toFixed(2) + 'T';
|
| 1195 |
+
if (value >= 1e9) return (value / 1e9).toFixed(2) + 'B';
|
| 1196 |
+
if (value >= 1e6) return (value / 1e6).toFixed(2) + 'M';
|
| 1197 |
+
if (value >= 1e3) return (value / 1e3).toFixed(2) + 'K';
|
| 1198 |
+
return Number(value).toFixed(2);
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
function setupResourceSearch() {
|
| 1202 |
+
const input = document.getElementById('resourceSearch');
|
| 1203 |
+
input.addEventListener('input', () => {
|
| 1204 |
+
clearTimeout(state.resourceSearchTimeout);
|
| 1205 |
+
state.resourceSearchTimeout = setTimeout(loadResourceSearch, 400);
|
| 1206 |
+
});
|
| 1207 |
+
}
|
| 1208 |
+
|
| 1209 |
+
initializeWebSocket();
|
| 1210 |
+
setupResourceSearch();
|
| 1211 |
+
loadInitialData();
|
| 1212 |
+
startAutoRefresh();
|
| 1213 |
+
</script>
|
| 1214 |
+
</body>
|
| 1215 |
+
</html>
|
| 1216 |
+
|
index_backup.html
ADDED
|
@@ -0,0 +1,2452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Crypto API Monitor - Real-time Dashboard</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
:root {
|
| 11 |
+
--bg-primary: #ffffff;
|
| 12 |
+
--bg-secondary: #f8f9ff;
|
| 13 |
+
--bg-card: #ffffff;
|
| 14 |
+
--bg-hover: #f3f4ff;
|
| 15 |
+
--text-primary: #1e1b4b;
|
| 16 |
+
--text-secondary: #4c4380;
|
| 17 |
+
--text-muted: #7c3aed;
|
| 18 |
+
--accent-primary: #8b5cf6;
|
| 19 |
+
--accent-secondary: #a78bfa;
|
| 20 |
+
--accent-tertiary: #c084fc;
|
| 21 |
+
--purple-glow: rgba(139, 92, 246, 0.5);
|
| 22 |
+
--success: #10b981;
|
| 23 |
+
--success-bg: #d1fae5;
|
| 24 |
+
--warning: #f59e0b;
|
| 25 |
+
--warning-bg: #fef3c7;
|
| 26 |
+
--danger: #ef4444;
|
| 27 |
+
--danger-bg: #fee2e2;
|
| 28 |
+
--info: #06b6d4;
|
| 29 |
+
--info-bg: #cffafe;
|
| 30 |
+
--border: rgba(139, 92, 246, 0.2);
|
| 31 |
+
--shadow-sm: 0 2px 8px rgba(139, 92, 246, 0.08);
|
| 32 |
+
--shadow: 0 4px 16px rgba(139, 92, 246, 0.12);
|
| 33 |
+
--shadow-lg: 0 10px 40px rgba(139, 92, 246, 0.15);
|
| 34 |
+
--radius: 16px;
|
| 35 |
+
--radius-lg: 24px;
|
| 36 |
+
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
* {
|
| 40 |
+
margin: 0;
|
| 41 |
+
padding: 0;
|
| 42 |
+
box-sizing: border-box;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
body {
|
| 46 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
| 47 |
+
background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 50%, #f0f4ff 100%);
|
| 48 |
+
background-attachment: fixed;
|
| 49 |
+
color: var(--text-primary);
|
| 50 |
+
line-height: 1.6;
|
| 51 |
+
min-height: 100vh;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
body::before {
|
| 55 |
+
content: '';
|
| 56 |
+
position: fixed;
|
| 57 |
+
top: 0;
|
| 58 |
+
left: 0;
|
| 59 |
+
right: 0;
|
| 60 |
+
bottom: 0;
|
| 61 |
+
background:
|
| 62 |
+
radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
|
| 63 |
+
radial-gradient(circle at 80% 70%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
|
| 64 |
+
pointer-events: none;
|
| 65 |
+
z-index: 0;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.container {
|
| 69 |
+
max-width: 1600px;
|
| 70 |
+
margin: 0 auto;
|
| 71 |
+
padding: 24px;
|
| 72 |
+
position: relative;
|
| 73 |
+
z-index: 1;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* Header */
|
| 77 |
+
.header {
|
| 78 |
+
background: var(--bg-card);
|
| 79 |
+
border: 2px solid var(--border);
|
| 80 |
+
border-radius: var(--radius-lg);
|
| 81 |
+
padding: 28px;
|
| 82 |
+
margin-bottom: 24px;
|
| 83 |
+
box-shadow: var(--shadow-lg);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.header-top {
|
| 87 |
+
display: flex;
|
| 88 |
+
align-items: center;
|
| 89 |
+
justify-content: space-between;
|
| 90 |
+
flex-wrap: wrap;
|
| 91 |
+
gap: 20px;
|
| 92 |
+
margin-bottom: 24px;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.logo {
|
| 96 |
+
display: flex;
|
| 97 |
+
align-items: center;
|
| 98 |
+
gap: 16px;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.logo-icon {
|
| 102 |
+
width: 64px;
|
| 103 |
+
height: 64px;
|
| 104 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #c084fc 100%);
|
| 105 |
+
border-radius: 20px;
|
| 106 |
+
display: flex;
|
| 107 |
+
align-items: center;
|
| 108 |
+
justify-content: center;
|
| 109 |
+
box-shadow: 0 10px 30px rgba(139, 92, 246, 0.4);
|
| 110 |
+
position: relative;
|
| 111 |
+
overflow: hidden;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.logo-icon::after {
|
| 115 |
+
content: '';
|
| 116 |
+
position: absolute;
|
| 117 |
+
top: -50%;
|
| 118 |
+
left: -50%;
|
| 119 |
+
right: -50%;
|
| 120 |
+
bottom: -50%;
|
| 121 |
+
background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
| 122 |
+
animation: shimmer 3s infinite;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
@keyframes shimmer {
|
| 126 |
+
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
|
| 127 |
+
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.logo-text h1 {
|
| 131 |
+
font-size: 32px;
|
| 132 |
+
font-weight: 900;
|
| 133 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #c084fc 100%);
|
| 134 |
+
-webkit-background-clip: text;
|
| 135 |
+
-webkit-text-fill-color: transparent;
|
| 136 |
+
background-clip: text;
|
| 137 |
+
margin-bottom: 4px;
|
| 138 |
+
letter-spacing: -0.5px;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
.logo-text p {
|
| 142 |
+
font-size: 14px;
|
| 143 |
+
color: var(--text-muted);
|
| 144 |
+
font-weight: 600;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.header-actions {
|
| 148 |
+
display: flex;
|
| 149 |
+
gap: 12px;
|
| 150 |
+
align-items: center;
|
| 151 |
+
flex-wrap: wrap;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.status-badge {
|
| 155 |
+
display: flex;
|
| 156 |
+
align-items: center;
|
| 157 |
+
gap: 10px;
|
| 158 |
+
padding: 12px 20px;
|
| 159 |
+
border-radius: 999px;
|
| 160 |
+
background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.08) 100%);
|
| 161 |
+
border: 2px solid rgba(16, 185, 129, 0.4);
|
| 162 |
+
font-size: 14px;
|
| 163 |
+
font-weight: 700;
|
| 164 |
+
color: var(--success);
|
| 165 |
+
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
|
| 166 |
+
text-transform: uppercase;
|
| 167 |
+
letter-spacing: 0.5px;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.status-dot {
|
| 171 |
+
width: 10px;
|
| 172 |
+
height: 10px;
|
| 173 |
+
border-radius: 50%;
|
| 174 |
+
background: var(--success);
|
| 175 |
+
animation: pulse-glow 2s infinite;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
@keyframes pulse-glow {
|
| 179 |
+
0%, 100% {
|
| 180 |
+
box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7),
|
| 181 |
+
0 0 10px rgba(16, 185, 129, 0.5);
|
| 182 |
+
}
|
| 183 |
+
50% {
|
| 184 |
+
box-shadow: 0 0 0 8px rgba(16, 185, 129, 0),
|
| 185 |
+
0 0 20px rgba(16, 185, 129, 0.3);
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.connection-status {
|
| 190 |
+
display: flex;
|
| 191 |
+
align-items: center;
|
| 192 |
+
gap: 8px;
|
| 193 |
+
padding: 10px 16px;
|
| 194 |
+
border-radius: 999px;
|
| 195 |
+
background: var(--bg-card);
|
| 196 |
+
border: 2px solid var(--border);
|
| 197 |
+
font-size: 12px;
|
| 198 |
+
font-weight: 700;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.connection-status.connected { border-color: var(--success); color: var(--success); }
|
| 202 |
+
.connection-status.disconnected { border-color: var(--danger); color: var(--danger); }
|
| 203 |
+
.connection-status.connecting { border-color: var(--warning); color: var(--warning); }
|
| 204 |
+
|
| 205 |
+
.btn {
|
| 206 |
+
padding: 14px 28px;
|
| 207 |
+
border-radius: 14px;
|
| 208 |
+
border: none;
|
| 209 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
|
| 210 |
+
color: white;
|
| 211 |
+
font-family: inherit;
|
| 212 |
+
font-size: 14px;
|
| 213 |
+
font-weight: 700;
|
| 214 |
+
cursor: pointer;
|
| 215 |
+
transition: var(--transition);
|
| 216 |
+
display: inline-flex;
|
| 217 |
+
align-items: center;
|
| 218 |
+
gap: 10px;
|
| 219 |
+
box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
|
| 220 |
+
text-transform: uppercase;
|
| 221 |
+
letter-spacing: 0.5px;
|
| 222 |
+
position: relative;
|
| 223 |
+
overflow: hidden;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.btn::before {
|
| 227 |
+
content: '';
|
| 228 |
+
position: absolute;
|
| 229 |
+
top: 0;
|
| 230 |
+
left: -100%;
|
| 231 |
+
width: 100%;
|
| 232 |
+
height: 100%;
|
| 233 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
| 234 |
+
transition: left 0.5s;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.btn:hover {
|
| 238 |
+
transform: translateY(-3px);
|
| 239 |
+
box-shadow: 0 8px 24px rgba(139, 92, 246, 0.5);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.btn:hover::before {
|
| 243 |
+
left: 100%;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.btn-secondary {
|
| 247 |
+
background: white;
|
| 248 |
+
color: var(--accent-primary);
|
| 249 |
+
border: 2px solid var(--border);
|
| 250 |
+
box-shadow: var(--shadow-sm);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.btn-secondary:hover {
|
| 254 |
+
background: var(--bg-hover);
|
| 255 |
+
border-color: var(--accent-primary);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
.btn-icon {
|
| 259 |
+
padding: 12px;
|
| 260 |
+
width: 44px;
|
| 261 |
+
height: 44px;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
.icon {
|
| 265 |
+
width: 20px;
|
| 266 |
+
height: 20px;
|
| 267 |
+
stroke: currentColor;
|
| 268 |
+
stroke-width: 2.5;
|
| 269 |
+
stroke-linecap: round;
|
| 270 |
+
stroke-linejoin: round;
|
| 271 |
+
fill: none;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.icon-lg {
|
| 275 |
+
width: 26px;
|
| 276 |
+
height: 26px;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
/* KPI Cards */
|
| 280 |
+
.kpi-grid {
|
| 281 |
+
display: grid;
|
| 282 |
+
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
| 283 |
+
gap: 20px;
|
| 284 |
+
margin-bottom: 24px;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
.kpi-card {
|
| 288 |
+
background: var(--bg-card);
|
| 289 |
+
border: 2px solid var(--border);
|
| 290 |
+
border-radius: var(--radius-lg);
|
| 291 |
+
padding: 32px;
|
| 292 |
+
transition: var(--transition);
|
| 293 |
+
box-shadow: var(--shadow);
|
| 294 |
+
position: relative;
|
| 295 |
+
overflow: hidden;
|
| 296 |
+
cursor: pointer;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
.kpi-card::before {
|
| 300 |
+
content: '';
|
| 301 |
+
position: absolute;
|
| 302 |
+
top: 0;
|
| 303 |
+
left: 0;
|
| 304 |
+
right: 0;
|
| 305 |
+
height: 6px;
|
| 306 |
+
background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 50%, #c084fc 100%);
|
| 307 |
+
transform: scaleX(0);
|
| 308 |
+
transform-origin: left;
|
| 309 |
+
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
.kpi-card:hover {
|
| 313 |
+
transform: translateY(-8px) scale(1.02);
|
| 314 |
+
box-shadow: 0 16px 48px rgba(139, 92, 246, 0.25);
|
| 315 |
+
border-color: var(--accent-primary);
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
.kpi-card:hover::before {
|
| 319 |
+
transform: scaleX(1);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.kpi-header {
|
| 323 |
+
display: flex;
|
| 324 |
+
align-items: center;
|
| 325 |
+
justify-content: space-between;
|
| 326 |
+
margin-bottom: 20px;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
.kpi-label {
|
| 330 |
+
font-size: 12px;
|
| 331 |
+
color: var(--text-muted);
|
| 332 |
+
font-weight: 800;
|
| 333 |
+
text-transform: uppercase;
|
| 334 |
+
letter-spacing: 1.2px;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
.kpi-icon-wrapper {
|
| 338 |
+
width: 64px;
|
| 339 |
+
height: 64px;
|
| 340 |
+
border-radius: 18px;
|
| 341 |
+
display: flex;
|
| 342 |
+
align-items: center;
|
| 343 |
+
justify-content: center;
|
| 344 |
+
transition: var(--transition);
|
| 345 |
+
box-shadow: var(--shadow);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
.kpi-card:hover .kpi-icon-wrapper {
|
| 349 |
+
transform: rotate(-5deg) scale(1.15);
|
| 350 |
+
box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
.kpi-value {
|
| 354 |
+
font-size: 48px;
|
| 355 |
+
font-weight: 900;
|
| 356 |
+
margin-bottom: 16px;
|
| 357 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #c084fc 100%);
|
| 358 |
+
-webkit-background-clip: text;
|
| 359 |
+
-webkit-text-fill-color: transparent;
|
| 360 |
+
background-clip: text;
|
| 361 |
+
line-height: 1;
|
| 362 |
+
animation: countUp 0.6s ease-out;
|
| 363 |
+
letter-spacing: -2px;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
@keyframes countUp {
|
| 367 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 368 |
+
to { opacity: 1; transform: translateY(0); }
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
.kpi-trend {
|
| 372 |
+
display: flex;
|
| 373 |
+
align-items: center;
|
| 374 |
+
gap: 10px;
|
| 375 |
+
font-size: 13px;
|
| 376 |
+
font-weight: 700;
|
| 377 |
+
padding: 8px 16px;
|
| 378 |
+
border-radius: 12px;
|
| 379 |
+
width: fit-content;
|
| 380 |
+
text-transform: uppercase;
|
| 381 |
+
letter-spacing: 0.5px;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.trend-up {
|
| 385 |
+
color: var(--success);
|
| 386 |
+
background: var(--success-bg);
|
| 387 |
+
border: 2px solid var(--success);
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
.trend-down {
|
| 391 |
+
color: var(--danger);
|
| 392 |
+
background: var(--danger-bg);
|
| 393 |
+
border: 2px solid var(--danger);
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
.trend-neutral {
|
| 397 |
+
color: var(--info);
|
| 398 |
+
background: var(--info-bg);
|
| 399 |
+
border: 2px solid var(--info);
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
/* Tabs */
|
| 403 |
+
.tabs {
|
| 404 |
+
display: flex;
|
| 405 |
+
gap: 6px;
|
| 406 |
+
margin-bottom: 24px;
|
| 407 |
+
overflow-x: auto;
|
| 408 |
+
padding: 8px;
|
| 409 |
+
background: var(--bg-card);
|
| 410 |
+
border-radius: var(--radius-lg);
|
| 411 |
+
border: 2px solid var(--border);
|
| 412 |
+
box-shadow: var(--shadow-sm);
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
.tab {
|
| 416 |
+
padding: 12px 20px;
|
| 417 |
+
border-radius: 12px;
|
| 418 |
+
background: transparent;
|
| 419 |
+
border: none;
|
| 420 |
+
color: var(--text-secondary);
|
| 421 |
+
cursor: pointer;
|
| 422 |
+
transition: all 0.25s;
|
| 423 |
+
white-space: nowrap;
|
| 424 |
+
font-weight: 700;
|
| 425 |
+
font-size: 13px;
|
| 426 |
+
display: flex;
|
| 427 |
+
align-items: center;
|
| 428 |
+
gap: 8px;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
.tab:hover:not(.active) {
|
| 432 |
+
background: var(--bg-hover);
|
| 433 |
+
color: var(--text-primary);
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
.tab.active {
|
| 437 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
|
| 438 |
+
color: white;
|
| 439 |
+
box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
|
| 440 |
+
transform: scale(1.05);
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
.tab .icon {
|
| 444 |
+
width: 16px;
|
| 445 |
+
height: 16px;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
/* Tab Content */
|
| 449 |
+
.tab-content {
|
| 450 |
+
display: none;
|
| 451 |
+
animation: fadeIn 0.4s ease;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
.tab-content.active {
|
| 455 |
+
display: block;
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
@keyframes fadeIn {
|
| 459 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 460 |
+
to { opacity: 1; transform: translateY(0); }
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
/* Card */
|
| 464 |
+
.card {
|
| 465 |
+
background: var(--bg-card);
|
| 466 |
+
border: 2px solid var(--border);
|
| 467 |
+
border-radius: var(--radius-lg);
|
| 468 |
+
padding: 28px;
|
| 469 |
+
margin-bottom: 24px;
|
| 470 |
+
box-shadow: var(--shadow);
|
| 471 |
+
transition: var(--transition);
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
.card:hover {
|
| 475 |
+
box-shadow: var(--shadow-lg);
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
.card-header {
|
| 479 |
+
display: flex;
|
| 480 |
+
align-items: center;
|
| 481 |
+
justify-content: space-between;
|
| 482 |
+
margin-bottom: 24px;
|
| 483 |
+
padding-bottom: 16px;
|
| 484 |
+
border-bottom: 2px solid var(--border);
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
.card-title {
|
| 488 |
+
font-size: 20px;
|
| 489 |
+
font-weight: 800;
|
| 490 |
+
display: flex;
|
| 491 |
+
align-items: center;
|
| 492 |
+
gap: 12px;
|
| 493 |
+
color: var(--text-primary);
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
.card-actions {
|
| 497 |
+
display: flex;
|
| 498 |
+
gap: 8px;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/* Table */
|
| 502 |
+
.table-container {
|
| 503 |
+
overflow-x: auto;
|
| 504 |
+
border-radius: var(--radius);
|
| 505 |
+
border: 2px solid var(--border);
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
.table {
|
| 509 |
+
width: 100%;
|
| 510 |
+
border-collapse: collapse;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
.table thead {
|
| 514 |
+
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
.table thead th {
|
| 518 |
+
color: white;
|
| 519 |
+
font-weight: 700;
|
| 520 |
+
font-size: 13px;
|
| 521 |
+
text-align: left;
|
| 522 |
+
padding: 16px;
|
| 523 |
+
text-transform: uppercase;
|
| 524 |
+
letter-spacing: 0.8px;
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
.table tbody tr {
|
| 528 |
+
transition: var(--transition);
|
| 529 |
+
border-bottom: 1px solid var(--border);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
.table tbody tr:hover {
|
| 533 |
+
background: var(--bg-hover);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.table tbody td {
|
| 537 |
+
padding: 16px;
|
| 538 |
+
font-size: 14px;
|
| 539 |
+
color: var(--text-secondary);
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
/* Badge */
|
| 543 |
+
.badge {
|
| 544 |
+
display: inline-flex;
|
| 545 |
+
align-items: center;
|
| 546 |
+
gap: 6px;
|
| 547 |
+
padding: 6px 12px;
|
| 548 |
+
border-radius: 999px;
|
| 549 |
+
font-size: 12px;
|
| 550 |
+
font-weight: 700;
|
| 551 |
+
white-space: nowrap;
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
.badge-success {
|
| 555 |
+
background: var(--success-bg);
|
| 556 |
+
color: var(--success);
|
| 557 |
+
border: 2px solid var(--success);
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.badge-warning {
|
| 561 |
+
background: var(--warning-bg);
|
| 562 |
+
color: var(--warning);
|
| 563 |
+
border: 2px solid var(--warning);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
.badge-danger {
|
| 567 |
+
background: var(--danger-bg);
|
| 568 |
+
color: var(--danger);
|
| 569 |
+
border: 2px solid var(--danger);
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
.badge-info {
|
| 573 |
+
background: var(--info-bg);
|
| 574 |
+
color: var(--info);
|
| 575 |
+
border: 2px solid var(--info);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
/* Progress Bar */
|
| 579 |
+
.progress {
|
| 580 |
+
height: 12px;
|
| 581 |
+
background: var(--bg-hover);
|
| 582 |
+
border-radius: 999px;
|
| 583 |
+
overflow: hidden;
|
| 584 |
+
margin: 8px 0;
|
| 585 |
+
border: 2px solid var(--border);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
.progress-bar {
|
| 589 |
+
height: 100%;
|
| 590 |
+
background: linear-gradient(90deg, #8b5cf6, #a78bfa);
|
| 591 |
+
border-radius: 999px;
|
| 592 |
+
transition: width 0.5s ease;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
.progress-bar.success {
|
| 596 |
+
background: linear-gradient(90deg, var(--success), #34d399);
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
.progress-bar.warning {
|
| 600 |
+
background: linear-gradient(90deg, var(--warning), #fbbf24);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
.progress-bar.danger {
|
| 604 |
+
background: linear-gradient(90deg, var(--danger), #f87171);
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/* Chart Container */
|
| 608 |
+
.chart-container {
|
| 609 |
+
position: relative;
|
| 610 |
+
height: 320px;
|
| 611 |
+
margin: 20px 0;
|
| 612 |
+
background: var(--bg-secondary);
|
| 613 |
+
border-radius: var(--radius);
|
| 614 |
+
padding: 16px;
|
| 615 |
+
border: 2px solid var(--border);
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
/* Loading */
|
| 619 |
+
.loading-overlay {
|
| 620 |
+
position: fixed;
|
| 621 |
+
top: 0;
|
| 622 |
+
left: 0;
|
| 623 |
+
right: 0;
|
| 624 |
+
bottom: 0;
|
| 625 |
+
background: rgba(255, 255, 255, 0.95);
|
| 626 |
+
backdrop-filter: blur(8px);
|
| 627 |
+
display: none;
|
| 628 |
+
align-items: center;
|
| 629 |
+
justify-content: center;
|
| 630 |
+
z-index: 9999;
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
.loading-overlay.active {
|
| 634 |
+
display: flex;
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
.spinner {
|
| 638 |
+
width: 60px;
|
| 639 |
+
height: 60px;
|
| 640 |
+
border: 6px solid var(--border);
|
| 641 |
+
border-top-color: var(--accent-primary);
|
| 642 |
+
border-radius: 50%;
|
| 643 |
+
animation: spin 0.8s linear infinite;
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
@keyframes spin {
|
| 647 |
+
to { transform: rotate(360deg); }
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
.loading-inline {
|
| 651 |
+
display: flex;
|
| 652 |
+
align-items: center;
|
| 653 |
+
justify-content: center;
|
| 654 |
+
padding: 40px;
|
| 655 |
+
color: var(--text-muted);
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
.spinner-inline {
|
| 659 |
+
width: 32px;
|
| 660 |
+
height: 32px;
|
| 661 |
+
border: 3px solid var(--border);
|
| 662 |
+
border-top-color: var(--accent-primary);
|
| 663 |
+
border-radius: 50%;
|
| 664 |
+
animation: spin 0.8s linear infinite;
|
| 665 |
+
margin-right: 12px;
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
/* Toast */
|
| 669 |
+
.toast-container {
|
| 670 |
+
position: fixed;
|
| 671 |
+
bottom: 24px;
|
| 672 |
+
right: 24px;
|
| 673 |
+
z-index: 10000;
|
| 674 |
+
display: flex;
|
| 675 |
+
flex-direction: column;
|
| 676 |
+
gap: 12px;
|
| 677 |
+
max-width: 400px;
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
.toast {
|
| 681 |
+
padding: 16px 20px;
|
| 682 |
+
border-radius: var(--radius);
|
| 683 |
+
background: var(--bg-card);
|
| 684 |
+
border: 2px solid var(--border);
|
| 685 |
+
box-shadow: var(--shadow-lg);
|
| 686 |
+
display: flex;
|
| 687 |
+
align-items: center;
|
| 688 |
+
gap: 12px;
|
| 689 |
+
animation: slideInRight 0.3s ease;
|
| 690 |
+
min-width: 300px;
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
@keyframes slideInRight {
|
| 694 |
+
from { transform: translateX(400px); opacity: 0; }
|
| 695 |
+
to { transform: translateX(0); opacity: 1; }
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
.toast.success { border-color: var(--success); background: var(--success-bg); }
|
| 699 |
+
.toast.error { border-color: var(--danger); background: var(--danger-bg); }
|
| 700 |
+
.toast.warning { border-color: var(--warning); background: var(--warning-bg); }
|
| 701 |
+
.toast.info { border-color: var(--info); background: var(--info-bg); }
|
| 702 |
+
|
| 703 |
+
.toast-content { flex: 1; }
|
| 704 |
+
.toast-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
|
| 705 |
+
.toast-message { font-size: 13px; color: var(--text-secondary); }
|
| 706 |
+
|
| 707 |
+
/* Alert */
|
| 708 |
+
.alert {
|
| 709 |
+
padding: 18px 24px;
|
| 710 |
+
border-radius: var(--radius);
|
| 711 |
+
margin-bottom: 16px;
|
| 712 |
+
display: flex;
|
| 713 |
+
align-items: flex-start;
|
| 714 |
+
gap: 14px;
|
| 715 |
+
border-left: 6px solid;
|
| 716 |
+
box-shadow: var(--shadow-sm);
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
|
| 720 |
+
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
|
| 721 |
+
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
|
| 722 |
+
.alert-info { background: var(--info-bg); border-color: var(--info); color: var(--info); }
|
| 723 |
+
|
| 724 |
+
.alert-content { flex: 1; }
|
| 725 |
+
.alert-title { font-weight: 800; margin-bottom: 6px; font-size: 15px; }
|
| 726 |
+
.alert-message { font-size: 14px; opacity: 0.9; }
|
| 727 |
+
|
| 728 |
+
/* Grid */
|
| 729 |
+
.grid { display: grid; gap: 20px; }
|
| 730 |
+
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
|
| 731 |
+
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
|
| 732 |
+
|
| 733 |
+
/* Input */
|
| 734 |
+
.input {
|
| 735 |
+
width: 100%;
|
| 736 |
+
padding: 12px 16px;
|
| 737 |
+
border-radius: var(--radius);
|
| 738 |
+
border: 2px solid var(--border);
|
| 739 |
+
background: var(--bg-card);
|
| 740 |
+
color: var(--text-primary);
|
| 741 |
+
font-family: inherit;
|
| 742 |
+
font-size: 14px;
|
| 743 |
+
transition: var(--transition);
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
.input:focus {
|
| 747 |
+
outline: none;
|
| 748 |
+
border-color: var(--accent-primary);
|
| 749 |
+
box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
/* Responsive */
|
| 753 |
+
@media (max-width: 768px) {
|
| 754 |
+
.container { padding: 16px; }
|
| 755 |
+
.header-top { flex-direction: column; align-items: flex-start; }
|
| 756 |
+
.kpi-grid { grid-template-columns: 1fr; }
|
| 757 |
+
.grid-2, .grid-3 { grid-template-columns: 1fr; }
|
| 758 |
+
.card-header { flex-direction: column; align-items: flex-start; gap: 16px; }
|
| 759 |
+
.card-actions { width: 100%; justify-content: flex-end; }
|
| 760 |
+
}
|
| 761 |
+
</style>
|
| 762 |
+
</head>
|
| 763 |
+
<body>
|
| 764 |
+
<div class="loading-overlay" id="loadingOverlay">
|
| 765 |
+
<div class="spinner"></div>
|
| 766 |
+
</div>
|
| 767 |
+
|
| 768 |
+
<div class="toast-container" id="toastContainer"></div>
|
| 769 |
+
|
| 770 |
+
<div class="container">
|
| 771 |
+
<div class="header">
|
| 772 |
+
<div class="header-top">
|
| 773 |
+
<div class="logo">
|
| 774 |
+
<div class="logo-icon">
|
| 775 |
+
<svg class="icon icon-lg" style="stroke: white;">
|
| 776 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 777 |
+
<path d="M12 6v6l4 2"></path>
|
| 778 |
+
</svg>
|
| 779 |
+
</div>
|
| 780 |
+
<div class="logo-text">
|
| 781 |
+
<h1>Crypto API Monitor</h1>
|
| 782 |
+
<p>Real-time Cryptocurrency API Resource Monitoring</p>
|
| 783 |
+
</div>
|
| 784 |
+
</div>
|
| 785 |
+
<div class="header-actions">
|
| 786 |
+
<div class="connection-status" id="wsStatus">
|
| 787 |
+
<span class="status-dot"></span>
|
| 788 |
+
<span id="wsStatusText">Connecting...</span>
|
| 789 |
+
</div>
|
| 790 |
+
<div class="status-badge" id="systemStatus">
|
| 791 |
+
<span class="status-dot"></span>
|
| 792 |
+
<span id="systemStatusText">System Active</span>
|
| 793 |
+
</div>
|
| 794 |
+
<button class="btn" onclick="refreshAll()">
|
| 795 |
+
<svg class="icon">
|
| 796 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 797 |
+
</svg>
|
| 798 |
+
Refresh All
|
| 799 |
+
</button>
|
| 800 |
+
</div>
|
| 801 |
+
</div>
|
| 802 |
+
|
| 803 |
+
<div class="kpi-grid" id="kpiGrid">
|
| 804 |
+
<div class="kpi-card">
|
| 805 |
+
<div class="kpi-header">
|
| 806 |
+
<span class="kpi-label">Total APIs</span>
|
| 807 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.1) 100%);">
|
| 808 |
+
<svg class="icon icon-lg" style="stroke: #3b82f6;">
|
| 809 |
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
| 810 |
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
| 811 |
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
| 812 |
+
</svg>
|
| 813 |
+
</div>
|
| 814 |
+
</div>
|
| 815 |
+
<div class="kpi-value" id="kpiTotalAPIs">--</div>
|
| 816 |
+
<div class="kpi-trend trend-neutral">
|
| 817 |
+
<svg class="icon" style="width: 16px; height: 16px;">
|
| 818 |
+
<path d="M12 20V10M18 20V4M6 20v-4"></path>
|
| 819 |
+
</svg>
|
| 820 |
+
<span id="kpiTotalTrend">Loading...</span>
|
| 821 |
+
</div>
|
| 822 |
+
</div>
|
| 823 |
+
|
| 824 |
+
<div class="kpi-card">
|
| 825 |
+
<div class="kpi-header">
|
| 826 |
+
<span class="kpi-label">Online</span>
|
| 827 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.1) 100%);">
|
| 828 |
+
<svg class="icon icon-lg" style="stroke: #10b981;">
|
| 829 |
+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
|
| 830 |
+
<polyline points="9 12 11 14 15 10"></polyline>
|
| 831 |
+
</svg>
|
| 832 |
+
</div>
|
| 833 |
+
</div>
|
| 834 |
+
<div class="kpi-value" id="kpiOnline">--</div>
|
| 835 |
+
<div class="kpi-trend trend-up">
|
| 836 |
+
<svg class="icon" style="width: 16px; height: 16px;">
|
| 837 |
+
<line x1="12" y1="19" x2="12" y2="5"></line>
|
| 838 |
+
<polyline points="5 12 12 5 19 12"></polyline>
|
| 839 |
+
</svg>
|
| 840 |
+
<span id="kpiOnlineTrend">Loading...</span>
|
| 841 |
+
</div>
|
| 842 |
+
</div>
|
| 843 |
+
|
| 844 |
+
<div class="kpi-card">
|
| 845 |
+
<div class="kpi-header">
|
| 846 |
+
<span class="kpi-label">Avg Response</span>
|
| 847 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.1) 100%);">
|
| 848 |
+
<svg class="icon icon-lg" style="stroke: #f59e0b;">
|
| 849 |
+
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path>
|
| 850 |
+
</svg>
|
| 851 |
+
</div>
|
| 852 |
+
</div>
|
| 853 |
+
<div class="kpi-value" id="kpiAvgResponse" style="font-size: 32px;">--</div>
|
| 854 |
+
<div class="kpi-trend trend-down">
|
| 855 |
+
<svg class="icon" style="width: 16px; height: 16px;">
|
| 856 |
+
<line x1="12" y1="5" x2="12" y2="19"></line>
|
| 857 |
+
<polyline points="19 12 12 19 5 12"></polyline>
|
| 858 |
+
</svg>
|
| 859 |
+
<span id="kpiResponseTrend">Loading...</span>
|
| 860 |
+
</div>
|
| 861 |
+
</div>
|
| 862 |
+
|
| 863 |
+
<div class="kpi-card">
|
| 864 |
+
<div class="kpi-header">
|
| 865 |
+
<span class="kpi-label">Last Update</span>
|
| 866 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(124, 58, 237, 0.1) 100%);">
|
| 867 |
+
<svg class="icon icon-lg" style="stroke: #8b5cf6;">
|
| 868 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 869 |
+
<polyline points="12 6 12 12 16 14"></polyline>
|
| 870 |
+
</svg>
|
| 871 |
+
</div>
|
| 872 |
+
</div>
|
| 873 |
+
<div class="kpi-value" id="kpiLastUpdate" style="font-size: 20px; line-height: 1.2;">--</div>
|
| 874 |
+
<div class="kpi-trend trend-neutral">
|
| 875 |
+
<svg class="icon" style="width: 16px; height: 16px;">
|
| 876 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 877 |
+
</svg>
|
| 878 |
+
<span>Auto-refresh enabled</span>
|
| 879 |
+
</div>
|
| 880 |
+
</div>
|
| 881 |
+
</div>
|
| 882 |
+
</div>
|
| 883 |
+
|
| 884 |
+
<div class="tabs">
|
| 885 |
+
<div class="tab active" onclick="switchTab(event, 'dashboard')">
|
| 886 |
+
<svg class="icon">
|
| 887 |
+
<rect x="3" y="3" width="7" height="7"></rect>
|
| 888 |
+
<rect x="14" y="3" width="7" height="7"></rect>
|
| 889 |
+
<rect x="14" y="14" width="7" height="7"></rect>
|
| 890 |
+
<rect x="3" y="14" width="7" height="7"></rect>
|
| 891 |
+
</svg>
|
| 892 |
+
<span>Dashboard</span>
|
| 893 |
+
</div>
|
| 894 |
+
<div class="tab" onclick="switchTab(event, 'providers')">
|
| 895 |
+
<svg class="icon">
|
| 896 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
| 897 |
+
<polyline points="14 2 14 8 20 8"></polyline>
|
| 898 |
+
</svg>
|
| 899 |
+
<span>Providers</span>
|
| 900 |
+
</div>
|
| 901 |
+
<div class="tab" onclick="switchTab(event, 'categories')">
|
| 902 |
+
<svg class="icon">
|
| 903 |
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
| 904 |
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
| 905 |
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
| 906 |
+
</svg>
|
| 907 |
+
<span>Categories</span>
|
| 908 |
+
</div>
|
| 909 |
+
<div class="tab" onclick="switchTab(event, 'ratelimits')">
|
| 910 |
+
<svg class="icon">
|
| 911 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 912 |
+
<polyline points="12 6 12 12 16 14"></polyline>
|
| 913 |
+
</svg>
|
| 914 |
+
<span>Rate Limits</span>
|
| 915 |
+
</div>
|
| 916 |
+
<div class="tab" onclick="switchTab(event, 'logs')">
|
| 917 |
+
<svg class="icon">
|
| 918 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
| 919 |
+
<polyline points="14 2 14 8 20 8"></polyline>
|
| 920 |
+
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 921 |
+
</svg>
|
| 922 |
+
<span>Logs</span>
|
| 923 |
+
</div>
|
| 924 |
+
<div class="tab" onclick="switchTab(event, 'alerts')">
|
| 925 |
+
<svg class="icon">
|
| 926 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 927 |
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
| 928 |
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
| 929 |
+
</svg>
|
| 930 |
+
<span>Alerts</span>
|
| 931 |
+
</div>
|
| 932 |
+
<div class="tab" onclick="switchTab(event, 'huggingface')">
|
| 933 |
+
<svg class="icon">
|
| 934 |
+
<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z"></path>
|
| 935 |
+
<circle cx="12" cy="12" r="3"></circle>
|
| 936 |
+
</svg>
|
| 937 |
+
<span>HuggingFace</span>
|
| 938 |
+
</div>
|
| 939 |
+
</div>
|
| 940 |
+
|
| 941 |
+
<!-- Dashboard Tab -->
|
| 942 |
+
<div class="tab-content active" id="tab-dashboard">
|
| 943 |
+
<div id="alertsContainer"></div>
|
| 944 |
+
|
| 945 |
+
<div class="card">
|
| 946 |
+
<div class="card-header">
|
| 947 |
+
<h2 class="card-title">
|
| 948 |
+
<svg class="icon icon-lg">
|
| 949 |
+
<rect x="3" y="3" width="7" height="7"></rect>
|
| 950 |
+
<rect x="14" y="3" width="7" height="7"></rect>
|
| 951 |
+
</svg>
|
| 952 |
+
System Overview
|
| 953 |
+
</h2>
|
| 954 |
+
<button class="btn btn-secondary" onclick="loadProviders()">
|
| 955 |
+
<svg class="icon">
|
| 956 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 957 |
+
</svg>
|
| 958 |
+
Refresh
|
| 959 |
+
</button>
|
| 960 |
+
</div>
|
| 961 |
+
<div class="table-container">
|
| 962 |
+
<table class="table">
|
| 963 |
+
<thead>
|
| 964 |
+
<tr>
|
| 965 |
+
<th>Provider</th>
|
| 966 |
+
<th>Category</th>
|
| 967 |
+
<th>Status</th>
|
| 968 |
+
<th>Response Time</th>
|
| 969 |
+
<th>Last Check</th>
|
| 970 |
+
</tr>
|
| 971 |
+
</thead>
|
| 972 |
+
<tbody id="providersTableBody">
|
| 973 |
+
<tr>
|
| 974 |
+
<td colspan="5">
|
| 975 |
+
<div class="loading-inline">
|
| 976 |
+
<div class="spinner-inline"></div>
|
| 977 |
+
Loading providers...
|
| 978 |
+
</div>
|
| 979 |
+
</td>
|
| 980 |
+
</tr>
|
| 981 |
+
</tbody>
|
| 982 |
+
</table>
|
| 983 |
+
</div>
|
| 984 |
+
</div>
|
| 985 |
+
|
| 986 |
+
<div class="grid grid-2">
|
| 987 |
+
<div class="card">
|
| 988 |
+
<div class="card-header">
|
| 989 |
+
<h2 class="card-title">
|
| 990 |
+
<svg class="icon icon-lg">
|
| 991 |
+
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline>
|
| 992 |
+
</svg>
|
| 993 |
+
Health Status
|
| 994 |
+
</h2>
|
| 995 |
+
</div>
|
| 996 |
+
<div class="chart-container">
|
| 997 |
+
<canvas id="healthChart"></canvas>
|
| 998 |
+
</div>
|
| 999 |
+
</div>
|
| 1000 |
+
|
| 1001 |
+
<div class="card">
|
| 1002 |
+
<div class="card-header">
|
| 1003 |
+
<h2 class="card-title">
|
| 1004 |
+
<svg class="icon icon-lg">
|
| 1005 |
+
<path d="M21.21 15.89A10 10 0 1 1 8 2.83"></path>
|
| 1006 |
+
</svg>
|
| 1007 |
+
Status Distribution
|
| 1008 |
+
</h2>
|
| 1009 |
+
</div>
|
| 1010 |
+
<div class="chart-container">
|
| 1011 |
+
<canvas id="statusChart"></canvas>
|
| 1012 |
+
</div>
|
| 1013 |
+
</div>
|
| 1014 |
+
</div>
|
| 1015 |
+
</div>
|
| 1016 |
+
|
| 1017 |
+
<!-- Providers Tab -->
|
| 1018 |
+
<div class="tab-content" id="tab-providers">
|
| 1019 |
+
<div class="card">
|
| 1020 |
+
<div class="card-header">
|
| 1021 |
+
<h2 class="card-title">
|
| 1022 |
+
<svg class="icon icon-lg">
|
| 1023 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1024 |
+
</svg>
|
| 1025 |
+
All Providers
|
| 1026 |
+
</h2>
|
| 1027 |
+
<button class="btn btn-secondary" onclick="loadProviders()">
|
| 1028 |
+
<svg class="icon">
|
| 1029 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1030 |
+
</svg>
|
| 1031 |
+
Refresh
|
| 1032 |
+
</button>
|
| 1033 |
+
</div>
|
| 1034 |
+
<div id="providersDetail">
|
| 1035 |
+
<div class="loading-inline">
|
| 1036 |
+
<div class="spinner-inline"></div>
|
| 1037 |
+
Loading providers details...
|
| 1038 |
+
</div>
|
| 1039 |
+
</div>
|
| 1040 |
+
</div>
|
| 1041 |
+
</div>
|
| 1042 |
+
|
| 1043 |
+
<!-- Categories Tab -->
|
| 1044 |
+
<div class="tab-content" id="tab-categories">
|
| 1045 |
+
<div class="card">
|
| 1046 |
+
<div class="card-header">
|
| 1047 |
+
<h2 class="card-title">
|
| 1048 |
+
<svg class="icon icon-lg">
|
| 1049 |
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
| 1050 |
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
| 1051 |
+
</svg>
|
| 1052 |
+
Categories Overview
|
| 1053 |
+
</h2>
|
| 1054 |
+
<button class="btn btn-secondary" onclick="loadCategories()">
|
| 1055 |
+
<svg class="icon">
|
| 1056 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1057 |
+
</svg>
|
| 1058 |
+
Refresh
|
| 1059 |
+
</button>
|
| 1060 |
+
</div>
|
| 1061 |
+
<div class="table-container">
|
| 1062 |
+
<table class="table">
|
| 1063 |
+
<thead>
|
| 1064 |
+
<tr>
|
| 1065 |
+
<th>Category</th>
|
| 1066 |
+
<th>Total Sources</th>
|
| 1067 |
+
<th>Online</th>
|
| 1068 |
+
<th>Health %</th>
|
| 1069 |
+
<th>Avg Response</th>
|
| 1070 |
+
<th>Last Updated</th>
|
| 1071 |
+
<th>Status</th>
|
| 1072 |
+
</tr>
|
| 1073 |
+
</thead>
|
| 1074 |
+
<tbody id="categoriesTableBody">
|
| 1075 |
+
<tr>
|
| 1076 |
+
<td colspan="7">
|
| 1077 |
+
<div class="loading-inline">
|
| 1078 |
+
<div class="spinner-inline"></div>
|
| 1079 |
+
Loading categories...
|
| 1080 |
+
</div>
|
| 1081 |
+
</td>
|
| 1082 |
+
</tr>
|
| 1083 |
+
</tbody>
|
| 1084 |
+
</table>
|
| 1085 |
+
</div>
|
| 1086 |
+
</div>
|
| 1087 |
+
</div>
|
| 1088 |
+
|
| 1089 |
+
<!-- Rate Limits Tab -->
|
| 1090 |
+
<div class="tab-content" id="tab-ratelimits">
|
| 1091 |
+
<div class="card">
|
| 1092 |
+
<div class="card-header">
|
| 1093 |
+
<h2 class="card-title">
|
| 1094 |
+
<svg class="icon icon-lg">
|
| 1095 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1096 |
+
<polyline points="12 6 12 12 16 14"></polyline>
|
| 1097 |
+
</svg>
|
| 1098 |
+
Rate Limit Monitor
|
| 1099 |
+
</h2>
|
| 1100 |
+
<button class="btn btn-secondary" onclick="loadRateLimits()">
|
| 1101 |
+
<svg class="icon">
|
| 1102 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1103 |
+
</svg>
|
| 1104 |
+
Refresh
|
| 1105 |
+
</button>
|
| 1106 |
+
</div>
|
| 1107 |
+
<div id="rateLimitCards" class="grid grid-2">
|
| 1108 |
+
<div class="loading-inline">
|
| 1109 |
+
<div class="spinner-inline"></div>
|
| 1110 |
+
Loading rate limits...
|
| 1111 |
+
</div>
|
| 1112 |
+
</div>
|
| 1113 |
+
</div>
|
| 1114 |
+
</div>
|
| 1115 |
+
|
| 1116 |
+
<!-- Logs Tab -->
|
| 1117 |
+
<div class="tab-content" id="tab-logs">
|
| 1118 |
+
<div class="card">
|
| 1119 |
+
<div class="card-header">
|
| 1120 |
+
<h2 class="card-title">
|
| 1121 |
+
<svg class="icon icon-lg">
|
| 1122 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
| 1123 |
+
<polyline points="14 2 14 8 20 8"></polyline>
|
| 1124 |
+
</svg>
|
| 1125 |
+
Connection Logs
|
| 1126 |
+
</h2>
|
| 1127 |
+
<div class="card-actions">
|
| 1128 |
+
<select id="logType" class="input" style="width: auto; padding: 10px 16px;" onchange="loadLogs()">
|
| 1129 |
+
<option value="connection">Connection</option>
|
| 1130 |
+
<option value="error">Error</option>
|
| 1131 |
+
<option value="rate_limit">Rate Limit</option>
|
| 1132 |
+
<option value="all">All</option>
|
| 1133 |
+
</select>
|
| 1134 |
+
<button class="btn btn-secondary" onclick="loadLogs()">
|
| 1135 |
+
<svg class="icon">
|
| 1136 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1137 |
+
</svg>
|
| 1138 |
+
Refresh
|
| 1139 |
+
</button>
|
| 1140 |
+
</div>
|
| 1141 |
+
</div>
|
| 1142 |
+
<div class="table-container">
|
| 1143 |
+
<table class="table">
|
| 1144 |
+
<thead>
|
| 1145 |
+
<tr>
|
| 1146 |
+
<th>Timestamp</th>
|
| 1147 |
+
<th>Provider</th>
|
| 1148 |
+
<th>Type</th>
|
| 1149 |
+
<th>Status</th>
|
| 1150 |
+
<th>Response Time</th>
|
| 1151 |
+
<th>Message</th>
|
| 1152 |
+
</tr>
|
| 1153 |
+
</thead>
|
| 1154 |
+
<tbody id="logsTableBody">
|
| 1155 |
+
<tr>
|
| 1156 |
+
<td colspan="6">
|
| 1157 |
+
<div class="loading-inline">
|
| 1158 |
+
<div class="spinner-inline"></div>
|
| 1159 |
+
Loading logs...
|
| 1160 |
+
</div>
|
| 1161 |
+
</td>
|
| 1162 |
+
</tr>
|
| 1163 |
+
</tbody>
|
| 1164 |
+
</table>
|
| 1165 |
+
</div>
|
| 1166 |
+
</div>
|
| 1167 |
+
</div>
|
| 1168 |
+
|
| 1169 |
+
<!-- Alerts Tab -->
|
| 1170 |
+
<div class="tab-content" id="tab-alerts">
|
| 1171 |
+
<div class="card">
|
| 1172 |
+
<div class="card-header">
|
| 1173 |
+
<h2 class="card-title">
|
| 1174 |
+
<svg class="icon icon-lg">
|
| 1175 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1176 |
+
<line x1="12" y1="8" x2="12" y2="12"></line>
|
| 1177 |
+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
| 1178 |
+
</svg>
|
| 1179 |
+
System Alerts
|
| 1180 |
+
</h2>
|
| 1181 |
+
<button class="btn btn-secondary" onclick="loadAlerts()">
|
| 1182 |
+
<svg class="icon">
|
| 1183 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1184 |
+
</svg>
|
| 1185 |
+
Refresh
|
| 1186 |
+
</button>
|
| 1187 |
+
</div>
|
| 1188 |
+
<div id="alertsList">
|
| 1189 |
+
<div class="loading-inline">
|
| 1190 |
+
<div class="spinner-inline"></div>
|
| 1191 |
+
Loading alerts...
|
| 1192 |
+
</div>
|
| 1193 |
+
</div>
|
| 1194 |
+
</div>
|
| 1195 |
+
</div>
|
| 1196 |
+
|
| 1197 |
+
<!-- HuggingFace Tab -->
|
| 1198 |
+
<div class="tab-content" id="tab-huggingface">
|
| 1199 |
+
<div class="card">
|
| 1200 |
+
<div class="card-header">
|
| 1201 |
+
<h2 class="card-title">
|
| 1202 |
+
<svg class="icon icon-lg">
|
| 1203 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1204 |
+
</svg>
|
| 1205 |
+
🤗 HuggingFace Health Status
|
| 1206 |
+
</h2>
|
| 1207 |
+
<div class="card-actions">
|
| 1208 |
+
<button class="btn" onclick="refreshHFRegistry()">
|
| 1209 |
+
<svg class="icon">
|
| 1210 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1211 |
+
</svg>
|
| 1212 |
+
Refresh Registry
|
| 1213 |
+
</button>
|
| 1214 |
+
</div>
|
| 1215 |
+
</div>
|
| 1216 |
+
<div id="hfHealthDisplay" style="padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); font-family: monospace; font-size: 13px; white-space: pre-wrap; max-height: 300px; overflow-y: auto; border: 2px solid var(--border);">
|
| 1217 |
+
Loading HF health status...
|
| 1218 |
+
</div>
|
| 1219 |
+
</div>
|
| 1220 |
+
|
| 1221 |
+
<div class="grid grid-2">
|
| 1222 |
+
<div class="card">
|
| 1223 |
+
<div class="card-header">
|
| 1224 |
+
<h2 class="card-title">
|
| 1225 |
+
Models Registry
|
| 1226 |
+
<span class="badge badge-success" id="hfModelsCount">0</span>
|
| 1227 |
+
</h2>
|
| 1228 |
+
</div>
|
| 1229 |
+
<div id="hfModelsList" style="max-height: 400px; overflow-y: auto;">
|
| 1230 |
+
<div class="loading-inline">
|
| 1231 |
+
<div class="spinner-inline"></div>
|
| 1232 |
+
Loading models...
|
| 1233 |
+
</div>
|
| 1234 |
+
</div>
|
| 1235 |
+
</div>
|
| 1236 |
+
|
| 1237 |
+
<div class="card">
|
| 1238 |
+
<div class="card-header">
|
| 1239 |
+
<h2 class="card-title">
|
| 1240 |
+
Datasets Registry
|
| 1241 |
+
<span class="badge badge-success" id="hfDatasetsCount">0</span>
|
| 1242 |
+
</h2>
|
| 1243 |
+
</div>
|
| 1244 |
+
<div id="hfDatasetsList" style="max-height: 400px; overflow-y: auto;">
|
| 1245 |
+
<div class="loading-inline">
|
| 1246 |
+
<div class="spinner-inline"></div>
|
| 1247 |
+
Loading datasets...
|
| 1248 |
+
</div>
|
| 1249 |
+
</div>
|
| 1250 |
+
</div>
|
| 1251 |
+
</div>
|
| 1252 |
+
|
| 1253 |
+
<div class="card">
|
| 1254 |
+
<div class="card-header">
|
| 1255 |
+
<h2 class="card-title">
|
| 1256 |
+
<svg class="icon icon-lg">
|
| 1257 |
+
<circle cx="11" cy="11" r="8"></circle>
|
| 1258 |
+
<path d="m21 21-4.35-4.35"></path>
|
| 1259 |
+
</svg>
|
| 1260 |
+
Search Registry
|
| 1261 |
+
</h2>
|
| 1262 |
+
</div>
|
| 1263 |
+
<div style="display: flex; gap: 12px; margin-bottom: 20px;">
|
| 1264 |
+
<input type="text" id="hfSearchQuery" placeholder="Search crypto, bitcoin, sentiment..." class="input" style="flex: 1;" value="crypto">
|
| 1265 |
+
<select id="hfSearchKind" class="input" style="width: auto; padding: 12px 16px;">
|
| 1266 |
+
<option value="models">Models</option>
|
| 1267 |
+
<option value="datasets">Datasets</option>
|
| 1268 |
+
</select>
|
| 1269 |
+
<button class="btn" onclick="searchHF()">
|
| 1270 |
+
<svg class="icon">
|
| 1271 |
+
<circle cx="11" cy="11" r="8"></circle>
|
| 1272 |
+
<path d="m21 21-4.35-4.35"></path>
|
| 1273 |
+
</svg>
|
| 1274 |
+
Search
|
| 1275 |
+
</button>
|
| 1276 |
+
</div>
|
| 1277 |
+
<div id="hfSearchResults" style="max-height: 400px; overflow-y: auto; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); border: 2px solid var(--border);">
|
| 1278 |
+
<div style="text-align: center; color: var(--text-muted);">Enter a query and click search</div>
|
| 1279 |
+
</div>
|
| 1280 |
+
</div>
|
| 1281 |
+
|
| 1282 |
+
<div class="card">
|
| 1283 |
+
<div class="card-header">
|
| 1284 |
+
<h2 class="card-title">💭 Sentiment Analysis</h2>
|
| 1285 |
+
</div>
|
| 1286 |
+
<div style="margin-bottom: 16px;">
|
| 1287 |
+
<label style="display: block; font-weight: 700; margin-bottom: 8px; color: var(--text-primary);">Text Samples (one per line)</label>
|
| 1288 |
+
<textarea id="hfSentimentTexts" rows="6" class="input" placeholder="BTC strong breakout ETH looks weak Crypto market is bullish today">BTC strong breakout
|
| 1289 |
+
ETH looks weak
|
| 1290 |
+
Crypto market is bullish today
|
| 1291 |
+
Bears are taking control
|
| 1292 |
+
Neutral market conditions</textarea>
|
| 1293 |
+
</div>
|
| 1294 |
+
<button class="btn" onclick="runHFSentiment()">
|
| 1295 |
+
<svg class="icon">
|
| 1296 |
+
<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z"></path>
|
| 1297 |
+
</svg>
|
| 1298 |
+
Run Sentiment Analysis
|
| 1299 |
+
</button>
|
| 1300 |
+
<div id="hfSentimentVote" style="margin: 20px 0; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); text-align: center; font-size: 32px; font-weight: 900; border: 2px solid var(--border);">
|
| 1301 |
+
<span style="color: var(--text-muted);">—</span>
|
| 1302 |
+
</div>
|
| 1303 |
+
<div id="hfSentimentResults" style="padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); font-family: monospace; font-size: 13px; white-space: pre-wrap; max-height: 400px; overflow-y: auto; border: 2px solid var(--border);">
|
| 1304 |
+
Results will appear here...
|
| 1305 |
+
</div>
|
| 1306 |
+
</div>
|
| 1307 |
+
</div>
|
| 1308 |
+
</div>
|
| 1309 |
+
|
| 1310 |
+
<script>
|
| 1311 |
+
// Configuration - آپدیت شده برای Hugging Face Spaces
|
| 1312 |
+
const config = {
|
| 1313 |
+
// استفاده از آدرس نسبی برای Hugging Face
|
| 1314 |
+
apiBaseUrl: '', // خالی بذارید تا از همون origin استفاده کنه
|
| 1315 |
+
wsUrl: (() => {
|
| 1316 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 1317 |
+
const host = window.location.host;
|
| 1318 |
+
return `${protocol}//${host}/ws`;
|
| 1319 |
+
})(),
|
| 1320 |
+
autoRefreshInterval: 30000,
|
| 1321 |
+
maxRetries: 3
|
| 1322 |
+
};
|
| 1323 |
+
|
| 1324 |
+
// Global state
|
| 1325 |
+
let state = {
|
| 1326 |
+
ws: null,
|
| 1327 |
+
wsConnected: false,
|
| 1328 |
+
autoRefreshEnabled: true,
|
| 1329 |
+
charts: {},
|
| 1330 |
+
currentTab: 'dashboard',
|
| 1331 |
+
providers: [],
|
| 1332 |
+
categories: [],
|
| 1333 |
+
rateLimits: [],
|
| 1334 |
+
logs: [],
|
| 1335 |
+
alerts: [],
|
| 1336 |
+
lastUpdate: null
|
| 1337 |
+
};
|
| 1338 |
+
|
| 1339 |
+
// Initialize on page load
|
| 1340 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 1341 |
+
console.log('🚀 Initializing Crypto API Monitor...');
|
| 1342 |
+
console.log('📍 API Base URL:', config.apiBaseUrl);
|
| 1343 |
+
console.log('📡 WebSocket URL:', config.wsUrl);
|
| 1344 |
+
|
| 1345 |
+
discoverEndpoints(); // کشف endpoint های موجود
|
| 1346 |
+
initializeWebSocket();
|
| 1347 |
+
loadInitialData();
|
| 1348 |
+
startAutoRefresh();
|
| 1349 |
+
});
|
| 1350 |
+
|
| 1351 |
+
// تابع برای کشف endpoint های موجود
|
| 1352 |
+
async function discoverEndpoints() {
|
| 1353 |
+
console.log('🔍 Discovering available endpoints...');
|
| 1354 |
+
|
| 1355 |
+
const testEndpoints = [
|
| 1356 |
+
'/',
|
| 1357 |
+
'/health',
|
| 1358 |
+
'/api/health',
|
| 1359 |
+
'/info',
|
| 1360 |
+
'/api/info',
|
| 1361 |
+
'/providers',
|
| 1362 |
+
'/api/providers',
|
| 1363 |
+
'/status',
|
| 1364 |
+
'/api/status',
|
| 1365 |
+
'/api/crypto/market-overview',
|
| 1366 |
+
'/api/crypto/prices/top'
|
| 1367 |
+
];
|
| 1368 |
+
|
| 1369 |
+
const availableEndpoints = [];
|
| 1370 |
+
|
| 1371 |
+
for (const endpoint of testEndpoints) {
|
| 1372 |
+
try {
|
| 1373 |
+
const response = await fetch(endpoint);
|
| 1374 |
+
console.log(`${endpoint}: ${response.status}`);
|
| 1375 |
+
if (response.ok) {
|
| 1376 |
+
availableEndpoints.push(endpoint);
|
| 1377 |
+
console.log(`✅ Found: ${endpoint}`);
|
| 1378 |
+
}
|
| 1379 |
+
} catch (error) {
|
| 1380 |
+
console.log(`❌ Failed: ${endpoint}`);
|
| 1381 |
+
}
|
| 1382 |
+
}
|
| 1383 |
+
|
| 1384 |
+
console.log('📋 Available endpoints:', availableEndpoints);
|
| 1385 |
+
return availableEndpoints;
|
| 1386 |
+
}
|
| 1387 |
+
|
| 1388 |
+
// WebSocket Connection
|
| 1389 |
+
function initializeWebSocket() {
|
| 1390 |
+
updateWSStatus('connecting');
|
| 1391 |
+
|
| 1392 |
+
const wsEndpoints = [
|
| 1393 |
+
'/ws/live',
|
| 1394 |
+
'/ws',
|
| 1395 |
+
'/live',
|
| 1396 |
+
'/api/ws'
|
| 1397 |
+
];
|
| 1398 |
+
|
| 1399 |
+
for (const endpoint of wsEndpoints) {
|
| 1400 |
+
try {
|
| 1401 |
+
const wsUrl = `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}${endpoint}`;
|
| 1402 |
+
console.log(`🔄 Trying WebSocket: ${wsUrl}`);
|
| 1403 |
+
|
| 1404 |
+
state.ws = new WebSocket(wsUrl);
|
| 1405 |
+
setupWebSocketHandlers();
|
| 1406 |
+
break; // اگر موفق بود، بقیه رو امتحان نکن
|
| 1407 |
+
} catch (error) {
|
| 1408 |
+
console.log(`❌ WebSocket failed: ${endpoint}`);
|
| 1409 |
+
}
|
| 1410 |
+
}
|
| 1411 |
+
|
| 1412 |
+
if (!state.ws) {
|
| 1413 |
+
console.log('⚠️ No WebSocket endpoints available');
|
| 1414 |
+
updateWSStatus('disconnected');
|
| 1415 |
+
}
|
| 1416 |
+
}
|
| 1417 |
+
|
| 1418 |
+
function setupWebSocketHandlers() {
|
| 1419 |
+
state.ws.onopen = () => {
|
| 1420 |
+
console.log('✅ WebSocket connected');
|
| 1421 |
+
state.wsConnected = true;
|
| 1422 |
+
updateWSStatus('connected');
|
| 1423 |
+
showToast('Connected', 'Real-time data stream active', 'success');
|
| 1424 |
+
};
|
| 1425 |
+
|
| 1426 |
+
state.ws.onmessage = (event) => {
|
| 1427 |
+
try {
|
| 1428 |
+
const data = JSON.parse(event.data);
|
| 1429 |
+
handleWSMessage(data);
|
| 1430 |
+
} catch (error) {
|
| 1431 |
+
console.error('Error parsing WebSocket message:', error);
|
| 1432 |
+
}
|
| 1433 |
+
};
|
| 1434 |
+
|
| 1435 |
+
state.ws.onerror = (error) => {
|
| 1436 |
+
console.error('❌ WebSocket error:', error);
|
| 1437 |
+
updateWSStatus('disconnected');
|
| 1438 |
+
};
|
| 1439 |
+
|
| 1440 |
+
state.ws.onclose = () => {
|
| 1441 |
+
console.log('⚠️ WebSocket disconnected');
|
| 1442 |
+
state.wsConnected = false;
|
| 1443 |
+
updateWSStatus('disconnected');
|
| 1444 |
+
};
|
| 1445 |
+
}
|
| 1446 |
+
|
| 1447 |
+
function updateWSStatus(status) {
|
| 1448 |
+
const statusEl = document.getElementById('wsStatus');
|
| 1449 |
+
const textEl = document.getElementById('wsStatusText');
|
| 1450 |
+
|
| 1451 |
+
statusEl.classList.remove('connected', 'disconnected', 'connecting');
|
| 1452 |
+
statusEl.classList.add(status);
|
| 1453 |
+
|
| 1454 |
+
const statusText = {
|
| 1455 |
+
'connected': '✓ Connected',
|
| 1456 |
+
'disconnected': '✗ Disconnected',
|
| 1457 |
+
'connecting': '⟳ Connecting...'
|
| 1458 |
+
};
|
| 1459 |
+
|
| 1460 |
+
textEl.textContent = statusText[status] || 'Unknown';
|
| 1461 |
+
}
|
| 1462 |
+
|
| 1463 |
+
function handleWSMessage(data) {
|
| 1464 |
+
console.log('📨 WebSocket message:', data.type);
|
| 1465 |
+
|
| 1466 |
+
switch(data.type) {
|
| 1467 |
+
case 'status_update':
|
| 1468 |
+
updateKPIs(data.data);
|
| 1469 |
+
break;
|
| 1470 |
+
case 'provider_status_change':
|
| 1471 |
+
loadProviders();
|
| 1472 |
+
break;
|
| 1473 |
+
case 'new_alert':
|
| 1474 |
+
addAlert(data.data);
|
| 1475 |
+
break;
|
| 1476 |
+
default:
|
| 1477 |
+
console.log('Unknown message type:', data.type);
|
| 1478 |
+
}
|
| 1479 |
+
}
|
| 1480 |
+
|
| 1481 |
+
// API Calls - آپدیت شده با endpoint های جایگزین
|
| 1482 |
+
async function apiCall(endpoint, options = {}) {
|
| 1483 |
+
try {
|
| 1484 |
+
const url = `${config.apiBaseUrl}${endpoint}`;
|
| 1485 |
+
console.log('🌐 API Call:', url);
|
| 1486 |
+
|
| 1487 |
+
const response = await fetch(url, {
|
| 1488 |
+
...options,
|
| 1489 |
+
headers: {
|
| 1490 |
+
'Content-Type': 'application/json',
|
| 1491 |
+
...options.headers
|
| 1492 |
+
}
|
| 1493 |
+
});
|
| 1494 |
+
|
| 1495 |
+
if (!response.ok) {
|
| 1496 |
+
// اگر 404 باشه، endpoint های جایگزین رو چک کن
|
| 1497 |
+
if (response.status === 404) {
|
| 1498 |
+
console.log(`⚠️ Endpoint ${endpoint} not found, trying alternatives...`);
|
| 1499 |
+
return await tryAlternativeEndpoints(endpoint, options);
|
| 1500 |
+
}
|
| 1501 |
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
| 1502 |
+
}
|
| 1503 |
+
|
| 1504 |
+
const data = await response.json();
|
| 1505 |
+
console.log('✅ API Response:', endpoint, data);
|
| 1506 |
+
return data;
|
| 1507 |
+
} catch (error) {
|
| 1508 |
+
console.error(`❌ API call failed: ${endpoint}`, error);
|
| 1509 |
+
showToast('API Error', `Failed: ${endpoint}`, 'error');
|
| 1510 |
+
throw error;
|
| 1511 |
+
}
|
| 1512 |
+
}
|
| 1513 |
+
|
| 1514 |
+
// تابع برای امتحان endpoint های جایگزین
|
| 1515 |
+
async function tryAlternativeEndpoints(originalEndpoint, options) {
|
| 1516 |
+
const alternatives = {
|
| 1517 |
+
'/api/providers': ['/providers', '/api/sources', '/status'],
|
| 1518 |
+
'/health': ['/api/health', '/status/health'],
|
| 1519 |
+
'/info': ['/api/info', '/system/info'],
|
| 1520 |
+
'/api/categories': ['/categories', '/api/groups'],
|
| 1521 |
+
'/api/rate-limits': ['/rate-limits', '/api/limits'],
|
| 1522 |
+
'/api/logs': ['/logs', '/api/events'],
|
| 1523 |
+
'/api/alerts': ['/alerts', '/api/notifications'],
|
| 1524 |
+
'/api/hf/health': ['/hf/health', '/api/huggingface/health'],
|
| 1525 |
+
'/api/hf/refresh': ['/hf/refresh', '/api/huggingface/refresh'],
|
| 1526 |
+
'/api/hf/registry': ['/hf/registry', '/api/huggingface/registry'],
|
| 1527 |
+
'/api/hf/search': ['/hf/search', '/api/huggingface/search'],
|
| 1528 |
+
'/api/hf/run-sentiment': ['/hf/sentiment', '/api/huggingface/sentiment']
|
| 1529 |
+
};
|
| 1530 |
+
|
| 1531 |
+
for (const altEndpoint of alternatives[originalEndpoint] || []) {
|
| 1532 |
+
try {
|
| 1533 |
+
const url = `${config.apiBaseUrl}${altEndpoint}`;
|
| 1534 |
+
console.log(`🔄 Trying alternative: ${altEndpoint}`);
|
| 1535 |
+
|
| 1536 |
+
const response = await fetch(url, options);
|
| 1537 |
+
if (response.ok) {
|
| 1538 |
+
const data = await response.json();
|
| 1539 |
+
console.log(`✅ Alternative endpoint worked: ${altEndpoint}`);
|
| 1540 |
+
return data;
|
| 1541 |
+
}
|
| 1542 |
+
} catch (error) {
|
| 1543 |
+
console.log(`❌ Alternative failed: ${altEndpoint}`);
|
| 1544 |
+
}
|
| 1545 |
+
}
|
| 1546 |
+
|
| 1547 |
+
throw new Error(`All endpoints failed for ${originalEndpoint}`);
|
| 1548 |
+
}
|
| 1549 |
+
|
| 1550 |
+
async function loadInitialData() {
|
| 1551 |
+
showLoading();
|
| 1552 |
+
|
| 1553 |
+
try {
|
| 1554 |
+
console.log('📊 Loading initial data...');
|
| 1555 |
+
|
| 1556 |
+
await loadHealth();
|
| 1557 |
+
await loadProviders();
|
| 1558 |
+
await loadSystemInfo();
|
| 1559 |
+
|
| 1560 |
+
initializeCharts();
|
| 1561 |
+
|
| 1562 |
+
state.lastUpdate = new Date();
|
| 1563 |
+
updateLastUpdateDisplay();
|
| 1564 |
+
|
| 1565 |
+
console.log('✅ Initial data loaded successfully');
|
| 1566 |
+
showToast('Success', 'Dashboard loaded successfully', 'success');
|
| 1567 |
+
} catch (error) {
|
| 1568 |
+
console.error('❌ Error loading initial data:', error);
|
| 1569 |
+
showToast('Error', 'Failed to load initial data', 'error');
|
| 1570 |
+
} finally {
|
| 1571 |
+
hideLoading();
|
| 1572 |
+
}
|
| 1573 |
+
}
|
| 1574 |
+
|
| 1575 |
+
async function loadHealth() {
|
| 1576 |
+
try {
|
| 1577 |
+
const data = await apiCall('/health');
|
| 1578 |
+
updateKPIs(data.components || data);
|
| 1579 |
+
|
| 1580 |
+
const statusBadge = document.getElementById('systemStatus');
|
| 1581 |
+
const statusText = document.getElementById('systemStatusText');
|
| 1582 |
+
|
| 1583 |
+
if (data.status === 'healthy') {
|
| 1584 |
+
statusBadge.style.background = 'linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08))';
|
| 1585 |
+
statusBadge.style.borderColor = 'rgba(16, 185, 129, 0.4)';
|
| 1586 |
+
statusBadge.style.color = 'var(--success)';
|
| 1587 |
+
statusText.textContent = '✓ System Healthy';
|
| 1588 |
+
} else if (data.status === 'degraded') {
|
| 1589 |
+
statusBadge.style.background = 'linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08))';
|
| 1590 |
+
statusBadge.style.borderColor = 'rgba(245, 158, 11, 0.4)';
|
| 1591 |
+
statusBadge.style.color = 'var(--warning)';
|
| 1592 |
+
statusText.textContent = '⚠ System Degraded';
|
| 1593 |
+
} else {
|
| 1594 |
+
statusBadge.style.background = 'linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08))';
|
| 1595 |
+
statusBadge.style.borderColor = 'rgba(239, 68, 68, 0.4)';
|
| 1596 |
+
statusBadge.style.color = 'var(--danger)';
|
| 1597 |
+
statusText.textContent = '✗ System Critical';
|
| 1598 |
+
}
|
| 1599 |
+
} catch (error) {
|
| 1600 |
+
console.error('Error loading health:', error);
|
| 1601 |
+
}
|
| 1602 |
+
}
|
| 1603 |
+
|
| 1604 |
+
async function loadSystemInfo() {
|
| 1605 |
+
try {
|
| 1606 |
+
const data = await apiCall('/info');
|
| 1607 |
+
console.log('📋 System Info:', data);
|
| 1608 |
+
} catch (error) {
|
| 1609 |
+
console.error('Error loading system info:', error);
|
| 1610 |
+
}
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
async function loadProviders() {
|
| 1614 |
+
try {
|
| 1615 |
+
const data = await apiCall('/api/providers');
|
| 1616 |
+
state.providers = data;
|
| 1617 |
+
renderProvidersTable(data);
|
| 1618 |
+
renderProvidersDetail(data);
|
| 1619 |
+
updateStatusChart(data);
|
| 1620 |
+
} catch (error) {
|
| 1621 |
+
console.error('Error loading providers:', error);
|
| 1622 |
+
document.getElementById('providersTableBody').innerHTML = `
|
| 1623 |
+
<tr>
|
| 1624 |
+
<td colspan="5" style="text-align: center; color: var(--text-muted); padding: 40px;">
|
| 1625 |
+
Failed to load providers. Please check if the API endpoint is available.
|
| 1626 |
+
</td>
|
| 1627 |
+
</tr>
|
| 1628 |
+
`;
|
| 1629 |
+
}
|
| 1630 |
+
}
|
| 1631 |
+
|
| 1632 |
+
async function loadCategories() {
|
| 1633 |
+
try {
|
| 1634 |
+
showLoading();
|
| 1635 |
+
const data = await apiCall('/api/categories');
|
| 1636 |
+
state.categories = data;
|
| 1637 |
+
renderCategoriesTable(data);
|
| 1638 |
+
showToast('Success', 'Categories loaded successfully', 'success');
|
| 1639 |
+
} catch (error) {
|
| 1640 |
+
console.error('Error loading categories:', error);
|
| 1641 |
+
showToast('Error', 'Failed to load categories', 'error');
|
| 1642 |
+
} finally {
|
| 1643 |
+
hideLoading();
|
| 1644 |
+
}
|
| 1645 |
+
}
|
| 1646 |
+
|
| 1647 |
+
async function loadRateLimits() {
|
| 1648 |
+
try {
|
| 1649 |
+
showLoading();
|
| 1650 |
+
const data = await apiCall('/api/rate-limits');
|
| 1651 |
+
state.rateLimits = data;
|
| 1652 |
+
renderRateLimitCards(data);
|
| 1653 |
+
showToast('Success', 'Rate limits loaded successfully', 'success');
|
| 1654 |
+
} catch (error) {
|
| 1655 |
+
console.error('Error loading rate limits:', error);
|
| 1656 |
+
showToast('Error', 'Failed to load rate limits', 'error');
|
| 1657 |
+
} finally {
|
| 1658 |
+
hideLoading();
|
| 1659 |
+
}
|
| 1660 |
+
}
|
| 1661 |
+
|
| 1662 |
+
async function loadLogs() {
|
| 1663 |
+
try {
|
| 1664 |
+
showLoading();
|
| 1665 |
+
const logType = document.getElementById('logType').value;
|
| 1666 |
+
const data = await apiCall(`/api/logs?type=${logType}`);
|
| 1667 |
+
state.logs = data;
|
| 1668 |
+
renderLogsTable(data);
|
| 1669 |
+
showToast('Success', 'Logs loaded successfully', 'success');
|
| 1670 |
+
} catch (error) {
|
| 1671 |
+
console.error('Error loading logs:', error);
|
| 1672 |
+
showToast('Error', 'Failed to load logs', 'error');
|
| 1673 |
+
} finally {
|
| 1674 |
+
hideLoading();
|
| 1675 |
+
}
|
| 1676 |
+
}
|
| 1677 |
+
|
| 1678 |
+
async function loadAlerts() {
|
| 1679 |
+
try {
|
| 1680 |
+
showLoading();
|
| 1681 |
+
const data = await apiCall('/api/alerts');
|
| 1682 |
+
state.alerts = data;
|
| 1683 |
+
renderAlertsList(data);
|
| 1684 |
+
showToast('Success', 'Alerts loaded successfully', 'success');
|
| 1685 |
+
} catch (error) {
|
| 1686 |
+
console.error('Error loading alerts:', error);
|
| 1687 |
+
showToast('Error', 'Failed to load alerts', 'error');
|
| 1688 |
+
} finally {
|
| 1689 |
+
hideLoading();
|
| 1690 |
+
}
|
| 1691 |
+
}
|
| 1692 |
+
|
| 1693 |
+
// HuggingFace APIs
|
| 1694 |
+
async function loadHFHealth() {
|
| 1695 |
+
try {
|
| 1696 |
+
const data = await apiCall('/api/hf/health');
|
| 1697 |
+
document.getElementById('hfHealthDisplay').textContent = JSON.stringify(data, null, 2);
|
| 1698 |
+
} catch (error) {
|
| 1699 |
+
console.error('Error loading HF health:', error);
|
| 1700 |
+
document.getElementById('hfHealthDisplay').textContent = 'Error loading health status';
|
| 1701 |
+
}
|
| 1702 |
+
}
|
| 1703 |
+
|
| 1704 |
+
async function refreshHFRegistry() {
|
| 1705 |
+
try {
|
| 1706 |
+
showLoading();
|
| 1707 |
+
const data = await apiCall('/api/hf/refresh', { method: 'POST' });
|
| 1708 |
+
showToast('Success', 'HF Registry refreshed', 'success');
|
| 1709 |
+
loadHFModels();
|
| 1710 |
+
loadHFDatasets();
|
| 1711 |
+
} catch (error) {
|
| 1712 |
+
console.error('Error refreshing HF registry:', error);
|
| 1713 |
+
showToast('Error', 'Failed to refresh registry', 'error');
|
| 1714 |
+
} finally {
|
| 1715 |
+
hideLoading();
|
| 1716 |
+
}
|
| 1717 |
+
}
|
| 1718 |
+
|
| 1719 |
+
async function loadHFModels() {
|
| 1720 |
+
try {
|
| 1721 |
+
const data = await apiCall('/api/hf/registry?type=models');
|
| 1722 |
+
document.getElementById('hfModelsCount').textContent = data.length || 0;
|
| 1723 |
+
document.getElementById('hfModelsList').innerHTML = data.map(item => `
|
| 1724 |
+
<div style="padding: 12px; border-bottom: 1px solid var(--border);">
|
| 1725 |
+
<div style="font-weight: 700; margin-bottom: 4px;">${item.id || 'Unknown'}</div>
|
| 1726 |
+
<div style="font-size: 12px; color: var(--text-muted);">${item.description || 'No description'}</div>
|
| 1727 |
+
</div>
|
| 1728 |
+
`).join('');
|
| 1729 |
+
} catch (error) {
|
| 1730 |
+
console.error('Error loading HF models:', error);
|
| 1731 |
+
document.getElementById('hfModelsList').innerHTML = '<div style="padding: 20px; text-align: center; color: var(--text-muted);">Error loading models</div>';
|
| 1732 |
+
}
|
| 1733 |
+
}
|
| 1734 |
+
|
| 1735 |
+
async function loadHFDatasets() {
|
| 1736 |
+
try {
|
| 1737 |
+
const data = await apiCall('/api/hf/registry?type=datasets');
|
| 1738 |
+
document.getElementById('hfDatasetsCount').textContent = data.length || 0;
|
| 1739 |
+
document.getElementById('hfDatasetsList').innerHTML = data.map(item => `
|
| 1740 |
+
<div style="padding: 12px; border-bottom: 1px solid var(--border);">
|
| 1741 |
+
<div style="font-weight: 700; margin-bottom: 4px;">${item.id || 'Unknown'}</div>
|
| 1742 |
+
<div style="font-size: 12px; color: var(--text-muted);">${item.description || 'No description'}</div>
|
| 1743 |
+
</div>
|
| 1744 |
+
`).join('');
|
| 1745 |
+
} catch (error) {
|
| 1746 |
+
console.error('Error loading HF datasets:', error);
|
| 1747 |
+
document.getElementById('hfDatasetsList').innerHTML = '<div style="padding: 20px; text-align: center; color: var(--text-muted);">Error loading datasets</div>';
|
| 1748 |
+
}
|
| 1749 |
+
}
|
| 1750 |
+
|
| 1751 |
+
async function searchHF() {
|
| 1752 |
+
try {
|
| 1753 |
+
showLoading();
|
| 1754 |
+
const query = document.getElementById('hfSearchQuery').value;
|
| 1755 |
+
const kind = document.getElementById('hfSearchKind').value;
|
| 1756 |
+
const data = await apiCall(`/api/hf/search?q=${encodeURIComponent(query)}&kind=${kind}`);
|
| 1757 |
+
|
| 1758 |
+
document.getElementById('hfSearchResults').innerHTML = data.map(item => `
|
| 1759 |
+
<div style="padding: 12px; border-bottom: 1px solid var(--border);">
|
| 1760 |
+
<div style="font-weight: 700; margin-bottom: 4px;">${item.id || 'Unknown'}</div>
|
| 1761 |
+
<div style="font-size: 12px; color: var(--text-muted); margin-bottom: 4px;">${item.description || 'No description'}</div>
|
| 1762 |
+
<div style="font-size: 11px; color: var(--accent-primary);">Downloads: ${item.downloads || 0} • Likes: ${item.likes || 0}</div>
|
| 1763 |
+
</div>
|
| 1764 |
+
`).join('');
|
| 1765 |
+
|
| 1766 |
+
showToast('Success', `Found ${data.length} results`, 'success');
|
| 1767 |
+
} catch (error) {
|
| 1768 |
+
console.error('Error searching HF:', error);
|
| 1769 |
+
showToast('Error', 'Search failed', 'error');
|
| 1770 |
+
} finally {
|
| 1771 |
+
hideLoading();
|
| 1772 |
+
}
|
| 1773 |
+
}
|
| 1774 |
+
|
| 1775 |
+
async function runHFSentiment() {
|
| 1776 |
+
try {
|
| 1777 |
+
showLoading();
|
| 1778 |
+
const texts = document.getElementById('hfSentimentTexts').value.split('\n').filter(t => t.trim());
|
| 1779 |
+
|
| 1780 |
+
const data = await apiCall('/api/hf/run-sentiment', {
|
| 1781 |
+
method: 'POST',
|
| 1782 |
+
body: JSON.stringify({ texts: texts })
|
| 1783 |
+
});
|
| 1784 |
+
|
| 1785 |
+
document.getElementById('hfSentimentResults').textContent = JSON.stringify(data, null, 2);
|
| 1786 |
+
|
| 1787 |
+
// Calculate overall sentiment vote
|
| 1788 |
+
const sentiments = data.results || [];
|
| 1789 |
+
const positive = sentiments.filter(s => s.sentiment === 'positive').length;
|
| 1790 |
+
const negative = sentiments.filter(s => s.sentiment === 'negative').length;
|
| 1791 |
+
const neutral = sentiments.filter(s => s.sentiment === 'neutral').length;
|
| 1792 |
+
|
| 1793 |
+
let overall = 'NEUTRAL';
|
| 1794 |
+
let color = 'var(--info)';
|
| 1795 |
+
|
| 1796 |
+
if (positive > negative && positive > neutral) {
|
| 1797 |
+
overall = 'BULLISH 📈';
|
| 1798 |
+
color = 'var(--success)';
|
| 1799 |
+
} else if (negative > positive && negative > neutral) {
|
| 1800 |
+
overall = 'BEARISH 📉';
|
| 1801 |
+
color = 'var(--danger)';
|
| 1802 |
+
}
|
| 1803 |
+
|
| 1804 |
+
document.getElementById('hfSentimentVote').innerHTML = `
|
| 1805 |
+
<span style="color: ${color};">${overall}</span>
|
| 1806 |
+
<div style="font-size: 14px; margin-top: 8px; color: var(--text-muted);">
|
| 1807 |
+
Positive: ${positive} • Negative: ${negative} • Neutral: ${neutral}
|
| 1808 |
+
</div>
|
| 1809 |
+
`;
|
| 1810 |
+
|
| 1811 |
+
showToast('Success', 'Sentiment analysis completed', 'success');
|
| 1812 |
+
} catch (error) {
|
| 1813 |
+
console.error('Error running sentiment analysis:', error);
|
| 1814 |
+
showToast('Error', 'Sentiment analysis failed', 'error');
|
| 1815 |
+
} finally {
|
| 1816 |
+
hideLoading();
|
| 1817 |
+
}
|
| 1818 |
+
}
|
| 1819 |
+
|
| 1820 |
+
// Rendering Functions
|
| 1821 |
+
function renderProvidersTable(providers) {
|
| 1822 |
+
const tbody = document.getElementById('providersTableBody');
|
| 1823 |
+
|
| 1824 |
+
if (!providers || providers.length === 0) {
|
| 1825 |
+
tbody.innerHTML = `
|
| 1826 |
+
<tr>
|
| 1827 |
+
<td colspan="5" style="text-align: center; color: var(--text-muted); padding: 40px;">
|
| 1828 |
+
No providers found
|
| 1829 |
+
</td>
|
| 1830 |
+
</tr>
|
| 1831 |
+
`;
|
| 1832 |
+
return;
|
| 1833 |
+
}
|
| 1834 |
+
|
| 1835 |
+
tbody.innerHTML = providers.map(provider => `
|
| 1836 |
+
<tr>
|
| 1837 |
+
<td>
|
| 1838 |
+
<strong>${provider.name || 'Unknown'}</strong>
|
| 1839 |
+
<div style="font-size: 12px; color: var(--text-muted);">${provider.base_url || ''}</div>
|
| 1840 |
+
</td>
|
| 1841 |
+
<td>${provider.category || 'General'}</td>
|
| 1842 |
+
<td>
|
| 1843 |
+
<span class="badge ${getStatusBadgeClass(provider.status)}">
|
| 1844 |
+
${provider.status || 'unknown'}
|
| 1845 |
+
</span>
|
| 1846 |
+
</td>
|
| 1847 |
+
<td>${provider.response_time ? provider.response_time + 'ms' : '--'}</td>
|
| 1848 |
+
<td>
|
| 1849 |
+
<div style="font-size: 12px; font-weight: 700;">${formatTimestamp(provider.last_checked)}</div>
|
| 1850 |
+
<div style="font-size: 11px; color: var(--text-muted);">${formatTimeAgo(provider.last_checked)}</div>
|
| 1851 |
+
</td>
|
| 1852 |
+
</tr>
|
| 1853 |
+
`).join('');
|
| 1854 |
+
}
|
| 1855 |
+
|
| 1856 |
+
function renderProvidersDetail(providers) {
|
| 1857 |
+
const container = document.getElementById('providersDetail');
|
| 1858 |
+
|
| 1859 |
+
if (!providers || providers.length === 0) {
|
| 1860 |
+
container.innerHTML = `
|
| 1861 |
+
<div style="text-align: center; color: var(--text-muted); padding: 40px;">
|
| 1862 |
+
No providers data available
|
| 1863 |
+
</div>
|
| 1864 |
+
`;
|
| 1865 |
+
return;
|
| 1866 |
+
}
|
| 1867 |
+
|
| 1868 |
+
container.innerHTML = `
|
| 1869 |
+
<div class="table-container">
|
| 1870 |
+
<table class="table">
|
| 1871 |
+
<thead>
|
| 1872 |
+
<tr>
|
| 1873 |
+
<th>Provider</th>
|
| 1874 |
+
<th>Status</th>
|
| 1875 |
+
<th>Response Time</th>
|
| 1876 |
+
<th>Success Rate</th>
|
| 1877 |
+
<th>Last Success</th>
|
| 1878 |
+
<th>Errors (24h)</th>
|
| 1879 |
+
</tr>
|
| 1880 |
+
</thead>
|
| 1881 |
+
<tbody>
|
| 1882 |
+
${providers.map(provider => `
|
| 1883 |
+
<tr>
|
| 1884 |
+
<td>
|
| 1885 |
+
<strong>${provider.name || 'Unknown'}</strong>
|
| 1886 |
+
<div style="font-size: 12px; color: var(--text-muted);">${provider.base_url || ''}</div>
|
| 1887 |
+
</td>
|
| 1888 |
+
<td>
|
| 1889 |
+
<span class="badge ${getStatusBadgeClass(provider.status)}">
|
| 1890 |
+
${provider.status || 'unknown'}
|
| 1891 |
+
</span>
|
| 1892 |
+
</td>
|
| 1893 |
+
<td>${provider.response_time ? provider.response_time + 'ms' : '--'}</td>
|
| 1894 |
+
<td>
|
| 1895 |
+
<div class="progress">
|
| 1896 |
+
<div class="progress-bar ${getHealthClass(provider.success_rate || 0)}"
|
| 1897 |
+
style="width: ${provider.success_rate || 0}%"></div>
|
| 1898 |
+
</div>
|
| 1899 |
+
<small>${Math.round(provider.success_rate || 0)}%</small>
|
| 1900 |
+
</td>
|
| 1901 |
+
<td>${formatTimestamp(provider.last_success)}</td>
|
| 1902 |
+
<td>${provider.error_count_24h || 0}</td>
|
| 1903 |
+
</tr>
|
| 1904 |
+
`).join('')}
|
| 1905 |
+
</tbody>
|
| 1906 |
+
</table>
|
| 1907 |
+
</div>
|
| 1908 |
+
`;
|
| 1909 |
+
}
|
| 1910 |
+
|
| 1911 |
+
function renderCategoriesTable(categories) {
|
| 1912 |
+
const tbody = document.getElementById('categoriesTableBody');
|
| 1913 |
+
|
| 1914 |
+
if (!categories || categories.length === 0) {
|
| 1915 |
+
tbody.innerHTML = `
|
| 1916 |
+
<tr>
|
| 1917 |
+
<td colspan="7" style="text-align: center; color: var(--text-muted); padding: 40px;">
|
| 1918 |
+
No categories found
|
| 1919 |
+
</td>
|
| 1920 |
+
</tr>
|
| 1921 |
+
`;
|
| 1922 |
+
return;
|
| 1923 |
+
}
|
| 1924 |
+
|
| 1925 |
+
tbody.innerHTML = categories.map(category => `
|
| 1926 |
+
<tr>
|
| 1927 |
+
<td>
|
| 1928 |
+
<strong>${category.name || 'Unnamed'}</strong>
|
| 1929 |
+
</td>
|
| 1930 |
+
<td>${category.total_sources || 0}</td>
|
| 1931 |
+
<td>${category.online || 0}</td>
|
| 1932 |
+
<td>
|
| 1933 |
+
<div class="progress">
|
| 1934 |
+
<div class="progress-bar ${getHealthClass(category.health_percentage || 0)}"
|
| 1935 |
+
style="width: ${category.health_percentage || 0}%"></div>
|
| 1936 |
+
</div>
|
| 1937 |
+
<small>${Math.round(category.health_percentage || 0)}%</small>
|
| 1938 |
+
</td>
|
| 1939 |
+
<td>${category.avg_response || '--'}ms</td>
|
| 1940 |
+
<td>${formatTimestamp(category.last_updated)}</td>
|
| 1941 |
+
<td>
|
| 1942 |
+
<span class="badge ${getStatusBadgeClass(category.status)}">
|
| 1943 |
+
${category.status || 'unknown'}
|
| 1944 |
+
</span>
|
| 1945 |
+
</td>
|
| 1946 |
+
</tr>
|
| 1947 |
+
`).join('');
|
| 1948 |
+
}
|
| 1949 |
+
|
| 1950 |
+
function renderRateLimitCards(rateLimits) {
|
| 1951 |
+
const container = document.getElementById('rateLimitCards');
|
| 1952 |
+
|
| 1953 |
+
if (!rateLimits || rateLimits.length === 0) {
|
| 1954 |
+
container.innerHTML = `
|
| 1955 |
+
<div class="card" style="grid-column: 1 / -1; text-align: center; padding: 40px;">
|
| 1956 |
+
<div style="color: var(--text-muted); font-size: 16px;">
|
| 1957 |
+
No rate limit data available
|
| 1958 |
+
</div>
|
| 1959 |
+
</div>
|
| 1960 |
+
`;
|
| 1961 |
+
return;
|
| 1962 |
+
}
|
| 1963 |
+
|
| 1964 |
+
container.innerHTML = rateLimits.map(limit => `
|
| 1965 |
+
<div class="card">
|
| 1966 |
+
<div class="card-header">
|
| 1967 |
+
<h3 class="card-title" style="font-size: 16px;">
|
| 1968 |
+
${limit.provider || 'Unknown Provider'}
|
| 1969 |
+
</h3>
|
| 1970 |
+
<span class="badge ${getRateLimitStatusClass(limit)}">
|
| 1971 |
+
${getRateLimitStatus(limit)}
|
| 1972 |
+
</span>
|
| 1973 |
+
</div>
|
| 1974 |
+
|
| 1975 |
+
<div style="margin-bottom: 16px;">
|
| 1976 |
+
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
| 1977 |
+
<span style="font-size: 12px; color: var(--text-muted);">Usage</span>
|
| 1978 |
+
<span style="font-size: 12px; font-weight: 700;">
|
| 1979 |
+
${limit.used || 0}/${limit.limit || 0}
|
| 1980 |
+
</span>
|
| 1981 |
+
</div>
|
| 1982 |
+
<div class="progress">
|
| 1983 |
+
<div class="progress-bar ${getRateLimitProgressClass(limit)}"
|
| 1984 |
+
style="width: ${calculateUsagePercentage(limit)}%"></div>
|
| 1985 |
+
</div>
|
| 1986 |
+
</div>
|
| 1987 |
+
|
| 1988 |
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 12px;">
|
| 1989 |
+
<div>
|
| 1990 |
+
<div style="color: var(--text-muted);">Reset In</div>
|
| 1991 |
+
<div style="font-weight: 700;">${formatResetTime(limit.reset_time)}</div>
|
| 1992 |
+
</div>
|
| 1993 |
+
<div>
|
| 1994 |
+
<div style="color: var(--text-muted);">Window</div>
|
| 1995 |
+
<div style="font-weight: 700;">${limit.window || 'N/A'}</div>
|
| 1996 |
+
</div>
|
| 1997 |
+
</div>
|
| 1998 |
+
|
| 1999 |
+
${limit.endpoint ? `
|
| 2000 |
+
<div style="margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);">
|
| 2001 |
+
<div style="font-size: 11px; color: var(--text-muted);">Endpoint</div>
|
| 2002 |
+
<div style="font-size: 12px; font-family: monospace;">${limit.endpoint}</div>
|
| 2003 |
+
</div>
|
| 2004 |
+
` : ''}
|
| 2005 |
+
</div>
|
| 2006 |
+
`).join('');
|
| 2007 |
+
}
|
| 2008 |
+
|
| 2009 |
+
function renderLogsTable(logs) {
|
| 2010 |
+
const tbody = document.getElementById('logsTableBody');
|
| 2011 |
+
|
| 2012 |
+
if (!logs || logs.length === 0) {
|
| 2013 |
+
tbody.innerHTML = `
|
| 2014 |
+
<tr>
|
| 2015 |
+
<td colspan="6" style="text-align: center; color: var(--text-muted); padding: 40px;">
|
| 2016 |
+
No logs found
|
| 2017 |
+
</td>
|
| 2018 |
+
</tr>
|
| 2019 |
+
`;
|
| 2020 |
+
return;
|
| 2021 |
+
}
|
| 2022 |
+
|
| 2023 |
+
tbody.innerHTML = logs.map(log => `
|
| 2024 |
+
<tr>
|
| 2025 |
+
<td>
|
| 2026 |
+
<div style="font-size: 12px; font-weight: 700;">${formatTimestamp(log.timestamp)}</div>
|
| 2027 |
+
<div style="font-size: 11px; color: var(--text-muted);">${formatTimeAgo(log.timestamp)}</div>
|
| 2028 |
+
</td>
|
| 2029 |
+
<td>
|
| 2030 |
+
<strong>${log.provider || 'System'}</strong>
|
| 2031 |
+
</td>
|
| 2032 |
+
<td>
|
| 2033 |
+
<span class="badge ${getLogTypeClass(log.type)}">
|
| 2034 |
+
${log.type || 'unknown'}
|
| 2035 |
+
</span>
|
| 2036 |
+
</td>
|
| 2037 |
+
<td>
|
| 2038 |
+
<span class="badge ${getStatusBadgeClass(log.status)}">
|
| 2039 |
+
${log.status || 'unknown'}
|
| 2040 |
+
</span>
|
| 2041 |
+
</td>
|
| 2042 |
+
<td>${log.response_time ? log.response_time + 'ms' : '--'}</td>
|
| 2043 |
+
<td>
|
| 2044 |
+
<div style="max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
| 2045 |
+
${log.message || 'No message'}
|
| 2046 |
+
</div>
|
| 2047 |
+
</td>
|
| 2048 |
+
</tr>
|
| 2049 |
+
`).join('');
|
| 2050 |
+
}
|
| 2051 |
+
|
| 2052 |
+
function renderAlertsList(alerts) {
|
| 2053 |
+
const container = document.getElementById('alertsList');
|
| 2054 |
+
|
| 2055 |
+
if (!alerts || alerts.length === 0) {
|
| 2056 |
+
container.innerHTML = `
|
| 2057 |
+
<div class="alert alert-success">
|
| 2058 |
+
<div class="alert-content">
|
| 2059 |
+
<div class="alert-title">No Active Alerts</div>
|
| 2060 |
+
<div class="alert-message">All systems are operating normally</div>
|
| 2061 |
+
</div>
|
| 2062 |
+
</div>
|
| 2063 |
+
`;
|
| 2064 |
+
return;
|
| 2065 |
+
}
|
| 2066 |
+
|
| 2067 |
+
container.innerHTML = alerts.map(alert => `
|
| 2068 |
+
<div class="alert ${getAlertClass(alert.severity)}">
|
| 2069 |
+
<div class="alert-content">
|
| 2070 |
+
<div class="alert-title">
|
| 2071 |
+
${alert.title || 'Alert'}
|
| 2072 |
+
<span style="font-size: 11px; margin-left: 8px; opacity: 0.8;">
|
| 2073 |
+
${formatTimeAgo(alert.timestamp)}
|
| 2074 |
+
</span>
|
| 2075 |
+
</div>
|
| 2076 |
+
<div class="alert-message">
|
| 2077 |
+
${alert.message || 'No message provided'}
|
| 2078 |
+
</div>
|
| 2079 |
+
${alert.provider ? `
|
| 2080 |
+
<div style="margin-top: 8px; font-size: 12px;">
|
| 2081 |
+
<strong>Provider:</strong> ${alert.provider}
|
| 2082 |
+
</div>
|
| 2083 |
+
` : ''}
|
| 2084 |
+
</div>
|
| 2085 |
+
</div>
|
| 2086 |
+
`).join('');
|
| 2087 |
+
}
|
| 2088 |
+
|
| 2089 |
+
// Helper functions
|
| 2090 |
+
function getHealthClass(percentage) {
|
| 2091 |
+
if (percentage >= 80) return 'success';
|
| 2092 |
+
if (percentage >= 60) return 'warning';
|
| 2093 |
+
return 'danger';
|
| 2094 |
+
}
|
| 2095 |
+
|
| 2096 |
+
function getStatusBadgeClass(status) {
|
| 2097 |
+
switch (status?.toLowerCase()) {
|
| 2098 |
+
case 'healthy': case 'online': case 'success': return 'badge-success';
|
| 2099 |
+
case 'degraded': case 'warning': return 'badge-warning';
|
| 2100 |
+
case 'offline': case 'error': case 'critical': return 'badge-danger';
|
| 2101 |
+
default: return 'badge-info';
|
| 2102 |
+
}
|
| 2103 |
+
}
|
| 2104 |
+
|
| 2105 |
+
function getLogTypeClass(type) {
|
| 2106 |
+
switch (type?.toLowerCase()) {
|
| 2107 |
+
case 'error': return 'badge-danger';
|
| 2108 |
+
case 'warning': return 'badge-warning';
|
| 2109 |
+
case 'info': case 'connection': return 'badge-info';
|
| 2110 |
+
case 'success': return 'badge-success';
|
| 2111 |
+
default: return 'badge-info';
|
| 2112 |
+
}
|
| 2113 |
+
}
|
| 2114 |
+
|
| 2115 |
+
function getAlertClass(severity) {
|
| 2116 |
+
switch (severity?.toLowerCase()) {
|
| 2117 |
+
case 'critical': case 'error': return 'alert-danger';
|
| 2118 |
+
case 'warning': return 'alert-warning';
|
| 2119 |
+
case 'info': return 'alert-info';
|
| 2120 |
+
case 'success': return 'alert-success';
|
| 2121 |
+
default: return 'alert-info';
|
| 2122 |
+
}
|
| 2123 |
+
}
|
| 2124 |
+
|
| 2125 |
+
function getRateLimitStatusClass(limit) {
|
| 2126 |
+
const usage = calculateUsagePercentage(limit);
|
| 2127 |
+
if (usage >= 90) return 'badge-danger';
|
| 2128 |
+
if (usage >= 75) return 'badge-warning';
|
| 2129 |
+
return 'badge-success';
|
| 2130 |
+
}
|
| 2131 |
+
|
| 2132 |
+
function getRateLimitStatus(limit) {
|
| 2133 |
+
const usage = calculateUsagePercentage(limit);
|
| 2134 |
+
if (usage >= 90) return 'Critical';
|
| 2135 |
+
if (usage >= 75) return 'Warning';
|
| 2136 |
+
return 'Normal';
|
| 2137 |
+
}
|
| 2138 |
+
|
| 2139 |
+
function getRateLimitProgressClass(limit) {
|
| 2140 |
+
const usage = calculateUsagePercentage(limit);
|
| 2141 |
+
if (usage >= 90) return 'danger';
|
| 2142 |
+
if (usage >= 75) return 'warning';
|
| 2143 |
+
return 'success';
|
| 2144 |
+
}
|
| 2145 |
+
|
| 2146 |
+
function calculateUsagePercentage(limit) {
|
| 2147 |
+
if (!limit.limit || limit.limit === 0) return 0;
|
| 2148 |
+
return Math.min(100, ((limit.used || 0) / limit.limit) * 100);
|
| 2149 |
+
}
|
| 2150 |
+
|
| 2151 |
+
function formatResetTime(resetTime) {
|
| 2152 |
+
if (!resetTime) return 'N/A';
|
| 2153 |
+
// Simple formatting - you can enhance this with proper time parsing
|
| 2154 |
+
return typeof resetTime === 'string' ? resetTime : 'Soon';
|
| 2155 |
+
}
|
| 2156 |
+
|
| 2157 |
+
function formatTimestamp(timestamp) {
|
| 2158 |
+
if (!timestamp) return '--';
|
| 2159 |
+
try {
|
| 2160 |
+
return new Date(timestamp).toLocaleString();
|
| 2161 |
+
} catch {
|
| 2162 |
+
return 'Invalid Date';
|
| 2163 |
+
}
|
| 2164 |
+
}
|
| 2165 |
+
|
| 2166 |
+
function formatTimeAgo(timestamp) {
|
| 2167 |
+
if (!timestamp) return '';
|
| 2168 |
+
try {
|
| 2169 |
+
const now = new Date();
|
| 2170 |
+
const time = new Date(timestamp);
|
| 2171 |
+
const diff = now - time;
|
| 2172 |
+
|
| 2173 |
+
const minutes = Math.floor(diff / 60000);
|
| 2174 |
+
const hours = Math.floor(diff / 3600000);
|
| 2175 |
+
const days = Math.floor(diff / 86400000);
|
| 2176 |
+
|
| 2177 |
+
if (days > 0) return `${days}d ago`;
|
| 2178 |
+
if (hours > 0) return `${hours}h ago`;
|
| 2179 |
+
if (minutes > 0) return `${minutes}m ago`;
|
| 2180 |
+
return 'Just now';
|
| 2181 |
+
} catch {
|
| 2182 |
+
return 'Unknown';
|
| 2183 |
+
}
|
| 2184 |
+
}
|
| 2185 |
+
|
| 2186 |
+
// KPI Updates
|
| 2187 |
+
function updateKPIs(data) {
|
| 2188 |
+
if (!data) return;
|
| 2189 |
+
|
| 2190 |
+
// Update Total APIs
|
| 2191 |
+
const totalAPIs = data.length || 0;
|
| 2192 |
+
document.getElementById('kpiTotalAPIs').textContent = totalAPIs;
|
| 2193 |
+
document.getElementById('kpiTotalTrend').textContent = `${totalAPIs} active`;
|
| 2194 |
+
|
| 2195 |
+
// Update Online count
|
| 2196 |
+
const onlineCount = data.filter(p => p.status === 'online' || p.status === 'healthy').length;
|
| 2197 |
+
document.getElementById('kpiOnline').textContent = onlineCount;
|
| 2198 |
+
document.getElementById('kpiOnlineTrend').textContent = `${Math.round((onlineCount / totalAPIs) * 100)}% uptime`;
|
| 2199 |
+
|
| 2200 |
+
// Update Average Response
|
| 2201 |
+
const validResponses = data.filter(p => p.response_time).map(p => p.response_time);
|
| 2202 |
+
const avgResponse = validResponses.length > 0 ?
|
| 2203 |
+
Math.round(validResponses.reduce((a, b) => a + b, 0) / validResponses.length) : 0;
|
| 2204 |
+
|
| 2205 |
+
document.getElementById('kpiAvgResponse').textContent = avgResponse + 'ms';
|
| 2206 |
+
|
| 2207 |
+
const responseTrend = avgResponse < 500 ? 'Optimal' : avgResponse < 1000 ? 'Acceptable' : 'Slow';
|
| 2208 |
+
document.getElementById('kpiResponseTrend').textContent = responseTrend;
|
| 2209 |
+
|
| 2210 |
+
const trendElement = document.querySelector('#kpiAvgResponse').nextElementSibling;
|
| 2211 |
+
trendElement.className = `kpi-trend ${
|
| 2212 |
+
avgResponse < 500 ? 'trend-up' : avgResponse < 1000 ? 'trend-neutral' : 'trend-down'
|
| 2213 |
+
}`;
|
| 2214 |
+
}
|
| 2215 |
+
|
| 2216 |
+
function updateLastUpdateDisplay() {
|
| 2217 |
+
if (state.lastUpdate) {
|
| 2218 |
+
document.getElementById('kpiLastUpdate').textContent =
|
| 2219 |
+
state.lastUpdate.toLocaleTimeString() + '\n' + state.lastUpdate.toLocaleDateString();
|
| 2220 |
+
}
|
| 2221 |
+
}
|
| 2222 |
+
|
| 2223 |
+
// Chart Functions
|
| 2224 |
+
function initializeCharts() {
|
| 2225 |
+
// Health Chart
|
| 2226 |
+
const healthCtx = document.getElementById('healthChart').getContext('2d');
|
| 2227 |
+
state.charts.health = new Chart(healthCtx, {
|
| 2228 |
+
type: 'line',
|
| 2229 |
+
data: {
|
| 2230 |
+
labels: [],
|
| 2231 |
+
datasets: [{
|
| 2232 |
+
label: 'System Health %',
|
| 2233 |
+
data: [],
|
| 2234 |
+
borderColor: '#8b5cf6',
|
| 2235 |
+
backgroundColor: 'rgba(139, 92, 246, 0.1)',
|
| 2236 |
+
borderWidth: 3,
|
| 2237 |
+
fill: true,
|
| 2238 |
+
tension: 0.4
|
| 2239 |
+
}]
|
| 2240 |
+
},
|
| 2241 |
+
options: {
|
| 2242 |
+
responsive: true,
|
| 2243 |
+
maintainAspectRatio: false,
|
| 2244 |
+
plugins: {
|
| 2245 |
+
legend: {
|
| 2246 |
+
display: false
|
| 2247 |
+
}
|
| 2248 |
+
},
|
| 2249 |
+
scales: {
|
| 2250 |
+
y: {
|
| 2251 |
+
beginAtZero: true,
|
| 2252 |
+
max: 100,
|
| 2253 |
+
grid: {
|
| 2254 |
+
color: 'rgba(139, 92, 246, 0.1)'
|
| 2255 |
+
}
|
| 2256 |
+
},
|
| 2257 |
+
x: {
|
| 2258 |
+
grid: {
|
| 2259 |
+
color: 'rgba(139, 92, 246, 0.1)'
|
| 2260 |
+
}
|
| 2261 |
+
}
|
| 2262 |
+
}
|
| 2263 |
+
}
|
| 2264 |
+
});
|
| 2265 |
+
|
| 2266 |
+
// Status Chart
|
| 2267 |
+
const statusCtx = document.getElementById('statusChart').getContext('2d');
|
| 2268 |
+
state.charts.status = new Chart(statusCtx, {
|
| 2269 |
+
type: 'doughnut',
|
| 2270 |
+
data: {
|
| 2271 |
+
labels: ['Online', 'Degraded', 'Offline'],
|
| 2272 |
+
datasets: [{
|
| 2273 |
+
data: [0, 0, 0],
|
| 2274 |
+
backgroundColor: [
|
| 2275 |
+
'#10b981',
|
| 2276 |
+
'#f59e0b',
|
| 2277 |
+
'#ef4444'
|
| 2278 |
+
],
|
| 2279 |
+
borderWidth: 0
|
| 2280 |
+
}]
|
| 2281 |
+
},
|
| 2282 |
+
options: {
|
| 2283 |
+
responsive: true,
|
| 2284 |
+
maintainAspectRatio: false,
|
| 2285 |
+
cutout: '70%',
|
| 2286 |
+
plugins: {
|
| 2287 |
+
legend: {
|
| 2288 |
+
position: 'bottom'
|
| 2289 |
+
}
|
| 2290 |
+
}
|
| 2291 |
+
}
|
| 2292 |
+
});
|
| 2293 |
+
}
|
| 2294 |
+
|
| 2295 |
+
function updateStatusChart(providers) {
|
| 2296 |
+
if (!state.charts.status || !providers) return;
|
| 2297 |
+
|
| 2298 |
+
const online = providers.filter(p => p.status === 'online' || p.status === 'healthy').length;
|
| 2299 |
+
const degraded = providers.filter(p => p.status === 'degraded' || p.status === 'warning').length;
|
| 2300 |
+
const offline = providers.filter(p => p.status === 'offline' || p.status === 'error').length;
|
| 2301 |
+
|
| 2302 |
+
state.charts.status.data.datasets[0].data = [online, degraded, offline];
|
| 2303 |
+
state.charts.status.update();
|
| 2304 |
+
}
|
| 2305 |
+
|
| 2306 |
+
// Tab Management
|
| 2307 |
+
function switchTab(event, tabName) {
|
| 2308 |
+
// Remove active class from all tabs
|
| 2309 |
+
document.querySelectorAll('.tab').forEach(tab => {
|
| 2310 |
+
tab.classList.remove('active');
|
| 2311 |
+
});
|
| 2312 |
+
|
| 2313 |
+
// Remove active class from all contents
|
| 2314 |
+
document.querySelectorAll('.tab-content').forEach(content => {
|
| 2315 |
+
content.classList.remove('active');
|
| 2316 |
+
});
|
| 2317 |
+
|
| 2318 |
+
// Add active class to clicked tab
|
| 2319 |
+
event.currentTarget.classList.add('active');
|
| 2320 |
+
|
| 2321 |
+
// Show corresponding content
|
| 2322 |
+
document.getElementById(`tab-${tabName}`).classList.add('active');
|
| 2323 |
+
|
| 2324 |
+
// Load data for the tab
|
| 2325 |
+
switch(tabName) {
|
| 2326 |
+
case 'dashboard':
|
| 2327 |
+
loadProviders();
|
| 2328 |
+
break;
|
| 2329 |
+
case 'providers':
|
| 2330 |
+
loadProviders();
|
| 2331 |
+
break;
|
| 2332 |
+
case 'categories':
|
| 2333 |
+
loadCategories();
|
| 2334 |
+
break;
|
| 2335 |
+
case 'ratelimits':
|
| 2336 |
+
loadRateLimits();
|
| 2337 |
+
break;
|
| 2338 |
+
case 'logs':
|
| 2339 |
+
loadLogs();
|
| 2340 |
+
break;
|
| 2341 |
+
case 'alerts':
|
| 2342 |
+
loadAlerts();
|
| 2343 |
+
break;
|
| 2344 |
+
case 'huggingface':
|
| 2345 |
+
loadHFHealth();
|
| 2346 |
+
loadHFModels();
|
| 2347 |
+
loadHFDatasets();
|
| 2348 |
+
break;
|
| 2349 |
+
}
|
| 2350 |
+
|
| 2351 |
+
state.currentTab = tabName;
|
| 2352 |
+
}
|
| 2353 |
+
|
| 2354 |
+
// Utility Functions
|
| 2355 |
+
function showLoading() {
|
| 2356 |
+
document.getElementById('loadingOverlay').classList.add('active');
|
| 2357 |
+
}
|
| 2358 |
+
|
| 2359 |
+
function hideLoading() {
|
| 2360 |
+
document.getElementById('loadingOverlay').classList.remove('active');
|
| 2361 |
+
}
|
| 2362 |
+
|
| 2363 |
+
function showToast(title, message, type = 'info') {
|
| 2364 |
+
const container = document.getElementById('toastContainer');
|
| 2365 |
+
const toast = document.createElement('div');
|
| 2366 |
+
toast.className = `toast ${type}`;
|
| 2367 |
+
toast.innerHTML = `
|
| 2368 |
+
<div class="toast-content">
|
| 2369 |
+
<div class="toast-title">${title}</div>
|
| 2370 |
+
<div class="toast-message">${message}</div>
|
| 2371 |
+
</div>
|
| 2372 |
+
<button onclick="this.parentElement.remove()" style="background: none; border: none; cursor: pointer; color: inherit;">
|
| 2373 |
+
<svg class="icon" style="width: 16px; height: 16px;">
|
| 2374 |
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
| 2375 |
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
| 2376 |
+
</svg>
|
| 2377 |
+
</button>
|
| 2378 |
+
`;
|
| 2379 |
+
|
| 2380 |
+
container.appendChild(toast);
|
| 2381 |
+
|
| 2382 |
+
// Auto remove after 5 seconds
|
| 2383 |
+
setTimeout(() => {
|
| 2384 |
+
if (toast.parentElement) {
|
| 2385 |
+
toast.remove();
|
| 2386 |
+
}
|
| 2387 |
+
}, 5000);
|
| 2388 |
+
}
|
| 2389 |
+
|
| 2390 |
+
function addAlert(alert) {
|
| 2391 |
+
const container = document.getElementById('alertsContainer');
|
| 2392 |
+
const alertEl = document.createElement('div');
|
| 2393 |
+
alertEl.className = `alert ${getAlertClass(alert.severity)}`;
|
| 2394 |
+
alertEl.innerHTML = `
|
| 2395 |
+
<div class="alert-content">
|
| 2396 |
+
<div class="alert-title">
|
| 2397 |
+
${alert.title}
|
| 2398 |
+
<span style="font-size: 11px; margin-left: 8px; opacity: 0.8;">
|
| 2399 |
+
${formatTimeAgo(alert.timestamp)}
|
| 2400 |
+
</span>
|
| 2401 |
+
</div>
|
| 2402 |
+
<div class="alert-message">${alert.message}</div>
|
| 2403 |
+
</div>
|
| 2404 |
+
`;
|
| 2405 |
+
|
| 2406 |
+
container.appendChild(alertEl);
|
| 2407 |
+
|
| 2408 |
+
// Auto remove after 10 seconds
|
| 2409 |
+
setTimeout(() => {
|
| 2410 |
+
if (alertEl.parentElement) {
|
| 2411 |
+
alertEl.remove();
|
| 2412 |
+
}
|
| 2413 |
+
}, 10000);
|
| 2414 |
+
}
|
| 2415 |
+
|
| 2416 |
+
function refreshAll() {
|
| 2417 |
+
console.log('🔄 Refreshing all data...');
|
| 2418 |
+
loadInitialData();
|
| 2419 |
+
|
| 2420 |
+
// Refresh current tab data
|
| 2421 |
+
switch(state.currentTab) {
|
| 2422 |
+
case 'categories':
|
| 2423 |
+
loadCategories();
|
| 2424 |
+
break;
|
| 2425 |
+
case 'ratelimits':
|
| 2426 |
+
loadRateLimits();
|
| 2427 |
+
break;
|
| 2428 |
+
case 'logs':
|
| 2429 |
+
loadLogs();
|
| 2430 |
+
break;
|
| 2431 |
+
case 'alerts':
|
| 2432 |
+
loadAlerts();
|
| 2433 |
+
break;
|
| 2434 |
+
case 'huggingface':
|
| 2435 |
+
loadHFHealth();
|
| 2436 |
+
loadHFModels();
|
| 2437 |
+
loadHFDatasets();
|
| 2438 |
+
break;
|
| 2439 |
+
}
|
| 2440 |
+
}
|
| 2441 |
+
|
| 2442 |
+
function startAutoRefresh() {
|
| 2443 |
+
setInterval(() => {
|
| 2444 |
+
if (state.autoRefreshEnabled && state.wsConnected) {
|
| 2445 |
+
console.log('🔄 Auto-refreshing data...');
|
| 2446 |
+
refreshAll();
|
| 2447 |
+
}
|
| 2448 |
+
}, config.autoRefreshInterval);
|
| 2449 |
+
}
|
| 2450 |
+
</script>
|
| 2451 |
+
</body>
|
| 2452 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>🚀 Crypto API Monitor - Professional Dashboard</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
:root {
|
| 11 |
+
--bg-primary: #0f0f23;
|
| 12 |
+
--bg-secondary: #1a1a2e;
|
| 13 |
+
--bg-card: #16213e;
|
| 14 |
+
--bg-hover: #1f2b4d;
|
| 15 |
+
--text-primary: #ffffff;
|
| 16 |
+
--text-secondary: #b8c1ec;
|
| 17 |
+
--text-muted: #8892b0;
|
| 18 |
+
|
| 19 |
+
--accent-blue: #00d4ff;
|
| 20 |
+
--accent-purple: #a855f7;
|
| 21 |
+
--accent-pink: #ec4899;
|
| 22 |
+
--accent-green: #10b981;
|
| 23 |
+
--accent-yellow: #fbbf24;
|
| 24 |
+
--accent-red: #ef4444;
|
| 25 |
+
--accent-orange: #f97316;
|
| 26 |
+
--accent-cyan: #06b6d4;
|
| 27 |
+
|
| 28 |
+
--success: #10b981;
|
| 29 |
+
--success-glow: rgba(16, 185, 129, 0.3);
|
| 30 |
+
--warning: #fbbf24;
|
| 31 |
+
--warning-glow: rgba(251, 191, 36, 0.3);
|
| 32 |
+
--danger: #ef4444;
|
| 33 |
+
--danger-glow: rgba(239, 68, 68, 0.3);
|
| 34 |
+
--info: #00d4ff;
|
| 35 |
+
--info-glow: rgba(0, 212, 255, 0.3);
|
| 36 |
+
|
| 37 |
+
--border: rgba(255, 255, 255, 0.1);
|
| 38 |
+
--shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
| 39 |
+
--shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
|
| 40 |
+
--glow: 0 0 20px;
|
| 41 |
+
|
| 42 |
+
--radius: 16px;
|
| 43 |
+
--radius-lg: 24px;
|
| 44 |
+
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
* {
|
| 48 |
+
margin: 0;
|
| 49 |
+
padding: 0;
|
| 50 |
+
box-sizing: border-box;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
body {
|
| 54 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
| 55 |
+
background: var(--bg-primary);
|
| 56 |
+
color: var(--text-primary);
|
| 57 |
+
line-height: 1.6;
|
| 58 |
+
min-height: 100vh;
|
| 59 |
+
overflow-x: hidden;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/* Animated Background */
|
| 63 |
+
body::before {
|
| 64 |
+
content: '';
|
| 65 |
+
position: fixed;
|
| 66 |
+
top: 0;
|
| 67 |
+
left: 0;
|
| 68 |
+
right: 0;
|
| 69 |
+
bottom: 0;
|
| 70 |
+
background:
|
| 71 |
+
radial-gradient(circle at 20% 30%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
|
| 72 |
+
radial-gradient(circle at 80% 70%, rgba(0, 212, 255, 0.15) 0%, transparent 50%),
|
| 73 |
+
radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.1) 0%, transparent 70%);
|
| 74 |
+
pointer-events: none;
|
| 75 |
+
z-index: 0;
|
| 76 |
+
animation: backgroundPulse 20s ease-in-out infinite;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
@keyframes backgroundPulse {
|
| 80 |
+
0%, 100% { opacity: 0.5; }
|
| 81 |
+
50% { opacity: 0.8; }
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.container {
|
| 85 |
+
max-width: 1800px;
|
| 86 |
+
margin: 0 auto;
|
| 87 |
+
padding: 32px;
|
| 88 |
+
position: relative;
|
| 89 |
+
z-index: 1;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/* Header */
|
| 93 |
+
.header {
|
| 94 |
+
background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
|
| 95 |
+
border: 2px solid var(--border);
|
| 96 |
+
border-radius: var(--radius-lg);
|
| 97 |
+
padding: 40px;
|
| 98 |
+
margin-bottom: 32px;
|
| 99 |
+
box-shadow: var(--shadow-lg);
|
| 100 |
+
position: relative;
|
| 101 |
+
overflow: hidden;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.header::before {
|
| 105 |
+
content: '';
|
| 106 |
+
position: absolute;
|
| 107 |
+
top: 0;
|
| 108 |
+
left: 0;
|
| 109 |
+
right: 0;
|
| 110 |
+
height: 4px;
|
| 111 |
+
background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
|
| 112 |
+
animation: gradientSlide 3s linear infinite;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
@keyframes gradientSlide {
|
| 116 |
+
0% { transform: translateX(-100%); }
|
| 117 |
+
100% { transform: translateX(100%); }
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.header-top {
|
| 121 |
+
display: flex;
|
| 122 |
+
align-items: center;
|
| 123 |
+
justify-content: space-between;
|
| 124 |
+
flex-wrap: wrap;
|
| 125 |
+
gap: 24px;
|
| 126 |
+
margin-bottom: 32px;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.logo {
|
| 130 |
+
display: flex;
|
| 131 |
+
align-items: center;
|
| 132 |
+
gap: 20px;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.logo-icon {
|
| 136 |
+
width: 80px;
|
| 137 |
+
height: 80px;
|
| 138 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
|
| 139 |
+
border-radius: 24px;
|
| 140 |
+
display: flex;
|
| 141 |
+
align-items: center;
|
| 142 |
+
justify-content: center;
|
| 143 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 144 |
+
position: relative;
|
| 145 |
+
overflow: hidden;
|
| 146 |
+
animation: logoFloat 3s ease-in-out infinite;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
@keyframes logoFloat {
|
| 150 |
+
0%, 100% { transform: translateY(0px) rotate(0deg); }
|
| 151 |
+
50% { transform: translateY(-10px) rotate(5deg); }
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.logo-icon::after {
|
| 155 |
+
content: '';
|
| 156 |
+
position: absolute;
|
| 157 |
+
top: -50%;
|
| 158 |
+
left: -50%;
|
| 159 |
+
right: -50%;
|
| 160 |
+
bottom: -50%;
|
| 161 |
+
background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.4), transparent);
|
| 162 |
+
animation: shimmer 2s infinite;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
@keyframes shimmer {
|
| 166 |
+
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
|
| 167 |
+
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.logo-text h1 {
|
| 171 |
+
font-size: 36px;
|
| 172 |
+
font-weight: 900;
|
| 173 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
|
| 174 |
+
-webkit-background-clip: text;
|
| 175 |
+
-webkit-text-fill-color: transparent;
|
| 176 |
+
background-clip: text;
|
| 177 |
+
margin-bottom: 8px;
|
| 178 |
+
letter-spacing: -1px;
|
| 179 |
+
text-shadow: 0 0 30px var(--info-glow);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.logo-text p {
|
| 183 |
+
font-size: 14px;
|
| 184 |
+
color: var(--text-secondary);
|
| 185 |
+
font-weight: 600;
|
| 186 |
+
letter-spacing: 0.5px;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.header-actions {
|
| 190 |
+
display: flex;
|
| 191 |
+
gap: 16px;
|
| 192 |
+
align-items: center;
|
| 193 |
+
flex-wrap: wrap;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.status-badge {
|
| 197 |
+
display: flex;
|
| 198 |
+
align-items: center;
|
| 199 |
+
gap: 12px;
|
| 200 |
+
padding: 14px 24px;
|
| 201 |
+
border-radius: 999px;
|
| 202 |
+
background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.1) 100%);
|
| 203 |
+
border: 2px solid var(--success);
|
| 204 |
+
font-size: 14px;
|
| 205 |
+
font-weight: 700;
|
| 206 |
+
color: var(--success);
|
| 207 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 208 |
+
text-transform: uppercase;
|
| 209 |
+
letter-spacing: 1px;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
.status-dot {
|
| 213 |
+
width: 12px;
|
| 214 |
+
height: 12px;
|
| 215 |
+
border-radius: 50%;
|
| 216 |
+
background: var(--success);
|
| 217 |
+
animation: pulse-glow 2s infinite;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
@keyframes pulse-glow {
|
| 221 |
+
0%, 100% {
|
| 222 |
+
box-shadow: 0 0 0 0 var(--success-glow),
|
| 223 |
+
0 0 15px var(--success);
|
| 224 |
+
}
|
| 225 |
+
50% {
|
| 226 |
+
box-shadow: 0 0 0 10px transparent,
|
| 227 |
+
0 0 25px var(--success);
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
.connection-status {
|
| 232 |
+
display: flex;
|
| 233 |
+
align-items: center;
|
| 234 |
+
gap: 10px;
|
| 235 |
+
padding: 12px 20px;
|
| 236 |
+
border-radius: 999px;
|
| 237 |
+
background: var(--bg-secondary);
|
| 238 |
+
border: 2px solid var(--border);
|
| 239 |
+
font-size: 13px;
|
| 240 |
+
font-weight: 700;
|
| 241 |
+
transition: var(--transition);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.connection-status.connected {
|
| 245 |
+
border-color: var(--success);
|
| 246 |
+
color: var(--success);
|
| 247 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 248 |
+
}
|
| 249 |
+
.connection-status.disconnected {
|
| 250 |
+
border-color: var(--danger);
|
| 251 |
+
color: var(--danger);
|
| 252 |
+
box-shadow: var(--glow) var(--danger-glow);
|
| 253 |
+
}
|
| 254 |
+
.connection-status.connecting {
|
| 255 |
+
border-color: var(--warning);
|
| 256 |
+
color: var(--warning);
|
| 257 |
+
box-shadow: var(--glow) var(--warning-glow);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
.btn {
|
| 261 |
+
padding: 14px 28px;
|
| 262 |
+
border-radius: 14px;
|
| 263 |
+
border: none;
|
| 264 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
|
| 265 |
+
color: white;
|
| 266 |
+
font-family: inherit;
|
| 267 |
+
font-size: 14px;
|
| 268 |
+
font-weight: 700;
|
| 269 |
+
cursor: pointer;
|
| 270 |
+
transition: var(--transition);
|
| 271 |
+
display: inline-flex;
|
| 272 |
+
align-items: center;
|
| 273 |
+
gap: 10px;
|
| 274 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 275 |
+
text-transform: uppercase;
|
| 276 |
+
letter-spacing: 0.5px;
|
| 277 |
+
position: relative;
|
| 278 |
+
overflow: hidden;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.btn::before {
|
| 282 |
+
content: '';
|
| 283 |
+
position: absolute;
|
| 284 |
+
top: 0;
|
| 285 |
+
left: -100%;
|
| 286 |
+
width: 100%;
|
| 287 |
+
height: 100%;
|
| 288 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
| 289 |
+
transition: left 0.5s;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
.btn:hover {
|
| 293 |
+
transform: translateY(-3px) scale(1.05);
|
| 294 |
+
box-shadow: 0 15px 40px var(--info-glow);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.btn:hover::before {
|
| 298 |
+
left: 100%;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.btn:active {
|
| 302 |
+
transform: translateY(-1px) scale(1.02);
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/* KPI Cards */
|
| 306 |
+
.kpi-grid {
|
| 307 |
+
display: grid;
|
| 308 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
| 309 |
+
gap: 24px;
|
| 310 |
+
margin-bottom: 32px;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.kpi-card {
|
| 314 |
+
background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
|
| 315 |
+
border: 2px solid var(--border);
|
| 316 |
+
border-radius: var(--radius-lg);
|
| 317 |
+
padding: 32px;
|
| 318 |
+
transition: var(--transition);
|
| 319 |
+
box-shadow: var(--shadow);
|
| 320 |
+
position: relative;
|
| 321 |
+
overflow: hidden;
|
| 322 |
+
cursor: pointer;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
.kpi-card::before {
|
| 326 |
+
content: '';
|
| 327 |
+
position: absolute;
|
| 328 |
+
top: 0;
|
| 329 |
+
left: 0;
|
| 330 |
+
right: 0;
|
| 331 |
+
height: 4px;
|
| 332 |
+
background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
|
| 333 |
+
transform: scaleX(0);
|
| 334 |
+
transform-origin: left;
|
| 335 |
+
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.kpi-card:hover {
|
| 339 |
+
transform: translateY(-12px) scale(1.03);
|
| 340 |
+
box-shadow: 0 20px 60px rgba(0, 212, 255, 0.3);
|
| 341 |
+
border-color: var(--accent-blue);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.kpi-card:hover::before {
|
| 345 |
+
transform: scaleX(1);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
.kpi-header {
|
| 349 |
+
display: flex;
|
| 350 |
+
align-items: center;
|
| 351 |
+
justify-content: space-between;
|
| 352 |
+
margin-bottom: 24px;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.kpi-label {
|
| 356 |
+
font-size: 12px;
|
| 357 |
+
color: var(--text-muted);
|
| 358 |
+
font-weight: 800;
|
| 359 |
+
text-transform: uppercase;
|
| 360 |
+
letter-spacing: 1.5px;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
.kpi-icon-wrapper {
|
| 364 |
+
width: 72px;
|
| 365 |
+
height: 72px;
|
| 366 |
+
border-radius: 20px;
|
| 367 |
+
display: flex;
|
| 368 |
+
align-items: center;
|
| 369 |
+
justify-content: center;
|
| 370 |
+
transition: var(--transition);
|
| 371 |
+
box-shadow: var(--shadow);
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.kpi-card:hover .kpi-icon-wrapper {
|
| 375 |
+
transform: rotate(-10deg) scale(1.2);
|
| 376 |
+
box-shadow: 0 15px 40px rgba(0, 212, 255, 0.4);
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
.kpi-value {
|
| 380 |
+
font-size: 56px;
|
| 381 |
+
font-weight: 900;
|
| 382 |
+
margin-bottom: 20px;
|
| 383 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
|
| 384 |
+
-webkit-background-clip: text;
|
| 385 |
+
-webkit-text-fill-color: transparent;
|
| 386 |
+
background-clip: text;
|
| 387 |
+
line-height: 1;
|
| 388 |
+
animation: countUp 0.6s ease-out;
|
| 389 |
+
letter-spacing: -3px;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
@keyframes countUp {
|
| 393 |
+
from { opacity: 0; transform: translateY(30px); }
|
| 394 |
+
to { opacity: 1; transform: translateY(0); }
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
.kpi-trend {
|
| 398 |
+
display: flex;
|
| 399 |
+
align-items: center;
|
| 400 |
+
gap: 10px;
|
| 401 |
+
font-size: 13px;
|
| 402 |
+
font-weight: 700;
|
| 403 |
+
padding: 10px 18px;
|
| 404 |
+
border-radius: 12px;
|
| 405 |
+
width: fit-content;
|
| 406 |
+
text-transform: uppercase;
|
| 407 |
+
letter-spacing: 0.5px;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
.trend-up {
|
| 411 |
+
color: var(--success);
|
| 412 |
+
background: rgba(16, 185, 129, 0.15);
|
| 413 |
+
border: 2px solid var(--success);
|
| 414 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
.trend-down {
|
| 418 |
+
color: var(--danger);
|
| 419 |
+
background: rgba(239, 68, 68, 0.15);
|
| 420 |
+
border: 2px solid var(--danger);
|
| 421 |
+
box-shadow: var(--glow) var(--danger-glow);
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
.trend-neutral {
|
| 425 |
+
color: var(--info);
|
| 426 |
+
background: rgba(0, 212, 255, 0.15);
|
| 427 |
+
border: 2px solid var(--info);
|
| 428 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
/* Tabs */
|
| 432 |
+
.tabs {
|
| 433 |
+
display: flex;
|
| 434 |
+
gap: 8px;
|
| 435 |
+
margin-bottom: 32px;
|
| 436 |
+
overflow-x: auto;
|
| 437 |
+
padding: 12px;
|
| 438 |
+
background: var(--bg-card);
|
| 439 |
+
border-radius: var(--radius-lg);
|
| 440 |
+
border: 2px solid var(--border);
|
| 441 |
+
box-shadow: var(--shadow);
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
.tab {
|
| 445 |
+
padding: 14px 24px;
|
| 446 |
+
border-radius: 14px;
|
| 447 |
+
background: transparent;
|
| 448 |
+
border: 2px solid transparent;
|
| 449 |
+
color: var(--text-secondary);
|
| 450 |
+
cursor: pointer;
|
| 451 |
+
transition: all 0.25s;
|
| 452 |
+
white-space: nowrap;
|
| 453 |
+
font-weight: 700;
|
| 454 |
+
font-size: 14px;
|
| 455 |
+
display: flex;
|
| 456 |
+
align-items: center;
|
| 457 |
+
gap: 10px;
|
| 458 |
+
position: relative;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
.tab:hover:not(.active) {
|
| 462 |
+
background: var(--bg-hover);
|
| 463 |
+
color: var(--text-primary);
|
| 464 |
+
border-color: var(--border);
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
.tab.active {
|
| 468 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
|
| 469 |
+
color: white;
|
| 470 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 471 |
+
transform: scale(1.05);
|
| 472 |
+
border-color: var(--accent-blue);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
.tab .icon {
|
| 476 |
+
width: 18px;
|
| 477 |
+
height: 18px;
|
| 478 |
+
stroke: currentColor;
|
| 479 |
+
stroke-width: 2.5;
|
| 480 |
+
stroke-linecap: round;
|
| 481 |
+
stroke-linejoin: round;
|
| 482 |
+
fill: none;
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
/* Tab Content */
|
| 486 |
+
.tab-content {
|
| 487 |
+
display: none;
|
| 488 |
+
animation: fadeIn 0.5s ease;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
.tab-content.active {
|
| 492 |
+
display: block;
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
@keyframes fadeIn {
|
| 496 |
+
from { opacity: 0; transform: translateY(30px); }
|
| 497 |
+
to { opacity: 1; transform: translateY(0); }
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
/* Card */
|
| 501 |
+
.card {
|
| 502 |
+
background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
|
| 503 |
+
border: 2px solid var(--border);
|
| 504 |
+
border-radius: var(--radius-lg);
|
| 505 |
+
padding: 32px;
|
| 506 |
+
margin-bottom: 32px;
|
| 507 |
+
box-shadow: var(--shadow);
|
| 508 |
+
transition: var(--transition);
|
| 509 |
+
position: relative;
|
| 510 |
+
overflow: hidden;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
.card::before {
|
| 514 |
+
content: '';
|
| 515 |
+
position: absolute;
|
| 516 |
+
top: 0;
|
| 517 |
+
left: 0;
|
| 518 |
+
width: 100%;
|
| 519 |
+
height: 100%;
|
| 520 |
+
background: radial-gradient(circle at top right, rgba(0, 212, 255, 0.05) 0%, transparent 70%);
|
| 521 |
+
pointer-events: none;
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
.card:hover {
|
| 525 |
+
box-shadow: var(--shadow-lg);
|
| 526 |
+
border-color: var(--accent-blue);
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
.card-header {
|
| 530 |
+
display: flex;
|
| 531 |
+
align-items: center;
|
| 532 |
+
justify-content: space-between;
|
| 533 |
+
margin-bottom: 28px;
|
| 534 |
+
padding-bottom: 20px;
|
| 535 |
+
border-bottom: 2px solid var(--border);
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
.card-title {
|
| 539 |
+
font-size: 22px;
|
| 540 |
+
font-weight: 800;
|
| 541 |
+
display: flex;
|
| 542 |
+
align-items: center;
|
| 543 |
+
gap: 14px;
|
| 544 |
+
color: var(--text-primary);
|
| 545 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
|
| 546 |
+
-webkit-background-clip: text;
|
| 547 |
+
-webkit-text-fill-color: transparent;
|
| 548 |
+
background-clip: text;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
/* Table */
|
| 552 |
+
.table-container {
|
| 553 |
+
overflow-x: auto;
|
| 554 |
+
border-radius: var(--radius);
|
| 555 |
+
border: 2px solid var(--border);
|
| 556 |
+
background: var(--bg-secondary);
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
.table {
|
| 560 |
+
width: 100%;
|
| 561 |
+
border-collapse: collapse;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
.table thead {
|
| 565 |
+
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
|
| 566 |
+
position: sticky;
|
| 567 |
+
top: 0;
|
| 568 |
+
z-index: 10;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
.table thead th {
|
| 572 |
+
color: white;
|
| 573 |
+
font-weight: 700;
|
| 574 |
+
font-size: 13px;
|
| 575 |
+
text-align: left;
|
| 576 |
+
padding: 18px 20px;
|
| 577 |
+
text-transform: uppercase;
|
| 578 |
+
letter-spacing: 1px;
|
| 579 |
+
border-bottom: 2px solid rgba(255, 255, 255, 0.2);
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
.table tbody tr {
|
| 583 |
+
transition: var(--transition);
|
| 584 |
+
border-bottom: 1px solid var(--border);
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
.table tbody tr:hover {
|
| 588 |
+
background: var(--bg-hover);
|
| 589 |
+
transform: scale(1.01);
|
| 590 |
+
box-shadow: 0 4px 12px rgba(0, 212, 255, 0.1);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
.table tbody td {
|
| 594 |
+
padding: 18px 20px;
|
| 595 |
+
font-size: 14px;
|
| 596 |
+
color: var(--text-secondary);
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
.table tbody td strong {
|
| 600 |
+
color: var(--text-primary);
|
| 601 |
+
font-weight: 700;
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
/* Badge */
|
| 605 |
+
.badge {
|
| 606 |
+
display: inline-flex;
|
| 607 |
+
align-items: center;
|
| 608 |
+
gap: 8px;
|
| 609 |
+
padding: 8px 14px;
|
| 610 |
+
border-radius: 999px;
|
| 611 |
+
font-size: 12px;
|
| 612 |
+
font-weight: 700;
|
| 613 |
+
white-space: nowrap;
|
| 614 |
+
text-transform: uppercase;
|
| 615 |
+
letter-spacing: 0.5px;
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
.badge-success {
|
| 619 |
+
background: rgba(16, 185, 129, 0.2);
|
| 620 |
+
color: var(--success);
|
| 621 |
+
border: 2px solid var(--success);
|
| 622 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
.badge-warning {
|
| 626 |
+
background: rgba(251, 191, 36, 0.2);
|
| 627 |
+
color: var(--warning);
|
| 628 |
+
border: 2px solid var(--warning);
|
| 629 |
+
box-shadow: var(--glow) var(--warning-glow);
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
.badge-danger {
|
| 633 |
+
background: rgba(239, 68, 68, 0.2);
|
| 634 |
+
color: var(--danger);
|
| 635 |
+
border: 2px solid var(--danger);
|
| 636 |
+
box-shadow: var(--glow) var(--danger-glow);
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
.badge-info {
|
| 640 |
+
background: rgba(0, 212, 255, 0.2);
|
| 641 |
+
color: var(--info);
|
| 642 |
+
border: 2px solid var(--info);
|
| 643 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/* Progress Bar */
|
| 647 |
+
.progress {
|
| 648 |
+
height: 14px;
|
| 649 |
+
background: var(--bg-secondary);
|
| 650 |
+
border-radius: 999px;
|
| 651 |
+
overflow: hidden;
|
| 652 |
+
margin: 10px 0;
|
| 653 |
+
border: 2px solid var(--border);
|
| 654 |
+
box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
.progress-bar {
|
| 658 |
+
height: 100%;
|
| 659 |
+
background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
|
| 660 |
+
border-radius: 999px;
|
| 661 |
+
transition: width 0.5s ease;
|
| 662 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 663 |
+
position: relative;
|
| 664 |
+
overflow: hidden;
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
.progress-bar::after {
|
| 668 |
+
content: '';
|
| 669 |
+
position: absolute;
|
| 670 |
+
top: 0;
|
| 671 |
+
left: 0;
|
| 672 |
+
right: 0;
|
| 673 |
+
bottom: 0;
|
| 674 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
|
| 675 |
+
animation: progressShine 2s infinite;
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
@keyframes progressShine {
|
| 679 |
+
0% { transform: translateX(-100%); }
|
| 680 |
+
100% { transform: translateX(100%); }
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
.progress-bar.success {
|
| 684 |
+
background: linear-gradient(90deg, var(--success), #34d399);
|
| 685 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
.progress-bar.warning {
|
| 689 |
+
background: linear-gradient(90deg, var(--warning), #fbbf24);
|
| 690 |
+
box-shadow: var(--glow) var(--warning-glow);
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
.progress-bar.danger {
|
| 694 |
+
background: linear-gradient(90deg, var(--danger), #f87171);
|
| 695 |
+
box-shadow: var(--glow) var(--danger-glow);
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
/* Loading */
|
| 699 |
+
.loading-overlay {
|
| 700 |
+
position: fixed;
|
| 701 |
+
top: 0;
|
| 702 |
+
left: 0;
|
| 703 |
+
right: 0;
|
| 704 |
+
bottom: 0;
|
| 705 |
+
background: rgba(15, 15, 35, 0.95);
|
| 706 |
+
backdrop-filter: blur(10px);
|
| 707 |
+
display: none;
|
| 708 |
+
align-items: center;
|
| 709 |
+
justify-content: center;
|
| 710 |
+
z-index: 9999;
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
.loading-overlay.active {
|
| 714 |
+
display: flex;
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
.spinner {
|
| 718 |
+
width: 80px;
|
| 719 |
+
height: 80px;
|
| 720 |
+
border: 6px solid var(--border);
|
| 721 |
+
border-top-color: var(--accent-blue);
|
| 722 |
+
border-right-color: var(--accent-purple);
|
| 723 |
+
border-radius: 50%;
|
| 724 |
+
animation: spin 1s linear infinite;
|
| 725 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
@keyframes spin {
|
| 729 |
+
to { transform: rotate(360deg); }
|
| 730 |
+
}
|
| 731 |
+
|
| 732 |
+
/* Toast */
|
| 733 |
+
.toast-container {
|
| 734 |
+
position: fixed;
|
| 735 |
+
bottom: 32px;
|
| 736 |
+
right: 32px;
|
| 737 |
+
z-index: 10000;
|
| 738 |
+
display: flex;
|
| 739 |
+
flex-direction: column;
|
| 740 |
+
gap: 16px;
|
| 741 |
+
max-width: 400px;
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
.toast {
|
| 745 |
+
padding: 20px 24px;
|
| 746 |
+
border-radius: var(--radius);
|
| 747 |
+
background: var(--bg-card);
|
| 748 |
+
border: 2px solid var(--border);
|
| 749 |
+
box-shadow: var(--shadow-lg);
|
| 750 |
+
display: flex;
|
| 751 |
+
align-items: center;
|
| 752 |
+
gap: 14px;
|
| 753 |
+
animation: slideInRight 0.4s ease;
|
| 754 |
+
min-width: 320px;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
@keyframes slideInRight {
|
| 758 |
+
from { transform: translateX(500px); opacity: 0; }
|
| 759 |
+
to { transform: translateX(0); opacity: 1; }
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
.toast.success {
|
| 763 |
+
border-color: var(--success);
|
| 764 |
+
background: rgba(16, 185, 129, 0.1);
|
| 765 |
+
box-shadow: var(--glow) var(--success-glow);
|
| 766 |
+
}
|
| 767 |
+
.toast.error {
|
| 768 |
+
border-color: var(--danger);
|
| 769 |
+
background: rgba(239, 68, 68, 0.1);
|
| 770 |
+
box-shadow: var(--glow) var(--danger-glow);
|
| 771 |
+
}
|
| 772 |
+
.toast.warning {
|
| 773 |
+
border-color: var(--warning);
|
| 774 |
+
background: rgba(251, 191, 36, 0.1);
|
| 775 |
+
box-shadow: var(--glow) var(--warning-glow);
|
| 776 |
+
}
|
| 777 |
+
.toast.info {
|
| 778 |
+
border-color: var(--info);
|
| 779 |
+
background: rgba(0, 212, 255, 0.1);
|
| 780 |
+
box-shadow: var(--glow) var(--info-glow);
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
/* Grid */
|
| 784 |
+
.grid { display: grid; gap: 24px; }
|
| 785 |
+
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); }
|
| 786 |
+
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
|
| 787 |
+
|
| 788 |
+
/* Responsive */
|
| 789 |
+
@media (max-width: 768px) {
|
| 790 |
+
.container { padding: 20px; }
|
| 791 |
+
.header { padding: 24px; }
|
| 792 |
+
.header-top { flex-direction: column; align-items: flex-start; }
|
| 793 |
+
.kpi-grid { grid-template-columns: 1fr; }
|
| 794 |
+
.grid-2, .grid-3 { grid-template-columns: 1fr; }
|
| 795 |
+
.tabs { overflow-x: scroll; }
|
| 796 |
+
}
|
| 797 |
+
|
| 798 |
+
/* Icon Styles */
|
| 799 |
+
.icon {
|
| 800 |
+
stroke: currentColor;
|
| 801 |
+
stroke-width: 2.5;
|
| 802 |
+
stroke-linecap: round;
|
| 803 |
+
stroke-linejoin: round;
|
| 804 |
+
fill: none;
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
.icon-lg {
|
| 808 |
+
width: 32px;
|
| 809 |
+
height: 32px;
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
/* Provider Status Icons */
|
| 813 |
+
.provider-icon {
|
| 814 |
+
width: 48px;
|
| 815 |
+
height: 48px;
|
| 816 |
+
border-radius: 12px;
|
| 817 |
+
display: flex;
|
| 818 |
+
align-items: center;
|
| 819 |
+
justify-content: center;
|
| 820 |
+
font-size: 24px;
|
| 821 |
+
box-shadow: var(--shadow);
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
.provider-icon.online {
|
| 825 |
+
background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
|
| 826 |
+
border: 2px solid var(--success);
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
.provider-icon.offline {
|
| 830 |
+
background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
|
| 831 |
+
border: 2px solid var(--danger);
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
.provider-icon.degraded {
|
| 835 |
+
background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.1));
|
| 836 |
+
border: 2px solid var(--warning);
|
| 837 |
+
}
|
| 838 |
+
</style>
|
| 839 |
+
</head>
|
| 840 |
+
<body>
|
| 841 |
+
<div class="loading-overlay" id="loadingOverlay">
|
| 842 |
+
<div class="spinner"></div>
|
| 843 |
+
</div>
|
| 844 |
+
|
| 845 |
+
<div class="toast-container" id="toastContainer"></div>
|
| 846 |
+
|
| 847 |
+
<div class="container">
|
| 848 |
+
<!-- Header -->
|
| 849 |
+
<div class="header">
|
| 850 |
+
<div class="header-top">
|
| 851 |
+
<div class="logo">
|
| 852 |
+
<div class="logo-icon">
|
| 853 |
+
<svg class="icon icon-lg" style="stroke: white; width: 40px; height: 40px;">
|
| 854 |
+
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path>
|
| 855 |
+
</svg>
|
| 856 |
+
</div>
|
| 857 |
+
<div class="logo-text">
|
| 858 |
+
<h1>🚀 Crypto API Monitor</h1>
|
| 859 |
+
<p>Real-time Cryptocurrency API Resource Monitoring</p>
|
| 860 |
+
</div>
|
| 861 |
+
</div>
|
| 862 |
+
<div class="header-actions">
|
| 863 |
+
<div class="connection-status" id="wsStatus">
|
| 864 |
+
<span class="status-dot"></span>
|
| 865 |
+
<span id="wsStatusText">Connecting...</span>
|
| 866 |
+
</div>
|
| 867 |
+
<div class="status-badge" id="systemStatus">
|
| 868 |
+
<span class="status-dot"></span>
|
| 869 |
+
<span id="systemStatusText">System Active</span>
|
| 870 |
+
</div>
|
| 871 |
+
<button class="btn" onclick="refreshAll()">
|
| 872 |
+
<svg class="icon">
|
| 873 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 874 |
+
</svg>
|
| 875 |
+
Refresh All
|
| 876 |
+
</button>
|
| 877 |
+
</div>
|
| 878 |
+
</div>
|
| 879 |
+
|
| 880 |
+
<!-- KPI Cards -->
|
| 881 |
+
<div class="kpi-grid" id="kpiGrid">
|
| 882 |
+
<div class="kpi-card">
|
| 883 |
+
<div class="kpi-header">
|
| 884 |
+
<span class="kpi-label">📊 Total APIs</span>
|
| 885 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 212, 255, 0.1));">
|
| 886 |
+
<svg class="icon icon-lg" style="stroke: var(--accent-blue); width: 36px; height: 36px;">
|
| 887 |
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
| 888 |
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
| 889 |
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
| 890 |
+
</svg>
|
| 891 |
+
</div>
|
| 892 |
+
</div>
|
| 893 |
+
<div class="kpi-value" id="kpiTotalAPIs">--</div>
|
| 894 |
+
<div class="kpi-trend trend-neutral">
|
| 895 |
+
<svg class="icon" style="width: 18px; height: 18px;">
|
| 896 |
+
<path d="M12 20V10M18 20V4M6 20v-4"></path>
|
| 897 |
+
</svg>
|
| 898 |
+
<span id="kpiTotalTrend">Loading...</span>
|
| 899 |
+
</div>
|
| 900 |
+
</div>
|
| 901 |
+
|
| 902 |
+
<div class="kpi-card">
|
| 903 |
+
<div class="kpi-header">
|
| 904 |
+
<span class="kpi-label">✅ Online</span>
|
| 905 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));">
|
| 906 |
+
<svg class="icon icon-lg" style="stroke: var(--success); width: 36px; height: 36px;">
|
| 907 |
+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
|
| 908 |
+
<polyline points="9 12 11 14 15 10"></polyline>
|
| 909 |
+
</svg>
|
| 910 |
+
</div>
|
| 911 |
+
</div>
|
| 912 |
+
<div class="kpi-value" id="kpiOnline">--</div>
|
| 913 |
+
<div class="kpi-trend trend-up">
|
| 914 |
+
<svg class="icon" style="width: 18px; height: 18px;">
|
| 915 |
+
<line x1="12" y1="19" x2="12" y2="5"></line>
|
| 916 |
+
<polyline points="5 12 12 5 19 12"></polyline>
|
| 917 |
+
</svg>
|
| 918 |
+
<span id="kpiOnlineTrend">Loading...</span>
|
| 919 |
+
</div>
|
| 920 |
+
</div>
|
| 921 |
+
|
| 922 |
+
<div class="kpi-card">
|
| 923 |
+
<div class="kpi-header">
|
| 924 |
+
<span class="kpi-label">⚡ Avg Response</span>
|
| 925 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.1));">
|
| 926 |
+
<svg class="icon icon-lg" style="stroke: var(--warning); width: 36px; height: 36px;">
|
| 927 |
+
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path>
|
| 928 |
+
</svg>
|
| 929 |
+
</div>
|
| 930 |
+
</div>
|
| 931 |
+
<div class="kpi-value" id="kpiAvgResponse" style="font-size: 36px;">--</div>
|
| 932 |
+
<div class="kpi-trend trend-down">
|
| 933 |
+
<svg class="icon" style="width: 18px; height: 18px;">
|
| 934 |
+
<line x1="12" y1="5" x2="12" y2="19"></line>
|
| 935 |
+
<polyline points="19 12 12 19 5 12"></polyline>
|
| 936 |
+
</svg>
|
| 937 |
+
<span id="kpiResponseTrend">Loading...</span>
|
| 938 |
+
</div>
|
| 939 |
+
</div>
|
| 940 |
+
|
| 941 |
+
<div class="kpi-card">
|
| 942 |
+
<div class="kpi-header">
|
| 943 |
+
<span class="kpi-label">🕐 Last Update</span>
|
| 944 |
+
<div class="kpi-icon-wrapper" style="background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0.1));">
|
| 945 |
+
<svg class="icon icon-lg" style="stroke: var(--accent-purple); width: 36px; height: 36px;">
|
| 946 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 947 |
+
<polyline points="12 6 12 12 16 14"></polyline>
|
| 948 |
+
</svg>
|
| 949 |
+
</div>
|
| 950 |
+
</div>
|
| 951 |
+
<div class="kpi-value" id="kpiLastUpdate" style="font-size: 22px; line-height: 1.3;">--</div>
|
| 952 |
+
<div class="kpi-trend trend-neutral">
|
| 953 |
+
<svg class="icon" style="width: 18px; height: 18px;">
|
| 954 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 955 |
+
</svg>
|
| 956 |
+
<span>Auto-refresh</span>
|
| 957 |
+
</div>
|
| 958 |
+
</div>
|
| 959 |
+
</div>
|
| 960 |
+
</div>
|
| 961 |
+
|
| 962 |
+
<!-- Tabs -->
|
| 963 |
+
<div class="tabs">
|
| 964 |
+
<div class="tab active" onclick="switchTab(event, 'dashboard')">
|
| 965 |
+
<svg class="icon">
|
| 966 |
+
<rect x="3" y="3" width="7" height="7"></rect>
|
| 967 |
+
<rect x="14" y="3" width="7" height="7"></rect>
|
| 968 |
+
<rect x="14" y="14" width="7" height="7"></rect>
|
| 969 |
+
<rect x="3" y="14" width="7" height="7"></rect>
|
| 970 |
+
</svg>
|
| 971 |
+
<span>Dashboard</span>
|
| 972 |
+
</div>
|
| 973 |
+
<div class="tab" onclick="switchTab(event, 'providers')">
|
| 974 |
+
<svg class="icon">
|
| 975 |
+
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
|
| 976 |
+
<polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
|
| 977 |
+
<line x1="12" y1="22.08" x2="12" y2="12"></line>
|
| 978 |
+
</svg>
|
| 979 |
+
<span>Providers</span>
|
| 980 |
+
</div>
|
| 981 |
+
<div class="tab" onclick="switchTab(event, 'categories')">
|
| 982 |
+
<svg class="icon">
|
| 983 |
+
<rect x="3" y="3" width="7" height="7"></rect>
|
| 984 |
+
<rect x="14" y="3" width="7" height="7"></rect>
|
| 985 |
+
<rect x="14" y="14" width="7" height="7"></rect>
|
| 986 |
+
<rect x="3" y="14" width="7" height="7"></rect>
|
| 987 |
+
</svg>
|
| 988 |
+
<span>Categories</span>
|
| 989 |
+
</div>
|
| 990 |
+
<div class="tab" onclick="switchTab(event, 'logs')">
|
| 991 |
+
<svg class="icon">
|
| 992 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
| 993 |
+
<polyline points="14 2 14 8 20 8"></polyline>
|
| 994 |
+
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 995 |
+
<line x1="16" y1="17" x2="8" y2="17"></line>
|
| 996 |
+
<polyline points="10 9 9 9 8 9"></polyline>
|
| 997 |
+
</svg>
|
| 998 |
+
<span>Logs</span>
|
| 999 |
+
</div>
|
| 1000 |
+
<div class="tab" onclick="switchTab(event, 'huggingface')">
|
| 1001 |
+
<svg class="icon">
|
| 1002 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1003 |
+
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
|
| 1004 |
+
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
| 1005 |
+
</svg>
|
| 1006 |
+
<span>🤗 HuggingFace</span>
|
| 1007 |
+
</div>
|
| 1008 |
+
</div>
|
| 1009 |
+
|
| 1010 |
+
<!-- Dashboard Tab -->
|
| 1011 |
+
<div class="tab-content active" id="tab-dashboard">
|
| 1012 |
+
<div class="card">
|
| 1013 |
+
<div class="card-header">
|
| 1014 |
+
<h2 class="card-title">
|
| 1015 |
+
<svg class="icon icon-lg">
|
| 1016 |
+
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
|
| 1017 |
+
</svg>
|
| 1018 |
+
System Overview
|
| 1019 |
+
</h2>
|
| 1020 |
+
<button class="btn" onclick="loadProviders()" style="padding: 10px 20px; font-size: 13px;">
|
| 1021 |
+
<svg class="icon">
|
| 1022 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1023 |
+
</svg>
|
| 1024 |
+
Refresh
|
| 1025 |
+
</button>
|
| 1026 |
+
</div>
|
| 1027 |
+
<div class="table-container">
|
| 1028 |
+
<table class="table">
|
| 1029 |
+
<thead>
|
| 1030 |
+
<tr>
|
| 1031 |
+
<th>🔌 Provider</th>
|
| 1032 |
+
<th>📁 Category</th>
|
| 1033 |
+
<th>📊 Status</th>
|
| 1034 |
+
<th>⚡ Response Time</th>
|
| 1035 |
+
<th>🕐 Last Check</th>
|
| 1036 |
+
</tr>
|
| 1037 |
+
</thead>
|
| 1038 |
+
<tbody id="providersTableBody">
|
| 1039 |
+
<tr>
|
| 1040 |
+
<td colspan="5" style="text-align: center; padding: 60px;">
|
| 1041 |
+
<div class="spinner" style="width: 40px; height: 40px; margin: 0 auto 20px;"></div>
|
| 1042 |
+
<div style="color: var(--text-muted);">Loading providers...</div>
|
| 1043 |
+
</td>
|
| 1044 |
+
</tr>
|
| 1045 |
+
</tbody>
|
| 1046 |
+
</table>
|
| 1047 |
+
</div>
|
| 1048 |
+
</div>
|
| 1049 |
+
|
| 1050 |
+
<div class="grid grid-2">
|
| 1051 |
+
<div class="card">
|
| 1052 |
+
<div class="card-header">
|
| 1053 |
+
<h2 class="card-title">
|
| 1054 |
+
<svg class="icon icon-lg">
|
| 1055 |
+
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline>
|
| 1056 |
+
<polyline points="17 6 23 6 23 12"></polyline>
|
| 1057 |
+
</svg>
|
| 1058 |
+
Health Status
|
| 1059 |
+
</h2>
|
| 1060 |
+
</div>
|
| 1061 |
+
<div style="position: relative; height: 320px; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); border: 2px solid var(--border);">
|
| 1062 |
+
<canvas id="healthChart"></canvas>
|
| 1063 |
+
</div>
|
| 1064 |
+
</div>
|
| 1065 |
+
|
| 1066 |
+
<div class="card">
|
| 1067 |
+
<div class="card-header">
|
| 1068 |
+
<h2 class="card-title">
|
| 1069 |
+
<svg class="icon icon-lg">
|
| 1070 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1071 |
+
<line x1="2" y1="12" x2="22" y2="12"></line>
|
| 1072 |
+
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
|
| 1073 |
+
</svg>
|
| 1074 |
+
Status Distribution
|
| 1075 |
+
</h2>
|
| 1076 |
+
</div>
|
| 1077 |
+
<div style="position: relative; height: 320px; padding: 20px; background: var(--bg-secondary); border-radius: var(--radius); border: 2px solid var(--border);">
|
| 1078 |
+
<canvas id="statusChart"></canvas>
|
| 1079 |
+
</div>
|
| 1080 |
+
</div>
|
| 1081 |
+
</div>
|
| 1082 |
+
</div>
|
| 1083 |
+
|
| 1084 |
+
<!-- Providers Tab -->
|
| 1085 |
+
<div class="tab-content" id="tab-providers">
|
| 1086 |
+
<div class="card">
|
| 1087 |
+
<div class="card-header">
|
| 1088 |
+
<h2 class="card-title">
|
| 1089 |
+
<svg class="icon icon-lg">
|
| 1090 |
+
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
|
| 1091 |
+
</svg>
|
| 1092 |
+
All Providers
|
| 1093 |
+
</h2>
|
| 1094 |
+
<button class="btn" onclick="loadProviders()" style="padding: 10px 20px; font-size: 13px;">
|
| 1095 |
+
<svg class="icon">
|
| 1096 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1097 |
+
</svg>
|
| 1098 |
+
Refresh
|
| 1099 |
+
</button>
|
| 1100 |
+
</div>
|
| 1101 |
+
<div id="providersDetail">
|
| 1102 |
+
<div style="text-align: center; padding: 60px;">
|
| 1103 |
+
<div class="spinner" style="width: 40px; height: 40px; margin: 0 auto 20px;"></div>
|
| 1104 |
+
<div style="color: var(--text-muted);">Loading providers details...</div>
|
| 1105 |
+
</div>
|
| 1106 |
+
</div>
|
| 1107 |
+
</div>
|
| 1108 |
+
</div>
|
| 1109 |
+
|
| 1110 |
+
<!-- Categories Tab -->
|
| 1111 |
+
<div class="tab-content" id="tab-categories">
|
| 1112 |
+
<div class="card">
|
| 1113 |
+
<div class="card-header">
|
| 1114 |
+
<h2 class="card-title">
|
| 1115 |
+
<svg class="icon icon-lg">
|
| 1116 |
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
| 1117 |
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
| 1118 |
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
| 1119 |
+
</svg>
|
| 1120 |
+
Categories Overview
|
| 1121 |
+
</h2>
|
| 1122 |
+
<button class="btn" onclick="loadCategories()" style="padding: 10px 20px; font-size: 13px;">
|
| 1123 |
+
<svg class="icon">
|
| 1124 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1125 |
+
</svg>
|
| 1126 |
+
Refresh
|
| 1127 |
+
</button>
|
| 1128 |
+
</div>
|
| 1129 |
+
<div class="table-container">
|
| 1130 |
+
<table class="table">
|
| 1131 |
+
<thead>
|
| 1132 |
+
<tr>
|
| 1133 |
+
<th>📁 Category</th>
|
| 1134 |
+
<th>📊 Total Sources</th>
|
| 1135 |
+
<th>✅ Online</th>
|
| 1136 |
+
<th>💚 Health %</th>
|
| 1137 |
+
<th>⚡ Avg Response</th>
|
| 1138 |
+
<th>🕐 Last Updated</th>
|
| 1139 |
+
<th>📈 Status</th>
|
| 1140 |
+
</tr>
|
| 1141 |
+
</thead>
|
| 1142 |
+
<tbody id="categoriesTableBody">
|
| 1143 |
+
<tr>
|
| 1144 |
+
<td colspan="7" style="text-align: center; padding: 60px;">
|
| 1145 |
+
<div class="spinner" style="width: 40px; height: 40px; margin: 0 auto 20px;"></div>
|
| 1146 |
+
<div style="color: var(--text-muted);">Loading categories...</div>
|
| 1147 |
+
</td>
|
| 1148 |
+
</tr>
|
| 1149 |
+
</tbody>
|
| 1150 |
+
</table>
|
| 1151 |
+
</div>
|
| 1152 |
+
</div>
|
| 1153 |
+
</div>
|
| 1154 |
+
|
| 1155 |
+
<!-- Logs Tab -->
|
| 1156 |
+
<div class="tab-content" id="tab-logs">
|
| 1157 |
+
<div class="card">
|
| 1158 |
+
<div class="card-header">
|
| 1159 |
+
<h2 class="card-title">
|
| 1160 |
+
<svg class="icon icon-lg">
|
| 1161 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
| 1162 |
+
<polyline points="14 2 14 8 20 8"></polyline>
|
| 1163 |
+
</svg>
|
| 1164 |
+
Connection Logs
|
| 1165 |
+
</h2>
|
| 1166 |
+
<button class="btn" onclick="loadLogs()" style="padding: 10px 20px; font-size: 13px;">
|
| 1167 |
+
<svg class="icon">
|
| 1168 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1169 |
+
</svg>
|
| 1170 |
+
Refresh
|
| 1171 |
+
</button>
|
| 1172 |
+
</div>
|
| 1173 |
+
<div class="table-container">
|
| 1174 |
+
<table class="table">
|
| 1175 |
+
<thead>
|
| 1176 |
+
<tr>
|
| 1177 |
+
<th>🕐 Timestamp</th>
|
| 1178 |
+
<th>🔌 Provider</th>
|
| 1179 |
+
<th>📝 Type</th>
|
| 1180 |
+
<th>📊 Status</th>
|
| 1181 |
+
<th>⚡ Response Time</th>
|
| 1182 |
+
<th>💬 Message</th>
|
| 1183 |
+
</tr>
|
| 1184 |
+
</thead>
|
| 1185 |
+
<tbody id="logsTableBody">
|
| 1186 |
+
<tr>
|
| 1187 |
+
<td colspan="6" style="text-align: center; padding: 60px;">
|
| 1188 |
+
<div class="spinner" style="width: 40px; height: 40px; margin: 0 auto 20px;"></div>
|
| 1189 |
+
<div style="color: var(--text-muted);">Loading logs...</div>
|
| 1190 |
+
</td>
|
| 1191 |
+
</tr>
|
| 1192 |
+
</tbody>
|
| 1193 |
+
</table>
|
| 1194 |
+
</div>
|
| 1195 |
+
</div>
|
| 1196 |
+
</div>
|
| 1197 |
+
|
| 1198 |
+
<!-- HuggingFace Tab -->
|
| 1199 |
+
<div class="tab-content" id="tab-huggingface">
|
| 1200 |
+
<div class="card">
|
| 1201 |
+
<div class="card-header">
|
| 1202 |
+
<h2 class="card-title">
|
| 1203 |
+
<svg class="icon icon-lg">
|
| 1204 |
+
<circle cx="12" cy="12" r="10"></circle>
|
| 1205 |
+
</svg>
|
| 1206 |
+
🤗 HuggingFace Health Status
|
| 1207 |
+
</h2>
|
| 1208 |
+
<button class="btn" onclick="refreshHFRegistry()" style="padding: 10px 20px; font-size: 13px;">
|
| 1209 |
+
<svg class="icon">
|
| 1210 |
+
<path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"></path>
|
| 1211 |
+
</svg>
|
| 1212 |
+
Refresh Registry
|
| 1213 |
+
</button>
|
| 1214 |
+
</div>
|
| 1215 |
+
<div id="hfHealthDisplay" style="padding: 24px; background: var(--bg-secondary); border-radius: var(--radius); font-family: 'Courier New', monospace; font-size: 14px; white-space: pre-wrap; max-height: 320px; overflow-y: auto; border: 2px solid var(--border); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);">
|
| 1216 |
+
Loading HF health status...
|
| 1217 |
+
</div>
|
| 1218 |
+
</div>
|
| 1219 |
+
|
| 1220 |
+
<div class="grid grid-2">
|
| 1221 |
+
<div class="card">
|
| 1222 |
+
<div class="card-header">
|
| 1223 |
+
<h2 class="card-title">
|
| 1224 |
+
🤖 Models Registry
|
| 1225 |
+
<span class="badge badge-success" id="hfModelsCount">0</span>
|
| 1226 |
+
</h2>
|
| 1227 |
+
</div>
|
| 1228 |
+
<div id="hfModelsList" style="max-height: 450px; overflow-y: auto;">
|
| 1229 |
+
<div style="text-align: center; padding: 40px;">
|
| 1230 |
+
<div class="spinner" style="width: 32px; height: 32px; margin: 0 auto 16px;"></div>
|
| 1231 |
+
<div style="color: var(--text-muted);">Loading models...</div>
|
| 1232 |
+
</div>
|
| 1233 |
+
</div>
|
| 1234 |
+
</div>
|
| 1235 |
+
|
| 1236 |
+
<div class="card">
|
| 1237 |
+
<div class="card-header">
|
| 1238 |
+
<h2 class="card-title">
|
| 1239 |
+
📊 Datasets Registry
|
| 1240 |
+
<span class="badge badge-success" id="hfDatasetsCount">0</span>
|
| 1241 |
+
</h2>
|
| 1242 |
+
</div>
|
| 1243 |
+
<div id="hfDatasetsList" style="max-height: 450px; overflow-y: auto;">
|
| 1244 |
+
<div style="text-align: center; padding: 40px;">
|
| 1245 |
+
<div class="spinner" style="width: 32px; height: 32px; margin: 0 auto 16px;"></div>
|
| 1246 |
+
<div style="color: var(--text-muted);">Loading datasets...</div>
|
| 1247 |
+
</div>
|
| 1248 |
+
</div>
|
| 1249 |
+
</div>
|
| 1250 |
+
</div>
|
| 1251 |
+
|
| 1252 |
+
<div class="card">
|
| 1253 |
+
<div class="card-header">
|
| 1254 |
+
<h2 class="card-title">
|
| 1255 |
+
<svg class="icon icon-lg">
|
| 1256 |
+
<circle cx="11" cy="11" r="8"></circle>
|
| 1257 |
+
<path d="m21 21-4.35-4.35"></path>
|
| 1258 |
+
</svg>
|
| 1259 |
+
Search Registry
|
| 1260 |
+
</h2>
|
| 1261 |
+
</div>
|
| 1262 |
+
<div style="display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;">
|
| 1263 |
+
<input type="text" id="hfSearchQuery" placeholder="Search crypto, bitcoin, sentiment..."
|
| 1264 |
+
style="flex: 1; min-width: 250px; padding: 14px 20px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-size: 14px;"
|
| 1265 |
+
value="crypto">
|
| 1266 |
+
<select id="hfSearchKind" style="padding: 14px 20px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-size: 14px;">
|
| 1267 |
+
<option value="models">Models</option>
|
| 1268 |
+
<option value="datasets">Datasets</option>
|
| 1269 |
+
</select>
|
| 1270 |
+
<button class="btn" onclick="searchHF()" style="padding: 14px 28px;">
|
| 1271 |
+
<svg class="icon">
|
| 1272 |
+
<circle cx="11" cy="11" r="8"></circle>
|
| 1273 |
+
<path d="m21 21-4.35-4.35"></path>
|
| 1274 |
+
</svg>
|
| 1275 |
+
Search
|
| 1276 |
+
</button>
|
| 1277 |
+
</div>
|
| 1278 |
+
<div id="hfSearchResults" style="max-height: 450px; overflow-y: auto; padding: 24px; background: var(--bg-secondary); border-radius: var(--radius); border: 2px solid var(--border); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);">
|
| 1279 |
+
<div style="text-align: center; color: var(--text-muted);">Enter a query and click search</div>
|
| 1280 |
+
</div>
|
| 1281 |
+
</div>
|
| 1282 |
+
|
| 1283 |
+
<div class="card">
|
| 1284 |
+
<div class="card-header">
|
| 1285 |
+
<h2 class="card-title">💭 Sentiment Analysis</h2>
|
| 1286 |
+
</div>
|
| 1287 |
+
<div style="margin-bottom: 20px;">
|
| 1288 |
+
<label style="display: block; font-weight: 700; margin-bottom: 12px; color: var(--text-primary);">Text Samples (one per line)</label>
|
| 1289 |
+
<textarea id="hfSentimentTexts" rows="6"
|
| 1290 |
+
style="width: 100%; padding: 16px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-size: 14px; font-family: inherit; resize: vertical;"
|
| 1291 |
+
placeholder="BTC strong breakout ETH looks weak Crypto market is bullish today">BTC strong breakout
|
| 1292 |
+
ETH looks weak
|
| 1293 |
+
Crypto market is bullish today
|
| 1294 |
+
Bears are taking control
|
| 1295 |
+
Neutral market conditions</textarea>
|
| 1296 |
+
</div>
|
| 1297 |
+
<button class="btn" onclick="runHFSentiment()">
|
| 1298 |
+
<svg class="icon">
|
| 1299 |
+
<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z"></path>
|
| 1300 |
+
</svg>
|
| 1301 |
+
Run Sentiment Analysis
|
| 1302 |
+
</button>
|
| 1303 |
+
<div id="hfSentimentVote" style="margin: 24px 0; padding: 32px; background: var(--bg-secondary); border-radius: var(--radius); text-align: center; font-size: 40px; font-weight: 900; border: 2px solid var(--border); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);">
|
| 1304 |
+
<span style="color: var(--text-muted);">—</span>
|
| 1305 |
+
</div>
|
| 1306 |
+
<div id="hfSentimentResults" style="padding: 24px; background: var(--bg-secondary); border-radius: var(--radius); font-family: 'Courier New', monospace; font-size: 13px; white-space: pre-wrap; max-height: 450px; overflow-y: auto; border: 2px solid var(--border); box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);">
|
| 1307 |
+
Results will appear here...
|
| 1308 |
+
</div>
|
| 1309 |
+
</div>
|
| 1310 |
+
</div>
|
| 1311 |
+
</div>
|
| 1312 |
+
|
| 1313 |
+
<script>
|
| 1314 |
+
// Configuration
|
| 1315 |
+
const config = {
|
| 1316 |
+
apiBaseUrl: '',
|
| 1317 |
+
wsUrl: (() => {
|
| 1318 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 1319 |
+
const host = window.location.host;
|
| 1320 |
+
return `${protocol}//${host}/ws`;
|
| 1321 |
+
})(),
|
| 1322 |
+
autoRefreshInterval: 30000,
|
| 1323 |
+
maxRetries: 3
|
| 1324 |
+
};
|
| 1325 |
+
|
| 1326 |
+
// Global state
|
| 1327 |
+
let state = {
|
| 1328 |
+
ws: null,
|
| 1329 |
+
wsConnected: false,
|
| 1330 |
+
autoRefreshEnabled: true,
|
| 1331 |
+
charts: {},
|
| 1332 |
+
currentTab: 'dashboard',
|
| 1333 |
+
providers: [],
|
| 1334 |
+
categories: [],
|
| 1335 |
+
logs: [],
|
| 1336 |
+
lastUpdate: null
|
| 1337 |
+
};
|
| 1338 |
+
|
| 1339 |
+
// Initialize on page load
|
| 1340 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 1341 |
+
console.log('🚀 Initializing Crypto API Monitor...');
|
| 1342 |
+
initializeWebSocket();
|
| 1343 |
+
loadInitialData();
|
| 1344 |
+
startAutoRefresh();
|
| 1345 |
+
});
|
| 1346 |
+
|
| 1347 |
+
// WebSocket Connection
|
| 1348 |
+
function initializeWebSocket() {
|
| 1349 |
+
updateWSStatus('connecting');
|
| 1350 |
+
|
| 1351 |
+
try {
|
| 1352 |
+
state.ws = new WebSocket(config.wsUrl);
|
| 1353 |
+
setupWebSocketHandlers();
|
| 1354 |
+
} catch (error) {
|
| 1355 |
+
console.error('WebSocket connection failed:', error);
|
| 1356 |
+
updateWSStatus('disconnected');
|
| 1357 |
+
}
|
| 1358 |
+
}
|
| 1359 |
+
|
| 1360 |
+
function setupWebSocketHandlers() {
|
| 1361 |
+
state.ws.onopen = () => {
|
| 1362 |
+
console.log('✅ WebSocket connected');
|
| 1363 |
+
state.wsConnected = true;
|
| 1364 |
+
updateWSStatus('connected');
|
| 1365 |
+
showToast('Connected', 'Real-time data stream active', 'success');
|
| 1366 |
+
};
|
| 1367 |
+
|
| 1368 |
+
state.ws.onmessage = (event) => {
|
| 1369 |
+
try {
|
| 1370 |
+
const data = JSON.parse(event.data);
|
| 1371 |
+
handleWSMessage(data);
|
| 1372 |
+
} catch (error) {
|
| 1373 |
+
console.error('Error parsing WebSocket message:', error);
|
| 1374 |
+
}
|
| 1375 |
+
};
|
| 1376 |
+
|
| 1377 |
+
state.ws.onerror = (error) => {
|
| 1378 |
+
console.error('❌ WebSocket error:', error);
|
| 1379 |
+
updateWSStatus('disconnected');
|
| 1380 |
+
};
|
| 1381 |
+
|
| 1382 |
+
state.ws.onclose = () => {
|
| 1383 |
+
console.log('⚠️ WebSocket disconnected');
|
| 1384 |
+
state.wsConnected = false;
|
| 1385 |
+
updateWSStatus('disconnected');
|
| 1386 |
+
};
|
| 1387 |
+
}
|
| 1388 |
+
|
| 1389 |
+
function updateWSStatus(status) {
|
| 1390 |
+
const statusEl = document.getElementById('wsStatus');
|
| 1391 |
+
const textEl = document.getElementById('wsStatusText');
|
| 1392 |
+
|
| 1393 |
+
statusEl.classList.remove('connected', 'disconnected', 'connecting');
|
| 1394 |
+
statusEl.classList.add(status);
|
| 1395 |
+
|
| 1396 |
+
const statusText = {
|
| 1397 |
+
'connected': '✓ Connected',
|
| 1398 |
+
'disconnected': '✗ Disconnected',
|
| 1399 |
+
'connecting': '⟳ Connecting...'
|
| 1400 |
+
};
|
| 1401 |
+
|
| 1402 |
+
textEl.textContent = statusText[status] || 'Unknown';
|
| 1403 |
+
}
|
| 1404 |
+
|
| 1405 |
+
function handleWSMessage(data) {
|
| 1406 |
+
console.log('📨 WebSocket message:', data.type);
|
| 1407 |
+
|
| 1408 |
+
switch(data.type) {
|
| 1409 |
+
case 'status_update':
|
| 1410 |
+
updateKPIs(data.data);
|
| 1411 |
+
break;
|
| 1412 |
+
case 'provider_status_change':
|
| 1413 |
+
loadProviders();
|
| 1414 |
+
break;
|
| 1415 |
+
case 'new_alert':
|
| 1416 |
+
showToast('Alert', data.data.message, 'warning');
|
| 1417 |
+
break;
|
| 1418 |
+
default:
|
| 1419 |
+
console.log('Unknown message type:', data.type);
|
| 1420 |
+
}
|
| 1421 |
+
}
|
| 1422 |
+
|
| 1423 |
+
// API Calls
|
| 1424 |
+
async function apiCall(endpoint, options = {}) {
|
| 1425 |
+
try {
|
| 1426 |
+
const url = `${config.apiBaseUrl}${endpoint}`;
|
| 1427 |
+
console.log('🌐 API Call:', url);
|
| 1428 |
+
|
| 1429 |
+
const response = await fetch(url, {
|
| 1430 |
+
...options,
|
| 1431 |
+
headers: {
|
| 1432 |
+
'Content-Type': 'application/json',
|
| 1433 |
+
...options.headers
|
| 1434 |
+
}
|
| 1435 |
+
});
|
| 1436 |
+
|
| 1437 |
+
if (!response.ok) {
|
| 1438 |
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
| 1439 |
+
}
|
| 1440 |
+
|
| 1441 |
+
const data = await response.json();
|
| 1442 |
+
console.log('✅ API Response:', endpoint, data);
|
| 1443 |
+
return data;
|
| 1444 |
+
} catch (error) {
|
| 1445 |
+
console.error(`❌ API call failed: ${endpoint}`, error);
|
| 1446 |
+
showToast('API Error', `Failed: ${endpoint}`, 'error');
|
| 1447 |
+
throw error;
|
| 1448 |
+
}
|
| 1449 |
+
}
|
| 1450 |
+
|
| 1451 |
+
async function loadInitialData() {
|
| 1452 |
+
showLoading();
|
| 1453 |
+
|
| 1454 |
+
try {
|
| 1455 |
+
console.log('📊 Loading initial data...');
|
| 1456 |
+
|
| 1457 |
+
await loadProviders();
|
| 1458 |
+
|
| 1459 |
+
initializeCharts();
|
| 1460 |
+
|
| 1461 |
+
state.lastUpdate = new Date();
|
| 1462 |
+
updateLastUpdateDisplay();
|
| 1463 |
+
|
| 1464 |
+
console.log('✅ Initial data loaded successfully');
|
| 1465 |
+
showToast('Success', 'Dashboard loaded successfully', 'success');
|
| 1466 |
+
} catch (error) {
|
| 1467 |
+
console.error('❌ Error loading initial data:', error);
|
| 1468 |
+
showToast('Error', 'Failed to load initial data', 'error');
|
| 1469 |
+
} finally {
|
| 1470 |
+
hideLoading();
|
| 1471 |
+
}
|
| 1472 |
+
}
|
| 1473 |
+
|
| 1474 |
+
async function loadProviders() {
|
| 1475 |
+
try {
|
| 1476 |
+
const data = await apiCall('/api/providers');
|
| 1477 |
+
state.providers = data;
|
| 1478 |
+
renderProvidersTable(data);
|
| 1479 |
+
renderProvidersDetail(data);
|
| 1480 |
+
updateStatusChart(data);
|
| 1481 |
+
updateKPIs(data);
|
| 1482 |
+
} catch (error) {
|
| 1483 |
+
console.error('Error loading providers:', error);
|
| 1484 |
+
document.getElementById('providersTableBody').innerHTML = `
|
| 1485 |
+
<tr>
|
| 1486 |
+
<td colspan="5" style="text-align: center; color: var(--text-muted); padding: 60px;">
|
| 1487 |
+
Failed to load providers. Please check if the API endpoint is available.
|
| 1488 |
+
</td>
|
| 1489 |
+
</tr>
|
| 1490 |
+
`;
|
| 1491 |
+
}
|
| 1492 |
+
}
|
| 1493 |
+
|
| 1494 |
+
async function loadCategories() {
|
| 1495 |
+
try {
|
| 1496 |
+
showLoading();
|
| 1497 |
+
const data = await apiCall('/api/categories');
|
| 1498 |
+
state.categories = data;
|
| 1499 |
+
renderCategoriesTable(data);
|
| 1500 |
+
showToast('Success', 'Categories loaded successfully', 'success');
|
| 1501 |
+
} catch (error) {
|
| 1502 |
+
console.error('Error loading categories:', error);
|
| 1503 |
+
showToast('Error', 'Failed to load categories', 'error');
|
| 1504 |
+
} finally {
|
| 1505 |
+
hideLoading();
|
| 1506 |
+
}
|
| 1507 |
+
}
|
| 1508 |
+
|
| 1509 |
+
async function loadLogs() {
|
| 1510 |
+
try {
|
| 1511 |
+
showLoading();
|
| 1512 |
+
const data = await apiCall('/api/logs');
|
| 1513 |
+
state.logs = data;
|
| 1514 |
+
renderLogsTable(data);
|
| 1515 |
+
showToast('Success', 'Logs loaded successfully', 'success');
|
| 1516 |
+
} catch (error) {
|
| 1517 |
+
console.error('Error loading logs:', error);
|
| 1518 |
+
showToast('Error', 'Failed to load logs', 'error');
|
| 1519 |
+
} finally {
|
| 1520 |
+
hideLoading();
|
| 1521 |
+
}
|
| 1522 |
+
}
|
| 1523 |
+
|
| 1524 |
+
// HuggingFace APIs
|
| 1525 |
+
async function loadHFHealth() {
|
| 1526 |
+
try {
|
| 1527 |
+
const data = await apiCall('/api/hf/health');
|
| 1528 |
+
document.getElementById('hfHealthDisplay').textContent = JSON.stringify(data, null, 2);
|
| 1529 |
+
} catch (error) {
|
| 1530 |
+
console.error('Error loading HF health:', error);
|
| 1531 |
+
document.getElementById('hfHealthDisplay').textContent = 'Error loading health status';
|
| 1532 |
+
}
|
| 1533 |
+
}
|
| 1534 |
+
|
| 1535 |
+
async function refreshHFRegistry() {
|
| 1536 |
+
try {
|
| 1537 |
+
showLoading();
|
| 1538 |
+
const data = await apiCall('/api/hf/refresh', { method: 'POST' });
|
| 1539 |
+
showToast('Success', 'HF Registry refreshed', 'success');
|
| 1540 |
+
loadHFModels();
|
| 1541 |
+
loadHFDatasets();
|
| 1542 |
+
} catch (error) {
|
| 1543 |
+
console.error('Error refreshing HF registry:', error);
|
| 1544 |
+
showToast('Error', 'Failed to refresh registry', 'error');
|
| 1545 |
+
} finally {
|
| 1546 |
+
hideLoading();
|
| 1547 |
+
}
|
| 1548 |
+
}
|
| 1549 |
+
|
| 1550 |
+
async function loadHFModels() {
|
| 1551 |
+
try {
|
| 1552 |
+
const data = await apiCall('/api/hf/registry?type=models');
|
| 1553 |
+
document.getElementById('hfModelsCount').textContent = data.length || 0;
|
| 1554 |
+
document.getElementById('hfModelsList').innerHTML = data.map(item => `
|
| 1555 |
+
<div style="padding: 16px; border-bottom: 1px solid var(--border); transition: var(--transition); cursor: pointer;" onmouseover="this.style.background='var(--bg-hover)'" onmouseout="this.style.background='transparent'">
|
| 1556 |
+
<div style="font-weight: 700; margin-bottom: 6px; color: var(--text-primary);">🤖 ${item.id || 'Unknown'}</div>
|
| 1557 |
+
<div style="font-size: 12px; color: var(--text-muted);">${item.description || 'No description'}</div>
|
| 1558 |
+
</div>
|
| 1559 |
+
`).join('');
|
| 1560 |
+
} catch (error) {
|
| 1561 |
+
console.error('Error loading HF models:', error);
|
| 1562 |
+
document.getElementById('hfModelsList').innerHTML = '<div style="padding: 24px; text-align: center; color: var(--text-muted);">Error loading models</div>';
|
| 1563 |
+
}
|
| 1564 |
+
}
|
| 1565 |
+
|
| 1566 |
+
async function loadHFDatasets() {
|
| 1567 |
+
try {
|
| 1568 |
+
const data = await apiCall('/api/hf/registry?type=datasets');
|
| 1569 |
+
document.getElementById('hfDatasetsCount').textContent = data.length || 0;
|
| 1570 |
+
document.getElementById('hfDatasetsList').innerHTML = data.map(item => `
|
| 1571 |
+
<div style="padding: 16px; border-bottom: 1px solid var(--border); transition: var(--transition); cursor: pointer;" onmouseover="this.style.background='var(--bg-hover)'" onmouseout="this.style.background='transparent'">
|
| 1572 |
+
<div style="font-weight: 700; margin-bottom: 6px; color: var(--text-primary);">📊 ${item.id || 'Unknown'}</div>
|
| 1573 |
+
<div style="font-size: 12px; color: var(--text-muted);">${item.description || 'No description'}</div>
|
| 1574 |
+
</div>
|
| 1575 |
+
`).join('');
|
| 1576 |
+
} catch (error) {
|
| 1577 |
+
console.error('Error loading HF datasets:', error);
|
| 1578 |
+
document.getElementById('hfDatasetsList').innerHTML = '<div style="padding: 24px; text-align: center; color: var(--text-muted);">Error loading datasets</div>';
|
| 1579 |
+
}
|
| 1580 |
+
}
|
| 1581 |
+
|
| 1582 |
+
async function searchHF() {
|
| 1583 |
+
try {
|
| 1584 |
+
showLoading();
|
| 1585 |
+
const query = document.getElementById('hfSearchQuery').value;
|
| 1586 |
+
const kind = document.getElementById('hfSearchKind').value;
|
| 1587 |
+
const data = await apiCall(`/api/hf/search?q=${encodeURIComponent(query)}&kind=${kind}`);
|
| 1588 |
+
|
| 1589 |
+
document.getElementById('hfSearchResults').innerHTML = data.map(item => `
|
| 1590 |
+
<div style="padding: 16px; border-bottom: 1px solid var(--border); transition: var(--transition); cursor: pointer;" onmouseover="this.style.background='var(--bg-hover)'" onmouseout="this.style.background='transparent'">
|
| 1591 |
+
<div style="font-weight: 700; margin-bottom: 6px; color: var(--text-primary);">${kind === 'models' ? '🤖' : '📊'} ${item.id || 'Unknown'}</div>
|
| 1592 |
+
<div style="font-size: 12px; color: var(--text-muted); margin-bottom: 6px;">${item.description || 'No description'}</div>
|
| 1593 |
+
<div style="font-size: 11px; color: var(--accent-blue);">Downloads: ${item.downloads || 0} • Likes: ${item.likes || 0}</div>
|
| 1594 |
+
</div>
|
| 1595 |
+
`).join('');
|
| 1596 |
+
|
| 1597 |
+
showToast('Success', `Found ${data.length} results`, 'success');
|
| 1598 |
+
} catch (error) {
|
| 1599 |
+
console.error('Error searching HF:', error);
|
| 1600 |
+
showToast('Error', 'Search failed', 'error');
|
| 1601 |
+
} finally {
|
| 1602 |
+
hideLoading();
|
| 1603 |
+
}
|
| 1604 |
+
}
|
| 1605 |
+
|
| 1606 |
+
async function runHFSentiment() {
|
| 1607 |
+
try {
|
| 1608 |
+
showLoading();
|
| 1609 |
+
const texts = document.getElementById('hfSentimentTexts').value.split('\n').filter(t => t.trim());
|
| 1610 |
+
|
| 1611 |
+
const data = await apiCall('/api/hf/run-sentiment', {
|
| 1612 |
+
method: 'POST',
|
| 1613 |
+
body: JSON.stringify({ texts: texts })
|
| 1614 |
+
});
|
| 1615 |
+
|
| 1616 |
+
document.getElementById('hfSentimentResults').textContent = JSON.stringify(data, null, 2);
|
| 1617 |
+
|
| 1618 |
+
// Calculate overall sentiment vote
|
| 1619 |
+
const sentiments = data.results || [];
|
| 1620 |
+
const positive = sentiments.filter(s => s.sentiment === 'positive').length;
|
| 1621 |
+
const negative = sentiments.filter(s => s.sentiment === 'negative').length;
|
| 1622 |
+
const neutral = sentiments.filter(s => s.sentiment === 'neutral').length;
|
| 1623 |
+
|
| 1624 |
+
let overall = 'NEUTRAL';
|
| 1625 |
+
let color = 'var(--info)';
|
| 1626 |
+
|
| 1627 |
+
if (positive > negative && positive > neutral) {
|
| 1628 |
+
overall = 'BULLISH 📈';
|
| 1629 |
+
color = 'var(--success)';
|
| 1630 |
+
} else if (negative > positive && negative > neutral) {
|
| 1631 |
+
overall = 'BEARISH 📉';
|
| 1632 |
+
color = 'var(--danger)';
|
| 1633 |
+
}
|
| 1634 |
+
|
| 1635 |
+
document.getElementById('hfSentimentVote').innerHTML = `
|
| 1636 |
+
<span style="color: ${color};">${overall}</span>
|
| 1637 |
+
<div style="font-size: 16px; margin-top: 12px; color: var(--text-muted);">
|
| 1638 |
+
Positive: ${positive} • Negative: ${negative} • Neutral: ${neutral}
|
| 1639 |
+
</div>
|
| 1640 |
+
`;
|
| 1641 |
+
|
| 1642 |
+
showToast('Success', 'Sentiment analysis completed', 'success');
|
| 1643 |
+
} catch (error) {
|
| 1644 |
+
console.error('Error running sentiment analysis:', error);
|
| 1645 |
+
showToast('Error', 'Sentiment analysis failed', 'error');
|
| 1646 |
+
} finally {
|
| 1647 |
+
hideLoading();
|
| 1648 |
+
}
|
| 1649 |
+
}
|
| 1650 |
+
|
| 1651 |
+
// Rendering Functions
|
| 1652 |
+
function renderProvidersTable(providers) {
|
| 1653 |
+
const tbody = document.getElementById('providersTableBody');
|
| 1654 |
+
|
| 1655 |
+
if (!providers || providers.length === 0) {
|
| 1656 |
+
tbody.innerHTML = `
|
| 1657 |
+
<tr>
|
| 1658 |
+
<td colspan="5" style="text-align: center; color: var(--text-muted); padding: 60px;">
|
| 1659 |
+
No providers found
|
| 1660 |
+
</td>
|
| 1661 |
+
</tr>
|
| 1662 |
+
`;
|
| 1663 |
+
return;
|
| 1664 |
+
}
|
| 1665 |
+
|
| 1666 |
+
tbody.innerHTML = providers.map(provider => `
|
| 1667 |
+
<tr>
|
| 1668 |
+
<td>
|
| 1669 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
| 1670 |
+
<div class="provider-icon ${provider.status || 'offline'}">
|
| 1671 |
+
${provider.status === 'online' ? '✅' : provider.status === 'degraded' ? '⚠️' : '❌'}
|
| 1672 |
+
</div>
|
| 1673 |
+
<div>
|
| 1674 |
+
<strong style="font-size: 15px;">${provider.name || 'Unknown'}</strong>
|
| 1675 |
+
<div style="font-size: 11px; color: var(--text-muted);">${provider.base_url || ''}</div>
|
| 1676 |
+
</div>
|
| 1677 |
+
</div>
|
| 1678 |
+
</td>
|
| 1679 |
+
<td>
|
| 1680 |
+
<span class="badge badge-info">${provider.category || 'General'}</span>
|
| 1681 |
+
</td>
|
| 1682 |
+
<td>
|
| 1683 |
+
<span class="badge ${getStatusBadgeClass(provider.status)}">
|
| 1684 |
+
${provider.status || 'unknown'}
|
| 1685 |
+
</span>
|
| 1686 |
+
</td>
|
| 1687 |
+
<td>
|
| 1688 |
+
<strong style="color: ${provider.response_time < 500 ? 'var(--success)' : provider.response_time < 1000 ? 'var(--warning)' : 'var(--danger)'};">
|
| 1689 |
+
${provider.response_time ? provider.response_time + 'ms' : '--'}
|
| 1690 |
+
</strong>
|
| 1691 |
+
</td>
|
| 1692 |
+
<td>
|
| 1693 |
+
<div style="font-size: 12px; font-weight: 700;">${formatTimestamp(provider.last_checked)}</div>
|
| 1694 |
+
<div style="font-size: 11px; color: var(--text-muted);">${formatTimeAgo(provider.last_checked)}</div>
|
| 1695 |
+
</td>
|
| 1696 |
+
</tr>
|
| 1697 |
+
`).join('');
|
| 1698 |
+
}
|
| 1699 |
+
|
| 1700 |
+
function renderProvidersDetail(providers) {
|
| 1701 |
+
const container = document.getElementById('providersDetail');
|
| 1702 |
+
|
| 1703 |
+
if (!providers || providers.length === 0) {
|
| 1704 |
+
container.innerHTML = `
|
| 1705 |
+
<div style="text-align: center; color: var(--text-muted); padding: 60px;">
|
| 1706 |
+
No providers data available
|
| 1707 |
+
</div>
|
| 1708 |
+
`;
|
| 1709 |
+
return;
|
| 1710 |
+
}
|
| 1711 |
+
|
| 1712 |
+
container.innerHTML = `
|
| 1713 |
+
<div class="table-container">
|
| 1714 |
+
<table class="table">
|
| 1715 |
+
<thead>
|
| 1716 |
+
<tr>
|
| 1717 |
+
<th>🔌 Provider</th>
|
| 1718 |
+
<th>📊 Status</th>
|
| 1719 |
+
<th>⚡ Response Time</th>
|
| 1720 |
+
<th>💚 Success Rate</th>
|
| 1721 |
+
<th>✅ Last Success</th>
|
| 1722 |
+
<th>❌ Errors (24h)</th>
|
| 1723 |
+
</tr>
|
| 1724 |
+
</thead>
|
| 1725 |
+
<tbody>
|
| 1726 |
+
${providers.map(provider => `
|
| 1727 |
+
<tr>
|
| 1728 |
+
<td>
|
| 1729 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
| 1730 |
+
<div class="provider-icon ${provider.status || 'offline'}">
|
| 1731 |
+
${provider.status === 'online' ? '✅' : provider.status === 'degraded' ? '⚠️' : '❌'}
|
| 1732 |
+
</div>
|
| 1733 |
+
<div>
|
| 1734 |
+
<strong style="font-size: 15px;">${provider.name || 'Unknown'}</strong>
|
| 1735 |
+
<div style="font-size: 11px; color: var(--text-muted);">${provider.base_url || ''}</div>
|
| 1736 |
+
</div>
|
| 1737 |
+
</div>
|
| 1738 |
+
</td>
|
| 1739 |
+
<td>
|
| 1740 |
+
<span class="badge ${getStatusBadgeClass(provider.status)}">
|
| 1741 |
+
${provider.status || 'unknown'}
|
| 1742 |
+
</span>
|
| 1743 |
+
</td>
|
| 1744 |
+
<td>
|
| 1745 |
+
<strong style="color: ${provider.response_time < 500 ? 'var(--success)' : provider.response_time < 1000 ? 'var(--warning)' : 'var(--danger)'};">
|
| 1746 |
+
${provider.response_time ? provider.response_time + 'ms' : '--'}
|
| 1747 |
+
</strong>
|
| 1748 |
+
</td>
|
| 1749 |
+
<td>
|
| 1750 |
+
<div class="progress">
|
| 1751 |
+
<div class="progress-bar ${getHealthClass(provider.success_rate || 0)}"
|
| 1752 |
+
style="width: ${provider.success_rate || 0}%"></div>
|
| 1753 |
+
</div>
|
| 1754 |
+
<small style="font-weight: 700;">${Math.round(provider.success_rate || 0)}%</small>
|
| 1755 |
+
</td>
|
| 1756 |
+
<td>${formatTimestamp(provider.last_success)}</td>
|
| 1757 |
+
<td>
|
| 1758 |
+
<span class="badge ${provider.error_count_24h > 10 ? 'badge-danger' : provider.error_count_24h > 0 ? 'badge-warning' : 'badge-success'}">
|
| 1759 |
+
${provider.error_count_24h || 0}
|
| 1760 |
+
</span>
|
| 1761 |
+
</td>
|
| 1762 |
+
</tr>
|
| 1763 |
+
`).join('')}
|
| 1764 |
+
</tbody>
|
| 1765 |
+
</table>
|
| 1766 |
+
</div>
|
| 1767 |
+
`;
|
| 1768 |
+
}
|
| 1769 |
+
|
| 1770 |
+
function renderCategoriesTable(categories) {
|
| 1771 |
+
const tbody = document.getElementById('categoriesTableBody');
|
| 1772 |
+
|
| 1773 |
+
if (!categories || categories.length === 0) {
|
| 1774 |
+
tbody.innerHTML = `
|
| 1775 |
+
<tr>
|
| 1776 |
+
<td colspan="7" style="text-align: center; color: var(--text-muted); padding: 60px;">
|
| 1777 |
+
No categories found
|
| 1778 |
+
</td>
|
| 1779 |
+
</tr>
|
| 1780 |
+
`;
|
| 1781 |
+
return;
|
| 1782 |
+
}
|
| 1783 |
+
|
| 1784 |
+
tbody.innerHTML = categories.map(category => `
|
| 1785 |
+
<tr>
|
| 1786 |
+
<td>
|
| 1787 |
+
<strong style="font-size: 15px;">📁 ${category.name || 'Unnamed'}</strong>
|
| 1788 |
+
</td>
|
| 1789 |
+
<td><strong>${category.total_sources || 0}</strong></td>
|
| 1790 |
+
<td><strong style="color: var(--success);">${category.online || 0}</strong></td>
|
| 1791 |
+
<td>
|
| 1792 |
+
<div class="progress">
|
| 1793 |
+
<div class="progress-bar ${getHealthClass(category.health_percentage || 0)}"
|
| 1794 |
+
style="width: ${category.health_percentage || 0}%"></div>
|
| 1795 |
+
</div>
|
| 1796 |
+
<small style="font-weight: 700;">${Math.round(category.health_percentage || 0)}%</small>
|
| 1797 |
+
</td>
|
| 1798 |
+
<td><strong>${category.avg_response || '--'}ms</strong></td>
|
| 1799 |
+
<td>${formatTimestamp(category.last_updated)}</td>
|
| 1800 |
+
<td>
|
| 1801 |
+
<span class="badge ${getStatusBadgeClass(category.status)}">
|
| 1802 |
+
${category.status || 'unknown'}
|
| 1803 |
+
</span>
|
| 1804 |
+
</td>
|
| 1805 |
+
</tr>
|
| 1806 |
+
`).join('');
|
| 1807 |
+
}
|
| 1808 |
+
|
| 1809 |
+
function renderLogsTable(logs) {
|
| 1810 |
+
const tbody = document.getElementById('logsTableBody');
|
| 1811 |
+
|
| 1812 |
+
if (!logs || logs.length === 0) {
|
| 1813 |
+
tbody.innerHTML = `
|
| 1814 |
+
<tr>
|
| 1815 |
+
<td colspan="6" style="text-align: center; color: var(--text-muted); padding: 60px;">
|
| 1816 |
+
No logs found
|
| 1817 |
+
</td>
|
| 1818 |
+
</tr>
|
| 1819 |
+
`;
|
| 1820 |
+
return;
|
| 1821 |
+
}
|
| 1822 |
+
|
| 1823 |
+
tbody.innerHTML = logs.map(log => `
|
| 1824 |
+
<tr>
|
| 1825 |
+
<td>
|
| 1826 |
+
<div style="font-size: 12px; font-weight: 700;">${formatTimestamp(log.timestamp)}</div>
|
| 1827 |
+
<div style="font-size: 11px; color: var(--text-muted);">${formatTimeAgo(log.timestamp)}</div>
|
| 1828 |
+
</td>
|
| 1829 |
+
<td>
|
| 1830 |
+
<strong>${log.provider || 'System'}</strong>
|
| 1831 |
+
</td>
|
| 1832 |
+
<td>
|
| 1833 |
+
<span class="badge ${getLogTypeClass(log.type)}">
|
| 1834 |
+
${log.type || 'unknown'}
|
| 1835 |
+
</span>
|
| 1836 |
+
</td>
|
| 1837 |
+
<td>
|
| 1838 |
+
<span class="badge ${getStatusBadgeClass(log.status)}">
|
| 1839 |
+
${log.status || 'unknown'}
|
| 1840 |
+
</span>
|
| 1841 |
+
</td>
|
| 1842 |
+
<td><strong>${log.response_time ? log.response_time + 'ms' : '--'}</strong></td>
|
| 1843 |
+
<td>
|
| 1844 |
+
<div style="max-width: 350px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
| 1845 |
+
${log.message || 'No message'}
|
| 1846 |
+
</div>
|
| 1847 |
+
</td>
|
| 1848 |
+
</tr>
|
| 1849 |
+
`).join('');
|
| 1850 |
+
}
|
| 1851 |
+
|
| 1852 |
+
// Helper functions
|
| 1853 |
+
function getHealthClass(percentage) {
|
| 1854 |
+
if (percentage >= 80) return 'success';
|
| 1855 |
+
if (percentage >= 60) return 'warning';
|
| 1856 |
+
return 'danger';
|
| 1857 |
+
}
|
| 1858 |
+
|
| 1859 |
+
function getStatusBadgeClass(status) {
|
| 1860 |
+
switch (status?.toLowerCase()) {
|
| 1861 |
+
case 'healthy': case 'online': case 'success': return 'badge-success';
|
| 1862 |
+
case 'degraded': case 'warning': return 'badge-warning';
|
| 1863 |
+
case 'offline': case 'error': case 'critical': return 'badge-danger';
|
| 1864 |
+
default: return 'badge-info';
|
| 1865 |
+
}
|
| 1866 |
+
}
|
| 1867 |
+
|
| 1868 |
+
function getLogTypeClass(type) {
|
| 1869 |
+
switch (type?.toLowerCase()) {
|
| 1870 |
+
case 'error': return 'badge-danger';
|
| 1871 |
+
case 'warning': return 'badge-warning';
|
| 1872 |
+
case 'info': case 'connection': return 'badge-info';
|
| 1873 |
+
case 'success': return 'badge-success';
|
| 1874 |
+
default: return 'badge-info';
|
| 1875 |
+
}
|
| 1876 |
+
}
|
| 1877 |
+
|
| 1878 |
+
function formatTimestamp(timestamp) {
|
| 1879 |
+
if (!timestamp) return '--';
|
| 1880 |
+
try {
|
| 1881 |
+
return new Date(timestamp).toLocaleString();
|
| 1882 |
+
} catch {
|
| 1883 |
+
return 'Invalid Date';
|
| 1884 |
+
}
|
| 1885 |
+
}
|
| 1886 |
+
|
| 1887 |
+
function formatTimeAgo(timestamp) {
|
| 1888 |
+
if (!timestamp) return '';
|
| 1889 |
+
try {
|
| 1890 |
+
const now = new Date();
|
| 1891 |
+
const time = new Date(timestamp);
|
| 1892 |
+
const diff = now - time;
|
| 1893 |
+
|
| 1894 |
+
const minutes = Math.floor(diff / 60000);
|
| 1895 |
+
const hours = Math.floor(diff / 3600000);
|
| 1896 |
+
const days = Math.floor(diff / 86400000);
|
| 1897 |
+
|
| 1898 |
+
if (days > 0) return `${days}d ago`;
|
| 1899 |
+
if (hours > 0) return `${hours}h ago`;
|
| 1900 |
+
if (minutes > 0) return `${minutes}m ago`;
|
| 1901 |
+
return 'Just now';
|
| 1902 |
+
} catch {
|
| 1903 |
+
return 'Unknown';
|
| 1904 |
+
}
|
| 1905 |
+
}
|
| 1906 |
+
|
| 1907 |
+
// KPI Updates
|
| 1908 |
+
function updateKPIs(data) {
|
| 1909 |
+
if (!data) return;
|
| 1910 |
+
|
| 1911 |
+
const totalAPIs = data.length || 0;
|
| 1912 |
+
document.getElementById('kpiTotalAPIs').textContent = totalAPIs;
|
| 1913 |
+
document.getElementById('kpiTotalTrend').textContent = `${totalAPIs} active`;
|
| 1914 |
+
|
| 1915 |
+
const onlineCount = data.filter(p => p.status === 'online' || p.status === 'healthy').length;
|
| 1916 |
+
document.getElementById('kpiOnline').textContent = onlineCount;
|
| 1917 |
+
document.getElementById('kpiOnlineTrend').textContent = `${Math.round((onlineCount / totalAPIs) * 100)}% uptime`;
|
| 1918 |
+
|
| 1919 |
+
const validResponses = data.filter(p => p.response_time).map(p => p.response_time);
|
| 1920 |
+
const avgResponse = validResponses.length > 0 ?
|
| 1921 |
+
Math.round(validResponses.reduce((a, b) => a + b, 0) / validResponses.length) : 0;
|
| 1922 |
+
|
| 1923 |
+
document.getElementById('kpiAvgResponse').textContent = avgResponse + 'ms';
|
| 1924 |
+
|
| 1925 |
+
const responseTrend = avgResponse < 500 ? 'Optimal' : avgResponse < 1000 ? 'Acceptable' : 'Slow';
|
| 1926 |
+
document.getElementById('kpiResponseTrend').textContent = responseTrend;
|
| 1927 |
+
}
|
| 1928 |
+
|
| 1929 |
+
function updateLastUpdateDisplay() {
|
| 1930 |
+
if (state.lastUpdate) {
|
| 1931 |
+
document.getElementById('kpiLastUpdate').textContent =
|
| 1932 |
+
state.lastUpdate.toLocaleTimeString() + '\n' + state.lastUpdate.toLocaleDateString();
|
| 1933 |
+
}
|
| 1934 |
+
}
|
| 1935 |
+
|
| 1936 |
+
// Chart Functions
|
| 1937 |
+
function initializeCharts() {
|
| 1938 |
+
const healthCtx = document.getElementById('healthChart').getContext('2d');
|
| 1939 |
+
state.charts.health = new Chart(healthCtx, {
|
| 1940 |
+
type: 'line',
|
| 1941 |
+
data: {
|
| 1942 |
+
labels: [],
|
| 1943 |
+
datasets: [{
|
| 1944 |
+
label: 'System Health %',
|
| 1945 |
+
data: [],
|
| 1946 |
+
borderColor: '#00d4ff',
|
| 1947 |
+
backgroundColor: 'rgba(0, 212, 255, 0.1)',
|
| 1948 |
+
borderWidth: 3,
|
| 1949 |
+
fill: true,
|
| 1950 |
+
tension: 0.4
|
| 1951 |
+
}]
|
| 1952 |
+
},
|
| 1953 |
+
options: {
|
| 1954 |
+
responsive: true,
|
| 1955 |
+
maintainAspectRatio: false,
|
| 1956 |
+
plugins: {
|
| 1957 |
+
legend: {
|
| 1958 |
+
display: false
|
| 1959 |
+
}
|
| 1960 |
+
},
|
| 1961 |
+
scales: {
|
| 1962 |
+
y: {
|
| 1963 |
+
beginAtZero: true,
|
| 1964 |
+
max: 100,
|
| 1965 |
+
grid: {
|
| 1966 |
+
color: 'rgba(255, 255, 255, 0.1)'
|
| 1967 |
+
},
|
| 1968 |
+
ticks: {
|
| 1969 |
+
color: '#b8c1ec'
|
| 1970 |
+
}
|
| 1971 |
+
},
|
| 1972 |
+
x: {
|
| 1973 |
+
grid: {
|
| 1974 |
+
color: 'rgba(255, 255, 255, 0.1)'
|
| 1975 |
+
},
|
| 1976 |
+
ticks: {
|
| 1977 |
+
color: '#b8c1ec'
|
| 1978 |
+
}
|
| 1979 |
+
}
|
| 1980 |
+
}
|
| 1981 |
+
}
|
| 1982 |
+
});
|
| 1983 |
+
|
| 1984 |
+
const statusCtx = document.getElementById('statusChart').getContext('2d');
|
| 1985 |
+
state.charts.status = new Chart(statusCtx, {
|
| 1986 |
+
type: 'doughnut',
|
| 1987 |
+
data: {
|
| 1988 |
+
labels: ['Online', 'Degraded', 'Offline'],
|
| 1989 |
+
datasets: [{
|
| 1990 |
+
data: [0, 0, 0],
|
| 1991 |
+
backgroundColor: [
|
| 1992 |
+
'#10b981',
|
| 1993 |
+
'#fbbf24',
|
| 1994 |
+
'#ef4444'
|
| 1995 |
+
],
|
| 1996 |
+
borderWidth: 0
|
| 1997 |
+
}]
|
| 1998 |
+
},
|
| 1999 |
+
options: {
|
| 2000 |
+
responsive: true,
|
| 2001 |
+
maintainAspectRatio: false,
|
| 2002 |
+
cutout: '70%',
|
| 2003 |
+
plugins: {
|
| 2004 |
+
legend: {
|
| 2005 |
+
position: 'bottom',
|
| 2006 |
+
labels: {
|
| 2007 |
+
color: '#b8c1ec',
|
| 2008 |
+
font: {
|
| 2009 |
+
size: 13,
|
| 2010 |
+
weight: 700
|
| 2011 |
+
}
|
| 2012 |
+
}
|
| 2013 |
+
}
|
| 2014 |
+
}
|
| 2015 |
+
}
|
| 2016 |
+
});
|
| 2017 |
+
}
|
| 2018 |
+
|
| 2019 |
+
function updateStatusChart(providers) {
|
| 2020 |
+
if (!state.charts.status || !providers) return;
|
| 2021 |
+
|
| 2022 |
+
const online = providers.filter(p => p.status === 'online' || p.status === 'healthy').length;
|
| 2023 |
+
const degraded = providers.filter(p => p.status === 'degraded' || p.status === 'warning').length;
|
| 2024 |
+
const offline = providers.filter(p => p.status === 'offline' || p.status === 'error').length;
|
| 2025 |
+
|
| 2026 |
+
state.charts.status.data.datasets[0].data = [online, degraded, offline];
|
| 2027 |
+
state.charts.status.update();
|
| 2028 |
+
}
|
| 2029 |
+
|
| 2030 |
+
// Tab Management
|
| 2031 |
+
function switchTab(event, tabName) {
|
| 2032 |
+
document.querySelectorAll('.tab').forEach(tab => {
|
| 2033 |
+
tab.classList.remove('active');
|
| 2034 |
+
});
|
| 2035 |
+
|
| 2036 |
+
document.querySelectorAll('.tab-content').forEach(content => {
|
| 2037 |
+
content.classList.remove('active');
|
| 2038 |
+
});
|
| 2039 |
+
|
| 2040 |
+
event.currentTarget.classList.add('active');
|
| 2041 |
+
|
| 2042 |
+
document.getElementById(`tab-${tabName}`).classList.add('active');
|
| 2043 |
+
|
| 2044 |
+
switch(tabName) {
|
| 2045 |
+
case 'dashboard':
|
| 2046 |
+
loadProviders();
|
| 2047 |
+
break;
|
| 2048 |
+
case 'providers':
|
| 2049 |
+
loadProviders();
|
| 2050 |
+
break;
|
| 2051 |
+
case 'categories':
|
| 2052 |
+
loadCategories();
|
| 2053 |
+
break;
|
| 2054 |
+
case 'logs':
|
| 2055 |
+
loadLogs();
|
| 2056 |
+
break;
|
| 2057 |
+
case 'huggingface':
|
| 2058 |
+
loadHFHealth();
|
| 2059 |
+
loadHFModels();
|
| 2060 |
+
loadHFDatasets();
|
| 2061 |
+
break;
|
| 2062 |
+
}
|
| 2063 |
+
|
| 2064 |
+
state.currentTab = tabName;
|
| 2065 |
+
}
|
| 2066 |
+
|
| 2067 |
+
// Utility Functions
|
| 2068 |
+
function showLoading() {
|
| 2069 |
+
document.getElementById('loadingOverlay').classList.add('active');
|
| 2070 |
+
}
|
| 2071 |
+
|
| 2072 |
+
function hideLoading() {
|
| 2073 |
+
document.getElementById('loadingOverlay').classList.remove('active');
|
| 2074 |
+
}
|
| 2075 |
+
|
| 2076 |
+
function showToast(title, message, type = 'info') {
|
| 2077 |
+
const container = document.getElementById('toastContainer');
|
| 2078 |
+
const toast = document.createElement('div');
|
| 2079 |
+
toast.className = `toast ${type}`;
|
| 2080 |
+
toast.innerHTML = `
|
| 2081 |
+
<div style="flex: 1;">
|
| 2082 |
+
<div style="font-weight: 700; font-size: 15px; margin-bottom: 4px;">${title}</div>
|
| 2083 |
+
<div style="font-size: 13px; color: var(--text-secondary);">${message}</div>
|
| 2084 |
+
</div>
|
| 2085 |
+
<button onclick="this.parentElement.remove()" style="background: none; border: none; cursor: pointer; color: inherit; padding: 4px;">
|
| 2086 |
+
<svg class="icon" style="width: 18px; height: 18px;">
|
| 2087 |
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
| 2088 |
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
| 2089 |
+
</svg>
|
| 2090 |
+
</button>
|
| 2091 |
+
`;
|
| 2092 |
+
|
| 2093 |
+
container.appendChild(toast);
|
| 2094 |
+
|
| 2095 |
+
setTimeout(() => {
|
| 2096 |
+
if (toast.parentElement) {
|
| 2097 |
+
toast.remove();
|
| 2098 |
+
}
|
| 2099 |
+
}, 5000);
|
| 2100 |
+
}
|
| 2101 |
+
|
| 2102 |
+
function refreshAll() {
|
| 2103 |
+
console.log('🔄 Refreshing all data...');
|
| 2104 |
+
loadInitialData();
|
| 2105 |
+
|
| 2106 |
+
switch(state.currentTab) {
|
| 2107 |
+
case 'categories':
|
| 2108 |
+
loadCategories();
|
| 2109 |
+
break;
|
| 2110 |
+
case 'logs':
|
| 2111 |
+
loadLogs();
|
| 2112 |
+
break;
|
| 2113 |
+
case 'huggingface':
|
| 2114 |
+
loadHFHealth();
|
| 2115 |
+
loadHFModels();
|
| 2116 |
+
loadHFDatasets();
|
| 2117 |
+
break;
|
| 2118 |
+
}
|
| 2119 |
+
}
|
| 2120 |
+
|
| 2121 |
+
function startAutoRefresh() {
|
| 2122 |
+
setInterval(() => {
|
| 2123 |
+
if (state.autoRefreshEnabled && state.wsConnected) {
|
| 2124 |
+
console.log('🔄 Auto-refreshing data...');
|
| 2125 |
+
refreshAll();
|
| 2126 |
+
}
|
| 2127 |
+
}, config.autoRefreshInterval);
|
| 2128 |
+
}
|
| 2129 |
+
</script>
|
| 2130 |
+
</body>
|
| 2131 |
+
</html>
|
| 2132 |
+
|
requirements.txt
CHANGED
|
@@ -24,28 +24,10 @@ pyyaml==6.0.1
|
|
| 24 |
# Logging
|
| 25 |
loguru==0.7.2
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
pytest==7.4.3
|
| 29 |
-
pytest-asyncio==0.21.1
|
| 30 |
-
|
| 31 |
-
# Database (optional - for future)
|
| 32 |
sqlalchemy==2.0.23
|
| 33 |
aiosqlite==0.19.0
|
| 34 |
|
| 35 |
-
# Caching (optional - for future)
|
| 36 |
-
redis==5.0.1
|
| 37 |
-
aioredis==2.0.1
|
| 38 |
-
|
| 39 |
-
# Machine Learning / NLP (optional - for advanced sentiment)
|
| 40 |
-
transformers==4.36.0
|
| 41 |
-
torch==2.1.2
|
| 42 |
-
sentencepiece==0.1.99
|
| 43 |
-
huggingface-hub==0.19.4
|
| 44 |
-
duckduckgo-search==4.1.0
|
| 45 |
-
|
| 46 |
-
# Monitoring (optional)
|
| 47 |
-
prometheus-client==0.19.0
|
| 48 |
-
|
| 49 |
# Utils
|
| 50 |
python-dateutil==2.8.2
|
| 51 |
pytz==2023.3
|
|
|
|
| 24 |
# Logging
|
| 25 |
loguru==0.7.2
|
| 26 |
|
| 27 |
+
# Database
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
sqlalchemy==2.0.23
|
| 29 |
aiosqlite==0.19.0
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Utils
|
| 32 |
python-dateutil==2.8.2
|
| 33 |
pytz==2023.3
|
simple_overview.html
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Crypto Monitor - Complete Overview</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
padding: 20px;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.container {
|
| 22 |
+
max-width: 1400px;
|
| 23 |
+
margin: 0 auto;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.header {
|
| 27 |
+
background: white;
|
| 28 |
+
border-radius: 15px;
|
| 29 |
+
padding: 30px;
|
| 30 |
+
margin-bottom: 20px;
|
| 31 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
| 32 |
+
display: flex;
|
| 33 |
+
justify-content: space-between;
|
| 34 |
+
align-items: center;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.header h1 {
|
| 38 |
+
color: #667eea;
|
| 39 |
+
font-size: 2em;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.refresh-btn {
|
| 43 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 44 |
+
color: white;
|
| 45 |
+
border: none;
|
| 46 |
+
padding: 12px 30px;
|
| 47 |
+
border-radius: 10px;
|
| 48 |
+
font-size: 1em;
|
| 49 |
+
font-weight: 600;
|
| 50 |
+
cursor: pointer;
|
| 51 |
+
transition: all 0.3s ease;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.refresh-btn:hover {
|
| 55 |
+
transform: translateY(-2px);
|
| 56 |
+
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.stats-grid {
|
| 60 |
+
display: grid;
|
| 61 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 62 |
+
gap: 15px;
|
| 63 |
+
margin-bottom: 20px;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.stat-card {
|
| 67 |
+
background: white;
|
| 68 |
+
border-radius: 12px;
|
| 69 |
+
padding: 20px;
|
| 70 |
+
text-align: center;
|
| 71 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.stat-card h3 {
|
| 75 |
+
color: #999;
|
| 76 |
+
font-size: 0.85em;
|
| 77 |
+
text-transform: uppercase;
|
| 78 |
+
margin-bottom: 10px;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.stat-card .value {
|
| 82 |
+
font-size: 2.5em;
|
| 83 |
+
font-weight: bold;
|
| 84 |
+
margin-bottom: 5px;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.stat-card.green .value { color: #10b981; }
|
| 88 |
+
.stat-card.blue .value { color: #3b82f6; }
|
| 89 |
+
.stat-card.orange .value { color: #f59e0b; }
|
| 90 |
+
.stat-card.red .value { color: #ef4444; }
|
| 91 |
+
|
| 92 |
+
.content-grid {
|
| 93 |
+
display: grid;
|
| 94 |
+
grid-template-columns: 2fr 1fr;
|
| 95 |
+
gap: 20px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.card {
|
| 99 |
+
background: white;
|
| 100 |
+
border-radius: 15px;
|
| 101 |
+
padding: 25px;
|
| 102 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.card h2 {
|
| 106 |
+
color: #333;
|
| 107 |
+
margin-bottom: 20px;
|
| 108 |
+
padding-bottom: 10px;
|
| 109 |
+
border-bottom: 3px solid #667eea;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.providers-list {
|
| 113 |
+
display: grid;
|
| 114 |
+
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
| 115 |
+
gap: 10px;
|
| 116 |
+
max-height: 600px;
|
| 117 |
+
overflow-y: auto;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.provider-item {
|
| 121 |
+
background: #f8f9fa;
|
| 122 |
+
border-radius: 8px;
|
| 123 |
+
padding: 12px;
|
| 124 |
+
border-left: 4px solid #ddd;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.provider-item.online {
|
| 128 |
+
border-left-color: #10b981;
|
| 129 |
+
background: linear-gradient(to right, #f0fdf4, #f8f9fa);
|
| 130 |
+
}
|
| 131 |
+
.provider-item.offline {
|
| 132 |
+
border-left-color: #ef4444;
|
| 133 |
+
background: linear-gradient(to right, #fef2f2, #f8f9fa);
|
| 134 |
+
}
|
| 135 |
+
.provider-item.degraded {
|
| 136 |
+
border-left-color: #f59e0b;
|
| 137 |
+
background: linear-gradient(to right, #fffbeb, #f8f9fa);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.provider-item .name {
|
| 141 |
+
font-weight: 600;
|
| 142 |
+
color: #333;
|
| 143 |
+
font-size: 0.9em;
|
| 144 |
+
margin-bottom: 5px;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.provider-item .info {
|
| 148 |
+
font-size: 0.75em;
|
| 149 |
+
color: #666;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.category-list {
|
| 153 |
+
display: flex;
|
| 154 |
+
flex-direction: column;
|
| 155 |
+
gap: 12px;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.category-item {
|
| 159 |
+
background: #f8f9fa;
|
| 160 |
+
border-radius: 8px;
|
| 161 |
+
padding: 15px;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.category-item .name {
|
| 165 |
+
font-weight: 600;
|
| 166 |
+
color: #333;
|
| 167 |
+
margin-bottom: 8px;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.category-item .stats {
|
| 171 |
+
display: flex;
|
| 172 |
+
gap: 10px;
|
| 173 |
+
font-size: 0.85em;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.loading {
|
| 177 |
+
text-align: center;
|
| 178 |
+
padding: 40px;
|
| 179 |
+
color: #666;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
@media (max-width: 768px) {
|
| 183 |
+
.content-grid {
|
| 184 |
+
grid-template-columns: 1fr;
|
| 185 |
+
}
|
| 186 |
+
.stats-grid {
|
| 187 |
+
grid-template-columns: repeat(2, 1fr);
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
</style>
|
| 191 |
+
</head>
|
| 192 |
+
<body>
|
| 193 |
+
<div class="container">
|
| 194 |
+
<div class="header">
|
| 195 |
+
<div>
|
| 196 |
+
<h1>🚀 Crypto API Monitor</h1>
|
| 197 |
+
<p style="color: #666; margin-top: 5px;">Complete System Overview</p>
|
| 198 |
+
</div>
|
| 199 |
+
<button class="refresh-btn" onclick="loadData()">🔄 Refresh</button>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<div class="stats-grid">
|
| 203 |
+
<div class="stat-card blue">
|
| 204 |
+
<h3>Total APIs</h3>
|
| 205 |
+
<div class="value" id="total">-</div>
|
| 206 |
+
</div>
|
| 207 |
+
<div class="stat-card green">
|
| 208 |
+
<h3>Online</h3>
|
| 209 |
+
<div class="value" id="online">-</div>
|
| 210 |
+
</div>
|
| 211 |
+
<div class="stat-card orange">
|
| 212 |
+
<h3>Degraded</h3>
|
| 213 |
+
<div class="value" id="degraded">-</div>
|
| 214 |
+
</div>
|
| 215 |
+
<div class="stat-card red">
|
| 216 |
+
<h3>Offline</h3>
|
| 217 |
+
<div class="value" id="offline">-</div>
|
| 218 |
+
</div>
|
| 219 |
+
</div>
|
| 220 |
+
|
| 221 |
+
<div class="content-grid">
|
| 222 |
+
<div class="card">
|
| 223 |
+
<h2>📊 All Providers</h2>
|
| 224 |
+
<div class="providers-list" id="providers">
|
| 225 |
+
<div class="loading">Loading...</div>
|
| 226 |
+
</div>
|
| 227 |
+
</div>
|
| 228 |
+
|
| 229 |
+
<div class="card">
|
| 230 |
+
<h2>📁 Categories</h2>
|
| 231 |
+
<div class="category-list" id="categories">
|
| 232 |
+
<div class="loading">Loading...</div>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
+
</div>
|
| 236 |
+
</div>
|
| 237 |
+
|
| 238 |
+
<script>
|
| 239 |
+
async function loadData() {
|
| 240 |
+
try {
|
| 241 |
+
const response = await fetch('/api/providers');
|
| 242 |
+
const providers = await response.json();
|
| 243 |
+
|
| 244 |
+
// Calculate stats
|
| 245 |
+
const online = providers.filter(p => p.status === 'online').length;
|
| 246 |
+
const offline = providers.filter(p => p.status === 'offline').length;
|
| 247 |
+
const degraded = providers.filter(p => p.status === 'degraded').length;
|
| 248 |
+
|
| 249 |
+
// Update stats
|
| 250 |
+
document.getElementById('total').textContent = providers.length;
|
| 251 |
+
document.getElementById('online').textContent = online;
|
| 252 |
+
document.getElementById('degraded').textContent = degraded;
|
| 253 |
+
document.getElementById('offline').textContent = offline;
|
| 254 |
+
|
| 255 |
+
// Group by category
|
| 256 |
+
const categories = {};
|
| 257 |
+
providers.forEach(p => {
|
| 258 |
+
if (!categories[p.category]) {
|
| 259 |
+
categories[p.category] = { online: 0, offline: 0, degraded: 0 };
|
| 260 |
+
}
|
| 261 |
+
categories[p.category][p.status]++;
|
| 262 |
+
});
|
| 263 |
+
|
| 264 |
+
// Display providers
|
| 265 |
+
const providersHtml = providers.map(p => `
|
| 266 |
+
<div class="provider-item ${p.status}">
|
| 267 |
+
<div class="name">${p.name}</div>
|
| 268 |
+
<div class="info">${p.category}</div>
|
| 269 |
+
<div class="info" style="color: ${p.status === 'online' ? '#10b981' : p.status === 'degraded' ? '#f59e0b' : '#ef4444'}">
|
| 270 |
+
${p.status.toUpperCase()}
|
| 271 |
+
</div>
|
| 272 |
+
</div>
|
| 273 |
+
`).join('');
|
| 274 |
+
document.getElementById('providers').innerHTML = providersHtml;
|
| 275 |
+
|
| 276 |
+
// Display categories
|
| 277 |
+
const categoriesHtml = Object.entries(categories).map(([name, stats]) => `
|
| 278 |
+
<div class="category-item">
|
| 279 |
+
<div class="name">${name}</div>
|
| 280 |
+
<div class="stats">
|
| 281 |
+
<span style="color: #10b981;">✓ ${stats.online}</span>
|
| 282 |
+
<span style="color: #f59e0b;">⚠ ${stats.degraded}</span>
|
| 283 |
+
<span style="color: #ef4444;">✗ ${stats.offline}</span>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
`).join('');
|
| 287 |
+
document.getElementById('categories').innerHTML = categoriesHtml;
|
| 288 |
+
|
| 289 |
+
} catch (error) {
|
| 290 |
+
console.error('Error:', error);
|
| 291 |
+
document.getElementById('providers').innerHTML = '<div class="loading">Error loading data</div>';
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Load on start
|
| 296 |
+
loadData();
|
| 297 |
+
|
| 298 |
+
// Auto-refresh every 30 seconds
|
| 299 |
+
setInterval(loadData, 30000);
|
| 300 |
+
</script>
|
| 301 |
+
</body>
|
| 302 |
+
</html>
|
| 303 |
+
|
static/js/dashboard.js
CHANGED
|
@@ -100,27 +100,47 @@ class DashboardApp {
|
|
| 100 |
try {
|
| 101 |
let html = '<div class="stats-grid">';
|
| 102 |
|
| 103 |
-
// Market stats
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
-
if (
|
| 108 |
-
html += this.createStatCard('📊', '24h Volume', this.formatCurrency(
|
| 109 |
}
|
| 110 |
-
if (
|
| 111 |
-
html += this.createStatCard('₿', 'BTC Dominance', `${
|
| 112 |
}
|
| 113 |
-
if (
|
| 114 |
-
html += this.createStatCard('🪙', 'Active Coins',
|
| 115 |
}
|
| 116 |
|
| 117 |
html += '</div>';
|
| 118 |
|
| 119 |
-
//
|
| 120 |
-
if (data.
|
| 121 |
-
html += '<div class="card"><div class="card-header"><h3 class="card-title"
|
| 122 |
-
html +=
|
| 123 |
-
html += '</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
container.innerHTML = html;
|
|
@@ -250,25 +270,34 @@ class DashboardApp {
|
|
| 250 |
|
| 251 |
let html = '<div class="card"><div class="card-header">';
|
| 252 |
html += '<h3 class="card-title">📝 Recent Logs</h3>';
|
| 253 |
-
html +=
|
| 254 |
html += '</div><div class="card-body">';
|
| 255 |
|
| 256 |
if (logs.length === 0) {
|
| 257 |
html += this.createEmptyState('No logs available', 'Logs will appear here as the system runs');
|
| 258 |
} else {
|
| 259 |
-
html += '<div class="
|
|
|
|
|
|
|
|
|
|
| 260 |
logs.forEach(log => {
|
| 261 |
-
const
|
|
|
|
| 262 |
const timestamp = log.timestamp ? new Date(log.timestamp).toLocaleString() : '';
|
| 263 |
const message = log.message || '';
|
|
|
|
|
|
|
| 264 |
|
| 265 |
-
html +=
|
| 266 |
-
html += `<
|
| 267 |
-
html += `<
|
| 268 |
-
html += `<
|
| 269 |
-
html +=
|
|
|
|
|
|
|
| 270 |
});
|
| 271 |
-
|
|
|
|
| 272 |
}
|
| 273 |
|
| 274 |
html += '</div></div>';
|
|
|
|
| 100 |
try {
|
| 101 |
let html = '<div class="stats-grid">';
|
| 102 |
|
| 103 |
+
// Market stats from global data
|
| 104 |
+
const global = data.global || {};
|
| 105 |
+
|
| 106 |
+
if (global.total_market_cap) {
|
| 107 |
+
html += this.createStatCard('💰', 'Market Cap', this.formatCurrency(global.total_market_cap), 'primary');
|
| 108 |
}
|
| 109 |
+
if (global.total_volume) {
|
| 110 |
+
html += this.createStatCard('📊', '24h Volume', this.formatCurrency(global.total_volume), 'purple');
|
| 111 |
}
|
| 112 |
+
if (global.btc_dominance) {
|
| 113 |
+
html += this.createStatCard('₿', 'BTC Dominance', `${global.btc_dominance.toFixed(2)}%`, 'yellow');
|
| 114 |
}
|
| 115 |
+
if (global.active_cryptocurrencies) {
|
| 116 |
+
html += this.createStatCard('🪙', 'Active Coins', global.active_cryptocurrencies.toLocaleString(), 'green');
|
| 117 |
}
|
| 118 |
|
| 119 |
html += '</div>';
|
| 120 |
|
| 121 |
+
// Top cryptocurrencies table
|
| 122 |
+
if (data.cryptocurrencies && data.cryptocurrencies.length > 0) {
|
| 123 |
+
html += '<div class="card"><div class="card-header"><h3 class="card-title">🔝 Top Cryptocurrencies</h3></div><div class="card-body">';
|
| 124 |
+
html += '<div class="table-container table-responsive"><table class="table"><thead><tr>';
|
| 125 |
+
html += '<th>Rank</th><th>Name</th><th>Price</th><th>24h Change</th><th>Market Cap</th><th>Volume</th>';
|
| 126 |
+
html += '</tr></thead><tbody>';
|
| 127 |
+
|
| 128 |
+
data.cryptocurrencies.slice(0, 10).forEach((coin, index) => {
|
| 129 |
+
const change = coin.price_change_24h || 0;
|
| 130 |
+
const changeClass = change >= 0 ? 'success' : 'danger';
|
| 131 |
+
const changeIcon = change >= 0 ? '📈' : '📉';
|
| 132 |
+
|
| 133 |
+
html += '<tr>';
|
| 134 |
+
html += `<td data-label="Rank">${index + 1}</td>`;
|
| 135 |
+
html += `<td data-label="Name"><strong>${coin.name}</strong> <span class="text-muted">${coin.symbol}</span></td>`;
|
| 136 |
+
html += `<td data-label="Price">${this.formatCurrency(coin.price)}</td>`;
|
| 137 |
+
html += `<td data-label="24h Change"><span class="badge badge-${changeClass}">${changeIcon} ${change.toFixed(2)}%</span></td>`;
|
| 138 |
+
html += `<td data-label="Market Cap">${coin.market_cap ? this.formatCurrency(coin.market_cap) : 'N/A'}</td>`;
|
| 139 |
+
html += `<td data-label="Volume">${coin.volume_24h ? this.formatCurrency(coin.volume_24h) : 'N/A'}</td>`;
|
| 140 |
+
html += '</tr>';
|
| 141 |
+
});
|
| 142 |
+
|
| 143 |
+
html += '</tbody></table></div></div></div>';
|
| 144 |
}
|
| 145 |
|
| 146 |
container.innerHTML = html;
|
|
|
|
| 270 |
|
| 271 |
let html = '<div class="card"><div class="card-header">';
|
| 272 |
html += '<h3 class="card-title">📝 Recent Logs</h3>';
|
| 273 |
+
html += `<span class="text-muted">${logs.length} entries</span>`;
|
| 274 |
html += '</div><div class="card-body">';
|
| 275 |
|
| 276 |
if (logs.length === 0) {
|
| 277 |
html += this.createEmptyState('No logs available', 'Logs will appear here as the system runs');
|
| 278 |
} else {
|
| 279 |
+
html += '<div class="table-container table-responsive"><table class="table"><thead><tr>';
|
| 280 |
+
html += '<th>Time</th><th>Provider</th><th>Status</th><th>Response Time</th><th>Message</th>';
|
| 281 |
+
html += '</tr></thead><tbody>';
|
| 282 |
+
|
| 283 |
logs.forEach(log => {
|
| 284 |
+
const type = log.type || 'info';
|
| 285 |
+
const status = log.status || 'unknown';
|
| 286 |
const timestamp = log.timestamp ? new Date(log.timestamp).toLocaleString() : '';
|
| 287 |
const message = log.message || '';
|
| 288 |
+
const provider = log.provider || 'System';
|
| 289 |
+
const responseTime = log.response_time ? `${log.response_time}ms` : 'N/A';
|
| 290 |
|
| 291 |
+
html += '<tr>';
|
| 292 |
+
html += `<td data-label="Time"><small>${timestamp}</small></td>`;
|
| 293 |
+
html += `<td data-label="Provider"><strong>${provider}</strong></td>`;
|
| 294 |
+
html += `<td data-label="Status">${this.createStatusBadge(status)}</td>`;
|
| 295 |
+
html += `<td data-label="Response Time">${responseTime}</td>`;
|
| 296 |
+
html += `<td data-label="Message">${this.escapeHtml(message)}</td>`;
|
| 297 |
+
html += '</tr>';
|
| 298 |
});
|
| 299 |
+
|
| 300 |
+
html += '</tbody></table></div>';
|
| 301 |
}
|
| 302 |
|
| 303 |
html += '</div></div>';
|
test_deployment.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Quick test to verify deployment readiness"""
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
print("Testing Deployment Readiness...\n")
|
| 7 |
+
|
| 8 |
+
# Test 1: Check main files exist
|
| 9 |
+
print("[1/4] Checking files...")
|
| 10 |
+
required_files = [
|
| 11 |
+
"Dockerfile",
|
| 12 |
+
"requirements.txt",
|
| 13 |
+
"README.md",
|
| 14 |
+
"main.py",
|
| 15 |
+
"app.py",
|
| 16 |
+
"unified_dashboard.html",
|
| 17 |
+
"config.js"
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
all_good = True
|
| 21 |
+
for file in required_files:
|
| 22 |
+
if os.path.exists(file):
|
| 23 |
+
print(f" OK: {file}")
|
| 24 |
+
else:
|
| 25 |
+
print(f" MISSING: {file}")
|
| 26 |
+
all_good = False
|
| 27 |
+
|
| 28 |
+
if not all_good:
|
| 29 |
+
sys.exit(1)
|
| 30 |
+
|
| 31 |
+
# Test 2: Check static folder
|
| 32 |
+
print("\n[2/4] Checking static folder...")
|
| 33 |
+
if os.path.exists("static"):
|
| 34 |
+
js_files = len([f for f in os.listdir("static/js") if f.endswith(".js")])
|
| 35 |
+
css_files = len([f for f in os.listdir("static/css") if f.endswith(".css")])
|
| 36 |
+
print(f" OK: static/ ({js_files} JS files, {css_files} CSS files)")
|
| 37 |
+
else:
|
| 38 |
+
print(" MISSING: static/ folder")
|
| 39 |
+
sys.exit(1)
|
| 40 |
+
|
| 41 |
+
# Test 3: Try importing app
|
| 42 |
+
print("\n[3/4] Testing Python imports...")
|
| 43 |
+
try:
|
| 44 |
+
from main import app
|
| 45 |
+
print(f" OK: main:app loaded successfully (Type: {type(app).__name__})")
|
| 46 |
+
except Exception as e:
|
| 47 |
+
print(f" ERROR: Failed to import - {e}")
|
| 48 |
+
sys.exit(1)
|
| 49 |
+
|
| 50 |
+
# Test 4: Check app routes
|
| 51 |
+
print("\n[4/4] Checking routes...")
|
| 52 |
+
routes = [r.path for r in app.routes]
|
| 53 |
+
critical_routes = ["/", "/health", "/api/providers", "/docs"]
|
| 54 |
+
for route in critical_routes:
|
| 55 |
+
if route in routes:
|
| 56 |
+
print(f" OK: {route}")
|
| 57 |
+
else:
|
| 58 |
+
print(f" WARNING: {route} not found")
|
| 59 |
+
|
| 60 |
+
print("\n" + "="*60)
|
| 61 |
+
print("SUCCESS! ALL TESTS PASSED!")
|
| 62 |
+
print("="*60)
|
| 63 |
+
print("\nYour project is ready to deploy to Hugging Face!")
|
| 64 |
+
print("\nDeployment steps:")
|
| 65 |
+
print("1. Create Space on HuggingFace.co (choose Docker SDK)")
|
| 66 |
+
print("2. Clone your space: git clone https://huggingface.co/spaces/USER/SPACE")
|
| 67 |
+
print("3. Copy all files to the space folder")
|
| 68 |
+
print("4. Push: git add . && git commit -m 'Deploy' && git push")
|
| 69 |
+
print("5. Wait 5-10 minutes for build")
|
| 70 |
+
print("6. Your HTML UI will be live at the root URL!")
|
| 71 |
+
print("\nThe unified_dashboard.html will load automatically when users visit your Space.")
|
utils/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/utils/__pycache__/__init__.cpython-313.pyc and b/utils/__pycache__/__init__.cpython-313.pyc differ
|
|
|
utils/__pycache__/logger.cpython-313.pyc
CHANGED
|
Binary files a/utils/__pycache__/logger.cpython-313.pyc and b/utils/__pycache__/logger.cpython-313.pyc differ
|
|
|