header details on map, too

This commit is contained in:
Jakob Ketterl 2020-05-09 00:20:38 +02:00
parent 3a455a0452
commit 3202f48f8e
3 changed files with 35 additions and 26 deletions

View File

@ -7,6 +7,7 @@
<script src="static/lib/chroma.min.js"></script>
<script src="static/map.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="static/lib/Header.js"></script>
<link rel="stylesheet" type="text/css" href="static/css/map.css" />
<meta charset="utf-8">
</head>

View File

@ -250,6 +250,11 @@
case "update":
processUpdates(json.value);
break;
case 'receiver_details':
$('#webrx-top-container').header().setDetails(json['value']);
break;
default:
console.warn('received message of unknown type: ' + json['type']);
}
} catch (e) {
// don't lose exception

View File

@ -15,7 +15,7 @@ from owrx.modes import Modes, DigitalMode
from multiprocessing import Queue
from queue import Full
from js8py import Js8Frame
from abc import ABC, abstractmethod
from abc import ABC, ABCMeta, abstractmethod
import json
import threading
@ -64,7 +64,33 @@ class Client(ABC):
self.close()
class OpenWebRxReceiverClient(Client):
class OpenWebRxClient(Client, metaclass=ABCMeta):
def __init__(self, conn):
super().__init__(conn)
receiver_details = Config.get().filter(
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
def send_receiver_info(*args):
receiver_info = receiver_details.__dict__()
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
self.write_receiver_details(receiver_info)
# TODO unsubscribe
receiver_details.wire(send_receiver_info)
send_receiver_info()
def write_receiver_details(self, details):
self.send({"type": "receiver_details", "value": details})
class OpenWebRxReceiverClient(OpenWebRxClient):
config_keys = [
"waterfall_colors",
"waterfall_min_level",
@ -97,34 +123,14 @@ class OpenWebRxReceiverClient(Client):
self.close()
raise
pm = Config.get()
self.setSdr()
receiver_details = pm.filter(
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
def send_receiver_info(*args):
receiver_info = receiver_details.__dict__()
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
self.write_receiver_details(receiver_info)
features = FeatureDetector().feature_availability()
self.write_features(features)
modes = Modes.getModes()
self.write_modes(modes)
# TODO unsubscribe
receiver_details.wire(send_receiver_info)
send_receiver_info()
self.__sendProfiles()
CpuUsageThread.getSharedInstance().add_client(self)
@ -314,9 +320,6 @@ class OpenWebRxReceiverClient(Client):
def write_config(self, cfg):
self.send({"type": "config", "value": cfg})
def write_receiver_details(self, details):
self.send({"type": "receiver_details", "value": details})
def write_profiles(self, profiles):
self.send({"type": "profiles", "value": profiles})
@ -382,7 +385,7 @@ class OpenWebRxReceiverClient(Client):
self.send({"type": "modes", "value": [to_json(m) for m in modes]})
class MapConnection(Client):
class MapConnection(OpenWebRxClient):
def __init__(self, conn):
super().__init__(conn)