From f7467690e43783b5ea3d1fa3f0ce1696ac0b142f Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Fri, 12 Dec 2025 06:50:38 -0500 Subject: [PATCH] Public board for local fligts --- backend/app/api/endpoints/public.py | 87 ++++++++++++++++++-- web/admin.html | 67 ++++++++++++---- web/index.html | 120 +++++++++++++++++++--------- 3 files changed, 215 insertions(+), 59 deletions(-) diff --git a/backend/app/api/endpoints/public.py b/backend/app/api/endpoints/public.py index f92f209..5d08c05 100644 --- a/backend/app/api/endpoints/public.py +++ b/backend/app/api/endpoints/public.py @@ -3,20 +3,95 @@ from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.api.deps import get_db from app.crud.crud_ppr import ppr as crud_ppr +from app.crud.crud_local_flight import local_flight as crud_local_flight from app.schemas.ppr import PPRPublic +from app.models.local_flight import LocalFlightStatus +from datetime import date router = APIRouter() -@router.get("/arrivals", response_model=List[PPRPublic]) +@router.get("/arrivals") async def get_public_arrivals(db: Session = Depends(get_db)): - """Get today's arrivals for public display""" + """Get today's arrivals for public display (PPR and local flights)""" arrivals = crud_ppr.get_arrivals_today(db) - return arrivals + + # Convert PPR arrivals to dictionaries + arrivals_list = [] + for arrival in arrivals: + arrivals_list.append({ + 'ac_call': arrival.ac_call, + 'ac_reg': arrival.ac_reg, + 'ac_type': arrival.ac_type, + 'in_from': arrival.in_from, + 'eta': arrival.eta, + 'landed_dt': arrival.landed_dt, + 'status': arrival.status.value, + 'isLocalFlight': False + }) + + # Add local flights with DEPARTED status + local_flights = crud_local_flight.get_multi( + db, + status=LocalFlightStatus.DEPARTED, + limit=1000 + ) + + # Convert local flights to match the PPR format for display + for flight in local_flights: + arrivals_list.append({ + 'ac_call': flight.callsign or flight.registration, + 'ac_reg': flight.registration, + 'ac_type': flight.type, + 'in_from': None, + 'eta': flight.departure_dt, + 'landed_dt': None, + 'status': 'DEPARTED', + 'isLocalFlight': True, + 'flight_type': flight.flight_type.value + }) + + return arrivals_list -@router.get("/departures", response_model=List[PPRPublic]) +@router.get("/departures") async def get_public_departures(db: Session = Depends(get_db)): - """Get today's departures for public display""" + """Get today's departures for public display (PPR and local flights)""" departures = crud_ppr.get_departures_today(db) - return departures \ No newline at end of file + + # Convert PPR departures to dictionaries + departures_list = [] + for departure in departures: + departures_list.append({ + 'ac_call': departure.ac_call, + 'ac_reg': departure.ac_reg, + 'ac_type': departure.ac_type, + 'out_to': departure.out_to, + 'etd': departure.etd, + 'departed_dt': departure.departed_dt, + 'status': departure.status.value, + 'isLocalFlight': False + }) + + # Add local flights with BOOKED_OUT status + local_flights = crud_local_flight.get_multi( + db, + status=LocalFlightStatus.BOOKED_OUT, + limit=1000 + ) + + # Convert local flights to match the PPR format for display + for flight in local_flights: + departures_list.append({ + 'ac_call': flight.callsign or flight.registration, + 'ac_reg': flight.registration, + 'ac_type': flight.type, + 'out_to': None, + 'etd': flight.booked_out_dt, + 'departed_dt': None, + 'status': 'BOOKED_OUT', + 'isLocalFlight': True, + 'flight_type': flight.flight_type.value + }) + + return departures_list \ No newline at end of file diff --git a/web/admin.html b/web/admin.html index ad3054c..d093fa5 100644 --- a/web/admin.html +++ b/web/admin.html @@ -982,25 +982,24 @@
- +
- +
- +
- +
- @@ -1504,6 +1503,13 @@ return; } + // Press 'Escape' to close Book Out modal if it's open (allow even when typing in inputs) + if (e.key === 'Escape' && document.getElementById('localFlightModal').style.display === 'block') { + e.preventDefault(); + closeLocalFlightModal(); + return; + } + // Only trigger other shortcuts when not typing in input fields if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT') { return; @@ -1514,6 +1520,24 @@ e.preventDefault(); openNewPPRModal(); } + + // Press 'b' to book out local flight (LOCAL type) + if (e.key === 'b' || e.key === 'B') { + e.preventDefault(); + openLocalFlightModal('LOCAL'); + } + + // Press 'c' to book out circuits + if (e.key === 'c' || e.key === 'C') { + e.preventDefault(); + openLocalFlightModal('CIRCUITS'); + } + + // Press 'd' to book out departure + if (e.key === 'd' || e.key === 'D') { + e.preventDefault(); + openLocalFlightModal('DEPARTURE'); + } }); } @@ -2126,7 +2150,7 @@ pob = flight.pob || '-'; fuel = '-'; actionButtons = ` -