improve map

This commit is contained in:
KF7EEL 2021-08-08 12:41:35 -07:00
parent 2269b57b5c
commit 716acefb1e
3 changed files with 62 additions and 26 deletions

View File

@ -678,7 +678,7 @@ class HBSYSTEM(DatagramProtocol):
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
logger.info('(%s) Peer %s (%s) has sent repeater configuration', self._system, _this_peer['CALLSIGN'], _this_peer['RADIO_ID'])
self.send_peer_loc(_peer_id, _this_peer['CALLSIGN'], _this_peer['LATITUDE'], _this_peer['LONGITUDE'], _this_peer['URL'], _this_peer['DESCRIPTION'], _this_peer['LOCATION'], _this_peer['SOFTWARE_ID'])
self.send_peer_loc(_peer_id, _this_peer['CALLSIGN'], _this_peer['LATITUDE'], _this_peer['LONGITUDE'], _this_peer['URL'], _this_peer['DESCRIPTION'], _this_peer['LOCATION'], str(_this_peer['PACKAGE_ID']) + ' - ' + str(_this_peer['SOFTWARE_ID']))
else:
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
logger.warning('(%s) Peer info from Radio ID that has not logged in: %s', self._system, int_id(_peer_id))

View File

@ -699,24 +699,63 @@ def create_app():
@app.route('/map')
@login_required
def map_page():
print(peer_locations)
f_map = folium.Map(location=center_map, zoom_start=map_zoom)
## folium.Marker([45.372, -121.6972], popup="hello", icon=folium.Icon(color="red", icon="record"), tooltip='hi').add_to(f_map)
for l in peer_locations.items():
## folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
##<div class="panel panel-default">
## <div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
## <div class="panel-body">
## ''' + l[1][5] + '''
## <hr />
## ''' + l[1][1] + ''', ''' + l[1][2] + '''
## <hr />
## ''' + l[1][3] + '''
## <hr />
## ''' + l[1][4] + '''
## <hr />
## ''' + l[1][6] + '''
## </div>
##</div>
## ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
<div class="panel panel-default">
<div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
<div class="panel-body">
''' + l[1][5] + '''
<hr />
''' + l[1][1] + ''', ''' + l[1][2] + '''
<hr />
''' + l[1][3] + '''
<hr />
''' + l[1][4] + '''
<hr />
''' + l[1][6] + '''
</div>
</div>
<table border="1">
<tbody>
<tr>
<td>&nbsp;<strong><h4>''' + l[1][0] + '''</strong></h4>&nbsp;</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody>
<tr>
<td style="width: 64.4667px;"><strong>DMR ID:</strong></td>
<td>&nbsp;''' + str(l[0]) + '''&nbsp;</td>
</tr>
<tr>
<td style="width: 64.4667px;"><strong>Location:</strong></td>
<td>&nbsp;''' + l[1][5] + '''&nbsp;</td>
</tr>
<tr>
<td style="width: 64.4667px;"><strong>Lat, Lon:</strong></td>
<td>&nbsp;''' + l[1][1] + ''', ''' + l[1][2] + '''&nbsp;</td>
</tr>
<tr>
<td style="width: 64.4667px;"><strong>Description:</strong></td>
<td>&nbsp;''' + l[1][4] + '''&nbsp;</td>
</tr>
<tr>
<td style="width: 64.4667px;"><p><strong>URL:</strong></p>
</td>
<td><a href="''' + l[1][3] + '''">&nbsp;''' + l[1][3] + '''&nbsp;</a></td>
</tr>
<tr>
<td style="width: 64.4667px;"><strong>Device:</strong></td>
<td>&nbsp;''' + l[1][6] + '''&nbsp;</td>
</tr>
</tbody>
</table>
''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
content = f_map._repr_html_()
@ -766,13 +805,13 @@ def create_app():
svr_content = ''
for i in sl:
try:
if time.time() - ping_list[i.name] < 30:
if time.time() - ping_list[i.name] < 20:
svr_status = '''<div class="alert alert-success">
<strong>Online</strong>
</div> '''
elif time.time() - ping_list[i.name] <= 300:
svr_status = '''<div class="alert alert-warning">
<strong>No pings. ( < 5 min.)</strong>
<strong>Unknown <br /> (No pings, less than 5 min.)</strong>
</div> '''
elif time.time() - ping_list[i.name] > 300:
svr_status = '''<div class="alert alert-danger">
@ -5575,7 +5614,6 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
try:
if hblink_req['ping']:
ping_list[hblink_req['ping']] = time.time()
print(peer_locations)
response = ''
except:
pass

View File

@ -1,17 +1,15 @@
{% extends 'flask_user/_public_base.html' %}
{% block content %}
<div class="row container-fluid" style="width: 800px;">
<div class="col-sm-12">
<p>&nbsp;</p>
<div class="well">Map of connected peers.
</div>
<div class="row container-fluid" >
<div class="col-xs-12">
{{markup_content}}
</div>
</div>
<p>&nbsp;</p>
{% endblock %}