Add error handling on dashboard
This commit is contained in:
parent
df130b312c
commit
6fe0841cbc
@ -4,9 +4,10 @@
|
|||||||
<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>
|
||||||
@ -33,6 +34,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</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,6 @@
|
|||||||
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
|
|
||||||
const data = await getLogsOnDeviceId(1);
|
|
||||||
data.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
data.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||||
|
|
||||||
const xValues = data.map((log) =>
|
const xValues = data.map((log) =>
|
||||||
@ -74,4 +72,12 @@ function buildTable(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,3 +104,7 @@ table tr:not(:last-child) .temperature {
|
|||||||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
|
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#error {
|
||||||
|
margin: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user