okay got to a much more stable state. Fixed race condtion at stat of files. Should be smooth salining for a bit now.
This commit is contained in:
parent
1fc8b52840
commit
ac01d925ca
@ -236,3 +236,9 @@ For issues or questions:
|
||||
1. Check the troubleshooting section
|
||||
2. Review NocoDB documentation
|
||||
3. Open an issue on GitHub
|
||||
|
||||
# Known Bugs
|
||||
|
||||
- First load of page often fails, need to debug
|
||||
- want ui for dots tohave a edit button that then brings up the form.
|
||||
-
|
||||
@ -549,6 +549,21 @@ body {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
/* Popup actions section */
|
||||
.popup-content .popup-actions {
|
||||
margin-top: 15px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.popup-content .popup-actions .btn {
|
||||
flex: 1;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
/* Distinctive start location marker styles */
|
||||
.start-location-custom-marker {
|
||||
z-index: 2000 !important;
|
||||
|
||||
@ -20,14 +20,29 @@ let startLocationMarker = null;
|
||||
let isStartLocationVisible = true;
|
||||
|
||||
// Initialize the application
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
console.log('DOM loaded, initializing application...');
|
||||
checkAuth();
|
||||
initializeMap();
|
||||
loadLocations();
|
||||
setupEventListeners();
|
||||
setupAutoRefresh();
|
||||
hideLoading();
|
||||
|
||||
try {
|
||||
// First check authentication
|
||||
await checkAuth();
|
||||
|
||||
// Then initialize the map
|
||||
await initializeMap();
|
||||
|
||||
// Only load locations after map is ready
|
||||
await loadLocations();
|
||||
|
||||
// Setup other features
|
||||
setupEventListeners();
|
||||
setupAutoRefresh();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Initialization error:', error);
|
||||
showStatus('Failed to initialize application', 'error');
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
|
||||
// Check authentication
|
||||
@ -38,7 +53,8 @@ async function checkAuth() {
|
||||
|
||||
if (!data.authenticated) {
|
||||
window.location.href = '/login.html';
|
||||
return;
|
||||
// Throw error to stop further initialization
|
||||
throw new Error('Not authenticated');
|
||||
}
|
||||
|
||||
currentUser = data.user;
|
||||
@ -47,6 +63,8 @@ async function checkAuth() {
|
||||
} catch (error) {
|
||||
console.error('Auth check failed:', error);
|
||||
window.location.href = '/login.html';
|
||||
// Re-throw to stop initialization chain
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,14 +202,20 @@ async function loadLocations() {
|
||||
// Display locations on the map
|
||||
function displayLocations(locations) {
|
||||
// Clear existing markers
|
||||
markers.forEach(marker => map.removeLayer(marker));
|
||||
markers.forEach(marker => {
|
||||
if (marker && map) {
|
||||
map.removeLayer(marker);
|
||||
}
|
||||
});
|
||||
markers = [];
|
||||
|
||||
// Add new markers
|
||||
locations.forEach(location => {
|
||||
if (location.latitude && location.longitude) {
|
||||
const marker = createLocationMarker(location);
|
||||
markers.push(marker);
|
||||
if (marker) { // Only add if marker was successfully created
|
||||
markers.push(marker);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -200,6 +224,12 @@ function displayLocations(locations) {
|
||||
|
||||
// Create a location marker
|
||||
function createLocationMarker(location) {
|
||||
// Safety check - ensure map exists
|
||||
if (!map) {
|
||||
console.warn('Map not initialized, skipping marker creation');
|
||||
return null;
|
||||
}
|
||||
|
||||
const lat = parseFloat(location.latitude);
|
||||
const lng = parseFloat(location.longitude);
|
||||
|
||||
@ -228,16 +258,8 @@ function createLocationMarker(location) {
|
||||
const popupContent = createPopupContent(location);
|
||||
marker.bindPopup(popupContent);
|
||||
|
||||
// Add click handler for editing - Store location data on marker
|
||||
// Store location data on marker for later use
|
||||
marker._locationData = location;
|
||||
marker.on('click', () => {
|
||||
if (currentUser) {
|
||||
// Debug: Log the location object to see its structure
|
||||
console.log('Location clicked:', location);
|
||||
console.log('Available fields:', Object.keys(location));
|
||||
setTimeout(() => openEditForm(location), 100);
|
||||
}
|
||||
});
|
||||
|
||||
return marker;
|
||||
}
|
||||
@ -263,6 +285,14 @@ function createPopupContent(location) {
|
||||
<div class="popup-meta">
|
||||
<p>ID: ${locationId || 'Unknown'}</p>
|
||||
</div>
|
||||
${currentUser ? `
|
||||
<div class="popup-actions">
|
||||
<button class="btn btn-primary btn-sm edit-location-popup-btn"
|
||||
data-location='${escapeHtml(JSON.stringify(location))}'>
|
||||
✏️ Edit
|
||||
</button>
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -312,6 +342,20 @@ function setupEventListeners() {
|
||||
|
||||
// Geo-location field sync
|
||||
setupGeoLocationSync();
|
||||
|
||||
// Add event delegation for popup edit buttons
|
||||
document.addEventListener('click', (e) => {
|
||||
if (e.target.classList.contains('edit-location-popup-btn')) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const locationData = JSON.parse(e.target.getAttribute('data-location'));
|
||||
openEditForm(locationData);
|
||||
} catch (error) {
|
||||
console.error('Error parsing location data:', error);
|
||||
showStatus('Error opening edit form', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Setup geo-location field synchronization
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user