Add delete actions
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
PLUGIN="u-navigator"
|
PLUGIN="u-navigator"
|
||||||
VERSION="2026.06.23.r041"
|
VERSION="2026.06.23.r042"
|
||||||
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.
@@ -6,7 +6,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$action = $_GET['action'] ?? '';
|
$action = $_GET['action'] ?? '';
|
||||||
if (!in_array($action, ['move', 'copy', 'size', 'permissions'], true)) {
|
if (!in_array($action, ['move', 'copy', 'delete', 'size', 'permissions'], true)) {
|
||||||
unav_error(404, 'Unknown job action');
|
unav_error(404, 'Unknown job action');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +18,8 @@ if (in_array($action, ['move', 'copy'], true)) {
|
|||||||
unav_assert_writable();
|
unav_assert_writable();
|
||||||
$destination = unav_destination_path($data['destination'] ?? null);
|
$destination = unav_destination_path($data['destination'] ?? null);
|
||||||
unav_guard_destination($source['path'], $destination['path']);
|
unav_guard_destination($source['path'], $destination['path']);
|
||||||
|
} elseif ($action === 'delete') {
|
||||||
|
unav_assert_writable();
|
||||||
} elseif ($action === 'permissions') {
|
} elseif ($action === 'permissions') {
|
||||||
unav_assert_writable();
|
unav_assert_writable();
|
||||||
$permissions = unav_permission_options($data);
|
$permissions = unav_permission_options($data);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ function unav_run_job(string $id): void {
|
|||||||
} elseif ($job['type'] === 'copy') {
|
} elseif ($job['type'] === 'copy') {
|
||||||
unav_worker_guard($job['source'], $job['destination']);
|
unav_worker_guard($job['source'], $job['destination']);
|
||||||
unav_worker_copy($job['source'], $job['destination'], $job);
|
unav_worker_copy($job['source'], $job['destination'], $job);
|
||||||
|
} elseif ($job['type'] === 'delete') {
|
||||||
|
unav_worker_delete_job($job['source'], $job);
|
||||||
} elseif ($job['type'] === 'size') {
|
} elseif ($job['type'] === 'size') {
|
||||||
$result = unav_worker_size($job['source'], $job);
|
$result = unav_worker_size($job['source'], $job);
|
||||||
$job['result'] = $result;
|
$job['result'] = $result;
|
||||||
@@ -90,6 +92,12 @@ function unav_worker_move(string $source, string $destination, array &$job): voi
|
|||||||
unav_worker_delete($source);
|
unav_worker_delete($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unav_worker_delete_job(string $source, array &$job): void {
|
||||||
|
$sourceReal = unav_worker_guard_source($source);
|
||||||
|
unav_worker_update($job, 'running', 15, 'Deleting');
|
||||||
|
unav_worker_delete($sourceReal);
|
||||||
|
}
|
||||||
|
|
||||||
function unav_worker_size(string $source, array &$job): array {
|
function unav_worker_size(string $source, array &$job): array {
|
||||||
$sourceReal = unav_worker_guard_source($source);
|
$sourceReal = unav_worker_guard_source($source);
|
||||||
unav_worker_update($job, 'running', 10, 'Calculating size');
|
unav_worker_update($job, 'running', 10, 'Calculating size');
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ function renderExplorer(body, win) {
|
|||||||
<button class="icon" data-action="refresh" title="Neu laden" aria-label="Neu laden">↻</button>
|
<button class="icon" data-action="refresh" title="Neu laden" aria-label="Neu laden">↻</button>
|
||||||
<button class="icon" data-action="upload-files" title="Dateien hochladen" aria-label="Dateien hochladen" ${isReadOnly() ? 'disabled' : ''}>⤴</button>
|
<button class="icon" data-action="upload-files" title="Dateien hochladen" aria-label="Dateien hochladen" ${isReadOnly() ? 'disabled' : ''}>⤴</button>
|
||||||
<button class="icon" data-action="upload-folder" title="Ordner hochladen" aria-label="Ordner hochladen" ${isReadOnly() ? 'disabled' : ''}>⇪</button>
|
<button class="icon" data-action="upload-folder" title="Ordner hochladen" aria-label="Ordner hochladen" ${isReadOnly() ? 'disabled' : ''}>⇪</button>
|
||||||
|
<button class="icon danger" data-action="delete-selected" title="Auswahl löschen" aria-label="Auswahl löschen" ${isReadOnly() ? 'disabled' : ''}>×</button>
|
||||||
<input class="upload-input" data-upload="files" type="file" multiple>
|
<input class="upload-input" data-upload="files" type="file" multiple>
|
||||||
<input class="upload-input" data-upload="folder" type="file" multiple webkitdirectory directory>
|
<input class="upload-input" data-upload="folder" type="file" multiple webkitdirectory directory>
|
||||||
<div class="view-toggle" aria-label="Ansicht">
|
<div class="view-toggle" aria-label="Ansicht">
|
||||||
@@ -293,6 +294,7 @@ function renderExplorer(body, win) {
|
|||||||
body.querySelector('[data-action="view-icons"]').addEventListener('click', () => setExplorerView(win, 'icons'));
|
body.querySelector('[data-action="view-icons"]').addEventListener('click', () => setExplorerView(win, 'icons'));
|
||||||
body.querySelector('[data-action="upload-files"]').addEventListener('click', () => body.querySelector('[data-upload="files"]').click());
|
body.querySelector('[data-action="upload-files"]').addEventListener('click', () => body.querySelector('[data-upload="files"]').click());
|
||||||
body.querySelector('[data-action="upload-folder"]').addEventListener('click', () => body.querySelector('[data-upload="folder"]').click());
|
body.querySelector('[data-action="upload-folder"]').addEventListener('click', () => body.querySelector('[data-upload="folder"]').click());
|
||||||
|
body.querySelector('[data-action="delete-selected"]').addEventListener('click', () => deleteEntries(win));
|
||||||
for (const inputEl of body.querySelectorAll('.upload-input')) {
|
for (const inputEl of body.querySelectorAll('.upload-input')) {
|
||||||
inputEl.addEventListener('change', async () => {
|
inputEl.addEventListener('change', async () => {
|
||||||
try {
|
try {
|
||||||
@@ -1042,6 +1044,25 @@ async function promptTransfer(win, entry, type) {
|
|||||||
await createJob(type, entry.path, `${targetDir.replace(/\/$/, '')}/${entry.name}`, []);
|
await createJob(type, entry.path, `${targetDir.replace(/\/$/, '')}/${entry.name}`, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteEntries(win, entry = null) {
|
||||||
|
if (isReadOnly()) {
|
||||||
|
showError(new Error('Read-only mode ist aktiv.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const entries = entry && selectedPathSet(win).has(entry.path) ? selectedEntries(win) : (entry ? [entry] : selectedEntries(win));
|
||||||
|
if (!entries.length) {
|
||||||
|
showError(new Error('Keine Datei ausgewählt.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const label = entries.length === 1 ? `"${entries[0].name}" wirklich löschen?` : `${entries.length} Objekte wirklich löschen?`;
|
||||||
|
if (!confirm(`${label}\n\nDieser Vorgang löscht direkt vom Dateisystem.`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const item of entries) {
|
||||||
|
await createJob('delete', item.path, null, [win.id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openPermissionsDialog(win, entry) {
|
function openPermissionsDialog(win, entry) {
|
||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
showError(new Error('Read-only mode ist aktiv.'));
|
showError(new Error('Read-only mode ist aktiv.'));
|
||||||
@@ -1301,6 +1322,7 @@ function renderContextMenu() {
|
|||||||
actions.push(['Berechtigungen...', () => openPermissionsDialog(win, entry)]);
|
actions.push(['Berechtigungen...', () => openPermissionsDialog(win, entry)]);
|
||||||
actions.push(['Kopieren nach...', () => promptTransfer(win, entry, 'copy')]);
|
actions.push(['Kopieren nach...', () => promptTransfer(win, entry, 'copy')]);
|
||||||
actions.push(['Verschieben nach...', () => promptTransfer(win, entry, 'move')]);
|
actions.push(['Verschieben nach...', () => promptTransfer(win, entry, 'move')]);
|
||||||
|
actions.push(['Löschen', () => deleteEntries(win, entry)]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
actions.push(['Aktuellen Ordner herunterladen', () => downloadEntries(win, null)]);
|
actions.push(['Aktuellen Ordner herunterladen', () => downloadEntries(win, null)]);
|
||||||
|
|||||||
@@ -57,6 +57,14 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.u-nav button.danger {
|
||||||
|
color: #c4382d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.u-nav button.danger:hover {
|
||||||
|
border-color: #c4382d;
|
||||||
|
}
|
||||||
|
|
||||||
.u-nav button.icon {
|
.u-nav button.icon {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE PLUGIN [
|
<!DOCTYPE PLUGIN [
|
||||||
<!ENTITY name "u-navigator">
|
<!ENTITY name "u-navigator">
|
||||||
<!ENTITY author "Michael Roll">
|
<!ENTITY author "Michael Roll">
|
||||||
<!ENTITY version "2026.06.23.r041">
|
<!ENTITY version "2026.06.23.r042">
|
||||||
<!ENTITY package "&name;-&version;.tgz">
|
<!ENTITY package "&name;-&version;.tgz">
|
||||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
<!ENTITY pluginURL "https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/u-navigator.plg">
|
||||||
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
<!ENTITY support "https://git.casaderoll.de/michael/Unraid-Navigator">
|
||||||
@@ -24,7 +24,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>381ba21ef4664561c9a69ddada5b5b15</MD5>
|
<MD5>b6edc78a8c0336b58273aa31ab69a2af</MD5>
|
||||||
</FILE>
|
</FILE>
|
||||||
|
|
||||||
<FILE Run="/bin/bash">
|
<FILE Run="/bin/bash">
|
||||||
|
|||||||
Reference in New Issue
Block a user