From d53ddff4bec2669ab21a7f5cc9104ce6c6f70182 Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Wed, 17 Dec 2025 04:20:12 -0500 Subject: [PATCH] List circuits --- web/admin.html | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/web/admin.html b/web/admin.html index b01e83d..4c16c37 100644 --- a/web/admin.html +++ b/web/admin.html @@ -509,6 +509,14 @@ + + + @@ -3266,6 +3274,16 @@ cancelBtn.style.display = (flight.status === 'BOOKED_OUT' || flight.status === 'DEPARTED') ? 'inline-block' : 'none'; document.getElementById('local-flight-edit-title').textContent = `${flight.registration} - ${flight.flight_type}`; + + // Load and display circuits if this is a CIRCUITS flight + const circuitsSection = document.getElementById('circuits-section'); + if (flight.flight_type === 'CIRCUITS') { + circuitsSection.style.display = 'block'; + loadCircuitsDisplay(flight.id); + } else { + circuitsSection.style.display = 'none'; + } + document.getElementById('localFlightEditModal').style.display = 'block'; } catch (error) { console.error('Error loading flight:', error); @@ -3273,6 +3291,39 @@ } } + async function loadCircuitsDisplay(localFlightId) { + try { + const response = await authenticatedFetch(`/api/v1/circuits/flight/${localFlightId}`); + if (!response.ok) throw new Error('Failed to load circuits'); + + const circuits = await response.json(); + displayCircuitsList(circuits); + } catch (error) { + console.error('Error loading circuits:', error); + document.getElementById('circuits-list').innerHTML = '

Error loading circuits

'; + } + } + + function displayCircuitsList(circuits) { + const circuitsList = document.getElementById('circuits-list'); + + if (circuits.length === 0) { + circuitsList.innerHTML = '

No touch & go records yet

'; + return; + } + + let html = `

Total circuits: ${circuits.length}

`; + html += '
'; + + circuits.forEach((circuit, index) => { + const time = formatTimeOnly(circuit.circuit_timestamp); + html += `
Circuit ${index + 1}: ${time}
`; + }); + + html += '
'; + circuitsList.innerHTML = html; + } + function closeLocalFlightEditModal() { document.getElementById('localFlightEditModal').style.display = 'none'; currentLocalFlightId = null;