diff --git a/htdocs/css/admin.css b/htdocs/css/admin.css index a632da6..5c94caa 100644 --- a/htdocs/css/admin.css +++ b/htdocs/css/admin.css @@ -13,10 +13,6 @@ html, body { margin: 15px 15px 0; } -.device { - margin-top: 20px; -} - .settings-section { margin-top: 3em; } @@ -84,4 +80,8 @@ table.bookmarks .frequency { .wsjt-decoding-depths-table td:first-child { padding-left: 0; +} + +.sdr-device-list .list-group-item { + background: initial; } \ No newline at end of file diff --git a/htdocs/settings/general.html b/htdocs/settings/general.html index e9297b1..1e6724d 100644 --- a/htdocs/settings/general.html +++ b/htdocs/settings/general.html @@ -2,18 +2,18 @@ OpenWebRX Settings - - - + + + - + ${header}
-

${title}s

+

${title}

${content}
diff --git a/owrx/controllers/settings/__init__.py b/owrx/controllers/settings/__init__.py index 6ddcb54..9800801 100644 --- a/owrx/controllers/settings/__init__.py +++ b/owrx/controllers/settings/__init__.py @@ -69,6 +69,7 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB variables = super().template_variables() variables["content"] = self.render_sections() variables["title"] = self.getTitle() + variables["assets_prefix"] = "../" return variables def parseFormData(self): diff --git a/owrx/controllers/settings/sdr.py b/owrx/controllers/settings/sdr.py index 24d39e0..88cf10f 100644 --- a/owrx/controllers/settings/sdr.py +++ b/owrx/controllers/settings/sdr.py @@ -1,9 +1,10 @@ from owrx.controllers.admin import AuthorizationMixin from owrx.controllers.template import WebpageController from owrx.config import Config +from urllib.parse import quote, unquote -class SdrSettingsController(AuthorizationMixin, WebpageController): +class SdrDeviceListController(AuthorizationMixin, WebpageController): def header_variables(self): variables = super().header_variables() variables["assets_prefix"] = "../" @@ -13,30 +14,59 @@ class SdrSettingsController(AuthorizationMixin, WebpageController): variables = super().template_variables() variables["content"] = self.render_devices() variables["title"] = "SDR device settings" + variables["assets_prefix"] = "../" return variables def render_devices(self): def render_device(device_id, config): return """ -
-
- {device_name} +
  • + +

    {device_name}

    +
    +
    + some more device info here
    -
    - sdr detail goes here -
    -
  • + """.format( - device_name=config["name"] + device_name=config["name"], + device_link="{}/{}".format(self.request.path, quote(device_id)), ) return """ -
    +
    + """.format( devices="".join(render_device(key, value) for key, value in Config.get()["sdrs"].items()) ) def indexAction(self): self.serve_template("settings/general.html", **self.template_variables()) + + +class SdrDeviceController(AuthorizationMixin, WebpageController): + def get_device(self): + device_id = unquote(self.request.matches.group(1)) + if device_id not in Config.get()["sdrs"]: + return None + return Config.get()["sdrs"][device_id] + + def header_variables(self): + variables = super().header_variables() + variables["assets_prefix"] = "../../" + return variables + + def template_variables(self, device): + variables = super().template_variables() + variables["title"] = device["name"] + variables["content"] = "TODO" + variables["assets_prefix"] = "../../" + return variables + + def indexAction(self): + device = self.get_device() + if device is None: + self.send_response("device not found", code=404) + return + self.serve_template("settings/general.html", **self.template_variables(device)) diff --git a/owrx/http.py b/owrx/http.py index 4d712d4..9360fb6 100644 --- a/owrx/http.py +++ b/owrx/http.py @@ -6,7 +6,7 @@ from owrx.controllers.api import ApiController from owrx.controllers.metrics import MetricsController from owrx.controllers.settings import SettingsController from owrx.controllers.settings.general import GeneralSettingsController -from owrx.controllers.settings.sdr import SdrSettingsController +from owrx.controllers.settings.sdr import SdrDeviceListController, SdrDeviceController from owrx.controllers.settings.reporting import ReportingController from owrx.controllers.settings.backgrounddecoding import BackgroundDecodingController from owrx.controllers.settings.decoding import DecodingSettingsController @@ -115,7 +115,8 @@ class Router(object): StaticRoute( "/settings/general", GeneralSettingsController, method="POST", options={"action": "processFormData"} ), - StaticRoute("/settings/sdr", SdrSettingsController), + StaticRoute("/settings/sdr", SdrDeviceListController), + RegexRoute("/settings/sdr/(.+)", SdrDeviceController), StaticRoute("/settings/bookmarks", BookmarksController), StaticRoute("/settings/bookmarks", BookmarksController, method="POST", options={"action": "new"}), RegexRoute("/settings/bookmarks/(.+)", BookmarksController, method="POST", options={"action": "update"}),