From 2c0c943c3bed59a1f80da3c6278a77539e6a7634 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 16 Jul 2025 10:28:28 -0600 Subject: [PATCH] config changes to better build map .env and updates to the login ui controls --- config.sh | 24 ++++++++++++++---- map/app/public/css/style.css | 43 ++++++++++++++++++++++++++++++++ map/app/public/index.html | 11 ++++++++ map/app/public/js/ui-controls.js | 41 +++++++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/config.sh b/config.sh index 4ec8ee0..e7c438d 100755 --- a/config.sh +++ b/config.sh @@ -541,6 +541,12 @@ NOCODB_LOGIN_SHEET= # NOCODB_SETTINGS_SHEET is the URL to your NocoDB settings sheet. NOCODB_SETTINGS_SHEET= +# NOCODB_SHIFTS_SHEET is the urls to your shifts sheets. +NOCODB_SHIFTS_SHEET= + +# NOCODB_SHIFT_SIGNUPS_SHEET is the URL to your NocoDB shift signups sheet where users can add their own shifts. +NOCODB_SHIFT_SIGNUPS_SHEET= + # Server Configuration PORT=3000 NODE_ENV=production @@ -582,6 +588,13 @@ EOL cp "$MAP_ENV_FILE" "$backup_file" echo "Created backup of map .env at $backup_file" + # Update NOCODB_API_URL to use new domain + if grep -q "^NOCODB_API_URL=" "$MAP_ENV_FILE"; then + sed -i "s|^NOCODB_API_URL=.*|NOCODB_API_URL=https://db.$new_domain/api/v1|" "$MAP_ENV_FILE" + else + echo "NOCODB_API_URL=https://db.$new_domain/api/v1" >> "$MAP_ENV_FILE" + fi + # Update COOKIE_DOMAIN if grep -q "^COOKIE_DOMAIN=" "$MAP_ENV_FILE"; then sed -i "s|^COOKIE_DOMAIN=.*|COOKIE_DOMAIN=.$new_domain|" "$MAP_ENV_FILE" @@ -597,15 +610,16 @@ EOL echo "ALLOWED_ORIGINS=$allowed_origins" >> "$MAP_ENV_FILE" fi - # Also update the NOCODB URLs if they contain domain references - sed -i "s|example\.org|$new_domain|g" "$MAP_ENV_FILE" - sed -i "s|changeme\.org|$new_domain|g" "$MAP_ENV_FILE" - sed -i "s|albertademocracytaskforce\.org|$new_domain|g" "$MAP_ENV_FILE" + # Update domain references in NocoDB URLs while preserving the sheet IDs and paths + # This will update domains like cmlite.org, changeme.org, etc. to the new domain + sed -i "s|://db\.cmlite\.org/|://db.$new_domain/|g" "$MAP_ENV_FILE" + sed -i "s|://map\.cmlite\.org|://map.$new_domain|g" "$MAP_ENV_FILE" echo "✅ Updated map .env file with:" + echo " - NOCODB_API_URL=https://db.$new_domain/api/v1" echo " - COOKIE_DOMAIN=.$new_domain" echo " - ALLOWED_ORIGINS=$allowed_origins" - echo " - Updated all NocoDB URLs to use $new_domain" + echo " - Updated all NocoDB URLs to use $new_domain domain" return 0 } diff --git a/map/app/public/css/style.css b/map/app/public/css/style.css index 6d20867..140053b 100644 --- a/map/app/public/css/style.css +++ b/map/app/public/css/style.css @@ -698,6 +698,17 @@ body { .mobile-dropdown-item:last-child { border-bottom: none; + border-top: 1px solid #ddd; + background-color: #fff5f5; +} + +.mobile-dropdown-item:last-child button { + color: var(--danger-color); + font-weight: 500; +} + +.mobile-dropdown-item:last-child:hover { + background-color: #fee; } .mobile-dropdown-item.location-info { @@ -711,6 +722,38 @@ body { color: var(--dark-color); } +/* Add logout button specific styles */ +.mobile-dropdown-item button { + background: none; + border: none; + color: inherit; + font-size: inherit; + cursor: pointer; + width: 100%; + text-align: left; + padding: 0; + font-family: inherit; +} + +.mobile-dropdown-item button:hover { + background-color: rgba(0, 0, 0, 0.05); +} + +/* Logout button danger styling */ +.mobile-dropdown-item.logout-item { + border-top: 1px solid #eee; + background-color: #fee; +} + +.mobile-dropdown-item.logout-item button { + color: var(--danger-color); + font-weight: 500; +} + +.mobile-dropdown-item.logout-item:hover { + background-color: #fdd; +} + /* Floating sidebar for mobile */ .mobile-sidebar { position: fixed; diff --git a/map/app/public/index.html b/map/app/public/index.html index 8b47722..4d08825 100644 --- a/map/app/public/index.html +++ b/map/app/public/index.html @@ -28,6 +28,11 @@ Loading...
0 locations
+ + @@ -46,6 +51,12 @@
Loading...
+ +
+ +
diff --git a/map/app/public/js/ui-controls.js b/map/app/public/js/ui-controls.js index e1b8437..28113b8 100644 --- a/map/app/public/js/ui-controls.js +++ b/map/app/public/js/ui-controls.js @@ -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();