388 lines
12 KiB
HTML
388 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Airfield PPR - Arrivals & Departures</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Arial', sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: #333;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.header {
|
|
text-align: center;
|
|
color: white;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 10px;
|
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.header p {
|
|
font-size: 1.2rem;
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.boards {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 30px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.boards {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
.board {
|
|
background: white;
|
|
border-radius: 15px;
|
|
overflow: hidden;
|
|
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.board-header {
|
|
background: linear-gradient(45deg, #28a745, #20c997);
|
|
color: white;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.board-header.departures {
|
|
background: linear-gradient(45deg, #dc3545, #fd7e14);
|
|
}
|
|
|
|
.board-header h2 {
|
|
font-size: 1.5rem;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.board-content {
|
|
min-height: 400px;
|
|
position: relative;
|
|
}
|
|
|
|
.loading {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 400px;
|
|
font-size: 1.1rem;
|
|
color: #666;
|
|
}
|
|
|
|
.spinner {
|
|
border: 4px solid #f3f3f3;
|
|
border-top: 4px solid #667eea;
|
|
border-radius: 50%;
|
|
width: 40px;
|
|
height: 40px;
|
|
animation: spin 1s linear infinite;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
.ppr-list {
|
|
padding: 0;
|
|
}
|
|
|
|
.ppr-item {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
gap: 15px;
|
|
padding: 15px 20px;
|
|
border-bottom: 1px solid #eee;
|
|
align-items: center;
|
|
}
|
|
|
|
.ppr-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.ppr-item:hover {
|
|
background: #f8f9fa;
|
|
}
|
|
|
|
.ppr-field {
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.ppr-field strong {
|
|
display: block;
|
|
color: #495057;
|
|
font-size: 0.8rem;
|
|
margin-bottom: 2px;
|
|
text-transform: uppercase;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.ppr-field span {
|
|
font-size: 1rem;
|
|
color: #212529;
|
|
}
|
|
|
|
.status {
|
|
display: inline-block;
|
|
padding: 4px 8px;
|
|
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; }
|
|
|
|
.no-data {
|
|
text-align: center;
|
|
padding: 40px 20px;
|
|
color: #666;
|
|
}
|
|
|
|
.no-data i {
|
|
font-size: 3rem;
|
|
margin-bottom: 15px;
|
|
opacity: 0.3;
|
|
}
|
|
|
|
.last-updated {
|
|
text-align: center;
|
|
color: white;
|
|
opacity: 0.8;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.auto-refresh {
|
|
background: rgba(255,255,255,0.1);
|
|
color: white;
|
|
border: 1px solid rgba(255,255,255,0.2);
|
|
padding: 8px 16px;
|
|
border-radius: 20px;
|
|
font-size: 0.9rem;
|
|
margin-top: 10px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>✈️ Airfield PPR System</h1>
|
|
<p>Real-time Arrivals & Departures Board</p>
|
|
</div>
|
|
|
|
<div class="boards">
|
|
<!-- Arrivals Board -->
|
|
<div class="board">
|
|
<div class="board-header">
|
|
<h2>🛬 Today's Arrivals</h2>
|
|
<div id="arrivals-count">Loading...</div>
|
|
</div>
|
|
<div class="board-content">
|
|
<div id="arrivals-loading" class="loading">
|
|
<div class="spinner"></div>
|
|
Loading arrivals...
|
|
</div>
|
|
<div id="arrivals-list" class="ppr-list" style="display: none;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Departures Board -->
|
|
<div class="board">
|
|
<div class="board-header departures">
|
|
<h2>🛫 Today's Departures</h2>
|
|
<div id="departures-count">Loading...</div>
|
|
</div>
|
|
<div class="board-content">
|
|
<div id="departures-loading" class="loading">
|
|
<div class="spinner"></div>
|
|
Loading departures...
|
|
</div>
|
|
<div id="departures-list" class="ppr-list" style="display: none;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="last-updated">
|
|
<div>Last updated: <span id="last-updated">Never</span></div>
|
|
<div class="auto-refresh">🔄 Auto-refresh every 30 seconds</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let refreshInterval;
|
|
|
|
// Format datetime for display
|
|
function formatDateTime(dateStr) {
|
|
if (!dateStr) return 'N/A';
|
|
const date = new Date(dateStr);
|
|
return date.toLocaleTimeString('en-GB', {
|
|
hour: '2-digit',
|
|
minute: '2-digit'
|
|
});
|
|
}
|
|
|
|
// Format status for display
|
|
function formatStatus(status) {
|
|
return `<span class="status ${status.toLowerCase()}">${status}</span>`;
|
|
}
|
|
|
|
// Create PPR item HTML
|
|
function createPPRItem(ppr) {
|
|
return `
|
|
<div class="ppr-item">
|
|
<div class="ppr-field">
|
|
<strong>Aircraft</strong>
|
|
<span>${ppr.ac_reg}</span>
|
|
</div>
|
|
<div class="ppr-field">
|
|
<strong>Type</strong>
|
|
<span>${ppr.ac_type}</span>
|
|
</div>
|
|
<div class="ppr-field">
|
|
<strong>Time</strong>
|
|
<span>${formatDateTime(ppr.eta || ppr.etd)}</span>
|
|
</div>
|
|
<div class="ppr-field">
|
|
<strong>Status</strong>
|
|
<span>${formatStatus(ppr.status)}</span>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// Create no data message
|
|
function createNoDataMessage(type) {
|
|
return `
|
|
<div class="no-data">
|
|
<div style="font-size: 3rem; margin-bottom: 15px; opacity: 0.3;">
|
|
${type === 'arrivals' ? '🛬' : '🛫'}
|
|
</div>
|
|
<div>No ${type} scheduled for today</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// Fetch and display arrivals
|
|
async function loadArrivals() {
|
|
try {
|
|
const response = await fetch('/api/v1/public/arrivals');
|
|
const arrivals = await response.json();
|
|
|
|
const loadingEl = document.getElementById('arrivals-loading');
|
|
const listEl = document.getElementById('arrivals-list');
|
|
const countEl = document.getElementById('arrivals-count');
|
|
|
|
loadingEl.style.display = 'none';
|
|
listEl.style.display = 'block';
|
|
|
|
if (arrivals.length === 0) {
|
|
listEl.innerHTML = createNoDataMessage('arrivals');
|
|
countEl.textContent = '0 flights';
|
|
} else {
|
|
listEl.innerHTML = arrivals.map(createPPRItem).join('');
|
|
countEl.textContent = `${arrivals.length} flight${arrivals.length !== 1 ? 's' : ''}`;
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading arrivals:', error);
|
|
document.getElementById('arrivals-list').innerHTML = `
|
|
<div class="no-data">
|
|
<div style="color: #dc3545;">❌ Error loading arrivals</div>
|
|
</div>
|
|
`;
|
|
document.getElementById('arrivals-loading').style.display = 'none';
|
|
document.getElementById('arrivals-list').style.display = 'block';
|
|
}
|
|
}
|
|
|
|
// Fetch and display departures
|
|
async function loadDepartures() {
|
|
try {
|
|
const response = await fetch('/api/v1/public/departures');
|
|
const departures = await response.json();
|
|
|
|
const loadingEl = document.getElementById('departures-loading');
|
|
const listEl = document.getElementById('departures-list');
|
|
const countEl = document.getElementById('departures-count');
|
|
|
|
loadingEl.style.display = 'none';
|
|
listEl.style.display = 'block';
|
|
|
|
if (departures.length === 0) {
|
|
listEl.innerHTML = createNoDataMessage('departures');
|
|
countEl.textContent = '0 flights';
|
|
} else {
|
|
listEl.innerHTML = departures.map(createPPRItem).join('');
|
|
countEl.textContent = `${departures.length} flight${departures.length !== 1 ? 's' : ''}`;
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading departures:', error);
|
|
document.getElementById('departures-list').innerHTML = `
|
|
<div class="no-data">
|
|
<div style="color: #dc3545;">❌ Error loading departures</div>
|
|
</div>
|
|
`;
|
|
document.getElementById('departures-loading').style.display = 'none';
|
|
document.getElementById('departures-list').style.display = 'block';
|
|
}
|
|
}
|
|
|
|
// Load both arrivals and departures
|
|
async function loadData() {
|
|
await Promise.all([loadArrivals(), loadDepartures()]);
|
|
document.getElementById('last-updated').textContent = new Date().toLocaleTimeString('en-GB');
|
|
}
|
|
|
|
// Initialize the page
|
|
async function init() {
|
|
await loadData();
|
|
|
|
// Set up auto-refresh every 30 seconds
|
|
refreshInterval = setInterval(loadData, 30000);
|
|
}
|
|
|
|
// Start the application
|
|
init();
|
|
|
|
// Handle page visibility change to pause/resume refresh
|
|
document.addEventListener('visibilitychange', function() {
|
|
if (document.visibilityState === 'visible') {
|
|
if (!refreshInterval) {
|
|
loadData();
|
|
refreshInterval = setInterval(loadData, 30000);
|
|
}
|
|
} else {
|
|
if (refreshInterval) {
|
|
clearInterval(refreshInterval);
|
|
refreshInterval = null;
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |