Admin rename and ATC fixes
This commit is contained in:
+43
-9
@@ -232,7 +232,7 @@
|
||||
⚙️ Admin
|
||||
</button>
|
||||
<div class="dropdown-menu" id="adminDropdownMenu">
|
||||
<a href="#" onclick="window.location.href = '/admin'">🏠 Admin View</a>
|
||||
<a href="#" onclick="window.location.href = '/admin'">🏠 Home</a>
|
||||
<a href="#" onclick="window.location.href = '/reports'">📊 Reports</a>
|
||||
<a href="#" onclick="window.location.href = '/bulk-log'">🧾 Bulk Flight Log</a>
|
||||
<a href="#" onclick="window.location.href = '/journal'">📔 Journal Log</a>
|
||||
@@ -1358,6 +1358,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getLocalDateString(date = new Date()) {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function isTodayDateTime(value) {
|
||||
return Boolean(value) && value.split('T')[0] === getLocalDateString();
|
||||
}
|
||||
|
||||
function isTodayRecord(record, fields = ['created_dt']) {
|
||||
return fields.some(field => isTodayDateTime(record[field]));
|
||||
}
|
||||
|
||||
// Load departing aircraft (ready to take off)
|
||||
async function loadDepartingAircraft() {
|
||||
try {
|
||||
@@ -1369,6 +1384,7 @@
|
||||
let groundAircraft = [];
|
||||
if (groundDeparturesResponse.ok) groundAircraft = await groundDeparturesResponse.json();
|
||||
if (groundLocalResponse.ok) groundAircraft = groundAircraft.concat((await groundLocalResponse.json()).map(l => ({ ...l, isLocalFlight: true })));
|
||||
groundAircraft = groundAircraft.filter(ac => isTodayRecord(ac, ['created_dt', 'etd']));
|
||||
|
||||
displayDepartingAircraft(groundAircraft.map(ac => ({
|
||||
...ac,
|
||||
@@ -1440,6 +1456,13 @@
|
||||
if (response[1].ok) locals = locals.concat((await response[1].json()).map(d => ({ ...d, isDeparture: true })));
|
||||
if (response[2].ok) locals = locals.concat((await response[2].json()).map(a => ({ ...a, isArrival: true })));
|
||||
if (response[3].ok) locals = locals.concat((await response[3].json()).map(o => ({ ...o, isOverflight: true })));
|
||||
locals = locals.filter(ac => {
|
||||
if (ac.isOverflight) return true;
|
||||
if (ac.isLocalFlight) return isTodayRecord(ac, ['created_dt', 'etd', 'takeoff_dt', 'departed_dt']);
|
||||
if (ac.isArrival) return isTodayRecord(ac, ['created_dt', 'eta']);
|
||||
if (ac.isDeparture) return isTodayRecord(ac, ['created_dt', 'etd', 'takeoff_dt', 'departed_dt']);
|
||||
return true;
|
||||
});
|
||||
|
||||
displayLocalAircraft(locals);
|
||||
} catch (error) {
|
||||
@@ -1507,9 +1530,13 @@
|
||||
const pprs = response[0].ok ? await response[0].json() : [];
|
||||
const arrivals = response[1].ok ? await response[1].json() : [];
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const today = getLocalDateString();
|
||||
let inbound = pprs.filter(p => p.status === 'CONFIRMED' && p.eta && p.eta.split('T')[0] === today);
|
||||
inbound = inbound.concat(arrivals.map(a => ({ ...a, isArrival: true })));
|
||||
inbound = inbound.concat(
|
||||
arrivals
|
||||
.filter(a => isTodayRecord(a, ['created_dt', 'eta']))
|
||||
.map(a => ({ ...a, isArrival: true }))
|
||||
);
|
||||
|
||||
displayInboundAircraft(inbound);
|
||||
} catch (error) {
|
||||
@@ -1565,6 +1592,11 @@
|
||||
if (response[0].ok) circuits = circuits.concat(await response[0].json());
|
||||
if (response[1].ok) circuits = circuits.concat((await response[1].json()).map(l => ({ ...l, circuitStatus: getCircuitStatus(l.status) })));
|
||||
if (response[2].ok) circuits = circuits.concat((await response[2].json()).map(a => ({ ...a, isArrival: true, circuitStatus: getCircuitStatus(a.status) })));
|
||||
circuits = circuits.filter(ac => (
|
||||
ac.isArrival
|
||||
? isTodayRecord(ac, ['created_dt', 'eta'])
|
||||
: isTodayRecord(ac, ['created_dt', 'etd', 'takeoff_dt', 'departed_dt'])
|
||||
));
|
||||
|
||||
displayCircuitAircraft(circuits);
|
||||
} catch (error) {
|
||||
@@ -1659,7 +1691,12 @@
|
||||
const response = await authenticatedFetch('/api/v1/pprs/?limit=1000');
|
||||
const pprs = response.ok ? await response.json() : [];
|
||||
|
||||
const pending = pprs.filter(p => p.status === 'NEW' || p.status === 'CONFIRMED');
|
||||
const today = getLocalDateString();
|
||||
const pending = pprs.filter(p => (
|
||||
(p.status === 'NEW' || p.status === 'CONFIRMED') &&
|
||||
p.eta &&
|
||||
p.eta.split('T')[0] === today
|
||||
));
|
||||
displayPendingPPRs(pending);
|
||||
} catch (error) {
|
||||
console.error('Error loading pending PPRs:', error);
|
||||
@@ -1724,18 +1761,15 @@
|
||||
const depBookedOut = depBookedOutResponse.ok ? await depBookedOutResponse.json() : [];
|
||||
|
||||
// Filter for today's bookings
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const bookedOutAircraft = [
|
||||
...localBookedOut.filter(flight => {
|
||||
const createdDate = flight.created_dt.split('T')[0];
|
||||
return createdDate === today;
|
||||
return isTodayRecord(flight, ['created_dt', 'etd']);
|
||||
}).map(flight => ({
|
||||
...flight,
|
||||
isLocalFlight: true
|
||||
})),
|
||||
...depBookedOut.filter(flight => {
|
||||
const createdDate = flight.created_dt.split('T')[0];
|
||||
return createdDate === today;
|
||||
return isTodayRecord(flight, ['created_dt', 'etd']);
|
||||
}).map(flight => ({
|
||||
...flight,
|
||||
isDeparture: true
|
||||
|
||||
Reference in New Issue
Block a user