botserver/web/desktop/js/layout.js
Rodrigo Rodriguez (Pragmatismo) afe87e1ab5 feat: add actix-files dependency for file serving support
Added actix-files and its dependencies (http-range, mime_guess, unicase, v_htmlescape) to enable static file functionality in the botserver. This will allow serving static assets and files through the web server. The change includes all required transitive dependencies for proper file handling and MIME type detection.
2025-11-15 19:08:26 -03:00

37 lines
1.1 KiB
JavaScript

const sections = {
drive: 'drive/index.html',
tasks: 'tasks/index.html',
mail: 'mail/index.html'
};
async function loadSectionHTML(path) {
const response = await fetch(path);
if (!response.ok) throw new Error('Failed to load section');
return await response.text();
}
async function switchSection(section) {
const mainContent = document.getElementById('main-content');
try {
const html = await loadSectionHTML(sections[section]);
mainContent.innerHTML = html;
window.history.pushState({}, '', `#${section}`);
Alpine.initTree(mainContent);
} catch (err) {
console.error('Error loading section:', err);
mainContent.innerHTML = `<div class="error">Failed to load ${section} section</div>`;
}
}
// Handle initial load based on URL hash
window.addEventListener('DOMContentLoaded', () => {
const initialSection = window.location.hash.substring(1) || 'drive';
switchSection(initialSection);
});
// Handle browser back/forward navigation
window.addEventListener('popstate', () => {
const section = window.location.hash.substring(1) || 'drive';
switchSection(section);
});