from owrx.controllers.admin import AuthorizationMixin from owrx.controllers.template import WebpageController from owrx.controllers.settings import SettingsFormController from owrx.source import SdrDeviceDescription, SdrDeviceDescriptionMissing, SdrClientClass from owrx.config import Config from owrx.connection import OpenWebRxReceiverClient from owrx.controllers.settings import SettingsBreadcrumb from owrx.form.section import Section from urllib.parse import quote, unquote from owrx.sdr import SdrService from owrx.form.input import TextInput, DropdownInput, Option from owrx.form.input.validator import RequiredValidator from owrx.property import PropertyLayer from owrx.breadcrumb import BreadcrumbMixin, Breadcrumb, BreadcrumbItem from abc import ABCMeta, abstractmethod from uuid import uuid4 class SdrDeviceBreadcrumb(SettingsBreadcrumb): def __init__(self): super().__init__() self.append(BreadcrumbItem("SDR device settings", "settings/sdr")) class SdrDeviceListController(AuthorizationMixin, BreadcrumbMixin, WebpageController): def template_variables(self): variables = super().template_variables() variables["content"] = self.render_devices() variables["title"] = "SDR device settings" variables["modal"] = "" variables["error"] = "" return variables def get_breadcrumb(self): return SdrDeviceBreadcrumb() def render_devices(self): def render_device(device_id, config): sources = SdrService.getAllSources() source = sources[device_id] if device_id in sources else None additional_info = "" state_info = "Unknown" if source is not None: profiles = source.getProfiles() currentProfile = profiles[source.getProfileId()] clients = {c: len(source.getClients(c)) for c in SdrClientClass} clients = {c: v for c, v in clients.items() if v} connections = len([c for c in source.getClients() if isinstance(c, OpenWebRxReceiverClient)]) additional_info = """