108 lines
2.8 KiB
HTML
108 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
|
<title>Sensor Data Dashboard</title>
|
|
<!-- <link rel="stylesheet" href="/css"> -->
|
|
<style>body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.container {
|
|
max-width: 800px;
|
|
margin: 20px auto;
|
|
padding: 20px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 5px;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
th, td {
|
|
padding: 8px;
|
|
text-align: left;
|
|
border-bottom: 1px solid #ddd;
|
|
}
|
|
tr:hover {
|
|
background-color: #f2f2f2;
|
|
}
|
|
.btn-container {
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
.btn {
|
|
padding: 10px 20px;
|
|
font-size: 16px;
|
|
text-decoration: none;
|
|
color: #fff;
|
|
background-color: #007bff;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
.btn:hover {
|
|
background-color: #0056b3;
|
|
}</style>
|
|
</head>
|
|
<body>
|
|
<div class="btn-container">
|
|
<a href="/" class="btn">Dashboard</a>
|
|
<a href="/history" class="btn">View History</a>
|
|
<a href="/adm" class="btn">Admin</a>
|
|
</div>
|
|
<div class="container">
|
|
<h1>Sensor Data Dashboard</h1>
|
|
<table>
|
|
<tr>
|
|
<th>Id</th>
|
|
<th>Sensor</th>
|
|
<th>Timestamp</th>
|
|
<th>Temp</th>
|
|
<th>HR</th>
|
|
<th>Bat</th>
|
|
</tr>
|
|
{% for row in data %}
|
|
<tr>
|
|
<td>{{ row[0] }}</td>
|
|
<td>{{ row[1] }}</td>
|
|
<td>{{ row[2] }}</td>
|
|
<td>{{ row[3] }}°C</td>
|
|
<td>{{ row[4] }}%</td>
|
|
<td>{{ row[5] }}%</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
<h1>Current Weather</h1>
|
|
{% if temperature %}
|
|
<p>The current temperature is {{ temperature }}°C</p>
|
|
{% else %}
|
|
<p>Unable to fetch weather data.</p>
|
|
{% endif %}
|
|
</div>
|
|
<h1>History in graphs</h1>
|
|
<div id="graph_temp"></div>
|
|
<div id="graph_hr"></div>
|
|
<script>
|
|
// Parse JSON data
|
|
var temp_graphData = {{ temp_graph_json | safe }};
|
|
var HR_graphData = {{ HR_graph_json | safe }};
|
|
// Render graph
|
|
Plotly.newPlot('graph_temp', temp_graphData.data, temp_graphData.layout);
|
|
Plotly.newPlot('graph_hr', HR_graphData.data, HR_graphData.layout);
|
|
</script>
|
|
<script>
|
|
// Refresh the page every 10 seconds
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 20000);
|
|
</script>
|
|
</body>
|
|
</html>
|