mirror of
https://github.com/unraid/webgui.git
synced 2026-02-07 01:19:08 -06:00
Re-implementation of #1743 based on the received feedback. This implementation is far more robust, as it injects the NOMPOWER value into the existing code, allowing the existing Unraid GUI code to interpret and display the values in the same manner
This commit is contained in:
@@ -91,14 +91,17 @@ if (file_exists("/var/run/apcupsd.pid")) {
|
||||
if ($i%2==1) $result[] = "</tr>";
|
||||
}
|
||||
if (count($rows)%2==1) $result[] = "<td></td><td></td></tr>";
|
||||
|
||||
// If the override is defined, override the power value, using the same implementation as above.
|
||||
// This is a better implementation, as it allows the existing Unraid code to work with the override.
|
||||
if ($overrideUpsCapacity > 0) {
|
||||
$power = $overrideUpsCapacity;
|
||||
$status[4] = $power>0 ? "<td $green>$power W</td>" : "<td $red>$power W</td>";
|
||||
}
|
||||
|
||||
if ($power && isset($load)) $status[5] = ($load<90 ? "<td $green>" : "<td $red>").round($power*$load/100)." W (".$status[5].")</td>";
|
||||
elseif (isset($load)) $status[5] = ($load<90 ? "<td $green>" : "<td $red>").$status[5]."</td>";
|
||||
$status[6] = isset($output) ? ((!$volt || ($minv<$output && $output<$maxv) ? "<td $green>" : "<td $red>").$status[6].(isset($freq) ? " ~ $freq Hz" : "")."</td>") : $status[6];
|
||||
|
||||
if ($status[4] == $defaultCell && $overrideUpsCapacity > 0 && isset($load) && $load > 0) {
|
||||
$nominalPower = round($load * 0.01 * $overrideUpsCapacity);
|
||||
$status[4] = ($nominalPower > 0 ? "<td $green>" : "<td $red>") . "≈ $nominalPower W</td>";
|
||||
}
|
||||
}
|
||||
if (empty($rows)) $result[] = "<tr><td colspan='4' style='text-align:center'>"._('No information available')."</td></tr>";
|
||||
|
||||
|
||||
@@ -119,14 +119,17 @@ while (true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the override is defined, override the power value, using the same implementation as above.
|
||||
// This is a better implementation, as it allows the existing Unraid code to work with the override.
|
||||
if ($overrideUpsCapacity > 0) {
|
||||
$power = $overrideUpsCapacity;
|
||||
$echo[4] = $power>0 ? "<span $green>$power W</span>" : "<span $red>$power W</span>";
|
||||
}
|
||||
|
||||
if (isset($power) && isset($load)) $echo[5] = ($load<90 ? "<span $green>" : "<span $red>").round($power*$load/100)." W (".$echo[5].")</span>";
|
||||
elseif (isset($load)) $echo[5] = ($load<90 ? "<span>" : "<span $red>").$echo[5]."</span>";
|
||||
$echo[6] = isset($output) ? ((empty($volt) || ($minv<$output && $output<$maxv) ? "<span $green>" : "<span $red>").$echo[6].(isset($freq) ? " ~ $freq Hz" : "")."</span>") : $echo[6];
|
||||
|
||||
if ($echo[4] == $defaultCell && $overrideUpsCapacity > 0 && isset($load) && $load > 0) {
|
||||
$nominalPower = round($load * 0.01 * $overrideUpsCapacity);
|
||||
$echo[4] = ($nominalPower > 0 ? "<span $green>" : "<span $red>") . "≈ $nominalPower W</span>";
|
||||
}
|
||||
}
|
||||
$echo = json_encode($echo);
|
||||
$md5_new = md5($echo,true);
|
||||
|
||||
Reference in New Issue
Block a user