Add mobile wifi tools (#1691)

* Add mobile wifi signal tool

* Add mobile wifi scan tool

* Enable
This commit is contained in:
Tim Wilkinson 2024-11-13 22:39:59 -08:00 committed by GitHub
parent bdff952f9b
commit 787e5f55fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 11 deletions

View File

@ -144,7 +144,7 @@ const mynode = configuration.getName();
case "CONNECTING":
if (line.match(/^traceroute/)) {
state = "PRINT";
out(line);
out(line.replace(".local.mesh", ""));
}
break;
case "PRINT":
@ -159,7 +159,7 @@ const mynode = configuration.getName();
else {
const m = line.match(/^[0-9]+ +(.+\.local\.mesh) /);
if (m) {
line = line.replace(m[1], `<a href="http://${m[1]}">${m[1]}</a>`);
line = line.replace(m[1], `<a href="http://${m[1]}">${m[1].replace(".local.mesh", "")}</a>`);
}
out(line);
}

View File

@ -249,15 +249,23 @@ else {
<table>
<thead>
<tr>
{% if (!request.mobile) { %}
<td>SNR</td><td>Signal</td><td style="width:50px">Chan</td><td>Enc</td><td>SSID</td><td>Hostname</td><td>BSSID</td><td>802.11 Mode</td>
{% } else { %}
<td>Signal</td><td style="width:50px">Chan</td><td>SSID</td><td>Hostname</td>
{% } %}
</tr>
</thead>
<tbody>
{% for (let i = 0; i < length(last_scan); i++) {
const s = last_scan[i];
if (!request.mobile) {
%}
<tr><td>{{95 + s.signal}}</td><td>{{s.signal}}</td><td>{{s.chan}}</td><td>-</td><td>{{s.ssid}}</td><td>{{s.hostname || s.ip || "-"}}</td><td>{{s.mac}}</td><td>{{s.mode}}</td></tr>
{% } %}
{% } else { %}
<tr><td>{{s.signal}}</td><td>{{s.chan}}</td><td>{{s.ssid}}</td><td>{{s.hostname || s.ip || "-"}}</td></tr>
{% }
} %}
</tbody>
</table>
</div>

View File

@ -157,6 +157,7 @@ for (let i = 0; i < length(stations); i++) {
<div style="font-size:12px;padding:4px 16px 0 28px;">Local<div style="float:right">Remote</div></div>
</div>
</div>
{% if (!request.mobile) { %}
<div class="chart">
<div>
<svg viewBox="0 0 200 100" preserveAspectRatio="meet">
@ -175,6 +176,7 @@ for (let i = 0; i < length(stations); i++) {
</svg>
</div>
</div>
{% } %}
</div>
<div class="cols">
<div class="cols">
@ -225,9 +227,11 @@ for (let i = 0; i < length(stations); i++) {
const rbar1 = htmx.find("#wifi-bar .bars:nth-child(2) > div:nth-child(1)");
const rbar2 = htmx.find("#wifi-bar .bars:nth-child(2) > div:nth-child(2)");
const rbar3 = htmx.find("#wifi-bar .bars:nth-child(2) > div:nth-child(3)");
{% if (!request.mobile) { %}
const chart = htmx.find("#wifi-chart svg");
const signal = htmx.find("#wifi-chart svg .signal");
const rsignal = htmx.find("#wifi-chart svg .rsignal");
{% } %}
let oscillator;
let gain;
@ -276,8 +280,10 @@ for (let i = 0; i < length(stations); i++) {
rbar1.lastElementChild.innerText = "";
rbar2.lastElementChild.innerText = "";
rbar3.lastElementChild.innerText = "";
{% if (!request.mobile) { %}
signal.points.clear();
rsignal.points.clear();
{% } %}
}
const timer = setInterval(async _ => {
if (!document.contains(target)) {
@ -341,6 +347,7 @@ for (let i = 0; i < length(stations); i++) {
bar2.style.height = p(sf);
bar2.firstElementChild.innerText = "";
}
{% if (!request.mobile) { %}
if (signal.points.length >= maxpoints) {
signal.points.removeItem(0);
rsignal.points.removeItem(0);
@ -358,6 +365,7 @@ for (let i = 0; i < length(stations); i++) {
rpoint.x = 10 + rsignal.points.length / maxpoints * 180;
rpoint.y = 90 - 80 * ((rsl > -120 ? rsl : -120) + 120) / 120;
rsignal.points.appendItem(rpoint);
{% } %}
oscillator.frequency.value = (s - sf) * htmx.find("#wifi-chart input[name=pitch]").value;
gain.gain.value = htmx.find("#wifi-chart input[name=volume]").value;
}, 1000);

View File

@ -38,7 +38,7 @@
<input type="checkbox">
<div class="icon tools"></div>
<div class="menu" hx-on:htmx:after-request="htmx.find('#tools input').checked = false">
{% if (hardware.getRadioCount() > 0 && !request.mobile) { %}
{% if (hardware.getRadioCount() > 0) { %}
{% const config = radios.getActiveConfiguration();
if (config[0]?.mode !== radios.RADIO_OFF || config[1]?.mode !== radios.RADIO_OFF) { %}
<div hx-trigger="click" hx-get="tools/e/wifiscan" hx-target="#ctrl-modal"><div class="icon signal"></div>WiFi Scan</div>

View File

@ -311,20 +311,25 @@ body.mobile .reboot > div:nth-child(2)
padding: 10px 0;
}
.mobile #target-swap,
.mobile #target-swap-dummy
body.mobile #target-swap,
body.mobile #target-swap-dummy
{
display: none;
}
.mobile #ctrl-modal .simple-tool input
body.mobile #ctrl-modal .simple-tool input
{
font-size: 12px;
}
.mobile #ctrl-modal .tool-console pre
body.mobile #ctrl-modal .tool-console pre
{
overflow: scroll scroll;
}
.mobile #ctrl-modal button#tool-start
body.mobile #ctrl-modal button#tool-start
{
font-size: 12px;
}
body.mobile #wifi-chart .cols:nth-child(2)
{
justify-content: center;
}

View File

@ -981,7 +981,7 @@ body.authenticated #local-and-neighbor-devices .status.ctrl:hover
}
.icon.tools
{
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z" /></svg>') !important;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 26 26" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z" /></svg>') !important;
}
.icon.login
{