send changed keys over websocket connection for the map

This commit is contained in:
Jakob Ketterl 2021-02-27 01:00:38 +01:00
parent 7dcafab2c1
commit e9cb5d54be
2 changed files with 57 additions and 47 deletions

View File

@ -1,4 +1,4 @@
(function(){
$(function(){
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
var s = v.split('=');
var r = {};
@ -212,6 +212,8 @@
var reconnect_timeout = false;
var config = {}
var connect = function(){
var ws = new WebSocket(ws_url);
ws.onopen = function(){
@ -225,14 +227,14 @@
return
}
if (e.data.substr(0, 16) == "CLIENT DE SERVER") {
console.log("Server acknowledged WebSocket connection.");
return
}
try {
var json = JSON.parse(e.data);
switch (json.type) {
case "config":
var config = json.value;
Object.assign(config, json.value);
if ('receiver_gps' in config) {
var receiverPos = {
lat: config.receiver_gps.lat,
lng: config.receiver_gps.lon
@ -272,11 +274,18 @@
receiverMarker.setOptions({
map: map,
position: receiverPos,
title: config['receiver_name'],
config: config
});
}
}
if ('receiver_name' in config && receiverMarker) {
receiverMarker.setOptions({
title: config['receiver_name']
});
}
if ('map_position_retention_time' in config) {
retention_time = config.map_position_retention_time * 1000;
}
break;
case "update":
processUpdates(json.value);
@ -464,4 +473,4 @@
});
}
})();
});

View File

@ -459,14 +459,15 @@ class MapConnection(OpenWebRxClient):
super().__init__(conn)
pm = Config.get()
self.write_config(
pm.filter(
filtered_config = pm.filter(
"google_maps_api_key",
"receiver_gps",
"map_position_retention_time",
"receiver_name",
).__dict__()
)
filtered_config.wire(self.write_config)
self.write_config(filtered_config.__dict__())
Map.getSharedInstance().addClient(self)