-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.html
81 lines (66 loc) · 2.24 KB
/
show.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Show Data | Blood Pressure Logger</title>
</head>
<body>
<div id="app">
<h1>Blood Pressure Logger</h1>
<p>Show previously logged blood pressure entries.</p>
<p>
Navigation:
<ul>
<li><a href="./index.html">Add new data</a></li>
<li><a href="./show.html">Show previously entered data</a> (you are here)</li>
</ul>
</p>
<table border="1">
<thead>
<tr>
<th>Timestamp</th>
<th>Systolic</th>
<th>Diastolic</th>
</tr>
</thead>
<tbody id="table-items">
<tr>
<td>Loading...</td>
<td>Loading...</td>
<td>Loading...</td>
</tr>
</tbody>
</table>
</div>
<script>
((window, document) => {
'use strict';
const INVOKE_URL = '{{INVOKE_URL}}';
const tableItems = document.getElementById('table-items');
document.addEventListener('DOMContentLoaded', loadBloodPressure);
async function loadBloodPressure() {
tableItems.innerHTML = 'Loading...';
let response = await fetch(INVOKE_URL);
if (! response.ok) {
tableItems.innerHTML = 'There was an error with the request.';
return;
}
tableItems.innerHTML = '';
let items = (await response.json()).Items;
if (items.length == 0) {
tableItems.innerHTML = 'No data found. Try first logging new data.';
}
for (const item of items) {
let row = document.createElement('tr');
row.innerHTML = `
<td>${item.RequestTime}</td>
<td>${item.Systolic}</td>
<td>${item.Diastolic}</td>
`;
tableItems.appendChild(row);
}
}
})(window, document);
</script>
</body>
</html>