Show permissions in properties

This commit is contained in:
Mikei386
2026-06-23 09:06:23 +02:00
parent dd011bbaa4
commit 74ba8d0984
6 changed files with 48 additions and 4 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
set -eu set -eu
PLUGIN="u-navigator" PLUGIN="u-navigator"
VERSION="2026.06.23.r012" VERSION="2026.06.23.r013"
PKG_DIR="packages" PKG_DIR="packages"
WORK_DIR=".plugin-build" WORK_DIR=".plugin-build"
PKG_NAME="${PLUGIN}-${VERSION}.tgz" PKG_NAME="${PLUGIN}-${VERSION}.tgz"
Binary file not shown.
Binary file not shown.
@@ -13,12 +13,20 @@ foreach (scandir($resolved['path']) ?: [] as $name) {
} }
$full = $resolved['path'] . '/' . $name; $full = $resolved['path'] . '/' . $name;
$type = is_link($full) ? 'symlink' : (is_dir($full) ? 'directory' : (is_file($full) ? 'file' : 'other')); $type = is_link($full) ? 'symlink' : (is_dir($full) ? 'directory' : (is_file($full) ? 'file' : 'other'));
$ownerId = fileowner($full);
$groupId = filegroup($full);
$perms = fileperms($full);
$entries[] = [ $entries[] = [
'name' => $name, 'name' => $name,
'path' => $full, 'path' => $full,
'type' => $type, 'type' => $type,
'size' => is_file($full) ? filesize($full) : 0, 'size' => is_file($full) ? filesize($full) : 0,
'modifiedAt' => date(DATE_ATOM, filemtime($full) ?: time()), 'modifiedAt' => date(DATE_ATOM, filemtime($full) ?: time()),
'owner' => unav_owner_name($ownerId),
'ownerId' => $ownerId,
'group' => unav_group_name($groupId),
'groupId' => $groupId,
'permissions' => $perms === false ? null : substr(sprintf('%o', $perms), -4),
]; ];
} }
@@ -32,3 +40,29 @@ unav_json([
'path' => $resolved['path'], 'path' => $resolved['path'],
'entries' => $entries, 'entries' => $entries,
]); ]);
function unav_owner_name($uid): ?string {
if ($uid === false) {
return null;
}
if (function_exists('posix_getpwuid')) {
$info = posix_getpwuid($uid);
if (is_array($info) && isset($info['name'])) {
return $info['name'];
}
}
return (string)$uid;
}
function unav_group_name($gid): ?string {
if ($gid === false) {
return null;
}
if (function_exists('posix_getgrgid')) {
$info = posix_getgrgid($gid);
if (is_array($info) && isset($info['name'])) {
return $info['name'];
}
}
return (string)$gid;
}
+11 -1
View File
@@ -72,7 +72,7 @@ function openExplorer(initialPath = state.config?.roots?.[0]?.path) {
path: initialPath, path: initialPath,
entries: [], entries: [],
selectedPath: null, selectedPath: null,
view: 'list', view: 'icons',
loading: false, loading: false,
error: null error: null
} }
@@ -347,6 +347,9 @@ function renderProperties(body) {
<dt>Pfad</dt><dd>${escapeHtml(entry.path)}</dd> <dt>Pfad</dt><dd>${escapeHtml(entry.path)}</dd>
<dt>Größe</dt><dd>${formatBytes(entry.size)}</dd> <dt>Größe</dt><dd>${formatBytes(entry.size)}</dd>
<dt>Geändert</dt><dd>${new Date(entry.modifiedAt).toLocaleString()}</dd> <dt>Geändert</dt><dd>${new Date(entry.modifiedAt).toLocaleString()}</dd>
<dt>Besitzer</dt><dd>${escapeHtml(formatPrincipal(entry.owner, entry.ownerId))}</dd>
<dt>Gruppe</dt><dd>${escapeHtml(formatPrincipal(entry.group, entry.groupId))}</dd>
<dt>Rechte</dt><dd>${escapeHtml(entry.permissions ? `0${entry.permissions}`.slice(-4) : '-')}</dd>
</dl> </dl>
`; `;
} }
@@ -958,6 +961,13 @@ function formatBytes(bytes) {
return `${(value / 1024 / 1024 / 1024).toFixed(1)} GB`; return `${(value / 1024 / 1024 / 1024).toFixed(1)} GB`;
} }
function formatPrincipal(name, id) {
if (name == null && id == null) return '-';
if (name == null || String(name) === String(id)) return String(id);
if (id == null) return String(name);
return `${name} (${id})`;
}
function escapeHtml(value) { function escapeHtml(value) {
return String(value ?? '').replace(/[&<>"']/g, (char) => ({ return String(value ?? '').replace(/[&<>"']/g, (char) => ({
'&': '&amp;', '&': '&amp;',
+2 -2
View File
@@ -1,7 +1,7 @@
<!DOCTYPE PLUGIN [ <!DOCTYPE PLUGIN [
<!ENTITY name "u-navigator"> <!ENTITY name "u-navigator">
<!ENTITY author "michael"> <!ENTITY author "michael">
<!ENTITY version "2026.06.23.r012"> <!ENTITY version "2026.06.23.r013">
<!ENTITY package "&name;-&version;.tgz"> <!ENTITY package "&name;-&version;.tgz">
]> ]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg"> <PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
@@ -14,7 +14,7 @@
<FILE Name="/boot/config/plugins/&name;/&package;"> <FILE Name="/boot/config/plugins/&name;/&package;">
<URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL> <URL>https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package;</URL>
<MD5>3ab1180514677a7270013846b08706b0</MD5> <MD5>b72f22b37e34b4bdfd93a57c138af2d0</MD5>
</FILE> </FILE>
<FILE Run="/bin/bash"> <FILE Run="/bin/bash">