add profile list to the device page

This commit is contained in:
Jakob Ketterl 2021-03-02 20:28:49 +01:00
parent e0b289b6a5
commit 2b1dc76e48
2 changed files with 30 additions and 7 deletions

View File

@ -103,6 +103,11 @@ table.bookmarks .frequency {
background: initial; background: initial;
} }
.sdr-device-list .sdr-profile-list {
max-height: 20rem;
overflow-y: auto;
}
.removable-group.removable { .removable-group.removable {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -23,6 +23,16 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
return variables return variables
def render_devices(self): def render_devices(self):
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)),
)
def render_device(device_id, config): def render_device(device_id, config):
# TODO: this only returns non-failed sources... # TODO: this only returns non-failed sources...
source = SdrService.getSource(device_id) source = SdrService.getSource(device_id)
@ -47,12 +57,19 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
return """ return """
<li class="list-group-item"> <li class="list-group-item">
<a href="{device_link}"> <div class="row">
<h3>{device_name}</h3> <div class="col-6">
</a> <a href="{device_link}">
<div>State: {state}</div> <h3>{device_name}</h3>
<div>{num_profiles} profile(s)</div> </a>
{additional_info} <div>State: {state}</div>
<div>{num_profiles} profile(s)</div>
{additional_info}
</div>
<ul class="col-6 list-group list-group-flush sdr-profile-list">
{profiles}
</ul>
</div>
</li> </li>
""".format( """.format(
device_name=config["name"], device_name=config["name"],
@ -60,10 +77,11 @@ class SdrDeviceListController(AuthorizationMixin, WebpageController):
state="Unknown" if source is None else source.getState(), state="Unknown" if source is None else source.getState(),
num_profiles=len(config["profiles"]), num_profiles=len(config["profiles"]),
additional_info=additional_info, additional_info=additional_info,
profiles="".join(render_profile(p_id, p) for p_id, p in config["profiles"].items())
) )
return """ return """
<ul class="row list-group list-group-flush sdr-device-list"> <ul class="list-group list-group-flush sdr-device-list">
{devices} {devices}
</ul> </ul>
""".format( """.format(