Files
simple-aircraft-manager-rails/app/views/oil_analyses/show.html.erb
T
rickyandClaude Opus 5.5 1c6c2f88c0 Blackstone oil analysis, .sam.zip export/import, AI logbook transcription
- Oil analysis: Blackstone PDF import (20 elements, oil properties, universal
  averages), results stored per element, oil type, "leave out of trends",
  the original app's statuses; AvLab fixes (multi-line comments, unrelated
  labels no longer steal values). Existing records migrate.
- Aircraft archives in the original app's .sam.zip format (schema v2): export
  from Access & Sharing, background import from the Fleet page, rake tasks.
  Archives move both ways between this app and the original.
- Scanned logbook pages (images or PDFs) upload as a document; with
  ANTHROPIC_API_KEY set, Claude transcribes them into logbook entries.
- Fix: deleting a component or aircraft failed when AD compliances or
  inspection records pointed at a component.

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

78 lines
4.9 KiB
ERB

<% 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">Oil</dt><dd><%= @analysis.oil_type || "—" %></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.excluded_from_averages? %>
<p class="border-t border-slate-100 px-4 py-2 text-xs text-slate-500">Left out of trend charts.</p>
<% end %>
<% if @analysis.oil_properties.any? %>
<div class="border-t border-slate-100 px-4 py-3 text-sm">
<div class="mb-1 text-xs font-semibold text-slate-500">Oil properties</div>
<dl class="grid grid-cols-2 gap-x-4 gap-y-1">
<% OilAnalysis::PROPERTIES.each_key do |key| %>
<% next unless @analysis.property(key) %>
<dt class="text-slate-500"><%= OilAnalysis::PROPERTIES[key][0] %></dt><dd class="tabular-nums"><%= oil_property(@analysis, key) %></dd>
<% end %>
</dl>
</div>
<% end %>
<% 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) %>
<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>