Make sidebar persistent and delay preview sheet until icon-flight ends
@@ -42,6 +42,7 @@
42
42
- highlightCode(raw, lang) - Escapes and syntax-highlights preview text into HTML spans.
43
43
- fileAccentColor(name) - Returns canonical file-type accent color used by icon strokes and preview sheet outline.
44
44
- animatePreviewOpen(sourceSvgEl, sheetEl) - Animates a cloned file icon from its tile position into the full preview sheet.
45
- openFolderSidebar() - Persistent sidebar fallback view that shows current folder/root overview when no item is selected.
45
46
- fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.
46
47
- downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.
47
48
- renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.
@@ -42,6 +42,7 @@42
- highlightCode(raw, lang) - Escapes and syntax-highlights preview text into HTML spans.42
- highlightCode(raw, lang) - Escapes and syntax-highlights preview text into HTML spans.43
- fileAccentColor(name) - Returns canonical file-type accent color used by icon strokes and preview sheet outline.43
- fileAccentColor(name) - Returns canonical file-type accent color used by icon strokes and preview sheet outline.44
- animatePreviewOpen(sourceSvgEl, sheetEl) - Animates a cloned file icon from its tile position into the full preview sheet.44
- animatePreviewOpen(sourceSvgEl, sheetEl) - Animates a cloned file icon from its tile position into the full preview sheet.45
- openFolderSidebar() - Persistent sidebar fallback view that shows current folder/root overview when no item is selected.45
- fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.46
- fetchFileBlob(item) - Downloads a file as Blob with auth headers for preview/download flows.46
- downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.47
- downloadOrView(item) - Opens the in-app file-preview overlay and attaches bottom download action.47
- renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.48
- renderPreviewBody(item, blob, objectUrl) - Renders preview content (image/video/audio/pdf/text) or unsupported message.@@ -509,6 +509,8 @@ function showApp ()
509
509
{
510
510
document.getElementById('auth-overlay').classList.add('hidden');
511
511
document.getElementById('app').classList.remove('hidden');
512
document.getElementById('app').classList.add('sidebar-open');
513
document.getElementById('sidebar').classList.remove('hidden');
512
514
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
513
515
startAutoRefresh();
514
516
}
@@ -709,7 +711,7 @@ async function navigateTo (absPath, root, opts = {})
709
711
renderBreadcrumb();
710
712
renderFileGrid();
711
713
await refreshFolderStats();
712
if (!opts.keepSidebar) closeSidebar();
714
closeSidebar();
713
715
}
714
716
715
717
function renderBreadcrumb ()
@@ -807,7 +809,7 @@ function itemsSignature (items)
807
809
async function incrementalRefreshCurrentDir ()
808
810
{
809
811
if (!STATE.currentDir || STATE.uploadInProgress) return;
810
const data = await api('GET', `/files/list?dir=${encodeURIComponent(STATE.currentDir)}`).catch(() => null);
812
closeSidebar();
811
813
if (!data) return;
812
814
813
815
const oldSig = itemsSignature(STATE.items);
@@ -1007,12 +1009,47 @@ async function openSidebar (item)
1007
1009
}
1008
1010
}
1009
1011
1012
function openFolderSidebar ()
1013
{
1014
const sidebar = document.getElementById('sidebar');
1015
sidebar.classList.remove('hidden');
1016
document.getElementById('app').classList.add('sidebar-open');
1017
1018
document.getElementById('sidebar-icon').innerHTML = iconFolder(64);
1019
1020
const nameEl = document.getElementById('sidebar-name');
1021
const dl = document.getElementById('sidebar-meta');
1022
const actions = document.getElementById('sidebar-actions');
1023
actions.innerHTML = '';
1024
1025
if (!STATE.currentDir || !STATE.currentRoot)
1026
{
1027
nameEl.textContent = 'Storage Roots';
1028
dl.innerHTML = `
1029
<dt>Type</dt><dd>Root overview</dd>
1030
<dt>Roots</dt><dd>${STATE.roots.length}</dd>
1031
`;
1032
return;
1033
}
1034
1035
const parts = String(STATE.currentDir).split(/[\\/]/).filter(Boolean);
1036
const fallback = STATE.currentRoot.label || 'Folder';
1037
nameEl.textContent = parts.length ? parts[parts.length - 1] : fallback;
1038
1039
const dirs = STATE.items.filter(i => i.isDir).length;
1040
const files = STATE.items.length - dirs;
1041
dl.innerHTML = `
1042
<dt>Path</dt><dd>${STATE.currentDir}</dd>
1043
<dt>Folders</dt><dd>${dirs}</dd>
1044
<dt>Files</dt><dd>${files}</dd>
1045
`;
1046
}
1047
1010
1048
function closeSidebar ()
1011
1049
{
1012
document.getElementById('sidebar').classList.add('hidden');
1013
document.getElementById('app').classList.remove('sidebar-open');
1014
1050
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));
1015
1051
STATE.selectedItem = null;
1052
openFolderSidebar();
1016
1053
}
1017
1054
1018
1055
// ───────────────────────────────────────────────────────────────────────────
@@ -1389,10 +1426,10 @@ async function downloadOrView (item, sourceSvgEl = null)
1389
1426
dlBtn.onclick = () => triggerDownload(item.name, objectUrl);
1390
1427
await renderPreviewBody(item, blob, objectUrl);
1391
1428
1392
overlay.classList.add('preview-opening');
1429
overlay.classList.add('preview-prep');
1393
1430
overlay.classList.remove('hidden');
1394
1431
await animatePreviewOpen(sourceSvgEl, sheet);
1395
overlay.classList.remove('preview-opening');
1432
overlay.classList.remove('preview-prep');
1396
1433
}
1397
1434
1398
1435
// ───────────────────────────────────────────────────────────────────────────
@@ -1430,7 +1467,6 @@ async function uploadFiles (fileList)
1430
1467
xhr.setRequestHeader('Authorization', 'Bearer ' + STATE.token);
1431
1468
xhr.setRequestHeader('X-Fp', getFingerprint());
1432
1469
xhr.setRequestHeader('X-Upload-Size', String(totalSize));
1433
1434
1470
xhr.upload.addEventListener('progress', e =>
1435
1471
{
1436
1472
if (e.lengthComputable)
@@ -2348,10 +2384,9 @@ function wireEvents ()
2348
2384
}
2349
2385
});
2350
2386
2351
// Sidebar close
2352
document.getElementById('sidebar-close').addEventListener('click', closeSidebar);
2387
// Sidebar is persistent; close button is intentionally disabled.
2353
2388
2354
// Click outside grid closes sidebar
2389
// Click outside grid clears selection and returns to folder sidebar info.
2355
2390
document.getElementById('main-content').addEventListener('click', (e) =>
2356
2391
{
2357
2392
if (!e.target.closest('.file-item')) closeSidebar();
@@ -509,6 +509,8 @@ function showApp ()509
{509
{510
document.getElementById('auth-overlay').classList.add('hidden');510
document.getElementById('auth-overlay').classList.add('hidden');511
document.getElementById('app').classList.remove('hidden');511
document.getElementById('app').classList.remove('hidden');512
document.getElementById('app').classList.add('sidebar-open');513
document.getElementById('sidebar').classList.remove('hidden');512
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);514
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);513
startAutoRefresh();515
startAutoRefresh();514
}516
}@@ -709,7 +711,7 @@ async function navigateTo (absPath, root, opts = {})709
renderBreadcrumb();711
renderBreadcrumb();710
renderFileGrid();712
renderFileGrid();711
await refreshFolderStats();713
await refreshFolderStats();712
if (!opts.keepSidebar) closeSidebar();714
closeSidebar();713
}715
}714
716
715
function renderBreadcrumb ()717
function renderBreadcrumb ()@@ -807,7 +809,7 @@ function itemsSignature (items)807
async function incrementalRefreshCurrentDir ()809
async function incrementalRefreshCurrentDir ()808
{810
{809
if (!STATE.currentDir || STATE.uploadInProgress) return;811
if (!STATE.currentDir || STATE.uploadInProgress) return;810
const data = await api('GET', `/files/list?dir=${encodeURIComponent(STATE.currentDir)}`).catch(() => null);812
closeSidebar();811
if (!data) return;813
if (!data) return;812
814
813
const oldSig = itemsSignature(STATE.items);815
const oldSig = itemsSignature(STATE.items);@@ -1007,12 +1009,47 @@ async function openSidebar (item)1007
}1009
}1008
}1010
}1009
1011
1012
function openFolderSidebar ()1013
{1014
const sidebar = document.getElementById('sidebar');1015
sidebar.classList.remove('hidden');1016
document.getElementById('app').classList.add('sidebar-open');1017
1018
document.getElementById('sidebar-icon').innerHTML = iconFolder(64);1019
1020
const nameEl = document.getElementById('sidebar-name');1021
const dl = document.getElementById('sidebar-meta');1022
const actions = document.getElementById('sidebar-actions');1023
actions.innerHTML = '';1024
1025
if (!STATE.currentDir || !STATE.currentRoot)1026
{1027
nameEl.textContent = 'Storage Roots';1028
dl.innerHTML = `1029
<dt>Type</dt><dd>Root overview</dd>1030
<dt>Roots</dt><dd>${STATE.roots.length}</dd>1031
`;1032
return;1033
}1034
1035
const parts = String(STATE.currentDir).split(/[\\/]/).filter(Boolean);1036
const fallback = STATE.currentRoot.label || 'Folder';1037
nameEl.textContent = parts.length ? parts[parts.length - 1] : fallback;1038
1039
const dirs = STATE.items.filter(i => i.isDir).length;1040
const files = STATE.items.length - dirs;1041
dl.innerHTML = `1042
<dt>Path</dt><dd>${STATE.currentDir}</dd>1043
<dt>Folders</dt><dd>${dirs}</dd>1044
<dt>Files</dt><dd>${files}</dd>1045
`;1046
}1047
1010
function closeSidebar ()1048
function closeSidebar ()1011
{1049
{1012
document.getElementById('sidebar').classList.add('hidden');1013
document.getElementById('app').classList.remove('sidebar-open');1014
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));1050
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));1015
STATE.selectedItem = null;1051
STATE.selectedItem = null;1052
openFolderSidebar();1016
}1053
}1017
1054
1018
// ───────────────────────────────────────────────────────────────────────────1055
// ───────────────────────────────────────────────────────────────────────────@@ -1389,10 +1426,10 @@ async function downloadOrView (item, sourceSvgEl = null)1389
dlBtn.onclick = () => triggerDownload(item.name, objectUrl);1426
dlBtn.onclick = () => triggerDownload(item.name, objectUrl);1390
await renderPreviewBody(item, blob, objectUrl);1427
await renderPreviewBody(item, blob, objectUrl);1391
1428
1392
overlay.classList.add('preview-opening');1429
overlay.classList.add('preview-prep');1393
overlay.classList.remove('hidden');1430
overlay.classList.remove('hidden');1394
await animatePreviewOpen(sourceSvgEl, sheet);1431
await animatePreviewOpen(sourceSvgEl, sheet);1395
overlay.classList.remove('preview-opening');1432
overlay.classList.remove('preview-prep');1396
}1433
}1397
1434
1398
// ───────────────────────────────────────────────────────────────────────────1435
// ───────────────────────────────────────────────────────────────────────────@@ -1430,7 +1467,6 @@ async function uploadFiles (fileList)1430
xhr.setRequestHeader('Authorization', 'Bearer ' + STATE.token);1467
xhr.setRequestHeader('Authorization', 'Bearer ' + STATE.token);1431
xhr.setRequestHeader('X-Fp', getFingerprint());1468
xhr.setRequestHeader('X-Fp', getFingerprint());1432
xhr.setRequestHeader('X-Upload-Size', String(totalSize));1469
xhr.setRequestHeader('X-Upload-Size', String(totalSize));1433
1434
xhr.upload.addEventListener('progress', e =>1470
xhr.upload.addEventListener('progress', e =>1435
{1471
{1436
if (e.lengthComputable)1472
if (e.lengthComputable)@@ -2348,10 +2384,9 @@ function wireEvents ()2348
}2384
}2349
});2385
});2350
2386
2351
// Sidebar close2387
// Sidebar is persistent; close button is intentionally disabled.2352
document.getElementById('sidebar-close').addEventListener('click', closeSidebar);2353
2388
2354
// Click outside grid closes sidebar2389
// Click outside grid clears selection and returns to folder sidebar info.2355
document.getElementById('main-content').addEventListener('click', (e) =>2390
document.getElementById('main-content').addEventListener('click', (e) =>2356
{2391
{2357
if (!e.target.closest('.file-item')) closeSidebar();2392
if (!e.target.closest('.file-item')) closeSidebar();@@ -343,15 +343,7 @@ button.danger:hover {
343
343
}
344
344
345
345
#sidebar-close {
346
background: none;
347
color: var(--text-muted);
348
align-self: flex-end;
349
font-size: 1.1rem;
350
padding: 0.2rem 0.5rem;
351
}
352
353
#sidebar-close:hover {
354
color: var(--text);
346
display: none;
355
347
}
356
348
357
349
#sidebar-icon {
@@ -658,7 +650,11 @@ button.danger:hover {
658
650
border-bottom: 1px solid var(--preview-accent);
659
651
}
660
652
661
.preview-opening .preview-sheet {
653
.preview-prep {
654
opacity: 0;
655
}
656
657
.preview-prep .preview-sheet {
662
658
opacity: 0;
663
659
}
664
660
@@ -343,15 +343,7 @@ button.danger:hover {343
}343
}344
344
345
#sidebar-close {345
#sidebar-close {346
background: none;346
display: none;347
color: var(--text-muted);348
align-self: flex-end;349
font-size: 1.1rem;350
padding: 0.2rem 0.5rem;351
}352
353
#sidebar-close:hover {354
color: var(--text);355
}347
}356
348
357
#sidebar-icon {349
#sidebar-icon {@@ -658,7 +650,11 @@ button.danger:hover {658
border-bottom: 1px solid var(--preview-accent);650
border-bottom: 1px solid var(--preview-accent);659
}651
}660
652
661
.preview-opening .preview-sheet {653
.preview-prep {654
opacity: 0;655
}656
657
.preview-prep .preview-sheet {662
opacity: 0;658
opacity: 0;663
}659
}664
660