routertools/router.html: Display warning for lost coordinates

Warning: This requires a change of the MySQL table 'router'

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-11-22 23:22:08 +01:00
parent ebb4589301
commit 8f04e13c24
3 changed files with 11 additions and 3 deletions

View File

@ -42,6 +42,7 @@ mysql.execute("""
`contact` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`lng` double DEFAULT NULL,
`lat` double DEFAULT NULL,
`reset` tinyint(1) NOT NULL DEFAULT '0',
`neighbors` smallint(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
""")

View File

@ -40,10 +40,11 @@ def import_nodewatcher_xml(mysql, mac, xml):
keepvalues = ['lat','lng','description','position_comment','contact']
router_id = None
olddata = []
olddata = False
uptime = 0
events = []
status_comment = ""
reset = False
try:
findrouter = mysql.findone("SELECT router FROM router_netif WHERE mac = %s LIMIT 1",(mac.lower(),))
@ -81,6 +82,9 @@ def import_nodewatcher_xml(mysql, mac, xml):
""",(lat,lng,lat,),"name")
if not router_update["hood"]:
router_update["hood"] = "Default"
if not router_update['lat'] and not router_update['lng'] and olddata and olddata['lat'] and olddata['lng']:
# Enable reset state; do before variable fallback
reset = True
if olddata:
# Has to be done after hood detection, so default hood is selected if no lat/lng
@ -97,13 +101,13 @@ def import_nodewatcher_xml(mysql, mac, xml):
SET status = %s, hostname = %s, last_contact = %s, sys_time = %s, sys_uptime = %s, sys_memfree = %s, sys_membuff = %s, sys_memcache = %s,
sys_loadavg = %s, sys_procrun = %s, sys_proctot = %s, clients = %s, wan_uplink = %s, cpu = %s, chipset = %s, hardware = %s, os = %s,
batman = %s, kernel = %s, nodewatcher = %s, firmware = %s, firmware_rev = %s, description = %s, position_comment = %s, community = %s, hood = %s,
status_text = %s, contact = %s, lng = %s, lat = %s, neighbors = %s
status_text = %s, contact = %s, lng = %s, lat = %s, neighbors = %s, reset = %s
WHERE id = %s
""",(
ru["status"],ru["hostname"],ru["last_contact"],ru["sys_time"],ru["sys_uptime"],ru["memory"]["free"],ru["memory"]["buffering"],ru["memory"]["caching"],
ru["sys_loadavg"],ru["processes"]["runnable"],ru["processes"]["total"],ru["clients"],ru["has_wan_uplink"],ru["cpu"],ru["chipset"],ru["hardware"],ru["os"],
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],
ru["status_text"],ru["contact"],ru["lng"],ru["lat"],ru["visible_neighbours"],router_id,))
ru["status_text"],ru["contact"],ru["lng"],ru["lat"],ru["visible_neighbours"],reset,router_id,))
mysql.execute("DELETE FROM router_netif WHERE router = %s",(router_id,))
mysql.execute("DELETE FROM router_ipv6 WHERE router = %s",(router_id,))

View File

@ -121,6 +121,9 @@
{%- if router.community %}
({{ router.community }})
{%- endif -%}
{%- if router.reset %}
<span style="color:#d90000">- Router has lost its position!</span>
{%- endif -%}
</td></tr>
{%- endif %}
{%- if router.user or router.contact %}