From 2e9a204c7466446a895f3ba62e0aab69ea1be21f Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 22 Aug 2023 12:31:44 -0400 Subject: [PATCH] Make use of webchat gps config options This patch makes use of the gps settings in the webchat section. If the user sets the latitude and longitude in the config file, then the gps beacon button will be enabled. The gps button will still be enabled if the http connection is over SSL. --- aprsd/cmds/webchat.py | 9 +++++++++ aprsd/web/chat/static/js/gps.js | 10 +++++++++- aprsd/web/chat/static/js/send-message-mobile.js | 1 - aprsd/web/chat/templates/index.html | 7 ++++++- aprsd/web/chat/templates/mobile.html | 10 ++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py index 3c20f39..a7552f4 100644 --- a/aprsd/cmds/webchat.py +++ b/aprsd/cmds/webchat.py @@ -239,6 +239,13 @@ def index(): stats["transport"] = transport stats["aprs_connection"] = aprs_connection LOG.debug(f"initial stats = {stats}") + latitude = CONF.webchat.latitude + if latitude: + latitude = float(CONF.webchat.latitude) + + longitude = CONF.webchat.longitude + if longitude: + longitude = float(longitude) return flask.render_template( html_template, @@ -246,6 +253,8 @@ def index(): aprs_connection=aprs_connection, callsign=CONF.callsign, version=aprsd.__version__, + latitude=latitude, + longitude=longitude, ) diff --git a/aprsd/web/chat/static/js/gps.js b/aprsd/web/chat/static/js/gps.js index dbe0229..85329ba 100644 --- a/aprsd/web/chat/static/js/gps.js +++ b/aprsd/web/chat/static/js/gps.js @@ -1,9 +1,17 @@ function init_gps() { console.log("init_gps Called.") + console.log("latitude: "+latitude) + console.log("longitude: "+longitude) $("#send_beacon").click(function() { console.log("Send a beacon!") - getLocation(); + if (!isNaN(latitude) && !isNaN(longitude)) { + // webchat admin has hard coded lat/long in the config file + showPosition({'coords': {'latitude': latitude, 'longitude': longitude}}) + } else { + // Try to get the current location from the browser + getLocation(); + } }); } diff --git a/aprsd/web/chat/static/js/send-message-mobile.js b/aprsd/web/chat/static/js/send-message-mobile.js index d5fd126..7dc92e6 100644 --- a/aprsd/web/chat/static/js/send-message-mobile.js +++ b/aprsd/web/chat/static/js/send-message-mobile.js @@ -43,7 +43,6 @@ function init_chat() { } socket.emit("send", msg); $('#message').val(''); - $('#to_call').val(''); }); init_gps(); diff --git a/aprsd/web/chat/templates/index.html b/aprsd/web/chat/templates/index.html index 0388475..cf45909 100644 --- a/aprsd/web/chat/templates/index.html +++ b/aprsd/web/chat/templates/index.html @@ -17,6 +17,8 @@