router.html: Add permalink

This is fixed to the br-mesh address. If a router has no br-mesh,
no perma-link is displayed.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-12-09 00:01:28 +01:00
parent f56d70ea55
commit ce4193556a
2 changed files with 10 additions and 2 deletions

View File

@ -83,6 +83,7 @@ def router_info(dbid):
try:
mysql = FreifunkMySQL()
router = mysql.findone("""SELECT * FROM router WHERE id = %s LIMIT 1""",(dbid,))
mac = None
if router:
if request.args.get('fffconfig', None) != None:
@ -102,6 +103,8 @@ def router_info(dbid):
router["netifs"] = mysql.fetchall("""SELECT * FROM router_netif WHERE router = %s""",(dbid,))
for n in router["netifs"]:
n["ipv6_addrs"] = mysql.fetchall("""SELECT ipv6 FROM router_ipv6 WHERE router = %s AND netif = %s""",(dbid,n["netif"],),"ipv6")
if n["netif"]=="br-mesh":
mac = n["mac"]
router["neighbours"] = mysql.fetchall("""
SELECT nb.mac, nb.quality, nb.net_if, r.hostname, r.id
@ -160,7 +163,7 @@ def router_info(dbid):
#FIXME: Only as admin
return Response(bson2json(router, sort_keys=True, indent=4), mimetype='application/json')
else:
return render_template("router.html", router=router, tileurls=tileurls, netifstats=netiffetch, neighstats=neighfetch)
return render_template("router.html", router=router, mac=mac, tileurls=tileurls, netifstats=netiffetch, neighstats=neighfetch)
except Exception as e:
writelog(CONFIG["debug_dir"] + "/fail_router.txt", str(e))

View File

@ -38,7 +38,12 @@
{% block content %}
<div class="row" style="margin-top: 5px; margin-bottom: 5px;">
<div class="col-xs-12 col-sm-10"><h2 style="margin-top: 10px;">Router: {{ router.hostname }}</h2></div>
<div class="col-xs-12 col-sm-10">
<h2 style="margin-top: 10px;">Router: {{ router.hostname }}</h2>
{%- if mac %}
<h4 style="margin-top: 10px;margin-bottom: 20px">Perma-Link: <a href="{{ url_for('router_mac',mac=mac) }}">https://monitoring.freifunk-franken.de{{ url_for('router_mac',mac=mac) }}</a></h4>
{%- endif %}
</div>
<div class="col-xs-12 col-sm-2 text-right" style="margin-top: 10px; margin-bottom: 10px;">
<form method="post" id="actform">
<input type="hidden" name="act" id="act" value="" />