Admin rename and ATC fixes
This commit is contained in:
+43
-9
@@ -232,7 +232,7 @@
|
|||||||
⚙️ Admin
|
⚙️ Admin
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu" id="adminDropdownMenu">
|
<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 = '/reports'">📊 Reports</a>
|
||||||
<a href="#" onclick="window.location.href = '/bulk-log'">🧾 Bulk Flight Log</a>
|
<a href="#" onclick="window.location.href = '/bulk-log'">🧾 Bulk Flight Log</a>
|
||||||
<a href="#" onclick="window.location.href = '/journal'">📔 Journal 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)
|
// Load departing aircraft (ready to take off)
|
||||||
async function loadDepartingAircraft() {
|
async function loadDepartingAircraft() {
|
||||||
try {
|
try {
|
||||||
@@ -1369,6 +1384,7 @@
|
|||||||
let groundAircraft = [];
|
let groundAircraft = [];
|
||||||
if (groundDeparturesResponse.ok) groundAircraft = await groundDeparturesResponse.json();
|
if (groundDeparturesResponse.ok) groundAircraft = await groundDeparturesResponse.json();
|
||||||
if (groundLocalResponse.ok) groundAircraft = groundAircraft.concat((await groundLocalResponse.json()).map(l => ({ ...l, isLocalFlight: true })));
|
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 => ({
|
displayDepartingAircraft(groundAircraft.map(ac => ({
|
||||||
...ac,
|
...ac,
|
||||||
@@ -1440,6 +1456,13 @@
|
|||||||
if (response[1].ok) locals = locals.concat((await response[1].json()).map(d => ({ ...d, isDeparture: true })));
|
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[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 })));
|
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);
|
displayLocalAircraft(locals);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1507,9 +1530,13 @@
|
|||||||
const pprs = response[0].ok ? await response[0].json() : [];
|
const pprs = response[0].ok ? await response[0].json() : [];
|
||||||
const arrivals = response[1].ok ? await response[1].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);
|
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);
|
displayInboundAircraft(inbound);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1565,6 +1592,11 @@
|
|||||||
if (response[0].ok) circuits = circuits.concat(await response[0].json());
|
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[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) })));
|
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);
|
displayCircuitAircraft(circuits);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1659,7 +1691,12 @@
|
|||||||
const response = await authenticatedFetch('/api/v1/pprs/?limit=1000');
|
const response = await authenticatedFetch('/api/v1/pprs/?limit=1000');
|
||||||
const pprs = response.ok ? await response.json() : [];
|
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);
|
displayPendingPPRs(pending);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading pending PPRs:', error);
|
console.error('Error loading pending PPRs:', error);
|
||||||
@@ -1724,18 +1761,15 @@
|
|||||||
const depBookedOut = depBookedOutResponse.ok ? await depBookedOutResponse.json() : [];
|
const depBookedOut = depBookedOutResponse.ok ? await depBookedOutResponse.json() : [];
|
||||||
|
|
||||||
// Filter for today's bookings
|
// Filter for today's bookings
|
||||||
const today = new Date().toISOString().split('T')[0];
|
|
||||||
const bookedOutAircraft = [
|
const bookedOutAircraft = [
|
||||||
...localBookedOut.filter(flight => {
|
...localBookedOut.filter(flight => {
|
||||||
const createdDate = flight.created_dt.split('T')[0];
|
return isTodayRecord(flight, ['created_dt', 'etd']);
|
||||||
return createdDate === today;
|
|
||||||
}).map(flight => ({
|
}).map(flight => ({
|
||||||
...flight,
|
...flight,
|
||||||
isLocalFlight: true
|
isLocalFlight: true
|
||||||
})),
|
})),
|
||||||
...depBookedOut.filter(flight => {
|
...depBookedOut.filter(flight => {
|
||||||
const createdDate = flight.created_dt.split('T')[0];
|
return isTodayRecord(flight, ['created_dt', 'etd']);
|
||||||
return createdDate === today;
|
|
||||||
}).map(flight => ({
|
}).map(flight => ({
|
||||||
...flight,
|
...flight,
|
||||||
isDeparture: true
|
isDeparture: true
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@
|
|||||||
⚙️ Menu <span class="notification-badge" id="drone-request-menu-badge" hidden>0</span>
|
⚙️ Menu <span class="notification-badge" id="drone-request-menu-badge" hidden>0</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu" id="adminDropdownMenu">
|
<div class="dropdown-menu" id="adminDropdownMenu">
|
||||||
${navLink('🏠 Admin View', '/admin')}
|
${navLink('🏠 Home', '/admin')}
|
||||||
${navLink('🎛️ ATC View', '/atc')}
|
${navLink('🎛️ ATC View', '/atc')}
|
||||||
${navLink('📊 Reports', '/reports')}
|
${navLink('📊 Reports', '/reports')}
|
||||||
${navLink('🛸 Drone Requests <span class="notification-badge" id="drone-request-badge" hidden>0</span>', '/drone-requests')}
|
${navLink('🛸 Drone Requests <span class="notification-badge" id="drone-request-badge" hidden>0</span>', '/drone-requests')}
|
||||||
|
|||||||
Reference in New Issue
Block a user