mirror of
https://github.com/unraid/webgui.git
synced 2026-01-03 08:00:57 -06:00
file manager: add UD selection
This commit is contained in:
@@ -360,10 +360,10 @@ function doAction(action, title, id) {
|
||||
if (!access.includes(path[0])) return;
|
||||
var user = /^(user0?|rootshare)$/.test(path[1]);
|
||||
var root = '/'+path[0]+(user ? '/'+path[1] : '');
|
||||
var share = user||!path[2]||(link&&path.length==3) ? '' : path[2]+'/';
|
||||
var share = user || !path[2] || (link && path.length==3) ? '' : path[2]+'/';
|
||||
var ud = ['disks','remotes'].includes(path[1]); // unassigned devices
|
||||
var match = ud||user ? '' : '^(?!\\/mnt\\/user0?\\/).*$';
|
||||
var name = path.pop()||path.pop();
|
||||
var match = ud || user ? '' : '^(?!\\/mnt\\/(user0?|rootshare)\\/).*$';
|
||||
var name = path.pop() || path.pop();
|
||||
var hdlink = "<?=$var['fuse_directio'] == 1 ? '1' : ''?>";
|
||||
dfm.window = $("#dfm_dialogWindow");
|
||||
switch (action) {
|
||||
@@ -625,10 +625,10 @@ function doActions(action, title) {
|
||||
if (!access.includes(path[0])) return;
|
||||
var user = /^(user0?|rootshare)$/.test(path[1]);
|
||||
var root = '/'+path[0]+(user ? '/'+path[1] : '');
|
||||
var share = user||!path[2] ? '' : path[2]+'/';
|
||||
var share = user || !path[2] ? '' : path[2]+'/';
|
||||
var ud = ['disks','remotes'].includes(path[1]); // unassigned devices
|
||||
var match = ud||user ? '' : '^(?!.*(user0?|rootshare)).*$';
|
||||
var name = path.pop()||path.pop();
|
||||
var match = ud || user ? '' : '^(?!\\/mnt\\/(user0?|rootshare)\\/).*$';
|
||||
var name = path.pop() || path.pop();
|
||||
var hdlink = "<?=$var['fuse_directio'] == 1 ? '1' : ''?>";
|
||||
var u = false;
|
||||
var d = false;
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
function path($dir) {
|
||||
return mb_substr($dir,-1)=='/' ? $dir : $dir.'/';
|
||||
return mb_substr($dir,-1) == '/' ? $dir : $dir.'/';
|
||||
}
|
||||
function is_top($dir) {
|
||||
global $root;
|
||||
return mb_strlen($dir)>mb_strlen($root);
|
||||
return mb_strlen($dir) > mb_strlen($root);
|
||||
}
|
||||
function is_low($dir) {
|
||||
global $root;
|
||||
return mb_substr($dir,0,mb_strlen($root))==$root;
|
||||
return mb_substr($dir,0,mb_strlen($root)) == $root;
|
||||
}
|
||||
|
||||
$root = path(realpath($_POST['root']));
|
||||
@@ -47,36 +47,46 @@ require_once "$docroot/webGui/include/Secure.php";
|
||||
$rootdir = path(realpath($_POST['dir']));
|
||||
$filters = (array)$_POST['filter'];
|
||||
$match = $_POST['match'];
|
||||
$checkbox = $_POST['multiSelect']=='true' ? "<input type='checkbox'>" : "";
|
||||
$checkbox = $_POST['multiSelect'] == 'true' ? "<input type='checkbox'>" : "";
|
||||
|
||||
/* Excluded folders to not show in the dropdown in the '/mnt/' directory only. */
|
||||
$excludedFolders = ["RecycleBin", "addons", "rootshare", "user0"];
|
||||
$excludedFolders = ['RecycleBin', 'addons', 'rootshare'];
|
||||
|
||||
$udShares = ['addons','disks','remotes'];
|
||||
|
||||
echo "<ul class='jqueryFileTree'>";
|
||||
if ($_POST['show_parent']=='true' && is_top($rootdir)) echo "<li class='directory collapsed'>$checkbox<a href='#' rel=\"".htmlspecialchars(dirname($rootdir))."\">..</a></li>";
|
||||
if ($_POST['show_parent'] == 'true' && is_top($rootdir)) {
|
||||
echo "<li class='directory collapsed'>$checkbox<a href='#' rel=\"".htmlspecialchars(dirname($rootdir))."\">..</a></li>";
|
||||
}
|
||||
|
||||
if (is_low($rootdir) && is_dir($rootdir)) {
|
||||
$dirs = $files = [];
|
||||
$names = array_filter(scandir($rootdir, SCANDIR_SORT_NONE), function($n) { return $n != '.' && $n != '..'; });
|
||||
$names = array_filter(scandir($rootdir, SCANDIR_SORT_NONE), function($n){return $n != '.' && $n != '..';});
|
||||
if (is_top($rootdir)) {
|
||||
// add unassigned devices top level shares
|
||||
foreach ($udShares as $name) if (is_dir($rootdir.$name) && !in_array($name, $names)) $names[] = $name;
|
||||
}
|
||||
natcasesort($names);
|
||||
foreach ($names as $name) {
|
||||
if (is_dir($rootdir . $name)) {
|
||||
if (is_dir($rootdir.$name)) {
|
||||
$dirs[] = $name;
|
||||
} else {
|
||||
$files[] = $name;
|
||||
}
|
||||
}
|
||||
foreach ($dirs as $name) {
|
||||
$htmlRel = htmlspecialchars($rootdir . $name);
|
||||
$htmlName = htmlspecialchars(mb_strlen($name) <= 33 ? $name : mb_substr($name, 0, 30) . '...');
|
||||
$htmlRel = htmlspecialchars($rootdir.$name);
|
||||
$htmlName = htmlspecialchars(mb_strlen($name) <= 33 ? $name : mb_substr($name, 0, 30).'...');
|
||||
|
||||
/* Exclude '.Recycle.Bin' from all directories */
|
||||
if ($name === ".Recycle.Bin") continue;
|
||||
if ($name === '.Recycle.Bin') continue;
|
||||
|
||||
/* Exclude folders only when directory is '/mnt/' */
|
||||
if (in_array($name, $excludedFolders) && $rootdir === "/mnt/") continue;
|
||||
if (in_array($name, $excludedFolders) && $rootdir === '/mnt/') continue;
|
||||
|
||||
echo "<li class='directory collapsed'>$checkbox<a href='#' rel=\"$htmlRel/\">$htmlName</a></li>";
|
||||
if (empty($match) || preg_match("/$match/", $rootdir.$name.'/')) {
|
||||
echo "<li class='directory collapsed'>$checkbox<a href='#' rel=\"$htmlRel/\">$htmlName</a></li>";
|
||||
}
|
||||
}
|
||||
foreach ($files as $name) {
|
||||
$htmlRel = htmlspecialchars($rootdir . $name);
|
||||
|
||||
Reference in New Issue
Block a user