File size: 12,988 Bytes
b068b76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Crypto Monitor - Feature Flags Demo</title>
    <link rel="stylesheet" href="/static/css/mobile-responsive.css">
    <style>

        * {

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }



        body {

            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

            background: #f5f7fa;

            padding: 20px;

        }



        .header {

            background: #fff;

            padding: 20px;

            border-radius: 8px;

            margin-bottom: 20px;

            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

        }



        h1 {

            color: #333;

            margin-bottom: 10px;

        }



        .subtitle {

            color: #666;

            font-size: 0.95rem;

        }



        .dashboard {

            display: grid;

            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

            gap: 20px;

        }



        .card {

            background: #fff;

            border-radius: 8px;

            padding: 20px;

            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

        }



        .card h3 {

            margin-bottom: 15px;

            color: #333;

        }



        .stats-grid {

            display: grid;

            grid-template-columns: repeat(2, 1fr);

            gap: 15px;

            margin-top: 15px;

        }



        .stat-item {

            padding: 15px;

            background: #f8f9fa;

            border-radius: 6px;

            text-align: center;

        }



        .stat-label {

            font-size: 0.85rem;

            color: #666;

            margin-bottom: 8px;

        }



        .stat-value {

            font-size: 1.8rem;

            font-weight: 700;

            color: #333;

        }



        .btn {

            padding: 10px 20px;

            background: #007bff;

            color: #fff;

            border: none;

            border-radius: 4px;

            cursor: pointer;

            font-size: 0.95rem;

            transition: background 0.2s;

        }



        .btn:hover {

            background: #0056b3;

        }



        .btn-secondary {

            background: #6c757d;

        }



        .btn-secondary:hover {

            background: #5a6268;

        }



        .provider-list {

            display: flex;

            flex-direction: column;

            gap: 10px;

            margin-top: 15px;

        }



        .provider-item {

            padding: 12px;

            background: #f8f9fa;

            border-radius: 6px;

            display: flex;

            justify-content: space-between;

            align-items: center;

            border-left: 4px solid #ccc;

        }



        .provider-item.online {

            border-left-color: #28a745;

        }



        .provider-item.degraded {

            border-left-color: #ffc107;

        }



        .provider-item.offline {

            border-left-color: #dc3545;

        }



        .provider-info {

            flex: 1;

        }



        .provider-name {

            font-weight: 600;

            color: #333;

            margin-bottom: 4px;

        }



        .provider-meta {

            font-size: 0.85rem;

            color: #666;

        }



        .proxy-indicator {

            display: inline-flex;

            align-items: center;

            gap: 4px;

            padding: 4px 8px;

            background: #fff3cd;

            color: #856404;

            border-radius: 4px;

            font-size: 0.75rem;

            margin-left: 8px;

        }



        .footer {

            margin-top: 30px;

            text-align: center;

            color: #666;

            font-size: 0.85rem;

        }



        @media screen and (max-width: 768px) {

            .dashboard {

                grid-template-columns: 1fr;

            }



            .stats-grid {

                grid-template-columns: 1fr;

            }

        }

    </style>
</head>
<body>
    <div class="header">
        <h1>πŸš€ Crypto Monitor - Feature Flags Demo</h1>
        <p class="subtitle">Enterprise-Grade API Monitoring with Smart Proxy Mode</p>
    </div>

    <div class="dashboard">
        <!-- Feature Flags Card -->
        <div class="card">
            <div id="feature-flags-container"></div>
        </div>

        <!-- System Status Card -->
        <div class="card">
            <h3>πŸ“Š System Status</h3>
            <div class="stats-grid">
                <div class="stat-item">
                    <div class="stat-label">Total Providers</div>
                    <div class="stat-value" id="stat-total">-</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">Online</div>
                    <div class="stat-value" id="stat-online" style="color: #28a745;">-</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">Using Proxy</div>
                    <div class="stat-value" id="stat-proxy" style="color: #ffc107;">-</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">Avg Response</div>
                    <div class="stat-value" id="stat-response">-</div>
                </div>
            </div>
        </div>

        <!-- Provider Health Card -->
        <div class="card" style="grid-column: span 2;">
            <h3>πŸ”§ Provider Health Status</h3>
            <div class="provider-list" id="provider-list">
                <p style="color: #666;">Loading providers...</p>
            </div>
        </div>

        <!-- Proxy Status Card -->
        <div class="card">
            <h3>🌐 Smart Proxy Status</h3>
            <div id="proxy-status">
                <p style="color: #666;">Loading proxy status...</p>
            </div>
        </div>
    </div>

    <div class="footer">
        <p>Crypto Monitor ULTIMATE - Enterprise Edition &copy; 2025</p>
        <p>Powered by Real APIs β€’ Smart Proxy Mode β€’ Feature Flags</p>
    </div>

    <!-- Mobile Navigation (shows on mobile only) -->
    <div class="mobile-nav-bottom">
        <div class="nav-items">
            <div class="nav-item">
                <a href="#" class="nav-link active">
                    <span class="nav-icon">πŸ“Š</span>
                    <span>Dashboard</span>
                </a>
            </div>
            <div class="nav-item">
                <a href="#" class="nav-link">
                    <span class="nav-icon">πŸ”§</span>
                    <span>Providers</span>
                </a>
            </div>
            <div class="nav-item">
                <a href="#" class="nav-link">
                    <span class="nav-icon">βš™οΈ</span>
                    <span>Settings</span>
                </a>
            </div>
        </div>
    </div>

    <script src="/static/js/feature-flags.js"></script>
    <script>

        // Initialize Feature Flags UI

        document.addEventListener('DOMContentLoaded', async () => {

            await window.featureFlagsManager.init();

            window.featureFlagsManager.renderUI('feature-flags-container');



            // Load system status

            loadSystemStatus();



            // Load provider health

            loadProviderHealth();



            // Load proxy status

            loadProxyStatus();



            // Auto-refresh every 30 seconds

            setInterval(() => {

                loadSystemStatus();

                loadProviderHealth();

                loadProxyStatus();

            }, 30000);

        });



        async function loadSystemStatus() {

            try {

                const response = await fetch('/api/status');

                const data = await response.json();



                document.getElementById('stat-total').textContent = data.total_providers || 0;

                document.getElementById('stat-online').textContent = data.online || 0;

                document.getElementById('stat-response').textContent =

                    data.avg_response_time_ms ? `${Math.round(data.avg_response_time_ms)}ms` : '-';



                // Get proxy status

                const proxyResp = await fetch('/api/proxy-status');

                const proxyData = await proxyResp.json();

                document.getElementById('stat-proxy').textContent =

                    proxyData.total_providers_using_proxy || 0;

            } catch (error) {

                console.error('Error loading system status:', error);

            }

        }



        async function loadProviderHealth() {

            try {

                const response = await fetch('/api/providers');

                const providers = await response.json();



                if (!Array.isArray(providers)) {

                    return;

                }



                const listEl = document.getElementById('provider-list');

                let html = '';



                providers.slice(0, 10).forEach(provider => {

                    const status = provider.status || 'unknown';

                    const statusClass = status.toLowerCase();



                    html += `

                        <div class="provider-item ${statusClass}">

                            <div class="provider-info">

                                <div class="provider-name">${provider.name}</div>

                                <div class="provider-meta">

                                    ${provider.category || 'unknown'} β€’

                                    ${provider.response_time_ms ? provider.response_time_ms + 'ms' : 'N/A'}

                                </div>

                            </div>

                            <div>

                                <span class="provider-status-badge ${statusClass}">

                                    ${status === 'online' ? 'βœ“' : status === 'degraded' ? '⚠' : 'βœ—'}

                                    ${status.toUpperCase()}

                                </span>

                            </div>

                        </div>

                    `;

                });



                listEl.innerHTML = html || '<p style="color: #666;">No providers found</p>';

            } catch (error) {

                console.error('Error loading provider health:', error);

            }

        }



        async function loadProxyStatus() {

            try {

                const response = await fetch('/api/proxy-status');

                const data = await response.json();



                const statusEl = document.getElementById('proxy-status');



                let html = `

                    <div style="margin-bottom: 15px;">

                        <strong>Auto Mode:</strong>

                        <span style="color: ${data.proxy_auto_mode_enabled ? '#28a745' : '#dc3545'}">

                            ${data.proxy_auto_mode_enabled ? 'βœ“ Enabled' : 'βœ— Disabled'}

                        </span>

                    </div>

                    <div style="margin-bottom: 15px;">

                        <strong>Providers Using Proxy:</strong> ${data.total_providers_using_proxy}

                    </div>

                `;



                if (data.providers && data.providers.length > 0) {

                    html += '<div style="margin-top: 15px;"><strong>Currently Proxied:</strong></div>';

                    html += '<div class="provider-list">';

                    data.providers.forEach(p => {

                        html += `

                            <div class="provider-item">

                                <div class="provider-info">

                                    <div class="provider-name">${p.provider}</div>

                                    <div class="provider-meta">

                                        ${p.reason} β€’ Cached ${p.cache_age_seconds}s ago

                                    </div>

                                </div>

                                <div class="proxy-indicator">🌐 PROXY</div>

                            </div>

                        `;

                    });

                    html += '</div>';

                } else {

                    html += '<p style="color: #666; margin-top: 15px;">No providers currently using proxy</p>';

                }



                statusEl.innerHTML = html;

            } catch (error) {

                console.error('Error loading proxy status:', error);

            }

        }

    </script>
</body>
</html>