send changed keys over websocket connection for the map
This commit is contained in:
parent
7dcafab2c1
commit
e9cb5d54be
@ -1,4 +1,4 @@
|
|||||||
(function(){
|
$(function(){
|
||||||
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
|
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
|
||||||
var s = v.split('=');
|
var s = v.split('=');
|
||||||
var r = {};
|
var r = {};
|
||||||
@ -212,6 +212,8 @@
|
|||||||
|
|
||||||
var reconnect_timeout = false;
|
var reconnect_timeout = false;
|
||||||
|
|
||||||
|
var config = {}
|
||||||
|
|
||||||
var connect = function(){
|
var connect = function(){
|
||||||
var ws = new WebSocket(ws_url);
|
var ws = new WebSocket(ws_url);
|
||||||
ws.onopen = function(){
|
ws.onopen = function(){
|
||||||
@ -225,58 +227,65 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
|
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
|
||||||
console.log("Server acknowledged WebSocket connection.");
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var json = JSON.parse(e.data);
|
var json = JSON.parse(e.data);
|
||||||
switch (json.type) {
|
switch (json.type) {
|
||||||
case "config":
|
case "config":
|
||||||
var config = json.value;
|
Object.assign(config, json.value);
|
||||||
var receiverPos = {
|
if ('receiver_gps' in config) {
|
||||||
lat: config.receiver_gps.lat,
|
var receiverPos = {
|
||||||
lng: config.receiver_gps.lon
|
lat: config.receiver_gps.lat,
|
||||||
};
|
lng: config.receiver_gps.lon
|
||||||
if (!map) $.getScript("https://maps.googleapis.com/maps/api/js?key=" + config.google_maps_api_key).done(function(){
|
};
|
||||||
map = new google.maps.Map($('.openwebrx-map')[0], {
|
if (!map) $.getScript("https://maps.googleapis.com/maps/api/js?key=" + config.google_maps_api_key).done(function(){
|
||||||
center: receiverPos,
|
map = new google.maps.Map($('.openwebrx-map')[0], {
|
||||||
zoom: 5,
|
center: receiverPos,
|
||||||
});
|
zoom: 5,
|
||||||
|
});
|
||||||
|
|
||||||
$.getScript("static/lib/nite-overlay.js").done(function(){
|
$.getScript("static/lib/nite-overlay.js").done(function(){
|
||||||
nite.init(map);
|
nite.init(map);
|
||||||
setInterval(function() { nite.refresh() }, 10000); // every 10s
|
setInterval(function() { nite.refresh() }, 10000); // every 10s
|
||||||
});
|
});
|
||||||
$.getScript('static/lib/AprsMarker.js').done(function(){
|
$.getScript('static/lib/AprsMarker.js').done(function(){
|
||||||
processUpdates(updateQueue);
|
processUpdates(updateQueue);
|
||||||
updateQueue = [];
|
updateQueue = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
var $legend = $(".openwebrx-map-legend");
|
var $legend = $(".openwebrx-map-legend");
|
||||||
setupLegendFilters($legend);
|
setupLegendFilters($legend);
|
||||||
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push($legend[0]);
|
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push($legend[0]);
|
||||||
|
|
||||||
if (!receiverMarker) {
|
if (!receiverMarker) {
|
||||||
receiverMarker = new google.maps.Marker();
|
receiverMarker = new google.maps.Marker();
|
||||||
receiverMarker.addListener('click', function() {
|
receiverMarker.addListener('click', function() {
|
||||||
showReceiverInfoWindow(receiverMarker);
|
showReceiverInfoWindow(receiverMarker);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
receiverMarker.setOptions({
|
||||||
|
map: map,
|
||||||
|
position: receiverPos,
|
||||||
|
title: config['receiver_name'],
|
||||||
|
config: config
|
||||||
|
});
|
||||||
|
}); else {
|
||||||
|
receiverMarker.setOptions({
|
||||||
|
map: map,
|
||||||
|
position: receiverPos,
|
||||||
|
config: config
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ('receiver_name' in config && receiverMarker) {
|
||||||
receiverMarker.setOptions({
|
receiverMarker.setOptions({
|
||||||
map: map,
|
title: config['receiver_name']
|
||||||
position: receiverPos,
|
|
||||||
title: config['receiver_name'],
|
|
||||||
config: config
|
|
||||||
});
|
|
||||||
}); else {
|
|
||||||
receiverMarker.setOptions({
|
|
||||||
map: map,
|
|
||||||
position: receiverPos,
|
|
||||||
title: config['receiver_name'],
|
|
||||||
config: config
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
retention_time = config.map_position_retention_time * 1000;
|
if ('map_position_retention_time' in config) {
|
||||||
|
retention_time = config.map_position_retention_time * 1000;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "update":
|
case "update":
|
||||||
processUpdates(json.value);
|
processUpdates(json.value);
|
||||||
@ -464,4 +473,4 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
@ -459,14 +459,15 @@ class MapConnection(OpenWebRxClient):
|
|||||||
super().__init__(conn)
|
super().__init__(conn)
|
||||||
|
|
||||||
pm = Config.get()
|
pm = Config.get()
|
||||||
self.write_config(
|
filtered_config = pm.filter(
|
||||||
pm.filter(
|
"google_maps_api_key",
|
||||||
"google_maps_api_key",
|
"receiver_gps",
|
||||||
"receiver_gps",
|
"map_position_retention_time",
|
||||||
"map_position_retention_time",
|
"receiver_name",
|
||||||
"receiver_name",
|
|
||||||
).__dict__()
|
|
||||||
)
|
)
|
||||||
|
filtered_config.wire(self.write_config)
|
||||||
|
|
||||||
|
self.write_config(filtered_config.__dict__())
|
||||||
|
|
||||||
Map.getSharedInstance().addClient(self)
|
Map.getSharedInstance().addClient(self)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user