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.version import openwebrx_version
from owrx.sdr import SdrService from owrx.sdr import SdrService
from owrx.config import Config from owrx.config import Config
from owrx.jsons import Encoder
import json import json
import logging import logging
@ -40,4 +41,4 @@ class StatusController(ReceiverIdController):
"version": openwebrx_version, "version": openwebrx_version,
"sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()], "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): def keys(self):
pass pass
@abstractmethod
def values(self):
pass
@abstractmethod
def items(self): def items(self):
return self.__dict__().items() pass
def __len__(self): def __len__(self):
return self.__dict__().__len__() return self.__dict__().__len__()
@ -141,6 +146,12 @@ class PropertyLayer(PropertyManager):
def keys(self): def keys(self):
return self.properties.keys() return self.properties.keys()
def values(self):
return self.properties.values()
def items(self):
return self.properties.items()
class PropertyFilter(PropertyManager): class PropertyFilter(PropertyManager):
def __init__(self, pm: PropertyManager, filter: Filter): def __init__(self, pm: PropertyManager, filter: Filter):
@ -179,6 +190,12 @@ class PropertyFilter(PropertyManager):
def keys(self): def keys(self):
return [k for k in self.pm.keys() if self._filter.apply(k)] 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): class PropertyDelegator(PropertyManager):
def __init__(self, pm: PropertyManager): def __init__(self, pm: PropertyManager):
@ -204,6 +221,12 @@ class PropertyDelegator(PropertyManager):
def keys(self): def keys(self):
return self.pm.keys() return self.pm.keys()
def values(self):
return self.pm.values()
def items(self):
return self.pm.items()
class PropertyValidationError(PropertyError): class PropertyValidationError(PropertyError):
def __init__(self, key, value): def __init__(self, key, value):
@ -341,6 +364,12 @@ class PropertyStack(PropertyManager):
def keys(self): def keys(self):
return set([key for l in self.layers for key in l["props"].keys()]) 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): class PropertyCarousel(PropertyDelegator):
def __init__(self): def __init__(self):