diff --git a/htdocs/css/admin.css b/htdocs/css/admin.css index dc0f952..a632da6 100644 --- a/htdocs/css/admin.css +++ b/htdocs/css/admin.css @@ -79,4 +79,9 @@ table.bookmarks .frequency { .wsjt-decoding-depths-table { width: auto; + margin: 0; +} + +.wsjt-decoding-depths-table td:first-child { + padding-left: 0; } \ No newline at end of file diff --git a/htdocs/lib/settings/WsjtDecodingDepthsInput.js b/htdocs/lib/settings/WsjtDecodingDepthsInput.js index f49aa04..0383630 100644 --- a/htdocs/lib/settings/WsjtDecodingDepthsInput.js +++ b/htdocs/lib/settings/WsjtDecodingDepthsInput.js @@ -1,16 +1,32 @@ $.fn.wsjtDecodingDepthsInput = function() { - var renderTable = function(data) { - var $table = $(''); - $table.append($.map(data, function(value, mode){ - return $(''); + function WsjtDecodingDepthRow(inputs, mode, value) { + this.el = $(''); + this.modeInput = $(inputs.get(0)).clone(); + this.modeInput.val(mode); + this.valueInput = $(inputs.get(1)).clone(); + this.valueInput.val(value); + this.el.append([this.modeInput, this.valueInput].map(function(i) { + return $('
' + mode + '' + value + '
').append(i); })); - return $table; + } + + WsjtDecodingDepthRow.prototype.getEl = function() { + return this.el; } this.each(function(){ var $input = $(this); var $el = $input.parent(); - var $table = renderTable(JSON.parse($input.val())); + var $inputs = $el.find('.inputs') + var inputs = $inputs.find('input, select'); + $inputs.remove(); + var rows = $.map(JSON.parse($input.val()), function(value, mode) { + return new WsjtDecodingDepthRow(inputs, mode, value); + }); + var $table = $(''); + $table.append(rows.map(function(r) { + return r.getEl(); + })); $el.append($table); }); }; \ No newline at end of file diff --git a/owrx/form/wsjt.py b/owrx/form/wsjt.py index dd3827c..ec79654 100644 --- a/owrx/form/wsjt.py +++ b/owrx/form/wsjt.py @@ -1,6 +1,6 @@ from owrx.form import Input from owrx.wsjt import Q65Mode, Q65Interval -from owrx.modes import Modes +from owrx.modes import Modes, WsjtMode import json import html @@ -57,12 +57,25 @@ class Q65ModeMatrix(Input): class WsjtDecodingDepthsInput(Input): def render_input(self, value): + def render_mode(m): + return """ + + """.format( + mode=m.modulation, + name=m.name, + ) + return """ + """.format( id=self.id, classes=self.input_classes(), value=html.escape(json.dumps(value)), + options="".join(render_mode(m) for m in Modes.getAvailableModes() if isinstance(m, WsjtMode)), ) def input_classes(self): diff --git a/owrx/modes.py b/owrx/modes.py index 0df4747..869bf49 100644 --- a/owrx/modes.py +++ b/owrx/modes.py @@ -51,6 +51,15 @@ class DigitalMode(Mode): return Modes.findByModulation(self.underlying[0]).get_modulation() +class WsjtMode(DigitalMode): + def __init__(self, modulation, name, bandpass=None, requirements=None): + if bandpass is None: + bandpass = Bandpass(0, 3000) + if requirements is None: + requirements = ["wsjt-x"] + super().__init__(modulation, name, ["usb"], bandpass=bandpass, requirements=requirements, service=True) + + class Modes(object): mappings = [ AnalogMode("nfm", "FM", bandpass=Bandpass(-4000, 4000)), @@ -72,35 +81,14 @@ class Modes(object): AnalogMode("drm", "DRM", bandpass=Bandpass(-5000, 5000), requirements=["drm"], squelch=False), DigitalMode("bpsk31", "BPSK31", underlying=["usb"]), DigitalMode("bpsk63", "BPSK63", underlying=["usb"]), - DigitalMode( - "ft8", "FT8", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True - ), - DigitalMode( - "ft4", "FT4", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True - ), - DigitalMode( - "jt65", "JT65", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True - ), - DigitalMode( - "jt9", "JT9", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True - ), - DigitalMode( - "wspr", "WSPR", underlying=["usb"], bandpass=Bandpass(1350, 1650), requirements=["wsjt-x"], service=True - ), - DigitalMode( - "fst4", "FST4", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x-2-3"], service=True - ), - DigitalMode( - "fst4w", - "FST4W", - underlying=["usb"], - bandpass=Bandpass(1350, 1650), - requirements=["wsjt-x-2-3"], - service=True, - ), - DigitalMode( - "q65", "Q65", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x-2-4"], service=True - ), + WsjtMode("ft8", "FT8"), + WsjtMode("ft4", "FT4"), + WsjtMode("jt65", "JT65"), + WsjtMode("jt9", "JT9"), + WsjtMode("wspr", "WSPR", bandpass=Bandpass(1350, 1650)), + WsjtMode("fst4", "FST4", requirements=["wsjt-x-2-3"]), + WsjtMode("fst4w", "FST4W", bandpass=Bandpass(1350, 1650), requirements=["wsjt-x-2-3"]), + WsjtMode("q65", "Q65", requirements=["wsjt-x-2-4"]), DigitalMode( "js8", "JS8Call", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["js8call"], service=True ),