fb9c77943f
TaxBaik CI/CD / build-and-deploy (push) Successful in 50s
- App.razor: loading overlay starts with `show` class (visible on cold load) - admin-session.js: add showLoading()/hideLoading(); MutationObserver detects .admin-page-hero / .admin-login-page instead of mud-element count threshold; observer restarts on every navigation cycle via LocationChanged - MainLayout.razor: subscribe to NavigationManager.LocationChanged → call JS showLoading() on every route change; implements IDisposable - InquiryList.razor: remove unused IInquiryRepository injection; load data once (GetPagedAsync(1,200)) and pass IReadOnlyList to all six tab panels - InquiryTable.razor: accept Inquiries parameter; filter synchronously in OnParametersSet() — eliminates 6 redundant API calls per page visit - admin.css: overlay fade-in animation (0.15s); page content fade-in on route mount via .admin-page-hero / .admin-login-page animation (0.25s) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
89 lines
3.1 KiB
JavaScript
89 lines
3.1 KiB
JavaScript
window.taxbaikAdminSession = {
|
|
syncRouteClass: function () {
|
|
document.documentElement.classList.toggle(
|
|
'admin-login-route',
|
|
window.location.pathname.toLowerCase().endsWith('/admin/login'));
|
|
},
|
|
|
|
clearAuthToken: function () {
|
|
try {
|
|
localStorage.removeItem('auth_token');
|
|
} catch {
|
|
// Ignore storage errors; redirect still recovers the session.
|
|
}
|
|
},
|
|
|
|
showLoading: function () {
|
|
const overlay = document.getElementById('blazor-loading');
|
|
if (!overlay) return;
|
|
|
|
// Start observer FIRST so it catches the mutation that brings new content in.
|
|
if (window._taxbaikLoadingObserver) {
|
|
window._taxbaikLoadingObserver.disconnect();
|
|
}
|
|
window._taxbaikLoadingObserver = new MutationObserver(function () {
|
|
const pageReady =
|
|
document.querySelector('.admin-page-hero') !== null ||
|
|
document.querySelector('.admin-login-page') !== null;
|
|
if (pageReady) {
|
|
window.taxbaikAdminSession.hideLoading();
|
|
}
|
|
});
|
|
window._taxbaikLoadingObserver.observe(document.body, {
|
|
childList: true,
|
|
subtree: true
|
|
});
|
|
|
|
// Show overlay after observer is active.
|
|
overlay.classList.add('show');
|
|
|
|
// Safety fallback: hide after 3 seconds regardless.
|
|
if (window._taxbaikLoadingTimeout) {
|
|
clearTimeout(window._taxbaikLoadingTimeout);
|
|
}
|
|
window._taxbaikLoadingTimeout = setTimeout(function () {
|
|
window.taxbaikAdminSession.hideLoading();
|
|
}, 3000);
|
|
},
|
|
|
|
hideLoading: function () {
|
|
const overlay = document.getElementById('blazor-loading');
|
|
if (overlay) {
|
|
overlay.classList.remove('show');
|
|
}
|
|
|
|
if (window._taxbaikLoadingTimeout) {
|
|
clearTimeout(window._taxbaikLoadingTimeout);
|
|
window._taxbaikLoadingTimeout = null;
|
|
}
|
|
|
|
if (window._taxbaikLoadingObserver) {
|
|
window._taxbaikLoadingObserver.disconnect();
|
|
window._taxbaikLoadingObserver = null;
|
|
}
|
|
},
|
|
|
|
watchReconnect: function () {
|
|
window.taxbaikAdminSession.syncRouteClass();
|
|
window.addEventListener('popstate', window.taxbaikAdminSession.syncRouteClass);
|
|
|
|
// Show loading on initial page load — overlay has 'show' from HTML,
|
|
// but we still need to set up the observer to detect when to hide it.
|
|
window.taxbaikAdminSession.showLoading();
|
|
|
|
const modal = document.getElementById('components-reconnect-modal');
|
|
if (!modal) return;
|
|
|
|
const reloadOnRejectedCircuit = function () {
|
|
const className = modal.className || '';
|
|
if (className.includes('components-reconnect-failed') ||
|
|
className.includes('components-reconnect-rejected')) {
|
|
window.setTimeout(function () { window.location.reload(); }, 1500);
|
|
}
|
|
};
|
|
|
|
new MutationObserver(reloadOnRejectedCircuit)
|
|
.observe(modal, { attributes: true, attributeFilter: ['class'] });
|
|
}
|
|
};
|