BlueGit

timfa filemanager

Fix icon thumbnail auth headers and SVG clip compatibility

timfa Tim Falken · pushed by timfa

Authored 2026-05-03 · 6 months ago

Hash
b054c31b548447cc351f4b530279dabd1b799c6c
Parent
19c0a00b
2 files changed +10 −1
.github/technical-reference.md +2 −0
@@ -33,6 +33,8 @@
33 33 - showConfirm(title, message) - In-page confirm dialog; returns Promise<boolean>. Use instead of window.confirm().
34 34 - showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
35 35 - showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
36 - loadThumbnails() - Loads per-file image thumbnails into file SVG icons after grid rendering.
37 - loadOneThumbnail(iconEl) - Fetches authenticated image blob and injects clipped thumbnail into a file icon SVG.
36 38 - fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.
37 39 - downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.
38 40 - renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.
@@ -33,6 +33,8 @@
33- showConfirm(title, message) - In-page confirm dialog; returns Promise<boolean>. Use instead of window.confirm().
33- showConfirm(title, message) - In-page confirm dialog; returns Promise<boolean>. Use instead of window.confirm().
34- showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
34- showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
35- showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
35- showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
36- loadThumbnails() - Loads per-file image thumbnails into file SVG icons after grid rendering.
37- loadOneThumbnail(iconEl) - Fetches authenticated image blob and injects clipped thumbnail into a file icon SVG.
36- fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.
38- fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.
37- downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.
39- downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.
38- renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.
40- renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.
public/app.js +8 −1
@@ -1803,7 +1803,12 @@ async function loadOneThumbnail (iconEl)
1803 1803 let res;
1804 1804 try
1805 1805 {
1806 res = await fetch(url, { headers: { Authorization: `Bearer ${STATE.token}` } });
1806 res = await fetch(url, {
1807 headers: {
1808 Authorization: `Bearer ${STATE.token}`,
1809 'X-Fp': getFingerprint(),
1810 },
1811 });
1807 1812 } catch { return; }
1808 1813 if (!res.ok || !iconEl.isConnected) return;
1809 1814
@@ -1823,6 +1828,7 @@ async function loadOneThumbnail (iconEl)
1823 1828 const defs = document.createElementNS(NS, 'defs');
1824 1829 const clipPath = document.createElementNS(NS, 'clipPath');
1825 1830 clipPath.setAttribute('id', id);
1831 clipPath.setAttribute('clipPathUnits', 'userSpaceOnUse');
1826 1832 const clipShape = document.createElementNS(NS, 'path');
1827 1833 clipShape.setAttribute('d', 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z');
1828 1834 clipPath.appendChild(clipShape);
@@ -1831,6 +1837,7 @@ async function loadOneThumbnail (iconEl)
1831 1837 // Image fills the file bounding box; clip keeps it inside the outline
1832 1838 const img = document.createElementNS(NS, 'image');
1833 1839 img.setAttribute('href', objectUrl);
1840 img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', objectUrl);
1834 1841 img.setAttribute('x', '4');
1835 1842 img.setAttribute('y', '2');
1836 1843 img.setAttribute('width', '16');
@@ -1803,7 +1803,12 @@ async function loadOneThumbnail (iconEl)
1803 let res;
1803 let res;
1804 try
1804 try
1805 {
1805 {
1806 res = await fetch(url, { headers: { Authorization: `Bearer ${STATE.token}` } });
1806 res = await fetch(url, {
1807 headers: {
1808 Authorization: `Bearer ${STATE.token}`,
1809 'X-Fp': getFingerprint(),
1810 },
1811 });
1807 } catch { return; }
1812 } catch { return; }
1808 if (!res.ok || !iconEl.isConnected) return;
1813 if (!res.ok || !iconEl.isConnected) return;
1809
1814
@@ -1823,6 +1828,7 @@ async function loadOneThumbnail (iconEl)
1823 const defs = document.createElementNS(NS, 'defs');
1828 const defs = document.createElementNS(NS, 'defs');
1824 const clipPath = document.createElementNS(NS, 'clipPath');
1829 const clipPath = document.createElementNS(NS, 'clipPath');
1825 clipPath.setAttribute('id', id);
1830 clipPath.setAttribute('id', id);
1831 clipPath.setAttribute('clipPathUnits', 'userSpaceOnUse');
1826 const clipShape = document.createElementNS(NS, 'path');
1832 const clipShape = document.createElementNS(NS, 'path');
1827 clipShape.setAttribute('d', 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z');
1833 clipShape.setAttribute('d', 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z');
1828 clipPath.appendChild(clipShape);
1834 clipPath.appendChild(clipShape);
@@ -1831,6 +1837,7 @@ async function loadOneThumbnail (iconEl)
1831 // Image fills the file bounding box; clip keeps it inside the outline
1837 // Image fills the file bounding box; clip keeps it inside the outline
1832 const img = document.createElementNS(NS, 'image');
1838 const img = document.createElementNS(NS, 'image');
1833 img.setAttribute('href', objectUrl);
1839 img.setAttribute('href', objectUrl);
1840 img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', objectUrl);
1834 img.setAttribute('x', '4');
1841 img.setAttribute('x', '4');
1835 img.setAttribute('y', '2');
1842 img.setAttribute('y', '2');
1836 img.setAttribute('width', '16');
1843 img.setAttribute('width', '16');