fix status page

This commit is contained in:
Jakob Ketterl 2021-03-06 23:34:27 +01:00
parent 3d20e3ed80
commit e0985c3802
2 changed files with 32 additions and 2 deletions

View File

@ -2,6 +2,7 @@ from .receiverid import ReceiverIdController
from owrx.version import openwebrx_version
from owrx.sdr import SdrService
from owrx.config import Config
from owrx.jsons import Encoder
import json
import logging
@ -40,4 +41,4 @@ class StatusController(ReceiverIdController):
"version": openwebrx_version,
"sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()],
}
self.send_response(json.dumps(status), content_type="application/json")
self.send_response(json.dumps(status, cls=Encoder), content_type="application/json")

View File

@ -63,8 +63,13 @@ class PropertyManager(ABC):
def keys(self):
pass
@abstractmethod
def values(self):
pass
@abstractmethod
def items(self):
return self.__dict__().items()
pass
def __len__(self):
return self.__dict__().__len__()
@ -141,6 +146,12 @@ class PropertyLayer(PropertyManager):
def keys(self):
return self.properties.keys()
def values(self):
return self.properties.values()
def items(self):
return self.properties.items()
class PropertyFilter(PropertyManager):
def __init__(self, pm: PropertyManager, filter: Filter):
@ -179,6 +190,12 @@ class PropertyFilter(PropertyManager):
def keys(self):
return [k for k in self.pm.keys() if self._filter.apply(k)]
def values(self):
return [v for k, v in self.pm.items() if self._filter.apply(k)]
def items(self):
return self.__dict__().items()
class PropertyDelegator(PropertyManager):
def __init__(self, pm: PropertyManager):
@ -204,6 +221,12 @@ class PropertyDelegator(PropertyManager):
def keys(self):
return self.pm.keys()
def values(self):
return self.pm.values()
def items(self):
return self.pm.items()
class PropertyValidationError(PropertyError):
def __init__(self, key, value):
@ -341,6 +364,12 @@ class PropertyStack(PropertyManager):
def keys(self):
return set([key for l in self.layers for key in l["props"].keys()])
def values(self):
return [self.__getitem__(k) for k in self.keys()]
def items(self):
return self.__dict__().items()
class PropertyCarousel(PropertyDelegator):
def __init__(self):