mirror of
https://github.com/unraid/webgui.git
synced 2026-05-20 21:29:35 -05:00
Merge pull request #1159 from bergware/master
UPS display enhancements and other fixes
This commit is contained in:
@@ -18,11 +18,9 @@ Tag="battery-3"
|
||||
<script>
|
||||
function getUPSstatus() {
|
||||
$.post('/plugins/dynamix.apcupsd/include/UPSstatus.php',{level:<?=$cfg['BATTERYLEVEL']?>,runtime:<?=$cfg['MINUTES']?>},function(data) {
|
||||
if (data) {
|
||||
data = data.split(/\n/);
|
||||
$('#ups_summary').html(data[0].replace(/Percent/g,'%').replace(/Watt(s|age)/g,'W').replace('Minutes',"_(minutes)_").replace('Volts','V'));
|
||||
$('#ups_status').html(data[1]);
|
||||
}
|
||||
data = data.split('\n');
|
||||
$('#ups_summary').html(data[0]);
|
||||
$('#ups_status').html(data[1]);
|
||||
setTimeout(getUPSstatus,3000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ $cfg = parse_plugin_cfg($sName);
|
||||
?>
|
||||
|
||||
<style>
|
||||
table.ups thead tr th{width:16.6%;padding-left:10px;}
|
||||
table.ups tbody tr td{padding-left:10px;font-weight:bold;}
|
||||
table.ups thead tr th{width:16.6%;padding-left:10px}
|
||||
table.ups tbody tr td{padding-left:10px;font-weight:bold}
|
||||
tr.ups{height:3rem;line-height:3rem}
|
||||
i.ups{margin-right:8px}
|
||||
</style>
|
||||
<script>
|
||||
@@ -46,8 +47,8 @@ $(function() {
|
||||
});
|
||||
</script>
|
||||
<table class="tablesorter shift ups" <?if (!file_exists("/var/run/apcupsd.pid")):?>style="display:none"<?endif;?>>
|
||||
<thead><tr><th><i class='ups fa fa-plug'></i>_(UPS Status)_</th><th><i class='ups fa fa-battery'></i>_(Battery Charge)_</th><th><i class='ups fa fa-clock-o'></i>_(Runtime Left)_</th><th><i class='ups fa fa-bolt'></i>_(Nominal Power)_</th><th><i class='ups fa fa-bars'></i>_(UPS Load)_</th><th><i class='ups fa fa-ellipsis-h'></i>_(Output Voltage)_</th></tr></thead>
|
||||
<tbody id="ups_summary"><tr><td colspan="6"> </td></tr></tbody>
|
||||
<thead><tr><th><i class='ups fa fa-shield'></i>_(UPS Model)_</th><th><i class='ups fa fa-plug'></i>_(UPS Status)_</th><th><i class='ups fa fa-battery'></i>_(Battery Charge)_</th><th><i class='ups fa fa-clock-o'></i>_(Runtime Left)_</th><th><i class='ups fa fa-bolt'></i>_(Nominal Power)_</th><th><i class='ups fa fa-bars'></i>_(UPS Load)_</th><th><i class='ups fa fa-ellipsis-h'></i>_(Output Voltage)_</th></tr></thead>
|
||||
<tbody id="ups_summary"><tr class="ups"><td colspan="7"> </td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<span style="float:right;margin-right:10px"><a href="http://apcupsd.org/manual/manual.html" target="_blank" title="_(APC UPS Daemon user manual)_"><i class="fa fa-file-text-o"></i> <u>_(Online Manual)_</u></a></span>
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# Send system notify message from apcupsd
|
||||
#
|
||||
read MESSAGE
|
||||
[[ "$MESSAGE" == *restored* ]] && LEVEL=normal || LEVEL=alert
|
||||
[[ "$MESSAGE" == *restored* || "$MESSAGE" == *returned* ]] && LEVEL=normal || LEVEL=alert
|
||||
/usr/local/emhttp/webGui/scripts/notify -l "/Settings/UPSsettings" -e "Unraid Server Alert" -s "UPS Alert" -d "$MESSAGE" -i $LEVEL
|
||||
|
||||
@@ -18,19 +18,21 @@ $_SERVER['REQUEST_URI'] = 'settings';
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
$state = [
|
||||
'TRIM ONLINE' => _('Online (trim)'),
|
||||
'BOOST ONLINE' => _('Online (boost)'),
|
||||
'ONLINE' => _('Online'),
|
||||
'SLAVE' => '('._('Slave').')',
|
||||
'ONBATT' => _('On battery'),
|
||||
'COMMLOST' => _('Lost communication'),
|
||||
'NOBATT' => _('No battery detected')
|
||||
'ONLINE' => _('Online'),
|
||||
'SLAVE' => '('._('slave').')',
|
||||
'TRIM' => '('._('trim').')',
|
||||
'BOOST' => '('._('boost').')',
|
||||
'COMMLOST' => _('Lost communication'),
|
||||
'ONBATT' => _('On battery'),
|
||||
'NOBATT' => _('No battery detected'),
|
||||
'LOWBATT' => _('Low on battery'),
|
||||
'OVERLOAD' => _('UPS overloaded')
|
||||
];
|
||||
|
||||
$red = "class='red-text'";
|
||||
$green = "class='green-text'";
|
||||
$orange = "class='orange-text'";
|
||||
$status = array_fill(0,6,"<td>-</td>");
|
||||
$status = array_fill(0,7,"<td>-</td>");
|
||||
$result = [];
|
||||
$level = $_POST['level'] ?: 10;
|
||||
$runtime = $_POST['runtime'] ?: 5;
|
||||
@@ -40,39 +42,41 @@ if (file_exists("/var/run/apcupsd.pid")) {
|
||||
for ($i=0; $i<count($rows); $i++) {
|
||||
[$key,$val] = array_map('trim', explode(':', $rows[$i], 2));
|
||||
switch ($key) {
|
||||
case 'MODEL':
|
||||
$status[0] = "<td $green>$val</td>";
|
||||
break;
|
||||
case 'STATUS':
|
||||
$var = strtr($val, $state);
|
||||
$status[0] = $var ? (stripos($var,'online')!==false ? "<td $green>$var</td>" : "<td $red>$var</td>") : "<td $orange>"._('Refreshing')."...</td>";
|
||||
$text = strtr($val, $state);
|
||||
$status[1] = $val ? (strpos($val,'ONLINE')!==false ? "<td $green>$text</td>" : "<td $red>$text</td>") : "<td $orange>"._('Refreshing')."...</td>";
|
||||
break;
|
||||
case 'BCHARGE':
|
||||
[$charge,$unit] = explode(' ', $val, 2);
|
||||
$charge = intval($charge);
|
||||
$status[1] = $charge>$level ? "<td $green>$charge $unit</td>" : "<td $red>$charge $unit</td>";
|
||||
$charge = round(strtok($val,' '));
|
||||
$status[2] = $charge>$level ? "<td $green>$charge %</td>" : "<td $red>$charge %</td>";
|
||||
break;
|
||||
case 'TIMELEFT':
|
||||
[$left,$unit] = explode(' ', $val, 2);
|
||||
$left = intval($left);
|
||||
$status[2] = $left>$runtime ? "<td $green>$left $unit</td>" : "<td $red>$left $unit</td>";
|
||||
$time = round(strtok($val,' '));
|
||||
$unit = _('minutes');
|
||||
$status[3] = $time>$runtime ? "<td $green>$time $unit</td>" : "<td $red>$time $unit</td>";
|
||||
break;
|
||||
case 'NOMPOWER':
|
||||
$power = strtok($val,' ');
|
||||
$status[3] = $power==0 ? "<td $red>$val</td>" : "<td $green>$val</td>";
|
||||
$status[4] = $power>0 ? "<td $green>$power W</td>" : "<td $red>$power W</td>";
|
||||
break;
|
||||
case 'LOADPCT':
|
||||
$load = strtok($val,' ');
|
||||
$status[4] = $val;
|
||||
$status[5] = round($load)." %";
|
||||
break;
|
||||
case 'OUTPUTV':
|
||||
$output = strtok($val,' ');
|
||||
$status[5] = $val;
|
||||
$output = round(strtok($val,' '));
|
||||
$status[6] = "$output V";
|
||||
break;
|
||||
case 'NOMINV':
|
||||
$volt = strtok($val,' ');
|
||||
$minv = $volt / 1.1; // +/- 10% tolerance
|
||||
$maxv = $volt * 1.1;
|
||||
$minv = floor($volt / 1.1); // +/- 10% tolerance
|
||||
$maxv = ceil($volt * 1.1);
|
||||
break;
|
||||
case 'LINEFREQ':
|
||||
$freq = $val;
|
||||
$freq = round(strtok($val,' '));
|
||||
break;
|
||||
}
|
||||
if ($i%2==0) $result[] = "<tr>";
|
||||
@@ -80,11 +84,11 @@ 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 ($power && isset($load)) $status[4] = ($load<90 ? "<td $green>" : "<td $red>").intval($power*$load/100)." W (".$status[4].")</td>";
|
||||
elseif (isset($load)) $status[4] = ($load<90 ? "<td $green>" : "<td $red>").$status[4]."</td>";
|
||||
$status[5] = $output ? (($output<$minv||$output>$maxv ? "<td $red>" : "<td $green>").$status[5].($freq ? " / $freq" : "")."</td>") : $status[5];
|
||||
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] = $output ? ((!$volt || ($minv<$output && $output<$maxv) ? "<td $green>" : "<td $red>").$status[6].($freq ? " ~ $freq Hz" : "")."</td>") : $status[6];
|
||||
}
|
||||
if (!$rows) $result[] = "<tr><td colspan='4' style='text-align:center'>"._('No information available')."</td></tr>";
|
||||
|
||||
echo "<tr>",implode($status),"</tr>\n",implode($result);
|
||||
echo "<tr class='ups'>",implode($status),"</tr>\n",implode($result);
|
||||
?>
|
||||
|
||||
@@ -23,10 +23,6 @@ $width = in_array($theme,['white','black']) ? -58: -44;
|
||||
$top = in_array($theme,['white','black']) ? 40 : 20;
|
||||
$busy = "<i class='fa fa-spin fa-circle-o-notch'></i> "._('Please wait')."... "._('starting up containers');
|
||||
$cpus = cpu_list();
|
||||
|
||||
// adjust the text color in log window
|
||||
$fgcolor = in_array($theme,['white','azure']) ? '#1c1c1c' : '#f2f2f2';
|
||||
exec("sed -ri 's/^\.logLine\{color:#......;/.logLine{color:$fgcolor;/' $docroot/plugins/dynamix.docker.manager/log.htm >/dev/null &");
|
||||
?>
|
||||
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.ui.css')?>">
|
||||
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.switchbutton.css')?>">
|
||||
|
||||
@@ -492,8 +492,12 @@ function formatWarning(val) {
|
||||
<tr><td>_(Estimated speed)_:</td><td id="line3"></td><td></td></tr>
|
||||
<tr><td>_(Estimated finish)_:</td><td id="line4"></td><td></td></tr>
|
||||
<? if ($action[0]=="check"):?>
|
||||
<? if (count($action)>1):?>
|
||||
<tr><td><?=$var['mdResyncCorr']==0 ? _('Sync errors detected') : _('Sync errors corrected')?>:</td><td id="line5"></td><td></td></tr>
|
||||
<? else:?>
|
||||
<tr><td><?=$var['mdResyncCorr']==0 ? _('Read errors detected') : _('Read errors corrected')?>:</td><td id="line5"></td><td></td></tr>
|
||||
<? endif;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case "Starting":?>
|
||||
|
||||
@@ -181,6 +181,7 @@ span.busy,i.inactive{opacity:0.5}
|
||||
span#inbound{width:75px;display:inline-block}
|
||||
span#load{width:120px;display:inline-block}
|
||||
span#util{margin-left:20px}
|
||||
span#ups_model{margin-right:30px}
|
||||
span[id^=cpu],span[id^=sys]{width:0}
|
||||
select#cpuline,select#netline{border:none;padding:0 12px 0 0}
|
||||
i.heat{margin-left:8px}
|
||||
@@ -369,6 +370,7 @@ foreach ($ports as $port) {
|
||||
<thead sort='<?=++$N?>'><tr class='hidden'><td></td><td colspan='3'></td><td></td></tr></thead>
|
||||
<tbody sort='<?=$N?>' class='sortable'>
|
||||
<tr><td></td><td colspan='3' class='next'><i class='icon-ups'></i><div class='section'>_(Power)_<br>
|
||||
<span><i class='ups fa fa-shield'></i>_(UPS Model)_: </span><span id='ups_model'></span>
|
||||
<span><i class='ups fa fa-bars'></i>_(UPS Load)_: </span><span id='ups_loadpct'></span><br><br></div>
|
||||
<i class='fa fa-fw chevron' id='ups_view' onclick='toggleChevron("ups_view",0)'></i>
|
||||
<a href='/Dashboard/Settings/UPSsettings' title="_(Go to UPS settings)_"><i class='fa fa-fw fa-cog chevron'></i></a>
|
||||
@@ -1126,14 +1128,15 @@ dashboard.on('message',function(msg,meta) {
|
||||
});
|
||||
<?if ($apcupsd):?>
|
||||
var apcups = new NchanSubscriber('/sub/apcups',{subscriber:'websocket'});
|
||||
apcups.on('message',function(d) {
|
||||
var data = d.split(';');
|
||||
$('#ups_status').html(data[0]);
|
||||
$('#ups_bcharge').html(data[1].replace('Percent','%'));
|
||||
$('#ups_timeleft').html(data[2].replace('Minutes',"_(minutes)_"));
|
||||
$('#ups_nompower').html(data[3].replace('Watts','W'));
|
||||
$('#ups_loadpct').html(data[4].replace('Percent','%'));
|
||||
$('#ups_outputv').html(data[5].replace('Volts','V'));
|
||||
apcups.on('message',function(data) {
|
||||
data = data.split(';');
|
||||
$('#ups_model').html(data[0]);
|
||||
$('#ups_status').html(data[1]);
|
||||
$('#ups_bcharge').html(data[2]);
|
||||
$('#ups_timeleft').html(data[3]);
|
||||
$('#ups_nompower').html(data[4]);
|
||||
$('#ups_loadpct').html(data[5]);
|
||||
$('#ups_outputv').html(data[6]);
|
||||
});
|
||||
<?endif;?>
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ $config = "/boot/config";
|
||||
$entity = $notify['entity'] & 1 == 1;
|
||||
$alerts = '/tmp/plugins/my_alerts.txt';
|
||||
|
||||
// adjust the text color in docker log window
|
||||
$fgcolor = in_array($theme,['white','azure']) ? '#1c1c1c' : '#f2f2f2';
|
||||
exec("sed -ri 's/^\.logLine\{color:#......;/.logLine{color:$fgcolor;/' $docroot/plugins/dynamix.docker.manager/log.htm >/dev/null &");
|
||||
|
||||
function annotate($text) {echo "\n<!--\n",str_repeat("#",strlen($text)),"\n$text\n",str_repeat("#",strlen($text)),"\n-->\n";}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -28,13 +28,15 @@ require_once "$docroot/webGui/include/Translations.php";
|
||||
$locale_init = $locale;
|
||||
|
||||
$state = [
|
||||
'TRIM ONLINE' => _('Online (trim)'),
|
||||
'BOOST ONLINE' => _('Online (boost)'),
|
||||
'ONLINE' => _('Online'),
|
||||
'SLAVE' => '('._('Slave').')',
|
||||
'ONBATT' => _('On battery'),
|
||||
'COMMLOST' => _('Lost communication'),
|
||||
'NOBATT' => _('No battery detected')
|
||||
'ONLINE' => _('Online'),
|
||||
'SLAVE' => '('._('slave').')',
|
||||
'TRIM' => '('._('trim').')',
|
||||
'BOOST' => '('._('boost').')',
|
||||
'COMMLOST' => _('Lost communication'),
|
||||
'ONBATT' => _('On battery'),
|
||||
'NOBATT' => _('No battery detected'),
|
||||
'LOWBATT' => _('Low on battery'),
|
||||
'OVERLOAD' => _('UPS overloaded')
|
||||
];
|
||||
|
||||
$red = "class='red-text'";
|
||||
@@ -66,56 +68,58 @@ while (true) {
|
||||
$locale_init = $display['locale'];
|
||||
update_translation($locale_init);
|
||||
}
|
||||
unset($status,$rows,$power,$load,$freq,$output);
|
||||
$status = array_fill(0,6,"<span>-</span>");
|
||||
unset($status,$rows,$power,$load,$freq,$output,$volt);
|
||||
$status = array_fill(0,7,"<span>-</span>");
|
||||
if (file_exists("/var/run/apcupsd.pid")) {
|
||||
// get battery-level and runtime settings
|
||||
$cfg = parse_plugin_cfg('dynamix.apcupsd');
|
||||
$level = $cfg['BATTERYLEVEL'] ?: 10;
|
||||
$runtime = $cfg['MINUTES'] ?: 5;
|
||||
exec("/sbin/apcaccess 2>/dev/null", $rows);
|
||||
exec("/sbin/apcaccess -u 2>/dev/null", $rows);
|
||||
foreach ($rows as $row) {
|
||||
[$key, $val] = array_map('trim', explode(':', $row, 2));
|
||||
switch ($key) {
|
||||
case 'MODEL':
|
||||
$status[0] = $val;
|
||||
break;
|
||||
case 'STATUS':
|
||||
$val = strtr($val, $state);
|
||||
$status[0] = $val ? (stripos($val,'online')!==false ? "<span $green>$val</span>" : "<span $red>$val</span>") : "<span $orange>"._('Refreshing')."...</span>";
|
||||
$text = strtr($val, $state);
|
||||
$status[1] = $val ? (strpos($val,'ONLINE')!==false ? "<span $green>$text</span>" : "<span $red>$text</span>") : "<span $orange>"._('Refreshing')."...</span>";
|
||||
break;
|
||||
case 'BCHARGE':
|
||||
[$val,$unit] = explode(' ', $val, 2);
|
||||
$val = intval($val);
|
||||
$status[1] = strtok($val,' ')>$level ? "<span $green>$val $unit</span>" : "<span $red>$val $unit</span>";
|
||||
$charge = round($val);
|
||||
$status[2] = $charge>$level ? "<span $green>$charge %</span>" : "<span $red>$charge %</span>";
|
||||
break;
|
||||
case 'TIMELEFT':
|
||||
[$val,$unit] = explode(' ', $val, 2);
|
||||
$val = intval($val);
|
||||
$status[2] = $val>$runtime ? "<span $green>$val $unit</span>" : "<span $red>$val $unit</span>";
|
||||
$time = round($val);
|
||||
$unit = _('minutes');
|
||||
$status[3] = $time>$runtime ? "<span $green>$time $unit</span>" : "<span $red>$time $unit</span>";
|
||||
break;
|
||||
case 'NOMPOWER':
|
||||
$power = strtok($val,' ');
|
||||
$status[3] = $power==0 ? "<span $red>$val</span>" : "<span $green>$val</span>";
|
||||
$power = $val;
|
||||
$status[4] = $power>0 ? "<span $green>$power W</span>" : "<span $red>$power W</span>";
|
||||
break;
|
||||
case 'LOADPCT':
|
||||
$load = strtok($val,' ');
|
||||
$status[4] = $val;
|
||||
$load = $val;
|
||||
$status[5] = round($load)." %";
|
||||
break;
|
||||
case 'OUTPUTV':
|
||||
$output = strtok($val,' ');
|
||||
$status[5] = $val;
|
||||
$output = round($val);
|
||||
$status[6] = "$output V";
|
||||
break;
|
||||
case 'NOMINV':
|
||||
$volt = strtok($val,' ');
|
||||
$minv = $volt / 1.1; // +/- 10% tolerance
|
||||
$maxv = $volt * 1.1;
|
||||
$volt = $val;
|
||||
$minv = floor($volt / 1.1); // +/- 10% tolerance
|
||||
$maxv = ceil($volt * 1.1);
|
||||
break;
|
||||
case 'LINEFREQ':
|
||||
$freq = $val;
|
||||
$freq = round($val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($power && isset($load)) $status[4] = ($load<90 ? "<span>" : "<span $red>").intval($power*$load/100)." W (".$status[4].")</span>";
|
||||
elseif (isset($load)) $status[4] = ($load<90 ? "<span>" : "<span $red>").$status[4]."</span>";
|
||||
$status[5] = $output ? (($output<$minv||$output>$maxv ? "<span $red>" : "<span $green>").$status[5].($freq ? " / $freq" : "")."</span>") : $status[5];
|
||||
if ($power && isset($load)) $status[5] = ($load<90 ? "<span>" : "<span $red>").round($power*$load/100)." W (".$status[5].")</span>";
|
||||
elseif (isset($load)) $status[5] = ($load<90 ? "<span>" : "<span $red>").$status[5]."</span>";
|
||||
$status[6] = $output ? ((!$volt || ($minv<$output && $output<$maxv) ? "<span $green>" : "<span $red>").$status[6].($freq ? " ~ $freq Hz" : "")."</span>") : $status[6];
|
||||
}
|
||||
publish('apcups',implode(';', $status));
|
||||
sleep(3);
|
||||
|
||||
Reference in New Issue
Block a user