From d1836782826d14629ba5dd3d95ba0995c6212277 Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Thu, 18 Dec 2025 08:10:57 -0500 Subject: [PATCH] Small bugfixes --- backend/app/crud/crud_ppr.py | 2 ++ nginx.conf | 8 ++++++ web/admin.html | 51 +++++++++--------------------------- 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/backend/app/crud/crud_ppr.py b/backend/app/crud/crud_ppr.py index 853d518..7b14b7e 100644 --- a/backend/app/crud/crud_ppr.py +++ b/backend/app/crud/crud_ppr.py @@ -4,6 +4,7 @@ from sqlalchemy import and_, or_, func, desc from datetime import date, datetime import secrets from app.models.ppr import PPRRecord, PPRStatus +from app.models.journal import EntityType from app.schemas.ppr import PPRCreate, PPRUpdate from app.crud.crud_journal import journal as crud_journal @@ -89,6 +90,7 @@ class CRUDPPR: # Log creation in journal crud_journal.log_change( db, + EntityType.PPR, db_obj.id, f"PPR created for {db_obj.ac_reg}", created_by, diff --git a/nginx.conf b/nginx.conf index 95eec5f..88e3709 100644 --- a/nginx.conf +++ b/nginx.conf @@ -63,6 +63,14 @@ http { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; + + # WebSocket timeout settings (prevent connection drops) + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; + proxy_connect_timeout 60s; + + # Additional WebSocket connection settings + proxy_buffering off; } # Security headers diff --git a/web/admin.html b/web/admin.html index 0e15d7a..6469f5f 100644 --- a/web/admin.html +++ b/web/admin.html @@ -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 = 'P'; - } + // Get registration + const registration = ppr.ac_reg || '-'; + const typeIconParked = 'P'; - // 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 || '-';