Skip to content

Commit

Permalink
Added device enable/disable option.
Browse files Browse the repository at this point in the history
  • Loading branch information
shajen committed Nov 2, 2023
1 parent 178066f commit ace4fca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion monitor/static/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function onConnect(client) {
for (const gain of devices[device_id]['gains']) {
gains[gain['name']] = gain['value']
}
let range = { "device_serial": device_id, "device_gains": gains, "ranges": devices[device_id]["ranges"] };
let range = { "device_enabled": devices[device_id]["enabled"], "device_serial": device_id, "device_gains": gains, "ranges": devices[device_id]["ranges"] };
ranges.push(range);
}
let config = scanners[scanner_id]['config'];
Expand Down Expand Up @@ -144,6 +144,7 @@ function selectScanner(id) {
scanners[id]['config']['ignored_frequencies'].push({ 'frequency': 0, 'bandwidth': 0 });
$("#save").prop("disabled", false);
});
$("#device_enabled").prop("disabled", true);
$("#new_scanned_frequency").prop("disabled", true);
}

Expand Down Expand Up @@ -206,6 +207,13 @@ function addIgnoredFrequency(id, frequency, bandwidth) {
}

function selectDevice(id) {
$("#device_enabled").prop("checked", devices[id]['enabled']);
$("#device_enabled").prop("disabled", false);
$("#device_enabled").unbind("click");
$("#device_enabled").click(function () {
devices[id]['enabled'] = $(this).is(':checked');
$("#save").prop("disabled", false);
});
$("#scanned_frequencies").find("tr:gt(0)").remove();
$("#gains").find("tr:gt(0)").remove();
devices[id]['ranges'] = devices[id]['ranges'].sort((a, b) => a['start'] > b['start']);
Expand Down
7 changes: 6 additions & 1 deletion sdr/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ <h5>Other</h5>
</div>
</div>
<div class="col">
<h5>Device enabled</h5>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="device_enabled" disabled="disabled"
autocomplete="off">
</div>
<h5>Scanned frequencies</h5>
<table class="table table-striped table-bordered table-hover" id="scanned_frequencies">
<tr>
Expand Down Expand Up @@ -196,4 +201,4 @@ <h5>Gains</h5>
</div>
<div class="col-2"></div>
</div>
{% endblock %}
{% endblock %}

0 comments on commit ace4fca

Please sign in to comment.