List circuits
This commit is contained in:
@@ -509,6 +509,14 @@
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Circuits Section (for CIRCUITS flights only) -->
|
||||
<div id="circuits-section" style="display: none; margin-top: 2rem; border-top: 1px solid #ddd; padding-top: 1rem;">
|
||||
<h3>✈️ Touch & Go Records</h3>
|
||||
<div id="circuits-list" style="margin-top: 1rem;">
|
||||
<p style="color: #666; font-style: italic;">Loading circuits...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 = '<p style="color: #d32f2f;">Error loading circuits</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function displayCircuitsList(circuits) {
|
||||
const circuitsList = document.getElementById('circuits-list');
|
||||
|
||||
if (circuits.length === 0) {
|
||||
circuitsList.innerHTML = '<p style="color: #666; font-style: italic;">No touch & go records yet</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `<p style="color: #333; font-weight: bold;">Total circuits: ${circuits.length}</p>`;
|
||||
html += '<div style="background-color: #f5f5f5; border-radius: 4px; padding: 1rem; margin-top: 0.5rem;">';
|
||||
|
||||
circuits.forEach((circuit, index) => {
|
||||
const time = formatTimeOnly(circuit.circuit_timestamp);
|
||||
html += `<div style="padding: 0.5rem 0; border-bottom: 1px solid #ddd;">Circuit ${index + 1}: <strong>${time}</strong></div>`;
|
||||
});
|
||||
|
||||
html += '</div>';
|
||||
circuitsList.innerHTML = html;
|
||||
}
|
||||
|
||||
function closeLocalFlightEditModal() {
|
||||
document.getElementById('localFlightEditModal').style.display = 'none';
|
||||
currentLocalFlightId = null;
|
||||
|
||||
Reference in New Issue
Block a user