Compare commits
2 Commits
dbb285fa20
...
ab3319af06
| Author | SHA1 | Date | |
|---|---|---|---|
| ab3319af06 | |||
| 32ad7a793a |
@@ -5,7 +5,8 @@ Revises: 001_initial_schema
|
||||
Create Date: 2025-12-12 12:00:00.000000
|
||||
|
||||
This migration adds a new table for tracking local flights (circuits, local, departure)
|
||||
that don't require PPR submissions.
|
||||
that don't require PPR submissions. Also adds etd and renames booked_out_dt to created_dt,
|
||||
and departure_dt to departed_dt for consistency.
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -32,8 +33,9 @@ def upgrade() -> None:
|
||||
sa.Column('flight_type', sa.Enum('LOCAL', 'CIRCUITS', 'DEPARTURE', name='localflighttype'), nullable=False),
|
||||
sa.Column('status', sa.Enum('BOOKED_OUT', 'DEPARTED', 'LANDED', 'CANCELLED', name='localflightstatus'), nullable=False, server_default='BOOKED_OUT'),
|
||||
sa.Column('notes', sa.Text(), nullable=True),
|
||||
sa.Column('booked_out_dt', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('departure_dt', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_dt', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('etd', sa.DateTime(), nullable=True),
|
||||
sa.Column('departed_dt', sa.DateTime(), nullable=True),
|
||||
sa.Column('landed_dt', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.String(length=16), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
|
||||
@@ -47,7 +49,8 @@ def upgrade() -> None:
|
||||
op.create_index('idx_registration', 'local_flights', ['registration'])
|
||||
op.create_index('idx_flight_type', 'local_flights', ['flight_type'])
|
||||
op.create_index('idx_status', 'local_flights', ['status'])
|
||||
op.create_index('idx_booked_out_dt', 'local_flights', ['booked_out_dt'])
|
||||
op.create_index('idx_created_dt', 'local_flights', ['created_dt'])
|
||||
op.create_index('idx_etd', 'local_flights', ['etd'])
|
||||
op.create_index('idx_created_by', 'local_flights', ['created_by'])
|
||||
|
||||
# Create departures table for non-PPR departures to other airports
|
||||
@@ -60,8 +63,9 @@ def upgrade() -> None:
|
||||
sa.Column('out_to', sa.String(length=64), nullable=False),
|
||||
sa.Column('status', sa.Enum('BOOKED_OUT', 'DEPARTED', 'CANCELLED', name='departuresstatus'), nullable=False, server_default='BOOKED_OUT'),
|
||||
sa.Column('notes', sa.Text(), nullable=True),
|
||||
sa.Column('booked_out_dt', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('departure_dt', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_dt', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('etd', sa.DateTime(), nullable=True),
|
||||
sa.Column('departed_dt', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_by', sa.String(length=16), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
@@ -73,7 +77,8 @@ def upgrade() -> None:
|
||||
op.create_index('idx_dep_registration', 'departures', ['registration'])
|
||||
op.create_index('idx_dep_out_to', 'departures', ['out_to'])
|
||||
op.create_index('idx_dep_status', 'departures', ['status'])
|
||||
op.create_index('idx_dep_booked_out_dt', 'departures', ['booked_out_dt'])
|
||||
op.create_index('idx_dep_created_dt', 'departures', ['created_dt'])
|
||||
op.create_index('idx_dep_etd', 'departures', ['etd'])
|
||||
op.create_index('idx_dep_created_by', 'departures', ['created_by'])
|
||||
|
||||
# Create arrivals table for non-PPR arrivals from elsewhere
|
||||
|
||||
@@ -132,7 +132,7 @@ async def update_departure_status(
|
||||
"id": departure.id,
|
||||
"registration": departure.registration,
|
||||
"status": departure.status.value,
|
||||
"departure_dt": departure.departure_dt.isoformat() if departure.departure_dt else None
|
||||
"departed_dt": departure.departed_dt.isoformat() if departure.departed_dt else None
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ async def get_public_arrivals(db: Session = Depends(get_db)):
|
||||
'ac_reg': flight.registration,
|
||||
'ac_type': flight.type,
|
||||
'in_from': None,
|
||||
'eta': flight.departure_dt,
|
||||
'eta': flight.departed_dt,
|
||||
'landed_dt': None,
|
||||
'status': 'DEPARTED',
|
||||
'isLocalFlight': True,
|
||||
@@ -92,7 +92,7 @@ async def get_public_departures(db: Session = Depends(get_db)):
|
||||
'ac_reg': flight.registration,
|
||||
'ac_type': flight.type,
|
||||
'out_to': None,
|
||||
'etd': flight.booked_out_dt,
|
||||
'etd': flight.etd or flight.created_dt,
|
||||
'departed_dt': None,
|
||||
'status': 'BOOKED_OUT',
|
||||
'isLocalFlight': True,
|
||||
@@ -114,7 +114,7 @@ async def get_public_departures(db: Session = Depends(get_db)):
|
||||
'ac_reg': dep.registration,
|
||||
'ac_type': dep.type,
|
||||
'out_to': dep.out_to,
|
||||
'etd': dep.booked_out_dt,
|
||||
'etd': dep.etd or dep.created_dt,
|
||||
'departed_dt': None,
|
||||
'status': 'BOOKED_OUT',
|
||||
'isLocalFlight': False,
|
||||
|
||||
@@ -25,25 +25,25 @@ class CRUDDeparture:
|
||||
query = query.filter(Departure.status == status)
|
||||
|
||||
if date_from:
|
||||
query = query.filter(func.date(Departure.booked_out_dt) >= date_from)
|
||||
query = query.filter(func.date(Departure.created_dt) >= date_from)
|
||||
|
||||
if date_to:
|
||||
query = query.filter(func.date(Departure.booked_out_dt) <= date_to)
|
||||
query = query.filter(func.date(Departure.created_dt) <= date_to)
|
||||
|
||||
return query.order_by(desc(Departure.booked_out_dt)).offset(skip).limit(limit).all()
|
||||
return query.order_by(desc(Departure.created_dt)).offset(skip).limit(limit).all()
|
||||
|
||||
def get_departures_today(self, db: Session) -> List[Departure]:
|
||||
"""Get today's departures (booked out or departed)"""
|
||||
today = date.today()
|
||||
return db.query(Departure).filter(
|
||||
and_(
|
||||
func.date(Departure.booked_out_dt) == today,
|
||||
func.date(Departure.created_dt) == today,
|
||||
or_(
|
||||
Departure.status == DepartureStatus.BOOKED_OUT,
|
||||
Departure.status == DepartureStatus.DEPARTED
|
||||
)
|
||||
)
|
||||
).order_by(Departure.booked_out_dt).all()
|
||||
).order_by(Departure.created_dt).all()
|
||||
|
||||
def create(self, db: Session, obj_in: DepartureCreate, created_by: str) -> Departure:
|
||||
db_obj = Departure(
|
||||
@@ -82,7 +82,7 @@ class CRUDDeparture:
|
||||
db_obj.status = status
|
||||
|
||||
if status == DepartureStatus.DEPARTED and timestamp:
|
||||
db_obj.departure_dt = timestamp
|
||||
db_obj.departed_dt = timestamp
|
||||
|
||||
db.add(db_obj)
|
||||
db.commit()
|
||||
|
||||
@@ -29,12 +29,12 @@ class CRUDLocalFlight:
|
||||
query = query.filter(LocalFlight.flight_type == flight_type)
|
||||
|
||||
if date_from:
|
||||
query = query.filter(func.date(LocalFlight.booked_out_dt) >= date_from)
|
||||
query = query.filter(func.date(LocalFlight.created_dt) >= date_from)
|
||||
|
||||
if date_to:
|
||||
query = query.filter(func.date(LocalFlight.booked_out_dt) <= date_to)
|
||||
query = query.filter(func.date(LocalFlight.created_dt) <= date_to)
|
||||
|
||||
return query.order_by(desc(LocalFlight.booked_out_dt)).offset(skip).limit(limit).all()
|
||||
return query.order_by(desc(LocalFlight.created_dt)).offset(skip).limit(limit).all()
|
||||
|
||||
def get_active_flights(self, db: Session) -> List[LocalFlight]:
|
||||
"""Get currently active (booked out or departed) flights"""
|
||||
@@ -43,33 +43,33 @@ class CRUDLocalFlight:
|
||||
LocalFlight.status == LocalFlightStatus.BOOKED_OUT,
|
||||
LocalFlight.status == LocalFlightStatus.DEPARTED
|
||||
)
|
||||
).order_by(desc(LocalFlight.booked_out_dt)).all()
|
||||
).order_by(desc(LocalFlight.created_dt)).all()
|
||||
|
||||
def get_departures_today(self, db: Session) -> List[LocalFlight]:
|
||||
"""Get today's departures (booked out or departed)"""
|
||||
today = date.today()
|
||||
return db.query(LocalFlight).filter(
|
||||
and_(
|
||||
func.date(LocalFlight.booked_out_dt) == today,
|
||||
func.date(LocalFlight.created_dt) == today,
|
||||
or_(
|
||||
LocalFlight.status == LocalFlightStatus.BOOKED_OUT,
|
||||
LocalFlight.status == LocalFlightStatus.DEPARTED
|
||||
)
|
||||
)
|
||||
).order_by(LocalFlight.booked_out_dt).all()
|
||||
).order_by(LocalFlight.created_dt).all()
|
||||
|
||||
def get_booked_out_today(self, db: Session) -> List[LocalFlight]:
|
||||
"""Get all flights booked out today"""
|
||||
today = date.today()
|
||||
return db.query(LocalFlight).filter(
|
||||
and_(
|
||||
func.date(LocalFlight.booked_out_dt) == today,
|
||||
func.date(LocalFlight.created_dt) == today,
|
||||
or_(
|
||||
LocalFlight.status == LocalFlightStatus.BOOKED_OUT,
|
||||
LocalFlight.status == LocalFlightStatus.LANDED
|
||||
)
|
||||
)
|
||||
).order_by(LocalFlight.booked_out_dt).all()
|
||||
).order_by(LocalFlight.created_dt).all()
|
||||
|
||||
def create(self, db: Session, obj_in: LocalFlightCreate, created_by: str) -> LocalFlight:
|
||||
db_obj = LocalFlight(
|
||||
@@ -114,7 +114,7 @@ class CRUDLocalFlight:
|
||||
# Set timestamps based on status
|
||||
current_time = timestamp if timestamp is not None else datetime.utcnow()
|
||||
if status == LocalFlightStatus.DEPARTED:
|
||||
db_obj.departure_dt = current_time
|
||||
db_obj.departed_dt = current_time
|
||||
elif status == LocalFlightStatus.LANDED:
|
||||
db_obj.landed_dt = current_time
|
||||
|
||||
|
||||
@@ -20,10 +20,11 @@ class Departure(Base):
|
||||
type = Column(String(32), nullable=True)
|
||||
callsign = Column(String(16), nullable=True)
|
||||
pob = Column(Integer, nullable=False)
|
||||
out_to = Column(String(4), nullable=False, index=True)
|
||||
out_to = Column(String(64), nullable=False, index=True)
|
||||
status = Column(SQLEnum(DepartureStatus), default=DepartureStatus.BOOKED_OUT, nullable=False, index=True)
|
||||
notes = Column(Text, nullable=True)
|
||||
booked_out_dt = Column(DateTime, server_default=func.now(), nullable=False, index=True)
|
||||
departure_dt = Column(DateTime, nullable=True)
|
||||
created_dt = Column(DateTime, server_default=func.now(), nullable=False, index=True)
|
||||
etd = Column(DateTime, nullable=True, index=True) # Estimated Time of Departure
|
||||
departed_dt = Column(DateTime, nullable=True) # Actual departure time
|
||||
created_by = Column(String(16), nullable=True, index=True)
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
|
||||
|
||||
@@ -28,8 +28,9 @@ class LocalFlight(Base):
|
||||
flight_type = Column(SQLEnum(LocalFlightType), nullable=False, index=True)
|
||||
status = Column(SQLEnum(LocalFlightStatus), nullable=False, default=LocalFlightStatus.BOOKED_OUT, index=True)
|
||||
notes = Column(Text, nullable=True)
|
||||
booked_out_dt = Column(DateTime, nullable=False, server_default=func.current_timestamp(), index=True)
|
||||
departure_dt = Column(DateTime, nullable=True) # Actual takeoff time
|
||||
created_dt = Column(DateTime, nullable=False, server_default=func.current_timestamp(), index=True)
|
||||
etd = Column(DateTime, nullable=True, index=True) # Estimated Time of Departure
|
||||
departed_dt = Column(DateTime, nullable=True) # Actual takeoff time
|
||||
landed_dt = Column(DateTime, nullable=True)
|
||||
created_by = Column(String(16), nullable=True, index=True)
|
||||
updated_at = Column(DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp())
|
||||
|
||||
@@ -16,6 +16,7 @@ class DepartureBase(BaseModel):
|
||||
callsign: Optional[str] = None
|
||||
pob: int
|
||||
out_to: str
|
||||
etd: Optional[datetime] = None # Estimated Time of Departure
|
||||
notes: Optional[str] = None
|
||||
|
||||
@validator('registration')
|
||||
@@ -46,6 +47,7 @@ class DepartureUpdate(BaseModel):
|
||||
callsign: Optional[str] = None
|
||||
pob: Optional[int] = None
|
||||
out_to: Optional[str] = None
|
||||
etd: Optional[datetime] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
@@ -57,10 +59,6 @@ class DepartureStatusUpdate(BaseModel):
|
||||
class Departure(DepartureBase):
|
||||
id: int
|
||||
status: DepartureStatus
|
||||
booked_out_dt: datetime
|
||||
departure_dt: Optional[datetime] = None
|
||||
created_by: Optional[str] = None
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
created_dt: datetime
|
||||
etd: Optional[datetime] = None
|
||||
departed_dt: Optional[datetime] = None
|
||||
|
||||
@@ -23,6 +23,7 @@ class LocalFlightBase(BaseModel):
|
||||
callsign: Optional[str] = None
|
||||
pob: int
|
||||
flight_type: LocalFlightType
|
||||
etd: Optional[datetime] = None # Estimated Time of Departure
|
||||
notes: Optional[str] = None
|
||||
|
||||
@validator('registration')
|
||||
@@ -57,7 +58,8 @@ class LocalFlightUpdate(BaseModel):
|
||||
pob: Optional[int] = None
|
||||
flight_type: Optional[LocalFlightType] = None
|
||||
status: Optional[LocalFlightStatus] = None
|
||||
departure_dt: Optional[datetime] = None
|
||||
etd: Optional[datetime] = None
|
||||
departed_dt: Optional[datetime] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
|
||||
@@ -69,8 +71,9 @@ class LocalFlightStatusUpdate(BaseModel):
|
||||
class LocalFlightInDBBase(LocalFlightBase):
|
||||
id: int
|
||||
status: LocalFlightStatus
|
||||
booked_out_dt: datetime
|
||||
departure_dt: Optional[datetime] = None
|
||||
created_dt: datetime
|
||||
etd: Optional[datetime] = None
|
||||
departed_dt: Optional[datetime] = None
|
||||
landed_dt: Optional[datetime] = None
|
||||
created_by: Optional[str] = None
|
||||
updated_at: datetime
|
||||
|
||||
648
web/admin.css
Normal file
648
web/admin.css
Normal file
@@ -0,0 +1,648 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
color: #333;
|
||||
padding-bottom: 40px; /* Make room for footer */
|
||||
}
|
||||
|
||||
.top-bar {
|
||||
background: linear-gradient(135deg, #2c3e50, #3498db);
|
||||
color: white;
|
||||
padding: 0.5rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.title h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.menu-buttons {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.top-bar .user-info {
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.9;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 0.7rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background-color: #27ae60;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background-color: #229954;
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
background-color: #f39c12;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-warning:hover {
|
||||
background-color: #e67e22;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-info:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: #e74c3c;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background-color: #c0392b;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
padding: 0.3rem 0.6rem;
|
||||
font-size: 0.8rem;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.btn-icon:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-group label {
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.filter-group select, .filter-group input {
|
||||
padding: 0.5rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.ppr-table {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
background: #34495e;
|
||||
color: white;
|
||||
padding: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-header-collapsible {
|
||||
background: #34495e;
|
||||
color: white;
|
||||
padding: 1rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.table-header-collapsible:hover {
|
||||
background: #3d5a6e;
|
||||
}
|
||||
|
||||
.collapse-icon {
|
||||
transition: transform 0.3s ease;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.collapse-icon.collapsed {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.footer-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #34495e;
|
||||
color: white;
|
||||
padding: 0.5rem 2rem;
|
||||
text-align: center;
|
||||
font-size: 0.85rem;
|
||||
z-index: 50;
|
||||
box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
border: 3px solid #f3f3f3;
|
||||
border-top: 3px solid #3498db;
|
||||
border-radius: 50%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 0.5rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #eee;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 0.3rem 0.6rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.status.new { background: #e3f2fd; color: #1565c0; }
|
||||
.status.confirmed { background: #e8f5e8; color: #2e7d32; }
|
||||
.status.landed { background: #fff3e0; color: #ef6c00; }
|
||||
.status.departed { background: #fce4ec; color: #c2185b; }
|
||||
.status.canceled { background: #ffebee; color: #d32f2f; }
|
||||
.status.deleted { background: #f3e5f5; color: #7b1fa2; }
|
||||
|
||||
.no-data {
|
||||
text-align: center;
|
||||
padding: 3rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.notes-indicator {
|
||||
display: inline-block;
|
||||
background-color: #ffc107;
|
||||
color: #856404;
|
||||
font-size: 0.8rem;
|
||||
padding: 2px 6px;
|
||||
border-radius: 10px;
|
||||
margin-left: 5px;
|
||||
cursor: help;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.notes-tooltip {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.notes-tooltip .tooltip-text {
|
||||
visibility: hidden;
|
||||
width: 300px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: left;
|
||||
border-radius: 6px;
|
||||
padding: 8px;
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.4;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.notes-tooltip .tooltip-text::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: -5px;
|
||||
margin-top: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
border-color: transparent #333 transparent transparent;
|
||||
}
|
||||
|
||||
.notes-tooltip:hover .tooltip-text {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Modal Styles */
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: white;
|
||||
margin: 5% auto;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background: #34495e;
|
||||
color: white;
|
||||
padding: 1rem 1.5rem;
|
||||
border-radius: 8px 8px 0 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form-group.full-width {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.3rem;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.form-group input, .form-group select, .form-group textarea {
|
||||
padding: 0.6rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: #3498db;
|
||||
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
|
||||
}
|
||||
|
||||
#login-form .form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
#login-form .form-group input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#login-error {
|
||||
background-color: #ffebee;
|
||||
border: 1px solid #ffcdd2;
|
||||
border-radius: 4px;
|
||||
padding: 0.8rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: space-between;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.journal-section {
|
||||
margin-top: 2rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.journal-entries {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
padding: 1rem;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.journal-entry {
|
||||
margin-bottom: 0.8rem;
|
||||
padding-bottom: 0.8rem;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.journal-entry:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.journal-meta {
|
||||
font-size: 0.8rem;
|
||||
color: #666;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
.journal-text {
|
||||
font-size: 0.9rem;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* Aircraft Lookup Styles */
|
||||
#aircraft-lookup-results {
|
||||
margin-top: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
min-height: 20px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.aircraft-match {
|
||||
padding: 0.3rem;
|
||||
background-color: #e8f5e8;
|
||||
border: 1px solid #c3e6c3;
|
||||
border-radius: 4px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.aircraft-no-match {
|
||||
color: #6c757d;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.aircraft-searching {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
/* Airport Lookup Styles */
|
||||
#arrival-airport-lookup-results, #departure-airport-lookup-results, #local-out-to-lookup-results {
|
||||
margin-top: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
min-height: 20px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.airport-match {
|
||||
padding: 0.3rem;
|
||||
background-color: #e8f5e8;
|
||||
border: 1px solid #c3e6c3;
|
||||
border-radius: 4px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.airport-no-match {
|
||||
color: #6c757d;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.airport-searching {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.airport-list {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.airport-option {
|
||||
padding: 0.5rem;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.airport-option:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.airport-option:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.airport-code {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: bold;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.airport-name {
|
||||
color: #6c757d;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.airport-location {
|
||||
color: #868e96;
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.notification {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background-color: #27ae60;
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
||||
z-index: 10000;
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.notification.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.notification.error {
|
||||
background-color: #e74c3c;
|
||||
}
|
||||
|
||||
/* Unified Lookup Styles */
|
||||
.lookup-no-match {
|
||||
color: #6c757d;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.lookup-searching {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.lookup-list {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.lookup-option {
|
||||
padding: 0.5rem;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.lookup-option:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.lookup-option:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.lookup-code {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-weight: bold;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.lookup-name {
|
||||
color: #6c757d;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.lookup-location {
|
||||
color: #868e96;
|
||||
font-size: 0.8rem;
|
||||
font-style: italic;
|
||||
}
|
||||
1140
web/admin.html
1140
web/admin.html
File diff suppressed because it is too large
Load Diff
317
web/lookups.js
Normal file
317
web/lookups.js
Normal file
@@ -0,0 +1,317 @@
|
||||
/**
|
||||
* Lookup Utilities - Reusable functions for aircraft and airport lookups
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a reusable lookup handler
|
||||
* @param {string} fieldId - ID of the input field
|
||||
* @param {string} resultsId - ID of the results container
|
||||
* @param {function} selectCallback - Function to call when item is selected
|
||||
* @param {object} options - Additional options (minLength, debounceMs, etc.)
|
||||
*/
|
||||
function createLookup(fieldId, resultsId, selectCallback, options = {}) {
|
||||
const defaults = {
|
||||
minLength: 2,
|
||||
debounceMs: 300,
|
||||
isAirport: false,
|
||||
isAircraft: false,
|
||||
maxResults: 10
|
||||
};
|
||||
const config = { ...defaults, ...options };
|
||||
let debounceTimeout;
|
||||
|
||||
const lookup = {
|
||||
// Main handler called by oninput
|
||||
handle: (value) => {
|
||||
clearTimeout(debounceTimeout);
|
||||
|
||||
if (!value || value.trim().length < config.minLength) {
|
||||
lookup.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
lookup.showSearching();
|
||||
debounceTimeout = setTimeout(() => {
|
||||
lookup.perform(value);
|
||||
}, config.debounceMs);
|
||||
},
|
||||
|
||||
// Perform the lookup
|
||||
perform: async (searchTerm) => {
|
||||
try {
|
||||
const cleanInput = searchTerm.trim();
|
||||
let endpoint;
|
||||
|
||||
if (config.isAircraft) {
|
||||
const cleaned = cleanInput.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
|
||||
if (cleaned.length < config.minLength) {
|
||||
lookup.clear();
|
||||
return;
|
||||
}
|
||||
endpoint = `/api/v1/aircraft/lookup/${cleaned}`;
|
||||
} else if (config.isAirport) {
|
||||
endpoint = `/api/v1/airport/lookup/${encodeURIComponent(cleanInput)}`;
|
||||
}
|
||||
|
||||
if (!endpoint) throw new Error('Invalid lookup type');
|
||||
|
||||
const response = await authenticatedFetch(endpoint);
|
||||
if (!response.ok) throw new Error('Lookup failed');
|
||||
|
||||
const results = await response.json();
|
||||
lookup.display(results, cleanInput);
|
||||
} catch (error) {
|
||||
console.error('Lookup error:', error);
|
||||
lookup.showError();
|
||||
}
|
||||
},
|
||||
|
||||
// Display results
|
||||
display: (results, searchTerm) => {
|
||||
const resultsDiv = document.getElementById(resultsId);
|
||||
|
||||
if (config.isAircraft) {
|
||||
// Aircraft lookup: auto-populate on single match, show message on multiple
|
||||
if (!results || results.length === 0) {
|
||||
resultsDiv.innerHTML = '<div class="aircraft-no-match">No matches found</div>';
|
||||
} else if (results.length === 1) {
|
||||
// Single match - auto-populate
|
||||
const aircraft = results[0];
|
||||
resultsDiv.innerHTML = `
|
||||
<div class="aircraft-match">
|
||||
✓ ${aircraft.manufacturer_name || ''} ${aircraft.model || aircraft.type_code || ''}
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Auto-populate the form fields
|
||||
const field = document.getElementById(fieldId);
|
||||
if (field) field.value = aircraft.registration;
|
||||
|
||||
// Also populate type field
|
||||
let typeFieldId;
|
||||
if (fieldId === 'ac_reg') {
|
||||
typeFieldId = 'ac_type';
|
||||
} else if (fieldId === 'local_registration') {
|
||||
typeFieldId = 'local_type';
|
||||
}
|
||||
|
||||
if (typeFieldId) {
|
||||
const typeField = document.getElementById(typeFieldId);
|
||||
if (typeField) typeField.value = aircraft.type_code || '';
|
||||
}
|
||||
} else {
|
||||
// Multiple matches
|
||||
resultsDiv.innerHTML = `
|
||||
<div class="aircraft-no-match">
|
||||
Multiple matches found (${results.length}) - please be more specific
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
} else {
|
||||
// Airport lookup: show list of options
|
||||
if (!results || results.length === 0) {
|
||||
resultsDiv.innerHTML = '<div class="lookup-no-match">No matches found - will use as entered</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const itemsToShow = results.slice(0, config.maxResults);
|
||||
const matchText = itemsToShow.length === 1 ? 'Match found - click to select:' : 'Multiple matches found - select one:';
|
||||
|
||||
let html = `<div class="lookup-no-match" style="margin-bottom: 0.5rem;">${matchText}</div><div class="lookup-list">`;
|
||||
|
||||
itemsToShow.forEach(item => {
|
||||
html += `
|
||||
<div class="lookup-option" onclick="lookupManager.selectItem('${resultsId}', '${fieldId}', '${item.icao}')">
|
||||
<div class="lookup-code">${item.icao}</div>
|
||||
<div class="lookup-name">${item.name || '-'}</div>
|
||||
${item.city ? `<div class="lookup-location">${item.city}, ${item.country}</div>` : ''}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</div>';
|
||||
resultsDiv.innerHTML = html;
|
||||
}
|
||||
},
|
||||
|
||||
// Show searching state
|
||||
showSearching: () => {
|
||||
const resultsDiv = document.getElementById(resultsId);
|
||||
if (resultsDiv) {
|
||||
resultsDiv.innerHTML = '<div class="lookup-searching">Searching...</div>';
|
||||
}
|
||||
},
|
||||
|
||||
// Show error state
|
||||
showError: () => {
|
||||
const resultsDiv = document.getElementById(resultsId);
|
||||
if (resultsDiv) {
|
||||
resultsDiv.innerHTML = '<div class="lookup-no-match">Lookup failed - will use as entered</div>';
|
||||
}
|
||||
},
|
||||
|
||||
// Clear results
|
||||
clear: () => {
|
||||
const resultsDiv = document.getElementById(resultsId);
|
||||
if (resultsDiv) {
|
||||
resultsDiv.innerHTML = '';
|
||||
}
|
||||
},
|
||||
|
||||
// Set the selected value
|
||||
setValue: (value) => {
|
||||
const field = document.getElementById(fieldId);
|
||||
if (field) {
|
||||
field.value = value;
|
||||
}
|
||||
lookup.clear();
|
||||
if (selectCallback) selectCallback(value);
|
||||
}
|
||||
};
|
||||
|
||||
return lookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global lookup manager for all lookups on the page
|
||||
*/
|
||||
const lookupManager = {
|
||||
lookups: {},
|
||||
|
||||
// Register a lookup instance
|
||||
register: (name, lookup) => {
|
||||
lookupManager.lookups[name] = lookup;
|
||||
},
|
||||
|
||||
// Generic item selection handler
|
||||
selectItem: (resultsId, fieldId, itemCode) => {
|
||||
const field = document.getElementById(fieldId);
|
||||
if (field) {
|
||||
field.value = itemCode;
|
||||
}
|
||||
const resultsDiv = document.getElementById(resultsId);
|
||||
if (resultsDiv) {
|
||||
resultsDiv.innerHTML = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize all lookups when page loads
|
||||
function initializeLookups() {
|
||||
// Create reusable lookup instances
|
||||
const arrivalAirportLookup = createLookup(
|
||||
'in_from',
|
||||
'arrival-airport-lookup-results',
|
||||
null,
|
||||
{ isAirport: true, minLength: 2 }
|
||||
);
|
||||
lookupManager.register('arrival-airport', arrivalAirportLookup);
|
||||
|
||||
const departureAirportLookup = createLookup(
|
||||
'out_to',
|
||||
'departure-airport-lookup-results',
|
||||
null,
|
||||
{ isAirport: true, minLength: 2 }
|
||||
);
|
||||
lookupManager.register('departure-airport', departureAirportLookup);
|
||||
|
||||
const localOutToLookup = createLookup(
|
||||
'local_out_to',
|
||||
'local-out-to-lookup-results',
|
||||
null,
|
||||
{ isAirport: true, minLength: 2 }
|
||||
);
|
||||
lookupManager.register('local-out-to', localOutToLookup);
|
||||
|
||||
const aircraftLookup = createLookup(
|
||||
'ac_reg',
|
||||
'aircraft-lookup-results',
|
||||
null,
|
||||
{ isAircraft: true, minLength: 4, debounceMs: 300 }
|
||||
);
|
||||
lookupManager.register('aircraft', aircraftLookup);
|
||||
|
||||
const localAircraftLookup = createLookup(
|
||||
'local_registration',
|
||||
'local-aircraft-lookup-results',
|
||||
null,
|
||||
{ isAircraft: true, minLength: 4, debounceMs: 300 }
|
||||
);
|
||||
lookupManager.register('local-aircraft', localAircraftLookup);
|
||||
}
|
||||
|
||||
// Initialize on DOM ready or immediately if already loaded
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initializeLookups);
|
||||
} else {
|
||||
initializeLookups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper functions for backward compatibility
|
||||
*/
|
||||
function handleArrivalAirportLookup(value) {
|
||||
const lookup = lookupManager.lookups['arrival-airport'];
|
||||
if (lookup) lookup.handle(value);
|
||||
}
|
||||
|
||||
function handleDepartureAirportLookup(value) {
|
||||
const lookup = lookupManager.lookups['departure-airport'];
|
||||
if (lookup) lookup.handle(value);
|
||||
}
|
||||
|
||||
function handleLocalOutToAirportLookup(value) {
|
||||
const lookup = lookupManager.lookups['local-out-to'];
|
||||
if (lookup) lookup.handle(value);
|
||||
}
|
||||
|
||||
function handleAircraftLookup(value) {
|
||||
const lookup = lookupManager.lookups['aircraft'];
|
||||
if (lookup) lookup.handle(value);
|
||||
}
|
||||
|
||||
function handleLocalAircraftLookup(value) {
|
||||
const lookup = lookupManager.lookups['local-aircraft'];
|
||||
if (lookup) lookup.handle(value);
|
||||
}
|
||||
|
||||
function clearArrivalAirportLookup() {
|
||||
const lookup = lookupManager.lookups['arrival-airport'];
|
||||
if (lookup) lookup.clear();
|
||||
}
|
||||
|
||||
function clearDepartureAirportLookup() {
|
||||
const lookup = lookupManager.lookups['departure-airport'];
|
||||
if (lookup) lookup.clear();
|
||||
}
|
||||
|
||||
function clearLocalOutToAirportLookup() {
|
||||
const lookup = lookupManager.lookups['local-out-to'];
|
||||
if (lookup) lookup.clear();
|
||||
}
|
||||
|
||||
function clearAircraftLookup() {
|
||||
const lookup = lookupManager.lookups['aircraft'];
|
||||
if (lookup) lookup.clear();
|
||||
}
|
||||
|
||||
function clearLocalAircraftLookup() {
|
||||
const lookup = lookupManager.lookups['local-aircraft'];
|
||||
if (lookup) lookup.clear();
|
||||
}
|
||||
|
||||
function selectArrivalAirport(icaoCode) {
|
||||
lookupManager.selectItem('arrival-airport-lookup-results', 'in_from', icaoCode);
|
||||
}
|
||||
|
||||
function selectDepartureAirport(icaoCode) {
|
||||
lookupManager.selectItem('departure-airport-lookup-results', 'out_to', icaoCode);
|
||||
}
|
||||
|
||||
function selectLocalOutToAirport(icaoCode) {
|
||||
lookupManager.selectItem('local-out-to-lookup-results', 'local_out_to', icaoCode);
|
||||
}
|
||||
|
||||
function selectLocalAircraft(registration) {
|
||||
lookupManager.selectItem('local-aircraft-lookup-results', 'local_registration', registration);
|
||||
}
|
||||
Reference in New Issue
Block a user