config changes to better build map .env and updates to the login ui controls

This commit is contained in:
2025-07-16 10:28:28 -06:00
parent 0553a933a7
commit 94755521d7
4 changed files with 113 additions and 6 deletions

View File

@@ -6,6 +6,42 @@ import { loadLocations, handleAddLocation, handleEditLocation, handleDeleteLocat
export let userLocationMarker = null;
export let isAddingLocation = false;
// Add logout function
async function logout() {
try {
const response = await fetch('/api/auth/logout', {
method: 'POST',
credentials: 'include'
});
if (response.ok) {
// Clear any local storage or session storage
localStorage.clear();
sessionStorage.clear();
// Redirect to login page
window.location.href = '/login.html';
} else {
throw new Error('Logout failed');
}
} catch (error) {
console.error('Logout error:', error);
showStatus('Logout failed, redirecting anyway...', 'warning');
// Force redirect even if logout request fails
setTimeout(() => {
window.location.href = '/login.html';
}, 1000);
}
}
// Add logout handler function
function handleLogout(e) {
e.preventDefault();
if (confirm('Are you sure you want to logout?')) {
logout();
}
}
export function getUserLocation() {
if (!navigator.geolocation) {
showStatus('Geolocation is not supported by your browser', 'error');
@@ -284,7 +320,6 @@ export function setupGeoLocationSync() {
}
}
// ...existing code...
export function setupEventListeners() {
// Desktop controls
document.getElementById('refresh-btn')?.addEventListener('click', () => {
@@ -297,6 +332,10 @@ export function setupEventListeners() {
document.getElementById('add-location-btn')?.addEventListener('click', toggleAddLocationMode);
document.getElementById('fullscreen-btn')?.addEventListener('click', toggleFullscreen);
// Add logout button event listeners
document.getElementById('logout-btn')?.addEventListener('click', handleLogout);
document.getElementById('mobile-logout-btn')?.addEventListener('click', handleLogout);
// Mobile controls
document.getElementById('mobile-refresh-btn')?.addEventListener('click', () => {
loadLocations();