mirror of
https://github.com/jketterl/openwebrx.git
synced 2025-12-06 07:12:09 +01:00
Merge branch 'develop' into active_arrays
This commit is contained in:
commit
eb618a6544
|
|
@ -162,7 +162,11 @@ class Migrator(object):
|
|||
def migrate(config):
|
||||
version = config["version"] if "version" in config else 1
|
||||
if version == Migrator.currentVersion:
|
||||
return config
|
||||
return
|
||||
elif version > Migrator.currentVersion:
|
||||
raise ValueError(
|
||||
"Configuration version is too high (current: {}, found: {})".format(Migrator.currentVersion, version)
|
||||
)
|
||||
|
||||
logger.debug("migrating config from version %i", version)
|
||||
migrators = [Migrator.migrators[i] for i in range(version, Migrator.currentVersion)]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from owrx.form.input import (
|
|||
Option,
|
||||
)
|
||||
from owrx.form.input.converter import WaterfallColorsConverter, IntConverter
|
||||
from owrx.form.input.receiverid import ReceiverKeysConverter
|
||||
from owrx.form.input.receiverid import ReceiverKeysInput
|
||||
from owrx.form.input.gfx import AvatarInput, TopPhotoInput
|
||||
from owrx.form.input.device import WaterfallLevelsInput, WaterfallAutoLevelsInput
|
||||
from owrx.form.input.location import LocationInput
|
||||
|
|
@ -75,12 +75,9 @@ class GeneralSettingsController(SettingsFormController):
|
|||
),
|
||||
Section(
|
||||
"Receiver listings",
|
||||
TextAreaInput(
|
||||
ReceiverKeysInput(
|
||||
"receiver_keys",
|
||||
"Receiver keys",
|
||||
converter=ReceiverKeysConverter(),
|
||||
infotext="Put the keys you receive on listing sites (e.g. "
|
||||
+ '<a href="https://www.receiverbook.de" target="_blank">Receiverbook</a>) here, one per line',
|
||||
),
|
||||
),
|
||||
Section(
|
||||
|
|
|
|||
|
|
@ -163,14 +163,19 @@ class FloatInput(NumberInput):
|
|||
class TextAreaInput(Input):
|
||||
def render_input(self, value, errors):
|
||||
return """
|
||||
<textarea class="{classes}" id="{id}" name="{id}" style="height:200px;" {disabled}>{value}</textarea>
|
||||
<textarea {properties}>{value}</textarea>
|
||||
""".format(
|
||||
id=self.id,
|
||||
classes=self.input_classes(errors),
|
||||
properties=self.render_input_properties(value, errors),
|
||||
value=value,
|
||||
disabled="disabled" if self.disabled else "",
|
||||
)
|
||||
|
||||
def input_properties(self, value, errors):
|
||||
props = super().input_properties(value, errors)
|
||||
props["style"] = "height:200px;"
|
||||
# value works differently on textareas
|
||||
del props["value"]
|
||||
return props
|
||||
|
||||
|
||||
class CheckboxInput(Input):
|
||||
def __init__(self, id, checkboxText, infotext=None, converter: Converter = None):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from owrx.form.input import TextAreaInput
|
||||
from owrx.form.input.converter import Converter
|
||||
|
||||
|
||||
|
|
@ -7,4 +8,26 @@ class ReceiverKeysConverter(Converter):
|
|||
|
||||
def convert_from_form(self, value):
|
||||
# \r\n or \n? this should work with both.
|
||||
return [v.strip("\r ") for v in value.split("\n")]
|
||||
stripped = [v.strip("\r ") for v in value.split("\n")]
|
||||
# omit empty lines
|
||||
return [v for v in stripped if v]
|
||||
|
||||
|
||||
class ReceiverKeysInput(TextAreaInput):
|
||||
def __init__(self, id, label):
|
||||
super().__init__(
|
||||
id,
|
||||
label,
|
||||
infotext="Put the keys you receive on listing sites (e.g. "
|
||||
+ '<a href="https://www.receiverbook.de" target="_blank">Receiverbook</a>) here, one per line',
|
||||
)
|
||||
|
||||
def input_properties(self, value, errors):
|
||||
props = super().input_properties(value, errors)
|
||||
# disable word wrap on the textarea.
|
||||
# why? keys are longer than the input, and word wrap makes the "one per line" instruction confusing.
|
||||
props["wrap"] = "off"
|
||||
return props
|
||||
|
||||
def defaultConverter(self):
|
||||
return ReceiverKeysConverter()
|
||||
|
|
|
|||
Loading…
Reference in a new issue