implement optional device fields

This commit is contained in:
Jakob Ketterl
2021-02-22 23:49:28 +01:00
parent f8beae5f46
commit 54a34b2084
10 changed files with 213 additions and 51 deletions

View File

@ -151,6 +151,7 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController):
"lib/settings/WsjtDecodingDepthsInput.js",
"lib/settings/WaterfallDropdown.js",
"lib/settings/GainInput.js",
"lib/settings/OptionalSection.js",
"settings.js",
],
}

View File

@ -10,19 +10,25 @@ class Section(object):
self.title = title
self.inputs = inputs
def render_input(self, input, data):
return input.render(data)
def render_inputs(self, data):
return "".join([i.render(data) for i in self.inputs])
return "".join([self.render_input(i, data) for i in self.inputs])
def classes(self):
return ["col-12", "settings-section"]
def render(self, data):
return """
<div class="col-12 settings-section">
<div class="{classes}">
<h3 class="settings-header">
{title}
</h3>
{inputs}
</div>
""".format(
title=self.title, inputs=self.render_inputs(data)
classes=" ".join(self.classes()), title=self.title, inputs=self.render_inputs(data)
)
def parse(self, data):

View File

@ -71,7 +71,7 @@ class SdrDeviceController(SettingsFormController):
def getSections(self):
try:
description = SdrDeviceDescription.getByType(self.device["type"])
return [description.getSection(self.device)]
return [description.getSection()]
except SdrDeviceDescriptionMissing:
# TODO provide a generic interface that allows to switch the type
return []