live updating admin graph

This commit is contained in:
2020-06-08 16:17:25 +02:00
parent 522ac9d345
commit 4a7a60f5d2
2 changed files with 19 additions and 11 deletions

View File

@@ -83,10 +83,16 @@ var graph = new Chart(
}
);
function setData(days, interval){
let graphTimeout = null;
function loadGraph(minutes, interval, live){
if (graphTimeout !== null) { clearTimeout(graphTimeout) }
if (live) {
graphTimeout = setTimeout(() => {loadGraph(60, 1, true)}, 3000)
}
let today = new Date()
let start = new Date()
start.setDate(start.getDate()-days)
start.setMinutes(start.getMinutes()-minutes)
fetch(
apiEndpoint+"/admin/files/timeseries" +
@@ -107,7 +113,8 @@ function setData(days, interval){
alert("Error requesting time series: "+e);
})
}
setData(7, 60);
loadGraph(60, 1, true);
// Load performance statistics