nbroad HF staff commited on
Commit
31ff22c
1 Parent(s): 895cb32

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +80 -1
static/index.html CHANGED
@@ -1 +1,80 @@
1
- a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>API Monitoring Dashboard</title>
7
+ <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
8
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
9
+ <style>
10
+ body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }
11
+ h1 { text-align: center; }
12
+ #charts { display: flex; flex-wrap: wrap; justify-content: space-around; }
13
+ .chart { width: 100%; max-width: 600px; margin-bottom: 20px; }
14
+ #logs { margin-top: 40px; }
15
+ table { width: 100%; border-collapse: collapse; }
16
+ th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
17
+ th { background-color: #f2f2f2; }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <h1>API Monitoring Dashboard</h1>
22
+ <div id="charts"></div>
23
+ <div id="logs">
24
+ <h2>Logs</h2>
25
+ <table id="logTable">
26
+ <thead>
27
+ <tr>
28
+ <th>Timestamp</th>
29
+ <th>URL</th>
30
+ <th>Status</th>
31
+ </tr>
32
+ </thead>
33
+ <tbody></tbody>
34
+ </table>
35
+ </div>
36
+
37
+ <script>
38
+ function updateCharts() {
39
+ $.getJSON('/api/chart-data', function(data) {
40
+ $('#charts').empty();
41
+ for (let model in data) {
42
+ let div = $('<div>').addClass('chart').appendTo('#charts');
43
+ let trace = {
44
+ x: data[model].x,
45
+ y: data[model].y,
46
+ type: 'scatter',
47
+ mode: 'lines+markers',
48
+ name: model
49
+ };
50
+ let layout = {
51
+ title: 'API Status: ' + model,
52
+ xaxis: { title: 'Timestamp' },
53
+ yaxis: { title: 'Status', range: [-0.1, 1.1] }
54
+ };
55
+ Plotly.newPlot(div[0], [trace], layout);
56
+ }
57
+ });
58
+ }
59
+ function updateLogs() {
60
+ $.getJSON('/api/logs', function(data) {
61
+ let tbody = $('#logTable tbody');
62
+ tbody.empty();
63
+ data.forEach(function(log) {
64
+ let row = $('<tr>');
65
+ $('<td>').text(log.timestamp).appendTo(row);
66
+ $('<td>').text(log.model).appendTo(row);
67
+ $('<td>').text(log.success ? 'Success' : 'Failure').appendTo(row);
68
+ tbody.append(row);
69
+ });
70
+ });
71
+ }
72
+ $(document).ready(function() {
73
+ updateCharts();
74
+ updateLogs();
75
+ setInterval(updateCharts, 60000); // Update every minute
76
+ setInterval(updateLogs, 60000); // Update every minute
77
+ });
78
+ </script>
79
+ </body>
80
+ </html>