Add collapsable CPU load details in Dashboard

This commit is contained in:
bergware
2016-08-27 17:03:06 +02:00
parent 82d4af2090
commit f02565dd49

View File

@@ -112,6 +112,7 @@ function active_disks($disk) {
$disks = array_filter($disks,'active_disks');
$slots = count($disks) + count($devs);
?>
<style>a.popup:hover{text-decoration:underline;}</style>
<link type="text/css" rel="stylesheet" href="/webGui/styles/context.standalone.css">
<script src="/webGui/javascript/context.js"></script>
@@ -175,7 +176,9 @@ echo "<td>Array Status</td>".implode('',$row0);
</td></tr><tr><td colspan='4'><center>Load Statistics</center></td></tr></thead>
<tbody>
<tr class='wide'><td>Avg. CPU load</td><td colspan='3'><div class='usage-disk sys'><span id='cpu' style='width:0'></span></div></td></tr>
<?if (count($cpus)>1):?><tr><td rowspan='<?=count($cpus)?>'><?else:?><tr class='wide'><td><?endif;?>Per CPU load</td>
</tbody>
<tbody class='cpu_open' style='display:none'>
<?if (count($cpus)>1):?><tr><td rowspan='<?=count($cpus)?>'><?else:?><tr class='wide'><td><?endif;?><a href='#' onclick='toggle_CPU()' title='Click to hide details' class='none popup'>Per CPU load</a><span class='red-text'> *</span></td>
<?
$tr = false;
foreach ($cpus as $pair):
@@ -188,6 +191,21 @@ foreach ($cpus as $pair):
echo "</tr>";
$tr = true;
endforeach;
?>
</tbody>
<tbody class='cpu_closed' style='display:none'>
<?
$text = '';
foreach ($cpus as $pair):
list($cpu1, $cpu2) = preg_split('/[,-]/',$pair);
if ($text) $text .= ", ";
$text .= isset($cpu2) ? "[$cpu1/$cpu2]" : $cpu1;
endforeach;
?>
<tr class='wide'><td><a href='#' onclick='toggle_CPU()' class='none popup'>Per CPU load</a><span class='red-text'> *</span></td><td colspan='3' style='text-align:center'><?=$text?></td></tr>
</tbody>
<tbody>
<?
if ($fans>0):
echo $fans>2 ? "<tr><td rowspan='".ceil($fans/2)."'>" : "<tr class='wide'><td>";
echo "FAN speed</td>";
@@ -485,9 +503,24 @@ function dropdown(menu) {
$(select+' option')[$.cookie(menu)].selected = true;
$(select).change();
}
function toggle_CPU(init) {
if ($.cookie('cpu')===undefined) {
if (!init) $.cookie('cpu','close',{path:'/',expires:3650});
} else {
if (!init) $.removeCookie('cpu',{path:'/'});
}
if ($.cookie('cpu')===undefined) {
$('.cpu_open').show();
$('.cpu_closed').hide();
} else {
$('.cpu_open').hide();
$('.cpu_closed').show();
}
}
$(function() {
dropdown('enter_share');
dropdown('enter_view');
toggle_CPU(true);
update3();
update60();
update30();