waterfall config fine-adjustments
* hide the waterfall colors input when pre-defined color scheme is selected * skip unparseable lines on custom color input * fallback to black and white if custom color config is unusable * always use the waterfall classes when sending changes to the client
This commit is contained in:
parent
9aebeb51f8
commit
691d88f841
11
htdocs/lib/settings/WaterfallDropdown.js
Normal file
11
htdocs/lib/settings/WaterfallDropdown.js
Normal file
@ -0,0 +1,11 @@
|
||||
$.fn.waterfallDropdown = function(){
|
||||
this.each(function(){
|
||||
var $select = $(this);
|
||||
var setVisibility = function() {
|
||||
var show = $select.val() === 'CUSTOM';
|
||||
$('#waterfall_colors').parents('.form-group')[show ? 'show' : 'hide']();
|
||||
}
|
||||
$select.on('change', setVisibility);
|
||||
setVisibility();
|
||||
})
|
||||
}
|
@ -4,4 +4,5 @@ $(function(){
|
||||
$('.imageupload').imageUpload();
|
||||
$('.bookmarks').bookmarktable();
|
||||
$('.wsjt-decoding-depths').wsjtDecodingDepthsInput();
|
||||
$('#waterfall_scheme').waterfallDropdown();
|
||||
});
|
@ -207,8 +207,8 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
|
||||
def writeConfig(changes):
|
||||
# TODO it would be nicer to have all options available and switchable in the client
|
||||
# this restores the existing functionality for now, but there is lots of potential
|
||||
if "waterfall_scheme" in changes:
|
||||
scheme = WaterfallOptions(changes["waterfall_scheme"]).instantiate()
|
||||
if "waterfall_scheme" in changes or "waterfall_colors" in changes:
|
||||
scheme = WaterfallOptions(globalConfig["waterfall_scheme"]).instantiate()
|
||||
changes["waterfall_colors"] = scheme.getColors()
|
||||
self.write_config(changes)
|
||||
|
||||
|
@ -151,6 +151,7 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController):
|
||||
"lib/settings/ImageUpload.js",
|
||||
"lib/settings/BookmarkTable.js",
|
||||
"lib/settings/WsjtDecodingDepthsInput.js",
|
||||
"lib/settings/WaterfallDropdown.js",
|
||||
"settings.js",
|
||||
],
|
||||
}
|
||||
|
@ -76,10 +76,14 @@ class WaterfallColorsConverter(Converter):
|
||||
|
||||
def convert_from_form(self, value):
|
||||
def parseString(s):
|
||||
if s.startswith("#"):
|
||||
return int(s[1:], 16)
|
||||
# int() with base 0 can accept "0x" prefixed hex strings, or int numbers
|
||||
return int(s, 0)
|
||||
try:
|
||||
if s.startswith("#"):
|
||||
return int(s[1:], 16)
|
||||
# int() with base 0 can accept "0x" prefixed hex strings, or int numbers
|
||||
return int(s, 0)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
# \r\n or \n? this should work with both.
|
||||
return [parseString(v.strip("\r ")) for v in value.split("\n")]
|
||||
values = [parseString(v.strip("\r ")) for v in value.split("\n")]
|
||||
return [v for v in values if v is not None]
|
||||
|
@ -287,7 +287,12 @@ class Ha7ilmWaterfall(Waterfall):
|
||||
class CustomWaterfall(Waterfall):
|
||||
def __init__(self):
|
||||
config = Config.get()
|
||||
super().__init__(config["waterfall_colors"])
|
||||
if "waterfall_colors" in config and config["waterfall_colors"]:
|
||||
colors = config["waterfall_colors"]
|
||||
else:
|
||||
# fallback: black and white
|
||||
colors = [0x000000, 0xffffff]
|
||||
super().__init__(colors)
|
||||
|
||||
|
||||
class WaterfallOptions(DropdownEnum):
|
||||
|
Loading…
Reference in New Issue
Block a user