From af2e2591b9e1c43d1fe72c838d353ecfdd6ef52e Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 12 Apr 2018 18:48:48 +0200 Subject: [PATCH] statistics.html: Show "models per client" pie chart Signed-off-by: Adrian Schmutzler --- ffmap/stattools.py | 12 ++++++------ ffmap/web/static/js/graph.js | 6 +++--- ffmap/web/templates/statistics.html | 9 ++++++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ffmap/stattools.py b/ffmap/stattools.py index 7065e26..10cc213 100644 --- a/ffmap/stattools.py +++ b/ffmap/stattools.py @@ -88,28 +88,28 @@ def router_status_gw(mysql): def router_models(mysql,selecthood=None,selectgw=None): if selecthood: return mysql.fetchdict(""" - SELECT hardware, COUNT(id) AS count + SELECT hardware, COUNT(id) AS count, SUM(clients) AS clients FROM router WHERE hood = %s GROUP BY hardware ORDER BY hardware - """,(selecthood,),"hardware","count") + """,(selecthood,),"hardware") elif selectgw: return mysql.fetchdict(""" - SELECT hardware, COUNT(router_gw.router) AS count + SELECT hardware, COUNT(router_gw.router) AS count, SUM(clients) AS clients FROM router INNER JOIN router_gw ON router.id = router_gw.router WHERE mac = %s GROUP BY hardware ORDER BY hardware - """,(selectgw,),"hardware","count") + """,(selectgw,),"hardware") else: return mysql.fetchdict(""" - SELECT hardware, COUNT(id) AS count + SELECT hardware, COUNT(id) AS count, SUM(clients) AS clients FROM router GROUP BY hardware ORDER BY hardware - """,(),"hardware","count") + """,(),"hardware") def router_firmwares(mysql,selecthood=None,selectgw=None): if selecthood: diff --git a/ffmap/web/static/js/graph.js b/ffmap/web/static/js/graph.js index faaa8e3..912f968 100644 --- a/ffmap/web/static/js/graph.js +++ b/ffmap/web/static/js/graph.js @@ -479,13 +479,13 @@ function global_router_firmwares_graph() { }); } -function global_router_models_graph() { - var placeholder = $("#globroutermodelsstat"); +function global_router_models_graph(id,field) { + var placeholder = $("#"+id); var pdata = []; for (var mdname in router_models) { pdata.push({ "label": mdname, - "data": [router_models[mdname]] + "data": [router_models[mdname][field]] }); } var plot = $.plot(placeholder, pdata, { diff --git a/ffmap/web/templates/statistics.html b/ffmap/web/templates/statistics.html index 978192c..be76ac5 100644 --- a/ffmap/web/templates/statistics.html +++ b/ffmap/web/templates/statistics.html @@ -208,6 +208,12 @@
+
+
Router Models per Client{%- if selecthood %} @ {{ selecthood }}{%- endif -%}{%- if selectgw %} @ {{ selectgw }}{%- endif -%}
+
+
+
+