diff --git a/htdocs/css/admin.css b/htdocs/css/admin.css index aeaf728..dc0f952 100644 --- a/htdocs/css/admin.css +++ b/htdocs/css/admin.css @@ -75,4 +75,8 @@ table.bookmarks .frequency { .actions .btn { width: 100%; +} + +.wsjt-decoding-depths-table { + width: auto; } \ No newline at end of file diff --git a/htdocs/lib/settings/MapInput.js b/htdocs/lib/settings/MapInput.js new file mode 100644 index 0000000..a35b8a9 --- /dev/null +++ b/htdocs/lib/settings/MapInput.js @@ -0,0 +1,23 @@ +$.fn.mapInput = function() { + this.each(function(el) { + var $el = $(this); + var field_id = $el.attr("for"); + var $lat = $('#' + field_id + '-lat'); + var $lon = $('#' + field_id + '-lon'); + $.getScript('https://maps.googleapis.com/maps/api/js?key=' + $el.data('key')).done(function(){ + $el.css('height', '200px'); + var lp = new locationPicker($el.get(0), { + lat: parseFloat($lat.val()), + lng: parseFloat($lon.val()) + }, { + zoom: 7 + }); + + google.maps.event.addListener(lp.map, 'idle', function(event){ + var pos = lp.getMarkerPosition(); + $lat.val(pos.lat); + $lon.val(pos.lng); + }); + }); + }); +}; \ No newline at end of file diff --git a/htdocs/lib/settings/WsjtDecodingDepthsInput.js b/htdocs/lib/settings/WsjtDecodingDepthsInput.js new file mode 100644 index 0000000..f49aa04 --- /dev/null +++ b/htdocs/lib/settings/WsjtDecodingDepthsInput.js @@ -0,0 +1,16 @@ +$.fn.wsjtDecodingDepthsInput = function() { + var renderTable = function(data) { + var $table = $(''); + $table.append($.map(data, function(value, mode){ + return $(''); + })); + return $table; + } + + this.each(function(){ + var $input = $(this); + var $el = $input.parent(); + var $table = renderTable(JSON.parse($input.val())); + $el.append($table); + }); +}; \ No newline at end of file diff --git a/htdocs/settings.js b/htdocs/settings.js index bddbf16..072ae79 100644 --- a/htdocs/settings.js +++ b/htdocs/settings.js @@ -1,27 +1,7 @@ $(function(){ - $(".map-input").each(function(el) { - var $el = $(this); - var field_id = $el.attr("for"); - var $lat = $('#' + field_id + '-lat'); - var $lon = $('#' + field_id + '-lon'); - $.getScript("https://maps.googleapis.com/maps/api/js?key=" + $el.data("key")).done(function(){ - $el.css("height", "200px"); - var lp = new locationPicker($el.get(0), { - lat: parseFloat($lat.val()), - lng: parseFloat($lon.val()) - }, { - zoom: 7 - }); - - google.maps.event.addListener(lp.map, 'idle', function(event){ - var pos = lp.getMarkerPosition(); - $lat.val(pos.lat); - $lon.val(pos.lng); - }); - }); - }); - - $(".sdrdevice").sdrdevice(); - $(".imageupload").imageUpload(); - $(".bookmarks").bookmarktable(); + $('.map-input').mapInput(); + $('.sdrdevice').sdrdevice(); + $('.imageupload').imageUpload(); + $('.bookmarks').bookmarktable(); + $('.wsjt-decoding-depths').wsjtDecodingDepthsInput(); }); \ No newline at end of file diff --git a/owrx/controllers/assets.py b/owrx/controllers/assets.py index daeaddd..61483b7 100644 --- a/owrx/controllers/assets.py +++ b/owrx/controllers/assets.py @@ -147,8 +147,10 @@ class CompiledAssetsController(GzipMixin, ModificationAwareController): "lib/Header.js", "lib/settings/Input.js", "lib/settings/SdrDevice.js", + "lib/settings/MapInput.js", "lib/settings/ImageUpload.js", "lib/settings/BookmarkTable.js", + "lib/settings/WsjtDecodingDepthsInput.js", "settings.js", ], } diff --git a/owrx/controllers/settings/decoding.py b/owrx/controllers/settings/decoding.py index a40edd9..4ef5428 100644 --- a/owrx/controllers/settings/decoding.py +++ b/owrx/controllers/settings/decoding.py @@ -1,7 +1,7 @@ from owrx.controllers.settings import SettingsFormController, Section from owrx.form import CheckboxInput, NumberInput, DropdownInput, Js8ProfileCheckboxInput, MultiCheckboxInput, Option from owrx.form.wfm import WfmTauValues -from owrx.form.wsjt import Q65ModeMatrix +from owrx.form.wsjt import Q65ModeMatrix, WsjtDecodingDepthsInput from owrx.wsjt import Fst4Profile, Fst4wProfile @@ -55,6 +55,10 @@ class DecodingSettingsController(SettingsFormController): "Default WSJT decoding depth", infotext="A higher decoding depth will allow more results, but will also consume more cpu", ), + WsjtDecodingDepthsInput( + "wsjt_decoding_depths", + "Individual decoding depths", + ), NumberInput( "js8_decoding_depth", "Js8Call decoding depth", diff --git a/owrx/form/wsjt.py b/owrx/form/wsjt.py index 1c77a3c..dd3827c 100644 --- a/owrx/form/wsjt.py +++ b/owrx/form/wsjt.py @@ -1,5 +1,8 @@ from owrx.form import Input from owrx.wsjt import Q65Mode, Q65Interval +from owrx.modes import Modes +import json +import html class Q65ModeMatrix(Input): @@ -50,3 +53,17 @@ class Q65ModeMatrix(Input): if in_response(mode, interval) ], } + + +class WsjtDecodingDepthsInput(Input): + def render_input(self, value): + return """ + + """.format( + id=self.id, + classes=self.input_classes(), + value=html.escape(json.dumps(value)), + ) + + def input_classes(self): + return super().input_classes() + " wsjt-decoding-depths"
' + mode + '' + value + '