diff --git a/templates/index.html b/templates/index.html index 56c1e89..7e1d4ce 100644 --- a/templates/index.html +++ b/templates/index.html @@ -119,15 +119,39 @@ function renderTable(files) { const tbody = document.getElementById('fileTableBody'); - + // tbody is cleared in loadFiles, so we just append. + + // Add "Go Up" link if not at root + if (currentPath && currentPath !== '/' && currentPath.length > 1) { + let parentPath = currentPath.substring(0, currentPath.lastIndexOf('/')); + if (parentPath === '') parentPath = '/'; + + const tr = document.createElement('tr'); + tr.className = 'file-row'; + tr.onclick = () => enterDir(parentPath); + tr.innerHTML = ` + + .. + + + `; + tbody.appendChild(tr); + } + if (files.length === 0) { - tbody.innerHTML = 'No files found.'; + // If we haven't added the "up" directory, show no files. + if (tbody.childElementCount === 0) { + tbody.innerHTML = 'No files found.'; + } return; } files.forEach(file => { const tr = document.createElement('tr'); tr.className = 'file-row'; + if (file.is_dir) { + tr.onclick = () => enterDir(file.path); + } // Icon logic let icon = 'fa-file'; @@ -141,9 +165,7 @@ tr.innerHTML = ` - - ${file.name} - + ${file.name} ${size} ${getActions(file)}