diff --git a/plugins/dynamix/nchan/device_list b/plugins/dynamix/nchan/device_list index 445821c23..6d121cb8e 100755 --- a/plugins/dynamix/nchan/device_list +++ b/plugins/dynamix/nchan/device_list @@ -47,15 +47,16 @@ function device_info(&$disk,$online) { $type = $disk['type']=='Flash' ? $disk['type'] : 'Device'; $action = strpos($disk['color'],'blink')===false ? 'down' : 'up'; switch ($disk['color']) { - case 'green-on': $orb = 'circle'; $color = 'green'; $help = _('Normal operation, device is active'); break; - case 'green-blink': $orb = 'circle'; $color = 'grey'; $help = _('Device is in standby mode (spun-down)'); break; - case 'blue-on': $orb = 'square'; $color = 'blue'; $help = _('New device'); break; - case 'blue-blink': $orb = 'square'; $color = 'grey'; $help = _('New device, in standby mode (spun-down)'); break; - case 'yellow-on': $orb = 'warning'; $color = 'yellow'; $help = $disk['type']=='Parity' ? _('Parity is invalid') : _('Device contents emulated'); break; - case 'yellow-blink': $orb = 'warning'; $color = 'grey'; $help = $disk['type']=='Parity' ? _('Parity is invalid, in standby mode (spun-down)') : _('Device contents emulated, in standby mode (spun-down)'); break; - case 'red-on': case 'red-blink': $orb = 'times'; $color = 'red'; $help = $disk['type']=='Parity' ? _('Parity device is disabled') : _('Device is disabled, contents emulated'); break; - case 'red-off': $orb = 'times'; $color = 'red'; $help = $disk['type']=='Parity' ? _('Parity device is missing') : _('Device is missing (disabled), contents emulated'); break; - case 'grey-off': $orb = 'square'; $color = 'grey'; $help = _('Device not present'); break; + case 'green-on': $orb = 'circle'; $color = 'green'; $help = _('Normal operation, device is active'); break; + case 'green-blink': $orb = 'circle'; $color = 'grey'; $help = _('Device is in standby mode (spun-down)'); break; + case 'blue-on': $orb = 'square'; $color = 'blue'; $help = _('New device'); break; + case 'blue-blink': $orb = 'square'; $color = 'grey'; $help = _('New device, in standby mode (spun-down)'); break; + case 'yellow-on': $orb = 'warning'; $color = 'yellow'; $help = $disk['type']=='Parity' ? _('Parity is invalid') : _('Device contents emulated'); break; + case 'yellow-blink': $orb = 'warning'; $color = 'grey'; $help = $disk['type']=='Parity' ? _('Parity is invalid, in standby mode (spun-down)') : _('Device contents emulated, in standby mode (spun-down)'); break; + case 'red-on': + case 'red-blink': $orb = 'times'; $color = 'red'; $help = $disk['type']=='Parity' ? _('Parity device is disabled') : _('Device is disabled, contents emulated'); break; + case 'red-off': $orb = 'times'; $color = 'red'; $help = $disk['type']=='Parity' ? _('Parity device is missing') : _('Device is missing (disabled), contents emulated'); break; + case 'grey-off': $orb = 'square'; $color = 'grey'; $help = _('Device not present'); break; } $ctrl = ''; if ($var['fsState']=='Started' && $type!='Flash' && strpos($disk['status'],'_NP')===false) { @@ -63,11 +64,11 @@ function device_info(&$disk,$online) { $help .= "
"._("Click to spin $action device"); } $status = "$help"; - $link = ($disk['type']=='Parity' && strpos($disk['status'],'_NP')===false) || - ($disk['type']=='Data' && $disk['status']!='DISK_NP') || - ($disk['type']=='Cache' && $disk['status']!='DISK_NP') || - ($disk['name']=='flash') || in_array($disk['name'],$pools) || - $disk['type']=='New' ? "$fancyname" : $fancyname; + $link = ($disk['type']=='Parity' && strpos($disk['status'],'_NP')===false) || + ($disk['type']=='Data' && $disk['status']!='DISK_NP') || + ($disk['type']=='Cache' && $disk['status']!='DISK_NP') || + ($disk['name']=='flash') || in_array($disk['name'],$pools) || + $disk['type']=='New' ? "$fancyname" : $fancyname; if ($crypto) switch ($disk['luksState']) { case 0: if (!vfs_luks($disk['fsType'])) @@ -101,11 +102,11 @@ function device_desc(&$disk) { global $var; $size = my_scale($disk['size'] ? $disk['size']*1024 : $disk['sectors']*$disk['sector_size'],$unit,-1); switch ($disk['type']) { - case 'Flash' : $type = 'usb'; break; + case 'Flash': $type = 'usb'; break; case 'Parity': $type = $disk['rotational'] ? 'disk' : 'nvme'; break; - case 'Data' : - case 'Cache' : $type = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme'; break; - default : $type = 'disk'; break; + case 'Data': + case 'Cache': $type = $disk['rotational'] ? ($disk['luksState'] ? 'disk-encrypted' : 'disk') : 'nvme'; break; + default: $type = 'disk'; break; } $log = $var['fsState']=='Started' ? ""._('Disk Log Information')."" @@ -114,18 +115,21 @@ function device_desc(&$disk) { } function assignment(&$disk) { global $var, $devs; - $out = "
"; - $out .= ""; - $out .= ""; - $out .= ""; + $echo[] = ""; + $echo[] = "
"; + $echo[] = ""; + $echo[] = ""; + } else { + $echo[] = ""; + } + foreach ($devs as $dev) $echo[] = ""; + $echo[] = ""; + return implode($echo); } function vfs_type($fs) { return str_replace('luks:','',$fs); @@ -154,16 +158,17 @@ function fs_info(&$disk) { $echo[] = "
".my_scale($disk['fsFree']*1024,$unit)." $unit
"; } $echo[] = "".device_browse($disk).""; - } else - $echo[] = "".vfs_type($disk['fsType']).""._($disk['fsStatus']); - return implode('',$echo); + } else { + $echo[] = "".vfs_type($disk['fsType']).""._($disk['fsStatus']).""; + } + return implode($echo); } function my_diskio($data) { return my_scale($data,$unit,1)." $unit/s"; } function array_offline(&$disk,$pool='') { global $var, $disks; - $echo = []; + $echo = []; $warning = ''; if (strpos($var['mdState'],'ERROR:')===false) { $text = ""._('All existing data on this device will be OVERWRITTEN when array is Started').""; if ($disk['type']=='Cache') { @@ -171,7 +176,7 @@ function array_offline(&$disk,$pool='') { } else { if ($var['mdState']=='NEW_ARRAY') { if ($disk['type']=='Parity') $warning = $text; - } else if ($var['mdNumInvalid']<=1) { + } elseif ($var['mdNumInvalid']<=1) { if (in_array($disk['status'],['DISK_INVALID','DISK_DSBL_NEW','DISK_WRONG','DISK_NEW'])) $warning = $text; } } @@ -207,7 +212,7 @@ function array_offline(&$disk,$pool='') { break; } $echo[] = ""; - return implode('',$echo); + return implode($echo); } function array_online(&$disk) { global $pools, $sum, $diskio; @@ -258,15 +263,15 @@ function array_online(&$disk) { break; } $echo[] = ""; - return implode('',$echo); + return implode($echo); } function show_totals($text,$array,$name) { global $var, $display, $sum, $locale; - $echo = []; $ctrl1 = "onclick=\"toggle_state('Device','$name','down')\""; $ctrl2 = "onclick=\"toggle_state('Device','$name','up')\""; $help1 = _('Spin Down').' '._(ucfirst(substr($name,0,-1))); $help2 = _('Spin Up').' '._(ucfirst(substr($name,0,-1))); + $echo = []; $echo[] = ""; $echo[] = "$help1$help2"; $echo[] = "$text"; @@ -294,39 +299,41 @@ function show_totals($text,$array,$name) { $echo[] = ""; } $echo[] = ""; - return implode('',$echo); + return implode($echo); } function array_slots() { global $var; - $min = max($var['sbNumDisks'], 3); - $max = $var['MAX_ARRAYSZ']; - $out = "
"; - $out .= ""; - $out .= ""; - $out .= ""; + $echo[] = ""; + $echo[] = "
"; - return $out; + $echo[] = ""; + return implode($echo); } function cache_slots($off,$pool,$min,$slots) { global $var; - $off = $off && $min ? ' disabled' : ''; - $max = $var['MAX_CACHESZ']; - $out = "
"; - $out .= ""; - $out .= ""; - $out .= ""; - $out .= ""; + $echo[] = ""; + $echo[] = ""; + $echo[] = "
"; - return $out; + $echo[] = ""; + return implode($echo); } function update_translation($locale) { global $docroot,$language; @@ -434,7 +441,7 @@ while (true) { if (substr($cache[$pool]['fsStatus'],0,11)=='Unmountable' && empty($disk['fsStatus'])) $disk['fsStatus'] = $cache[$pool]['fsStatus']; $echo[$n] .= array_online($disk); } - @unlink($pool_log); + delete_file($pool_log); if ($display['total'] && $cache[$pool]['devices']>1) $echo[$n] .= show_totals(sprintf(_('Pool of %s devices'),my_word($cache[$pool]['devices'])),false,"$pool*"); $sum = initSum(); }