From 384bbf62d8e147d72323e324263f73955e8af477 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Thu, 21 May 2020 21:42:50 +0200 Subject: [PATCH] update admin chart --- res/template/admin.html | 35 +++++++++++++++++++++-------------- res/template/file_viewer.html | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/res/template/admin.html b/res/template/admin.html index 319adbc..d9a3890 100644 --- a/res/template/admin.html +++ b/res/template/admin.html @@ -12,16 +12,16 @@ {{if $isAdmin.IsAdmin}}

Bandwidth and views

- - - - - - - - + + + + + + + +
-
+
@@ -40,8 +40,6 @@ Chart.defaults.global.tooltips.axis = "x"; Chart.defaults.global.tooltips.intersect = false; - var days = 7; - var interval = 60; var graph = new Chart( document.getElementById('bandwidth_chart'), { @@ -116,8 +114,17 @@ } ); - function setData(){ - fetch(apiEndpoint+"/admin/files/timeseries?days="+days+"&interval="+interval).then(resp => { + function setData(days, interval){ + let today = new Date() + let start = new Date() + start.setDate(start.getDate()-days) + + fetch( + apiEndpoint+"/admin/files/timeseries" + + "?start="+start.toISOString() + + "&end="+today.toISOString() + + "&interval="+interval + ).then(resp => { if (!resp.ok) { return Promise.reject("Error: "+resp.status);} return resp.json(); }).then(resp => { @@ -132,7 +139,7 @@ }) } - setData(); + setData(7, 60);
diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index 85a7d70..bf6f6b8 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -111,7 +111,7 @@

Downloads and views

-
+