download receiver details via rest api

This commit is contained in:
Jakob Ketterl 2020-05-10 17:27:46 +02:00
parent 11cf2a96e2
commit 8df885b727
4 changed files with 33 additions and 19 deletions

View File

@ -6,6 +6,7 @@ function Header(el) {
}); });
this.init_rx_photo(); this.init_rx_photo();
this.download_details();
}; };
Header.prototype.setDetails = function(details) { Header.prototype.setDetails = function(details) {
@ -57,6 +58,13 @@ Header.prototype.toggle_rx_photo = function(ev) {
} }
}; };
Header.prototype.download_details = function() {
var self = this;
$.ajax('api/receiverdetails').done(function(data){
self.setDetails(data);
});
};
$.fn.header = function() { $.fn.header = function() {
if (!this.data('header')) { if (!this.data('header')) {
this.data('header', new Header(this)); this.data('header', new Header(this));

View File

@ -1,4 +1,5 @@
from owrx.config import Config from owrx.config import Config
from owrx.details import ReceiverDetails
from owrx.dsp import DspManager from owrx.dsp import DspManager
from owrx.cpu import CpuUsageThread from owrx.cpu import CpuUsageThread
from owrx.sdr import SdrService from owrx.sdr import SdrService
@ -9,7 +10,6 @@ from owrx.version import openwebrx_version
from owrx.bands import Bandplan from owrx.bands import Bandplan
from owrx.bookmarks import Bookmarks from owrx.bookmarks import Bookmarks
from owrx.map import Map from owrx.map import Map
from owrx.locator import Locator
from owrx.property import PropertyStack from owrx.property import PropertyStack
from owrx.modes import Modes, DigitalMode from owrx.modes import Modes, DigitalMode
from multiprocessing import Queue from multiprocessing import Queue
@ -68,18 +68,10 @@ class OpenWebRxClient(Client, metaclass=ABCMeta):
def __init__(self, conn): def __init__(self, conn):
super().__init__(conn) super().__init__(conn)
receiver_details = Config.get().filter( receiver_details = ReceiverDetails()
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
def send_receiver_info(*args): def send_receiver_info(*args):
receiver_info = receiver_details.__dict__() receiver_info = receiver_details.__dict__()
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
self.write_receiver_details(receiver_info) self.write_receiver_details(receiver_info)
# TODO unsubscribe # TODO unsubscribe

View File

@ -1,6 +1,6 @@
from . import Controller from . import Controller
from owrx.feature import FeatureDetector from owrx.feature import FeatureDetector
from owrx.config import Config from owrx.details import ReceiverDetails
import json import json
@ -10,13 +10,6 @@ class ApiController(Controller):
self.send_response(data, content_type="application/json") self.send_response(data, content_type="application/json")
def receiverDetails(self): def receiverDetails(self):
receiver_details = Config.get().filter( receiver_details = ReceiverDetails()
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
data = json.dumps(receiver_details.__dict__()) data = json.dumps(receiver_details.__dict__())
self.send_response(data, content_type="application/json") self.send_response(data, content_type="application/json")

21
owrx/details.py Normal file
View File

@ -0,0 +1,21 @@
from owrx.config import Config
from owrx.locator import Locator
from owrx.property import PropertyFilter
class ReceiverDetails(PropertyFilter):
def __init__(self):
super().__init__(
Config.get(),
"receiver_name",
"receiver_location",
"receiver_asl",
"receiver_gps",
"photo_title",
"photo_desc",
)
def __dict__(self):
receiver_info = super().__dict__()
receiver_info["locator"] = Locator.fromCoordinates(receiver_info["receiver_gps"])
return receiver_info