<% content_for :title, "Airports" %>

Airports

<%= link_to "+ Custom Airport", new_admin_airport_path, class: "btn-primary" %>

Airport database

<% if @running %> Updating… <% 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 %>
<%= number_with_delimiter(@total) %>
airports
<%= @custom.size %>
custom
<%= @last_success ? "#{time_ago_in_words(@last_success.finished_at)} ago" : "never" %>
last updated
<% if @total.zero? %>

No airport data yet. It downloads automatically when the app starts. Use “Update from OurAirports” if that didn't happen.

<% end %>

Airport data comes from OurAirports (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.

<% if @updates.any? %> <% @updates.each do |u| %> <% end %>
StartedByStatusResult
<%= fmt_time(u.created_at) %> <%= u.requested_by&.display_name || "Startup" %> <%= tag.span u.status.capitalize, class: { "done" => "badge-green", "failed" => "badge-red" }.fetch(u.status, "badge-blue") %> <%= u.done? ? u.summary : u.error %>
<% end %>

Look up

<%= 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? %>
    <% @results.each do |a| %>
  • <%= a.code %> <%= a.name %>
    <%= [a.place, "AirTrail #{a.airtrail_code}", (a.custom? ? "custom" : nil), Airport::KIND_LABELS[a.kind]].compact_blank.join(" · ") %>
  • <% end %>
<% else %>

No match for “<%= @query %>”. <%= link_to "Add it as a custom airport", new_admin_airport_path(ident: @query.upcase), class: "link" %>.

<% end %> <% end %>

Custom airports

<% if @custom.any? %> <% @custom.each do |a| %> <% end %>
CodeNameLocationType
<%= a.ident %><%= a.name %><%= a.place %> <%= a.kind.to_s.humanize %> <%= link_to "Edit", edit_admin_airport_path(a), class: "btn-secondary btn-sm" %>
<% else %> <%= empty_state "None. Add private strips or fields that aren't in OurAirports." %> <% end %>