introduce profile list

This commit is contained in:
Jakob Ketterl 2021-02-20 23:45:06 +01:00
parent 44250f9719
commit 7f3d421b25
3 changed files with 33 additions and 9 deletions

View File

@ -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;
}

View File

@ -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 """
<li class="list-group-item">
<a href="{profile_link}">{profile_name}</a>
</li>
""".format(
profile_name=profile["name"],
profile_link="{}/{}".format(self.request.path, quote(profile_id)),
)
return """
<h3 class="settings-header">Profiles</h3>
<ul class="row list-group list-group-flush sdr-profile-list">
{profiles}
</ul>
""".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)

View File

@ -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"}