Files
simple-aircraft-manager-rails/app/views/oil_analyses/index.html.erb
T
rickyandClaude Opus 5.5 3f45b557c2 Secondary actions behind More menus; tidier aircraft header and tabs
- more_menu helper (menu / menu-item styles): each section keeps its main
  action as a button; imports, exports, printing and tools move under More
  (flights, logbook, logbook entry, documents, inspections, fleet)
- Aircraft header: More with status report and, for owners, access &
  sharing, edit, .sam.zip and records package; Access & Sharing and Oil
  Analysis tabs removed (oil analysis is under Oil & Fuel with a switch)
- Logbook: Print selected appears once an entry is ticked; filters apply on
  change; dates use fmt_date (also AirTrail, notes, audits, About)
- Header shows the role on the aircraft and hides the usual Available badge;
  no second Grounded badge on the Overview; AD DRS import listed once
- Flights: stat cards 2x2 on phones; By year opens visibly, only with more
  than one year; duplicate + Log Flight removed
- Remove unused hello_controller.js; guide and README updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 21:21:57 -05:00

89 lines
5.0 KiB
ERB
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<% content_for :title, "#{@aircraft.tail_number} Oil Analysis" %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "shared/oil_subnav", aircraft: @aircraft %>
<% recent = @analyses.first(OilAnalysesController::COMPARE_SAMPLES) %>
<div class="space-y-5">
<section class="card">
<div class="card-header">
<div>
<h2 class="card-title">Import a lab report</h2>
<p class="hint">AvLab or Blackstone PDF reports: each sample on the report (including earlier ones) is added unless it's already here.</p>
</div>
<%= render "import", aircraft: @aircraft %>
</div>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title">Wear metal trends</h2>
<%= link_to "+ Add Oil Analysis", new_aircraft_oil_analysis_path(@aircraft), class: "btn-secondary btn-sm" %>
</div>
<div class="card-body">
<% series = oil_trend_series(@analyses) %>
<% if series.any? %>
<%= line_chart series, ytitle: "ppm", height: "260px", curve: false, colors: OilAnalysesHelper::TREND_COLORS, legend: "bottom" %>
<p class="hint">Lead is left out of the chart: it comes from 100LL fuel and reads in the thousands. Look for a steady trend rather than a single reading.<%= " Samples marked “leave out of trends” aren't charted." if @analyses.any?(&:excluded_from_averages?) %></p>
<% else %>
<%= empty_state @analyses.any? ? "Add another sample to see trends." : "No oil analyses yet. Add one from your lab report." %>
<% end %>
</div>
</section>
<% if recent.any?(&:any_results?) %>
<section class="card">
<div class="card-header"><h2 class="card-title">Results (ppm)</h2>
<span class="text-xs text-slate-500">Lab average for similar engines in (parentheses); <span class="font-semibold text-red-700">red</span> is <%= OilAnalysis::FLAG_RATIO %>× or more above it.</span></div>
<div class="overflow-x-auto">
<table class="table table-keep">
<thead>
<tr><th>Element</th>
<% recent.each do |a| %><th class="text-right whitespace-nowrap"><%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %></th><% end %></tr>
</thead>
<tbody>
<tr class="text-xs text-slate-500"><td>Engine / oil hrs</td>
<% recent.each do |a| %><td class="text-right tabular-nums"><%= a.engine_hours ? hours(a.engine_hours) : "—" %> / <%= a.oil_hours ? hours(a.oil_hours) : "—" %></td><% end %></tr>
<% OilAnalysis.elements_in(recent).each do |el| %>
<% label, source = OilAnalysis::ELEMENTS.fetch(el) %>
<tr><td><span title="<%= source %>"><%= label %></span></td>
<% recent.each do |a| %><td class="text-right align-top"><%= ppm_cell(a, el) %></td><% end %></tr>
<% end %>
<% OilAnalysis::PROPERTIES.each_key do |key| %>
<% next if recent.none? { _1.property(key) } %>
<tr class="text-sm"><td class="text-slate-600"><%= OilAnalysis::PROPERTIES[key][0] %></td>
<% recent.each do |a| %><td class="text-right tabular-nums whitespace-nowrap text-slate-600"><%= oil_property(a, key) %></td><% end %></tr>
<% end %>
</tbody>
</table>
</div>
</section>
<% end %>
<section class="card">
<div class="card-header"><h2 class="card-title">Samples</h2></div>
<% if @analyses.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Sampled</th><th>Result</th><th>Engine</th><th class="text-right">Engine hrs</th><th class="text-right">Oil hrs</th><th>Lab</th><th>Report</th></tr></thead>
<tbody>
<% @analyses.each do |a| %>
<tr>
<td class="whitespace-nowrap"><%= link_to fmt_date(a.sample_date), aircraft_oil_analysis_path(@aircraft, a), class: "link" %>
<% if a.excluded_from_averages? %><div class="text-xs text-slate-500">left out of trends</div><% end %></td>
<td class="whitespace-nowrap"><%= oil_status_badge(a) %>
<% if (flags = a.flagged_elements).any? %><span class="ml-1 text-xs text-red-700"><%= flags.map { OilAnalysis.element_label(_1) }.to_sentence %> above average</span><% end %></td>
<td><%= a.component&.to_s || "—" %></td>
<td class="text-right tabular-nums"><%= a.engine_hours ? hours(a.engine_hours) : "—" %></td>
<td class="text-right tabular-nums"><%= a.oil_hours ? hours(a.oil_hours) : "—" %></td>
<td><%= [ a.lab, a.sample_number ].compact.join(" · ").presence || "—" %></td>
<td><%= a.report.attached? ? link_to("PDF", rails_blob_path(a.report, disposition: :inline), class: "link", target: "_blank", rel: "noopener") : "—" %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state "No samples recorded." %>
<% end %>
</section>
</div>