1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

tunnel support, imperial units, admin ui bugfixes

This commit is contained in:
NoobishSVK
2024-09-26 15:07:40 +02:00
parent e0c085b789
commit 431dc7cedf
9 changed files with 124 additions and 64 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@ node_modules/
/*.json
/serverlog.txt
/web/js/plugins/
/libraries/**
/plugins/*
!/plugins/example/frontend.js
!/plugins/example.js

View File

@@ -1,6 +1,6 @@
{
"name": "fm-dx-webserver",
"version": "1.3.0.1",
"version": "1.3.1",
"description": "FM DX Webserver",
"main": "index.js",
"scripts": {

View File

@@ -3,7 +3,7 @@
height: 48px;
background: var(--color-4);
position: relative;
margin-right: 20px;
margin: auto;
border-radius: 15px;
/*border-bottom: 4px solid var(--color-2);*/
}
@@ -34,7 +34,7 @@
.dropdown input {
width: 100%;
height: 100%;
padding: 10px;
padding: 10px 20px 10px 10px;
cursor: pointer;
border: none;
user-select: none;

View File

@@ -92,7 +92,7 @@
<div class="flex-container">
<div class="panel-33 hover-brighten tooltip" id="pi-code-container" data-tooltip="Clicking on the PI code will show the current station on a map.">
<h2>PI CODE</h2>
<h2 class="signal-heading">PI CODE</h2>
<div class="text-small text-gray highest-signal-container">
<span id="data-regular-pi">&nbsp;</span>
</div>
@@ -139,7 +139,7 @@
<% } %>
<div class="panel-50 no-bg br-0 h-100 m-0 button-eq">
<% if (device == 'tef') { %><button id="data-eq" style="border-radius: 15px 0px 0px 15px;" class="tooltip" aria-label="EQ Filter" data-tooltip="<strong>The cEQ filter can reduce bandwidth below 56 KHz.</strong><br><br>Useful for weak stations next to strong ones,<br>although it may pick up more interference."><span class="text-bold">cEQ</span></button><% } %>
<% if (device == 'tef') { %><button id="data-eq" style="border-radius: 15px 0px 0px 15px;" class="tooltip" aria-label="EQ Filter" data-tooltip="<strong>The cEQ filter can reduce bandwidth below 56 kHz.</strong><br><br>Useful for weak stations next to strong ones,<br>although it may pick up more interference."><span class="text-bold">cEQ</span></button><% } %>
<% if (device == 'xdr') { %><button id="data-eq" style="border-radius: 15px 0px 0px 15px;" class="tooltip" aria-label="RF+ Filter" data-tooltip="<strong>The RF+ filter increases gain by 5dB</strong>"><span class="text-bold">RF+</span></button><% } %>
</div>
<div class="panel-50 no-bg br-0 h-100 m-0 button-ims">
@@ -165,21 +165,21 @@
<input type="text" placeholder="Auto BW" readonly tabindex="0">
<ul class="options open-top" tabindex="-1">
<li data-value="0" class="option" tabindex="0">Auto</li>
<li data-value="56000" class="option" tabindex="0">56 KHz</li>
<li data-value="64000" class="option" tabindex="0">64 KHz</li>
<li data-value="72000" class="option" tabindex="0">72 KHz</li>
<li data-value="84000" class="option" tabindex="0">84 KHz</li>
<li data-value="97000" class="option" tabindex="0">97 KHz</li>
<li data-value="114000" class="option" tabindex="0">114 KHz</li>
<li data-value="133000" class="option" tabindex="0">133 KHz</li>
<li data-value="151000" class="option" tabindex="0">151 KHz</li>
<li data-value="184000" class="option" tabindex="0">184 KHz</li>
<li data-value="200000" class="option" tabindex="0">200 KHz</li>
<li data-value="217000" class="option" tabindex="0">217 KHz</li>
<li data-value="236000" class="option" tabindex="0">236 KHz</li>
<li data-value="254000" class="option" tabindex="0">254 KHz</li>
<li data-value="287000" class="option" tabindex="0">287 KHz</li>
<li data-value="311000" class="option" tabindex="0">311 KHz</li>
<li data-value="56000" class="option" tabindex="0">56 kHz</li>
<li data-value="64000" class="option" tabindex="0">64 kHz</li>
<li data-value="72000" class="option" tabindex="0">72 kHz</li>
<li data-value="84000" class="option" tabindex="0">84 kHz</li>
<li data-value="97000" class="option" tabindex="0">97 kHz</li>
<li data-value="114000" class="option" tabindex="0">114 kHz</li>
<li data-value="133000" class="option" tabindex="0">133 kHz</li>
<li data-value="151000" class="option" tabindex="0">151 kHz</li>
<li data-value="184000" class="option" tabindex="0">184 kHz</li>
<li data-value="200000" class="option" tabindex="0">200 kHz</li>
<li data-value="217000" class="option" tabindex="0">217 kHz</li>
<li data-value="236000" class="option" tabindex="0">236 kHz</li>
<li data-value="254000" class="option" tabindex="0">254 kHz</li>
<li data-value="287000" class="option" tabindex="0">287 kHz</li>
<li data-value="311000" class="option" tabindex="0">311 kHz</li>
</ul>
</div>
<% } %>
@@ -189,22 +189,22 @@
<input type="text" placeholder="Auto BW" readonly tabindex="0">
<ul class="options open-top" tabindex="-1">
<li data-value="0" data-value2="-1" class="option" tabindex="0">Auto</li>
<li data-value="55000" data-value2="0" class="option" tabindex="0">55 KHz</li>
<li data-value="73000" data-value2="1" class="option" tabindex="0">73 KHz</li>
<li data-value="90000" data-value2="2" class="option" tabindex="0">90 KHz</li>
<li data-value="108000" data-value2="3" class="option" tabindex="0">108 KHz</li>
<li data-value="125000" data-value2="4" class="option" tabindex="0">125 KHz</li>
<li data-value="142000" data-value2="5" class="option" tabindex="0">142 KHz</li>
<li data-value="159000" data-value2="6" class="option" tabindex="0">159 KHz</li>
<li data-value="177000" data-value2="7" class="option" tabindex="0">177 KHz</li>
<li data-value="194000" data-value2="8" class="option" tabindex="0">194 KHz</li>
<li data-value="211000" data-value2="9" class="option" tabindex="0">211 KHz</li>
<li data-value="229000" data-value2="10" class="option" tabindex="0">229 KHz</li>
<li data-value="246000" data-value2="11" class="option" tabindex="0">246 KHz</li>
<li data-value="263000" data-value2="12" class="option" tabindex="0">263 KHz</li>
<li data-value="281000" data-value2="13" class="option" tabindex="0">281 KHz</li>
<li data-value="298000" data-value2="14" class="option" tabindex="0">298 KHz</li>
<li data-value="309000" data-value2="15" class="option" tabindex="0">309 KHz</li>
<li data-value="55000" data-value2="0" class="option" tabindex="0">55 kHz</li>
<li data-value="73000" data-value2="1" class="option" tabindex="0">73 kHz</li>
<li data-value="90000" data-value2="2" class="option" tabindex="0">90 kHz</li>
<li data-value="108000" data-value2="3" class="option" tabindex="0">108 kHz</li>
<li data-value="125000" data-value2="4" class="option" tabindex="0">125 kHz</li>
<li data-value="142000" data-value2="5" class="option" tabindex="0">142 kHz</li>
<li data-value="159000" data-value2="6" class="option" tabindex="0">159 kHz</li>
<li data-value="177000" data-value2="7" class="option" tabindex="0">177 kHz</li>
<li data-value="194000" data-value2="8" class="option" tabindex="0">194 kHz</li>
<li data-value="211000" data-value2="9" class="option" tabindex="0">211 kHz</li>
<li data-value="229000" data-value2="10" class="option" tabindex="0">229 kHz</li>
<li data-value="246000" data-value2="11" class="option" tabindex="0">246 kHz</li>
<li data-value="263000" data-value2="12" class="option" tabindex="0">263 kHz</li>
<li data-value="281000" data-value2="13" class="option" tabindex="0">281 kHz</li>
<li data-value="298000" data-value2="14" class="option" tabindex="0">298 kHz</li>
<li data-value="309000" data-value2="15" class="option" tabindex="0">309 kHz</li>
</ul>
</div>
<% } %>
@@ -214,19 +214,19 @@
<input type="text" placeholder="Auto BW" readonly tabindex="0">
<ul class="options open-top" tabindex="-1">
<li data-value="0" class="option" tabindex="0">Auto</li>
<li data-value="4000" class="option" tabindex="0">4 KHz</li>
<li data-value="8000" class="option" tabindex="0">8 KHz</li>
<li data-value="10000" class="option" tabindex="0">10 KHz</li>
<li data-value="20000" class="option" tabindex="0">20 KHz</li>
<li data-value="30000" class="option" tabindex="0">30 KHz</li>
<li data-value="50000" class="option" tabindex="0">50 KHz</li>
<li data-value="75000" class="option" tabindex="0">75 KHz</li>
<li data-value="100000" class="option" tabindex="0">100 KHz</li>
<li data-value="125000" class="option" tabindex="0">125 KHz</li>
<li data-value="150000" class="option" tabindex="0">150 KHz</li>
<li data-value="175000" class="option" tabindex="0">175 KHz</li>
<li data-value="200000" class="option" tabindex="0">200 KHz</li>
<li data-value="225000" class="option" tabindex="0">225 KHz</li>
<li data-value="4000" class="option" tabindex="0">4 kHz</li>
<li data-value="8000" class="option" tabindex="0">8 kHz</li>
<li data-value="10000" class="option" tabindex="0">10 kHz</li>
<li data-value="20000" class="option" tabindex="0">20 kHz</li>
<li data-value="30000" class="option" tabindex="0">30 kHz</li>
<li data-value="50000" class="option" tabindex="0">50 kHz</li>
<li data-value="75000" class="option" tabindex="0">75 kHz</li>
<li data-value="100000" class="option" tabindex="0">100 kHz</li>
<li data-value="125000" class="option" tabindex="0">125 kHz</li>
<li data-value="150000" class="option" tabindex="0">150 kHz</li>
<li data-value="175000" class="option" tabindex="0">175 kHz</li>
<li data-value="200000" class="option" tabindex="0">200 kHz</li>
<li data-value="225000" class="option" tabindex="0">225 kHz</li>
</ul>
</div>
<% } %>
@@ -260,7 +260,7 @@
<span id="data-station-city" style="font-size: 16px;"></span> <span class="text-small">[<span id="data-station-itu"></span>]</span>
</h4>
<span class="text-small">
<span id="data-station-erp"></span> kW [<span id="data-station-pol"></span>] <span class="text-gray">•</span> <span id="data-station-distance"></span> km <span class="text-gray">•</span> <span id="data-station-azimuth"></span>
<span id="data-station-erp"></span> kW [<span id="data-station-pol"></span>] <span class="text-gray">•</span> <span id="data-station-distance"></span> <span class="text-gray">•</span> <span id="data-station-azimuth"></span>
</span>
</div>
</div>
@@ -362,6 +362,10 @@
<input type="checkbox" tabindex="0" id="ps-underscores" aria-label="Add underscores to RDS PS">
<label for="ps-underscores" class="tooltip" data-tooltip="Enabling this option replaces spaces in RDS PS with underscores."><i class="fa-solid fa-toggle-off m-right-10"></i> RDS PS Underscores</label>
</div>
<div class="form-group checkbox">
<input type="checkbox" tabindex="0" id="imperial-units" aria-label="Imperial units">
<label for="imperial-units" class="tooltip" data-tooltip="Enabling this option will show miles in distances instead of kilometers."><i class="fa-solid fa-toggle-off m-right-10"></i> Imperial Units</label>
</div>
<div class="form-group bottom-20 hide-desktop" style="float: none;">
<label for="users-online"><i class="fa-solid fa-user"></i> Users online</label>
@@ -461,7 +465,7 @@
<strong>Support</strong> the developer!
</div>
<div class="hover-brighten br-0 bg-color-1" style="height: 50px;padding:12px;" onclick="window.open('https://discord.com/invite/ZAVNdS74mC')">
Join our <strong>OpenRadio Discord</strong> community!
Join our <strong>FMDX.org Discord</strong> community!
</div>
</div>
</div>

View File

@@ -80,6 +80,10 @@ function submitData() {
const fmlistIntegration = $("#fmlist-integration").is(":checked") || false;
const fmlistOmid = $('#fmlist-omid').val();
const tunnelUsername = $('#tunnel-username').val();
const tunnelSubdomain = $('#tunnel-subdomain').val();
const tunnelToken = $('#tunnel-token').val();
const publicTuner = $("#tuner-public").is(":checked");
const lockToAdmin = $("#tuner-lock").is(":checked");
const autoShutdown = $("#shutdown-tuner").is(":checked") || false;
@@ -150,6 +154,13 @@ function submitData() {
fmlistIntegration,
fmlistOmid,
},
tunnel: {
enabled: tunnelEnabled,
username: tunnelUsername,
token: tunnelToken,
lowLatencyMode: tunnelLowLatency,
subdomain: tunnelSubdomain,
},
plugins,
device,
publicTuner,
@@ -315,8 +326,15 @@ function submitData() {
}
}
$("#fmlist-integration").prop("checked", data.extras ? data.extras?.fmlistIntegration : "true");
$("#fmlist-integration").prop("checked", !!(data.extras && data.extras?.fmlistIntegration));
$('#fmlist-omid').val(data.extras?.fmlistOmid);
$("#tunnel-enable").prop("checked", !!(data.tunnel && data.tunnel?.enabled));
$("#tunnel-lowlatency").prop("checked", !!(data.tunnel && data.tunnel?.lowLatencyMode));
console.log((data.tunnel && data.tunnel?.enabled) ? data.tunnel?.enabled : "false");
$('#tunnel-token').val(data.tunnel?.token);
$('#tunnel-subdomain').val(data.tunnel?.subdomain);
$('#tunnel-username').val(data.tunnel?.username);
})
.catch(error => {
console.error('Error fetching data:', error.message);

View File

@@ -1,9 +1,9 @@
var currentDate = new Date('Sep 15, 2024 15:00:00');
var currentDate = new Date('Sep 26, 2024 12:00:00');
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1; // Months are zero-indexed, so add 1
var year = currentDate.getFullYear();
var formattedDate = day + '/' + month + '/' + year;
var currentVersion = 'v1.3.0.1 [' + formattedDate + ']';
var currentVersion = 'v1.3.1 [' + formattedDate + ']';
getInitialSettings();
removeUrlParameters(); // Call this function to remove URL parameters

View File

@@ -676,7 +676,7 @@ async function copyTx() {
const stationErp = $('#data-station-erp').text();
try {
await copyToClipboard(frequency + " - " + pi + " | " + stationName + " [" + stationCity + ", " + stationItu + "] - " + stationDistance + " km | " + stationErp + " kW");
await copyToClipboard(frequency + " - " + pi + " | " + stationName + " [" + stationCity + ", " + stationItu + "] - " + stationDistance + " | " + stationErp + " kW");
} catch (error) {
console.error(error);
}
@@ -878,8 +878,9 @@ const updateDataElements = throttle(function(parsedData) {
updateTextIfChanged($('#data-station-city'), parsedData.txInfo.city);
updateTextIfChanged($('#data-station-itu'), parsedData.txInfo.itu);
updateTextIfChanged($('#data-station-pol'), parsedData.txInfo.pol);
updateTextIfChanged($('#data-station-distance'), parsedData.txInfo.dist);
updateHtmlIfChanged($('#data-station-azimuth'), parsedData.txInfo.azi + '°');
const txDistance = localStorage.getItem('imperialUnits') == "true" ? (Number(parsedData.txInfo.dist) * 0.621371192).toFixed(0) + " mi" : parsedData.txInfo.dist + " km";
updateTextIfChanged($('#data-station-distance'), txDistance);
$dataStationContainer.css('display', 'block');
} else {
$dataStationContainer.removeAttr('style');

View File

@@ -102,7 +102,6 @@ $(document).ready(() => {
$('.logout-link').click(function (event) {
event.preventDefault();
// Perform an AJAX request to the /logout endpoint
$.ajax({
type: 'GET', // Assuming the logout is a GET request, adjust accordingly
url: './logout',
@@ -148,9 +147,19 @@ $(document).ready(() => {
$("#ps-underscores").change(function() {
var isChecked = $(this).is(":checked");
console.log(isChecked);
localStorage.setItem("psUnderscores", isChecked);
});
var imperialUnits = localStorage.getItem("imperialUnits");
if (imperialUnits) {
$("#imperial-units").prop("checked", JSON.parse(imperialUnits));
localStorage.setItem("imperialUnits", imperialUnits);
}
$("#imperial-units").change(function() {
var isChecked = $(this).is(":checked");
localStorage.setItem("imperialUnits", isChecked);
});
$('.version-string').text(currentVersion);

View File

@@ -83,7 +83,7 @@
</div>
<div class="flex-container">
<div class="panel-50 p-bottom-20">
<div class="panel-50 p-bottom-20" style="overflow-x: auto;">
<h3>Current users</h3>
<table class="table-big">
<thead>
@@ -164,7 +164,7 @@
<span class="text-gray">This is where your tuner is plugged in.</span>
</p>
<label for="audio-devices"><i class="fa-solid fa-headphones"></i> STREAM AUDIO FROM:</label>
<div class="dropdown" style="width: 300px;">
<div class="dropdown">
<input id="audio-devices" type="text" name="audio-devices" placeholder="Choose your audio device" readonly tabindex="0" />
<ul class="options" tabindex="-1" id="deviceList">
<% videoDevices.forEach(device => { %>
@@ -184,7 +184,7 @@
<span class="text-gray">Choose between Mono / Stereo.</span>
</p>
<label for="audio-devices"><i class="fa-solid fa-microphone-lines"></i> Audio channels:</label>
<div class="dropdown" style="width: 300px;">
<div class="dropdown">
<input id="audio-channels" type="text" name="audio-channels" placeholder="Stereo" readonly tabindex="0" />
<ul class="options" tabindex="-1">
<li data-value="2" class="option" tabindex="0">Stereo</li>
@@ -200,7 +200,7 @@
<span class="text-gray">Minimum: 64 Kbps • Maximum: 320 Kbps</span>
</p>
<label for="audio-quality"><i class="fa-solid fa-wave-square"></i> Audio quality:</label>
<div class="dropdown" style="width: 300px;">
<div class="dropdown">
<input id="audio-quality" type="text" name="audio-quality" placeholder="128k (standard)" readonly tabindex="0" />
<ul class="options" tabindex="-1">
<li data-value="64k" class="option" tabindex="0">64k (lowest quality)</li>
@@ -434,7 +434,7 @@
<div class="panel-33 p-bottom-20" style="padding-right: 20px; padding-left: 20px;">
<h3>Connection type</h3>
<p class="text-gray">If you want to choose the COM port directly, choose "Direct".<br>If you use xdrd or your receiver is connected via Wi-Fi, choose TCP/IP.</p>
<div style="width: 300px;" class="auto top-10">
<div class="auto top-10">
<label class="toggleSwitch nolabel" onclick="">
<input id="connection-type-toggle" type="checkbox" tabindex="0" aria-label="Connection type"/>
<a></a>
@@ -452,7 +452,7 @@
<p class="text-gray">Choose your desired <strong>COM port</strong><br>&nbsp;</p>
<div class="form-group">
<label for="com-devices"><i class="fa-brands fa-usb"></i> USB Device:</label>
<div class="dropdown" style="width: 300px;margin-right: 0;">
<div class="dropdown" style="margin-right: 0;">
<input id="com-devices" type="text" name="com-devices" placeholder="Choose your USB device" readonly tabindex="0" />
<ul class="options" tabindex="-1" id="deviceList">
<% serialPorts.forEach(serialPort => { %>
@@ -598,6 +598,33 @@
</div>
</div>
<div class="panel-100 p-bottom-20">
<h3>Tunnel</h3>
<p>When you become a <a href="https://buymeacoffee.com/fmdx" target="_blank"><strong>FMDX.org supporter</strong></a>, you can host your webserver without the need of a public IP address.<br>
When you become a supporter, you can message the Founders on Discord for your login details.</p>
<div class="form-group checkbox">
<input type="checkbox" tabindex="0" id="tunnel-enable" aria-label="Enable tunnel">
<label for="tunnel-enable"><i class="fa-solid fa-toggle-off m-right-10"></i> Enable tunnel</label>
</div><br>
<div class="form-group">
<label for="tunnel-subdomain">subdomain name</label>
<input class="input-text w-150" type="text" name="tunnel-subdomain" id="tunnel-subdomain" maxlength="20">.fmtuner.org
</div><br>
<div class="form-group">
<label for="tunnel-username">Username</label>
<input class="input-text w-150" type="text" name="tunnel-username" id="tunnel-username">
</div>
<div class="form-group">
<label for="tunnel-password">Token</label>
<input class="input-text" style="width: 100%; max-width: 400px;" type="password" name="tunnel-token" id="tunnel-token" maxlength="36">
</div><br>
<p>Enabling low latency mode may provide better experience, however it will also use more bandwidth.</p>
<div class="form-group checkbox">
<input type="checkbox" tabindex="0" id="tunnel-lowlatency" aria-label="Low latency mode">
<label for="tunnel-lowlatency"><i class="fa-solid fa-toggle-off m-right-10"></i> Low latency mode</label>
</div>
</div>
</div>
</div>