Skip to content

Commit

Permalink
Fix: date format, add additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dnzbk committed Jan 28, 2025
1 parent 6bd54ac commit baa6d36
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
4 changes: 0 additions & 4 deletions webui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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); } }
Expand Down
30 changes: 25 additions & 5 deletions webui/system-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -516,17 +516,19 @@ 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;
},
function(res)
{
$SysInfo_NetworkSpeedTestBtn.text(TEST_BTN_DEFAULT_TEXT);
$SysInfo_NetworkSpeedTestBtn.removeClass('btn--disabled');
removeNetworkSpeedTestBtnTitle();
var errTxt = res.split('<br>')[0];
$SysInfo_NetworkSpeedTestErrorTxt.html(errTxt);
NETWORK_SPEED_TEST_RUNNING = false;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion webui/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var Util = (new function($)

this.formatNetworkSpeed = function(speedMbps)
{
if (speedMbps <= 0)
if (!speedMbps || speedMbps <= 0)
{
return '';
}
Expand Down

0 comments on commit baa6d36

Please sign in to comment.