mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Move all user-facing text into config/locales/en.yml for localization
- Views use lazy t(".key") lookups; sentences with values or links stay
whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
from labels: in the current locale; field names and validation messages
under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
templates, records package README and transcription warnings localized;
the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
follows the locale
- APP_LOCALE picks the language (falls back to English); missing
translations raise in development and tests
- README: Translating section and APP_LOCALE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f45b557c2
commit
89ed0a76f9
313 files changed
+6387
-2653
No files matched your search
@@ -7,30 +7,30 @@
|
||||
<% days.each do |day| %>
|
||||
<details class="group flight-day border-b border-slate-100">
|
||||
<summary class="flex cursor-pointer list-none flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-slate-50 sm:grid sm:grid-cols-[9.5rem_1fr_repeat(4,5rem)_1.25rem] [&::-webkit-details-marker]:hidden">
|
||||
<span class="font-medium whitespace-nowrap"><%= day.date.strftime("%a %b %-d, %Y") %><span class="block text-xs font-normal text-slate-500"><%= pluralize(day.flights.size, "flight") %></span></span>
|
||||
<span class="font-medium whitespace-nowrap"><%= l(day.date, format: :weekday) %><span class="block text-xs font-normal text-slate-500"><%= t("counts.flight", count: day.flights.size) %></span></span>
|
||||
<span class="min-w-0 basis-full sm:basis-auto">
|
||||
<%= day.route.presence || blank %>
|
||||
<% if day.track_log? %><span class="ml-1" role="img" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
|
||||
<% if day.engine_data? %><span class="ml-1" role="img" title="Engine data attached" aria-label="Engine data attached">📈</span><% end %>
|
||||
<% if day.track_log? %><span class="ml-1" role="img" title="<%= t(".gps_track_attached") %>" aria-label="<%= t(".gps_track_attached") %>">📍</span><% end %>
|
||||
<% if day.engine_data? %><span class="ml-1" role="img" title="<%= t(".engine_data_attached") %>" aria-label="<%= t(".engine_data_attached") %>">📈</span><% end %>
|
||||
<% if day.pilots.any? %><span class="block text-xs text-slate-500"><%= day.pilots.to_sentence %></span><% end %>
|
||||
</span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Tach </span><%= day.tach_time ? hours(day.tach_time) : blank %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Hobbs </span><%= day.hobbs_time ? hours(day.hobbs_time) : blank %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Fuel </span><%= qty.(day.fuel_added) %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Oil </span><%= qty.(day.oil_added) %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".tach") %> </span><%= day.tach_time ? hours(day.tach_time) : blank %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".hobbs") %> </span><%= day.hobbs_time ? hours(day.hobbs_time) : blank %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".fuel") %> </span><%= qty.(day.fuel_added) %></span>
|
||||
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".oil") %> </span><%= qty.(day.oil_added) %></span>
|
||||
<span aria-hidden="true" class="ml-auto text-slate-400 transition group-open:rotate-90">›</span>
|
||||
</summary>
|
||||
<div class="overflow-x-auto bg-slate-50/60 px-2 pb-3 sm:px-4">
|
||||
<table class="table">
|
||||
<thead><tr><th>Leg</th><th>Route</th><th class="text-right">Tach</th><th class="text-right">Hobbs</th><th class="text-right">Fuel (gal)</th><th class="text-right">Oil (qt)</th><th class="pl-6">Pilot</th></tr></thead>
|
||||
<thead><tr><th><%= t(".leg") %></th><th><%= t(".route") %></th><th class="text-right"><%= t(".tach") %></th><th class="text-right"><%= t(".hobbs") %></th><th class="text-right"><%= t(".fuel_gal") %></th><th class="text-right"><%= t(".oil_qt") %></th><th class="pl-6"><%= t(".pilot") %></th></tr></thead>
|
||||
<tbody>
|
||||
<% day.flights.each_with_index do |fl, i| %>
|
||||
<tr>
|
||||
<td class="whitespace-nowrap" data-label=""><%= link_to "Leg #{i + 1}", aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
|
||||
<td class="whitespace-nowrap" data-label=""><%= link_to t(".leg_2", i: i + 1), aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
|
||||
<td class="whitespace-nowrap" data-label="Route">
|
||||
<%= fl.route_summary.presence || blank %>
|
||||
<% if fl.track_log.attached? %><span class="ml-1" role="img" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
|
||||
<% if fl.engine_data.attached? %><span class="ml-1" role="img" title="Engine data attached" aria-label="Engine data attached">📈</span><% end %>
|
||||
<% if fl.track_log.attached? %><span class="ml-1" role="img" title="<%= t(".gps_track_attached") %>" aria-label="<%= t(".gps_track_attached") %>">📍</span><% end %>
|
||||
<% if fl.engine_data.attached? %><span class="ml-1" role="img" title="<%= t(".engine_data_attached") %>" aria-label="<%= t(".engine_data_attached") %>">📈</span><% end %>
|
||||
</td>
|
||||
<td class="text-right tabular-nums" data-label="Tach"><%= fl.tach_time ? hours(fl.tach_time) : blank %></td>
|
||||
<td class="text-right tabular-nums" data-label="Hobbs"><%= fl.hobbs_time ? hours(fl.hobbs_time) : blank %></td>
|
||||
@@ -47,7 +47,7 @@
|
||||
<% if more %>
|
||||
<%= turbo_frame_tag "flight-days-#{page + 1}", src: aircraft_flight_logs_path(@aircraft, page: page + 1), loading: :lazy, target: "_top", class: "block" do %>
|
||||
<p class="px-4 py-4 text-center text-sm text-slate-500">
|
||||
Loading earlier flights… <%= link_to "Load more", aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" } %>
|
||||
<%= t(".loading_earlier_flights_html", link: (link_to t(".load_more"), aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" })) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<%# Engine monitor recording: summary and charts. Locals: flight_log, recording, error %>
|
||||
<section class="card max-w-5xl" id="engine-data">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Engine data</h2>
|
||||
<h2 class="card-title"><%= t(".engine_data") %></h2>
|
||||
<% if flight_log.engine_data.attached? %>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<%= link_to flight_log.engine_data.filename, rails_blob_path(flight_log.engine_data, disposition: :attachment), class: "link" %>
|
||||
<% if manage_engine_data? %><%= delete_button "Remove", engine_data_aircraft_flight_log_path(@aircraft, flight_log), confirm: "Remove the engine data file from this flight?" %><% end %>
|
||||
<% if manage_engine_data? %><%= delete_button t(".remove"), engine_data_aircraft_flight_log_path(@aircraft, flight_log), confirm: t(".remove_the_engine_data_file") %><% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -15,33 +15,33 @@
|
||||
<% egt, cht = recording.hottest(:egt), recording.hottest(:cht) %>
|
||||
<% tail = recording.metadata[:aircraft_id] %>
|
||||
<% if tail.present? && tail.upcase != @aircraft.tail_number.to_s.upcase %>
|
||||
<p class="border-b border-slate-100 bg-amber-50 px-4 py-2 text-xs text-amber-800">This recording is from <strong><%= tail %></strong>, not <%= @aircraft.tail_number %>.</p>
|
||||
<p class="border-b border-slate-100 bg-amber-50 px-4 py-2 text-xs text-amber-800"><%= t(".this_recording_is_from_not_html", tail: tail, tail_number: @aircraft.tail_number) %></p>
|
||||
<% end %>
|
||||
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
|
||||
<dt class="text-slate-500">Recorded</dt>
|
||||
<dd class="col-span-3"><%= recording.local(recording.started_at).strftime("%Y-%m-%d %H:%M") %>–<%= recording.local(recording.ended_at).strftime("%H:%M") %> monitor time
|
||||
<span class="text-xs text-slate-500">· <%= recording.format %><%= " flight ##{recording.metadata[:flight_number]}" if recording.metadata[:flight_number] %> · <%= number_with_delimiter(recording.samples) %> samples</span></dd>
|
||||
<dt class="text-slate-500">Engine run</dt><dd><%= recording.engine_start ? run_duration(recording.run_time) : "Engine not run" %></dd>
|
||||
<dt class="text-slate-500">Fuel burned</dt><dd><%= engine_value(recording.fuel_burned, "gal", precision: 1) %></dd>
|
||||
<dt class="text-slate-500">Tach</dt><dd class="tabular-nums"><%= hours_line.(:tach, 2) %></dd>
|
||||
<dt class="text-slate-500">Engine hrs</dt><dd class="tabular-nums"><%= hours_line.(:engine_hours, 2) %></dd>
|
||||
<% if (flt = recording.last(:flight_hours)) %><dt class="text-slate-500">Airborne</dt><dd><%= flt.zero? ? "No (ground run)" : "#{number_with_precision(flt, precision: 2)} hrs" %></dd><% end %>
|
||||
<dt class="text-slate-500"><%= t(".recorded") %></dt>
|
||||
<dd class="col-span-3"><%= t(".monitor_time_html", start: (recording.local(recording.started_at).strftime("%Y-%m-%d %H:%M")), end: (recording.local(recording.ended_at).strftime("%H:%M"))) %>
|
||||
<span class="text-xs text-slate-500"><%= t(".samples_html", file_format: recording.format, flight_number: (" flight ##{recording.metadata[:flight_number]}" if recording.metadata[:flight_number]), samples: (number_with_delimiter(recording.samples))) %></span></dd>
|
||||
<dt class="text-slate-500"><%= t(".engine_run") %></dt><dd><%= recording.engine_start ? run_duration(recording.run_time) : t(".engine_not_run") %></dd>
|
||||
<dt class="text-slate-500"><%= t(".fuel_burned") %></dt><dd><%= engine_value(recording.fuel_burned, "gal", precision: 1) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".tach") %></dt><dd class="tabular-nums"><%= hours_line.(:tach, 2) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".engine_hrs") %></dt><dd class="tabular-nums"><%= hours_line.(:engine_hours, 2) %></dd>
|
||||
<% if (flt = recording.last(:flight_hours)) %><dt class="text-slate-500"><%= t(".airborne") %></dt><dd><%= flt.zero? ? t(".no_ground_run") : "#{number_with_precision(flt, precision: 2)} hrs" %></dd><% end %>
|
||||
</dl>
|
||||
|
||||
<div class="overflow-x-auto border-t border-slate-100">
|
||||
<table class="table">
|
||||
<thead><tr><th>Peak (engine running)</th><th class="text-right">Value</th><th class="text-right">At</th></tr></thead>
|
||||
<thead><tr><th><%= t(".peak_engine_running") %></th><th class="text-right"><%= t(".value") %></th><th class="text-right"><%= t(".at") %></th></tr></thead>
|
||||
<tbody>
|
||||
<% peaks = [
|
||||
[ "RPM", recording.max(:rpm), "rpm" ],
|
||||
[ "Manifold pressure", recording.max(:map), "inHg", 1 ],
|
||||
[ (egt ? "EGT (cyl #{egt[:cylinder]})" : "EGT"), egt && [ egt[:value], egt[:at] ], "°F" ],
|
||||
[ (cht ? "CHT (cyl #{cht[:cylinder]})" : "CHT"), cht && [ cht[:value], cht[:at] ], "°F" ],
|
||||
[ t(".manifold_pressure"), recording.max(:map), "inHg", 1 ],
|
||||
[ (egt ? t(".egt_cyl", cylinder: (egt[:cylinder])) : "EGT"), egt && [ egt[:value], egt[:at] ], "°F" ],
|
||||
[ (cht ? t(".cht_cyl", cylinder: (cht[:cylinder])) : "CHT"), cht && [ cht[:value], cht[:at] ], "°F" ],
|
||||
[ "TIT", recording.max(:tit), "°F" ],
|
||||
[ "Oil temp", recording.max(:oil_t), "°F" ],
|
||||
[ "Oil pressure", recording.max(:oil_p), "psi" ],
|
||||
[ "Fuel flow", recording.max(:fuel_flow), "gph", 1 ],
|
||||
[ "Volts (low)", recording.min(:volts), "V", 1 ]
|
||||
[ t(".oil_temp"), recording.max(:oil_t), "°F" ],
|
||||
[ t(".oil_pressure"), recording.max(:oil_p), "psi" ],
|
||||
[ t(".fuel_flow"), recording.max(:fuel_flow), "gph", 1 ],
|
||||
[ t(".volts_low"), recording.min(:volts), "V", 1 ]
|
||||
].select { _2 } %>
|
||||
<% peaks.each do |label, (value, at), unit, places| %>
|
||||
<tr><td><%= label %></td><td class="text-right tabular-nums"><%= engine_value(value, unit, precision: places || 0) %></td>
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<div data-controller="engine-chart" data-engine-chart-url-value="<%= engine_data_aircraft_flight_log_path(@aircraft, flight_log, format: :json) %>"
|
||||
class="border-t border-slate-100">
|
||||
<p class="px-4 pt-3 text-xs text-slate-500">Click a chart to explore it: zoom into any part of the flight and read exact values.</p>
|
||||
<p class="px-4 pt-3 text-xs text-slate-500"><%= t(".click_a_chart_to_explore") %></p>
|
||||
<div class="grid gap-6 p-4 lg:grid-cols-2">
|
||||
<% engine_chart_groups(recording).each_with_index do |group, i| %>
|
||||
<% chart = engine_chart(recording, *group[:keys], ytitle: group[:unit], colors: group[:colors].many? ? group[:colors] : nil) %>
|
||||
@@ -64,39 +64,39 @@
|
||||
data-engine-chart-group-param="<%= i %>">
|
||||
<figcaption class="mb-1 flex items-center justify-between text-xs font-semibold text-slate-600">
|
||||
<%= group[:title] %>
|
||||
<span class="font-normal text-slate-400 group-hover:text-sky-700" aria-hidden="true">⤢ Explore</span>
|
||||
<span class="font-normal text-slate-400 group-hover:text-sky-700" aria-hidden="true"><%= t(".explore") %></span>
|
||||
</figcaption>
|
||||
<%= chart %>
|
||||
</figure>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<dialog data-engine-chart-target="dialog" aria-label="Engine data viewer"
|
||||
<dialog data-engine-chart-target="dialog" aria-label="<%= t(".engine_data_viewer") %>"
|
||||
class="m-auto h-dvh max-h-none w-screen max-w-none bg-surface p-0 text-slate-800 shadow-2xl backdrop:bg-black/60 sm:h-[min(52rem,94dvh)] sm:w-[min(80rem,96vw)] sm:rounded-lg"
|
||||
data-action="keydown->engine-chart#keydown close->engine-chart#closed">
|
||||
<div class="flex h-full flex-col">
|
||||
<div class="flex items-center gap-2 border-b border-slate-200 px-3 py-2">
|
||||
<div data-engine-chart-target="tabs" role="tablist" class="flex min-w-0 flex-1 gap-1 overflow-x-auto"></div>
|
||||
<button type="button" data-action="engine-chart#close" class="rounded px-2 py-1 text-lg leading-none text-slate-500 hover:bg-slate-100" aria-label="Close">✕</button>
|
||||
<button type="button" data-action="engine-chart#close" class="rounded px-2 py-1 text-lg leading-none text-slate-500 hover:bg-slate-100" aria-label="<%= t(".close") %>">✕</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2 px-4 py-2 text-xs text-slate-500">
|
||||
<span data-engine-chart-target="range" class="tabular-nums"></span>
|
||||
<span class="hidden sm:inline">· Drag across the chart to zoom in, double-click to reset.</span>
|
||||
<span class="sm:hidden">· Drag to zoom.</span>
|
||||
<span class="hidden sm:inline"><%= t(".drag_across_the_chart_to") %></span>
|
||||
<span class="sm:hidden"><%= t(".drag_to_zoom") %></span>
|
||||
<span class="ml-auto flex gap-2">
|
||||
<button type="button" data-engine-chart-target="zoomOut" data-action="engine-chart#zoomOut" class="btn-secondary btn-sm" disabled>Zoom out</button>
|
||||
<button type="button" data-engine-chart-target="reset" data-action="engine-chart#resetZoom" class="btn-secondary btn-sm" disabled>Reset zoom</button>
|
||||
<button type="button" data-engine-chart-target="zoomOut" data-action="engine-chart#zoomOut" class="btn-secondary btn-sm" disabled><%= t(".zoom_out") %></button>
|
||||
<button type="button" data-engine-chart-target="reset" data-action="engine-chart#resetZoom" class="btn-secondary btn-sm" disabled><%= t(".reset_zoom") %></button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="relative min-h-0 flex-1 touch-none select-none px-2 sm:px-4" data-engine-chart-target="frame"
|
||||
data-action="pointerdown->engine-chart#dragStart pointermove->engine-chart#dragMove pointerup->engine-chart#dragEnd pointercancel->engine-chart#dragCancel dblclick->engine-chart#resetZoom">
|
||||
<canvas data-engine-chart-target="canvas"></canvas>
|
||||
<div data-engine-chart-target="selection" hidden class="pointer-events-none absolute border-x border-sky-500 bg-sky-500/15"></div>
|
||||
<p data-engine-chart-target="status" class="absolute inset-0 grid place-items-center text-sm text-slate-500">Loading…</p>
|
||||
<p data-engine-chart-target="status" class="absolute inset-0 grid place-items-center text-sm text-slate-500"><%= t(".loading") %></p>
|
||||
</div>
|
||||
<div class="max-h-[30%] overflow-auto border-t border-slate-200">
|
||||
<table class="table text-sm">
|
||||
<thead><tr><th>Series <span class="font-normal normal-case text-slate-500">(visible range)</span></th><th class="text-right">Min</th><th class="text-right">Avg</th><th class="text-right">Max</th></tr></thead>
|
||||
<thead><tr><th><%= t(".series") %> <span class="font-normal normal-case text-slate-500"><%= t(".visible_range") %></span></th><th class="text-right"><%= t(".min") %></th><th class="text-right"><%= t(".avg") %></th><th class="text-right"><%= t(".max") %></th></tr></thead>
|
||||
<tbody data-engine-chart-target="stats"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -109,10 +109,10 @@
|
||||
|
||||
<% if manage_engine_data? && !flight_log.engine_data.attached? %>
|
||||
<%= form_with model: flight_log, url: engine_data_aircraft_flight_log_path(@aircraft, flight_log), method: :patch, class: "card-body flex flex-wrap items-end gap-3" do |f| %>
|
||||
<%= f.field :engine_data, as: :file, label: "Attach engine monitor data", hint: "CGR-30P / CGR-30C flight recording (.csv).", accept: ".csv,text/csv" %>
|
||||
<%= f.submit "Upload", class: "btn-secondary" %>
|
||||
<%= f.field :engine_data, as: :file, label: t(".attach_engine_monitor_data"), hint: t(".cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
|
||||
<%= f.submit t(".upload"), class: "btn-secondary" %>
|
||||
<% end %>
|
||||
<% elsif !flight_log.engine_data.attached? %>
|
||||
<%= empty_state "No engine data for this flight." %>
|
||||
<%= empty_state t(".no_engine_data_for_this") %>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -1,39 +1,39 @@
|
||||
<%# Flying metrics. "Flight time" = Hobbs where recorded, else tach. %>
|
||||
<% periods = stats.periods %>
|
||||
<div class="mb-5 grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4">
|
||||
<% [ [ "Past 30 days", periods[0] ], [ "This year", periods[2] ], [ "Past 12 months", periods[1] ], [ "Since #{fmt_date(stats.first_date)}", periods[4] ] ].each do |title, p| %>
|
||||
<% [ [ t(".past_30_days"), periods[0] ], [ t(".this_year"), periods[2] ], [ t(".past_12_months"), periods[1] ], [ t(".since", first_date: (fmt_date(stats.first_date))), periods[4] ] ].each do |title, p| %>
|
||||
<section class="card p-3 sm:p-4">
|
||||
<div class="text-xs font-medium uppercase tracking-wide text-slate-500"><%= title %></div>
|
||||
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= hours(p.flight) %> <span class="text-sm font-normal text-slate-500">hrs</span></div>
|
||||
<div class="mt-1 text-xs text-slate-600"><%= pluralize(p.flights, "flight") %> · <%= hours(p.tach) %> tach · <%= number_with_delimiter(p.fuel) %> gal</div>
|
||||
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= hours(p.flight) %> <span class="text-sm font-normal text-slate-500"><%= t(".hrs") %></span></div>
|
||||
<div class="mt-1 text-xs text-slate-600"><%= t(".tach_gal_html", count: p.flights, tach: (hours(p.tach)), fuel: (number_with_delimiter(p.fuel))) %></div>
|
||||
</section>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 grid gap-5 lg:grid-cols-3">
|
||||
<section class="card lg:col-span-2">
|
||||
<div class="card-header"><h2 class="card-title">Flight hours by month</h2>
|
||||
<span class="text-xs text-slate-500">Avg <%= hours(stats.monthly_average_past_year) %> hrs/month over the past year</span></div>
|
||||
<div class="card-header"><h2 class="card-title"><%= t(".flight_hours_by_month") %></h2>
|
||||
<span class="text-xs text-slate-500"><%= t(".avg_hrs_month_over_the_html", monthly_average_past_year: (hours(stats.monthly_average_past_year))) %></span></div>
|
||||
<div class="card-body">
|
||||
<%= column_chart stats.flight_hours_by_month, height: "220px", colors: [ "#0369a1" ], ytitle: "hrs", library: { plugins: { legend: { display: false } } } %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<div class="card-header"><h2 class="card-title">Totals</h2></div>
|
||||
<div class="card-header"><h2 class="card-title"><%= t(".totals") %></h2></div>
|
||||
<dl class="card-body grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
|
||||
<dt class="text-slate-500">Flights logged</dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.count) %></dd>
|
||||
<dt class="text-slate-500">Flight time</dt><dd class="text-right tabular-nums"><%= hours(stats.total_flight) %> hrs</dd>
|
||||
<dt class="text-slate-500">Tach time</dt><dd class="text-right tabular-nums"><%= hours(stats.total_tach) %> hrs</dd>
|
||||
<dt class="text-slate-500">Average flight</dt><dd class="text-right tabular-nums"><%= hours(stats.average_flight) %> hrs</dd>
|
||||
<dt class="text-slate-500">Longest flight</dt><dd class="text-right tabular-nums"><%= hours(stats.longest_flight) %> hrs</dd>
|
||||
<dt class="text-slate-500">Fuel</dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.total_fuel) %> gal</dd>
|
||||
<dt class="text-slate-500">Fuel burn</dt><dd class="text-right tabular-nums"><%= stats.gph || "—" %> gal/hr</dd>
|
||||
<dt class="text-slate-500">Airports visited</dt><dd class="text-right tabular-nums"><%= stats.airports_visited %></dd>
|
||||
<dt class="text-slate-500"><%= t(".flights_logged") %></dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.count) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".flight_time") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_2_html", total_flight: (hours(stats.total_flight))) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".tach_time") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_3_html", total_tach: (hours(stats.total_tach))) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".average_flight") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_4_html", average_flight: (hours(stats.average_flight))) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".longest_flight") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_5_html", longest_flight: (hours(stats.longest_flight))) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".fuel") %></dt><dd class="text-right tabular-nums"><%= t(".gal_html", total_fuel: (number_with_delimiter(stats.total_fuel))) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".fuel_burn") %></dt><dd class="text-right tabular-nums"><%= t(".gal_hr_html", gph: (stats.gph || "—")) %></dd>
|
||||
<dt class="text-slate-500"><%= t(".airports_visited") %></dt><dd class="text-right tabular-nums"><%= stats.airports_visited %></dd>
|
||||
</dl>
|
||||
<% if stats.top_airports.any? %>
|
||||
<div class="border-t border-slate-100 px-4 py-3 text-xs text-slate-600">
|
||||
<span class="font-medium text-slate-700">Most visited:</span>
|
||||
<span class="font-medium text-slate-700"><%= t(".most_visited") %></span>
|
||||
<%= stats.top_airports.map { |code, n| "#{code} (#{n})" }.join(" · ") %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -42,9 +42,9 @@
|
||||
|
||||
<% if stats.by_year.size > 1 %>
|
||||
<details class="card group mb-5">
|
||||
<summary class="card-header cursor-pointer list-none [&::-webkit-details-marker]:hidden"><span class="card-title">By year</span><span aria-hidden="true" class="text-slate-500 transition group-open:rotate-180">▾</span></summary>
|
||||
<summary class="card-header cursor-pointer list-none [&::-webkit-details-marker]:hidden"><span class="card-title"><%= t(".by_year") %></span><span aria-hidden="true" class="text-slate-500 transition group-open:rotate-180">▾</span></summary>
|
||||
<table class="table">
|
||||
<thead><tr><th>Year</th><th class="text-right">Flights</th><th class="text-right">Flight hrs</th><th class="text-right">Tach hrs</th><th class="text-right">Fuel (gal)</th><th class="text-right">Avg flight</th></tr></thead>
|
||||
<thead><tr><th><%= t(".year") %></th><th class="text-right"><%= t(".flights") %></th><th class="text-right"><%= t(".flight_hrs") %></th><th class="text-right"><%= t(".tach_hrs") %></th><th class="text-right"><%= t(".fuel_gal") %></th><th class="text-right"><%= t(".avg_flight") %></th></tr></thead>
|
||||
<tbody>
|
||||
<% stats.by_year.each do |y| %>
|
||||
<tr>
|
||||
@@ -58,6 +58,6 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="px-4 pb-3 hint">Flight time is Hobbs time where recorded, otherwise tach time.</p>
|
||||
<p class="px-4 pb-3 hint"><%= t(".flight_time_is_hobbs_time") %></p>
|
||||
</details>
|
||||
<% end %>
|
||||
@@ -1,23 +1,23 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Flights" %>
|
||||
<% content_for :title, t(".flights", tail_number: @aircraft.tail_number) %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<% if @stats.any? %><%= render "flight_logs/stats", stats: @stats %><% end %>
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Flight Log</h2>
|
||||
<h2 class="card-title"><%= t(".flight_log") %></h2>
|
||||
<%= more_menu do %>
|
||||
<% if owner? %><%= link_to "Import from spreadsheet", new_aircraft_flight_import_path(@aircraft), class: "menu-item" %><% end %>
|
||||
<%= link_to "Export for AirTrail", new_aircraft_air_trail_export_path(@aircraft), class: "menu-item" %>
|
||||
<% if owner? %><%= link_to "Standardize airport codes", aircraft_airport_codes_path(@aircraft), class: "menu-item" %><% end %>
|
||||
<% if owner? %><%= link_to t(".import_from_spreadsheet"), new_aircraft_flight_import_path(@aircraft), class: "menu-item" %><% end %>
|
||||
<%= link_to t(".export_for_airtrail"), new_aircraft_air_trail_export_path(@aircraft), class: "menu-item" %>
|
||||
<% if owner? %><%= link_to t(".standardize_airport_codes"), aircraft_airport_codes_path(@aircraft), class: "menu-item" %><% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @days.any? %>
|
||||
<div class="hidden grid-cols-[9.5rem_1fr_repeat(4,5rem)_1.25rem] gap-3 border-b border-slate-200 bg-slate-50 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 sm:grid">
|
||||
<span>Date</span><span>Route</span><span class="text-right">Tach</span><span class="text-right">Hobbs</span><span class="text-right">Fuel (gal)</span><span class="text-right">Oil (qt)</span><span></span>
|
||||
<span><%= t(".date") %></span><span><%= t(".route") %></span><span class="text-right"><%= t(".tach") %></span><span class="text-right"><%= t(".hobbs") %></span><span class="text-right"><%= t(".fuel_gal") %></span><span class="text-right"><%= t(".oil_qt") %></span><span></span>
|
||||
</div>
|
||||
<div>
|
||||
<%= render "flight_logs/days", days: @days, page: @page, more: @more %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= empty_state "No flights logged yet." %>
|
||||
<%= empty_state t(".no_flights_logged_yet") %>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -1,4 +1,4 @@
|
||||
<% content_for :title, "Log Flight" %>
|
||||
<% content_for :title, t(".log_flight") %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<%= form_with model: [@aircraft, @flight_log], class: "card card-body space-y-5 max-w-3xl",
|
||||
data: { controller: "offline-flight", offline_flight_tail_value: @aircraft.tail_number,
|
||||
@@ -8,36 +8,36 @@
|
||||
<%= f.errors_summary %>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<%= f.field :date, as: :date, required: true %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: "From", aircraft: @aircraft, placeholder: "KOQU" %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: "To", aircraft: @aircraft, placeholder: "Code or name" %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: t(".from"), aircraft: @aircraft, placeholder: t(".koqu") %>
|
||||
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: t(".to"), aircraft: @aircraft, placeholder: t(".code_or_name") %>
|
||||
</div>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold">Tach (required)</legend>
|
||||
<%= f.field :tach_out, as: :number, step: 0.1, label: "Tach out" %>
|
||||
<%= f.field :tach_in, as: :number, step: 0.1, label: "Tach in" %>
|
||||
<%= f.field :tach_time, as: :number, step: 0.1, label: "…or duration", hint: "Calculated from out/in if blank." %>
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".tach_required") %></legend>
|
||||
<%= f.field :tach_out, as: :number, step: 0.1, label: t(".tach_out") %>
|
||||
<%= f.field :tach_in, as: :number, step: 0.1, label: t(".tach_in") %>
|
||||
<%= f.field :tach_time, as: :number, step: 0.1, label: t(".or_duration"), hint: t(".calculated_from_out_in_if") %>
|
||||
</fieldset>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold">Hobbs (optional)</legend>
|
||||
<%= f.field :hobbs_out, as: :number, step: 0.1, label: "Hobbs out" %>
|
||||
<%= f.field :hobbs_in, as: :number, step: 0.1, label: "Hobbs in" %>
|
||||
<%= f.field :hobbs_time, as: :number, step: 0.1, label: "…or duration" %>
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".hobbs_optional") %></legend>
|
||||
<%= f.field :hobbs_out, as: :number, step: 0.1, label: t(".hobbs_out") %>
|
||||
<%= f.field :hobbs_in, as: :number, step: 0.1, label: t(".hobbs_in") %>
|
||||
<%= f.field :hobbs_time, as: :number, step: 0.1, label: t(".or_duration") %>
|
||||
</fieldset>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-3">
|
||||
<legend class="mb-2 text-sm font-semibold">Oil & fuel added</legend>
|
||||
<%= f.field :oil_added, as: :number, step: 0.25, label: "Oil added (qt)" %>
|
||||
<%= f.field :oil_level_after, as: :number, step: 0.25, label: "Oil level after (qt)" %>
|
||||
<%= f.field :oil_added_type, label: "Oil type", placeholder: "Aeroshell W100" %>
|
||||
<%= f.field :fuel_added, as: :number, step: 0.1, label: "Fuel added (gal)" %>
|
||||
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: "Fuel level after (gal)" %>
|
||||
<%= f.field :fuel_added_type, label: "Fuel type", placeholder: "100LL" %>
|
||||
<legend class="mb-2 text-sm font-semibold"><%= t(".oil_fuel_added") %></legend>
|
||||
<%= f.field :oil_added, as: :number, step: 0.25, label: t(".oil_added_qt") %>
|
||||
<%= f.field :oil_level_after, as: :number, step: 0.25, label: t(".oil_level_after_qt") %>
|
||||
<%= f.field :oil_added_type, label: t(".oil_type"), placeholder: t(".aeroshell_w100") %>
|
||||
<%= f.field :fuel_added, as: :number, step: 0.1, label: t(".fuel_added_gal") %>
|
||||
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: t(".fuel_level_after_gal") %>
|
||||
<%= f.field :fuel_added_type, label: t(".fuel_type"), placeholder: t(".n100ll") %>
|
||||
</fieldset>
|
||||
<%= f.field :route, as: :textarea, rows: 2 %>
|
||||
<%= f.field :notes, as: :textarea, rows: 2 %>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :track_log, as: :file, label: "Track log (GPX/KML/CSV)" %>
|
||||
<%= f.field :engine_data, as: :file, label: "Engine monitor data", hint: "CGR-30P / CGR-30C flight recording (.csv).", accept: ".csv,text/csv" %>
|
||||
<%= f.field :track_log, as: :file, label: t(".track_log_gpx_kml_csv") %>
|
||||
<%= f.field :engine_data, as: :file, label: t(".engine_monitor_data"), hint: t(".cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
|
||||
</div>
|
||||
<p class="hint">Saving adds the tach time to the aircraft and all in-service components, and records any oil/fuel added.</p>
|
||||
<div class="flex gap-2"><%= f.submit "Log Flight" %><%= link_to "Cancel", aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
|
||||
<p class="hint"><%= t(".saving_adds_the_tach_time") %></p>
|
||||
<div class="flex gap-2"><%= f.submit t(".log_flight") %><%= link_to t(".cancel"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
@@ -1,24 +1,24 @@
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="space-y-6">
|
||||
<section class="card max-w-3xl">
|
||||
<div class="card-header"><h2 class="card-title">Flight on <%= fmt_date(@flight_log.date) %></h2>
|
||||
<% if owner? %><%= delete_button "Delete", aircraft_flight_log_path(@aircraft, @flight_log), confirm: "Delete this flight log? Aircraft and component hours will NOT be rolled back." %><% end %></div>
|
||||
<div class="card-header"><h2 class="card-title"><%= t(".flight_on_html", date: (fmt_date(@flight_log.date))) %></h2>
|
||||
<% if owner? %><%= delete_button t(".delete"), aircraft_flight_log_path(@aircraft, @flight_log), confirm: t(".delete_this_flight_log_aircraft") %><% end %></div>
|
||||
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
|
||||
<dt class="text-slate-500">Tach</dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd>
|
||||
<dt class="text-slate-500">Hobbs</dt><dd><%= hours(@flight_log.hobbs_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %></span></dd>
|
||||
<dt class="text-slate-500">Route</dt><dd class="col-span-3"><%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %></dd>
|
||||
<dt class="text-slate-500">Oil added</dt><dd><%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %></dd>
|
||||
<dt class="text-slate-500">Fuel added</dt><dd><%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %></dd>
|
||||
<dt class="text-slate-500">Pilot</dt><dd><%= @flight_log.user&.display_name || "—" %></dd>
|
||||
<dt class="text-slate-500">Track log</dt><dd class="col-span-3"><%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %>
|
||||
<% if @track %><span class="text-xs text-slate-500"> · <%= number_with_delimiter(@track.points) %> GPS points<%= " · max #{number_with_delimiter(@track.max_altitude_ft)} ft" if @track.max_altitude_ft %></span>
|
||||
<dt class="text-slate-500"><%= t(".tach") %></dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd>
|
||||
<dt class="text-slate-500"><%= t(".hobbs") %></dt><dd><%= hours(@flight_log.hobbs_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %></span></dd>
|
||||
<dt class="text-slate-500"><%= t(".route") %></dt><dd class="col-span-3"><%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %></dd>
|
||||
<dt class="text-slate-500"><%= t(".oil_added") %></dt><dd><%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %></dd>
|
||||
<dt class="text-slate-500"><%= t(".fuel_added") %></dt><dd><%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %></dd>
|
||||
<dt class="text-slate-500"><%= t(".pilot") %></dt><dd><%= @flight_log.user&.display_name || "—" %></dd>
|
||||
<dt class="text-slate-500"><%= t(".track_log") %></dt><dd class="col-span-3"><%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %>
|
||||
<% if @track %><span class="text-xs text-slate-500"> <%= t(".gps_points_html", points: (number_with_delimiter(@track.points)), max_altitude_ft: (t(".max_ft", max_altitude_ft: (number_with_delimiter(@track.max_altitude_ft))) if @track.max_altitude_ft)) %></span>
|
||||
<% elsif @track_error %><span class="text-xs text-amber-700"> · <%= @track_error %></span><% end %></dd>
|
||||
<% if @air_trail_sync || @air_trail_connection %>
|
||||
<dt class="text-slate-500">AirTrail</dt>
|
||||
<dt class="text-slate-500"><%= t(".airtrail") %></dt>
|
||||
<dd class="col-span-3 text-xs">
|
||||
<% if @air_trail_sync&.status == "synced" %><span class="badge-green">Synced</span> <%= time_ago_in_words(@air_trail_sync.synced_at) %> ago
|
||||
<% elsif @air_trail_sync&.status == "error" %><span class="badge-red">Not synced</span> <%= @air_trail_sync.last_error %>
|
||||
<% else %><span class="badge-gray">Pending</span><% end %>
|
||||
<% if @air_trail_sync&.status == "synced" %><span class="badge-green"><%= t(".synced") %></span> <%= t(".ago_html", synced_at: (time_ago_in_words(@air_trail_sync.synced_at))) %>
|
||||
<% elsif @air_trail_sync&.status == "error" %><span class="badge-red"><%= t(".not_synced") %></span> <%= @air_trail_sync.last_error %>
|
||||
<% else %><span class="badge-gray"><%= t(".pending") %></span><% end %>
|
||||
</dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
|
||||
Reference in new issue
Block a user