Merge pull request #447 from bergware/master

Dashboard: display UPS summary in table
This commit is contained in:
tom mortensen
2019-01-19 09:47:56 -08:00
committed by GitHub
3 changed files with 48 additions and 50 deletions

View File

@@ -1,33 +0,0 @@
Menu="Dashboard:1"
Cond="file_exists('/var/run/apcupsd.pid')"
---
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
* Copyright 2015, Dan Landon.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<style>
table.ups thead tr th{width:16.6%;padding-left:10px;}
table.ups tbody tr td{padding-left:10px;font-weight:bold;}
</style>
<script>
function getUPSstatus() {
$.get('/plugins/dynamix.apcupsd/include/UPSstatus.php',{all:'false'},function(data) {
if (data) $('#ups_summary').html(data);
setTimeout(getUPSstatus,15000);
});
}
$(getUPSstatus);
</script>
<table class="tablesorter ups">
<thead><tr><th>UPS Status</th><th>Battery Charge</th><th>Runtime Left</th><th>Nominal Power</th><th>UPS Load</th><th>UPS Load %</th></tr></thead>
<tbody id="ups_summary"><tr><td colspan="6">&nbsp;</td></tr></tbody>
</table>

View File

@@ -43,7 +43,9 @@ function cache_devices($disk) {
$dockerd = pgrep('dockerd');
$libvirtd = pgrep('libvirtd');
$apcupsd = file_exists('/var/run/apcupsd.pid');
$started = $var['fsState']=='Started';
$cache_pool = $var['cacheSbNumDisks'];
$array_size = $array_used = 0;
$cache_size = $cache_used = 0;
$extra_size = $extra_used = 0;
@@ -96,11 +98,11 @@ $mycase = file_exists("$boot/$myfile") ? file_get_contents("$boot/$myfile") : fa
$board = dmidecode('Base Board Information','2',0);
$serial = "s/n: {$board['Serial Number']}";
$board = "{$board['Manufacturer']} {$board['Product Name']} - v{$board['Version']}";
$board = "{$board['Manufacturer']} {$board['Product Name']}".($board['Version'] ? ", Version {$board['Version']}" : "");
$bios = dmidecode('BIOS Information','0',0);
$biosdate = "BIOS dated: ".my_time(strtotime($bios['Release Date']),$display['date']);
$bios = "{$bios['Vendor']} - v{$bios['Version']}";
$bios = $bios['Vendor'].($bios['Version'] ? ", Version {$bios['Version']}" : "");
$cpu = dmidecode('Processor Information','4',0);
$cpumodel = str_ireplace(["Processor","(C)","(R)","(TM)"],["","&#169;","&#174;","&#8482;"],$cpu['Version']);
@@ -148,12 +150,13 @@ if ($low) $memory_maximum = pow(2,ceil(log($memory_installed)/log(2)));
<?endif;?>
span.outer{float:left}
span.inner{width:124px}
span.ups{width:124px;display:inline-block}
</style>
<script src="<?autov('/webGui/javascript/jquery.switchbutton.js')?>"></script>
<script src="<?autov('/plugins/dynamix.docker.manager/javascript/docker.js')?>"></script>
<script src="<?autov('/plugins/dynamix.vm.manager/javascript/vmmanager.js')?>"></script>
<div style='float:left;margin:14px 0 36px 0'>
<div style='float:left;margin:14px 0 50px 0'>
<table class='share_status dashboard box1'>
<thead><tr><td></td><td colspan='3'><?=$var['NAME']?><i class='fa blue-text chevron mt0' id='sys_view' onclick='toggleChevron("sys_view",0)'></i></td><td></td></tr></thead>
<tbody class='sys_view' style='display:none'>
@@ -241,15 +244,28 @@ foreach ($ports as $port) {
}
?>
</tbody>
<?if ($fans>0) {
echo "<tbody>";
echo "<tr><td></td><td colspan='3' class='next'><i class='icon-fan'></i><div class='section'>Airflow<br><span>Fan count: $fans</span><br><br></div><i class='fa blue-text chevron' id='fan_view' onclick='toggleChevron(\"fan_view\",0)'></i></td><td></td></tr>";
for ($f=0; $f<$fans; $f+=2) {
if ($f+1<$fans) echo "<tr class='fan_view' style='display:none'><td></td><td>FAN ".($f)." - FAN ".($f+1)."</td><td id='fan{$f}'>"."</td><td id='fan".($f+1)."'></td><td></td></tr>";
else echo "<tr class='fan_view' style='display:none'><td></td><td>FAN ".($f)."</td><td colspan='2' id='fan{$f}'></td><td></td></tr>";
}
echo "</tbody>";
<?if ($apcupsd):?>
<tbody>
<tr><td></td><td colspan='3' class='next'><i class='icon-ups'></i><div class='section'>Power<br>
<span>UPS Load: <span id='ups_loadpct'></span></span><br><br></div><i class='fa blue-text chevron' id='ups_view' onclick='toggleChevron("ups_view",0)'></i></td><td></td></tr>
<tr class='ups_view' style='display:none'><td></td><td colspan='3'>
<span class='ups'>UPS status:</span><span id='ups_status'></span><br>
<span class='ups'>Battery charge:</span><span id='ups_bcharge'></span><br>
<span class='ups'>Runtime left:</span><span id='ups_timeleft'></span><br>
<span class='ups'>Nominal power:</span><span id='ups_nompower'></span><br>
</td><td></td></tr>
</tbody>
<?endif;?>
<?if ($fans):?>
<tbody>
<tr><td></td><td colspan='3' class='next'><i class='icon-fan'></i><div class='section'>Airflow<br><span>Fan count: <?=$fans?></span><br><br></div>
<i class='fa blue-text chevron' id='fan_view' onclick='toggleChevron("fan_view",0)'></i></td><td></td></tr>
<?for ($f=0; $f<$fans; $f+=2) {
if ($f+1<$fans) echo "<tr class='fan_view' style='display:none'><td></td><td>FAN ".($f)." - FAN ".($f+1)."</td><td id='fan{$f}'>"."</td><td id='fan".($f+1)."'></td><td></td></tr>";
else echo "<tr class='fan_view' style='display:none'><td></td><td>FAN ".($f)."</td><td colspan='2' id='fan{$f}'></td><td></td></tr>";
}?>
</tbody>
<?endif;?>
</table>
<table class='share_status dashboard box3'>
@@ -407,15 +423,15 @@ foreach ($users as $user) {
<tr><td></td><td colspan='5' id='parity'></td><td></td></tr>
<tr><td></td><td colspan='5' id='program'></td><td></td></tr>
</tbody>
<thead><tr><td></td><td colspan='5' class='next'>Array<?if (!$started):?> (not started)<?endif;?><i class='fa blue-text chevron mt0' id='array_view' onclick='toggleChevron("array_view",0)'></i>
<thead><tr><td></td><td colspan='5' class='next'>Array<?if (!$started):?> (stopped)<?endif;?><i class='fa blue-text chevron mt0' id='array_view' onclick='toggleChevron("array_view",0)'></i>
<?if ($started):?><span class='info'><?=my_scale($array_used*1024,$unit)." $unit"?> used of <?=my_scale($array_size*1024,$unit,-1,-1)." $unit"?> (<?=$array_percent?> %)</span><?endif;?>
</td><td></td></tr>
<tr style='display:none'><td></td><td id='array_info' colspan='5'></td><td></td></tr>
<tr id='array_view_on' style='display:none'><td></td><td>Device</td><td>Status</td><td>Temp</td><td>SMART</td><td>Utilization</td><td></td></tr>
</thead>
<tbody class='array_view' id='array_list' style='display:none'></tbody>
<?if (isset($disks['cache'])):?>
<thead><tr><td></td><td colspan='5' class='next'>Cache<?if (!$started):?> (not started)<?endif;?><i class='fa blue-text chevron mt0' id='cache_view' onclick='toggleChevron("cache_view",0)'></i>
<?if ($cache_pool):?>
<thead><tr><td></td><td colspan='5' class='next'>Cache<?if (!$started):?> (stopped)<?endif;?><i class='fa blue-text chevron mt0' id='cache_view' onclick='toggleChevron("cache_view",0)'></i>
<?if ($started):?><span class='info'><?=my_scale($cache_used*1024,$unit)." $unit"?> used of <?=my_scale($cache_size*1024,$unit,-1,-1)." $unit"?> (<?=$cache_percent?> %)</span><?endif;?>
</td><td></td></tr>
<tr style='display:none'><td></td><td id='cache_info' colspan='5'></td><td></td></tr>
@@ -545,7 +561,7 @@ function moreInfo(data,table) {
return info.length ? "<div style='padding-bottom:12px'><i class='icon-u-triangle failed'></i><span class='failed'>"+table+" has "+info.join('. ')+".</span></div>" : "";
}
function update5() {
<?if ($fans>0):?>
<?if ($fans):?>
$.post('<?=$url?>',{cmd:'fan'},function(data) {
$.each(data.split('\0'),function(k,v) {$('#fan'+k).html(v);});
});
@@ -566,6 +582,16 @@ function update15() {
$.post('<?=$url?>',{cmd:'shares',com:tag,names:'<?=addslashes(htmlspecialchars($names))?>'},function(data) {
$.each(data.split('\0'),function(k,v) {$('#share'+(k+1)).html(v);});
});
<?endif;?>
<?if ($apcupsd):?>
$.get('/plugins/dynamix.apcupsd/include/UPSstatus.php',{all:'false'},function(d) {
var data = d.replace(/<\/?tr>/,'').replace(/<td/g,'<span').replace(/td>/g,'span>;').split(';');
$('#ups_status').html(data[0]);
$('#ups_bcharge').html(data[1]);
$('#ups_timeleft').html(data[2]);
$('#ups_nompower').html(data[3]);
$('#ups_loadpct').html(data[5]+(data[5].search('-')==-1 ? '%':'')+(data[4].search('-')==-1 ? ' ('+data[4].replace(' Watts','W')+')':''));
});
<?endif;?>
$.post('<?=$url?>',{cmd:'status',number:'<?=$display['number']?>'},function(data) {$('span.info.title').html(data);});
$.post('<?=$url?>',{cmd:'parity',time:'<?=$display['date'].($display['date']!='%c'?", {$display['time']}":"")?>'},function(d) {
@@ -749,9 +775,12 @@ $(function() {
toggleView('cpu_view',true);
toggleView('mem_view',true);
toggleView('port_view',true);
<?if ($fans>0):?>
<?if ($fans):?>
toggleView('fan_view',true);
<?endif;?>
<?if ($apcupsd):?>
toggleView('ups_view',true);
<?endif;?>
<?if ($dockerd && ($display['dashapps']=='icons' || $display['dashapps']=='docker')):?>
toggleView('docker_view',true);
<?endif;?>
@@ -760,7 +789,9 @@ $(function() {
<?endif;?>
toggleView('parity_view',true);
toggleView('array_view',true);
<?if ($cache_pool):?>
toggleView('cache_view',true);
<?endif;?>
<?if ($devs):?>
toggleView('extra_view',true);
<?endif;?>

View File

@@ -55,7 +55,7 @@ html{font-size:<?=$font?>}
.inline_help{display:none}
.upgrade_notice{position:fixed;top:1px;left:0;width:100%;height:40px;line-height:40px;color:#e68a00;background:#feefb3;border-bottom:#e68a00 1px solid;text-align:center;font-size:1.4rem;z-index:999}
.upgrade_notice i{margin:14px;float:right;cursor:pointer}
.back_to_top{display:none;position:fixed;bottom:30px;right:12px;color:#e22828;font-size:2.5rem}
.back_to_top{display:none;position:fixed;bottom:30px;right:12px;color:#e22828;font-size:2.5rem;z-index:999}
<?
$safemode = strpos(file_get_contents('/proc/cmdline'),'unraidsafemode')!==false;
$tasks = find_pages('Tasks');