Closed jbtwo closed 3 months ago
Good catch!
Would you please switch this over to the _var()
function from Wrappers.php? It saves having to check for empty array values, and allows setting a default:
<?php
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
?>
var batteryLevel = "<?= _var($cfg,'BATTERYLEVEL',0) ?>";
var batteryRuntime = "<?= _var($cfg,'MINUTES',0) ?>";
Good catch!
Would you please switch this over to the
_var()
function from Wrappers.php? It saves having to check for empty array values, and allows setting a default:<?php $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; require_once "$docroot/webGui/include/Wrappers.php"; ?> var batteryLevel = "<?= _var($cfg,'BATTERYLEVEL',0) ?>"; var batteryRuntime = "<?= _var($cfg,'MINUTES',0) ?>";
Thanks @ljm42, changes made
Issue:
When either of the UPS config options
Battery level to initiate shutdown (%)
orRuntime left to initiate shutdown (minutes)
are set to empty, the UPS details section breaks. This is due to thegetUPSstatus
function passing values directly from the config, which results in an error if either value is empty.Solution:
The fix sets and passes variables to the
getUPSstatus
function for each of the config options. The variables are either set to the value contained in the config file, or0
if the config has no value set.Tested the fix locally and confirmed it functions as expected.