Multi cache pool support

This commit is contained in:
bergware
2020-04-12 12:31:52 +02:00
parent c661dcaaee
commit a2a4e051f5
4 changed files with 22 additions and 20 deletions

View File

@@ -14,14 +14,18 @@ Markdown="false"
* all copies or substantial portions of the Software.
*/
?>
<?
[$root,$main,$rest] = explode('/',substr($dir,1),3);
$user = ($root=='mnt' && ($main=='user'|| $main=='user0')) ? 1 : 0;
?>
<style>
.loc{text-align:left}
.loc{text-align:left!important}
#title span.left{text-transform:none}
</style>
<script>
$(function(){
timers.browse = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.get('/webGui/include/Browse.php',{dir:"<?=addslashes(urlencode($dir))?>",path:"<?=$path?>",user:<?=substr($dir,0,9)=='/mnt/user'?1:0?>},function(data){
$.get('/webGui/include/Browse.php',{dir:"<?=addslashes(urlencode($dir))?>",path:"<?=$path?>",user:<?=$user?>},function(data){
clearTimeout(timers.browse);
var table = $('table.indexer');
var col = $.cookie('col')||1;
@@ -38,7 +42,7 @@ $(function(){
});
</script>
<table class="indexer tablesorter shift">
<thead><tr><th>_(Type)_</th><th class='sorter-text'>_(Name)_</th><th>_(Size)_</th><th>_(Last Modified)_</th><th>_(Location)_</th></tr></thead>
<thead><tr><th>_(Type)_</th><th class='sorter-text'>_(Name)_</th><th>_(Size)_</th><th>_(Last Modified)_</th><th style="width:200px">_(Location)_</th></tr></thead>
<tbody><tr><td colspan="5">&nbsp;</td></tr></tbody>
</table>
<input type="button" value="_(Done)_" onclick="done('Browse')">

View File

@@ -23,22 +23,20 @@ function parent_link() {
return ($dir && dirname($dir)!='/' && dirname($dir)!='/mnt' && dirname($dir)!='/mnt/user') ? "<a href=\"/$path?dir=".htmlspecialchars(urlencode_path(dirname($dir)))."\">Parent Directory</a>" : "";
}
function trim_slash($url){
return preg_replace('/\/\/+/','/',$url);
return preg_replace('://+:','/',$url);
}
function my_devs(&$devs) {
global $disks;
$text = []; $i = 0;
foreach ($devs as $dev) {
$text[$i] = my_lang(my_disk($dev),3);
if (substr($disks[$dev]['fsType'],0,5)=='luks:') {
switch ($disks[$dev]['luksState']) {
case 0: $text[$i] .= "<a class='info' onclick='return false'><i class='lock fa fa-unlock grey-text'></i><span>"._('Not encrypted')."</span></a>"; break;
case 1: $text[$i] .= "<a class='info' onclick='return false'><i class='lock fa fa-unlock-alt green-text'></i><span>"._('Encrypted and unlocked')."</span></a>"; break;
case 2: $text[$i] .= "<a class='info' onclick='return false'><i class='lock fa fa-lock red-text'></i><span>"._('Locked: missing encryption key')."</span></a>"; break;
case 3: $text[$i] .= "<a class='info' onclick='return false'><i class='lock fa fa-lock red-text'></i><span>"._('Locked: wrong encryption key')."</span></a>"; break;
default: $text[$i] .= "<a class='info' onclick='return false'><i class='lock fa fa-lock red-text'></i><span>"._('Locked: unknown error')."</span></a>"; break;}
switch ($disks[$dev]['luksState']) {
case 0: $text[$i] = "<a class='info' onclick='return false'><i class='lock fa fa-fw fa-unlock grey-text'></i><span>"._('Not encrypted')."</span></a>"; break;
case 1: $text[$i] = "<a class='info' onclick='return false'><i class='lock fa fa-fw fa-unlock-alt green-text'></i><span>"._('Encrypted and unlocked')."</span></a>"; break;
case 2: $text[$i] = "<a class='info' onclick='return false'><i class='lock fa fa-fw fa-lock red-text'></i><span>"._('Locked: missing encryption key')."</span></a>"; break;
case 3: $text[$i] = "<a class='info' onclick='return false'><i class='lock fa fa-fw fa-lock red-text'></i><span>"._('Locked: wrong encryption key')."</span></a>"; break;
default: $text[$i] = "<a class='info' onclick='return false'><i class='lock fa fa-fw fa-lock red-text'></i><span>"._('Locked: unknown error')."</span></a>"; break;
}
$i++;
$text[$i++] .= compress($dev,8,0);
}
return implode(', ',$text);
}
@@ -48,7 +46,7 @@ $dir = urldecode($_GET['dir']);
$path = $_GET['path'];
$user = $_GET['user'];
$all = $docroot.preg_replace('/([\'" &()[\]\\\\])/','\\\\$1',$dir).'/*';
$fix = substr($dir,0,4)=='/mnt' ? explode('/',trim_slash($dir))[2] : 'flash';
$fix = substr($dir,0,4)=='/mnt' ? (explode('/',trim_slash($dir))[2] ?: _('---')) : _('flash');
$fmt = "%F {$display['time']}";
$dirs = $files = [];
$total = $i = 0;
@@ -64,7 +62,7 @@ while (($row = fgets($stat))!==false) {
}
pclose($stat);
echo "<thead><tr><th>"._('Type')."</th><th class='sorter-text'>"._('Name')."</th><th>"._('Size')."</th><th>"._('Last Modified')."</th><th>"._('Location')."</th></tr></thead>";
echo "<thead><tr><th>"._('Type')."</th><th class='sorter-text'>"._('Name')."</th><th>"._('Size')."</th><th>"._('Last Modified')."</th><th style='width:200px'>"._('Location')."</th></tr></thead>";
if ($link = parent_link()) echo "<tbody class='tablesorter-infoOnly'><tr><td><div><img src='/webGui/icons/folderup.png'></div></td><td>$link</td><td colspan='3'></td></tr></tbody>";
echo "<tbody>";

View File

@@ -72,7 +72,7 @@ function device_info(&$disk,$online) {
($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' ? "<a href=\"".htmlspecialchars("$path/$type?name=$name")."\">".compress($fancyname,15,5)."</a>" : compress($fancyname,15,5);
$disk['type']=='New' ? "<a href=\"".htmlspecialchars("$path/$type?name=$name")."\">".compress($fancyname,12,5)."</a>" : compress($fancyname,12,5);
if ($crypto) switch ($disk['luksState']) {
case 0:
if (!vfs_luks($disk['fsType']))

View File

@@ -52,9 +52,9 @@ function my_temp($value) {
$number = $display['number'];
return is_numeric($value) ? (($unit=='F' ? round(9/5*$value+32) : str_replace('.', $number[0], $value))." $unit") : $value;
}
function my_disk($name) {
function my_disk($name,$raw=false) {
global $display;
return $display['raw'] ? $name : ucfirst(preg_replace('/(\d+)$/',' $1',$name));
return $display['raw']||$raw ? $name : ucfirst(preg_replace('/(\d+)$/',' $1',$name));
}
function my_disks($disk) {
return strpos($disk['status'],'_NP')===false;
@@ -188,8 +188,8 @@ function day_count($time) {
function plus($val, $word, $last) {
return $val>0 ? (($val || $last) ? ($val.' '.$word.($val!=1?'s':'').($last ?'':', ')) : '') : '';
}
function compress($name,$size=20,$end=6) {
return strlen($name)<=$size ? $name : substr($name,0,$size-$end-3).'...'.substr($name,-$end);
function compress($name,$size=18,$end=6) {
return strlen($name)<=$size ? $name : substr($name,0,$size-($end?$end-3:0)).'...'.($end?substr($name,-$end):'');
}
function read_parity_log($epoch, $busy=false) {