Merge fix/restore-update-badge
@@ -1536,6 +1536,14 @@ function showApp ()
1536
1536
openFolderSidebar();
1537
1537
}
1538
1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
1539
if (STATE.isAdmin)
1540
{
1541
void refreshAdminUpdateStatus();
1542
}
1543
else
1544
{
1545
setAdminUpdateBadge(0);
1546
}
1539
1547
startAutoRefresh();
1540
1548
}
1541
1549
@@ -1659,6 +1667,8 @@ async function performLogout ()
1659
1667
STATE.restoreDir = null;
1660
1668
STATE.restoreRootPath = null;
1661
1669
STATE.lastOperationAt = null;
1670
_adminUpdateStatus = null;
1671
setAdminUpdateBadge(0);
1662
1672
clearSessionState();
1663
1673
closePreview({ force: true });
1664
1674
closeSidebar();
@@ -4573,12 +4583,54 @@ async function deleteItem (item)
4573
4583
4574
4584
let _adminUpdateStatus = null;
4575
4585
4586
function setAdminUpdateBadge (count)
4587
{
4588
const badge = document.getElementById('admin-update-badge');
4589
const adminBtn = document.getElementById('btn-admin');
4590
if (!badge || !adminBtn) return;
4591
4592
if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)
4593
{
4594
badge.classList.add('hidden');
4595
badge.textContent = '';
4596
adminBtn.removeAttribute('data-update-count');
4597
return;
4598
}
4599
4600
const whole = Math.floor(count);
4601
const capped = Math.min(whole, 99);
4602
badge.textContent = capped >= 99 ? '99+' : String(capped);
4603
badge.classList.remove('hidden');
4604
adminBtn.dataset.updateCount = String(whole);
4605
}
4606
4607
function pulseAdminUpdateButton ()
4608
{
4609
const btn = document.getElementById('admin-shutdown-btn');
4610
if (!btn) return;
4611
4612
if (typeof btn.scrollIntoView === 'function')
4613
{
4614
btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
4615
}
4616
4617
btn.classList.remove('admin-update-highlight');
4618
// Force reflow so repeated openings can replay the pulse animation.
4619
void btn.offsetWidth;
4620
btn.classList.add('admin-update-highlight');
4621
4622
setTimeout(() =>
4623
{
4624
btn.classList.remove('admin-update-highlight');
4625
}, 1800);
4626
}
4627
4576
4628
async function openAdminModal ()
4577
4629
{
4578
4630
document.getElementById('admin-modal').classList.remove('hidden');
4579
4631
await refreshAdminConfig();
4580
4632
await refreshAdminUsers();
4581
void refreshAdminUpdateStatus();
4633
await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });
4582
4634
}
4583
4635
4584
4636
async function refreshAdminConfig ()
@@ -4648,11 +4700,13 @@ async function refreshAdminUsers ()
4648
4700
}
4649
4701
}
4650
4702
4651
async function refreshAdminUpdateStatus ()
4703
async function refreshAdminUpdateStatus (opts = {})
4652
4704
{
4705
const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;
4653
4706
const btn = document.getElementById('admin-shutdown-btn');
4654
4707
_adminUpdateStatus = null;
4655
4708
btn.textContent = 'Shut down server';
4709
setAdminUpdateBadge(0);
4656
4710
4657
4711
try
4658
4712
{
@@ -4660,6 +4714,11 @@ async function refreshAdminUpdateStatus ()
4660
4714
if (!data) return;
4661
4715
_adminUpdateStatus = data;
4662
4716
4717
const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))
4718
? data.commitsAhead.length
4719
: 0;
4720
setAdminUpdateBadge(updateCount);
4721
4663
4722
if (!data.underSystemd)
4664
4723
{
4665
4724
btn.textContent = 'Shut down server';
@@ -4671,6 +4730,7 @@ async function refreshAdminUpdateStatus ()
4671
4730
else
4672
4731
{
4673
4732
btn.textContent = 'Restart & Update';
4733
if (pulseIfUpdateAvailable) pulseAdminUpdateButton();
4674
4734
}
4675
4735
}
4676
4736
catch
@@ -1536,6 +1536,14 @@ function showApp ()1536
openFolderSidebar();1536
openFolderSidebar();1537
}1537
}1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);1538
document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);1539
if (STATE.isAdmin)1540
{1541
void refreshAdminUpdateStatus();1542
}1543
else1544
{1545
setAdminUpdateBadge(0);1546
}1539
startAutoRefresh();1547
startAutoRefresh();1540
}1548
}1541
1549
@@ -1659,6 +1667,8 @@ async function performLogout ()1659
STATE.restoreDir = null;1667
STATE.restoreDir = null;1660
STATE.restoreRootPath = null;1668
STATE.restoreRootPath = null;1661
STATE.lastOperationAt = null;1669
STATE.lastOperationAt = null;1670
_adminUpdateStatus = null;1671
setAdminUpdateBadge(0);1662
clearSessionState();1672
clearSessionState();1663
closePreview({ force: true });1673
closePreview({ force: true });1664
closeSidebar();1674
closeSidebar();@@ -4573,12 +4583,54 @@ async function deleteItem (item)4573
4583
4574
let _adminUpdateStatus = null;4584
let _adminUpdateStatus = null;4575
4585
4586
function setAdminUpdateBadge (count)4587
{4588
const badge = document.getElementById('admin-update-badge');4589
const adminBtn = document.getElementById('btn-admin');4590
if (!badge || !adminBtn) return;4591
4592
if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)4593
{4594
badge.classList.add('hidden');4595
badge.textContent = '';4596
adminBtn.removeAttribute('data-update-count');4597
return;4598
}4599
4600
const whole = Math.floor(count);4601
const capped = Math.min(whole, 99);4602
badge.textContent = capped >= 99 ? '99+' : String(capped);4603
badge.classList.remove('hidden');4604
adminBtn.dataset.updateCount = String(whole);4605
}4606
4607
function pulseAdminUpdateButton ()4608
{4609
const btn = document.getElementById('admin-shutdown-btn');4610
if (!btn) return;4611
4612
if (typeof btn.scrollIntoView === 'function')4613
{4614
btn.scrollIntoView({ behavior: 'smooth', block: 'center' });4615
}4616
4617
btn.classList.remove('admin-update-highlight');4618
// Force reflow so repeated openings can replay the pulse animation.4619
void btn.offsetWidth;4620
btn.classList.add('admin-update-highlight');4621
4622
setTimeout(() =>4623
{4624
btn.classList.remove('admin-update-highlight');4625
}, 1800);4626
}4627
4576
async function openAdminModal ()4628
async function openAdminModal ()4577
{4629
{4578
document.getElementById('admin-modal').classList.remove('hidden');4630
document.getElementById('admin-modal').classList.remove('hidden');4579
await refreshAdminConfig();4631
await refreshAdminConfig();4580
await refreshAdminUsers();4632
await refreshAdminUsers();4581
void refreshAdminUpdateStatus();4633
await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });4582
}4634
}4583
4635
4584
async function refreshAdminConfig ()4636
async function refreshAdminConfig ()@@ -4648,11 +4700,13 @@ async function refreshAdminUsers ()4648
}4700
}4649
}4701
}4650
4702
4651
async function refreshAdminUpdateStatus ()4703
async function refreshAdminUpdateStatus (opts = {})4652
{4704
{4705
const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;4653
const btn = document.getElementById('admin-shutdown-btn');4706
const btn = document.getElementById('admin-shutdown-btn');4654
_adminUpdateStatus = null;4707
_adminUpdateStatus = null;4655
btn.textContent = 'Shut down server';4708
btn.textContent = 'Shut down server';4709
setAdminUpdateBadge(0);4656
4710
4657
try4711
try4658
{4712
{@@ -4660,6 +4714,11 @@ async function refreshAdminUpdateStatus ()4660
if (!data) return;4714
if (!data) return;4661
_adminUpdateStatus = data;4715
_adminUpdateStatus = data;4662
4716
4717
const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))4718
? data.commitsAhead.length4719
: 0;4720
setAdminUpdateBadge(updateCount);4721
4663
if (!data.underSystemd)4722
if (!data.underSystemd)4664
{4723
{4665
btn.textContent = 'Shut down server';4724
btn.textContent = 'Shut down server';@@ -4671,6 +4730,7 @@ async function refreshAdminUpdateStatus ()4671
else4730
else4672
{4731
{4673
btn.textContent = 'Restart & Update';4732
btn.textContent = 'Restart & Update';4733
if (pulseIfUpdateAvailable) pulseAdminUpdateButton();4674
}4734
}4675
}4735
}4676
catch4736
catch