Files
rickyandClaude Opus 5.5 d4b71d17a1 Smaller aircraft photos, one-row-per-item detail cards, push diagnostics
- Aircraft photos get 192px and 960x432 copies made on upload; the header,
  share page and Fleet cards use them (and the offline copies), instead of
  the full original.
- Flight, engine data, component and major record details show one label
  and value per row on phones (wide items no longer add grid columns).
- Profile re-records this device's push subscription on every visit, and
  says why if it can't; Send test delivers now and lists each device's
  result; Google's other push hosts are accepted; turning notifications on
  shows the browser's actual error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:55:11 -05:00

119 lines
8.9 KiB
ERB

<%# 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"><%= 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 t(".remove"), engine_data_aircraft_flight_log_path(@aircraft, flight_log), confirm: t(".remove_the_engine_data_file") %><% end %>
</div>
<% end %>
</div>
<% if recording %>
<% hours_line = ->(key, places) { (a = recording.first(key)) && (b = recording.last(key)) ? "#{number_with_precision(a, precision: places)} → #{number_with_precision(b, precision: places)} (#{number_with_precision(b - a, precision: places)})" : "—" } %>
<% 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"><%= t(".this_recording_is_from_not_html", tail: tail, tail_number: @aircraft.tail_number) %></p>
<% end %>
<dl class="card-body grid gap-x-8 gap-y-3 text-sm sm:grid-cols-2">
<div class="detail-row sm:col-span-2"><dt><%= t(".recorded") %></dt>
<dd><%= 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></div>
<div class="detail-row"><dt><%= t(".engine_run") %></dt><dd><%= recording.engine_start ? run_duration(recording.run_time) : t(".engine_not_run") %></dd></div>
<div class="detail-row"><dt><%= t(".fuel_burned") %></dt><dd><%= engine_value(recording.fuel_burned, "gal", precision: 1) %></dd></div>
<div class="detail-row"><dt><%= t(".tach") %></dt><dd class="tabular-nums"><%= hours_line.(:tach, 2) %></dd></div>
<div class="detail-row"><dt><%= t(".engine_hrs") %></dt><dd class="tabular-nums"><%= hours_line.(:engine_hours, 2) %></dd></div>
<% if (flt = recording.last(:flight_hours)) %><div class="detail-row"><dt><%= t(".airborne") %></dt><dd><%= flt.zero? ? t(".no_ground_run") : "#{number_with_precision(flt, precision: 2)} hrs" %></dd></div><% end %>
</dl>
<div class="overflow-x-auto border-t border-slate-100">
<table class="table">
<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" ],
[ 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" ],
[ 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>
<td class="text-right tabular-nums text-slate-500"><%= recording.local(at).strftime("%H:%M:%S") %></td></tr>
<% end %>
</tbody>
</table>
</div>
<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"><%= 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) %>
<% next unless chart %>
<figure role="button" tabindex="0" aria-label="Explore the <%= group[:title] %> chart"
class="group cursor-zoom-in rounded-md p-1 ring-sky-500/40 transition hover:ring-2 focus-visible:outline-none focus-visible:ring-2"
data-action="click->engine-chart#open keydown.enter->engine-chart#open keydown.space->engine-chart#open"
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"><%= t(".explore") %></span>
</figcaption>
<%= chart %>
</figure>
<% end %>
</div>
<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="<%= 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"><%= 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><%= 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"><%= t(".loading") %></p>
</div>
<div class="max-h-[30%] overflow-auto border-t border-slate-200">
<table class="table text-sm">
<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>
</div>
</dialog>
</div>
<% elsif error %>
<p class="card-body text-sm text-amber-700"><%= error %></p>
<% end %>
<% 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: 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 t(".no_engine_data_for_this") %>
<% end %>
</section>