356 lines
11 KiB
HTML
356 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="refresh" content="300">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Swansea Airport - Arrivals & Departures</title>
|
|
<style>
|
|
/* Overall page styling */
|
|
body {
|
|
margin: 0;
|
|
font-family: Arial, sans-serif;
|
|
display: grid;
|
|
grid-template-rows: auto 1fr auto;
|
|
grid-template-columns: 1fr;
|
|
height: 100vh;
|
|
font-size: 30px; /* Increased font size */
|
|
}
|
|
|
|
/* Header styles */
|
|
header {
|
|
background-color: #333;
|
|
color: white;
|
|
padding: 20px;
|
|
text-align: center;
|
|
position: relative;
|
|
}
|
|
|
|
header img.left-image {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
height: auto;
|
|
}
|
|
|
|
header img.right-image {
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
width: 9%;
|
|
height: auto;
|
|
}
|
|
|
|
/* Main section styles */
|
|
main {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr; /* Two equal-width columns */
|
|
gap: 20px;
|
|
padding: 20px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* Table styles */
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin: 0;
|
|
border: 1px solid #ccc;
|
|
}
|
|
|
|
th, td {
|
|
padding: 12px;
|
|
text-align: left;
|
|
border: 1px solid #ccc;
|
|
}
|
|
|
|
th {
|
|
background-color: #f4f4f4;
|
|
}
|
|
|
|
tr:nth-child(even) {
|
|
background-color: #d3d3d3;
|
|
}
|
|
|
|
/* Footer styles */
|
|
footer {
|
|
background-color: #333;
|
|
color: white;
|
|
text-align: center;
|
|
padding: 10px 0;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* Marquee container */
|
|
.marquee {
|
|
display: inline-block;
|
|
white-space: nowrap;
|
|
padding-right: 100%; /* This makes the text start out of view */
|
|
animation: scroll-left 20s linear infinite;
|
|
}
|
|
|
|
/* Keyframes for scrolling animation */
|
|
@keyframes scroll-left {
|
|
from {
|
|
transform: translateX(100%);
|
|
}
|
|
to {
|
|
transform: translateX(-100%);
|
|
}
|
|
}
|
|
|
|
/* Marquee text styling */
|
|
.marquee-text {
|
|
font-size: 18px;
|
|
font-weight: bold;
|
|
color: #f4f4f4;
|
|
padding-left: 50px;
|
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
/* Loading indicator */
|
|
.loading {
|
|
text-align: center;
|
|
padding: 20px;
|
|
color: #666;
|
|
}
|
|
|
|
/* Error message */
|
|
.error {
|
|
text-align: center;
|
|
padding: 20px;
|
|
color: #e74c3c;
|
|
}
|
|
|
|
/* Responsive adjustments */
|
|
@media (max-width: 768px) {
|
|
main {
|
|
grid-template-columns: 1fr; /* Stack columns on smaller screens */
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<img src="assets/logo.png" alt="EGFH Logo" class="left-image">
|
|
<h1>Arrivals/Departures Information</h1>
|
|
<img src="assets/flightImg.png" alt="EGFH Logo" class="right-image">
|
|
</header>
|
|
|
|
<main>
|
|
<!-- Left column with arrivals table -->
|
|
<div>
|
|
<h2><center>Arrivals</center></h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Registration</th>
|
|
<th>Aircraft Type</th>
|
|
<th>From</th>
|
|
<th>Due</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="arrivals-tbody">
|
|
<tr>
|
|
<td colspan="4" class="loading">Loading arrivals...</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Right column with departures table -->
|
|
<div>
|
|
<h2><center>Departures</center></h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Registration</th>
|
|
<th>Aircraft Type</th>
|
|
<th>To</th>
|
|
<th>Due</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="departures-tbody">
|
|
<tr>
|
|
<td colspan="4" class="loading">Loading departures...</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
<!-- Footer content -->
|
|
<div class="iso-marquee-linkwrap">
|
|
<div class="iso-marquee--long iso-marquee">
|
|
<!-- Add marquee content here -->
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
<script>
|
|
let wsConnection = null;
|
|
|
|
// WebSocket connection for real-time updates
|
|
function connectWebSocket() {
|
|
if (wsConnection && wsConnection.readyState === WebSocket.OPEN) {
|
|
return; // Already connected
|
|
}
|
|
|
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
const wsUrl = `${protocol}//${window.location.host}/ws/tower-updates`;
|
|
|
|
wsConnection = new WebSocket(wsUrl);
|
|
|
|
wsConnection.onopen = function(event) {
|
|
console.log('WebSocket connected for real-time updates');
|
|
};
|
|
|
|
wsConnection.onmessage = function(event) {
|
|
try {
|
|
const data = JSON.parse(event.data);
|
|
console.log('WebSocket message received:', data);
|
|
|
|
// Refresh display when any PPR-related event occurs
|
|
if (data.type && (data.type.includes('ppr_') || data.type === 'status_update')) {
|
|
console.log('PPR update detected, refreshing display...');
|
|
loadArrivals();
|
|
loadDepartures();
|
|
}
|
|
} catch (error) {
|
|
console.error('Error parsing WebSocket message:', error);
|
|
}
|
|
};
|
|
|
|
wsConnection.onclose = function(event) {
|
|
console.log('WebSocket disconnected');
|
|
// Attempt to reconnect after 5 seconds
|
|
setTimeout(() => {
|
|
console.log('Attempting to reconnect WebSocket...');
|
|
connectWebSocket();
|
|
}, 5000);
|
|
};
|
|
|
|
wsConnection.onerror = function(error) {
|
|
console.error('WebSocket error:', error);
|
|
};
|
|
}
|
|
|
|
// Convert UTC time to local time (Europe/London)
|
|
function convertToLocalTime(utcTimeString) {
|
|
if (!utcTimeString) return '';
|
|
|
|
// Parse the time string (format: HH:MM or HH:MM:SS)
|
|
const timeParts = utcTimeString.split(':');
|
|
if (timeParts.length < 2) return utcTimeString;
|
|
|
|
// Create a date object with today's date and the UTC time
|
|
const now = new Date();
|
|
const utcDate = new Date(Date.UTC(
|
|
now.getUTCFullYear(),
|
|
now.getUTCMonth(),
|
|
now.getUTCDate(),
|
|
parseInt(timeParts[0]),
|
|
parseInt(timeParts[1]),
|
|
timeParts.length > 2 ? parseInt(timeParts[2]) : 0
|
|
));
|
|
|
|
// Convert to local time
|
|
const localHours = utcDate.getHours().toString().padStart(2, '0');
|
|
const localMinutes = utcDate.getMinutes().toString().padStart(2, '0');
|
|
|
|
return `${localHours}:${localMinutes}`;
|
|
}
|
|
|
|
// Fetch and display arrivals
|
|
async function loadArrivals() {
|
|
const tbody = document.getElementById('arrivals-tbody');
|
|
|
|
try {
|
|
const response = await fetch('/api/v1/public/arrivals');
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch arrivals');
|
|
}
|
|
|
|
const arrivals = await response.json();
|
|
|
|
if (arrivals.length === 0) {
|
|
tbody.innerHTML = '<tr><td colspan="4">No arrivals found.</td></tr>';
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = arrivals.map(arrival => `
|
|
<tr>
|
|
<td>${escapeHtml(arrival.ac_reg || '')}</td>
|
|
<td>${escapeHtml(arrival.ac_type || '')}</td>
|
|
<td>${escapeHtml(arrival.in_from || '')}</td>
|
|
<td>${convertToLocalTime(arrival.eta)}</td>
|
|
</tr>
|
|
`).join('');
|
|
|
|
} catch (error) {
|
|
console.error('Error loading arrivals:', error);
|
|
tbody.innerHTML = '<tr><td colspan="4" class="error">Error loading arrivals</td></tr>';
|
|
}
|
|
}
|
|
|
|
// Fetch and display departures
|
|
async function loadDepartures() {
|
|
const tbody = document.getElementById('departures-tbody');
|
|
|
|
try {
|
|
const response = await fetch('/api/v1/public/departures');
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch departures');
|
|
}
|
|
|
|
const departures = await response.json();
|
|
|
|
if (departures.length === 0) {
|
|
tbody.innerHTML = '<tr><td colspan="4">No departures found.</td></tr>';
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = departures.map(departure => `
|
|
<tr>
|
|
<td>${escapeHtml(departure.ac_reg || '')}</td>
|
|
<td>${escapeHtml(departure.ac_type || '')}</td>
|
|
<td>${escapeHtml(departure.out_to || '')}</td>
|
|
<td>${convertToLocalTime(departure.etd)}</td>
|
|
</tr>
|
|
`).join('');
|
|
|
|
} catch (error) {
|
|
console.error('Error loading departures:', error);
|
|
tbody.innerHTML = '<tr><td colspan="4" class="error">Error loading departures</td></tr>';
|
|
}
|
|
}
|
|
|
|
// Escape HTML to prevent XSS
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text;
|
|
return div.innerHTML;
|
|
}
|
|
|
|
// Load data on page load
|
|
window.addEventListener('load', function() {
|
|
loadArrivals();
|
|
loadDepartures();
|
|
|
|
// Connect to WebSocket for real-time updates
|
|
connectWebSocket();
|
|
|
|
// Refresh data every 60 seconds as fallback
|
|
setInterval(() => {
|
|
loadArrivals();
|
|
loadDepartures();
|
|
}, 60000);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|