add number types

This commit is contained in:
Jakob Ketterl 2020-03-27 22:00:10 +01:00
parent 0e9bb45d89
commit 54dc412c4a

View File

@ -50,6 +50,26 @@ class TextInput(Input):
) )
class NumberInput(Input):
def render_input(self, value):
return """
<input type="number" class="{classes}" id="{id}" name="{id}" placeholder="{label}" value="{value}">
""".format(
id=self.id, label=self.label, classes=self.input_classes(), value=value
)
def convert_value(self, v):
return int(v)
def parse(self, data):
return {k: self.convert_value(v) for k, v in super().parse(data).items()}
class FloatInput(NumberInput):
def convert_value(self, v):
return float(v)
class LocationInput(Input): class LocationInput(Input):
def render_input(self, value): def render_input(self, value):
# TODO make this work and pretty # TODO make this work and pretty
@ -147,7 +167,7 @@ class SettingsController(AdminController):
"General settings", "General settings",
TextInput("receiver_name", "Receiver name"), TextInput("receiver_name", "Receiver name"),
TextInput("receiver_location", "Receiver location"), TextInput("receiver_location", "Receiver location"),
TextInput("receiver_asl", "Receiver elevation", infotext="Elevation in meters above mean see level"), NumberInput("receiver_asl", "Receiver elevation", infotext="Elevation in meters above mean see level"),
TextInput("receiver_admin", "Receiver admin"), TextInput("receiver_admin", "Receiver admin"),
LocationInput("receiver_gps", "Receiver coordinates"), LocationInput("receiver_gps", "Receiver coordinates"),
TextInput("photo_title", "Photo title"), TextInput("photo_title", "Photo title"),
@ -155,21 +175,21 @@ class SettingsController(AdminController):
), ),
Section( Section(
"Waterfall settings", "Waterfall settings",
TextInput( NumberInput(
"fft_fps", "fft_fps",
"FFT frames per second", "FFT frames per second",
infotext="This setting specifies how many lines are being added to the waterfall per second. " infotext="This setting specifies how many lines are being added to the waterfall per second. "
+ "Higher values will give you a faster waterfall, but will also use more CPU.", + "Higher values will give you a faster waterfall, but will also use more CPU.",
), ),
TextInput("fft_size", "FFT size"), NumberInput("fft_size", "FFT size"),
TextInput( FloatInput(
"fft_voverlap_factor", "fft_voverlap_factor",
"FFT vertical overlap factor", "FFT vertical overlap factor",
infotext="If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the " infotext="If fft_voverlap_factor is above 0, multiple FFTs will be used for creating a line on the "
+ "diagram.", + "diagram.",
), ),
TextInput("waterfall_min_level", "Lowest waterfall level"), NumberInput("waterfall_min_level", "Lowest waterfall level"),
TextInput("waterfall_max_level", "Highest waterfall level"), NumberInput("waterfall_max_level", "Highest waterfall level"),
), ),
Section( Section(
"Compression", "Compression",
@ -185,11 +205,11 @@ class SettingsController(AdminController):
Section( Section(
"Digimodes", "Digimodes",
CheckboxInput("digimodes_enable", "", checkboxText="Enable Digimodes"), CheckboxInput("digimodes_enable", "", checkboxText="Enable Digimodes"),
TextInput("digimodes_fft_size", "Digimodes FFT size"), NumberInput("digimodes_fft_size", "Digimodes FFT size"),
), ),
Section( Section(
"Digital voice", "Digital voice",
TextInput( NumberInput(
"digital_voice_unvoiced_quality", "digital_voice_unvoiced_quality",
"Quality of unvoiced sounds in synthesized voice", "Quality of unvoiced sounds in synthesized voice",
infotext="Determines the quality, and thus the cpu usage, for the ambe codec used by digital voice" infotext="Determines the quality, and thus the cpu usage, for the ambe codec used by digital voice"
@ -231,7 +251,7 @@ class SettingsController(AdminController):
+ '<a href="https://developers.google.com/maps/documentation/embed/get-api-key" target="_blank">' + '<a href="https://developers.google.com/maps/documentation/embed/get-api-key" target="_blank">'
+ "their documentation</a> on how to obtain one." + "their documentation</a> on how to obtain one."
), ),
TextInput( NumberInput(
"map_position_retention_time", "map_position_retention_time",
"Map retention time", "Map retention time",
infotext="Unit is seconds<br/>Specifies how log markers / grids will remain visible on the map" infotext="Unit is seconds<br/>Specifies how log markers / grids will remain visible on the map"
@ -239,9 +259,9 @@ class SettingsController(AdminController):
), ),
Section( Section(
"WSJT-X settings", "WSJT-X settings",
TextInput("wsjt_queue_workers", "Number of WSJT decoding workers"), NumberInput("wsjt_queue_workers", "Number of WSJT decoding workers"),
TextInput("wsjt_queue_length", "Maximum length of WSJT job queue"), NumberInput("wsjt_queue_length", "Maximum length of WSJT job queue"),
TextInput( NumberInput(
"wsjt_decoding_depth", "wsjt_decoding_depth",
"WSJT decoding depth", "WSJT decoding depth",
infotext="A higher decoding depth will allow more results, but will also consume more cpu" infotext="A higher decoding depth will allow more results, but will also consume more cpu"