From 9a7321834cb34899033bcae89ec340cce81ad37b Mon Sep 17 00:00:00 2001 From: kodi Date: Fri, 20 Feb 2026 11:13:24 +0100 Subject: [PATCH] feat(files-dashboard) mappen in en uitklapbaar --- webui/html/index.html | 62 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/webui/html/index.html b/webui/html/index.html index ff8b87c..7dbadea 100644 --- a/webui/html/index.html +++ b/webui/html/index.html @@ -381,6 +381,24 @@ .sidebar .navLabel { display: none; } .sidebar .tab { justify-content: center; } } + .file-folder-row{ + display:flex; + align-items:center; + justify-content:space-between; + gap:10px; + cursor:pointer; + user-select:none; + } + + .file-folder-left{ + display:flex; + align-items:center; + gap:10px; + } + + .file-folder-files{ + margin-left: 18px; + } @@ -861,6 +879,15 @@ localStorage.setItem('pod_group_collapsed:' + pod, v ? '1' : '0'); } + function _isFolderCollapsed(folderKey) { + return localStorage.getItem('files_folder_collapsed:' + folderKey) !== '0'; + // default collapsed = true + } + + function _setFolderCollapsed(folderKey, v) { + localStorage.setItem('files_folder_collapsed:' + folderKey, v ? '1' : '0'); + } + function renderActionsDropdown(menuId, actionFn, targetEsc) { // actionFn is string: "containerAction" of "podAction" // targetEsc is al esc(...) dus veilig in onclick @@ -1382,15 +1409,20 @@ const apiFolderPath = (folder.path || '').replace(/^\/+/, ''); const uiFolderPath = filesToUiPath(apiFolderPath); // zonder systemd/ const folderLabel = uiFolderPath || 'root'; + const folderKey = apiFolderPath; // unieke key (met systemd/..) + const collapsed = _isFolderCollapsed(folderKey); parts.push(` -
- 📂 ${esc(folderLabel)} - +
+ + ${collapsed ? '▶' : '▼'} + 📂 ${esc(folderLabel)} + + -
+
`); const files = folder.files || []; @@ -1399,17 +1431,37 @@ continue; } + parts.push(`
`); + for (const f of files) { const fullUi = uiFolderPath ? `${uiFolderPath}/${f}` : f; parts.push(` -
+
📄 ${esc(f)}
`); } + + parts.push(`
`); } treeEl.innerHTML = parts.join(''); + treeEl.onclick = (ev) => { + const row = ev.target.closest('.file-folder-row'); + if (!row) return; + + const folderKey = row.getAttribute('data-folder'); + const isNowCollapsed = !_isFolderCollapsed(folderKey); + _setFolderCollapsed(folderKey, isNowCollapsed); + + // pijltje updaten + const arrow = row.querySelector('.folder-toggle'); + if (arrow) arrow.textContent = isNowCollapsed ? '▶' : '▼'; + + // files block tonen/verbergen + const filesBlock = treeEl.querySelector(`[data-folder-files="${CSS.escape(folderKey)}"]`); + if (filesBlock) filesBlock.style.display = isNowCollapsed ? 'none' : ''; + }; } async function filesOpen(uiPath) {