render inputs, mode dropdown
This commit is contained in:
parent
578f165bdc
commit
1112334ea8
@ -79,4 +79,9 @@ table.bookmarks .frequency {
|
|||||||
|
|
||||||
.wsjt-decoding-depths-table {
|
.wsjt-decoding-depths-table {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wsjt-decoding-depths-table td:first-child {
|
||||||
|
padding-left: 0;
|
||||||
}
|
}
|
@ -1,16 +1,32 @@
|
|||||||
$.fn.wsjtDecodingDepthsInput = function() {
|
$.fn.wsjtDecodingDepthsInput = function() {
|
||||||
var renderTable = function(data) {
|
function WsjtDecodingDepthRow(inputs, mode, value) {
|
||||||
var $table = $('<table class="table table-sm table-borderless wsjt-decoding-depths-table">');
|
this.el = $('<tr>');
|
||||||
$table.append($.map(data, function(value, mode){
|
this.modeInput = $(inputs.get(0)).clone();
|
||||||
return $('<tr><td>' + mode + '</td><td>' + value + '</td></tr>');
|
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 $('<td>').append(i);
|
||||||
}));
|
}));
|
||||||
return $table;
|
}
|
||||||
|
|
||||||
|
WsjtDecodingDepthRow.prototype.getEl = function() {
|
||||||
|
return this.el;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.each(function(){
|
this.each(function(){
|
||||||
var $input = $(this);
|
var $input = $(this);
|
||||||
var $el = $input.parent();
|
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 class="table table-sm table-borderless wsjt-decoding-depths-table">');
|
||||||
|
$table.append(rows.map(function(r) {
|
||||||
|
return r.getEl();
|
||||||
|
}));
|
||||||
$el.append($table);
|
$el.append($table);
|
||||||
});
|
});
|
||||||
};
|
};
|
@ -1,6 +1,6 @@
|
|||||||
from owrx.form import Input
|
from owrx.form import Input
|
||||||
from owrx.wsjt import Q65Mode, Q65Interval
|
from owrx.wsjt import Q65Mode, Q65Interval
|
||||||
from owrx.modes import Modes
|
from owrx.modes import Modes, WsjtMode
|
||||||
import json
|
import json
|
||||||
import html
|
import html
|
||||||
|
|
||||||
@ -57,12 +57,25 @@ class Q65ModeMatrix(Input):
|
|||||||
|
|
||||||
class WsjtDecodingDepthsInput(Input):
|
class WsjtDecodingDepthsInput(Input):
|
||||||
def render_input(self, value):
|
def render_input(self, value):
|
||||||
|
def render_mode(m):
|
||||||
|
return """
|
||||||
|
<option value={mode}>{name}</option>
|
||||||
|
""".format(
|
||||||
|
mode=m.modulation,
|
||||||
|
name=m.name,
|
||||||
|
)
|
||||||
|
|
||||||
return """
|
return """
|
||||||
<input type="hidden" class="{classes}" id="{id}" name="{id}" value="{value}">
|
<input type="hidden" class="{classes}" id="{id}" name="{id}" value="{value}">
|
||||||
|
<div class="inputs" style="display:none;">
|
||||||
|
<select class="form-control form-control-sm">{options}</select>
|
||||||
|
<input class="form-control form-control-sm" type="number" step="1">
|
||||||
|
</div>
|
||||||
""".format(
|
""".format(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
classes=self.input_classes(),
|
classes=self.input_classes(),
|
||||||
value=html.escape(json.dumps(value)),
|
value=html.escape(json.dumps(value)),
|
||||||
|
options="".join(render_mode(m) for m in Modes.getAvailableModes() if isinstance(m, WsjtMode)),
|
||||||
)
|
)
|
||||||
|
|
||||||
def input_classes(self):
|
def input_classes(self):
|
||||||
|
@ -51,6 +51,15 @@ class DigitalMode(Mode):
|
|||||||
return Modes.findByModulation(self.underlying[0]).get_modulation()
|
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):
|
class Modes(object):
|
||||||
mappings = [
|
mappings = [
|
||||||
AnalogMode("nfm", "FM", bandpass=Bandpass(-4000, 4000)),
|
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),
|
AnalogMode("drm", "DRM", bandpass=Bandpass(-5000, 5000), requirements=["drm"], squelch=False),
|
||||||
DigitalMode("bpsk31", "BPSK31", underlying=["usb"]),
|
DigitalMode("bpsk31", "BPSK31", underlying=["usb"]),
|
||||||
DigitalMode("bpsk63", "BPSK63", underlying=["usb"]),
|
DigitalMode("bpsk63", "BPSK63", underlying=["usb"]),
|
||||||
DigitalMode(
|
WsjtMode("ft8", "FT8"),
|
||||||
"ft8", "FT8", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True
|
WsjtMode("ft4", "FT4"),
|
||||||
),
|
WsjtMode("jt65", "JT65"),
|
||||||
DigitalMode(
|
WsjtMode("jt9", "JT9"),
|
||||||
"ft4", "FT4", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True
|
WsjtMode("wspr", "WSPR", bandpass=Bandpass(1350, 1650)),
|
||||||
),
|
WsjtMode("fst4", "FST4", requirements=["wsjt-x-2-3"]),
|
||||||
DigitalMode(
|
WsjtMode("fst4w", "FST4W", bandpass=Bandpass(1350, 1650), requirements=["wsjt-x-2-3"]),
|
||||||
"jt65", "JT65", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["wsjt-x"], service=True
|
WsjtMode("q65", "Q65", requirements=["wsjt-x-2-4"]),
|
||||||
),
|
|
||||||
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
|
|
||||||
),
|
|
||||||
DigitalMode(
|
DigitalMode(
|
||||||
"js8", "JS8Call", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["js8call"], service=True
|
"js8", "JS8Call", underlying=["usb"], bandpass=Bandpass(0, 3000), requirements=["js8call"], service=True
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user