mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
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>
This commit is contained in:
1 parent
2d068e1a63
commit
1c6c2f88c0
54 files changed
+2794
-286
No files matched your search
@@ -1,7 +1,10 @@
|
||||
<% content_for :title, "Fleet" %>
|
||||
<div class="mb-5 flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold tracking-tight">Fleet</h1>
|
||||
<%= link_to "+ Add Aircraft", new_aircraft_path, class: "btn-primary" %>
|
||||
<div class="flex gap-2">
|
||||
<%= link_to "Import", new_aircraft_import_path, class: "btn-secondary", title: "Import an aircraft from a .sam.zip archive" %>
|
||||
<%= link_to "+ Add Aircraft", new_aircraft_path, class: "btn-primary" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @aircraft_list.empty? %>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<% content_for :title, "Import Aircraft" %>
|
||||
<div class="mx-auto max-w-2xl space-y-5">
|
||||
<h1 class="text-2xl font-bold tracking-tight">Import an aircraft</h1>
|
||||
<section class="card card-body space-y-4">
|
||||
<p class="text-sm text-slate-600">
|
||||
Upload a <strong>.sam.zip</strong> archive exported from Simple Aircraft Manager (this app or the original).
|
||||
Everything in it is added as a new aircraft that you own: components, logbook, squawks, inspections, ADs,
|
||||
documents, oil and fuel, oil analyses, flights and their files.
|
||||
</p>
|
||||
<% if @preview %>
|
||||
<div class="rounded-md bg-slate-50 px-3 py-2 text-sm ring-1 ring-slate-200">
|
||||
Archive: <strong><%= @preview.tail_number %></strong> <%= [ @preview.make, @preview.model ].compact_blank.join(" ") %>
|
||||
<% if @preview.exported_at %><span class="text-slate-500">· exported <%= fmt_date(@preview.exported_at.to_date) %></span><% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= form_with url: aircraft_imports_path, multipart: true, class: "space-y-4" do |f| %>
|
||||
<div>
|
||||
<%= f.label :archive, "Archive (.sam.zip)", class: "label" %>
|
||||
<%= f.file_field :archive, accept: ".zip,application/zip", required: true,
|
||||
class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
|
||||
<% if @conflict %><p class="hint mt-1">Choose the file again along with the new tail number.</p><% end %>
|
||||
</div>
|
||||
<div class="max-w-xs">
|
||||
<%= f.label :tail_number, "Tail number", class: "label" %>
|
||||
<%= f.text_field :tail_number, value: (params[:tail_number] unless @conflict), class: "input uppercase",
|
||||
placeholder: @preview&.tail_number || "From the archive", required: @conflict.present? %>
|
||||
<p class="hint mt-1">Leave blank to use the archive's. Needed when that tail number is already here.</p>
|
||||
</div>
|
||||
<div class="flex gap-2"><%= f.submit "Import", class: "btn-primary" %><%= link_to "Cancel", root_path, class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
</section>
|
||||
</div>
|
||||
@@ -0,0 +1,28 @@
|
||||
<% content_for :title, "Aircraft Import" %>
|
||||
<% if @import.in_progress? %><% content_for :head, tag.meta("http-equiv": "refresh", content: "2") %><% end %>
|
||||
<div class="mx-auto max-w-2xl space-y-5">
|
||||
<h1 class="text-2xl font-bold tracking-tight">Importing <%= @import.tail_number %></h1>
|
||||
<section class="card card-body space-y-3 text-sm" id="import-status">
|
||||
<p class="text-slate-500"><%= @import.filename %><%= " · from #{@import.source}" if @import.source.present? %></p>
|
||||
<% if @import.in_progress? %>
|
||||
<p class="flex items-center gap-2 font-medium"><span class="inline-block h-3 w-3 animate-pulse rounded-full bg-sky-500"></span>
|
||||
<%= @import.status == "queued" ? "Waiting to start…" : "Importing…" %></p>
|
||||
<% if @import.counts.any? %><p class="text-slate-600">So far: <%= @import.summary %>.</p><% end %>
|
||||
<p class="hint">This page updates by itself. Large archives with many documents can take a few minutes.</p>
|
||||
<% elsif @import.done? %>
|
||||
<p class="font-medium text-emerald-700">Imported.</p>
|
||||
<p class="text-slate-600"><%= @import.summary.presence&.upcase_first || "No records" %>.</p>
|
||||
<% if @import.aircraft %><p><%= link_to "Open #{@import.aircraft.tail_number} →", aircraft_path(@import.aircraft), class: "btn-primary" %></p><% end %>
|
||||
<% else %>
|
||||
<p class="font-medium text-red-700">The import failed. Nothing was added.</p>
|
||||
<p class="text-slate-600"><%= @import.error %></p>
|
||||
<p><%= link_to "Try another file", new_aircraft_import_path, class: "btn-secondary" %></p>
|
||||
<% end %>
|
||||
<% if @import.warnings.any? %>
|
||||
<div class="border-t border-slate-100 pt-3">
|
||||
<p class="mb-1 text-xs font-semibold text-slate-500"><%= pluralize(@import.warnings.size, "note") %></p>
|
||||
<ul class="list-disc space-y-0.5 pl-5 text-slate-600"><% @import.warnings.each do |w| %><li><%= w %></li><% end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
</div>
|
||||
@@ -58,4 +58,14 @@
|
||||
<%= f.submit "Create Share Link" %>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<section class="card lg:col-span-2">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h2 class="card-title">Backup & transfer</h2>
|
||||
<p class="hint">Everything recorded for <%= @aircraft.tail_number %>, with its files, in one .sam.zip archive. Import it from the Fleet page here or into another Simple Aircraft Manager (including the original).</p>
|
||||
</div>
|
||||
<%= link_to "Download .sam.zip", aircraft_export_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -9,7 +9,7 @@
|
||||
<%= f.select :log_type, LogbookEntry::LOG_TYPES.invert, { include_blank: "All logs", selected: @log_type }, class: "input w-32" %>
|
||||
<%= f.submit "Filter", class: "btn-secondary" %>
|
||||
<% end %>
|
||||
<% if owner? %><%= link_to "+ New Entry", new_aircraft_logbook_entry_path(@aircraft), class: "btn-primary" %><% end %>
|
||||
<% if owner? %><%= link_to "Import scans", new_aircraft_logbook_import_path(@aircraft), class: "btn-secondary" %><%= link_to "+ New Entry", new_aircraft_logbook_entry_path(@aircraft), class: "btn-primary" %><% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @entries.any? %>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Import Logbook Pages" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<% ai = LogbookImport.ai_available? %>
|
||||
<%= form_with url: aircraft_logbook_imports_path(@aircraft), multipart: true, class: "card card-body max-w-3xl space-y-5" do |f| %>
|
||||
<div>
|
||||
<h2 class="card-title">Import scanned logbook pages</h2>
|
||||
<p class="hint mt-1">
|
||||
The pages are saved as a document, in file-name order (name them page-001, page-002…).
|
||||
<% if ai %>Claude can also read them and add each entry to the logbook for you.<% else %>
|
||||
To have entries transcribed automatically, set an <code>ANTHROPIC_API_KEY</code> for the app.<% end %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.label :pages, "Scanned pages", class: "label" %>
|
||||
<%= f.file_field :pages, multiple: true, required: true, accept: "image/jpeg,image/png,image/gif,image/webp,application/pdf",
|
||||
class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
|
||||
<p class="hint mt-1">JPEG, PNG, WebP or PDF. For transcription, images up to 5 MB each and PDFs up to 30 MB.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<%= f.label :collection_id, "Collection", class: "label" %>
|
||||
<%= f.select :collection_id, [ [ "New collection…", "new" ] ] + @collections.map { [ _1.name, _1.id ] },
|
||||
{ selected: params[:collection_id] || @collections.find { _1.name.match?(/log/i) }&.id || "new" }, class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :collection_name, "New collection name", class: "label" %>
|
||||
<%= f.text_field :collection_name, value: params[:collection_name], placeholder: "Airframe Log #2", class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :document_name, "Document name", class: "label" %>
|
||||
<%= f.text_field :document_name, value: params[:document_name], placeholder: "Same as the collection", class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :doc_type, "Document type", class: "label" %>
|
||||
<%= f.select :doc_type, Document::TYPES.invert, { selected: params[:doc_type] || "LOG" }, class: "input" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset class="space-y-3 rounded-md p-3 ring-1 ring-slate-200 <%= 'opacity-60' unless ai %>">
|
||||
<label class="flex items-start gap-2 text-sm">
|
||||
<%= f.check_box :transcribe, { checked: ai, disabled: !ai, class: "mt-0.5" }, "1", "0" %>
|
||||
<span><strong>Transcribe with Claude</strong><br>
|
||||
<span class="hint">Each entry becomes a logbook entry linked to its page. Handwriting isn't always read perfectly: review the new entries against the scans.</span></span>
|
||||
</label>
|
||||
<div class="max-w-xs">
|
||||
<%= f.label :log_type, "Log", class: "label" %>
|
||||
<%= f.select :log_type, [ [ "Detect for each entry", "" ] ] + LogbookEntry::LOG_TYPES.invert.to_a, { selected: params[:log_type] }, class: "input", disabled: !ai %>
|
||||
<p class="hint mt-1">Pick one when the whole book is a single log (e.g. an engine log).</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<%= f.submit ai ? "Upload & transcribe" : "Upload pages", class: "btn-primary" %>
|
||||
<%= link_to "Cancel", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,44 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Logbook Import" %>
|
||||
<% if @import.in_progress? %><% content_for :head, tag.meta("http-equiv": "refresh", content: "3") %><% end %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<section class="card card-body max-w-3xl space-y-4 text-sm">
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<h2 class="card-title"><%= @import.document&.name || "Logbook pages" %></h2>
|
||||
<span class="text-xs text-slate-500"><%= pluralize(@import.pages_total, "page") %><%= " · read by #{@import.model}" if @import.transcribe && @import.model %></span>
|
||||
</div>
|
||||
|
||||
<% if @import.in_progress? %>
|
||||
<div>
|
||||
<div class="mb-1 flex justify-between text-xs text-slate-500">
|
||||
<span><%= @import.transcribe ? "Claude is reading the pages…" : "Saving pages…" %></span>
|
||||
<span class="tabular-nums"><%= @import.pages_done %> / <%= @import.pages_total %></span>
|
||||
</div>
|
||||
<div class="h-2 overflow-hidden rounded-full bg-slate-200" role="progressbar" aria-valuenow="<%= @import.progress_percent %>" aria-valuemin="0" aria-valuemax="100">
|
||||
<div class="h-full rounded-full bg-sky-600 transition-all" style="width: <%= @import.progress_percent %>%"></div>
|
||||
</div>
|
||||
<p class="hint mt-2"><%= pluralize(@import.entries_created, "entry") %> so far. This page updates by itself; a long logbook can take several minutes.</p>
|
||||
</div>
|
||||
<% elsif @import.done? %>
|
||||
<p class="font-medium text-emerald-700">
|
||||
<%= @import.transcribe ? "Done: #{pluralize(@import.entries_created, 'logbook entry')} added." : "Pages saved." %>
|
||||
</p>
|
||||
<% if @import.transcribe && @import.entries_created.positive? %>
|
||||
<p class="text-slate-600">Check the new entries against the scans: handwriting isn't always read perfectly.</p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="font-medium text-red-700">The import stopped: <%= @import.error %></p>
|
||||
<% if @import.entries_created.positive? %><p class="text-slate-600"><%= pluralize(@import.entries_created, "entry") %> were added before it stopped.</p><% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<%= link_to "Logbook", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary btn-sm" %>
|
||||
<% if @import.document %><%= link_to "View scans", aircraft_document_path(@aircraft, @import.document), class: "btn-secondary btn-sm" %><% end %>
|
||||
</div>
|
||||
|
||||
<% if @import.warnings.any? %>
|
||||
<div class="border-t border-slate-100 pt-3">
|
||||
<p class="mb-1 text-xs font-semibold text-slate-500"><%= pluralize(@import.warnings.size, "note") %></p>
|
||||
<ul class="list-disc space-y-0.5 pl-5 text-slate-600"><% @import.warnings.each do |w| %><li><%= w %></li><% end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -0,0 +1,9 @@
|
||||
<%# One element's result and lab average. Locals: element, analysis %>
|
||||
<% label = OilAnalysis.element_label(element) %>
|
||||
<div class="grid grid-cols-[6rem_1fr_1fr] items-center gap-2">
|
||||
<%= label_tag "oil_analysis_elements_#{element}", label, class: "text-sm font-medium text-slate-700" %>
|
||||
<%= number_field_tag "oil_analysis[elements][#{element}]", analysis.value(element), id: "oil_analysis_elements_#{element}",
|
||||
step: "any", min: 0, class: "input", placeholder: "Result" %>
|
||||
<%= number_field_tag "oil_analysis[element_averages][#{element}]", analysis.average(element), id: "oil_analysis_element_averages_#{element}",
|
||||
step: "any", min: 0, class: "input", placeholder: "Avg", "aria-label": "#{label} lab average" %>
|
||||
</div>
|
||||
@@ -3,10 +3,11 @@
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<%= f.field :sample_date, as: :date, required: true %>
|
||||
<%= f.field :analysis_date, as: :date %>
|
||||
<%= f.field :status, as: :select, label: "Lab's verdict", collection: OilAnalysis::STATUSES.invert %>
|
||||
<%= f.field :status, as: :select, label: "Lab's verdict", collection: [ [ "Not rated", "" ] ] + OilAnalysis::STATUSES.invert.to_a %>
|
||||
<%= f.field :component_id, as: :select, label: "Engine", collection: component_options(aircraft) %>
|
||||
<%= f.field :lab, placeholder: "AvLab, Blackstone…" %>
|
||||
<%= f.field :sample_number, label: "Sample #" %>
|
||||
<%= f.field :sample_number, label: "Sample / lab #" %>
|
||||
<%= f.field :oil_type, label: "Oil", placeholder: "Aeroshell W100…", wrapper: { class: "sm:col-span-2" } %>
|
||||
</div>
|
||||
<fieldset class="grid gap-4 sm:grid-cols-4">
|
||||
<legend class="mb-2 text-sm font-semibold">Hours</legend>
|
||||
@@ -15,19 +16,36 @@
|
||||
<%= f.field :filter_hours, as: :number, step: 0.1, label: "On filter" %>
|
||||
<%= f.field :oil_added, as: :number, step: 0.25, label: "Oil added (qt)" %>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend class="mb-2 text-sm font-semibold">Results (ppm)</legend>
|
||||
<p class="hint mb-3">Leave blank what the lab didn't test (N/A). Enter "< 0.1" as 0. The average is the lab's figure for similar engines, usually in (parentheses) under the result.</p>
|
||||
<div class="grid gap-x-4 gap-y-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<% OilAnalysis::ELEMENTS.each do |el, (label, _)| %>
|
||||
<div class="grid grid-cols-[6rem_1fr_1fr] items-center gap-2">
|
||||
<%= f.label el, label, class: "text-sm font-medium text-slate-700" %>
|
||||
<%= f.number_field el, step: 0.1, min: 0, class: "input", placeholder: "Result" %>
|
||||
<%= f.number_field :"#{el}_avg", step: 0.1, min: 0, class: "input", placeholder: "Avg", "aria-label": "#{label} lab average" %>
|
||||
<%= render partial: "element_input", collection: OilAnalysis::COMMON_ELEMENTS, as: :element, locals: { analysis: analysis } %>
|
||||
</div>
|
||||
<% extra = OilAnalysis::ELEMENTS.keys - OilAnalysis::COMMON_ELEMENTS %>
|
||||
<details class="mt-3" <%= "open" if extra.any? { analysis.value(_1) || analysis.average(_1) } %>>
|
||||
<summary class="cursor-pointer text-sm text-sky-700">More elements (Blackstone and other labs)</summary>
|
||||
<div class="mt-3 grid gap-x-4 gap-y-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<%= render partial: "element_input", collection: extra, as: :element, locals: { analysis: analysis } %>
|
||||
</div>
|
||||
</details>
|
||||
</fieldset>
|
||||
|
||||
<details <%= "open" if analysis.oil_properties.any? %>>
|
||||
<summary class="cursor-pointer text-sm font-semibold">Oil properties</summary>
|
||||
<div class="mt-3 grid gap-x-4 gap-y-3 sm:grid-cols-3">
|
||||
<% OilAnalysis::PROPERTIES.each do |key, (label, unit)| %>
|
||||
<div>
|
||||
<%= label_tag "oil_analysis_oil_properties_#{key}", [ label, (unit.presence && "(#{unit})") ].compact.join(" "), class: "label" %>
|
||||
<%= number_field_tag "oil_analysis[oil_properties][#{key}]", analysis.property(key), id: "oil_analysis_oil_properties_#{key}", step: "any", min: 0, class: "input" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
</details>
|
||||
|
||||
<%= f.field :excluded_from_averages, as: :checkbox, label: "Leave out of trends",
|
||||
hint: "For a sample that isn't representative, e.g. right after an overhaul or a top end." %>
|
||||
<%= f.field :lab_comments, as: :textarea, rows: 2 %>
|
||||
<%= f.field :notes, as: :textarea, rows: 2 %>
|
||||
<%= f.field :report, as: :file, label: "Lab report (PDF)", accept: ".pdf,application/pdf,image/*" %>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<h2 class="card-title">Import a lab report</h2>
|
||||
<p class="hint">AvLab PDF reports: each sample on the report (including previous ones) is added unless it's already here.</p>
|
||||
<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>
|
||||
@@ -21,7 +21,7 @@
|
||||
<% 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.</p>
|
||||
<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 %>
|
||||
@@ -41,11 +41,16 @@
|
||||
<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.each do |el, (label, source)| %>
|
||||
<% next if recent.none? { _1.value(el) } %>
|
||||
<% 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>
|
||||
@@ -61,7 +66,8 @@
|
||||
<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" %></td>
|
||||
<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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% content_for :title, "Add Oil Analysis" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<section class="card card-body mb-5 max-w-4xl">
|
||||
<h2 class="mb-1 text-sm font-semibold">Have an AvLab PDF? Import it instead</h2>
|
||||
<h2 class="mb-1 text-sm font-semibold">Have an AvLab or Blackstone PDF? Import it instead</h2>
|
||||
<p class="hint mb-3">Every sample on the report is filled in for you, and the PDF is attached to the newest one.</p>
|
||||
<%= render "import", aircraft: @aircraft %>
|
||||
</section>
|
||||
|
||||
@@ -12,11 +12,26 @@
|
||||
<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 %>
|
||||
@@ -40,7 +55,7 @@
|
||||
<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) %>
|
||||
<% 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>
|
||||
|
||||
Reference in new issue
Block a user