From 85a6f07455f144b3b107eaa4ba982530c535191a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 17 Feb 2020 09:49:34 +0100 Subject: [PATCH] luci-mod-network, luci-mod-status: harmonize wifi signal indicators Fixes: #3636 Signed-off-by: Jo-Philipp Wich (cherry picked from commit 2cad20e7ea90c962020bb2f2463fb660271b84ea) --- .../resources/view/network/wireless.js | 20 ++++++++++++------- .../resources/view/status/include/60_wifi.js | 10 +++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js index 61838a236..00e2fd889 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js @@ -30,7 +30,7 @@ function render_radio_badge(radioDev) { } function render_signal_badge(signalPercent, signalValue, noiseValue, wrap) { - var icon, title; + var icon, title, value; if (signalPercent < 0) icon = L.resource('icons/signal-none.png'); @@ -45,18 +45,24 @@ function render_signal_badge(signalPercent, signalValue, noiseValue, wrap) { else icon = L.resource('icons/signal-75-100.png'); - if (signalValue != null && signalValue != 0) { - title = '%s %d %s'.format(_('Signal'), signalValue, _('dBm')); - - if (noiseValue != null && noiseValue != 0) - title += ' / %s: %d %s'.format(_('Noise'), noiseValue, _('dBm')); + if (signalValue != null && signalValue != 0 && noiseValue != null && noiseValue != 0) { + value = '%d / %d %s'.format(signalValue, noiseValue, _('dBm')); + title = '%s: %d %s / %s: %d %s / %s %d'.format( + _('Signal'), signalValue, _('dBm'), + _('Noise'), noiseValue, _('dBm'), + _('SNR'), signalValue - noiseValue); + } + else if (signalValue != null && signalValue != 0) { + value = '%d %s'.format(signalValue, _('dBm')); + title = '%s: %d %s'.format(_('Signal'), signalValue, _('dBm')); } else { + value = E('em', {}, E('small', {}, [ _('disabled') ])); title = _('No signal'); } return E('div', { 'class': wrap ? 'center' : 'ifacebadge', 'title': title }, - [ E('img', { 'src': icon }), wrap ? E('br') : ' ', '%d%%'.format(Math.max(signalPercent, 0)) ]); + [ E('img', { 'src': icon }), wrap ? E('br') : ' ', value ]); } function render_network_badge(radioNet) { diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js index e73f57712..86468c718 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/60_wifi.js @@ -139,14 +139,14 @@ return L.Class.extend({ ipv6 = hosthints.getIP6AddrByMACAddr(bss.mac); var icon; - var q = (-1 * (bss.noise - bss.signal)) / 5; - if (q < 1) + var q = Math.min((bss.signal + 110) / 70 * 100, 100); + if (q == 0) icon = L.resource('icons/signal-0.png'); - else if (q < 2) + else if (q < 25) icon = L.resource('icons/signal-0-25.png'); - else if (q < 3) + else if (q < 50) icon = L.resource('icons/signal-25-50.png'); - else if (q < 4) + else if (q < 75) icon = L.resource('icons/signal-50-75.png'); else icon = L.resource('icons/signal-75-100.png'); -- 2.25.1