Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +82 -0
index.html
CHANGED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 url in data) {
|
42 |
+
let div = $('<div>').addClass('chart').appendTo('#charts');
|
43 |
+
let trace = {
|
44 |
+
x: data[url].x,
|
45 |
+
y: data[url].y,
|
46 |
+
type: 'scatter',
|
47 |
+
mode: 'lines+markers',
|
48 |
+
name: url
|
49 |
+
};
|
50 |
+
let layout = {
|
51 |
+
title: 'API Status: ' + url,
|
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 |
+
|
60 |
+
function updateLogs() {
|
61 |
+
$.getJSON('/api/logs', function(data) {
|
62 |
+
let tbody = $('#logTable tbody');
|
63 |
+
tbody.empty();
|
64 |
+
data.forEach(function(log) {
|
65 |
+
let row = $('<tr>');
|
66 |
+
$('<td>').text(log.timestamp).appendTo(row);
|
67 |
+
$('<td>').text(log.url).appendTo(row);
|
68 |
+
$('<td>').text(log.success ? 'Success' : 'Failure').appendTo(row);
|
69 |
+
tbody.append(row);
|
70 |
+
});
|
71 |
+
});
|
72 |
+
}
|
73 |
+
|
74 |
+
$(document).ready(function() {
|
75 |
+
updateCharts();
|
76 |
+
updateLogs();
|
77 |
+
setInterval(updateCharts, 60000); // Update every minute
|
78 |
+
setInterval(updateLogs, 60000); // Update every minute
|
79 |
+
});
|
80 |
+
</script>
|
81 |
+
</body>
|
82 |
+
</html>
|