Compare commits
2 Commits
dd2a3cf150
...
6fe0841cbc
Author | SHA1 | Date | |
---|---|---|---|
6fe0841cbc | |||
df130b312c |
@ -4,34 +4,37 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Temperature-Alarm-Web</title>
|
<title>Temperature-Alarm-Web</title>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
||||||
<link rel="stylesheet" href="/styles/home.css" />
|
|
||||||
<script defer type="module" src="/scripts/home.js"></script>
|
<script defer type="module" src="/scripts/home.js"></script>
|
||||||
|
<link rel="stylesheet" href="/styles/common.css">
|
||||||
|
<link rel="stylesheet" href="/styles/home.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div class="topnav">
|
||||||
<div class="topnav">
|
<a class="active" href="/home/index.html">Home</a>
|
||||||
<a class="active" href="/home/index.html">Home</a>
|
<div style="display: flex; justify-content: flex-end;">
|
||||||
<div style="display: flex; justify-content: flex-end;">
|
<a class="" href="/home/index.html">Devices</a>
|
||||||
<a class="" href="/home/index.html">Devices</a>
|
<a class="" href="/profile/index.html">Profile</a>
|
||||||
<a class="" href="/profile/index.html">Profile</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="chartContainer">
|
</div>
|
||||||
|
<div id="container">
|
||||||
|
<div class="chart-container">
|
||||||
<canvas id="myChart" style="width: 49%; height: 49%;"></canvas>
|
<canvas id="myChart" style="width: 49%; height: 49%;"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<table>
|
<div id="table-wrapper">
|
||||||
<tr>
|
<table>
|
||||||
<th>Name</th>
|
<tr>
|
||||||
<th>Temperature</th>
|
<th>Temperature</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>TempHigh</th>
|
<th>Time</th>
|
||||||
<th>TempLow</th>
|
<th>Limits</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody id="TemperatureTable"></tbody>
|
<tbody id="TemperatureTable"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="error" class="error"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Login - Temperature alarm</title>
|
<title>Login - Temperature alarm</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="/styles/common.css">
|
||||||
<link rel="stylesheet" href="/styles/auth.css">
|
<link rel="stylesheet" href="/styles/auth.css">
|
||||||
<script defer type="module" src="/scripts/login.js"></script>
|
<script defer type="module" src="/scripts/login.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@ -28,7 +29,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="form-error"></div>
|
<div id="form-error" class="error"></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Register - Temperature Alarm</title>
|
<title>Register - Temperature Alarm</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="/styles/common.css">
|
||||||
<link rel="stylesheet" href="/styles/auth.css">
|
<link rel="stylesheet" href="/styles/auth.css">
|
||||||
<script defer type="module" src="/scripts/register.js"></script>
|
<script defer type="module" src="/scripts/register.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@ -33,7 +34,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="form-error"></div>
|
<div id="form-error" class="error"></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { getLogsOnDeviceId } from "./services/devices.service.js";
|
import { getLogsOnDeviceId } from "./services/devices.service.js";
|
||||||
|
|
||||||
async function buildChart() {
|
async function buildChart(data) {
|
||||||
// TODO change device id
|
data.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||||
const data = await getLogsOnDeviceId(1);
|
|
||||||
|
|
||||||
const xValues = data.map((log) =>
|
const xValues = data.map((log) =>
|
||||||
new Date(log.date).toLocaleString()
|
new Date(log.date).toLocaleString()
|
||||||
@ -15,6 +14,7 @@ async function buildChart() {
|
|||||||
labels: xValues,
|
labels: xValues,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
|
label: "Temperature",
|
||||||
fill: false,
|
fill: false,
|
||||||
lineTension: 0.4,
|
lineTension: 0.4,
|
||||||
backgroundColor: "rgba(0,0,255,1.0)",
|
backgroundColor: "rgba(0,0,255,1.0)",
|
||||||
@ -43,29 +43,41 @@ function buildTable(data) {
|
|||||||
data.forEach((log) => {
|
data.forEach((log) => {
|
||||||
var averageTemp = (log.tempHigh + log.tempLow) / 2.0;
|
var averageTemp = (log.tempHigh + log.tempLow) / 2.0;
|
||||||
var color;
|
var color;
|
||||||
if (log.temperature > log.tempHigh) {
|
if (log.temperature >= log.tempHigh) {
|
||||||
color = "tempHigh";
|
color = "tempHigh";
|
||||||
} else if (
|
} else if (
|
||||||
log.temperature < log.tempHigh &&
|
log.temperature < log.tempHigh &&
|
||||||
log.temperature > averageTemp
|
log.temperature > averageTemp
|
||||||
) {
|
) {
|
||||||
color = "tempMidHigh";
|
color = "tempMidHigh";
|
||||||
} else if (log.temperature < log.tempLow) {
|
} else if (log.temperature <= log.tempLow) {
|
||||||
color = "tempLow";
|
color = "tempLow";
|
||||||
} else if (log.temperature > log.tempLow && log.temperature < averageTemp) {
|
} else if (log.temperature > log.tempLow && log.temperature < averageTemp) {
|
||||||
color = "tempMidLow";
|
color = "tempMidLow";
|
||||||
} else {
|
} else {
|
||||||
color = "tempNormal";
|
color = "tempNormal";
|
||||||
}
|
}
|
||||||
var row = ` <tr>
|
|
||||||
<td>Name</td>
|
const date = new Date(log.date).toLocaleDateString();
|
||||||
<td class="${color}">${log.temperature}</td>
|
const time = new Date(log.date).toLocaleTimeString();
|
||||||
<td>${log.date}</td>
|
|
||||||
<td class="tempHigh">${log.tempHigh}</td>
|
table.innerHTML += `
|
||||||
<td class="tempLow">${log.tempLow}</td>
|
<tr>
|
||||||
</tr>`;
|
<td class="temperature ${color}">${log.temperature}°C</td>
|
||||||
table.innerHTML += row;
|
<td>${date}</td>
|
||||||
|
<td width="50%">${time}</td>
|
||||||
|
<td width="50%">Min: <b class="low-limit">${log.tempLow}°C</b>, Max: <b class="high-limit">${log.tempHigh}°C</b></td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildChart();
|
// TODO change device id
|
||||||
|
getLogsOnDeviceId(1)
|
||||||
|
.then(buildChart)
|
||||||
|
.catch(err => {
|
||||||
|
document.getElementById("error").innerText = err;
|
||||||
|
document.getElementById("error").style.display = "block";
|
||||||
|
document.getElementById("container").style.display = "none";
|
||||||
|
});
|
||||||
|
|
||||||
|
@ -39,16 +39,6 @@ button:hover {
|
|||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#form-error {
|
|
||||||
display: none;
|
|
||||||
background-color: #FFCDD2;
|
|
||||||
color: #C62828;
|
|
||||||
border: 1px solid #C62828;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 1rem 2rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
button{
|
button{
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
.error {
|
.error {
|
||||||
background-color: #EF9A9A;
|
display: none;
|
||||||
|
background-color: #FFCDD2;
|
||||||
|
color: #C62828;
|
||||||
|
border: 1px solid #C62828;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1rem 2rem;
|
||||||
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,79 +1,110 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
background-color: #F9F9F9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#container {
|
#container {
|
||||||
background-color: white;
|
margin: 0 2rem;
|
||||||
opacity: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnav {
|
.topnav {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnav a {
|
.topnav a {
|
||||||
float: left;
|
float: left;
|
||||||
color: #f2f2f2;
|
color: #f2f2f2;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 14px 16px;
|
padding: 14px 16px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnav a:hover {
|
.topnav a:hover {
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnav a.active {
|
.topnav a.active {
|
||||||
background-color: #04aa6d;
|
background-color: #04aa6d;
|
||||||
color: white;
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#table-wrapper {
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
border: 1px solid #DDD;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
font-family: arial, sans-serif;
|
font-family: arial, sans-serif;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
background-color: white;
|
||||||
|
color: #616161;
|
||||||
}
|
}
|
||||||
|
|
||||||
td,
|
td,
|
||||||
th {
|
th {
|
||||||
border: 1px solid #dddddd;
|
border-right: 1px solid #DDD;
|
||||||
text-align: left;
|
border-bottom: 1px solid #DDD;
|
||||||
padding: 8px;
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
border-bottom: 2px solid #DDD;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:nth-child(even) {
|
tr:nth-child(even) {
|
||||||
background-color: #dddddd;
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
table .temperature {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
table tr:not(:last-child) .temperature {
|
||||||
|
border-bottom-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempHigh {
|
.tempHigh {
|
||||||
color: #ff0000;
|
background-color: #ff0000;
|
||||||
width: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempMidHigh {
|
.tempMidHigh {
|
||||||
color: #fffb00;
|
background-color: #FFA000;
|
||||||
width: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempNormal {
|
.tempNormal {
|
||||||
color: #02ed26;
|
background-color: #AAA;
|
||||||
width: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempMidLow {
|
.tempMidLow {
|
||||||
color: #16fae7;
|
background-color: #64B5F6;
|
||||||
width: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempLow {
|
.tempLow {
|
||||||
color: #0004ff;
|
background-color: #3F51B5;
|
||||||
width: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.chartContainer{
|
.low-limit {
|
||||||
margin: 20px;
|
color: #3F51B5;
|
||||||
}
|
}
|
||||||
|
.high-limit {
|
||||||
|
color: #F00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
margin: 2rem 0;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #DDD;
|
||||||
|
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#error {
|
||||||
|
margin: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user