From baa6d3666a5a12078ffea058a2eaaf0d02198090 Mon Sep 17 00:00:00 2001 From: dnzbk Date: Tue, 28 Jan 2025 13:45:04 +0300 Subject: [PATCH] Fix: date format, add additional checks --- webui/style.css | 4 ---- webui/system-info.js | 30 +++++++++++++++++++++++++----- webui/util.js | 2 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/webui/style.css b/webui/style.css index 50fda922..df97d562 100644 --- a/webui/style.css +++ b/webui/style.css @@ -125,10 +125,6 @@ body { animation:spin 1s linear infinite; } -.spinner.material-icon { - color: inherit; -} - @-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } } diff --git a/webui/system-info.js b/webui/system-info.js index a225229e..b0175f7d 100644 --- a/webui/system-info.js +++ b/webui/system-info.js @@ -493,9 +493,9 @@ var SystemInfo = (new function($) var savedResults = Util.getFromLocalStorage(NETWORK_SPEED_TEST_LS_KEY); if (savedResults && !NETWORK_SPEED_TEST_RUNNING) { - $SysInfo_NetworkSpeedTestBtn.text(Util.formatNetworkSpeed(savedResults)); + renderNetworkSpeedTestResults(savedResults); } - else if (NETWORK_SPEED_TEST_RUNNING) + else if (savedResults && NETWORK_SPEED_TEST_RUNNING) { $SysInfo_NetworkSpeedTestBtn.html(SPINNER); } @@ -516,10 +516,11 @@ var SystemInfo = (new function($) RPC.call('testnetworkspeed', [], function(rawRes) { + var date = Date.now(); Util.saveToLocalStorage(NETWORK_SPEED_TEST_LS_KEY, rawRes.SpeedMbps); - Util.saveToLocalStorage(NETWORK_SPEED_TEST_DATE_LS_KEY, Date.now()); + Util.saveToLocalStorage(NETWORK_SPEED_TEST_DATE_LS_KEY, date); $SysInfo_NetworkSpeedTestBtn.html(Util.formatNetworkSpeed(rawRes.SpeedMbps)); - renderNetworkSpeedTestBtnTitle(savedDate); + renderNetworkSpeedTestBtnTitle(date); $SysInfo_NetworkSpeedTestBtn.removeClass('btn--disabled'); NETWORK_SPEED_TEST_RUNNING = false; }, @@ -527,6 +528,7 @@ var SystemInfo = (new function($) { $SysInfo_NetworkSpeedTestBtn.text(TEST_BTN_DEFAULT_TEXT); $SysInfo_NetworkSpeedTestBtn.removeClass('btn--disabled'); + removeNetworkSpeedTestBtnTitle(); var errTxt = res.split('
')[0]; $SysInfo_NetworkSpeedTestErrorTxt.html(errTxt); NETWORK_SPEED_TEST_RUNNING = false; @@ -537,7 +539,25 @@ var SystemInfo = (new function($) function renderNetworkSpeedTestBtnTitle(date) { - $SysInfo_NetworkSpeedTestBtn.attr('title', 'Date: ' + Util.formatDateTime(date)); + var formatted = Util.formatDateTime(date / 1000); + if (formatted) + { + $SysInfo_NetworkSpeedTestBtn.attr('title', 'Date: ' + formatted); + } + } + + function removeNetworkSpeedTestBtnTitle() + { + $SysInfo_NetworkSpeedTestBtn.removeAttr('title'); + } + + function renderNetworkSpeedTestResults(results) + { + var formatted = Util.formatNetworkSpeed(results); + if (formatted) + { + $SysInfo_NetworkSpeedTestBtn.text(Util.formatNetworkSpeed(results)); + } } function renderAppVersion(version) diff --git a/webui/util.js b/webui/util.js index a6448a0d..3013840a 100644 --- a/webui/util.js +++ b/webui/util.js @@ -195,7 +195,7 @@ var Util = (new function($) this.formatNetworkSpeed = function(speedMbps) { - if (speedMbps <= 0) + if (!speedMbps || speedMbps <= 0) { return ''; }