Small bugfixes
This commit is contained in:
@@ -4,6 +4,7 @@ from sqlalchemy import and_, or_, func, desc
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
import secrets
|
import secrets
|
||||||
from app.models.ppr import PPRRecord, PPRStatus
|
from app.models.ppr import PPRRecord, PPRStatus
|
||||||
|
from app.models.journal import EntityType
|
||||||
from app.schemas.ppr import PPRCreate, PPRUpdate
|
from app.schemas.ppr import PPRCreate, PPRUpdate
|
||||||
from app.crud.crud_journal import journal as crud_journal
|
from app.crud.crud_journal import journal as crud_journal
|
||||||
|
|
||||||
@@ -89,6 +90,7 @@ class CRUDPPR:
|
|||||||
# Log creation in journal
|
# Log creation in journal
|
||||||
crud_journal.log_change(
|
crud_journal.log_change(
|
||||||
db,
|
db,
|
||||||
|
EntityType.PPR,
|
||||||
db_obj.id,
|
db_obj.id,
|
||||||
f"PPR created for {db_obj.ac_reg}",
|
f"PPR created for {db_obj.ac_reg}",
|
||||||
created_by,
|
created_by,
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ http {
|
|||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
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
|
# Security headers
|
||||||
|
|||||||
@@ -990,7 +990,7 @@
|
|||||||
// Refresh local flights when any local flight event occurs
|
// Refresh local flights when any local flight event occurs
|
||||||
if (data.type && (data.type.includes('local_flight_'))) {
|
if (data.type && (data.type.includes('local_flight_'))) {
|
||||||
console.log('Local flight update detected, refreshing...');
|
console.log('Local flight update detected, refreshing...');
|
||||||
loadLocalFlights();
|
loadPPRs();
|
||||||
showNotification('Local flight updated');
|
showNotification('Local flight updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1709,11 +1709,7 @@
|
|||||||
document.getElementById('parked-no-data').style.display = 'none';
|
document.getElementById('parked-no-data').style.display = 'none';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load both PPRs and booked-in arrivals
|
const pprResponse = await authenticatedFetch('/api/v1/pprs/?limit=1000');
|
||||||
const [pprResponse, bookedInResponse] = await Promise.all([
|
|
||||||
authenticatedFetch('/api/v1/pprs/?limit=1000'),
|
|
||||||
authenticatedFetch('/api/v1/arrivals/?limit=1000')
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!pprResponse.ok) {
|
if (!pprResponse.ok) {
|
||||||
throw new Error('Failed to fetch parked visitors');
|
throw new Error('Failed to fetch parked visitors');
|
||||||
@@ -1722,33 +1718,19 @@
|
|||||||
const allPPRs = await pprResponse.json();
|
const allPPRs = await pprResponse.json();
|
||||||
const today = new Date().toISOString().split('T')[0];
|
const today = new Date().toISOString().split('T')[0];
|
||||||
|
|
||||||
// Filter for parked visitors: LANDED status and (no ETD or ETD not today)
|
// Filter for parked PPR visitors: LANDED status and ETD on a different day
|
||||||
// Show all parked aircraft regardless of when they arrived
|
|
||||||
const parked = allPPRs.filter(ppr => {
|
const parked = allPPRs.filter(ppr => {
|
||||||
if (ppr.status !== 'LANDED') {
|
if (ppr.status !== 'LANDED') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// No ETD means parked
|
// Only show if ETD exists and is not today
|
||||||
if (!ppr.etd) {
|
if (!ppr.etd) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
// ETD exists but is not today
|
|
||||||
const etdDate = ppr.etd.split('T')[0];
|
const etdDate = ppr.etd.split('T')[0];
|
||||||
return etdDate !== today;
|
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);
|
displayParked(parked);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading parked visitors:', error);
|
console.error('Error loading parked visitors:', error);
|
||||||
@@ -1793,26 +1775,17 @@
|
|||||||
|
|
||||||
for (const ppr of uniqueParked) {
|
for (const ppr of uniqueParked) {
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
const isBookedIn = ppr.isBookedIn;
|
|
||||||
|
|
||||||
// Click handler that routes to correct modal/display
|
// All rows are PPR, so make them clickable
|
||||||
if (isBookedIn) {
|
|
||||||
row.style.cursor = 'default'; // Booked-in arrivals don't have a modal yet
|
|
||||||
} else {
|
|
||||||
row.onclick = () => openPPRModal(ppr.id);
|
row.onclick = () => openPPRModal(ppr.id);
|
||||||
}
|
|
||||||
row.style.cssText = 'font-size: 0.85rem !important; font-style: italic;';
|
row.style.cssText = 'font-size: 0.85rem !important; font-style: italic;';
|
||||||
|
|
||||||
// Get registration based on type (PPR vs booked-in)
|
// Get registration
|
||||||
let registration = ppr.ac_reg || ppr.registration || '-';
|
const registration = ppr.ac_reg || '-';
|
||||||
let typeIconParked = '';
|
const typeIconParked = '<span style="color: #032cfc; font-weight: bold;" title="From PPR">P</span>';
|
||||||
if (!isBookedIn) {
|
|
||||||
// Add P icon for PPR flights
|
|
||||||
typeIconParked = '<span style="color: #032cfc; font-weight: bold;" title="From PPR">P</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get aircraft type based on type (PPR vs booked-in)
|
// Get aircraft type
|
||||||
const acType = ppr.ac_type || ppr.type || '-';
|
const acType = ppr.ac_type || '-';
|
||||||
|
|
||||||
// Get from airport
|
// Get from airport
|
||||||
const fromAirport = ppr.in_from || '-';
|
const fromAirport = ppr.in_from || '-';
|
||||||
|
|||||||
Reference in New Issue
Block a user