fix: resolve file viewer auth issues and add text file viewing support

- Fix file viewer not sending JWT auth tokens when loading files
  - inlineViewer.js: already used XHR with auth (images/PDFs worked)
  - fileViewer.js: was setting img.src/iframe.src directly without auth headers,
    now uses fetch with Bearer token and blob URLs
  - ui.js/contextMenus.js/fileRenderer.js/recent.js/favorites.js: replaced all
    window.location.href = /api/files/... (unauthenticated navigation) with
    authenticated viewer or fileOps.downloadFile()

- Add text file viewing support (text/*, application/json, etc.)
  - New createTextViewer() in inlineViewer.js with authenticated fetch
  - New loadTextViewer() in fileViewer.js with authenticated fetch
  - New isViewableFile() helper in ui.js used across all entry points
  - CSS styles for .inline-viewer-text-content and .file-viewer-text-content

- Translate remaining Spanish strings to English in viewer files

Fixes: text files showing 'Token not provided', images failing to load,
and text files not being previewable at all.
This commit is contained in:
Dionisio
2026-02-12 11:16:58 +01:00
parent 6ca1ac4294
commit 3c03caaf60
9 changed files with 313 additions and 62 deletions
+12 -4
View File
@@ -609,9 +609,13 @@ const favorites = {
<div class="file-info">Modified ${formattedDate.split(' ')[0]}</div>
`;
// Download on click
// View or download on click
fileGridElement.addEventListener('click', () => {
window.location.href = `/api/files/${file.id}`;
if (window.ui && window.ui.isViewableFile(file) && window.inlineViewer) {
window.inlineViewer.openFile(file);
} else if (window.fileOps) {
window.fileOps.downloadFile(file.id, file.name);
}
});
// Context menu
@@ -654,9 +658,13 @@ const favorites = {
<div class="date-cell">${formattedDate}</div>
`;
// Download on click
// View or download on click
fileListElement.addEventListener('click', () => {
window.location.href = `/api/files/${file.id}`;
if (window.ui && window.ui.isViewableFile(file) && window.inlineViewer) {
window.inlineViewer.openFile(file);
} else if (window.fileOps) {
window.fileOps.downloadFile(file.id, file.name);
}
});
// Context menu