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
+19
View File
@@ -123,6 +123,25 @@
border: none;
}
/* Text viewer styles */
.file-viewer-text-content {
width: 100%;
height: 100%;
margin: 0;
padding: 16px 24px;
font-family: 'Courier New', Consolas, Monaco, monospace;
font-size: 14px;
line-height: 1.6;
color: #2d3748;
background-color: #fff;
overflow: auto;
white-space: pre-wrap;
word-wrap: break-word;
box-sizing: border-box;
text-align: left;
tab-size: 4;
}
/* Loader */
.file-viewer-loader {
position: absolute;
+19
View File
@@ -193,6 +193,25 @@
margin: 0 0 16px;
}
/* Text viewer */
.inline-viewer-text-content {
width: 100%;
height: 100%;
margin: 0;
padding: 16px 24px;
font-family: 'Courier New', Consolas, Monaco, monospace;
font-size: 14px;
line-height: 1.6;
color: #2d3748;
background-color: #fff;
overflow: auto;
white-space: pre-wrap;
word-wrap: break-word;
box-sizing: border-box;
text-align: left;
tab-size: 4;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.inline-viewer-content {