Small bugfixes

This commit is contained in:
2025-12-18 08:10:57 -05:00
parent a2682314c9
commit d183678282
3 changed files with 22 additions and 39 deletions

View File

@@ -990,7 +990,7 @@
// Refresh local flights when any local flight event occurs
if (data.type && (data.type.includes('local_flight_'))) {
console.log('Local flight update detected, refreshing...');
loadLocalFlights();
loadPPRs();
showNotification('Local flight updated');
}
@@ -1709,11 +1709,7 @@
document.getElementById('parked-no-data').style.display = 'none';
try {
// Load both PPRs and booked-in arrivals
const [pprResponse, bookedInResponse] = await Promise.all([
authenticatedFetch('/api/v1/pprs/?limit=1000'),
authenticatedFetch('/api/v1/arrivals/?limit=1000')
]);
const pprResponse = await authenticatedFetch('/api/v1/pprs/?limit=1000');
if (!pprResponse.ok) {
throw new Error('Failed to fetch parked visitors');
@@ -1722,33 +1718,19 @@
const allPPRs = await pprResponse.json();
const today = new Date().toISOString().split('T')[0];
// Filter for parked visitors: LANDED status and (no ETD or ETD not today)
// Show all parked aircraft regardless of when they arrived
// Filter for parked PPR visitors: LANDED status and ETD on a different day
const parked = allPPRs.filter(ppr => {
if (ppr.status !== 'LANDED') {
return false;
}
// No ETD means parked
// Only show if ETD exists and is not today
if (!ppr.etd) {
return true;
return false;
}
// ETD exists but is not today
const etdDate = ppr.etd.split('T')[0];
return etdDate !== today;
});
// Add booked-in arrivals with LANDED status
if (bookedInResponse.ok) {
const bookedInArrivals = await bookedInResponse.json();
const bookedInParked = bookedInArrivals
.filter(arrival => arrival.status === 'LANDED')
.map(arrival => ({
...arrival,
isBookedIn: true // Flag to distinguish from PPR
}));
parked.push(...bookedInParked);
}
displayParked(parked);
} catch (error) {
console.error('Error loading parked visitors:', error);
@@ -1793,26 +1775,17 @@
for (const ppr of uniqueParked) {
const row = document.createElement('tr');
const isBookedIn = ppr.isBookedIn;
// Click handler that routes to correct modal/display
if (isBookedIn) {
row.style.cursor = 'default'; // Booked-in arrivals don't have a modal yet
} else {
row.onclick = () => openPPRModal(ppr.id);
}
// All rows are PPR, so make them clickable
row.onclick = () => openPPRModal(ppr.id);
row.style.cssText = 'font-size: 0.85rem !important; font-style: italic;';
// Get registration based on type (PPR vs booked-in)
let registration = ppr.ac_reg || ppr.registration || '-';
let typeIconParked = '';
if (!isBookedIn) {
// Add P icon for PPR flights
typeIconParked = '<span style="color: #032cfc; font-weight: bold;" title="From PPR">P</span>';
}
// Get registration
const registration = ppr.ac_reg || '-';
const typeIconParked = '<span style="color: #032cfc; font-weight: bold;" title="From PPR">P</span>';
// Get aircraft type based on type (PPR vs booked-in)
const acType = ppr.ac_type || ppr.type || '-';
// Get aircraft type
const acType = ppr.ac_type || '-';
// Get from airport
const fromAirport = ppr.in_from || '-';