-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis.html
60 lines (59 loc) · 1.81 KB
/
redis.html
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
<!DOCTYPE html>
<html>
<head>
<title>Redis Data</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 15px;
text-align: left;
}
</style>
</head>
<body>
<h1>Redis Timeseries Data</h1>
<table>
<thead>
<tr>
<th>Key</th>
<th>Timestamp</th>
<th>Value</th>
</tr>
</thead>
<tbody id="data-table">
</tbody>
</table>
<script>
async function fetchData() {
try {
const response = await fetch('/get-redis-data');
const data = await response.json();
const tableBody = document.getElementById('data-table');
for (const [key, value] of Object.entries(data)) {
const row = document.createElement('tr');
const keyCell = document.createElement('td');
keyCell.textContent = key;
const timestampCell = document.createElement('td');
timestampCell.textContent = new Date(value.timestamp).toLocaleString();
const valueCell = document.createElement('td');
valueCell.textContent = value.value;
row.appendChild(keyCell);
row.appendChild(timestampCell);
row.appendChild(valueCell);
tableBody.appendChild(row);
}
} catch (error) {
console.error('Error fetching data:', error);
}
}
setInterval(fetchData, 60000); // Fetch data every 10 seconds
fetchData();
</script>
</body>
</html>