mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
AirTrail sync and export, GPS tracks, airport database with autocomplete
AirTrail (https://github.com/johanohly/AirTrail): - File export (Flights → Export for AirTrail) in AirTrail's import format, validated against its schema; same-day repeat legs get leg numbers so AirTrail's de-duplication doesn't merge them. - Automatic sync through AirTrail's REST API (Profile → AirTrail sync): per-user connection with an encrypted API key and scope check; flights are created/updated/deleted in background jobs; a full sync first links flights already in AirTrail (e.g. from a file import) instead of duplicating them; airports are resolved and cached, with manual mapping for unknown codes. - GPS tracks: GPX, KML and CSV track logs are converted to AirTrail's track format for both sync and export; the flight page shows a summary. - Aircraft ICAO type (e.g. C150) for AirTrail's aircraft type. Airport database (OurAirports, the source AirTrail uses): - Managed like AirTrail: downloaded in the background on first start, updated in place from Admin → Airports (adds, changes, removes; ids stable), with admin-managed custom airports that updates never touch. - Each airport carries AirTrail's code, so logged codes translate to AirTrail's exactly (1B9 → K1B9, 4MB → K5M3). - From/To autocomplete on new flights (airports this aircraft has used rank first); From is pre-filled with the last flight's destination; codes are normalized to uppercase. - Flights → Standardize airport codes: rewrite logged codes to the standard code, and fix codes not in the database (typos such as 0R8 → 08R are suggested). Also: admin pages grouped under an Admin dropdown menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c4803d717
commit
5bf682502b
68 files changed
+2667
-10
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<% content_for :title, "Airports" %>
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold">Airports</h1>
|
||||
<%= link_to "+ Custom Airport", new_admin_airport_path, class: "btn-primary" %>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<section class="card lg:col-span-2">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Airport database</h2>
|
||||
<% if @running %>
|
||||
<span class="badge-blue">Updating…</span>
|
||||
<% else %>
|
||||
<%= button_to "Update from OurAirports", refresh_admin_airports_path, class: "btn-secondary",
|
||||
form: { data: { turbo_confirm: "Download the latest airport data from OurAirports? Custom airports are kept." } } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-body space-y-3 text-sm">
|
||||
<div class="grid grid-cols-3 gap-3 text-center">
|
||||
<div><div class="text-2xl font-semibold"><%= number_with_delimiter(@total) %></div><div class="text-xs text-slate-500">airports</div></div>
|
||||
<div><div class="text-2xl font-semibold"><%= @custom.size %></div><div class="text-xs text-slate-500">custom</div></div>
|
||||
<div><div class="text-sm font-semibold"><%= @last_success ? "#{time_ago_in_words(@last_success.finished_at)} ago" : "never" %></div><div class="text-xs text-slate-500">last updated</div></div>
|
||||
</div>
|
||||
<% if @total.zero? %>
|
||||
<p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200">No airport data yet. It downloads automatically when the app starts. Use “Update from OurAirports” if that didn't happen.</p>
|
||||
<% end %>
|
||||
<p class="hint">Airport data comes from <a href="https://ourairports.com/data/" class="link" target="_blank" rel="noopener noreferrer">OurAirports</a> (public domain), the same source AirTrail uses. It's used for From/To autocomplete and to match airport codes when syncing to AirTrail. Updates add new airports, apply changes and remove closed-out entries; custom airports are never changed.</p>
|
||||
<% if @updates.any? %>
|
||||
<table class="table">
|
||||
<thead><tr><th>Started</th><th>By</th><th>Status</th><th>Result</th></tr></thead>
|
||||
<tbody>
|
||||
<% @updates.each do |u| %>
|
||||
<tr>
|
||||
<td class="whitespace-nowrap text-xs"><%= l(u.created_at, format: :short) %></td>
|
||||
<td class="text-xs"><%= u.requested_by&.display_name || "Startup" %></td>
|
||||
<td><%= tag.span u.status.capitalize, class: { "done" => "badge-green", "failed" => "badge-red" }.fetch(u.status, "badge-blue") %></td>
|
||||
<td class="text-xs"><%= u.done? ? u.summary : u.error %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<div class="card-header"><h2 class="card-title">Look up</h2></div>
|
||||
<div class="card-body space-y-2">
|
||||
<%= form_with url: admin_airports_path, method: :get, class: "flex gap-2" do |f| %>
|
||||
<%= f.search_field :q, value: @query, class: "input", placeholder: "Code or name" %>
|
||||
<%= f.submit "Search", class: "btn-secondary" %>
|
||||
<% end %>
|
||||
<% if @query.present? %>
|
||||
<% if @results.any? %>
|
||||
<ul class="divide-y divide-slate-100 text-sm">
|
||||
<% @results.each do |a| %>
|
||||
<li class="py-1.5"><span class="font-mono font-semibold"><%= a.code %></span> <%= a.name %>
|
||||
<div class="text-xs text-slate-500"><%= [a.place, "AirTrail #{a.airtrail_code}", (a.custom? ? "custom" : nil), Airport::KIND_LABELS[a.kind]].compact_blank.join(" · ") %></div></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p class="text-sm text-slate-600">No match for “<%= @query %>”. <%= link_to "Add it as a custom airport", new_admin_airport_path(ident: @query.upcase), class: "link" %>.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="card mt-5">
|
||||
<div class="card-header"><h2 class="card-title">Custom airports</h2></div>
|
||||
<% if @custom.any? %>
|
||||
<table class="table">
|
||||
<thead><tr><th>Code</th><th>Name</th><th>Location</th><th>Type</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<% @custom.each do |a| %>
|
||||
<tr>
|
||||
<td class="font-mono font-semibold"><%= a.ident %></td><td><%= a.name %></td><td class="text-xs"><%= a.place %></td>
|
||||
<td class="text-xs"><%= a.kind.to_s.humanize %></td>
|
||||
<td class="text-right"><%= link_to "Edit", edit_admin_airport_path(a), class: "btn-secondary btn-sm" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<%= empty_state "None. Add private strips or fields that aren't in OurAirports." %>
|
||||
<% end %>
|
||||
</section>
|
||||
Reference in new issue
Block a user