Add permission update jobs

This commit is contained in:
Mikei386
2026-06-23 14:35:33 +02:00
parent 69367fc0d8
commit 1e20799499
8 changed files with 137 additions and 9 deletions
+48 -5
View File
@@ -343,7 +343,13 @@ function renderExplorer(body, win) {
row.addEventListener('contextmenu', (event) => {
event.preventDefault();
event.stopPropagation();
selectEntry(win, entry, null, event);
if (selectedPathSet(win).has(entry.path)) {
state.selectedEntry = entry;
focusWindow(win);
updatePropertiesWindows();
} else {
selectEntry(win, entry, null, event);
}
showContextMenu(event, win, entry);
});
}
@@ -875,15 +881,22 @@ async function handleDrop(event, win, targetPath) {
}
}
async function createJob(type, source, destination, refreshWindowIds = []) {
if (['move', 'copy'].includes(type) && isReadOnly()) {
async function createJob(type, source, destination = null, refreshWindowIds = [], extra = {}) {
if (['move', 'copy', 'permissions'].includes(type) && isReadOnly()) {
showError(new Error('Read-only mode ist aktiv.'));
return null;
}
recordDebug('job.create.request', { type, source, destination, refreshWindowIds });
recordDebug('job.create.request', { type, source, destination, refreshWindowIds, extra });
const body = new URLSearchParams();
body.set('source', source);
body.set('destination', destination);
if (destination !== null) {
body.set('destination', destination);
}
for (const [key, value] of Object.entries(extra)) {
if (value !== null && value !== undefined) {
body.set(key, String(value));
}
}
appendCsrf(body);
const job = await api(apiUrl(`job.php?action=${encodeURIComponent(type)}`), {
method: 'POST',
@@ -999,6 +1012,35 @@ async function promptTransfer(win, entry, type) {
await createJob(type, entry.path, `${targetDir.replace(/\/$/, '')}/${entry.name}`, []);
}
async function promptPermissions(win, entry) {
if (isReadOnly()) {
showError(new Error('Read-only mode ist aktiv.'));
return;
}
const entries = selectedPathSet(win).has(entry.path) ? selectedEntries(win) : [entry];
const mode = prompt('Berechtigungen als Oktalmodus, z.B. 0644 oder 0755', entry.permissions ? `0${entry.permissions}`.slice(-4) : '');
if (mode === null) return;
const owner = prompt('Besitzer ändern, leer lassen für unverändert', entry.owner || '');
if (owner === null) return;
const group = prompt('Gruppe ändern, leer lassen für unverändert', entry.group || '');
if (group === null) return;
const hasDirectory = entries.some((item) => item.type === 'directory');
const recursive = hasDirectory && confirm('Rekursiv auf Unterordner und Dateien anwenden?');
const options = {
mode: mode.trim(),
owner: owner.trim(),
group: group.trim(),
recursive: recursive ? '1' : '0'
};
if (!options.mode && !options.owner && !options.group) {
showError(new Error('Keine Änderung angegeben.'));
return;
}
for (const item of entries) {
await createJob('permissions', item.path, null, [win.id], options);
}
}
function showPropertiesForEntry(win, entry) {
selectEntry(win, entry);
openProperties(entry);
@@ -1034,6 +1076,7 @@ function renderContextMenu() {
actions.push(['Eigenschaften', () => showPropertiesForEntry(win, entry)]);
if (!isReadOnly()) {
actions.push(['Umbenennen', () => renameEntry(win, entry)]);
actions.push(['Berechtigungen...', () => promptPermissions(win, entry)]);
actions.push(['Kopieren nach...', () => promptTransfer(win, entry, 'copy')]);
actions.push(['Verschieben nach...', () => promptTransfer(win, entry, 'move')]);
}