From 7f3d421b254e63f8b67bbcf3ce57600352f989ea Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 20 Feb 2021 23:45:06 +0100 Subject: [PATCH] introduce profile list --- htdocs/css/admin.css | 3 ++- owrx/controllers/settings/sdr.py | 23 +++++++++++++++++++++++ owrx/http.py | 16 ++++++++-------- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/htdocs/css/admin.css b/htdocs/css/admin.css index 5c94caa..038c25c 100644 --- a/htdocs/css/admin.css +++ b/htdocs/css/admin.css @@ -82,6 +82,7 @@ table.bookmarks .frequency { padding-left: 0; } -.sdr-device-list .list-group-item { +.sdr-device-list .list-group-item, +.sdr-profile-list .list-group-item { background: initial; } \ No newline at end of file diff --git a/owrx/controllers/settings/sdr.py b/owrx/controllers/settings/sdr.py index 6ce60c7..926001e 100644 --- a/owrx/controllers/settings/sdr.py +++ b/owrx/controllers/settings/sdr.py @@ -95,6 +95,29 @@ class SdrDeviceController(SettingsFormController): variables["assets_prefix"] = "../../" return variables + def render_sections(self): + return super().render_sections() + self.render_profile_list(self.device["profiles"]) + + def render_profile_list(self, profiles): + def render_profile(profile_id, profile): + return """ +
  • + {profile_name} +
  • + """.format( + profile_name=profile["name"], + profile_link="{}/{}".format(self.request.path, quote(profile_id)), + ) + + return """ +

    Profiles

    + + """.format( + profiles="".join(render_profile(p_id, p) for p_id, p in profiles.items()) + ) + def indexAction(self): if self.device is None: self.send_response("device not found", code=404) diff --git a/owrx/http.py b/owrx/http.py index 7fd53b0..e3db2e6 100644 --- a/owrx/http.py +++ b/owrx/http.py @@ -100,11 +100,11 @@ class Router(object): self.routes = [ StaticRoute("/", IndexController), StaticRoute("/status.json", StatusController), - RegexRoute("/static/(.+)", OwrxAssetsController), - RegexRoute("/compiled/(.+)", CompiledAssetsController), - RegexRoute("/aprs-symbols/(.+)", AprsSymbolsController), + RegexRoute("^/static/(.+)$", OwrxAssetsController), + RegexRoute("^/compiled/(.+)$", CompiledAssetsController), + RegexRoute("^/aprs-symbols/(.+)$", AprsSymbolsController), StaticRoute("/ws/", WebSocketController), - RegexRoute("(/favicon.ico)", OwrxAssetsController), + RegexRoute("^(/favicon.ico)$", OwrxAssetsController), StaticRoute("/map", MapController), StaticRoute("/features", FeatureController), StaticRoute("/api/features", ApiController), @@ -116,12 +116,12 @@ class Router(object): "/settings/general", GeneralSettingsController, method="POST", options={"action": "processFormData"} ), StaticRoute("/settings/sdr", SdrDeviceListController), - RegexRoute("/settings/sdr/(.+)", SdrDeviceController), - RegexRoute("/settings/sdr/(.+)", SdrDeviceController, method="POST", options={"action": "processFormData"}), + RegexRoute("^/settings/sdr/([^/]+)$", SdrDeviceController), + RegexRoute("^/settings/sdr/([^/]+)$", SdrDeviceController, method="POST", options={"action": "processFormData"}), StaticRoute("/settings/bookmarks", BookmarksController), StaticRoute("/settings/bookmarks", BookmarksController, method="POST", options={"action": "new"}), - RegexRoute("/settings/bookmarks/(.+)", BookmarksController, method="POST", options={"action": "update"}), - RegexRoute("/settings/bookmarks/(.+)", BookmarksController, method="DELETE", options={"action": "delete"}), + RegexRoute("^/settings/bookmarks/(.+)$", BookmarksController, method="POST", options={"action": "update"}), + RegexRoute("^/settings/bookmarks/(.+)$", BookmarksController, method="DELETE", options={"action": "delete"}), StaticRoute("/settings/reporting", ReportingController), StaticRoute( "/settings/reporting", ReportingController, method="POST", options={"action": "processFormData"}