From a5b06d62c63cf75e0a5e5c3abd372464bb584617 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 17 Jan 2018 00:52:52 +0100 Subject: [PATCH] statistics.html: Make hood and GW tables sortable This causes some adjustments in the underlying select queries. Signed-off-by: Adrian Schmutzler --- ffmap/stattools.py | 6 +-- ffmap/web/templates/statistics.html | 73 ++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/ffmap/stattools.py b/ffmap/stattools.py index 0334d37..fbbbc1f 100644 --- a/ffmap/stattools.py +++ b/ffmap/stattools.py @@ -190,7 +190,7 @@ def gws(mysql,selecthood=None): tup = () macs = mysql.fetchall(""" - SELECT router_gw.mac + SELECT router_gw.mac, CONCAT(ISNULL(gw.name),'-',IF(NOT ISNULL(gw.name),CONCAT(gw.name,'-',gw_netif.netif),router_gw.mac)) AS sort FROM router INNER JOIN router_gw ON router.id = router_gw.router LEFT JOIN (gw_netif INNER JOIN gw ON gw_netif.gw = gw.id) @@ -198,7 +198,7 @@ def gws(mysql,selecthood=None): {} GROUP BY router_gw.mac ORDER BY ISNULL(gw.name), gw.name ASC, gw_netif.netif ASC, router_gw.mac ASC - """.format(wherewhere),tup,"mac") + """.format(wherewhere),tup) selected = mysql.fetchall(""" SELECT router_gw.mac, router.status, COUNT(router_gw.router) AS count FROM router @@ -216,7 +216,7 @@ def gws(mysql,selecthood=None): result = OrderedDict() for m in macs: - result[m] = {"selected":{},"others":{}} + result[m["mac"]] = {"selected":{},"others":{},"sort":m["sort"]} for rs in selected: result[rs["mac"]]["selected"][rs["status"]] = rs["count"] for rs in others: diff --git a/ffmap/web/templates/statistics.html b/ffmap/web/templates/statistics.html index 6a516aa..4f7778e 100644 --- a/ffmap/web/templates/statistics.html +++ b/ffmap/web/templates/statistics.html @@ -12,6 +12,9 @@ + + +