From a3a4bc1db375c29e46297573be0bbce6b7464a7e Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Thu, 9 Dec 2021 07:42:26 -0800 Subject: [PATCH] add GPS map, clean PEER map, improve dash_only --- web/app.py | 173 +++++++++++++++++++++------ web/templates/flask_user_layout.html | 2 + web/templates/map.html | 5 + 3 files changed, 144 insertions(+), 36 deletions(-) diff --git a/web/app.py b/web/app.py index 4436ee1..9080ff8 100644 --- a/web/app.py +++ b/web/app.py @@ -41,6 +41,8 @@ from flask_mail import Message, Mail from socket import gethostbyname import re import folium +from folium.plugins import MarkerCluster + ##from pytz import timezone from datetime import timedelta @@ -774,7 +776,7 @@ def hbnet_web_service(): for i in mail_all: messages_waiting = messages_waiting + 1 - return dict(global_config={'mode': mode, 'messages': messages_waiting}) + return dict(global_config={'mode': mode, 'messages': messages_waiting, 'registration_enabled': USER_ENABLE_REGISTER}) # The Home page is accessible to anyone @@ -808,7 +810,77 @@ def hbnet_web_service(): tos_text = Misc.query.filter_by(field_1='terms_of_service').first() content = tos_text.field_2 - return render_template('flask_user_layout.html', markup_content = Markup(content)) + return render_template('generic.html', markup_content = Markup(content)) + + + @app.route('/map_gps/') +## @login_required + def all_gps(call_ssid): + content = '' + try: + first_loc = False + g = GPS_LocLog.query.order_by(GPS_LocLog.time.desc()).filter_by(callsign=call_ssid).all() + for i in g: + print(first_loc) + lat = i.lat + lon = i.lon + if 'S' in i.lat: + lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', i.lat))) + lat = -lat + if 'S' not in i.lat: + lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', i.lat))) + if 'W' in i.lon: + lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', i.lon))) + lon = -lon + if 'W' not in i.lon: + lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', i.lon))) + f_map = folium.Map(location=[lat, lon], zoom_start=10) + if first_loc == False: + folium.Marker([lat, lon], popup=""" + + + + + + + + + + + + + + + +
Last Location:
"""+ str(i.callsign) +"""
"""+ str(i.comment) +"""
"""+ str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """
+
+ """, icon=folium.Icon(color="blue", icon="record"), tooltip='' + i.callsign + '').add_to(f_map) + first_loc = True + if first_loc == True: + marker_cluster = MarkerCluster().add_to(f_map) + folium.CircleMarker([lat, lon], popup=""" + + + + + + + + + +
"""+ str(i.callsign) +"""
"""+ str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """
+
+ """, tooltip='' + i.callsign + '', fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster) + content = f_map._repr_html_() + + except Exception as e: + content = '
Callsign not found or other error.
/n' + str(e) + + return render_template('generic.html', markup_content = Markup(content)) + + + + @app.route('/map_info/') ## @login_required @@ -817,42 +889,68 @@ def hbnet_web_service(): l = PeerLoc.query.filter_by(dmr_id=dmr_id).first() content = ''' - - - - - - -
 

''' + l.callsign + '''

 
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +
DMR ID: ''' + str(l.dmr_id) + ''' 
Location: ''' + l.loc + ''' 
Lat, Lon: ''' + l.lat + ''', ''' + l.lon + ''' 
Description: ''' + l.comment + ''' 

URL:

+
+
+ ''' + l.callsign + ''' (''' + str(l.dmr_id) + ''') +
+
+
Peer Information
+

+ +

+ + + - + - - + + - -
+Description:  ''' + l.url + '''  +''' + l.comment + ''' +
Device: ''' + l.software + '''  +Device: + +''' + l.software + ''' +
+
+Location: + +''' + l.loc + ''' +
+Coordinates: + +''' + l.lat + ''', ''' + l.lon + ''' +
+URL: + + ''' + l.url + '''  +
+ + +

+ + + + ''' except: content = 'No peer found.' @@ -890,10 +988,13 @@ def hbnet_web_service(): Last Location: - """+ str(i.callsign) +""" + """+ str(i.callsign) +""" - """+ str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) +""" + """+ str(i.comment) +""" + + + """+ str((i.time + timedelta(hours=hbnet_tz)).strftime(time_format)) + """ diff --git a/web/templates/flask_user_layout.html b/web/templates/flask_user_layout.html index 7637b23..69f6f42 100644 --- a/web/templates/flask_user_layout.html +++ b/web/templates/flask_user_layout.html @@ -83,9 +83,11 @@ + {% if global_config['registration_enabled'] == True %} + {% endif %} {% endif %} {% if call_or_get(current_user.is_authenticated) %} diff --git a/web/templates/map.html b/web/templates/map.html index cfdef58..c59de04 100644 --- a/web/templates/map.html +++ b/web/templates/map.html @@ -2,6 +2,9 @@ {% block content %}

 

+ +{% if global_config['mode'] == 'FULL' %} +
Map of connected peers and GPS locations.
To diasble map plotting for your hotspot or repeater, see the MMDVM Options section in Help.

 

@@ -15,6 +18,8 @@ + +{% endif %}
{{markup_content}}