mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Track oil analysis reports; import AvLab PDFs
New Oil Analysis tab: one record per oil sample with dates, hours, the lab's verdict and comments, ppm results for 12 wear metals with the lab's averages, and the report PDF. Shows wear-metal trends, a side-by-side history table, and flags readings 1.5x or more above the lab average. AvLab report PDFs can be imported: every sample on the report (current and previous) is added unless already recorded, the engine is matched by serial number, and reports for another tail number are refused. The parser reads positioned text and drops the hidden color-code layer that overlaps results. Adds the pdf-reader gem. Test fixture is a rebuilt report with a dummy header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c6e7af8e6
commit
d519aa9aae
24 files changed
+3456
-2
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<% content_for :title, "Oil Analysis #{fmt_date(@analysis.sample_date)}" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<section class="card lg:col-span-1">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Sample <%= fmt_date(@analysis.sample_date) %></h2>
|
||||
<%= oil_status_badge(@analysis) %>
|
||||
</div>
|
||||
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm">
|
||||
<dt class="text-slate-500">Engine</dt><dd><%= @analysis.component ? link_to(@analysis.component, aircraft_component_path(@aircraft, @analysis.component), class: "link") : "—" %></dd>
|
||||
<dt class="text-slate-500">Engine hrs (TSN/TSO)</dt><dd><%= @analysis.engine_hours ? hours(@analysis.engine_hours) : "—" %></dd>
|
||||
<dt class="text-slate-500">Oil hrs</dt><dd><%= @analysis.oil_hours ? hours(@analysis.oil_hours) : "—" %></dd>
|
||||
<dt class="text-slate-500">Filter hrs</dt><dd><%= @analysis.filter_hours ? hours(@analysis.filter_hours) : "—" %></dd>
|
||||
<dt class="text-slate-500">Oil added</dt><dd><%= @analysis.oil_added ? "#{number_with_precision(@analysis.oil_added, precision: 2, strip_insignificant_zeros: true)} qt" : "—" %></dd>
|
||||
<dt class="text-slate-500">Lab</dt><dd><%= @analysis.lab || "—" %></dd>
|
||||
<dt class="text-slate-500">Sample #</dt><dd><%= @analysis.sample_number || "—" %></dd>
|
||||
<dt class="text-slate-500">Analyzed</dt><dd><%= @analysis.analysis_date ? fmt_date(@analysis.analysis_date) : "—" %></dd>
|
||||
<dt class="text-slate-500">Report</dt><dd><%= @analysis.report.attached? ? link_to(@analysis.report.filename, rails_blob_path(@analysis.report, disposition: :inline), class: "link", target: "_blank", rel: "noopener") : "—" %></dd>
|
||||
</dl>
|
||||
<% if @analysis.lab_comments.present? %>
|
||||
<div class="border-t border-slate-100 px-4 py-3 text-sm"><div class="mb-1 text-xs font-semibold text-slate-500">Lab comments</div><%= simple_format @analysis.lab_comments %></div>
|
||||
<% end %>
|
||||
<% if @analysis.notes.present? %>
|
||||
<div class="border-t border-slate-100 px-4 py-3 text-sm"><div class="mb-1 text-xs font-semibold text-slate-500">Notes</div><%= simple_format @analysis.notes %></div>
|
||||
<% end %>
|
||||
<% if owner? %>
|
||||
<div class="flex gap-2 border-t border-slate-100 px-4 py-3">
|
||||
<%= link_to "Edit", edit_aircraft_oil_analysis_path(@aircraft, @analysis), class: "btn-secondary btn-sm" %>
|
||||
<%= delete_button "Delete", aircraft_oil_analysis_path(@aircraft, @analysis), confirm: "Delete this oil analysis?" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<section class="card lg:col-span-2">
|
||||
<div class="card-header"><h2 class="card-title">Results (ppm)</h2>
|
||||
<span class="text-xs text-slate-500"><%= @previous ? "Compared with #{fmt_date(@previous.sample_date)}" : "First sample for this engine" %></span></div>
|
||||
<% if @analysis.any_results? %>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table">
|
||||
<thead><tr><th>Element</th><th class="text-right">This sample</th><th class="text-right">Lab average</th><% if @previous %><th class="text-right">Previous</th><th class="text-right">Change</th><% end %><th>Usual source</th></tr></thead>
|
||||
<tbody>
|
||||
<% OilAnalysis::ELEMENTS.each do |el, (label, source)| %>
|
||||
<% next unless @analysis.value(el) || @analysis.average(el) %>
|
||||
<tr class="<%= "bg-red-50" if @analysis.flagged?(el) %>">
|
||||
<td><%= label %></td>
|
||||
<td class="text-right tabular-nums <%= "font-semibold text-red-700" if @analysis.flagged?(el) %>"><%= ppm(@analysis.value(el)) %></td>
|
||||
<td class="text-right tabular-nums text-slate-500"><%= ppm(@analysis.average(el)) %></td>
|
||||
<% if @previous %>
|
||||
<td class="text-right tabular-nums"><%= ppm(@previous.value(el)) %></td>
|
||||
<td class="text-right tabular-nums"><%= ppm_change(@analysis, @previous, el) %></td>
|
||||
<% end %>
|
||||
<td class="text-xs text-slate-500"><%= source %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= empty_state "No results entered." %>
|
||||
<% end %>
|
||||
</section>
|
||||
</div>
|
||||
Reference in new issue
Block a user