Display pools in a single table

This commit is contained in:
bergware
2023-12-12 16:04:22 +01:00
parent 8617dc0d92
commit 8b9f99adbf
3 changed files with 18 additions and 14 deletions
+6 -2
View File
@@ -132,24 +132,28 @@ $('#tab2').bind({click:function() {$('i.toggle').show('slow');}});
<?endif;?>
</script>
<table class="unraid disk_status">
<?$i = 0?>
<?foreach ($pools as $pool):?>
<?if (isset($disks[$pool]['devices']) or _var($var,'fsState')=="Stopped"):?>
<table class="unraid disk_status<?=$i ? ' divider' : ''?>">
<?if (!isSubpool($pool)):
$cache = array_filter(cache_filter($disks),function($disk) use ($pool){return prefix($disk['name'])==$pool;});
$power = _var($display,'power') && in_array('nvme',array_column($cache,'transport')) ? ' / '._('Power') : '';
$root = explode($_tilde_,$pool)[0];
?>
<?if ($i==0):?>
<thead><tr><td>_(Device)_</td><td>_(Identification)_</td><td>_(Temp)_<?=$power?></td><td>_(Reads)_</td><td>_(Writes)_</td><td>_(Errors)_</td><td>_(FS)_</td><td>_(Size)_</td><td>_(Used)_</td><td>_(Free)_</td></tr></thead>
<?else:?>
<thead><tr><td class="divider" colspan="10"></td></td></tr></thead>
<?endif;?>
<?endif;?>
<tbody id="pool_device<?=$i++?>">
<?foreach ($cache as $disk) if (substr($disk['status'],0,7)!='DISK_NP') echo "<tr><td colspan='10'></td></tr>"?>
<?if (_var($display,'total') && _var($cache[$root],'devices',0)>1) echo "<tr class='tr_last'><td colspan='10'></td></tr>"?>
</tbody>
</table>
<?endif;?>
<?endforeach;?>
</table>
:cache_devices_help:
+11 -11
View File
@@ -154,7 +154,7 @@ function fs_info(&$disk) {
global $display, $pools;
$echo = [];
if (empty($disk['fsStatus']) || $disk['fsStatus']=='-') {
return (_var($disk,'type')=='Cache' && !in_array(_var($disk,'name'),$pools)) ? "<td colspan='4'>"._('Device is part of a pool')."</td>" : "<td></td><td></td><td></td><td></td>";
return (_var($disk,'type')=='Cache' && !in_array(_var($disk,'name'),$pools)) ? "<td colspan='4'>"._('Device is part of a pool')."</td>" : "<td colspan='4'></td>";
} elseif (_var($disk,'fsStatus')=='Mounted') {
$echo[] = "<td>".vfs_info(_var($disk,'fsType'))."</td>";
$echo[] = "<td>".my_scale(_var($disk,'fsSize',0)*1024,$unit,-1)." $unit</td>";
@@ -201,12 +201,12 @@ function array_offline(&$disk, $pool='') {
case 'DISK_NP_DSBL':
$echo[] = "<td>".device_info($disk,false)."</td>";
$echo[] = "<td>".assignment($disk)."</td>";
$echo[] = "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>";
$echo[] = "<td colspan='8'></td>";
break;
case 'DISK_NP_MISSING':
$echo[] = "<td>".device_info($disk,false)."<br><span class='diskinfo'><em>"._('Missing')."</em></span></td>";
$echo[] = "<td>".assignment($disk)."<em>{$disk['idSb']} - ".my_scale(_var($disk,'sizeSb',0)*1024,$unit)." $unit</em></td>";
$echo[] = "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>";
$echo[] = "<td colspan='8'></td>";
break;
case 'DISK_OK':
case 'DISK_DSBL':
@@ -219,9 +219,9 @@ function array_offline(&$disk, $pool='') {
if ($warning) {
$echo[] = "<td colspan='7'>$warning</td>";
} else {
$echo[] = "<td></td><td></td><td></td>";
$echo[] = "<td colspan='3'></td>";
$echo[] = "<td>".vfs_type(_var($disk,'fsType'))."</td>";
$echo[] = "<td></td><td></td><td></td>";
$echo[] = "<td colspan='3'></td>";
}
break;
case 'DISK_WRONG':
@@ -231,9 +231,9 @@ function array_offline(&$disk, $pool='') {
if ($warning) {
$echo[] = "<td colspan='7'>$warning</td>";
} else {
$echo[] = "<td></td><td></td><td></td>";
$echo[] = "<td colspan='3'></td>";
$echo[] = "<td>".vfs_type(_var($disk,'fsType'))."</td>";
$echo[] = "<td></td><td></td><td></td>";
$echo[] = "<td colspan='3'></td>";
}
break;
}
@@ -270,14 +270,14 @@ function array_online(&$disk, $fstype='') {
if (in_array(_var($disk,'name'),$pools) || $fstype=='zfs') {
$echo[] = "<td>".device_info($disk,true)."</td>";
$echo[] = "<td><a class='static'><i class='icon-disk icon'></i><span></span></a><em>".($fstype=='zfs' ? _('Not present') : _('Not installed'))."</em></td>";
$echo[] = "<td></td><td></td><td></td><td></td>";
$echo[] = "<td colspan='4'></td>";
$echo[] = fs_info($disk);
}
break;
case 'DISK_NP_DSBL':
$echo[] = "<td>".device_info($disk,true)."</td>";
$echo[] = "<td><a class='static'><i class='icon-disk icon'></i><span></span></a><em>"._('Not installed')."</em></td>";
$echo[] = "<td></td><td></td><td></td><td></td>";
$echo[] = "<td colspan='4'></td>";
$echo[] = fs_info($disk);
break;
case 'DISK_DSBL':
@@ -325,7 +325,7 @@ function show_totals($text,$array,$name) {
$echo[] = "<td><div class='usage-disk'><span style='width:$free%' class='".usage_color($display,$free,true)."'></span><span>".my_scale($sum['fsFree']*1024,$unit)." $unit</span></div></td>";
}
} else {
$echo[] = "<td></td><td></td><td></td>";
$echo[] = "<td colspan='3'></td>";
}
$echo[] = "</tr>";
return implode($echo);
@@ -493,7 +493,7 @@ while (true) {
$sum = initSum();
}
}
$n++;
$n++;
}
$echo[$n] = "open_devices\n";
@@ -1,2 +1,2 @@
table.divider{margin-top:20px}
td.divider{line-height:16px;height:16px}
div.template{display:none}