Add timely filter
This commit is contained in:
parent
18c80b8f99
commit
e0daec4c67
2 changed files with 22 additions and 3 deletions
|
@ -215,12 +215,20 @@ async function render_graph(plug, name) {
|
|||
old.remove();
|
||||
}
|
||||
|
||||
// get start date
|
||||
let start_text = document.getElementById("start").value;
|
||||
let start_date = parseInt(new Date(start_text).getTime() / 1000).toFixed(0);
|
||||
|
||||
// get end date1
|
||||
let end_text = document.getElementById("end").value;
|
||||
let end_date = parseInt(new Date(end_text).getTime() / 1000).toFixed(0);
|
||||
|
||||
// create new chart div
|
||||
let chart = document.createElement('canvas');
|
||||
chart.id = "chart";
|
||||
|
||||
const response = await fetch(
|
||||
"/plug_data/" + plug,
|
||||
"/plug_data/" + plug + "/" + start_date + "/" + end_date + "/" + "hourly",
|
||||
{
|
||||
method: "GET"
|
||||
}
|
||||
|
@ -270,5 +278,5 @@ async function render_graph(plug, name) {
|
|||
}
|
||||
});
|
||||
|
||||
document.getElementById("main").appendChild(chart);
|
||||
document.getElementById("graph").appendChild(chart);
|
||||
}
|
|
@ -2,10 +2,15 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<title>Smart Homeserver</title>
|
||||
<link href="/css/index.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.2.0/css/fork-awesome.min.css"
|
||||
integrity="sha256-XoaMnoYC5TH6/+ihMEnospgm0J1PM/nioxbOUdnM8HY=" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdn.korzh.com/metroui/v4/css/metro-all.min.css">
|
||||
<link href="/css/index.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -15,6 +20,12 @@
|
|||
src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/js/main.js"></script>
|
||||
<script src="https://cdn.korzh.com/metroui/v4/js/metro.min.js"></script>
|
||||
|
||||
<input id="start" type="text" data-role="calendarpicker">
|
||||
<input id="end" type="text" data-role="calendarpicker">
|
||||
<div id="graph">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue