summaryrefslogtreecommitdiff
path: root/src/main/resources/templates
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-07-25 20:55:32 +0200
committerPaul-Christian Volkmer2023-07-25 21:20:50 +0200
commit1a2d4ea7a20cddd61a89f11ed3d450a0381df6ab (patch)
tree92b240c66138513ea27962cea2214d0c98e8c613 /src/main/resources/templates
parent94846deb98ccb892a39795a9e8626f7303efd395 (diff)
(Near) realtime update of statistics charts
Diffstat (limited to 'src/main/resources/templates')
-rw-r--r--src/main/resources/templates/statistics.html14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/resources/templates/statistics.html b/src/main/resources/templates/statistics.html
index 3f2a11b..007303e 100644
--- a/src/main/resources/templates/statistics.html
+++ b/src/main/resources/templates/statistics.html
@@ -17,8 +17,18 @@
<script th:src="@{/echarts.min.js}"></script>
<script th:src="@{/scripts.js}"></script>
<script>
- drawPieChart('statistics/requeststates', 'piechart', 'Statusverteilung der Anfragen');
- drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen des letzten Monats');
+ window.onload = () => {
+ drawPieChart('statistics/requeststates', 'piechart', 'Statusverteilung aller Anfragen');
+ drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen der letzten 30 Tage');
+
+ const eventSource = new EventSource('statistics/events');
+ eventSource.addEventListener('requeststates', event => {
+ drawPieChart('statistics/requeststates', 'piechart', 'Statusverteilung aller Anfragen', JSON.parse(event.data));
+ });
+ eventSource.addEventListener('requestslastmonth', event => {
+ drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen des letzten Monats', JSON.parse(event.data));
+ });
+ }
</script>
</body>
</html> \ No newline at end of file