Move all user-facing text into config/locales/en.yml for localization

- Views use lazy t(".key") lookups; sentences with values or links stay
  whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
  from labels: in the current locale; field names and validation messages
  under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
  templates, records package README and transcription warnings localized;
  the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
  follows the locale
- APP_LOCALE picks the language (falls back to English); missing
  translations raise in development and tests
- README: Translating section and APP_LOCALE

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-13 22:08:20 -05:00
1 parent 3f45b557c2
commit 89ed0a76f9
313 files changed
+6387 -2653

No files matched your search

+15 -15
View File
@@ -3,30 +3,30 @@
<%= form_with model: compliance, url: compliance.new_record? ? aircraft_ad_compliances_path(aircraft) : aircraft_ad_compliance_path(aircraft, compliance),
class: "card card-body space-y-4 max-w-2xl", data: { controller: "next-due", next_due_rules_value: rules.to_json } do |f| %>
<%= f.errors_summary %>
<%= f.field :airworthiness_directive_id, as: :select, label: "AD", collection: ads.map { ["#{_1.name} – #{_1.short_description.truncate(50)}", _1.id] },
<%= f.field :airworthiness_directive_id, as: :select, label: t(".ad"), collection: ads.map { ["#{_1.name} – #{_1.short_description.truncate(50)}", _1.id] },
data: { next_due_target: "rule", action: "change->next-due#changed" } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date_complied, as: :date, data: { next_due_target: "date", action: "change->next-due#changed" } %>
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: "Aircraft hours (#{aircraft.time_basis_label.downcase})",
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: t(".aircraft_hours", time_basis_label: aircraft.time_basis_label.downcase),
data: { next_due_target: "hours", action: "input->next-due#changed" } %>
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: "Next due at #{aircraft.time_basis_label.downcase} reading",
hint: "Calculated from the AD's recurrence; you can override it. Leave 0 if not hour-based.",
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: t(".next_due_at_reading", time_basis_label: aircraft.time_basis_label.downcase),
hint: t(".calculated_from_the_ad_s"),
data: { next_due_target: "dueHours", action: "input->next-due#markManual" } %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
<%= f.field :component_id, as: :select, label: t(".component"), collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: t(".logbook_entry"), collection: logbook_options(aircraft) %>
</div>
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200" data-next-due-target="preview" hidden></p>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :compliance_method, as: :select, label: "Method of compliance", collection: AdCompliance::METHODS.invert,
<%= f.field :compliance_method, as: :select, label: t(".method_of_compliance"), collection: AdCompliance::METHODS.invert,
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
<%= f.field :ad_revision, label: "AD revision complied with", placeholder: "e.g. 2011-10-09 R1, effective 2011-06-01",
hint: "AD number and revision or effective date (91.417(a)(2)(v)). Left blank, it's taken from the AD." %>
<%= f.field :ad_revision, label: t(".ad_revision_complied_with"), placeholder: t(".e_g_2011_10_09"),
hint: t(".ad_number_and_revision_or") %>
</div>
<%= f.field :permanent, as: :checkbox, label: "No further action required (ends the recurring requirement)",
hint: "Set automatically for terminating action; tick it for an AMOC that ends the recurrence.",
<%= f.field :permanent, as: :checkbox, label: t(".no_further_action_required_ends"),
hint: t(".set_automatically_for_terminating_action"),
data: { next_due_target: "permanent", action: "change->next-due#changed" } %>
<%= f.field :compliance_notes, as: :textarea, label: "Details", rows: 3, required: true,
hint: "What was done and per which paragraph of the AD; for not applicable, why (e.g. serial number outside the affected range, equipment not installed)." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<%= f.field :compliance_notes, as: :textarea, label: t(".details"), rows: 3, required: true,
hint: t(".what_was_done_and_per") %>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if compliance.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_ad_compliance_path(aircraft, compliance) %></div><% end %>
<% if compliance.persisted? %><div class="mt-4"><%= delete_button t(".delete_record"), aircraft_ad_compliance_path(aircraft, compliance) %></div><% end %>
+10 -10
View File
@@ -1,23 +1,23 @@
<% content_for :title, "Import ADs" %>
<% content_for :title, t(".import_ads") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-3">
<%= form_with url: aircraft_ad_import_path(@aircraft), multipart: true, class: "card card-body space-y-4 lg:col-span-2" do |f| %>
<h2 class="card-title">Import ADs from the FAA DRS</h2>
<h2 class="card-title"><%= t(".import_ads_from_the_faa") %></h2>
<div>
<%= f.label :file, "DRS export (.csv or .xlsx)", class: "label" %>
<%= f.label :file, t(".drs_export_csv_or_xlsx"), class: "label" %>
<%= f.file_field :file, accept: ".xlsx,.csv", 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" %>
</div>
<%= f.submit "Upload & Preview", class: "btn-primary" %>
<p class="hint">Nothing is saved until you confirm on the next page.</p>
<%= f.submit t(".upload_preview"), class: "btn-primary" %>
<p class="hint"><%= t(".nothing_is_saved_until_you") %></p>
<% end %>
<section class="card card-body space-y-2 text-sm text-slate-700">
<h3 class="font-semibold">Getting the file</h3>
<h3 class="font-semibold"><%= t(".getting_the_file") %></h3>
<ol class="list-decimal space-y-1 pl-4 text-xs">
<li>On <a href="https://drs.faa.gov" class="link" target="_blank" rel="noopener noreferrer">drs.faa.gov</a>, search Airworthiness Directives for this aircraft's make and model (add the engine and propeller too).</li>
<li>Save the results as <strong>Excel</strong>. The Excel file links each AD number to its DRS page; the CSV doesn't, so a CSV import won't have links.</li>
<li>Upload it here.</li>
<li><%= t(".on_drs_faa_gov_search_html") %></li>
<li><%= t(".save_the_results_as_excel_html") %></li>
<li><%= t(".upload_it_here") %></li>
</ol>
<p class="text-xs">ADs already tracked are matched by number, so importing the Excel file after a CSV import just adds the links.</p>
<p class="text-xs"><%= t(".ads_already_tracked_are_matched") %></p>
</section>
</div>
+16 -16
View File
@@ -1,4 +1,4 @@
<% content_for :title, "AD Import Preview" %>
<% content_for :title, t(".ad_import_preview") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% rows = @import.rows %>
<%= form_with url: confirm_aircraft_ad_import_path(@aircraft), class: "space-y-5" do |f| %>
@@ -6,17 +6,17 @@
<%= hidden_field_tag :filename, @filename %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Preview: <%= @filename %></h2>
<span class="text-xs text-slate-500"><%= pluralize(rows.size, "AD") %> found · <%= rows.count(&:url) %> with DRS links</span>
<h2 class="card-title"><%= t(".preview_html", filename: @filename) %></h2>
<span class="text-xs text-slate-500"><%= t(".found_with_drs_links_html", rows: (t("counts.ad", count: rows.size)), url: (rows.count(&:url))) %></span>
</div>
<div class="card-body space-y-3 text-sm">
<% if rows.none?(&:url) %><p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200">This file has no links to the AD documents. DRS's <strong>Excel</strong> export includes them; import that file instead (or afterwards) to get clickable AD numbers.</p><% end %>
<p>Choose what to do with each AD. The suggestions are based on the FAA data and your aircraft's model (<%= @aircraft.model.presence || "not set" %>); you make the call.</p>
<% if rows.none?(&:url) %><p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200"><%= t(".this_file_has_no_links_html") %></p><% end %>
<p><%= t(".choose_what_to_do_with_html", model: (@aircraft.model.presence || t(".not_set"))) %></p>
<ul class="list-disc space-y-1 pl-5 text-xs text-slate-600">
<li><strong>Track</strong>: adds the AD. Until you record compliance, it counts against airworthiness, so <%= @aircraft.tail_number %> will show <span class="badge-red">Grounded</span> while any tracked AD has no compliance record.</li>
<li><strong>Not applicable</strong>: adds the AD with an N/A record (e.g. the equipment isn't installed). You can edit the reason afterwards.</li>
<li><strong>Update</strong> (ADs already tracked): refreshes the FAA details: subject, summary, dates, supersession and DRS link. Compliance records aren't touched.</li>
<li><strong>Skip</strong>: not imported, or left exactly as is.</li>
<li><%= t(".track_adds_the_ad_until_html", tail_number: @aircraft.tail_number) %> <span class="badge-red"><%= t(".grounded") %></span> <%= t(".while_any_tracked_ad_has") %></li>
<li><%= t(".not_applicable_adds_the_ad_html") %></li>
<li><%= t(".update_ads_already_tracked_refreshes_html") %></li>
<li><%= t(".skip_not_imported_or_left_html") %></li>
</ul>
</div>
</section>
@@ -24,21 +24,21 @@
<section class="card">
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>AD</th><th>Subject</th><th>Effective</th><th>Notes</th><th class="w-44">Action</th></tr></thead>
<thead><tr><th><%= t(".ad") %></th><th><%= t(".subject") %></th><th><%= t(".effective") %></th><th><%= t(".notes") %></th><th class="w-44"><%= t(".action") %></th></tr></thead>
<tbody>
<% rows.each do |r| %>
<tr>
<td class="whitespace-nowrap font-medium"><%= r.number %><%= link_to " 🔗", r.url, target: "_blank", rel: "noopener noreferrer", title: "Link found in file" if r.url %>
<td class="whitespace-nowrap font-medium"><%= r.number %><%= link_to " 🔗", r.url, target: "_blank", rel: "noopener noreferrer", title: t(".link_found_in_file") if r.url %>
<% if r.product_type %><div class="text-xs font-normal text-slate-500"><%= r.product_type %></div><% end %></td>
<td class="max-w-md">
<%= r.subject %>
<% if r.summary %><details class="mt-1 text-xs text-slate-600"><summary class="cursor-pointer text-sky-700">Summary</summary><%= r.summary %></details><% end %>
<% if r.summary %><details class="mt-1 text-xs text-slate-600"><summary class="cursor-pointer text-sky-700"><%= t(".summary") %></summary><%= r.summary %></details><% end %>
</td>
<td class="whitespace-nowrap text-xs"><%= fmt_date(r.effective_date) %></td>
<td class="text-xs">
<% r.notes.each do |n| %><div class="<%= n.start_with?("Already", "Matches") ? 'text-slate-500' : 'text-amber-800' %>">• <%= n %></div><% end %>
<% r.notes.each do |n| %><div class="<%= n.start_with?(t(".already"), t(".matches")) ? 'text-slate-500' : 'text-amber-800' %>">• <%= n %></div><% end %>
</td>
<td><% choices = r.tracked ? [ [ "Update", "track" ], [ "Not applicable", "na" ], [ "Skip (leave as is)", "skip" ] ] : AdImport::ACTIONS.invert %>
<td><% choices = r.tracked ? [ [ t(".update"), "track" ], [ t(".not_applicable"), "na" ], [ t(".skip_leave_as_is"), "skip" ] ] : AdImport::ACTIONS.invert %>
<%= select_tag "decisions[#{r.number}]", options_for_select(choices, r.suggested), class: "input" %></td>
</tr>
<% end %>
@@ -48,7 +48,7 @@
</section>
<div class="flex gap-2">
<%= f.submit "Import ADs", class: "btn-primary", data: { turbo_confirm: "Import these ADs to #{@aircraft.tail_number}?" } %>
<%= link_to "Upload a different file", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary" %>
<%= f.submit t(".import_ads"), class: "btn-primary", data: { turbo_confirm: t(".import_these_ads_to", tail_number: @aircraft.tail_number) } %>
<%= link_to t(".upload_a_different_file"), new_aircraft_ad_import_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>
+42 -43
View File
@@ -1,78 +1,77 @@
<% content_for :title, "About" %>
<% content_for :title, t(".about") %>
<% info = @info %>
<h1 class="mb-1 text-2xl font-bold">About</h1>
<p class="mb-5 text-sm text-slate-500">Simple Aircraft Manager: what's running, and how it's set up.</p>
<h1 class="mb-1 text-2xl font-bold"><%= t(".about") %></h1>
<p class="mb-5 text-sm text-slate-500"><%= t(".simple_aircraft_manager_what_s") %></p>
<section class="card card-body mb-5">
<div class="flex flex-wrap items-end justify-between gap-4">
<div>
<p class="text-xs uppercase tracking-wide text-slate-500">Version</p>
<p class="text-xs uppercase tracking-wide text-slate-500"><%= t(".version") %></p>
<p class="font-mono text-2xl font-semibold" data-version><%= info.version %></p>
<p class="text-sm text-slate-600" data-revision>Build
<%= info.revision_url ? link_to(info.revision, info.revision_url, class: "link font-mono", target: "_blank", rel: "noopener", title: "This commit on GitHub") : tag.span(info.revision, class: "font-mono") %></p>
<p class="mt-1 flex flex-wrap gap-x-3 text-sm"><%= link_to "What's new", help_page_path("changelog"), class: "link" %><%= link_to "Disclaimer", help_page_path("disclaimer"), class: "link" %><% if info.repository_url %><%= link_to "Source code", info.repository_url, class: "link", target: "_blank", rel: "noopener" %><% end %></p>
<p class="text-sm text-slate-600" data-revision><%= t(".build_html", build: (info.revision_url ? link_to(info.revision, info.revision_url, class: "link font-mono", target: "_blank", rel: "noopener", title: t(".this_commit_on_github")) : tag.span(info.revision, class: "font-mono"))) %></p>
<p class="mt-1 flex flex-wrap gap-x-3 text-sm"><%= link_to t(".what_s_new"), help_page_path("changelog"), class: "link" %><%= link_to t(".disclaimer"), help_page_path("disclaimer"), class: "link" %><% if info.repository_url %><%= link_to t(".source_code"), info.repository_url, class: "link", target: "_blank", rel: "noopener" %><% end %></p>
</div>
<dl class="grid grid-cols-2 gap-x-6 gap-y-1 text-sm sm:grid-cols-3">
<div><dt class="text-slate-500">Built</dt><dd class="font-medium"><%= info.built_at ? fmt_time(info.built_at.in_time_zone) : "—" %></dd></div>
<div><dt class="text-slate-500">Started</dt><dd class="font-medium"><%= fmt_time(info.booted_at.in_time_zone) %></dd></div>
<div><dt class="text-slate-500">Uptime</dt><dd class="font-medium"><%= distance_of_time_in_words(info.booted_at, Time.current) %></dd></div>
<div><dt class="text-slate-500"><%= t(".built") %></dt><dd class="font-medium"><%= info.built_at ? fmt_time(info.built_at.in_time_zone) : "—" %></dd></div>
<div><dt class="text-slate-500"><%= t(".started") %></dt><dd class="font-medium"><%= fmt_time(info.booted_at.in_time_zone) %></dd></div>
<div><dt class="text-slate-500"><%= t(".uptime") %></dt><dd class="font-medium"><%= distance_of_time_in_words(info.booted_at, Time.current) %></dd></div>
</dl>
</div>
</section>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">Runtime</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".runtime") %></h2></div>
<%= render "pairs", pairs: info.runtime %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Features</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".features") %></h2></div>
<%= render "pairs", pairs: info.features %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Key components</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".key_components") %></h2></div>
<%= render "pairs", pairs: info.key_gems %>
</section>
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Storage</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".storage") %></h2></div>
<% s = info.storage %>
<%= render "pairs", pairs: [
[ "Uploaded files", "#{number_with_delimiter(s[:files])} (#{number_to_human_size(s[:bytes])})" ],
[ "Saved by storing duplicates once", number_to_human_size(s[:shared_bytes]) ],
[ "Free disk space", s[:free_bytes] && number_to_human_size(s[:free_bytes]) ]
[ t(".uploaded_files"), "#{number_with_delimiter(s[:files])} (#{number_to_human_size(s[:bytes])})" ],
[ t(".saved_by_storing_duplicates_once"), number_to_human_size(s[:shared_bytes]) ],
[ t(".free_disk_space"), s[:free_bytes] && number_to_human_size(s[:free_bytes]) ]
] + info.databases.map { |label, bytes| [ "#{label} database", bytes && number_to_human_size(bytes) ] } %>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title">Email</h2>
<%= button_to "Send test email", admin_test_email_path, class: "btn-secondary btn-sm", disabled: !MailSettings.configured?,
data: { turbo_submits_with: "Sending…" }, title: "Sends to #{current_user.email_address}" %>
<h2 class="card-title"><%= t(".email") %></h2>
<%= button_to t(".send_test_email"), admin_test_email_path, class: "btn-secondary btn-sm", disabled: !MailSettings.configured?,
data: { turbo_submits_with: t(".sending") }, title: t(".sends_to", email_address: current_user.email_address) %>
</div>
<%= render "pairs", pairs: MailSettings.summary.merge("Weekly reminders" => "Mondays, to owners who haven't turned them off") %>
<div class="px-4 pb-3"><%= button_to "Send me this week's reminder", admin_test_reminder_path, class: "btn-secondary btn-sm", disabled: !MailSettings.configured? %></div>
<%= render "pairs", pairs: MailSettings.summary.merge(t(".weekly_reminders") => t(".mondays_to_owners_who_haven")) %>
<div class="px-4 pb-3"><%= button_to t(".send_me_this_week_s"), admin_test_reminder_path, class: "btn-secondary btn-sm", disabled: !MailSettings.configured? %></div>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Background jobs</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".background_jobs") %></h2></div>
<% if (j = info.jobs) %>
<%= render "pairs", pairs: [
[ "Workers running", j[:workers].zero? ? tag.span("none", class: "badge-red") : j[:workers] ],
[ "Waiting", j[:ready] ], [ "Scheduled", j[:scheduled] ],
[ "Failed", j[:failed].positive? ? tag.span(j[:failed], class: "badge-orange") : 0 ]
[ t(".workers_running"), j[:workers].zero? ? tag.span("none", class: "badge-red") : j[:workers] ],
[ t(".waiting"), j[:ready] ], [ t(".scheduled"), j[:scheduled] ],
[ t(".failed"), j[:failed].positive? ? tag.span(j[:failed], class: "badge-orange") : 0 ]
] %>
<% else %>
<%= empty_state "Job queue not available." %>
<%= empty_state t(".job_queue_not_available") %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Records</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".records") %></h2></div>
<%= render "pairs", pairs: info.record_counts.transform_values { number_with_delimiter(_1) } %>
</section>
</div>
@@ -81,23 +80,23 @@
<section class="card mt-5" id="records">
<div class="card-header">
<div>
<h2 class="card-title">Records integrity</h2>
<p class="text-xs text-slate-500">Nightly: a verified database backup, then a check of the record history chains and every electronic signature (AC 120-78B 3.2).</p>
<h2 class="card-title"><%= t(".records_integrity") %></h2>
<p class="text-xs text-slate-500"><%= t(".nightly_a_verified_database_backup") %></p>
</div>
<%= button_to "Back up and check now", admin_check_records_path, class: "btn-secondary btn-sm", data: { turbo_submits_with: "Checking…" } %>
<%= button_to t(".back_up_and_check_now"), admin_check_records_path, class: "btn-secondary btn-sm", data: { turbo_submits_with: t(".checking") } %>
</div>
<% check = IntegrityCheck.latest %>
<% backup = BackupRun.latest %>
<%= render "pairs", pairs: [
[ "Last check", check ? "#{fmt_time(check.created_at)} · #{check.ok ? 'no problems' : pluralize(check.problems.size, 'problem')}" : "not run yet" ],
[ "Checked", check ? "#{number_with_delimiter(check.versions_checked)} history entries, #{number_with_delimiter(check.signatures_checked)} signatures" : nil ],
[ "Last backup", backup ? "#{fmt_time(backup.created_at)} · #{backup.ok ? number_to_human_size(backup.bytes) : 'FAILED'}" : "not run yet" ],
[ "Backup check", backup&.message ],
[ "Backups kept", "#{Setting.integer('backups_kept')} (in storage/backups)" ],
[ "Off-site backup", OffsiteConnection.connected? ? ((o = OffsiteRun.latest_backup) ? tag.span("#{o.ok ? 'OK' : 'FAILED'} #{fmt_date(o.created_at.to_date)}", class: (o.ok && o.recent? ? nil : "badge-orange")) + " · Google Drive (#{OffsiteConnection.current.account_email})" : "Google Drive connected, none yet") : link_to("not set up", admin_offsite_backup_path, class: "badge-orange") ],
[ "Procedures", (r = ProceduresRevision.current) ? "Revision #{r.number}, adopted #{fmt_date(r.adopted_at.to_date)}" : tag.span("not adopted", class: "badge-orange") ],
[ "Last audit", AuditRun.latest ? "#{fmt_date(AuditRun.latest.performed_at.to_date)} · #{AuditRun.latest.passed ? 'passed' : 'items not passed'}" : "none yet" ],
[ "Next audit due", AuditRun.due_soon? ? tag.span(fmt_date(AuditRun.next_due), class: "badge-orange") : fmt_date(AuditRun.next_due) ]
[ t(".last_check"), check ? "#{fmt_time(check.created_at)} · #{check.ok ? t(".no_problems") : t("counts.problem", count: check.problems.size)}" : t(".not_run_yet") ],
[ t(".checked"), check ? t(".checked_counts", versions: number_with_delimiter(check.versions_checked), signatures: number_with_delimiter(check.signatures_checked)) : nil ],
[ t(".last_backup"), backup ? "#{fmt_time(backup.created_at)} · #{backup.ok ? number_to_human_size(backup.bytes) : 'FAILED'}" : t(".not_run_yet") ],
[ t(".backup_check"), backup&.message ],
[ t(".backups_kept"), t(".in_storage_backups", backups_kept: (Setting.integer('backups_kept'))) ],
[ t(".off_site_backup"), OffsiteConnection.connected? ? ((o = OffsiteRun.latest_backup) ? tag.span("#{o.ok ? 'OK' : 'FAILED'} #{fmt_date(o.created_at.to_date)}", class: (o.ok && o.recent? ? nil : "badge-orange")) + t(".google_drive", account_email: OffsiteConnection.current.account_email) : t(".google_drive_connected_none_yet")) : link_to(t(".not_set_up"), admin_offsite_backup_path, class: "badge-orange") ],
[ t(".procedures"), (r = ProceduresRevision.current) ? t(".revision_adopted", number: r.number, to_date: (fmt_date(r.adopted_at.to_date))) : tag.span(t(".not_adopted"), class: "badge-orange") ],
[ t(".last_audit"), AuditRun.latest ? "#{fmt_date(AuditRun.latest.performed_at.to_date)} · #{AuditRun.latest.passed ? 'passed' : 'items not passed'}" : t(".none_yet") ],
[ t(".next_audit_due"), AuditRun.due_soon? ? tag.span(fmt_date(AuditRun.next_due), class: "badge-orange") : fmt_date(AuditRun.next_due) ]
] %>
<% if check && !check.ok %>
<ul class="list-disc space-y-1 px-8 pb-3 text-sm text-red-700"><% check.problems.each do |p| %><li><%= p %></li><% end %></ul>
@@ -105,17 +104,17 @@
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Software versions</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".software_versions") %></h2></div>
<% revisions = AppRevision.latest_first.limit(20) %>
<% if revisions.any? %>
<%= render "pairs", pairs: revisions.map { |r| [ [ r.version, "build #{r.revision}" ].compact.join(" · "), "#{fmt_time(r.first_seen_at)} – #{fmt_time(r.last_seen_at)}" ] } %>
<% else %>
<%= empty_state "No versions recorded yet." %>
<%= empty_state t(".no_versions_recorded_yet") %>
<% end %>
</section>
<details class="card mt-5">
<summary class="card-header cursor-pointer"><span class="card-title">All gems (<%= info.all_gems.size %>)</span></summary>
<summary class="card-header cursor-pointer"><span class="card-title"><%= t(".all_gems_html", all_gems: info.all_gems.size) %></span></summary>
<div class="grid gap-x-6 px-4 py-3 font-mono text-xs sm:grid-cols-2 lg:grid-cols-3">
<% info.all_gems.each do |name, version| %>
<div class="flex justify-between gap-2 py-0.5"><span class="truncate"><%= name %></span><span class="text-slate-500"><%= version %></span></div>
+8 -8
View File
@@ -1,16 +1,16 @@
<%= form_with model: [:admin, airport], class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :ident, label: "Code", required: true, hint: "The code you log, e.g. 0R8." %>
<%= f.field :ident, label: t(".code"), required: true, hint: t(".the_code_you_log_e") %>
<%= f.field :name, required: true, wrapper: { class: "sm:col-span-2" } %>
<%= f.field :kind, as: :select, label: "Type", collection: Airport::KINDS.map { [_1.humanize, _1] } %>
<%= f.field :municipality, label: "Town" %>
<%= f.field :region, placeholder: "US-RI", hint: "ISO region" %>
<%= f.field :kind, as: :select, label: t(".type"), collection: Airport::KINDS.map { [_1.humanize, _1] } %>
<%= f.field :municipality, label: t(".town") %>
<%= f.field :region, placeholder: t(".us_ri"), hint: t(".iso_region") %>
<%= f.field :latitude, as: :number, step: "any" %>
<%= f.field :longitude, as: :number, step: "any" %>
<%= f.field :elevation_ft, as: :number, label: "Elevation (ft)" %>
<%= f.field :elevation_ft, as: :number, label: t(".elevation_ft") %>
</div>
<p class="hint">Custom airports are kept when the database is updated from OurAirports. To sync flights at this airport to AirTrail, add it there too with the same code (or map it on your AirTrail sync page).</p>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", admin_airports_path, class: "btn-secondary" %></div>
<p class="hint"><%= t(".custom_airports_are_kept_when") %></p>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), admin_airports_path, class: "btn-secondary" %></div>
<% end %>
<% if airport.persisted? %><div class="mt-4"><%= delete_button "Remove #{airport.ident}", admin_airport_path(airport) %></div><% end %>
<% if airport.persisted? %><div class="mt-4"><%= delete_button t(".remove", ident: airport.ident), admin_airport_path(airport) %></div><% end %>
+1 -1
View File
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">Edit <%= @airport.ident %></h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".edit_html", ident: @airport.ident) %></h1>
<%= render "form", airport: @airport %>
+23 -23
View File
@@ -1,38 +1,38 @@
<% content_for :title, "Airports" %>
<% content_for :title, t(".airports") %>
<div class="mb-4 flex items-center justify-between">
<h1 class="text-2xl font-bold">Airports</h1>
<%= link_to "+ Custom Airport", new_admin_airport_path, class: "btn-primary" %>
<h1 class="text-2xl font-bold"><%= t(".airports") %></h1>
<%= link_to t(".custom_airport"), new_admin_airport_path, class: "btn-primary" %>
</div>
<div class="grid gap-5 lg:grid-cols-3">
<section class="card lg:col-span-2">
<div class="card-header">
<h2 class="card-title">Airport database</h2>
<h2 class="card-title"><%= t(".airport_database") %></h2>
<% if @running %>
<span class="badge-blue">Updating…</span>
<span class="badge-blue"><%= t(".updating") %></span>
<% else %>
<%= button_to "Update from OurAirports", refresh_admin_airports_path, class: "btn-secondary",
form: { data: { turbo_confirm: "Download the latest airport data from OurAirports? Custom airports are kept." } } %>
<%= button_to t(".update_from_ourairports"), refresh_admin_airports_path, class: "btn-secondary",
form: { data: { turbo_confirm: t(".download_the_latest_airport_data") } } %>
<% end %>
</div>
<div class="card-body space-y-3 text-sm">
<div class="grid grid-cols-3 gap-3 text-center">
<div><div class="text-2xl font-semibold"><%= number_with_delimiter(@total) %></div><div class="text-xs text-slate-500">airports</div></div>
<div><div class="text-2xl font-semibold"><%= @custom.size %></div><div class="text-xs text-slate-500">custom</div></div>
<div><div class="text-sm font-semibold"><%= @last_success ? "#{time_ago_in_words(@last_success.finished_at)} ago" : "never" %></div><div class="text-xs text-slate-500">last updated</div></div>
<div><div class="text-2xl font-semibold"><%= number_with_delimiter(@total) %></div><div class="text-xs text-slate-500"><%= t(".airports_2") %></div></div>
<div><div class="text-2xl font-semibold"><%= @custom.size %></div><div class="text-xs text-slate-500"><%= t(".custom") %></div></div>
<div><div class="text-sm font-semibold"><%= @last_success ? "#{time_ago_in_words(@last_success.finished_at)} ago" : "never" %></div><div class="text-xs text-slate-500"><%= t(".last_updated") %></div></div>
</div>
<% if @total.zero? %>
<p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200">No airport data yet. It downloads automatically when the app starts. Use “Update from OurAirports” if that didn't happen.</p>
<p class="rounded-md bg-amber-50 px-3 py-2 text-amber-900 ring-1 ring-amber-200"><%= t(".no_airport_data_yet_it") %></p>
<% end %>
<p class="hint">Airport data comes from <a href="https://ourairports.com/data/" class="link" target="_blank" rel="noopener noreferrer">OurAirports</a> (public domain), the same source AirTrail uses. It's used for From/To autocomplete and to match airport codes when syncing to AirTrail. Updates add new airports, apply changes and remove closed-out entries; custom airports are never changed.</p>
<p class="hint"><%= t(".airport_data_comes_from_ourairports_html") %></p>
<% if @updates.any? %>
<table class="table">
<thead><tr><th>Started</th><th>By</th><th>Status</th><th>Result</th></tr></thead>
<thead><tr><th><%= t(".started") %></th><th><%= t(".by") %></th><th><%= t(".status") %></th><th><%= t(".result") %></th></tr></thead>
<tbody>
<% @updates.each do |u| %>
<tr>
<td class="whitespace-nowrap text-xs"><%= fmt_time(u.created_at) %></td>
<td class="text-xs"><%= u.requested_by&.display_name || "Startup" %></td>
<td class="text-xs"><%= u.requested_by&.display_name || t(".startup") %></td>
<td><%= tag.span u.status.capitalize, class: { "done" => "badge-green", "failed" => "badge-red" }.fetch(u.status, "badge-blue") %></td>
<td class="text-xs"><%= u.done? ? u.summary : u.error %></td>
</tr>
@@ -44,22 +44,22 @@
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Look up</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".look_up") %></h2></div>
<div class="card-body space-y-2">
<%= form_with url: admin_airports_path, method: :get, class: "flex gap-2" do |f| %>
<%= f.search_field :q, value: @query, class: "input", placeholder: "Code or name" %>
<%= f.submit "Search", class: "btn-secondary" %>
<%= f.search_field :q, value: @query, class: "input", placeholder: t(".code_or_name") %>
<%= f.submit t(".search"), class: "btn-secondary" %>
<% end %>
<% if @query.present? %>
<% if @results.any? %>
<ul class="divide-y divide-slate-100 text-sm">
<% @results.each do |a| %>
<li class="py-1.5"><span class="font-mono font-semibold"><%= a.code %></span> <%= a.name %>
<div class="text-xs text-slate-500"><%= [a.place, "AirTrail #{a.airtrail_code}", (a.custom? ? "custom" : nil), Airport::KIND_LABELS[a.kind]].compact_blank.join(" · ") %></div></li>
<div class="text-xs text-slate-500"><%= [a.place, t(".airtrail", airtrail_code: a.airtrail_code), (a.custom? ? "custom" : nil), Airport::KIND_LABELS[a.kind]].compact_blank.join(" · ") %></div></li>
<% end %>
</ul>
<% else %>
<p class="text-sm text-slate-600">No match for “<%= @query %>”. <%= link_to "Add it as a custom airport", new_admin_airport_path(ident: @query.upcase), class: "link" %>.</p>
<p class="text-sm text-slate-600"><%= t(".no_match_for_html", query: @query, link: (link_to t(".add_it_as_a_custom"), new_admin_airport_path(ident: @query.upcase), class: "link")) %></p>
<% end %>
<% end %>
</div>
@@ -67,21 +67,21 @@
</div>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Custom airports</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".custom_airports") %></h2></div>
<% if @custom.any? %>
<table class="table">
<thead><tr><th>Code</th><th>Name</th><th>Location</th><th>Type</th><th></th></tr></thead>
<thead><tr><th><%= t(".code") %></th><th><%= t(".name") %></th><th><%= t(".location") %></th><th><%= t(".type") %></th><th></th></tr></thead>
<tbody>
<% @custom.each do |a| %>
<tr>
<td class="font-mono font-semibold"><%= a.ident %></td><td><%= a.name %></td><td class="text-xs"><%= a.place %></td>
<td class="text-xs"><%= a.kind.to_s.humanize %></td>
<td class="text-right"><%= link_to "Edit", edit_admin_airport_path(a), class: "btn-secondary btn-sm" %></td>
<td class="text-right"><%= link_to t(".edit"), edit_admin_airport_path(a), class: "btn-secondary btn-sm" %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "None. Add private strips or fields that aren't in OurAirports." %>
<%= empty_state t(".none_add_private_strips_or") %>
<% end %>
</section>
+1 -1
View File
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">New Custom Airport</h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".new_custom_airport") %></h1>
<%= render "form", airport: @airport %>
+6 -6
View File
@@ -1,10 +1,10 @@
<% content_for :title, "Records audits" %>
<% content_for :title, t(".records_audits") %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-2">
<div>
<h1 class="text-2xl font-bold">Records audits</h1>
<p class="text-sm text-slate-600">Quality-control audits of the electronic records (AC 120-78B 3.2.8.5), every <%= RecordkeepingPolicy.current.audit_interval_months %> months. Next due <strong class="<%= AuditRun.due_soon? ? 'text-amber-700' : '' %>"><%= AuditRun.next_due %></strong>.</p>
<h1 class="text-2xl font-bold"><%= t(".records_audits") %></h1>
<p class="text-sm text-slate-600"><%= t(".quality_control_audits_of_the_html", audit_interval_months: RecordkeepingPolicy.current.audit_interval_months) %> <strong class="<%= AuditRun.due_soon? ? 'text-amber-700' : '' %>"><%= AuditRun.next_due %></strong>.</p>
</div>
<%= link_to "Start an audit", new_admin_audit_path, class: "btn-primary" %>
<%= link_to t(".start_an_audit"), new_admin_audit_path, class: "btn-primary" %>
</div>
<section class="card">
<% if @audits.any? %>
@@ -12,9 +12,9 @@
<% @audits.each do |a| %>
<li class="flex items-center justify-between px-4 py-2">
<span><%= link_to fmt_date(a.performed_at.to_date), admin_audit_path(a), class: "link" %> · <%= a.performed_by&.display_name %></span>
<span class="<%= a.passed ? 'badge-green' : 'badge-orange' %>"><%= a.passed ? "Passed" : "Items not passed" %></span>
<span class="<%= a.passed ? 'badge-green' : 'badge-orange' %>"><%= a.passed ? t(".passed") : t(".items_not_passed") %></span>
</li>
<% end %>
</ul>
<% else %><%= empty_state "No audits yet." %><% end %>
<% else %><%= empty_state t(".no_audits_yet") %><% end %>
</section>
+14 -14
View File
@@ -1,12 +1,12 @@
<% content_for :title, "Records audit" %>
<h1 class="mb-1 text-2xl font-bold">Records audit</h1>
<p class="mb-5 text-sm text-slate-600">Work through each item; the app has checked the first ones itself.</p>
<% content_for :title, t(".records_audit") %>
<h1 class="mb-1 text-2xl font-bold"><%= t(".records_audit") %></h1>
<p class="mb-5 text-sm text-slate-600"><%= t(".work_through_each_item_the") %></p>
<%= form_with url: admin_audits_path, class: "space-y-5" do %>
<section class="card">
<div class="card-header"><h2 class="card-title">Checked by the app</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".checked_by_the_app") %></h2></div>
<ul class="divide-y divide-slate-100 text-sm">
<% @audit.auto_items.each do |item| %>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= item.passed ? 'badge-green' : 'badge-red' %>"><%= item.passed ? "Pass" : "Fail" %></span>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= item.passed ? 'badge-green' : 'badge-red' %>"><%= item.passed ? t(".pass") : t(".fail") %></span>
<span><span class="font-medium"><%= item.title %></span><span class="block text-xs text-slate-500"><%= item.detail %></span></span></li>
<% end %>
</ul>
@@ -14,32 +14,32 @@
<% sample = @audit.sample %>
<section class="card">
<div class="card-header"><h2 class="card-title">Confirmed by you</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".confirmed_by_you") %></h2></div>
<div class="space-y-4 p-4">
<% RecordsAudit::MANUAL.each do |key, title| %>
<div class="space-y-2 rounded-md p-3 ring-1 ring-slate-200">
<label class="flex items-start gap-2 text-sm font-medium"><%= check_box_tag "answers[#{key}][passed]", "1", false, class: "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300" %><span><%= title %></span></label>
<% if key == "restore_test" && OffsiteConnection.connected? %>
<p class="ml-6 text-xs text-slate-600">
<% if (rt = @audit.restore_test) %>Last automatic restore test (<%= fmt_date(rt.created_at.to_date) %>): <span class="<%= rt.ok ? 'badge-green' : 'badge-red' %>"><%= rt.ok ? "OK" : "Failed" %></span> <%= rt.message %><% else %>No automatic restore test yet.<% end %>
<%= link_to "Run one", admin_offsite_backup_path, class: "link", target: "_blank" %> (Admin → Off-site Backup → Test restore), then also open a copy downloaded from Google Drive yourself.
<% if (rt = @audit.restore_test) %><%= t(".last_automatic_restore_test_html", to_date: (fmt_date(rt.created_at.to_date))) %> <span class="<%= rt.ok ? 'badge-green' : 'badge-red' %>"><%= rt.ok ? "OK" : t(".failed") %></span> <%= rt.message %><% else %><%= t(".no_automatic_restore_test_yet") %><% end %>
<%= t(".admin_off_site_backup_test_html", link: (link_to t(".run_one"), admin_offsite_backup_path, class: "link", target: "_blank")) %>
</p>
<% end %>
<% if key == "sample" %>
<ul class="ml-6 list-disc text-xs text-slate-600">
<% sample.each do |e| %><li><%= hidden_field_tag "sample_ids[]", e.id, id: nil %><%= link_to "#{e.aircraft.tail_number} · #{fmt_date(e.date)} · #{e.text.truncate(80)}", aircraft_logbook_entry_path(e.aircraft, e), class: "link", target: "_blank" %><%= " (signed)" if e.signature %></li><% end %>
<% if sample.empty? %><li>No entries since the last audit.</li><% end %>
<% sample.each do |e| %><li><%= hidden_field_tag "sample_ids[]", e.id, id: nil %><%= link_to "#{e.aircraft.tail_number} · #{fmt_date(e.date)} · #{e.text.truncate(80)}", aircraft_logbook_entry_path(e.aircraft, e), class: "link", target: "_blank" %><%= t(".signed") if e.signature %></li><% end %>
<% if sample.empty? %><li><%= t(".no_entries_since_the_last") %></li><% end %>
</ul>
<% elsif key == "users" %>
<ul class="ml-6 list-disc text-xs text-slate-600">
<% @audit.users.each do |u| %><li><%= u.display_name %> (<%= u.email_address %>)<%= " · admin" if u.admin? %><%= " · #{u.aircraft_roles.map { "#{_1.role} #{_1.aircraft.tail_number}" }.join(', ')}" if u.aircraft_roles.any? %> · last sign-in <%= u.last_signed_in_at ? time_ago_in_words(u.last_signed_in_at) + " ago" : "never" %><%= " · DISABLED" if u.disabled? %></li><% end %>
<% @audit.users.each do |u| %><li><%= t(".last_sign_in_html", display_name: u.display_name, email_address: u.email_address, admin: (t(".admin") if u.admin?), any: (" · #{u.aircraft_roles.map { "#{AircraftRole::ROLES[_1.role]} #{_1.aircraft.tail_number}" }.join(', ')}" if u.aircraft_roles.any?), never: (u.last_signed_in_at ? t(".ago", time: time_ago_in_words(u.last_signed_in_at)) : t(".never")), disabled: (t(".disabled") if u.disabled?)) %></li><% end %>
</ul>
<% end %>
<%= text_field_tag "answers[#{key}][note]", nil, class: "input", placeholder: "Note (what was checked, or what's being done)" %>
<%= text_field_tag "answers[#{key}][note]", nil, class: "input", placeholder: t(".note_what_was_checked_or") %>
</div>
<% end %>
<div><%= label_tag :notes, "Overall notes", class: "label" %><%= text_area_tag :notes, nil, rows: 3, class: "input" %></div>
<%= submit_tag "Record audit", class: "btn-primary" %>
<div><%= label_tag :notes, t(".overall_notes"), class: "label" %><%= text_area_tag :notes, nil, rows: 3, class: "input" %></div>
<%= submit_tag t(".record_audit"), class: "btn-primary" %>
</div>
</section>
<% end %>
+6 -6
View File
@@ -1,14 +1,14 @@
<% content_for :title, "Records audit" %>
<h1 class="mb-1 text-2xl font-bold">Records audit, <%= fmt_date(@audit.performed_at.to_date) %></h1>
<p class="mb-4 text-sm text-slate-600">By <%= @audit.performed_by&.display_name %> · <span class="<%= @audit.passed ? 'badge-green' : 'badge-orange' %>"><%= @audit.passed ? "Passed" : "Items not passed" %></span></p>
<% content_for :title, t(".records_audit") %>
<h1 class="mb-1 text-2xl font-bold"><%= t(".records_audit_2_html", to_date: (fmt_date(@audit.performed_at.to_date))) %></h1>
<p class="mb-4 text-sm text-slate-600"><%= t(".by_html", display_name: @audit.performed_by&.display_name) %> <span class="<%= @audit.passed ? 'badge-green' : 'badge-orange' %>"><%= @audit.passed ? t(".passed") : t(".items_not_passed") %></span></p>
<section class="card">
<ul class="divide-y divide-slate-100 text-sm">
<% @audit.results.each do |r| %>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= r['passed'] ? 'badge-green' : 'badge-red' %>"><%= r["passed"] ? "Pass" : "Fail" %></span>
<span><span class="font-medium"><%= r["title"] %></span><%= tag.span(" (checked by the app)", class: "text-xs text-slate-500") if r["auto"] %>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= r['passed'] ? 'badge-green' : 'badge-red' %>"><%= r["passed"] ? t(".pass") : t(".fail") %></span>
<span><span class="font-medium"><%= r["title"] %></span><%= tag.span(t(".checked_by_the_app"), class: "text-xs text-slate-500") if r["auto"] %>
<% if r["detail"].present? %><span class="block text-xs text-slate-600"><%= r["detail"] %></span><% end %></span></li>
<% end %>
</ul>
<% if @audit.notes.present? %><div class="whitespace-pre-wrap border-t border-slate-100 px-4 py-3 text-sm"><%= @audit.notes %></div><% end %>
</section>
<p class="mt-4"><%= link_to "All audits", admin_audits_path, class: "link" %></p>
<p class="mt-4"><%= link_to t(".all_audits"), admin_audits_path, class: "link" %></p>
@@ -1,7 +1,7 @@
<%= form_with model: [:admin, component_type], class: "card card-body space-y-4 max-w-md" do |f| %>
<%= f.errors_summary %>
<%= f.field :name, required: true %>
<%= f.field :consumable, as: :checkbox, label: "Consumable (oil filter, spark plugs…)" %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", admin_component_types_path, class: "btn-secondary" %></div>
<%= f.field :consumable, as: :checkbox, label: t(".consumable_oil_filter_spark_plugs") %>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), admin_component_types_path, class: "btn-secondary" %></div>
<% end %>
<% if component_type.persisted? %><div class="mt-4"><%= delete_button "Delete type", admin_component_type_path(component_type) %></div><% end %>
<% if component_type.persisted? %><div class="mt-4"><%= delete_button t(".delete_type"), admin_component_type_path(component_type) %></div><% end %>
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">Edit Component Type</h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".edit_component_type") %></h1>
<%= render "form", component_type: @component_type %>
@@ -1,7 +1,7 @@
<% content_for :title, "Component Types" %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold">Component Types</h1><%= link_to "+ New Type", new_admin_component_type_path, class: "btn-primary" %></div>
<% content_for :title, t(".component_types") %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold"><%= t(".component_types") %></h1><%= link_to t(".new_type"), new_admin_component_type_path, class: "btn-primary" %></div>
<section class="card"><table class="table">
<thead><tr><th>Name</th><th>Consumable</th><th></th></tr></thead>
<tbody><% @component_types.each do |t| %><tr><td><%= t.name %></td><td><%= "Yes" if t.consumable? %></td>
<td class="text-right"><%= link_to "Edit", edit_admin_component_type_path(t), class: "btn-secondary btn-sm" %></td></tr><% end %></tbody>
<thead><tr><th><%= t(".name") %></th><th><%= t(".consumable") %></th><th></th></tr></thead>
<tbody><% @component_types.each do |t| %><tr><td><%= t.name %></td><td><%= t(".yes") if t.consumable? %></td>
<td class="text-right"><%= link_to t(".edit"), edit_admin_component_type_path(t), class: "btn-secondary btn-sm" %></td></tr><% end %></tbody>
</table></section>
+1 -1
View File
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">New Component Type</h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".new_component_type") %></h1>
<%= render "form", component_type: @component_type %>
@@ -1,17 +1,17 @@
<%= form_with model: [ :admin, template ], class: "card card-body max-w-3xl space-y-4" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :name, required: true, placeholder: "Oil and filter change" %>
<%= f.field :reference, placeholder: "Part 43 App. A (c)(6)", hint: "Shown next to the name, e.g. the regulation or manual paragraph." %>
<%= f.field :name, required: true, placeholder: t(".oil_and_filter_change") %>
<%= f.field :reference, placeholder: t(".part_43_app_a_c"), hint: t(".shown_next_to_the_name") %>
</div>
<%= f.field :text, as: :textarea, rows: 5, required: true, hint: "The entry text. Use __ for blanks to fill in (quantities, part numbers…)." %>
<%= f.field :text, as: :textarea, rows: 5, required: true, hint: t(".the_entry_text_use_for") %>
<div class="grid gap-4 sm:grid-cols-4">
<%= f.field :entry_type, as: :select, label: "Entry type", collection: LogbookEntry::ENTRY_TYPES.invert %>
<%= f.field :log_type, as: :select, label: "Logbook", include_blank: "— Leave as is —", collection: LogbookEntry::LOG_TYPES.invert %>
<%= f.field :certificate_type, as: :select, label: "Kind of certificate", include_blank: "— Leave as is —", collection: LogbookEntry::CERTIFICATE_TYPES.invert,
hint: "Only filled in when none is chosen yet." %>
<%= f.field :position, as: :number, label: "Order" %>
<%= f.field :entry_type, as: :select, label: t(".entry_type"), collection: LogbookEntry::ENTRY_TYPES.invert %>
<%= f.field :log_type, as: :select, label: t(".logbook"), include_blank: t(".leave_as_is"), collection: LogbookEntry::LOG_TYPES.invert %>
<%= f.field :certificate_type, as: :select, label: t(".kind_of_certificate"), include_blank: t(".leave_as_is"), collection: LogbookEntry::CERTIFICATE_TYPES.invert,
hint: t(".only_filled_in_when_none") %>
<%= f.field :position, as: :number, label: t(".order") %>
</div>
<div class="flex gap-2"><%= f.submit "Save Template" %><%= link_to "Cancel", admin_logbook_templates_path, class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save_template") %><%= link_to t(".cancel"), admin_logbook_templates_path, class: "btn-secondary" %></div>
<% end %>
<% if template.persisted? %><div class="mt-4"><%= delete_button "Delete template", admin_logbook_template_path(template) %></div><% end %>
<% if template.persisted? %><div class="mt-4"><%= delete_button t(".delete_template"), admin_logbook_template_path(template) %></div><% end %>
@@ -1,3 +1,3 @@
<% content_for :title, "Logbook template" %>
<h1 class="mb-4 text-2xl font-bold">Logbook template</h1>
<% content_for :title, t(".logbook_template") %>
<h1 class="mb-4 text-2xl font-bold"><%= t(".logbook_template") %></h1>
<%= render "form", template: @template %>
@@ -1,12 +1,12 @@
<% content_for :title, "Logbook templates" %>
<% content_for :title, t(".logbook_templates") %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-2">
<h1 class="text-2xl font-bold">Logbook templates</h1>
<h1 class="text-2xl font-bold"><%= t(".logbook_templates") %></h1>
<div class="flex gap-2">
<%= button_to "Restore built-in templates", restore_admin_logbook_templates_path, class: "btn-secondary", title: "Add back any of the built-in preventive maintenance templates that were deleted" %>
<%= link_to "+ New Template", new_admin_logbook_template_path, class: "btn-primary" %>
<%= button_to t(".restore_built_in_templates"), restore_admin_logbook_templates_path, class: "btn-secondary", title: t(".add_back_any_of_the") %>
<%= link_to t(".new_template"), new_admin_logbook_template_path, class: "btn-primary" %>
</div>
</div>
<p class="mb-4 text-sm text-slate-600">Wording to start a logbook entry from: the "Template" list on a new entry. Use __ for blanks to fill in.</p>
<p class="mb-4 text-sm text-slate-600"><%= t(".wording_to_start_a_logbook") %></p>
<section class="card">
<% if @templates.any? %>
<ul class="divide-y divide-slate-100">
@@ -17,11 +17,11 @@
<div class="text-xs text-slate-500"><%= [ LogbookEntry::ENTRY_TYPES[t.entry_type], (t.log_type && "#{LogbookEntry::LOG_TYPES[t.log_type]} log"), (t.certificate_type && LogbookEntry::CERTIFICATE_TYPES[t.certificate_type]) ].compact.join(" · ") %></div>
<p class="mt-1 text-xs text-slate-600"><%= t.text.truncate(220) %></p>
</div>
<%= link_to "Edit", edit_admin_logbook_template_path(t), class: "btn-secondary btn-sm" %>
<%= link_to t(".edit"), edit_admin_logbook_template_path(t), class: "btn-secondary btn-sm" %>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No templates." %>
<%= empty_state t(".no_templates") %>
<% end %>
</section>
@@ -1,3 +1,3 @@
<% content_for :title, "Logbook template" %>
<h1 class="mb-4 text-2xl font-bold">Logbook template</h1>
<% content_for :title, t(".logbook_template") %>
<h1 class="mb-4 text-2xl font-bold"><%= t(".logbook_template") %></h1>
<%= render "form", template: @template %>
+31 -31
View File
@@ -1,59 +1,59 @@
<% content_for :title, "Off-site backup" %>
<h1 class="mb-1 text-2xl font-bold">Off-site backup</h1>
<p class="mb-5 max-w-3xl text-sm text-slate-600">Every night, after the verified database backup, the app copies it to Google Drive with every uploaded file not already there, so the records survive losing this server (AC 120-78B 3.2.7). The newest <%= Setting.integer("offsite_backups_kept") %> database copies are kept (<%= link_to "Settings", edit_admin_settings_path, class: "link" %>); uploaded files are copied once and never deleted there. The app can only see the files it created in your Drive.</p>
<% content_for :title, t(".off_site_backup") %>
<h1 class="mb-1 text-2xl font-bold"><%= t(".off_site_backup") %></h1>
<p class="mb-5 max-w-3xl text-sm text-slate-600"><%= t(".every_night_after_the_verified_html", offsite_backups_kept: (Setting.integer("offsite_backups_kept")), link: (link_to t(".settings"), edit_admin_settings_path, class: "link")) %></p>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card card-body space-y-3">
<h2 class="card-title">Google Drive</h2>
<h2 class="card-title"><%= t(".google_drive") %></h2>
<% if @connection.connected? %>
<p class="text-sm"><span class="badge-green">Connected</span> <strong><%= @connection.account_email %></strong>, by <%= @connection.connected_by&.display_name %> on <%= fmt_date(@connection.connected_at&.to_date) %>.
Folder: <em><%= OffsiteConnection::ROOT_FOLDER %></em>.</p>
<p class="text-sm">Uploaded files copied: <%= @files_copied %> of <%= @files_total %>.</p>
<p class="text-sm"><span class="badge-green"><%= t(".connected") %></span> <%= t(".by_on_html", account_email: @connection.account_email, display_name: @connection.connected_by&.display_name, to_date: (fmt_date(@connection.connected_at&.to_date))) %>
<%= t(".folder_html", folder: (OffsiteConnection::ROOT_FOLDER)) %></p>
<p class="text-sm"><%= t(".uploaded_files_copied_of_html", files_copied: @files_copied, files_total: @files_total) %></p>
<div class="flex flex-wrap gap-2">
<%= button_to "Back up now", backup_now_admin_offsite_backup_path, class: "btn-primary" %>
<%= button_to "Test restore", restore_test_admin_offsite_backup_path, class: "btn-secondary",
title: "Download the newest database copy and a few files from Drive and check them" %>
<%= button_to "Disconnect", admin_offsite_backup_path, method: :delete, class: "btn-secondary",
form: { data: { turbo_confirm: "Stop copying backups to #{@connection.account_email}? The copies already there stay in that Drive." } } %>
<%= button_to t(".back_up_now"), backup_now_admin_offsite_backup_path, class: "btn-primary" %>
<%= button_to t(".test_restore"), restore_test_admin_offsite_backup_path, class: "btn-secondary",
title: t(".download_the_newest_database_copy") %>
<%= button_to t(".disconnect"), admin_offsite_backup_path, method: :delete, class: "btn-secondary",
form: { data: { turbo_confirm: t(".stop_copying_backups_to_the", account_email: @connection.account_email) } } %>
</div>
<% elsif @connection.configured? %>
<p class="text-sm">The OAuth client is saved. Connect the Google account whose Drive will hold the backups.</p>
<%= link_to "Connect Google Drive", connect_admin_offsite_backup_path, class: "btn-primary self-start", data: { turbo: false } %>
<p class="text-sm"><%= t(".the_oauth_client_is_saved") %></p>
<%= link_to t(".connect_google_drive"), connect_admin_offsite_backup_path, class: "btn-primary self-start", data: { turbo: false } %>
<% else %>
<p class="text-sm text-amber-800">Not set up. Follow the steps to create a Google OAuth client, then connect.</p>
<p class="text-sm text-amber-800"><%= t(".not_set_up_follow_the") %></p>
<% end %>
<%= form_with model: @connection, url: admin_offsite_backup_path, method: :patch, class: "space-y-3 border-t border-slate-100 pt-3" do |f| %>
<%= f.field :client_id, label: "OAuth client ID", placeholder: "1234567890-abc.apps.googleusercontent.com" %>
<%= f.field :client_secret, as: :password, label: "OAuth client secret", value: nil,
placeholder: (@connection.client_secret.present? ? "saved (leave blank to keep)" : nil), autocomplete: "off" %>
<%= f.submit "Save client", class: "btn-secondary" %>
<%= f.field :client_id, label: t(".oauth_client_id"), placeholder: "1234567890-abc.apps.googleusercontent.com" %>
<%= f.field :client_secret, as: :password, label: t(".oauth_client_secret"), value: nil,
placeholder: (@connection.client_secret.present? ? t(".saved_leave_blank_to_keep") : nil), autocomplete: "off" %>
<%= f.submit t(".save_client"), class: "btn-secondary" %>
<% end %>
</section>
<section class="card card-body space-y-2 text-sm">
<h2 class="card-title">Setting up Google (once)</h2>
<h2 class="card-title"><%= t(".setting_up_google_once") %></h2>
<ol class="list-decimal space-y-1.5 pl-5">
<li>Open the <a class="link" href="https://console.cloud.google.com/projectcreate" target="_blank" rel="noopener">Google Cloud console</a> signed in as the account that will hold the backups, and create a project (e.g. “Aircraft records backup”).</li>
<li><a class="link" href="https://console.cloud.google.com/apis/library/drive.googleapis.com" target="_blank" rel="noopener">Enable the Google Drive API</a> for it.</li>
<li>Under <strong>Google Auth Platform → Branding</strong>, give the app a name and your email; under <strong>Audience</strong> choose <strong>External</strong> and then <strong>Publish app</strong> (in “Testing”, Google expires the access after 7 days). Google doesn't need to verify it: the app only asks for access to files it creates.</li>
<li>Under <strong>Clients</strong>, create an <strong>OAuth client ID</strong> of type <strong>Web application</strong> with this authorized redirect URI:
<li><%= t(".open_the_google_cloud_console_html") %></li>
<li><%= t(".enable_the_google_drive_api_html") %></li>
<li><%= t(".under_google_auth_platform_branding_html") %></li>
<li><%= t(".under_clients_create_an_oauth_html") %>
<code class="mt-1 block break-all rounded bg-slate-100 px-2 py-1"><%= @connection.redirect_uri %></code>
(It must be the address you open the app at; set <code>APP_URL</code> if it isn't.)</li>
<li>Paste the client ID and secret here, save, and choose <strong>Connect Google Drive</strong>. Google will warn that the app isn't verified: choose <strong>Advanced → Go to …</strong> and allow access.</li>
<%= t(".it_must_be_the_address_html") %></li>
<li><%= t(".paste_the_client_id_and_html") %></li>
</ol>
<p class="text-slate-600">Restoring: see <%= link_to "Help → Administration", help_page_path("administration", anchor: "restoring-from-google-drive"), class: "link" %>.</p>
<p class="text-slate-600"><%= t(".restoring_see_html", link: (link_to t(".help_administration"), help_page_path("administration", anchor: "restoring-from-google-drive"), class: "link")) %></p>
</section>
</div>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Recent runs</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".recent_runs") %></h2></div>
<% if @runs.any? %>
<ul class="divide-y divide-slate-100 text-sm">
<% @runs.each do |r| %>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= r.ok ? 'badge-green' : 'badge-red' %>"><%= r.ok ? "OK" : "Failed" %></span>
<span><span class="font-medium"><%= r.kind == "restore_test" ? "Restore test" : "Backup" %></span> · <%= fmt_time(r.created_at.in_time_zone) %><span class="block text-xs text-slate-600"><%= r.message %></span></span></li>
<li class="flex items-start gap-3 px-4 py-2"><span class="<%= r.ok ? 'badge-green' : 'badge-red' %>"><%= r.ok ? "OK" : t(".failed") %></span>
<span><span class="font-medium"><%= r.kind == "restore_test" ? t(".restore_test") : t(".backup") %></span> · <%= fmt_time(r.created_at.in_time_zone) %><span class="block text-xs text-slate-600"><%= r.message %></span></span></li>
<% end %>
</ul>
<% else %><%= empty_state "None yet." %><% end %>
<% else %><%= empty_state t(".none_yet") %><% end %>
</section>
+61 -61
View File
@@ -7,111 +7,111 @@
<% p_ = "mt-1 text-sm leading-relaxed" %>
<article class="text-slate-900">
<header class="border-b-2 border-slate-800 pb-3">
<p class="text-xs uppercase tracking-wide text-slate-500">Standalone procedures document · AC 120-78B paragraphs 2.2.11 and 3.2.8</p>
<h1 class="text-2xl font-bold">Electronic Signature and Recordkeeping Procedures</h1>
<p class="text-sm text-slate-600"><%= policy.operator_name.presence || "[Operator]" %> · Simple Aircraft Manager</p>
<p class="mt-1 text-sm"><strong>Revision <%= number %></strong><%= adopted_at ? " · adopted #{adopted_at.to_date.iso8601} by #{adopted_by&.display_name}" : " · not yet adopted" %></p>
<p class="text-xs uppercase tracking-wide text-slate-500"><%= t(".standalone_procedures_document_ac_120") %></p>
<h1 class="text-2xl font-bold"><%= t(".electronic_signature_and_recordkeeping_procedure") %></h1>
<p class="text-sm text-slate-600"><%= t(".simple_aircraft_manager_html", operator: (policy.operator_name.presence || t(".operator"))) %></p>
<p class="mt-1 text-sm"><%= t(".revision_html", number: number, adopted: (adopted_at ? t(".adopted_by", date: adopted_at.to_date.iso8601, display_name: adopted_by&.display_name) : t(".not_yet_adopted"))) %></p>
</header>
<h2 class="<%= h2 %>">1. Purpose and scope</h2>
<p class="<%= p_ %>">These procedures describe how <%= policy.operator_name.presence || "[Operator]" %> keeps the maintenance records required by 14 CFR 91.417 electronically in Simple Aircraft Manager, and how entries are signed electronically under 14 CFR 43.9 and 43.11. They follow FAA AC 120-78B. Under its paragraph 1.9.5, use of electronic signatures and recordkeeping under part 91 (other than subpart K) needs no FAA approval, acceptance or authorization; the FAA recommends following the AC, and these procedures do.</p>
<h2 class="<%= h2 %>"><%= t(".n1_purpose_and_scope") %></h2>
<p class="<%= p_ %>"><%= t(".these_procedures_describe_how_keeps_html", operator: (policy.operator_name.presence || t(".operator"))) %></p>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1">Aircraft</th><th>Serial number</th><th>Electronic records since</th><th>Earlier records</th></tr></thead>
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".aircraft") %></th><th><%= t(".serial_number") %></th><th><%= t(".electronic_records_since") %></th><th><%= t(".earlier_records") %></th></tr></thead>
<tbody>
<% aircraft.each do |a| %>
<tr class="border-b border-slate-100"><td class="py-1"><%= a.tail_number %> <%= [ a.make, a.model ].compact_blank.join(" ") %></td><td><%= a.serial_number.presence || "—" %></td>
<td><%= a.electronic_records_since || "not set" %></td><td>Paper logbooks<%= " (scans held as legacy records)" if a.documents.where(legacy_record: true).exists? %></td></tr>
<td><%= a.electronic_records_since || t(".not_set") %></td><td><%= t(".paper_logbooks_html", legacy: (t(".scans_held_as_legacy_records") if a.documents.where(legacy_record: true).exists?)) %></td></tr>
<% end %>
</tbody>
</table>
<p class="<%= p_ %>">Records kept electronically: logbook entries (maintenance, preventive maintenance, inspections, alterations), inspection status and history, airworthiness directive compliance, component times and life limits, major repairs and alterations with their Form 337s, weight and balance, and supporting documents. Paper logbooks from before the date above remain the record for that period and are kept.</p>
<p class="<%= p_ %>"><%= t(".records_kept_electronically_logbook_entries") %></p>
<h2 class="<%= h2 %>">2. Regulatory compliance</h2>
<p class="<%= p_ %>">Each logbook entry carries what 14 CFR 43.9 requires (description of the work, date, the name, certificate number and kind of certificate of the person approving return to service, and their signature) and, for inspections, what 43.11 requires (type and extent of inspection, aircraft time in service, and the airworthiness statement or discrepancy list). The app flags entries missing any of these. Records include the key elements of AC 120-78B 3.1.1: the event, when (date, and the signature's time), where (location), who, the signature, and the make, model and serial of the aircraft, engine, propeller and components. The status required by 91.417(a)(2) is produced by the maintenance status report. Records are made available under 91.417(c) and transferred under 91.419 as described in sections 9 and 10.</p>
<h2 class="<%= h2 %>"><%= t(".n2_regulatory_compliance") %></h2>
<p class="<%= p_ %>"><%= t(".each_logbook_entry_carries_what") %></p>
<h2 class="<%= h2 %>">3. System description</h2>
<h2 class="<%= h2 %>"><%= t(".n3_system_description") %></h2>
<ul class="<%= p_ %> list-disc pl-5">
<li><strong>Software:</strong> Simple Aircraft Manager, version <%= info.version_label %> (Ruby <%= RUBY_VERSION %>, Rails <%= Rails.version %>, SQLite <%= SQLite3::SQLITE_VERSION %>).</li>
<li><strong>Hosting and network:</strong>
<% if policy.hosting_description.present? %><div class="mt-1"><%= markdown(policy.hosting_description) %></div><% else %>[describe the server, location and network]<% end %>
<p class="mt-1"><%= ProceduresTemplates.https? ? "Connections use HTTPS only: the system redirects plain HTTP and marks its cookies secure." : "The system is set not to enforce HTTPS itself (FORCE_SSL=false); how connections are protected is described above." %> <%= ProceduresTemplates.sign_in_sentence %></p></li>
<li><strong>Data:</strong> one SQLite database plus uploaded files (stored once per identical file) on the server's storage volume.</li>
<li><strong>Backups:</strong> every night the app makes a verified copy of the database in the storage volume (SQLite integrity check and record counts compared) and keeps the newest <%= Setting.integer("backups_kept") %>. Off-site: <% if OffsiteConnection.connected? %>after each nightly backup the app copies the verified database snapshot (compressed) to Google Drive (account <%= OffsiteConnection.current.account_email %>, folder “<%= OffsiteConnection::ROOT_FOLDER %>”), keeping the newest <%= Setting.integer("offsite_backups_kept") %>, together with every uploaded file (scans, documents, attachments) not already copied; files are never deleted from the off-site copy. A failed copy is emailed to the administrators. A restore test downloads the newest copy, opens it and checks it, and checks a sample of files against their checksums.<%= " #{policy.offsite_backup_description}" if policy.offsite_backup_description.present? %><% else %><%= policy.offsite_backup_description.presence || "[describe the off-site backup]" %><% end %></li>
<li><%= t(".software_simple_aircraft_manager_version_html", version_label: info.version_label, ruby: RUBY_VERSION, rails: Rails.version, sqlite: (SQLite3::SQLITE_VERSION)) %></li>
<li><%= t(".hosting_and_network_html") %>
<% if policy.hosting_description.present? %><div class="mt-1"><%= markdown(policy.hosting_description) %></div><% else %><%= t(".describe_the_server_location_and") %><% end %>
<p class="mt-1"><%= ProceduresTemplates.https? ? t(".connections_use_https_only_the") : t(".https_not_enforced") %> <%= ProceduresTemplates.sign_in_sentence %></p></li>
<li><%= t(".data_one_sqlite_database_plus_html") %></li>
<li><%= t(".backups_every_night_the_app_html", backups_kept: (Setting.integer("backups_kept"))) %> <% if OffsiteConnection.connected? %><%= t(".after_each_nightly_backup_the_html", account_email: OffsiteConnection.current.account_email, folder: (OffsiteConnection::ROOT_FOLDER), offsite_backups_kept: (Setting.integer("offsite_backups_kept")), present: (" #{policy.offsite_backup_description}" if policy.offsite_backup_description.present?)) %><% else %><%= policy.offsite_backup_description.presence || t(".describe_the_off_site_backup") %><% end %></li>
</ul>
<h2 class="<%= h2 %>">4. Responsible personnel</h2>
<p class="<%= p_ %>"><%= policy.responsible_name.presence || "[Name]" %><%= ", #{policy.responsible_title}" if policy.responsible_title.present? %>, has authority and overall responsibility for the electronic signature process and the recordkeeping system, for controlling access to it (accounts, roles, disabling accounts), and for the quality-control audits. Administrators: <%= users.select(&:admin?).reject(&:disabled?).map(&:display_name).to_sentence.presence || "none" %>.</p>
<h2 class="<%= h2 %>"><%= t(".n4_responsible_personnel") %></h2>
<p class="<%= p_ %>"><%= t(".has_authority_and_overall_responsibility_html", name: (policy.responsible_name.presence || t(".name")), title: (", #{policy.responsible_title}" if policy.responsible_title.present?), admins: (users.select(&:admin?).reject(&:disabled?).map(&:display_name).to_sentence.presence || t(".none"))) %></p>
<h2 class="<%= h2 %>">5. Defined users and roles</h2>
<p class="<%= p_ %>">Owners keep an aircraft's records; pilots can view them and record flights, squawks and preventive maintenance. A user may sign entries with a current certificate on their profile: mechanic certificates (A&amp;P, IA, airframe, powerplant, repair station, repairman) for maintenance and inspection entries; a pilot certificate for preventive maintenance only. Disabled accounts can't sign in or sign.</p>
<h2 class="<%= h2 %>"><%= t(".n5_defined_users_and_roles") %></h2>
<p class="<%= p_ %>"><%= t(".owners_keep_an_aircraft_s_html") %></p>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1">User</th><th>Roles</th><th>Certificates</th><th>May sign</th></tr></thead>
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".user") %></th><th><%= t(".roles") %></th><th><%= t(".certificates") %></th><th><%= t(".may_sign") %></th></tr></thead>
<tbody>
<% users.each do |u| %>
<% current = u.certificates.reject(&:expired?) %>
<tr class="border-b border-slate-100 align-top"><td class="py-1"><%= u.display_name %><div class="text-xs text-slate-500"><%= u.email_address %></div></td>
<td class="text-xs"><%= [ ("Administrator" if u.admin?), *u.aircraft_roles.map { "#{_1.role.capitalize}, #{_1.aircraft.tail_number}" } ].compact.join("; ").presence || "—" %><%= " (DISABLED)" if u.disabled? %></td>
<td class="text-xs"><%= u.certificates.map { "#{_1.short_label} #{_1.number}#{" exp. #{_1.expires_on}" if _1.expires_on}" }.join("; ").presence || "—" %></td>
<td class="text-xs"><%= if u.disabled? || current.empty? then "No"
elsif current.any?(&:mechanic?) then "Maintenance and inspection entries"
else "Preventive maintenance entries" end %></td></tr>
<td class="text-xs"><%= [ (t(".administrator") if u.admin?), *u.aircraft_roles.map { "#{_1.role.capitalize}, #{_1.aircraft.tail_number}" } ].compact.join("; ").presence || "—" %><%= t(".disabled") if u.disabled? %></td>
<td class="text-xs"><%= u.certificates.map { "#{_1.short_label} #{_1.number}#{" #{t('.expires_short', date: _1.expires_on)}" if _1.expires_on}" }.join("; ").presence || "—" %></td>
<td class="text-xs"><%= if u.disabled? || current.empty? then t(".no")
elsif current.any?(&:mechanic?) then t(".maintenance_and_inspection_entries")
else t(".preventive_maintenance_entries") end %></td></tr>
<% end %>
</tbody>
</table>
<p class="<%= p_ %>">People outside these users (e.g. a mechanic who did the work) sign through a one-time email invitation from an owner, with their own account and certificate, for that entry only; or they sign on paper (section 11).</p>
<p class="<%= p_ %>"><%= t(".people_outside_these_users_e") %></p>
<h2 class="<%= h2 %>">6. Electronic signature process</h2>
<h2 class="<%= h2 %>"><%= t(".n6_electronic_signature_process") %></h2>
<ol class="<%= p_ %> list-decimal pl-5">
<li>The signer opens the entry and chooses Sign. The entry is shown in full exactly as it will be certified (AC 2.2.4).</li>
<li>They choose one of their own current certificates. The statement they will certify is shown with it, under the heading “Certified by” (2.2.2): for maintenance, “I certify that the work described in this entry was performed in accordance with 14 CFR Part 43, and I approve it for return to service with respect to that work”; for inspections, the 43.11(a)(5) statement; for preventive maintenance by a pilot, the corresponding statement.</li>
<li>They prove who they are again: their password (with a code from their authenticator app, if they use one), or signing in again with single sign-on within the last five minutes (2.2.6), and confirm that they are signing with intent to sign (2.1.2.4–5).</li>
<li>The system records the signer, the certificate (kind and number), the statement, the time (UTC), how they authenticated, their network address and browser, a SHA-256 fingerprint of the entry's content and a readable copy of it, and a server seal (HMAC) over the signature record (2.1.2.6, 2.2.5). The signer is told on screen and by email (2.2.3).</li>
<li>Once signed, the entry and its components can't be edited or deleted (2.1.2.7–8, 2.2.7). A correction is made as a new entry that, once signed, supersedes the original; the original and its signature are kept and marked superseded (2.2.8).</li>
<li>When someone no longer needs access, the responsible person disables their account: they can no longer sign in or sign, and their past signatures stay valid (2.2.6.4).</li>
<li><%= t(".the_signer_opens_the_entry") %></li>
<li><%= t(".they_choose_one_of_their") %></li>
<li><%= t(".they_prove_who_they_are") %></li>
<li><%= t(".the_system_records_the_signer") %></li>
<li><%= t(".once_signed_the_entry_and") %></li>
<li><%= t(".when_someone_no_longer_needs") %></li>
</ol>
<p class="<%= p_ %>">Signed records are archived in the database, its nightly verified copies and the off-site backup, and can be exported with their signatures (2.2.9).</p>
<p class="<%= p_ %>"><%= t(".signed_records_are_archived_in") %></p>
<h2 class="<%= h2 %>">7. Recordkeeping system controls</h2>
<h2 class="<%= h2 %>"><%= t(".n7_recordkeeping_system_controls") %></h2>
<ul class="<%= p_ %> list-disc pl-5">
<li><strong>Controlled access (3.2.1):</strong> personal accounts (<%= Sso.enabled? ? (Sso.password_login? ? "single sign-on with #{Sso.label} or password" : "single sign-on with #{Sso.label} only") : "email and password" %>); roles per aircraft; passwords of at least 12 characters, refused if known from a data breach; optional authenticator-app codes; accounts locked for 15 minutes after 10 failed sign-ins (the user is emailed); rate-limited sign-in; sessions end after 30 days unused; changing an email or password needs the current password.</li>
<li><strong>Record preservation (3.2.2):</strong> every change to a maintenance record is kept with who, when and what changed, in a hash chain per aircraft that can't be edited; signed entries are locked.</li>
<li><strong>Confidential information (3.2.3):</strong> records are visible only to the aircraft's users, and to share links an owner creates (scoped and optionally expiring).</li>
<li><strong>Data corruption (3.2.4):</strong> nightly, the history chains and every signature's seal and fingerprint are checked; administrators are emailed on any problem.</li>
<li><strong>Outages (3.2.5):</strong> entries are made on paper and signed in ink during an outage (section 13); the database is restored from the latest verified copy or the off-site backup.</li>
<li><strong>Software revision control (3.2.6):</strong> the software is updated by deploying a new release built from its source repository. Each release has a version (year.month.release, e.g. 2026.11.0) and a build (the exact source commit), with release notes describing what changed (What's new); each version and when it ran is recorded by the system. Before an update that changes how records are entered, displayed or accessed, the responsible person reviews it, and these procedures are revised if they're affected.</li>
<li><strong>Backups (3.2.7):</strong> see section 3.</li>
<li><%= t(".controlled_access_3_2_1_html", password: (Sso.enabled? ? (Sso.password_login? ? t(".single_sign_on_with_or", so: Sso.label) : t(".single_sign_on_with_only", so: Sso.label)) : t(".email_and_password"))) %></li>
<li><%= t(".record_preservation_3_2_2_html") %></li>
<li><%= t(".confidential_information_3_2_3_html") %></li>
<li><%= t(".data_corruption_3_2_4_html") %></li>
<li><%= t(".outages_3_2_5_entries_html") %></li>
<li><%= t(".software_revision_control_3_2_html") %></li>
<li><%= t(".backups_3_2_7_see_html") %></li>
</ul>
<h2 class="<%= h2 %>">8. Quality control and auditing</h2>
<p class="<%= p_ %>">Every <%= policy.audit_interval_months %> months the responsible person carries out and records an audit in the system (3.2.8.5). The app checks that the integrity check and backups are passing, the procedures are adopted, signatures are intact, and lists expired certificates and software versions since the last audit. The auditor restores the off-site backup somewhere separate and opens it, compares <%= policy.audit_sample_size %> randomly chosen entries with their work orders or source documents, reviews the users and roles (disabling accounts no longer needed), and confirms the paper logbooks are kept. Audit results are kept in the system.<%= " Last audit: #{AuditRun.latest.performed_at.to_date}." if AuditRun.latest %></p>
<h2 class="<%= h2 %>"><%= t(".n8_quality_control_and_auditing") %></h2>
<p class="<%= p_ %>"><%= t(".every_months_the_responsible_person_html", audit_interval_months: policy.audit_interval_months, audit_sample_size: policy.audit_sample_size, latest: (t(".last_audit", to_date: AuditRun.latest.performed_at.to_date) if AuditRun.latest)) %></p>
<h2 class="<%= h2 %>">9. Making records available to the FAA and NTSB</h2>
<p class="<%= p_ %>">On request (14 CFR 91.417(c), 49 CFR 830), the responsible person provides the records package for the aircraft: every logbook entry as a PDF with its electronic signature, a signature register, the full change history, the maintenance status report and the data archive, with a README. Printed copies are produced the same way. Direct access to the system can be offered but isn't required (3.2.8.6).</p>
<h2 class="<%= h2 %>"><%= t(".n9_making_records_available_to") %></h2>
<p class="<%= p_ %>"><%= t(".on_request_14_cfr_91") %></p>
<h2 class="<%= h2 %>">10. Transfer of records</h2>
<p class="<%= p_ %>"><strong>At sale (91.419, 3.2.8.12):</strong> the buyer receives the records package and the data archive, which another installation of the system can import, together with the paper logbooks. <strong>To another system (3.2.8.9):</strong> records are exported as the data archive and the records package; both systems run side by side until the transfer is checked.</p>
<h2 class="<%= h2 %>"><%= t(".n10_transfer_of_records") %></h2>
<p class="<%= p_ %>"><%= t(".at_sale_91_419_3_html") %></p>
<h2 class="<%= h2 %>">11. Continuity</h2>
<p class="<%= p_ %>"><strong>Legacy records (3.2.8.10):</strong> records before the dates in section 1 are the paper logbooks, which are kept; scans are held as legacy records for reference. <strong>Maintenance providers (3.2.8.11):</strong> a provider signs electronically through an invitation, or signs a printed entry in ink; the signed paper is kept with the logbooks and scanned into the system.</p>
<h2 class="<%= h2 %>"><%= t(".n11_continuity") %></h2>
<p class="<%= p_ %>"><%= t(".legacy_records_3_2_8_html") %></p>
<h2 class="<%= h2 %>">12. Changes to the system and these procedures</h2>
<p class="<%= p_ %>">These procedures are revised when the system or its use changes. Each revision is numbered, dated and adopted in the system by an administrator; earlier revisions are kept. Under AC 120-78B 1.9.5 no submission to the FAA is required for part 91 operations (3.2.8.13).</p>
<h2 class="<%= h2 %>"><%= t(".n12_changes_to_the_system") %></h2>
<p class="<%= p_ %>"><%= t(".these_procedures_are_revised_when") %></p>
<h2 class="<%= h2 %>">13. User instructions and training</h2>
<p class="<%= p_ %>">Every user who keeps or signs records reads these instructions (also in the system under “How electronic records work”) before signing (2.2.12, 3.2.9).</p>
<h2 class="<%= h2 %>"><%= t(".n13_user_instructions_and_training") %></h2>
<p class="<%= p_ %>"><%= t(".every_user_who_keeps_or") %></p>
<div class="mt-2 rounded border border-slate-200 p-3"><%= guide_html(HelpGuide.find("records"), links: false, title: false) %></div>
<% if policy.additional_procedures.present? %>
<h2 class="<%= h2 %>">14. Additional procedures</h2>
<h2 class="<%= h2 %>"><%= t(".n14_additional_procedures") %></h2>
<div class="<%= p_ %>"><%= markdown(policy.additional_procedures) %></div>
<% end %>
<h2 class="<%= h2 %>">Revision history</h2>
<h2 class="<%= h2 %>"><%= t(".revision_history") %></h2>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1">Revision</th><th>Adopted</th><th>By</th><th>Summary</th></tr></thead>
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".revision_2") %></th><th><%= t(".adopted") %></th><th><%= t(".by") %></th><th><%= t(".summary") %></th></tr></thead>
<tbody>
<% revisions.each do |r| %><tr class="border-b border-slate-100"><td class="py-1"><%= r.number %></td><td><%= fmt_date(r.adopted_at.to_date) %></td><td><%= r.adopted_by&.display_name %></td><td><%= r.summary %></td></tr><% end %>
<tr><td class="py-1"><%= number %></td><td><%= adopted_at&.to_date || "—" %></td><td><%= adopted_by&.display_name %></td><td><%= summary.presence || "This revision" %></td></tr>
<tr><td class="py-1"><%= number %></td><td><%= adopted_at&.to_date || "—" %></td><td><%= adopted_by&.display_name %></td><td><%= summary.presence || t(".this_revision") %></td></tr>
</tbody>
</table>
</article>
+32 -32
View File
@@ -1,62 +1,62 @@
<% content_for :title, "Recordkeeping procedures" %>
<h1 class="mb-1 text-2xl font-bold">Recordkeeping procedures</h1>
<p class="mb-5 max-w-3xl text-sm text-slate-600">The standalone procedures document AC 120-78B asks for (paragraphs 2.2.11 and 3.2.8): how signatures and records work here, who's responsible, who may sign, backups, audits, and how records are produced and transferred. It's generated from the system's setup; fill in what the app can't know, review the draft, and adopt it as a revision. Adopt a new revision whenever users, hosting or procedures change.</p>
<% content_for :title, t(".recordkeeping_procedures") %>
<h1 class="mb-1 text-2xl font-bold"><%= t(".recordkeeping_procedures") %></h1>
<p class="mb-5 max-w-3xl text-sm text-slate-600"><%= t(".the_standalone_procedures_document_ac") %></p>
<div class="grid gap-5 lg:grid-cols-2">
<%= form_with model: @policy, url: admin_procedures_path, method: :patch, class: "card card-body space-y-4" do |f| %>
<h2 class="card-title">Details</h2>
<h2 class="card-title"><%= t(".details") %></h2>
<%= f.errors_summary %>
<%= f.field :operator_name, label: "Owner / operator", placeholder: "Jane Pilot" %>
<%= f.field :operator_name, label: t(".owner_operator"), placeholder: t(".jane_pilot") %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :responsible_name, label: "Responsible person", placeholder: "Jane Pilot" %>
<%= f.field :responsible_title, label: "Their role", placeholder: "Owner" %>
<%= f.field :responsible_name, label: t(".responsible_person"), placeholder: t(".jane_pilot") %>
<%= f.field :responsible_title, label: t(".their_role"), placeholder: t(".owner") %>
</div>
<div data-controller="insert-text" data-insert-text-text-value="<%= ProceduresTemplates.hosting %>">
<%= f.field :hosting_description, as: :textarea, rows: 8, label: "Hosting and network",
hint: "Leave a blank line between paragraphs. Markdown works: **bold**, lists.", data: { insert_text_target: "field" },
placeholder: "Where the server is, who can administer it, how it's reached and protected, how updates are installed." %>
<button type="button" class="btn-secondary btn-sm mt-2" data-action="insert-text#insert">Insert suggested text</button>
<%= f.field :hosting_description, as: :textarea, rows: 8, label: t(".hosting_and_network"),
hint: t(".leave_a_blank_line_between"), data: { insert_text_target: "field" },
placeholder: t(".where_the_server_is_who") %>
<button type="button" class="btn-secondary btn-sm mt-2" data-action="insert-text#insert"><%= t(".insert_suggested_text") %></button>
</div>
<%= f.field :offsite_backup_description, as: :textarea, rows: 2, label: (OffsiteConnection.connected? ? "Off-site backup (optional: Google Drive is connected)" : "Off-site backup"),
hint: (OffsiteConnection.connected? ? "The Google Drive backup is described automatically; add anything else here." : "Or set up the built-in Google Drive backup under Admin → Off-site Backup."),
placeholder: "The storage volume is backed up nightly with restic to an encrypted off-site repository; retention 30 days." %>
<%= f.field :offsite_backup_description, as: :textarea, rows: 2, label: (OffsiteConnection.connected? ? t(".off_site_backup_optional_google") : t(".off_site_backup")),
hint: (OffsiteConnection.connected? ? t(".the_google_drive_backup_is") : t(".or_set_up_the_built")),
placeholder: t(".the_storage_volume_is_backed") %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :audit_interval_months, as: :number, min: 1, max: 24, label: "Audit every (months)" %>
<%= f.field :audit_sample_size, as: :number, min: 1, max: 50, label: "Entries sampled per audit" %>
<%= f.field :audit_interval_months, as: :number, min: 1, max: 24, label: t(".audit_every_months") %>
<%= f.field :audit_sample_size, as: :number, min: 1, max: 50, label: t(".entries_sampled_per_audit") %>
</div>
<div data-controller="insert-text" data-insert-text-text-value="<%= ProceduresTemplates.additional %>">
<%= f.field :additional_procedures, as: :textarea, rows: 12, label: "Additional procedures (optional)",
hint: "Leave a blank line between items. Markdown works: **bold** headings, lists.", data: { insert_text_target: "field" } %>
<button type="button" class="btn-secondary btn-sm mt-2" data-action="insert-text#insert">Insert suggested text</button>
<%= f.field :additional_procedures, as: :textarea, rows: 12, label: t(".additional_procedures_optional"),
hint: t(".leave_a_blank_line_between_2"), data: { insert_text_target: "field" } %>
<button type="button" class="btn-secondary btn-sm mt-2" data-action="insert-text#insert"><%= t(".insert_suggested_text") %></button>
</div>
<p class="hint">Suggested text is filled in from this installation's settings, with [bracketed] blanks for what only you know. Edit it to match how you actually work, then save. A revision can't be adopted while a blank is left.</p>
<%= f.submit "Save" %>
<p class="hint"><%= t(".suggested_text_is_filled_in") %></p>
<%= f.submit t(".save") %>
<% end %>
<div class="space-y-5">
<section class="card card-body space-y-3">
<h2 class="card-title">Current revision</h2>
<h2 class="card-title"><%= t(".current_revision") %></h2>
<% current = @revisions.first %>
<% if current %>
<p class="text-sm">Revision <strong><%= current.number %></strong>, adopted <%= fmt_date(current.adopted_at.to_date) %> by <%= current.adopted_by&.display_name %>. <%= link_to "View / print", revision_admin_procedures_path(current), class: "link", target: "_blank" %></p>
<p class="text-sm"><%= t(".revision_adopted_by_html", number: current.number, to_date: (fmt_date(current.adopted_at.to_date)), display_name: current.adopted_by&.display_name, link: (link_to t(".view_print"), revision_admin_procedures_path(current), class: "link", target: "_blank")) %></p>
<% else %>
<p class="text-sm text-amber-800">No revision adopted yet.</p>
<p class="text-sm text-amber-800"><%= t(".no_revision_adopted_yet") %></p>
<% end %>
<p class="text-sm"><%= link_to "Preview the draft", draft_admin_procedures_path, class: "link", target: "_blank" %> (generated from the current setup).</p>
<p class="text-sm"><%= t(".generated_from_the_current_setup_html", link: (link_to t(".preview_the_draft"), draft_admin_procedures_path, class: "link", target: "_blank")) %></p>
<%= form_with url: adopt_admin_procedures_path, class: "flex flex-wrap items-end gap-2" do %>
<div class="min-w-0 flex-1"><%= label_tag :summary, "What changed", class: "label" %><%= text_field_tag :summary, nil, class: "input", placeholder: current ? "e.g. new mechanic added" : "Initial issue" %></div>
<% if @policy.unfilled_fields.any? %><p class="w-full text-sm text-amber-800">Fill in the [bracketed] blanks in: <%= @policy.unfilled_fields.to_sentence %>.</p><% end %>
<%= submit_tag "Adopt as revision #{(current&.number || 0) + 1}", class: "btn-primary", disabled: !@policy.complete?,
title: (@policy.complete? ? nil : "Fill in the operator, responsible person, hosting and off-site backup (or connect Google Drive) first") %>
<div class="min-w-0 flex-1"><%= label_tag :summary, t(".what_changed"), class: "label" %><%= text_field_tag :summary, nil, class: "input", placeholder: current ? t(".e_g_new_mechanic_added") : t(".initial_issue") %></div>
<% if @policy.unfilled_fields.any? %><p class="w-full text-sm text-amber-800"><%= t(".fill_in_the_bracketed_blanks_html", to_sentence: @policy.unfilled_fields.to_sentence) %></p><% end %>
<%= submit_tag t(".adopt_as_revision", number: (current&.number || 0) + 1), class: "btn-primary", disabled: !@policy.complete?,
title: (@policy.complete? ? nil : t(".fill_in_the_operator_responsible")) %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Earlier revisions</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".earlier_revisions") %></h2></div>
<% if @revisions.size > 1 %>
<ul class="divide-y divide-slate-100 text-sm">
<% @revisions.drop(1).each do |r| %><li class="flex justify-between px-4 py-2"><span>Revision <%= r.number %> · <%= fmt_date(r.adopted_at.to_date) %> · <%= r.summary %></span><%= link_to "View", revision_admin_procedures_path(r), class: "link", target: "_blank" %></li><% end %>
<% @revisions.drop(1).each do |r| %><li class="flex justify-between px-4 py-2"><span><%= t(".revision_html", number: r.number, to_date: (fmt_date(r.adopted_at.to_date)), summary: r.summary) %></span><%= link_to t(".view"), revision_admin_procedures_path(r), class: "link", target: "_blank" %></li><% end %>
</ul>
<% else %><%= empty_state "None." %><% end %>
<% else %><%= empty_state t(".none") %><% end %>
</section>
</div>
</div>
+17 -17
View File
@@ -1,5 +1,5 @@
<% content_for :title, "Settings" %>
<h1 class="mb-4 text-2xl font-bold">Settings</h1>
<% content_for :title, t(".settings") %>
<h1 class="mb-4 text-2xl font-bold"><%= t(".settings") %></h1>
<%= form_with url: admin_settings_path, method: :patch, class: "card card-body max-w-xl space-y-4" do |f| %>
<% if @errors.present? %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert">
@@ -7,44 +7,44 @@
</div>
<% end %>
<h2 class="card-title">Uploads</h2>
<h2 class="card-title"><%= t(".uploads") %></h2>
<% upload = Setting::INTEGERS["max_upload_mb"] %>
<div>
<%= label_tag "settings[max_upload_mb]", upload[:label], class: "label" %>
<%= label_tag "settings[max_upload_mb]", Setting::LABELS["max_upload_mb"], class: "label" %>
<%= number_field_tag "settings[max_upload_mb]", @values["max_upload_mb"], id: "settings_max_upload_mb",
min: upload[:in].min, max: upload[:in].max, step: 1, required: true, class: "input w-32" %>
<p class="hint">
The largest single file anyone can upload: documents, squawk photos and bulk uploads. Default <%= upload[:default] %> MB, up to <%= upload[:in].max %> MB.
<%= t(".the_largest_single_file_anyone_html", default_mb: (upload[:default]), max: (upload[:in].max)) %>
</p>
<p class="hint">
A proxy in front of the app can have its own, smaller limit. Cloudflare's proxy stops at 100 MB on its free plan; nginx needs <code>client_max_body_size</code>.
Logbook transcription with Claude reads PDFs up to <%= LogbookTranscriber::MAX_PDF_BYTES / 1.megabyte %> MB and images up to <%= LogbookTranscriber::MAX_IMAGE_BYTES / 1.megabyte %> MB, whatever this is set to.
<%= t(".a_proxy_in_front_of_html") %>
<%= t(".logbook_transcription_with_claude_reads_html", pdf_mb: (LogbookTranscriber::MAX_PDF_BYTES / 1.megabyte), image_mb: (LogbookTranscriber::MAX_IMAGE_BYTES / 1.megabyte)) %>
</p>
</div>
<h2 class="card-title pt-2">Backups</h2>
<h2 class="card-title pt-2"><%= t(".backups") %></h2>
<% kept = Setting::INTEGERS["backups_kept"] %>
<div>
<%= label_tag "settings[backups_kept]", kept[:label], class: "label" %>
<%= label_tag "settings[backups_kept]", Setting::LABELS["backups_kept"], class: "label" %>
<%= number_field_tag "settings[backups_kept]", @values["backups_kept"], id: "settings_backups_kept", min: kept[:in].min, max: kept[:in].max,
step: 1, required: true, class: "input w-32" %>
<p class="hint">A verified copy of the database is made nightly in storage/backups; this many of the newest are kept. Back up off the server too: <%= link_to "Off-site Backup", admin_offsite_backup_path, class: "link" %>.</p>
<p class="hint"><%= t(".a_verified_copy_of_the_html", link: (link_to t(".off_site_backup"), admin_offsite_backup_path, class: "link")) %></p>
</div>
<% okept = Setting::INTEGERS["offsite_backups_kept"] %>
<div>
<%= label_tag "settings[offsite_backups_kept]", okept[:label], class: "label" %>
<%= label_tag "settings[offsite_backups_kept]", Setting::LABELS["offsite_backups_kept"], class: "label" %>
<%= number_field_tag "settings[offsite_backups_kept]", @values["offsite_backups_kept"], id: "settings_offsite_backups_kept", min: okept[:in].min, max: okept[:in].max,
step: 1, required: true, class: "input w-32" %>
<p class="hint">With off-site backup to Google Drive, this many of the newest nightly database copies are kept there. Uploaded files are copied once and kept.</p>
<p class="hint"><%= t(".with_off_site_backup_to") %></p>
</div>
<h2 class="card-title pt-2">Document search</h2>
<h2 class="card-title pt-2"><%= t(".document_search") %></h2>
<div>
<%= label_tag "settings[documents_claude_text]", "Read scanned documents with", class: "label" %>
<%= select_tag "settings[documents_claude_text]", options_for_select([ [ "Tesseract (free, on this server)", 0 ], [ "Claude (better on handwriting; uses the Anthropic API)", 1 ] ], @values["documents_claude_text"].to_i),
<%= label_tag "settings[documents_claude_text]", t(".read_scanned_documents_with"), class: "label" %>
<%= select_tag "settings[documents_claude_text]", options_for_select([ [ t(".tesseract_free_on_this_server"), 0 ], [ t(".claude_better_on_handwriting_uses"), 1 ] ], @values["documents_claude_text"].to_i),
id: "settings_documents_claude_text", class: "input" %>
<p class="hint">Text in documents is read so search can find it. PDFs that contain text are read directly either way. Claude is used only when an ANTHROPIC_API_KEY is set<%= " (it isn't)" if ENV["ANTHROPIC_API_KEY"].blank? %>, and costs API credit per page.</p>
<p class="hint"><%= t(".text_in_documents_is_read_html", blank: (t(".it_isn_t") if ENV["ANTHROPIC_API_KEY"].blank?)) %></p>
</div>
<div class="flex gap-2"><%= f.submit "Save Settings", class: "btn-primary" %><%= link_to "Cancel", admin_about_path, class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save_settings"), class: "btn-primary" %><%= link_to t(".cancel"), admin_about_path, class: "btn-secondary" %></div>
<% end %>
+5 -5
View File
@@ -1,10 +1,10 @@
<%= form_with model: [:admin, user], class: "card card-body space-y-4 max-w-md" do |f| %>
<%= f.errors_summary %>
<%= f.field :name %>
<%= f.field :email_address, as: :email, label: "Email", required: true %>
<%= f.field :password, as: :password, hint: (user.persisted? ? "Leave blank to keep current password." : "At least #{User::PASSWORD_MIN} characters; not one known from a data breach."), autocomplete: "new-password" %>
<%= f.field :email_address, as: :email, label: t(".email"), required: true %>
<%= f.field :password, as: :password, hint: (user.persisted? ? t(".leave_blank_to_keep_current") : t(".at_least_characters_not_one", _: (User::PASSWORD_MIN))), autocomplete: "new-password" %>
<%= f.field :password_confirmation, as: :password %>
<%= f.field :admin, as: :checkbox, label: "Administrator", hint: "Admins can see and edit every aircraft and manage users." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", admin_users_path, class: "btn-secondary" %></div>
<%= f.field :admin, as: :checkbox, label: t(".administrator"), hint: t(".admins_can_see_and_edit") %>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), admin_users_path, class: "btn-secondary" %></div>
<% end %>
<% if user.persisted? && user != current_user %><div class="mt-4"><%= delete_button "Delete user", admin_user_path(user) %></div><% end %>
<% if user.persisted? && user != current_user %><div class="mt-4"><%= delete_button t(".delete_user"), admin_user_path(user) %></div><% end %>
+1 -1
View File
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">Edit User</h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".edit_user") %></h1>
<%= render "form", user: @user %>
+10 -10
View File
@@ -1,18 +1,18 @@
<% content_for :title, "Users" %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold">Users</h1><%= link_to "+ New User", new_admin_user_path, class: "btn-primary" %></div>
<% content_for :title, t(".users") %>
<div class="mb-4 flex items-center justify-between"><h1 class="text-2xl font-bold"><%= t(".users") %></h1><%= link_to t(".new_user"), new_admin_user_path, class: "btn-primary" %></div>
<section class="card"><table class="table">
<thead><tr><th>Name</th><th>Email</th><th>Aircraft</th><th>Last sign-in</th><th></th></tr></thead>
<thead><tr><th><%= t(".name") %></th><th><%= t(".email") %></th><th><%= t(".aircraft") %></th><th><%= t(".last_sign_in") %></th><th></th></tr></thead>
<tbody><% @users.each do |u| %><tr>
<td><%= u.name %> <% if u.admin? %><span class="badge-blue">Admin</span><% end %><% if u.sso_uid? %> <span class="badge-gray" title="Signs in with <%= Sso.label %>"><%= Sso.label %></span><% end %><% if u.otp_enabled? %> <span class="badge-green" title="Authenticator app on">2FA</span><% end %><% if u.locked? %> <span class="badge-red" title="Too many failed sign-ins">Locked</span><% end %></td>
<td><%= u.name %> <% if u.admin? %><span class="badge-blue"><%= t(".admin") %></span><% end %><% if u.sso_uid? %> <span class="badge-gray" title="Signs in with <%= Sso.label %>"><%= Sso.label %></span><% end %><% if u.otp_enabled? %> <span class="badge-green" title="<%= t(".authenticator_app_on") %>"><%= t(".n2fa") %></span><% end %><% if u.locked? %> <span class="badge-red" title="<%= t(".too_many_failed_sign_ins") %>"><%= t(".locked") %></span><% end %></td>
<td><%= u.email_address %><% if u.certificates.any? %><div class="text-xs text-slate-500"><%= u.certificates.map { "#{_1.short_label} #{_1.number}" }.join(", ") %></div><% end %></td>
<td class="text-xs"><%= u.aircraft_roles.map { "#{_1.aircraft.tail_number} (#{_1.role})" }.join(", ").presence || "—" %></td>
<td class="text-xs text-slate-500"><%= u.last_signed_in_at ? "#{time_ago_in_words(u.last_signed_in_at)} ago" : "never" %></td>
<td class="whitespace-nowrap text-right">
<% if u.disabled? %><span class="badge-red mr-1">Disabled</span><%= button_to "Enable", enable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %>
<% elsif u != current_user %><%= button_to "Disable", disable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline", data: { turbo_confirm: "Disable #{u.email_address}? They'll be signed out and can't sign in or sign entries. Their past signatures are kept." } } %><% end %>
<% if u.locked? %><%= button_to "Unlock", unlock_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %><% end %>
<% if u.otp_enabled? %><%= button_to "Reset 2FA", reset_two_factor_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", title: "Turn off their authenticator app (lost phone)", form: { class: "inline", data: { turbo_confirm: "Turn off two-factor for #{u.email_address}? Only do this after confirming it's really them." } } %><% end %>
<%= link_to "Edit", edit_admin_user_path(u), class: "btn-secondary btn-sm" %></td>
<% if u.disabled? %><span class="badge-red mr-1"><%= t(".disabled") %></span><%= button_to t(".enable"), enable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %>
<% elsif u != current_user %><%= button_to t(".disable"), disable_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline", data: { turbo_confirm: t(".disable_they_ll_be_signed", email_address: u.email_address) } } %><% end %>
<% if u.locked? %><%= button_to t(".unlock"), unlock_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", form: { class: "inline" } %><% end %>
<% if u.otp_enabled? %><%= button_to t(".reset_2fa"), reset_two_factor_admin_user_path(u), method: :patch, class: "btn-secondary btn-sm", title: t(".turn_off_their_authenticator_app"), form: { class: "inline", data: { turbo_confirm: t(".turn_off_two_factor_for", email_address: u.email_address) } } %><% end %>
<%= link_to t(".edit"), edit_admin_user_path(u), class: "btn-secondary btn-sm" %></td>
</tr><% end %></tbody>
</table></section>
<p class="hint mt-3">After creating an account, an aircraft owner can grant access from the aircraft's “Access & Sharing” tab.</p>
<p class="hint mt-3"><%= t(".after_creating_an_account_an") %></p>
+1 -1
View File
@@ -1,2 +1,2 @@
<h1 class="mb-4 text-2xl font-bold">New User</h1>
<h1 class="mb-4 text-2xl font-bold"><%= t(".new_user") %></h1>
<%= render "form", user: @user %>
@@ -1,3 +1,3 @@
<p><%= @run.kind == "restore_test" ? "The off-site restore test failed." : "Copying the backup to Google Drive failed." %></p>
<p><%= @run.kind == "restore_test" ? t(".the_off_site_restore_test") : t(".copying_the_backup_to_google") %></p>
<p><%= @run.message %></p>
<p>Check <%= link_to "Admin → Off-site Backup", admin_offsite_backup_url %>. If Google Drive refused access, connect it again there.</p>
<p><%= t(".check_if_google_drive_refused_html", link: (link_to t(".admin_off_site_backup"), admin_offsite_backup_url)) %></p>
@@ -1,6 +1,6 @@
<%= @run.kind == "restore_test" ? "The off-site restore test failed." : "Copying the backup to Google Drive failed." %>
<%= @run.kind == "restore_test" ? t(".the_off_site_restore_test") : t(".copying_the_backup_to_google") %>
<%= @run.message %>
Check Admin → Off-site Backup: <%= admin_offsite_backup_url %>
If Google Drive refused access, connect it again there.
<%= raw t(".check_admin_off_site_backup_text", admin_offsite_backup_url: admin_offsite_backup_url) %>
<%= raw t(".if_google_drive_refused_access") %>
@@ -1,5 +1,5 @@
<p>Last night's records check found a problem.</p>
<p>Backup: <strong><%= @backup.ok ? "OK" : "FAILED: #{@backup.message}" %></strong><br>
Integrity check: <strong><%= @check.ok ? "OK" : "#{@check.problems.size} problem(s)" %></strong></p>
<p><%= t(".last_night_s_records_check") %></p>
<p><%= t(".backup_html", message: (@backup.ok ? "OK" : t(".failed", message: @backup.message))) %>
<%= t(".integrity_check_html", s: (@check.ok ? "OK" : t(".problem_s", problems: @check.problems.size))) %></p>
<ul><% Array(@check.problems).first(20).each do |p| %><li><%= p %></li><% end %></ul>
<p>See Admin → About for details.</p>
<p><%= t(".see_admin_about_for_details") %></p>
@@ -1,9 +1,7 @@
Last night's records check found a problem.
Backup: <%= @backup.ok ? "OK" : "FAILED: #{@backup.message}" %>
Integrity check: <%= @check.ok ? "OK" : "#{@check.problems.size} problem(s)" %>
<%= raw t(".last_night_s_records_check_2_text", message: (@backup.ok ? "OK" : t(".failed", message: @backup.message))) %>
<%= raw t(".integrity_check_2_text", s: (@check.ok ? "OK" : t(".problem_s", problems: @check.problems.size))) %>
<% Array(@check.problems).first(20).each do |p| %>
- <%= p %>
<% end %>
See Admin → About for details.
<%= raw t(".see_admin_about_for_details") %>
+2 -2
View File
@@ -1,2 +1,2 @@
<p>This is a test email from Simple Aircraft Manager, sent by <%= @user.email_address %> <%= @via %>.</p>
<p>Email is working: password resets and sign-in links will arrive.</p>
<p><%= t(".this_is_a_test_email_html", email_address: @user.email_address, via: @via) %></p>
<p><%= t(".email_is_working_password_resets") %></p>
+2 -2
View File
@@ -1,3 +1,3 @@
This is a test email from Simple Aircraft Manager, sent by <%= @user.email_address %> <%= @via %>.
<%= raw t(".this_is_a_test_email_text", email_address: @user.email_address, via: @via) %>
Email is working: password resets and sign-in links will arrive.
<%= raw t(".email_is_working_password_resets") %>
+30 -30
View File
@@ -1,56 +1,56 @@
<% content_for :title, "AirTrail sync" %>
<h1 class="mb-1 text-2xl font-bold">AirTrail sync</h1>
<p class="mb-5 text-sm text-slate-600">Push the flights you log to your <a href="https://github.com/johanohly/AirTrail" class="link" target="_blank" rel="noopener noreferrer">AirTrail</a> flight map, with GPS tracks.</p>
<% content_for :title, t(".airtrail_sync") %>
<h1 class="mb-1 text-2xl font-bold"><%= t(".airtrail_sync") %></h1>
<p class="mb-5 text-sm text-slate-600"><%= t(".push_the_flights_you_log_html") %></p>
<div class="grid gap-5 lg:grid-cols-3">
<div class="space-y-5 lg:col-span-2">
<%= form_with model: @connection, url: air_trail_connection_path, method: (@connection.persisted? ? :patch : :post), class: "card card-body space-y-4" do |f| %>
<h2 class="card-title">Connection</h2>
<h2 class="card-title"><%= t(".connection") %></h2>
<%= f.errors_summary %>
<%= f.field :base_url, label: "AirTrail URL", placeholder: "https://airtrail.example.com", required: true %>
<%= f.field :api_key, as: :password, label: "API key", autocomplete: "off",
placeholder: (@connection.persisted? ? "•••••••• (leave blank to keep)" : ""),
hint: "Create one in AirTrail under Settings → Security → API keys." %>
<%= f.field :enabled, as: :checkbox, label: "Sync automatically", hint: "Flights you log, or delete, are pushed to AirTrail in the background." %>
<%= f.field :base_url, label: t(".airtrail_url"), placeholder: "https://airtrail.example.com", required: true %>
<%= f.field :api_key, as: :password, label: t(".api_key"), autocomplete: "off",
placeholder: (@connection.persisted? ? t(".leave_blank_to_keep") : ""),
hint: t(".create_one_in_airtrail_under") %>
<%= f.field :enabled, as: :checkbox, label: t(".sync_automatically"), hint: t(".flights_you_log_or_delete") %>
<div class="flex flex-wrap gap-2">
<%= f.submit(@connection.persisted? ? "Save & test" : "Connect") %>
<%= f.submit(@connection.persisted? ? t(".save_test") : t(".connect")) %>
</div>
<% end %>
<% if @connection.persisted? %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Status</h2>
<% if @connection.ok? %><span class="badge-green">Connected as <%= @connection.remote_username %></span><% else %><span class="badge-red">Needs attention</span><% end %>
<h2 class="card-title"><%= t(".status") %></h2>
<% if @connection.ok? %><span class="badge-green"><%= t(".connected_as_html", remote_username: @connection.remote_username) %></span><% else %><span class="badge-red"><%= t(".needs_attention") %></span><% end %>
</div>
<div class="card-body space-y-3 text-sm">
<% if @connection.last_error.present? %><p class="rounded-md bg-red-50 px-3 py-2 text-red-800 ring-1 ring-red-200"><%= @connection.last_error %></p><% end %>
<div class="grid grid-cols-3 gap-3 text-center">
<div><div class="text-2xl font-semibold"><%= @counts["synced"] %></div><div class="text-xs text-slate-500">synced</div></div>
<div><div class="text-2xl font-semibold"><%= @counts["pending"] %></div><div class="text-xs text-slate-500">pending</div></div>
<div><div class="text-2xl font-semibold <%= 'text-red-700' if @counts['error'].positive? %>"><%= @counts["error"] %></div><div class="text-xs text-slate-500">failed</div></div>
<div><div class="text-2xl font-semibold"><%= @counts["synced"] %></div><div class="text-xs text-slate-500"><%= t(".synced") %></div></div>
<div><div class="text-2xl font-semibold"><%= @counts["pending"] %></div><div class="text-xs text-slate-500"><%= t(".pending") %></div></div>
<div><div class="text-2xl font-semibold <%= 'text-red-700' if @counts['error'].positive? %>"><%= @counts["error"] %></div><div class="text-xs text-slate-500"><%= t(".failed") %></div></div>
</div>
<p class="text-xs text-slate-500">You've logged <%= pluralize(@flight_count, "flight") %>.
<%= @connection.backfilled_at ? "Last full sync #{time_ago_in_words(@connection.backfilled_at)} ago." : "Run a full sync to send your existing flights." %></p>
<p class="text-xs text-slate-500"><%= t(".you_ve_logged_html", flight: (t("counts.flight", count: @flight_count))) %>
<%= @connection.backfilled_at ? t(".last_full_sync_ago", backfilled_at: (time_ago_in_words(@connection.backfilled_at))) : t(".run_a_full_sync_to") %></p>
<div class="flex flex-wrap gap-2">
<%= button_to "Sync all my flights now", sync_air_trail_connection_path, class: "btn-primary" %>
<%= button_to "Test connection", test_air_trail_connection_path, class: "btn-secondary" %>
<%= button_to t(".sync_all_my_flights_now"), sync_air_trail_connection_path, class: "btn-primary" %>
<%= button_to t(".test_connection"), test_air_trail_connection_path, class: "btn-secondary" %>
</div>
<p class="hint">A full sync first links flights that are already in AirTrail (e.g. from a file import), so nothing is duplicated, then sends the rest.</p>
<p class="hint"><%= t(".a_full_sync_first_links") %></p>
</div>
</section>
<% if @unresolved.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Airports AirTrail doesn't know</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".airports_airtrail_doesn_t_know") %></h2></div>
<div class="card-body space-y-2">
<p class="text-xs text-slate-600">Flights using these codes can't sync yet. Enter the code AirTrail uses for the same airport (e.g. its ICAO or GPS code).</p>
<p class="text-xs text-slate-600"><%= t(".flights_using_these_codes_can") %></p>
<% @unresolved.each do |code| %>
<%= form_with url: map_airport_air_trail_connection_path, class: "flex items-center gap-2" do |f| %>
<%= hidden_field_tag :code, code %>
<span class="w-16 font-mono text-sm"><%= code %></span><span class="text-slate-400">→</span>
<%= text_field_tag :airtrail_code, nil, class: "input w-32", placeholder: "AirTrail code", required: true %>
<%= f.submit "Map", class: "btn-secondary btn-sm" %>
<%= text_field_tag :airtrail_code, nil, class: "input w-32", placeholder: t(".airtrail_code"), required: true %>
<%= f.submit t(".map"), class: "btn-secondary btn-sm" %>
<% end %>
<% end %>
</div>
@@ -59,7 +59,7 @@
<% if @failed.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Flights that didn't sync</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".flights_that_didn_t_sync") %></h2></div>
<table class="table"><tbody>
<% @failed.each do |s| f = s.flight_log %>
<tr><td class="whitespace-nowrap"><%= link_to fmt_date(f.date), aircraft_flight_log_path(f.aircraft, f), class: "link" %></td>
@@ -69,15 +69,15 @@
</section>
<% end %>
<div><%= delete_button "Disconnect AirTrail", air_trail_connection_path, confirm: "Stop syncing to AirTrail? Flights already there stay." %></div>
<div><%= delete_button t(".disconnect_airtrail"), air_trail_connection_path, confirm: t(".stop_syncing_to_airtrail_flights") %></div>
<% end %>
</div>
<section class="card card-body space-y-2 text-sm text-slate-700">
<h3 class="font-semibold">Setting up the API key</h3>
<p class="text-xs">In AirTrail, open <strong>Settings → Security</strong> and create an API key with these scopes:</p>
<h3 class="font-semibold"><%= t(".setting_up_the_api_key") %></h3>
<p class="text-xs"><%= t(".in_airtrail_open_settings_security_html") %></p>
<ul class="list-disc pl-5 font-mono text-xs"><% AirTrailConnection::REQUIRED_SCOPES.each do |s| %><li><%= s %></li><% end %></ul>
<p class="text-xs">The key is stored encrypted. Flights go to the AirTrail account of the pilot who logged them, with you in the pilot seat, the tail number as registration, and the GPS track if one is attached.</p>
<p class="text-xs">Each aircraft's <strong>ICAO type</strong> (Edit aircraft) sets the aircraft type in AirTrail.</p>
<p class="text-xs"><%= t(".the_key_is_stored_encrypted") %></p>
<p class="text-xs"><%= t(".each_aircraft_s_icao_type_html") %></p>
</section>
</div>
+18 -18
View File
@@ -1,43 +1,43 @@
<% content_for :title, "Export for AirTrail" %>
<% content_for :title, t(".export_for_airtrail") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-3">
<%= form_with url: aircraft_air_trail_export_path(@aircraft), class: "card card-body space-y-4 lg:col-span-2", data: { turbo: false } do |f| %>
<h2 class="card-title">Export flights for AirTrail</h2>
<h2 class="card-title"><%= t(".export_flights_for_airtrail") %></h2>
<% if @export.errors.any? %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200"><ul class="list-disc pl-5"><% @export.errors.each do |e| %><li><%= e %></li><% end %></ul></div>
<% end %>
<div class="grid gap-4 sm:grid-cols-2">
<div>
<%= label_tag :username, "Your AirTrail username", class: "label" %>
<%= label_tag :username, t(".your_airtrail_username"), class: "label" %>
<%= text_field_tag :username, params[:username].presence || @export.as_json[:users].first[:username], class: "input", required: true, autocomplete: "off" %>
<p class="hint">AirTrail assigns the flights to the account with this username (you can also pick the account while importing).</p>
<p class="hint"><%= t(".airtrail_assigns_the_flights_to") %></p>
</div>
<div>
<%= label_tag :aircraft_type, "Aircraft type (ICAO, optional)", class: "label" %>
<%= label_tag :aircraft_type, t(".aircraft_type_icao_optional"), class: "label" %>
<%= text_field_tag :aircraft_type, params[:aircraft_type].presence || @aircraft.icao_type, class: "input", placeholder: "C150", maxlength: 4 %>
<p class="hint">ICAO type designator, e.g. C150, C172, PA28.</p>
<p class="hint"><%= t(".icao_type_designator_e_g") %></p>
</div>
</div>
<fieldset class="space-y-1 text-sm">
<legend class="label">Flights</legend>
<label class="flex items-center gap-2"><%= radio_button_tag :scope, "all", params[:scope] != "mine" %> All <%= @aircraft.tail_number %> flights</label>
<label class="flex items-center gap-2"><%= radio_button_tag :scope, "mine", params[:scope] == "mine" %> Only flights I logged</label>
<legend class="label"><%= t(".flights") %></legend>
<label class="flex items-center gap-2"><%= t(".all_flights_html", mine: (radio_button_tag :scope, "all", params[:scope] != "mine"), tail_number: @aircraft.tail_number) %></label>
<label class="flex items-center gap-2"><%= t(".only_flights_i_logged_html", mine: (radio_button_tag :scope, "mine", params[:scope] == "mine")) %></label>
</fieldset>
<% all = AirTrailExport.new(@aircraft, username: "preview") %>
<p class="text-sm text-slate-600">
<%= pluralize(all.exportable.size, "flight") %> ready to export<% if all.skipped.positive? %>; <%= all.skipped %> skipped because the From or To airport is missing or isn't a code AirTrail can look up<% end %>.
<%= t(".ready_to_export_html", flight: (t("counts.flight", count: all.exportable.size))) %><% if all.skipped.positive? %><%= t(".skipped_because_the_from_or_html", skipped: all.skipped) %><% end %>.
</p>
<%= f.submit "Download AirTrail file", class: "btn-primary" %>
<%= f.submit t(".download_airtrail_file"), class: "btn-primary" %>
<% end %>
<section class="card card-body space-y-2 text-sm text-slate-700">
<h3 class="font-semibold">Importing into AirTrail</h3>
<h3 class="font-semibold"><%= t(".importing_into_airtrail") %></h3>
<ol class="list-decimal space-y-1 pl-4 text-xs">
<li>In AirTrail, open <strong>Settings → Import</strong> and choose <strong>AirTrail</strong> as the source.</li>
<li>Select the downloaded file.</li>
<li>Map any airports AirTrail doesn't recognize (small private fields may need this).</li>
<li><%= t(".in_airtrail_open_settings_import_html") %></li>
<li><%= t(".select_the_downloaded_file") %></li>
<li><%= t(".map_any_airports_airtrail_doesn") %></li>
</ol>
<p class="text-xs">Each flight is imported with you in the pilot seat, the tail number as the registration, and its tach/Hobbs time in the note. Duration comes from Hobbs time (or tach). GPS track logs (GPX, KML or CSV) are included.</p>
<p class="text-xs">Prefer automatic? <%= link_to "Set up AirTrail sync", air_trail_connection_path, class: "link" %> to push new flights as you log them.</p>
<p class="text-xs">Re-importing later is safe with AirTrail's de-duplication left on; repeat legs on the same day and route are numbered #2, #3… so they aren't merged.</p>
<p class="text-xs"><%= t(".each_flight_is_imported_with") %></p>
<p class="text-xs"><%= t(".prefer_automatic_to_push_new_html", link: (link_to t(".set_up_airtrail_sync"), air_trail_connection_path, class: "link")) %></p>
<p class="text-xs"><%= t(".re_importing_later_is_safe") %></p>
</section>
</div>
+14 -15
View File
@@ -7,30 +7,29 @@
<%= f.field :serial_number %>
<%= f.field :purchased, as: :date %>
<%= f.field :status, as: :select, collection: Aircraft::STATUSES.invert %>
<%= f.field :icao_type, label: "ICAO type", placeholder: "C150", maxlength: 4, hint: "Type designator, used for AirTrail." %>
<%= f.field :icao_type, label: t(".icao_type"), placeholder: "C150", maxlength: 4, hint: t(".type_designator_used_for_airtrail") %>
</div>
<%= f.field :description, as: :textarea, rows: 3 %>
<div class="grid gap-4 sm:grid-cols-4">
<% if aircraft.new_record? %>
<%= f.field :tach_time, as: :number, step: 0.1, label: "Current tach" %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: "Current hobbs" %>
<%= f.field :tach_time, as: :number, step: 0.1, label: t(".current_tach") %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: t(".current_hobbs") %>
<% end %>
<%= f.field :tach_time_offset, as: :number, step: 0.1, hint: "Subtracted from tach for maintenance math (e.g. after a tach replacement)." %>
<%= f.field :hobbs_time_offset, as: :number, step: 0.1, hint: "The same, for Hobbs." %>
<%= f.field :tach_time_offset, as: :number, step: 0.1, hint: t(".subtracted_from_tach_for_maintenance") %>
<%= f.field :hobbs_time_offset, as: :number, step: 0.1, hint: t(".the_same_for_hobbs") %>
</div>
<%= f.field :time_basis, as: :select, label: "Maintenance clock", collection: Aircraft::TIME_BASES.invert,
hint: "The clock used as time in service for inspections, ADs and component times (14 CFR 1.1 defines it as takeoff to landing). " \
"Changing it doesn't convert hours already recorded against the other clock." %>
<%= f.field :time_basis, as: :select, label: t(".maintenance_clock"), collection: Aircraft::TIME_BASES.invert,
hint: t(".the_clock_used_as_time") %>
<% unless aircraft.new_record? %>
<p class="hint">To change hours use “Update Hours” on the overview, so component times stay in sync.</p>
<p class="hint"><%= t(".to_change_hours_use_update") %></p>
<% end %>
<%= f.field :picture, as: :file, accept: "image/*" %>
<%= f.field :electronic_records_since, as: :date, label: "Electronic records since", wrapper: { class: "max-w-xs" },
hint: "The date this app became the maintenance record. Earlier records stay in the paper logbooks (mark their scans as legacy records)." %>
<%= f.field :airworthiness_enforcement, as: :checkbox, label: "Enforce airworthiness",
hint: "Block flight logs and hours updates while the aircraft shows Grounded." %>
<%= f.field :electronic_records_since, as: :date, label: t(".electronic_records_since"), wrapper: { class: "max-w-xs" },
hint: t(".the_date_this_app_became") %>
<%= f.field :airworthiness_enforcement, as: :checkbox, label: t(".enforce_airworthiness"),
hint: t(".block_flight_logs_and_hours") %>
<div class="flex gap-2">
<%= f.submit aircraft.new_record? ? "Add Aircraft" : "Save" %>
<%= link_to "Cancel", aircraft.new_record? ? root_path : aircraft_path(aircraft), class: "btn-secondary" %>
<%= f.submit aircraft.new_record? ? t(".add_aircraft") : t(".save") %>
<%= link_to t(".cancel"), aircraft.new_record? ? root_path : aircraft_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
+11 -11
View File
@@ -1,8 +1,8 @@
<%# The most recent day's flying (Overview). %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Last flight</h2>
<%= link_to "Flights →", aircraft_flight_logs_path(aircraft), class: "link text-sm" %>
<h2 class="card-title"><%= t(".last_flight") %></h2>
<%= link_to t(".flights"), aircraft_flight_logs_path(aircraft), class: "link text-sm" %>
</div>
<% if last_day %>
<% route = last_day.flat_map { [ _1.departure_location, _1.destination_location ] }.compact_blank.chunk_while { _1 == _2 }.map(&:first) %>
@@ -10,18 +10,18 @@
<% fuel_after = last_day.reverse.find(&:fuel_level_after)&.fuel_level_after %>
<% oil_after = last_day.reverse.find(&:oil_level_after)&.oil_level_after %>
<dl class="card-body grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm">
<dt class="text-slate-500">Date</dt>
<dd><%= fmt_date(last_leg.date) %><%= " · #{pluralize(last_day.size, 'leg')}" if last_day.size > 1 %></dd>
<% if route.any? %><dt class="text-slate-500">Route</dt><dd><%= route.join(" → ") %></dd><% end %>
<dt class="text-slate-500">Flown</dt><dd><%= hours(last_day.sum { _1.tach_time.to_d }) %> hrs tach</dd>
<% if last_leg.tach_in %><dt class="text-slate-500">Ended at</dt><dd>Tach <%= hours(last_leg.tach_in) %><%= " · Hobbs #{hours(last_leg.hobbs_in)}" if last_leg.hobbs_in %></dd><% end %>
<% if fuel_after %><dt class="text-slate-500">Fuel after</dt><dd><%= number_with_precision(fuel_after, precision: 1, strip_insignificant_zeros: true) %> gal</dd><% end %>
<% if oil_after %><dt class="text-slate-500">Oil after</dt><dd><%= number_with_precision(oil_after, precision: 1, strip_insignificant_zeros: true) %> qt</dd><% end %>
<dt class="text-slate-500"><%= t(".date") %></dt>
<dd><%= fmt_date(last_leg.date) %><%= " · #{t("counts.leg", count: last_day.size)}" if last_day.size > 1 %></dd>
<% if route.any? %><dt class="text-slate-500"><%= t(".route") %></dt><dd><%= route.join(" → ") %></dd><% end %>
<dt class="text-slate-500"><%= t(".flown") %></dt><dd><%= t(".hrs_tach_html", hours: (hours(last_day.sum { _1.tach_time.to_d }))) %></dd>
<% if last_leg.tach_in %><dt class="text-slate-500"><%= t(".ended_at") %></dt><dd><%= t(".tach_html", tach_in: (hours(last_leg.tach_in)), hobbs_in: (t(".hobbs", hobbs_in: (hours(last_leg.hobbs_in))) if last_leg.hobbs_in)) %></dd><% end %>
<% if fuel_after %><dt class="text-slate-500"><%= t(".fuel_after") %></dt><dd><%= t(".gal_html", fuel: (number_with_precision(fuel_after, precision: 1, strip_insignificant_zeros: true))) %></dd><% end %>
<% if oil_after %><dt class="text-slate-500"><%= t(".oil_after") %></dt><dd><%= t(".qt_html", oil: (number_with_precision(oil_after, precision: 1, strip_insignificant_zeros: true))) %></dd><% end %>
<% if (notes = last_day.filter_map { _1.notes.presence }).any? %>
<dt class="text-slate-500">Notes</dt><dd class="whitespace-pre-line"><%= notes.join("\n") %></dd>
<dt class="text-slate-500"><%= t(".notes") %></dt><dd class="whitespace-pre-line"><%= notes.join("\n") %></dd>
<% end %>
</dl>
<% else %>
<%= empty_state "No flights logged yet." %>
<%= empty_state t(".no_flights_logged_yet") %>
<% end %>
</section>
+5 -5
View File
@@ -1,9 +1,9 @@
<% content_for :title, "Edit #{@aircraft.tail_number}" %>
<% content_for :title, t(".edit", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft %>
<div class="mt-6 max-w-3xl card card-body border-red-200">
<h2 class="font-semibold text-red-700">Danger zone</h2>
<p class="text-sm text-slate-600 mb-3">Deleting an aircraft removes all of its records, documents and history.</p>
<%= delete_button "Delete #{@aircraft.tail_number}", aircraft_path(@aircraft),
confirm: "Delete #{@aircraft.tail_number} and ALL its records? This cannot be undone.", class: "btn-danger" %>
<h2 class="font-semibold text-red-700"><%= t(".danger_zone") %></h2>
<p class="text-sm text-slate-600 mb-3"><%= t(".deleting_an_aircraft_removes_all") %></p>
<%= delete_button t(".delete", tail_number: @aircraft.tail_number), aircraft_path(@aircraft),
confirm: t(".delete_and_all_its_records", tail_number: @aircraft.tail_number), class: "btn-danger" %>
</div>
+9 -9
View File
@@ -1,16 +1,16 @@
<% content_for :title, "Fleet" %>
<% content_for :title, t(".fleet") %>
<div class="mb-5 flex items-center justify-between">
<h1 class="text-2xl font-bold tracking-tight">Fleet</h1>
<h1 class="text-2xl font-bold tracking-tight"><%= t(".fleet") %></h1>
<div class="flex gap-2">
<%= more_menu do %><%= link_to "Import from a .sam.zip archive", new_aircraft_import_path, class: "menu-item" %><% end %>
<%= link_to "+ Add Aircraft", new_aircraft_path, class: "btn-primary" %>
<%= more_menu do %><%= link_to t(".import_from_a_sam_zip"), new_aircraft_import_path, class: "menu-item" %><% end %>
<%= link_to t(".add_aircraft"), new_aircraft_path, class: "btn-primary" %>
</div>
</div>
<% if @aircraft_list.empty? %>
<div class="card card-body text-center">
<p class="text-slate-600">No aircraft yet.</p>
<p class="mt-3"><%= link_to "Add your first aircraft", new_aircraft_path, class: "btn-primary" %></p>
<p class="text-slate-600"><%= t(".no_aircraft_yet") %></p>
<p class="mt-3"><%= link_to t(".add_your_first_aircraft"), new_aircraft_path, class: "btn-primary" %></p>
</div>
<% else %>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
@@ -19,7 +19,7 @@
<%= link_to aircraft_path(aircraft), class: "card block overflow-hidden transition hover:shadow-md" do %>
<div class="flex h-36 items-center justify-center bg-slate-200">
<% if aircraft.picture.attached? %>
<%= image_tag aircraft.picture, class: "h-full w-full object-cover", alt: "Photo of #{aircraft.tail_number}" %>
<%= image_tag aircraft.picture, class: "h-full w-full object-cover", alt: t(".photo_of", tail_number: aircraft.tail_number) %>
<% else %>
<span class="text-5xl text-slate-400" aria-hidden="true">✈</span>
<% end %>
@@ -33,7 +33,7 @@
<%= airworthiness_badge(aw) %>
</div>
<div class="mt-3 flex items-center justify-between text-sm text-slate-600">
<span>Tach <strong><%= hours(aircraft.tach_time) %></strong></span>
<span><%= t(".tach_html", tach_time: (hours(aircraft.tach_time))) %></span>
<%= aircraft_status_badge(aircraft) %>
</div>
<% if aw.issues.any? %>
@@ -41,7 +41,7 @@
<% aw.issues.first(3).each do |issue| %>
<li class="<%= issue_text_class(issue) %>">• <%= issue.title %></li>
<% end %>
<% if aw.issues.size > 3 %><li class="text-slate-500">+ <%= aw.issues.size - 3 %> more</li><% end %>
<% if aw.issues.size > 3 %><li class="text-slate-500"><%= t(".more_html", issues: (aw.issues.size - 3)) %></li><% end %>
</ul>
<% end %>
</div>
+2 -2
View File
@@ -1,3 +1,3 @@
<% content_for :title, "Add Aircraft" %>
<h1 class="mb-4 text-2xl font-bold">Add Aircraft</h1>
<% content_for :title, t(".add_aircraft") %>
<h1 class="mb-4 text-2xl font-bold"><%= t(".add_aircraft") %></h1>
<%= render "form", aircraft: @aircraft %>
+30 -30
View File
@@ -5,19 +5,19 @@
<div class="space-y-5 lg:col-span-2">
<section class="card">
<div class="card-header">
<h2 class="card-title">Airworthiness</h2>
<h2 class="card-title"><%= t(".airworthiness") %></h2>
<div class="flex items-center gap-2">
<%= link_to "Status report", aircraft_report_path(@aircraft), class: "btn-secondary btn-sm", title: "Printable maintenance status (91.417)" %>
<%= link_to t(".status_report"), aircraft_report_path(@aircraft), class: "btn-secondary btn-sm", title: t(".printable_maintenance_status_91_417") %>
</div>
</div>
<div class="card-body">
<% if @airworthiness.issues.empty? %>
<p class="text-sm text-emerald-700">Nothing overdue or due soon. All tracked ADs, inspections, components and squawks are current.</p>
<p class="text-sm text-emerald-700"><%= t(".nothing_overdue_or_due_soon") %></p>
<% else %>
<ul class="divide-y divide-slate-100">
<% @airworthiness.issues.each do |issue| %>
<li class="flex items-start gap-3 py-2">
<span class="<%= issue_badge_class(issue) %> mt-0.5"><%= issue.category %></span>
<span class="<%= issue_badge_class(issue) %> mt-0.5"><%= issue.category_label %></span>
<div>
<div class="text-sm font-medium"><%= issue.title %></div>
<div class="text-xs text-slate-500"><%= issue.description %></div>
@@ -27,46 +27,46 @@
</ul>
<% end %>
<% if @aircraft.airworthiness_enforcement? %>
<p class="hint mt-3">Airworthiness enforcement is on: flights and hours updates are blocked while the aircraft shows Grounded.</p>
<p class="hint mt-3"><%= t(".airworthiness_enforcement_is_on_flights") %></p>
<% end %>
<p class="hint mt-3"><%= Airworthiness::DISCLAIMER %></p>
<p class="hint mt-3"><%= Airworthiness.disclaimer %></p>
</div>
</section>
<section class="card">
<div class="card-header">
<h2 class="card-title">Active Squawks</h2>
<%= link_to "All squawks →", aircraft_squawks_path(@aircraft), class: "link text-sm" %>
<h2 class="card-title"><%= t(".active_squawks") %></h2>
<%= link_to t(".all_squawks"), aircraft_squawks_path(@aircraft), class: "link text-sm" %>
</div>
<% if @active_squawks.any? %>
<%= render "squawks/table", squawks: @active_squawks, aircraft: @aircraft %>
<% else %>
<%= empty_state "No open squawks." %>
<%= empty_state t(".no_open_squawks") %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Consumption</h2>
<%= link_to "Oil & fuel →", aircraft_consumable_records_path(@aircraft), class: "link text-sm" %></div>
<div class="card-header"><h2 class="card-title"><%= t(".consumption") %></h2>
<%= link_to t(".oil_fuel"), aircraft_consumable_records_path(@aircraft), class: "link text-sm" %></div>
<div class="card-body grid grid-cols-2 gap-4 text-center">
<div><div class="text-2xl font-semibold"><%= @oil.recent || "—" %></div><div class="text-xs text-slate-500">Oil, hrs/qt (last ~100 hrs)</div></div>
<div><div class="text-2xl font-semibold"><%= @fuel.recent || "—" %></div><div class="text-xs text-slate-500">Fuel burn, gal/hr (last ~50 hrs)</div></div>
<div><div class="text-2xl font-semibold"><%= @oil.recent || "—" %></div><div class="text-xs text-slate-500"><%= t(".oil_hrs_qt_last_100") %></div></div>
<div><div class="text-2xl font-semibold"><%= @fuel.recent || "—" %></div><div class="text-xs text-slate-500"><%= t(".fuel_burn_gal_hr_last") %></div></div>
</div>
</section>
</div>
<div class="space-y-5">
<section class="card">
<div class="card-header"><h2 class="card-title">Update Hours</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".update_hours") %></h2></div>
<%= form_with url: hours_aircraft_path(@aircraft), method: :patch, class: "card-body space-y-3" do |f| %>
<div class="grid grid-cols-2 gap-3">
<div><%= f.label :tach_time, "Tach", class: "label" %>
<div><%= f.label :tach_time, t(".tach"), class: "label" %>
<%= f.number_field :tach_time, value: @aircraft.tach_time, step: 0.1, class: "input", required: true %></div>
<div><%= f.label :hobbs_time, "Hobbs", class: "label" %>
<div><%= f.label :hobbs_time, t(".hobbs"), class: "label" %>
<%= f.number_field :hobbs_time, value: @aircraft.hobbs_time, step: 0.1, class: "input" %></div>
</div>
<p class="hint">Enter the current meter readings. The difference is applied to every in-service component. For a single flight, use <%= link_to "Log Flight", new_aircraft_flight_log_path(@aircraft), class: "link" %>.</p>
<%= f.submit "Update Hours", class: "btn-primary" %>
<p class="hint"><%= t(".enter_the_current_meter_readings_html", link: (link_to t(".log_flight"), new_aircraft_flight_log_path(@aircraft), class: "link")) %></p>
<%= f.submit t(".update_hours"), class: "btn-primary" %>
<% end %>
</section>
@@ -74,14 +74,14 @@
<section class="card">
<div class="card-header">
<h2 class="card-title">Details</h2>
<% if owner? %><%= link_to "Edit", edit_aircraft_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
<h2 class="card-title"><%= t(".details") %></h2>
<% if owner? %><%= link_to t(".edit"), edit_aircraft_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
</div>
<dl class="card-body grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
<dt class="text-slate-500">Serial</dt><dd><%= @aircraft.serial_number.presence || "—" %></dd>
<dt class="text-slate-500">Purchased</dt><dd><%= fmt_date(@aircraft.purchased) %></dd>
<dt class="text-slate-500">Tach offset</dt><dd><%= hours(@aircraft.tach_time_offset) %></dd>
<dt class="text-slate-500">Hobbs offset</dt><dd><%= hours(@aircraft.hobbs_time_offset) %></dd>
<dt class="text-slate-500"><%= t(".serial") %></dt><dd><%= @aircraft.serial_number.presence || "—" %></dd>
<dt class="text-slate-500"><%= t(".purchased") %></dt><dd><%= fmt_date(@aircraft.purchased) %></dd>
<dt class="text-slate-500"><%= t(".tach_offset") %></dt><dd><%= hours(@aircraft.tach_time_offset) %></dd>
<dt class="text-slate-500"><%= t(".hobbs_offset") %></dt><dd><%= hours(@aircraft.hobbs_time_offset) %></dd>
</dl>
<% if @aircraft.description.present? %>
<p class="border-t border-slate-100 px-4 py-3 text-sm text-slate-600"><%= simple_format @aircraft.description %></p>
@@ -89,25 +89,25 @@
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Notes</h2>
<%= link_to "+ Add", new_aircraft_note_path(@aircraft), class: "btn-secondary btn-sm" %></div>
<div class="card-header"><h2 class="card-title"><%= t(".notes") %></h2>
<%= link_to t(".add"), new_aircraft_note_path(@aircraft), class: "btn-secondary btn-sm" %></div>
<% if @notes.any? %>
<ul class="divide-y divide-slate-100">
<% @notes.each do |note| %>
<li class="px-4 py-2 text-sm">
<div><%= markdown_excerpt note.text %></div>
<div class="text-xs text-slate-500"><%= note.user&.display_name %> · <%= time_ago_in_words(note.created_at) %> ago <%= "· public" if note.public? %></div>
<div class="text-xs text-slate-500"><%= t(".ago_html", display_name: note.user&.display_name, created_at: (time_ago_in_words(note.created_at)), public: (t(".public") if note.public?)) %></div>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No notes." %>
<%= empty_state t(".no_notes") %>
<% end %>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Recent Activity</h2>
<%= link_to "All →", aircraft_events_path(@aircraft), class: "link text-sm" %></div>
<div class="card-header"><h2 class="card-title"><%= t(".recent_activity") %></h2>
<%= link_to t(".all"), aircraft_events_path(@aircraft), class: "link text-sm" %></div>
<%= render "events/list", events: @recent_events %>
</section>
</div>
+12 -13
View File
@@ -1,32 +1,31 @@
<% content_for :title, "Import Aircraft" %>
<% content_for :title, t(".import_aircraft") %>
<div class="mx-auto max-w-2xl space-y-5">
<h1 class="text-2xl font-bold tracking-tight">Import an aircraft</h1>
<h1 class="text-2xl font-bold tracking-tight"><%= t(".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.
<%= t(".upload_a_sam_zip_archive_html") %>
<%= t(".everything_in_it_is_added") %>
</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 %>
<%= t(".archive_html", tail_number: @preview.tail_number, make_model: ([ @preview.make, @preview.model ].compact_blank.join(" "))) %>
<% if @preview.exported_at %><span class="text-slate-500"><%= t(".exported_html", to_date: (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.label :archive, t(".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 %>
<% if @conflict %><p class="hint mt-1"><%= t(".choose_the_file_again_along") %></p><% end %>
</div>
<div class="max-w-xs">
<%= f.label :tail_number, "Tail number", class: "label" %>
<%= f.label :tail_number, t(".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>
placeholder: @preview&.tail_number || t(".from_the_archive"), required: @conflict.present? %>
<p class="hint mt-1"><%= t(".leave_blank_to_use_the") %></p>
</div>
<div class="flex gap-2"><%= f.submit "Import", class: "btn-primary" %><%= link_to "Cancel", root_path, class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".import"), class: "btn-primary" %><%= link_to t(".cancel"), root_path, class: "btn-secondary" %></div>
<% end %>
</section>
</div>
+12 -12
View File
@@ -1,26 +1,26 @@
<% content_for :title, "Aircraft Import" %>
<% content_for :title, t(".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>
<h1 class="text-2xl font-bold tracking-tight"><%= t(".importing_html", tail_number: @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>
<p class="text-slate-500"><%= @import.filename %><%= t(".from", source: @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>
<%= @import.status == "queued" ? t(".waiting_to_start") : t(".importing_2") %></p>
<% if @import.counts.any? %><p class="text-slate-600"><%= t(".so_far_html", summary: @import.summary) %></p><% end %>
<p class="hint"><%= t(".this_page_updates_by_itself") %></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 %>
<p class="font-medium text-emerald-700"><%= t(".imported") %></p>
<p class="text-slate-600"><%= @import.summary.presence&.upcase_first || t(".no_records") %>.</p>
<% if @import.aircraft %><p><%= link_to t(".open", tail_number: @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="font-medium text-red-700"><%= t(".the_import_failed_nothing_was") %></p>
<p class="text-slate-600"><%= @import.error %></p>
<p><%= link_to "Try another file", new_aircraft_import_path, class: "btn-secondary" %></p>
<p><%= link_to t(".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>
<p class="mb-1 text-xs font-semibold text-slate-500"><%= t("counts.note", count: @import.warnings.size) %></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 %>
+24 -24
View File
@@ -1,9 +1,9 @@
<% content_for :title, "#{@aircraft.tail_number} Access" %>
<% content_for :title, t(".access", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<h2 class="mb-4 text-lg font-semibold">Access &amp; sharing</h2>
<h2 class="mb-4 text-lg font-semibold"><%= t(".access_sharing_html") %></h2>
<div class="grid gap-5 lg:grid-cols-2">
<section class="card">
<div class="card-header"><h2 class="card-title">People</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".people") %></h2></div>
<table class="table">
<tbody>
<% @roles.each do |r| %>
@@ -14,66 +14,66 @@
<%= f.select :role, AircraftRole::ROLES.invert, { selected: r.role }, class: "input w-28", data: { submit_on_change: true } %>
<% end %>
</td>
<td class="text-right"><% unless r.user == current_user %><%= delete_button "Remove", aircraft_aircraft_role_path(@aircraft, r), confirm: "Remove #{r.user.display_name}'s access?" %><% end %></td>
<td class="text-right"><% unless r.user == current_user %><%= delete_button t(".remove"), aircraft_aircraft_role_path(@aircraft, r), confirm: t(".remove_s_access", display_name: r.user.display_name) %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<%= form_with url: aircraft_aircraft_roles_path(@aircraft), class: "flex flex-wrap items-end gap-2 border-t border-slate-100 p-4" do |f| %>
<div class="flex-1"><%= f.label :email_address, "Add by email", class: "label" %><%= f.email_field :email_address, class: "input", required: true %></div>
<div class="flex-1"><%= f.label :email_address, t(".add_by_email"), class: "label" %><%= f.email_field :email_address, class: "input", required: true %></div>
<%= f.select :role, AircraftRole::ROLES.invert, { selected: "pilot" }, class: "input w-28" %>
<%= f.submit "Add", class: "btn-primary" %>
<%= f.submit t(".add"), class: "btn-primary" %>
<% end %>
<p class="px-4 pb-4 hint"><strong>Owners</strong> can edit everything. <strong>Pilots</strong> can view all records, log flights, update hours, and add squawks, notes and oil/fuel.</p>
<p class="px-4 pb-4 hint"><%= t(".owners_can_edit_everything_pilots_html") %></p>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Share Links</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".share_links") %></h2></div>
<% if @share_tokens.any? %>
<ul class="divide-y divide-slate-100">
<% @share_tokens.each do |t| %>
<li class="px-4 py-3">
<div class="flex items-center justify-between gap-2">
<div>
<span class="font-medium"><%= t.label.presence || "Untitled link" %></span>
<span class="font-medium"><%= t.label.presence || t(".untitled_link") %></span>
<%= tag.span ShareToken::PRIVILEGES[t.privilege], class: t.maintenance? ? "badge-blue" : "badge-green" %>
<% if t.expired? %><span class="badge-red">Expired</span><% end %>
<% if t.expired? %><span class="badge-red"><%= t(".expired") %></span><% end %>
</div>
<%= delete_button "Revoke", aircraft_share_token_path(@aircraft, t), confirm: "Revoke this link? Anyone using it will lose access." %>
<%= delete_button t(".revoke"), aircraft_share_token_path(@aircraft, t), confirm: t(".revoke_this_link_anyone_using") %>
</div>
<input type="text" readonly value="<%= shared_url(t.token) %>" class="input mt-2 font-mono text-xs" data-select-on-click>
<div class="mt-1 text-xs text-slate-500">Created <%= fmt_date(t.created_at.to_date) %><%= " by #{t.created_by.display_name}" if t.created_by %> · <%= t.expires_at ? "expires #{l t.expires_at, format: :short}" : "never expires" %></div>
<div class="mt-1 text-xs text-slate-500"><%= t(".created_html", to_date: (fmt_date(t.created_at.to_date)), created_by: (" by #{t.created_by.display_name}" if t.created_by), expires: (t.expires_at ? "expires #{l t.expires_at, format: :short}" : t(".never_expires"))) %></div>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No share links." %>
<%= empty_state t(".no_share_links") %>
<% end %>
<%= form_with model: ShareToken.new, url: aircraft_share_tokens_path(@aircraft), class: "space-y-3 border-t border-slate-100 p-4" do |f| %>
<div class="grid gap-3 sm:grid-cols-3">
<%= f.field :label, placeholder: "Mechanic, buyer…" %>
<%= f.field :privilege, as: :select, label: "Shows", collection: ShareToken::PRIVILEGES.invert %>
<%= f.field :expires_at, as: :datetime, label: "Expires (optional)" %>
<%= f.field :label, placeholder: t(".mechanic_buyer") %>
<%= f.field :privilege, as: :select, label: t(".shows"), collection: ShareToken::PRIVILEGES.invert %>
<%= f.field :expires_at, as: :datetime, label: t(".expires_optional") %>
</div>
<p class="hint"><strong>Current Status</strong>: overview, airworthiness, components, open squawks, AD/inspection status, oil & fuel, public notes and documents shared with all links. <strong>Maintenance Detail</strong> adds the full logbook, history, resolved squawks and major records.</p>
<%= f.submit "Create Share Link" %>
<p class="hint"><%= t(".current_status_overview_airworthiness_components_html") %></p>
<%= f.submit t(".create_share_link") %>
<% end %>
</section>
<section class="card lg:col-span-2">
<div class="card-header">
<div>
<h2 class="card-title">Backup &amp; 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>
<h2 class="card-title"><%= t(".backup_transfer_html") %></h2>
<p class="hint"><%= t(".everything_recorded_for_with_its_html", tail_number: @aircraft.tail_number) %></p>
</div>
<%= link_to "Download .sam.zip", aircraft_export_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
<%= link_to t(".download_sam_zip"), aircraft_export_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
</div>
<div class="card-header border-t border-slate-100">
<div>
<h2 class="card-title">Records package</h2>
<p class="hint">For an FAA or NTSB request, or a buyer: every logbook entry as a PDF with its electronic signature, a signature register, the full change history, the status report, and the .sam.zip, in one ZIP with a README.</p>
<h2 class="card-title"><%= t(".records_package") %></h2>
<p class="hint"><%= t(".for_an_faa_or_ntsb") %></p>
</div>
<%= link_to "Download records package", aircraft_records_package_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
<%= link_to t(".download_records_package"), aircraft_records_package_path(@aircraft), class: "btn-secondary", data: { turbo: false } %>
</div>
</section>
</div>
+14 -14
View File
@@ -1,18 +1,18 @@
<% content_for :title, "Standardize airport codes" %>
<% content_for :title, t(".standardize_airport_codes") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% changes = @standardizer.changes %>
<%= form_with url: aircraft_airport_codes_path(@aircraft), method: :patch, class: "space-y-5" do |f| %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Standardize airport codes</h2>
<span class="text-xs text-slate-500"><%= pluralize(changes.size, "code") %> to update · <%= changes.sum(&:flights) %> entries</span>
<h2 class="card-title"><%= t(".standardize_airport_codes") %></h2>
<span class="text-xs text-slate-500"><%= t(".to_update_entries_html", code: (t("counts.code", count: changes.size)), flights: (changes.sum(&:flights))) %></span>
</div>
<div class="card-body text-sm text-slate-600">
Rewrites the airport codes in <%= @aircraft.tail_number %>'s flight log to the airport database's standard code: the ICAO-style code AirTrail uses (e.g. 1B9 → K1B9). New flights picked from autocomplete already use these codes. Untick anything you'd rather keep as is.
<%= t(".rewrites_the_airport_codes_in_html", tail_number: @aircraft.tail_number) %>
</div>
<% if changes.any? %>
<table class="table">
<thead><tr><th class="w-8"><input type="checkbox" checked aria-label="Select all" data-check-all></th><th>Logged</th><th>Standard</th><th>Airport</th><th class="text-right">Entries</th></tr></thead>
<thead><tr><th class="w-8"><input type="checkbox" checked aria-label="<%= t(".select_all") %>" data-check-all></th><th><%= t(".logged") %></th><th><%= t(".standard") %></th><th><%= t(".airport") %></th><th class="text-right"><%= t(".entries") %></th></tr></thead>
<tbody>
<% changes.each do |c| %>
<tr>
@@ -27,31 +27,31 @@
</tbody>
</table>
<% else %>
<%= empty_state "All logged codes already match the airport database." %>
<%= empty_state t(".all_logged_codes_already_match") %>
<% end %>
</section>
<% if @standardizer.unknown.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title">Not in the airport database</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".not_in_the_airport_database") %></h2></div>
<div class="card-body space-y-3 text-sm">
<p class="text-slate-600">Often a typo. Tick “Fix” and choose the airport these entries should be. Unticked codes are left unchanged.<% if current_user.admin? %> For a private strip that isn't listed, add it as a <%= link_to "custom airport", admin_airports_path, class: "link" %>.<% end %></p>
<p class="text-slate-600"><%= t(".often_a_typo_tick_fix") %><% if current_user.admin? %> <%= t(".for_a_private_strip_that_html", link: (link_to t(".custom_airport"), admin_airports_path, class: "link")) %><% end %></p>
<% @standardizer.unknown.each do |u| %>
<div class="flex flex-wrap items-start gap-3">
<label class="mt-2 flex items-center gap-2"><%= check_box_tag "fix[]", u.code, u.suggestion.present?, id: "fix_#{u.code.parameterize}" %> Fix</label>
<label class="mt-2 flex items-center gap-2"><%= t(".fix_html", checkbox: (check_box_tag "fix[]", u.code, u.suggestion.present?, id: "fix_#{u.code.parameterize}")) %></label>
<div class="mt-2 w-16 font-mono"><%= u.code %></div>
<div class="mt-2 text-xs text-slate-500"><%= pluralize(u.flights, "entry") %> →</div>
<div class="mt-2 text-xs text-slate-500"><%= t("counts.entry", count: u.flights) %> →</div>
<div class="relative w-72" data-controller="airport-autocomplete"
data-airport-autocomplete-url-value="<%= airport_search_path(aircraft_id: @aircraft.id) %>">
<%= text_field_tag "fixes[#{u.code}]", u.suggestion&.code, class: "input font-mono uppercase placeholder:normal-case placeholder:font-sans",
placeholder: "Airport code or name", "aria-label": "Airport for #{u.code}",
placeholder: t(".airport_code_or_name"), "aria-label": t(".airport_for", code: u.code),
data: { airport_autocomplete_target: "input",
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
<ul data-airport-autocomplete-target="list" role="listbox" hidden
class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200"></ul>
<p class="hint min-h-4" data-airport-autocomplete-target="hint"></p>
</div>
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800">Suggested: <%= u.suggestion.name %>, <%= u.suggestion.place %> (letters swapped?)</div><% end %>
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800"><%= t(".suggested_letters_swapped_html", suggestion: u.suggestion.name, location: u.suggestion.place) %></div><% end %>
</div>
<% end %>
</div>
@@ -59,7 +59,7 @@
<% end %>
<div class="flex gap-2">
<% if changes.any? || @standardizer.unknown.any? %><%= f.submit "Update selected codes", class: "btn-primary", data: { turbo_confirm: "Rewrite the selected airport codes in #{@aircraft.tail_number}'s flight log?" } %><% end %>
<%= link_to "Back to flights", aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %>
<% if changes.any? || @standardizer.unknown.any? %><%= f.submit t(".update_selected_codes"), class: "btn-primary", data: { turbo_confirm: t(".rewrite_the_selected_airport_codes", tail_number: @aircraft.tail_number) } %><% end %>
<%= link_to t(".back_to_flights"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>
@@ -1,29 +1,29 @@
<%= form_with model: ad, url: ad.new_record? ? aircraft_airworthiness_directives_path(aircraft) : aircraft_airworthiness_directive_path(aircraft, ad), class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :name, label: "Number", required: true, placeholder: "2011-10-09" %>
<%= f.field :bulletin_type, as: :select, label: "Type", collection: AirworthinessDirective::BULLETIN_TYPES.invert %>
<%= f.field :compliance_type, as: :select, label: "Compliance", collection: AirworthinessDirective::COMPLIANCE_TYPES.invert,
hint: "Conditional ADs only apply when a trigger occurs and don't affect airworthiness." %>
<%= f.field :name, label: t(".number"), required: true, placeholder: "2011-10-09" %>
<%= f.field :bulletin_type, as: :select, label: t(".type"), collection: AirworthinessDirective::BULLETIN_TYPES.invert %>
<%= f.field :compliance_type, as: :select, label: t(".compliance"), collection: AirworthinessDirective::COMPLIANCE_TYPES.invert,
hint: t(".conditional_ads_only_apply_when") %>
</div>
<%= f.field :short_description, required: true %>
<%= f.field :required_action, as: :textarea, rows: 3 %>
<%= f.field :trigger_condition, as: :textarea, rows: 2, hint: "For conditional ADs (e.g. “on prop strike”)." %>
<%= f.field :trigger_condition, as: :textarea, rows: 2, hint: t(".for_conditional_ads_e_g") %>
<div class="flex gap-6">
<%= f.field :mandatory, as: :checkbox, label: "Mandatory" %>
<%= f.field :recurring, as: :checkbox, label: "Recurring" %>
<%= f.field :mandatory, as: :checkbox, label: t(".mandatory") %>
<%= f.field :recurring, as: :checkbox, label: t(".recurring") %>
</div>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %>
<%= f.interval :recurring, label: "Every", hint: "Months and years are due at the end of the month." %>
<%= f.field :document_id, as: :select, label: "Reference document", collection: document_options(aircraft) %>
<%= f.field :recurring_hours, as: :number, step: 0.1, label: t(".every_hours") %>
<%= f.interval :recurring, label: t(".every"), hint: t(".months_and_years_are_due") %>
<%= f.field :document_id, as: :select, label: t(".reference_document"), collection: document_options(aircraft) %>
</div>
<%= f.field :document_url, label: "Link to AD document", placeholder: "https://…",
hint: "Filled in automatically from a DRS Excel export. In DRS, open the AD and copy its link." %>
<%= f.field :document_url, label: t(".link_to_ad_document"), placeholder: t(".https"),
hint: t(".filled_in_automatically_from_a") %>
<%= render "shared/applicability_fields", aircraft: aircraft, record: ad, applies_to_airframe: @applies_to_airframe %>
<% if ad.persisted? && (ad.aircraft.count + ad.components.where.not(aircraft_id: aircraft.id).count) > 1 %>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800">This AD is shared with other aircraft; edits affect them too.</p>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800"><%= t(".this_ad_is_shared_with") %></p>
<% end %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if ad.persisted? %><div class="mt-4"><%= delete_button "Remove from #{aircraft.tail_number}", aircraft_airworthiness_directive_path(aircraft, ad) %></div><% end %>
<% if ad.persisted? %><div class="mt-4"><%= delete_button t(".remove_from", tail_number: aircraft.tail_number), aircraft_airworthiness_directive_path(aircraft, ad) %></div><% end %>
@@ -1,43 +1,43 @@
<% content_for :title, "#{@aircraft.tail_number} ADs" %>
<% content_for :title, t(".ads", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Airworthiness Directives & Bulletins</h2>
<h2 class="card-title"><%= t(".airworthiness_directives_bulletins") %></h2>
<% if owner? %>
<div class="flex flex-wrap items-center gap-2">
<% if @attachable.any? %>
<%= form_with url: attach_aircraft_airworthiness_directives_path(@aircraft), class: "flex gap-2" do |f| %>
<%= f.select :airworthiness_directive_id, @attachable.map { ["#{_1.name} – #{_1.short_description.truncate(40)}", _1.id] }, {}, class: "input w-64" %>
<%= f.submit "Link existing", class: "btn-secondary" %>
<%= f.submit t(".link_existing"), class: "btn-secondary" %>
<% end %>
<% end %>
<%= link_to "+ New AD", new_aircraft_airworthiness_directive_path(@aircraft), class: "btn-primary" %>
<%= link_to t(".new_ad"), new_aircraft_airworthiness_directive_path(@aircraft), class: "btn-primary" %>
</div>
<% end %>
</div>
<% if @rows.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>AD / Bulletin</th><th>Description</th><th>Recurrence</th><th>Last complied</th><th>Next due</th><th>Status</th><th></th></tr></thead>
<thead><tr><th><%= t(".ad_bulletin") %></th><th><%= t(".description") %></th><th><%= t(".recurrence") %></th><th><%= t(".last_complied") %></th><th><%= t(".next_due") %></th><th><%= t(".status") %></th><th></th></tr></thead>
<tbody>
<% @rows.each do |row| ad = row.ad %>
<tr>
<td class="whitespace-nowrap font-medium"><span class="badge-gray mr-1"><%= ad.bulletin_label %></span><%= ad_link(ad) %>
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name, "aria-label": "Document: #{ad.document.name}" %><% end %>
<% unless ad.mandatory? %><div class="text-xs text-slate-500">not mandatory</div><% end %></td>
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name, "aria-label": t(".document", document: ad.document.name) %><% end %>
<% unless ad.mandatory? %><div class="text-xs text-slate-500"><%= t(".not_mandatory") %></div><% end %></td>
<td class="max-w-sm text-xs"><%= ad.short_description %>
<% if ad.effective_date || ad.product_type.present? %><div class="text-slate-500"><%= [(ad.effective_date && "Effective #{fmt_date(ad.effective_date)}"), ad.product_type.presence].compact.join(" · ") %></div><% end %>
<% if ad.superseded_by.present? %><div class="text-amber-700">Superseded by <%= ad.superseded_by %></div><% end %>
<% if ad.conditional? && ad.trigger_condition.present? %><div class="text-slate-500">Trigger: <%= ad.trigger_condition %></div><% end %></td>
<td class="text-xs"><%= ad.recurring? ? [ad.recurring_hours.to_f > 0 && "#{hours(ad.recurring_hours)} h", ad.recurring_interval_label].select(&:itself).join(" / ") : "One-time" %></td>
<% if ad.effective_date || ad.product_type.present? %><div class="text-slate-500"><%= [(ad.effective_date && t(".effective_2", effective_date: (fmt_date(ad.effective_date)))), ad.product_type.presence].compact.join(" · ") %></div><% end %>
<% if ad.superseded_by.present? %><div class="text-amber-700"><%= t(".superseded_by_html", superseded_by: ad.superseded_by) %></div><% end %>
<% if ad.conditional? && ad.trigger_condition.present? %><div class="text-slate-500"><%= t(".trigger_html", trigger_condition: ad.trigger_condition) %></div><% end %></td>
<td class="text-xs"><%= ad.recurring? ? [ad.recurring_hours.to_f > 0 && "#{hours(ad.recurring_hours)} h", ad.recurring_interval_label].select(&:itself).join(" / ") : t(".one_time") %></td>
<td class="text-xs"><%= row.latest ? "#{row.latest.date_complied}#{' (permanent)' if row.latest.permanent?}" : "—" %></td>
<td class="text-xs"><%= [row.next_due_date&.strftime("%b %Y"), row.next_due_hours && "#{hours(row.next_due_hours)} #{@aircraft.time_basis} (#{hours(row.next_due_hours - @aircraft.current_hours)} h left)"].compact.join(" / ").presence || "—" %></td>
<td class="text-xs"><%= [row.next_due_date && l(row.next_due_date, format: :month_year), row.next_due_hours && t(".due_hours", hours: hours(row.next_due_hours), meter: Aircraft::TIME_BASES[@aircraft.time_basis].downcase, left: hours(row.next_due_hours - @aircraft.current_hours))].compact.join(" / ").presence || "—" %></td>
<td><%= compliance_badge(row.status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Comply", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id), class: "btn-secondary btn-sm" %>
<% if row.status.in?(%w[no_compliance overdue due_soon conditional]) %><%= link_to "N/A", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1), class: "btn-secondary btn-sm", title: "Record that this AD doesn't apply to this aircraft" %><% end %>
<%= link_to "Edit", edit_aircraft_airworthiness_directive_path(@aircraft, ad), class: "btn-secondary btn-sm" %>
<%= link_to t(".comply"), new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id), class: "btn-secondary btn-sm" %>
<% if row.status.in?(%w[no_compliance overdue due_soon conditional]) %><%= link_to "N/A", new_aircraft_ad_compliance_path(@aircraft, ad_id: ad.id, not_applicable: 1), class: "btn-secondary btn-sm", title: t(".record_that_this_ad_doesn") %><% end %>
<%= link_to t(".edit"), edit_aircraft_airworthiness_directive_path(@aircraft, ad), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
@@ -46,7 +46,7 @@
</table>
</div>
<% else %>
<%= empty_state "No ADs tracked for this aircraft." %>
<%= empty_state t(".no_ads_tracked_for_this") %>
<% end %>
</section>
@@ -55,69 +55,69 @@
<section class="card mt-5" id="ad-baseline">
<div class="card-header">
<div>
<h2 class="card-title">AD baseline from FAA DRS</h2>
<p class="text-xs text-slate-500">The full list comes from DRS imports; the weekly search below adds what's published after.</p>
<h2 class="card-title"><%= t(".ad_baseline_from_faa_drs") %></h2>
<p class="text-xs text-slate-500"><%= t(".the_full_list_comes_from") %></p>
</div>
<% if owner? %><%= link_to "Import from FAA DRS", new_aircraft_ad_import_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
<% if owner? %><%= link_to t(".import_from_faa_drs"), new_aircraft_ad_import_path(@aircraft), class: "btn-secondary btn-sm" %><% end %>
</div>
<div class="card-body space-y-2 text-sm">
<% if last_drs %>
<p>Last import <strong><%= fmt_date(last_drs.created_at.to_date) %></strong> by <%= last_drs.user&.display_name || "—" %>: <%= last_drs.ad_count %> ADs<%= ", covering #{Array(last_drs.models_covered).to_sentence}" if Array(last_drs.models_covered).any? %>.</p>
<% if last_drs.created_at < DrsImport::RENEW_AFTER.ago %><p class="text-amber-800">Over a year old: import again to pick up revised ADs and anything the weekly search missed.</p><% end %>
<p><%= t(".last_import_by_ads_html", to_date: (fmt_date(last_drs.created_at.to_date)), display_name: (last_drs.user&.display_name || "—"), ad_count: last_drs.ad_count, any: (t(".covering", to_sentence: (Array(last_drs.models_covered).to_sentence)) if Array(last_drs.models_covered).any?)) %></p>
<% if last_drs.created_at < DrsImport::RENEW_AFTER.ago %><p class="text-amber-800"><%= t(".over_a_year_old_import") %></p><% end %>
<% else %>
<p class="text-amber-800">No DRS import yet. Export the ADs for each model from drs.faa.gov and import them here.</p>
<p class="text-amber-800"><%= t(".no_drs_import_yet_export") %></p>
<% end %>
<% if missing.any? %><p class="text-amber-800">Never imported for: <strong><%= missing.join(", ") %></strong>. Search DRS for each and import the file.</p><% end %>
<% if missing.any? %><p class="text-amber-800"><%= t(".never_imported_for_search_drs_html", missing: (missing.join(", "))) %></p><% end %>
</div>
</section>
<section class="card mt-5" id="new-ads">
<div class="card-header">
<div>
<h2 class="card-title">Newly published ADs that may apply</h2>
<p class="text-xs text-slate-500">Searched weekly in the Federal Register for <%= AdWatch.new(@aircraft).terms.map(&:label).uniq.to_sentence.presence || "the aircraft and its installed components" %><%= " · last checked #{time_ago_in_words(@aircraft.ad_watch_checked_at)} ago" if @aircraft.ad_watch_checked_at %>.</p>
<h2 class="card-title"><%= t(".newly_published_ads_that_may") %></h2>
<p class="text-xs text-slate-500"><%= t(".searched_weekly_in_the_federal_html", components: (AdWatch.new(@aircraft).terms.map(&:label).uniq.to_sentence.presence || t(".the_aircraft_and_its_installed")), ad_watch_checked_at: (t(".last_checked_ago", ad_watch_checked_at: (time_ago_in_words(@aircraft.ad_watch_checked_at))) if @aircraft.ad_watch_checked_at)) %></p>
</div>
<% if owner? %><%= button_to "Check now", check_aircraft_ad_alerts_path(@aircraft), class: "btn-secondary btn-sm", data: { turbo_submits_with: "Checking…" } %><% end %>
<% if owner? %><%= button_to t(".check_now"), check_aircraft_ad_alerts_path(@aircraft), class: "btn-secondary btn-sm", data: { turbo_submits_with: t(".checking") } %><% end %>
</div>
<% if @alerts.any? %>
<ul class="divide-y divide-slate-100">
<% @alerts.each do |alert| %>
<li class="flex flex-wrap items-start justify-between gap-3 px-4 py-3">
<div class="min-w-0 flex-1 text-sm">
<div class="font-medium"><%= alert.ad_number ? "AD #{alert.ad_number}" : alert.fr_document_number %> · <%= alert.title.to_s.delete_prefix("Airworthiness Directives; ") %></div>
<div class="text-xs text-slate-500"><%= [ (alert.effective_on && "Effective #{fmt_date(alert.effective_on)}"), "published #{fmt_date(alert.publication_date)}", "matched “#{alert.matched_term}”" ].compact.join(" · ") %></div>
<div class="font-medium"><%= alert.ad_number ? t(".ad_2", ad_number: alert.ad_number) : alert.fr_document_number %> · <%= alert.title.to_s.delete_prefix("Airworthiness Directives; ") %></div>
<div class="text-xs text-slate-500"><%= [ (alert.effective_on && t(".effective", effective_on: (fmt_date(alert.effective_on)))), "published #{fmt_date(alert.publication_date)}", t(".matched", matched_term: alert.matched_term) ].compact.join(" · ") %></div>
<p class="mt-1 text-xs text-slate-600"><%= alert.abstract.to_s.truncate(400) %></p>
<%= link_to "Read it in the Federal Register", alert.html_url, class: "link text-xs", target: "_blank", rel: "noopener" %>
<%= link_to t(".read_it_in_the_federal"), alert.html_url, class: "link text-xs", target: "_blank", rel: "noopener" %>
</div>
<% if owner? %>
<div class="flex gap-2">
<%= button_to "Track", track_aircraft_ad_alert_path(@aircraft, alert), class: "btn-primary btn-sm", title: "Add it to this aircraft's ADs" %>
<%= button_to "Dismiss", dismiss_aircraft_ad_alert_path(@aircraft, alert), class: "btn-secondary btn-sm", title: "Doesn't apply" %>
<%= button_to t(".track"), track_aircraft_ad_alert_path(@aircraft, alert), class: "btn-primary btn-sm", title: t(".add_it_to_this_aircraft") %>
<%= button_to t(".dismiss"), dismiss_aircraft_ad_alert_path(@aircraft, alert), class: "btn-secondary btn-sm", title: t(".doesn_t_apply") %>
</div>
<% end %>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "Nothing new to review." %>
<%= empty_state t(".nothing_new_to_review") %>
<% end %>
<% if owner? %>
<%= form_with url: terms_aircraft_ad_alerts_path(@aircraft), method: :patch, class: "flex flex-wrap items-end gap-2 border-t border-slate-100 px-4 py-3" do %>
<div class="min-w-0 flex-1">
<%= label_tag :ad_watch_terms, "Additional search terms", class: "label" %>
<%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: "e.g. an STC or part that isn't a component" %>
<%= label_tag :ad_watch_terms, t(".additional_search_terms"), class: "label" %>
<%= text_field_tag :ad_watch_terms, @aircraft.ad_watch_terms, class: "input", placeholder: t(".e_g_an_stc_or") %>
</div>
<%= submit_tag "Save", class: "btn-secondary" %>
<p class="hint w-full">Comma-separated, searched in addition to the automatic ones: the aircraft make and model, engine and propeller models (and families), and every installed component’s maker, type and model. A match on a component makes the tracked AD apply to that component. Matches are only possibly applicable: check each AD's applicability (and serial number ranges) before tracking it.</p>
<%= submit_tag t(".save"), class: "btn-secondary" %>
<p class="hint w-full"><%= t(".comma_separated_searched_in_addition") %></p>
<% end %>
<% end %>
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Compliance History</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".compliance_history") %></h2></div>
<% if @history.any? %>
<table class="table">
<thead><tr><th>Date</th><th>AD</th><th class="text-right">Hours</th><th>Next due (tach)</th><th>Notes</th><th></th></tr></thead>
<thead><tr><th><%= t(".date") %></th><th><%= t(".ad") %></th><th class="text-right"><%= t(".hours") %></th><th><%= t(".next_due_tach") %></th><th><%= t(".notes") %></th><th></th></tr></thead>
<tbody>
<% @history.each do |c| %>
<tr>
@@ -125,27 +125,27 @@
<% ad = c.airworthiness_directive %>
<td class="max-w-xs">
<span class="whitespace-nowrap font-medium"><%= ad_link(ad) %></span>
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name, "aria-label": "Document: #{ad.document.name}" %><% end %>
<% if ad.document %><%= link_to "📄", aircraft_document_path(@aircraft, ad.document), title: ad.document.name, "aria-label": t(".document", document: ad.document.name) %><% end %>
<div class="text-xs text-slate-500"><%= ad.short_description %><%= " · #{c.component}" if c.component %></div>
</td>
<td class="text-right"><%= hours(c.aircraft_hours_at_compliance) %></td>
<td><%= c.not_applicable? ? "N/A" : c.permanent? ? "Permanent" : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %></td>
<td><%= c.not_applicable? ? "N/A" : c.permanent? ? t(".permanent") : (c.next_due_at_time.to_f > 0 ? hours(c.next_due_at_time) : "—") %></td>
<td class="max-w-md text-xs">
<div class="font-medium text-slate-700"><%= c.method_label %><%= " · #{c.ad_revision}" if c.ad_revision.present? %></div>
<%= c.compliance_notes %>
<% if c.logbook_entry || c.inspection_record %>
<div class="mt-1 flex flex-wrap gap-x-3">
<% if c.logbook_entry %><%= link_to "Logbook #{fmt_date(c.logbook_entry.date)}", aircraft_logbook_entry_path(@aircraft, c.logbook_entry), class: "link" %><% end %>
<% if c.logbook_entry %><%= link_to t(".logbook", date: fmt_date(c.logbook_entry.date)), aircraft_logbook_entry_path(@aircraft, c.logbook_entry), class: "link" %><% end %>
<% if c.inspection_record %><%= link_to "#{c.inspection_record.inspection_type.name} #{fmt_date(c.inspection_record.date)}", aircraft_inspections_path(@aircraft), class: "link" %><% end %>
</div>
<% end %>
</td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_ad_compliance_path(@aircraft, c), class: "btn-secondary btn-sm" %><% end %></td>
<td class="text-right"><% if owner? %><%= link_to t(".edit"), edit_aircraft_ad_compliance_path(@aircraft, c), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No compliance records." %>
<%= empty_state t(".no_compliance_records") %>
<% end %>
</section>
+31 -31
View File
@@ -2,56 +2,56 @@
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<div>
<%= f.field :component_type_id, as: :select, label: "Type",
collection: ComponentType.ordered.map { [_1.name, _1.id] }, include_blank: "— Select —" %>
<%= text_field_tag :new_component_type, params[:new_component_type], class: "input mt-2", placeholder: "…or type a new one" %>
<%= f.field :component_type_id, as: :select, label: t(".type"),
collection: ComponentType.ordered.map { [_1.name, _1.id] }, include_blank: t(".select") %>
<%= text_field_tag :new_component_type, params[:new_component_type], class: "input mt-2", placeholder: t(".or_type_a_new_one") %>
</div>
<%= f.field :manufacturer, required: true %>
<%= f.field :model, required: true %>
<%= f.field :serial_number %>
<%= f.field :install_location, hint: "e.g. Left mag, #3 cylinder" %>
<%= f.field :install_location, hint: t(".e_g_left_mag_3") %>
<%= f.field :status, as: :select, collection: Component::STATUSES.invert %>
<%= f.field :parent_component_id, as: :select, label: "Parent component",
collection: [["— None —", nil]] + aircraft.components.where.not(id: component.id).includes(:component_type).map { [_1.to_s, _1.id] } %>
<%= f.field :parent_component_id, as: :select, label: t(".parent_component"),
collection: [[t(".none"), nil]] + aircraft.components.where.not(id: component.id).includes(:component_type).map { [_1.to_s, _1.id] } %>
</div>
<fieldset class="grid gap-4 sm:grid-cols-4">
<legend class="mb-2 text-sm font-semibold text-slate-900">Time</legend>
<legend class="mb-2 text-sm font-semibold text-slate-900"><%= t(".time") %></legend>
<%= f.field :date_in_service, as: :date, required: true %>
<%= f.field :hours_in_service, as: :number, step: 0.1, label: "Total time (hours)" %>
<%= f.field :overhaul_date, as: :date, label: "Last overhaul / service" %>
<%= f.field :hours_since_overhaul, as: :number, step: 0.1, label: "Hours since OH / service" %>
<%= f.field :overhaul_kind, as: :select, label: "Overhaul type", include_blank: "—", collection: Component::OVERHAUL_KINDS.invert,
wrapper: { class: "sm:col-span-2" }, hint: "For engines and propellers: printed in logbook entries as SMOH, SFOH or SNEW." %>
<%= f.field :hours_in_service, as: :number, step: 0.1, label: t(".total_time_hours") %>
<%= f.field :overhaul_date, as: :date, label: t(".last_overhaul_service") %>
<%= f.field :hours_since_overhaul, as: :number, step: 0.1, label: t(".hours_since_oh_service") %>
<%= f.field :overhaul_kind, as: :select, label: t(".overhaul_type"), include_blank: "—", collection: Component::OVERHAUL_KINDS.invert,
wrapper: { class: "sm:col-span-2" }, hint: t(".for_engines_and_propellers_printed") %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold text-slate-900">Limits</legend>
<%= f.field :replacement_hours, as: :number, label: "Replace every (hrs)" %>
<%= f.interval :replacement, label: "Replace every" %>
<%= f.field :replacement_from_install, as: :select, label: "Replacement counts from",
collection: [ [ "Last service", false ], [ "Installation (life limit)", true ] ],
hint: "Installation: for a part that's cleaned and reused but has a life limit (e.g. a reusable oil filter); only Replaced restarts it." %>
<%= f.field :replacement_critical, as: :checkbox, label: "Replacement critical", hint: "Overdue replacement or expiry grounds the aircraft (oil, filters, ELT battery…)." %>
<%= f.field :expires_on, as: :date, label: "Expires on",
hint: "The date marked on the part, e.g. an ELT battery's replacement date (14 CFR 91.207(c): also replace it after 1 hour of cumulative use)." %>
<%= f.field :tbo_hours, as: :number, label: "TBO (hrs)" %>
<%= f.interval :tbo, label: "TBO (calendar)" %>
<legend class="mb-2 text-sm font-semibold text-slate-900"><%= t(".limits") %></legend>
<%= f.field :replacement_hours, as: :number, label: t(".replace_every_hrs") %>
<%= f.interval :replacement, label: t(".replace_every") %>
<%= f.field :replacement_from_install, as: :select, label: t(".replacement_counts_from"),
collection: [ [ t(".last_service"), false ], [ t(".installation_life_limit"), true ] ],
hint: t(".installation_for_a_part_that") %>
<%= f.field :replacement_critical, as: :checkbox, label: t(".replacement_critical"), hint: t(".overdue_replacement_or_expiry_grounds") %>
<%= f.field :expires_on, as: :date, label: t(".expires_on"),
hint: t(".the_date_marked_on_the") %>
<%= f.field :tbo_hours, as: :number, label: t(".tbo_hrs") %>
<%= f.interval :tbo, label: t(".tbo_calendar") %>
<div class="space-y-2">
<%= f.field :tbo_critical, as: :checkbox, label: "Treat TBO as a hard limit",
hint: "Under Part 91, TBO is usually the manufacturer's recommendation, unless an AD or the Airworthiness Limitations make it mandatory." %>
<%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)",
hint: "Run past TBO based on condition: TBO is shown for reference, never as a limit (this overrides the hard limit)." %>
<%= f.field :tbo_critical, as: :checkbox, label: t(".treat_tbo_as_a_hard"),
hint: t(".under_part_91_tbo_is") %>
<%= f.field :on_condition, as: :checkbox, label: t(".on_condition_part_91"),
hint: t(".run_past_tbo_based_on") %>
</div>
<p class="hint sm:col-span-3">Recurring inspections of this part (e.g. a 500-hour magneto inspection) are set up on the Inspections tab and applied to it.</p>
<p class="hint sm:col-span-3"><%= t(".recurring_inspections_of_this_part") %></p>
</fieldset>
<%= f.field :notes, as: :textarea, rows: 3 %>
<div class="flex gap-2">
<%= f.submit component.new_record? ? "Add Component" : "Save" %>
<%= link_to "Cancel", aircraft_components_path(aircraft), class: "btn-secondary" %>
<%= f.submit component.new_record? ? t(".add_component") : t(".save") %>
<%= link_to t(".cancel"), aircraft_components_path(aircraft), class: "btn-secondary" %>
</div>
<% end %>
<% if component.persisted? %>
<div class="mt-4"><%= delete_button "Delete component", aircraft_component_path(aircraft, component), confirm: "Delete #{component} and its sub-components?" %></div>
<div class="mt-4"><%= delete_button t(".delete_component"), aircraft_component_path(aircraft, component), confirm: t(".delete_and_its_sub_components", component: component) %></div>
<% end %>
+1 -1
View File
@@ -1,3 +1,3 @@
<% content_for :title, "Edit Component" %>
<% content_for :title, t(".edit_component") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, component: @component %>
+13 -13
View File
@@ -1,23 +1,23 @@
<% content_for :title, "#{@aircraft.tail_number} Components" %>
<% content_for :title, t(".components", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Components</h2>
<h2 class="card-title"><%= t(".components_2") %></h2>
<div class="flex items-center gap-3">
<%= link_to (@show_disposed ? "Hide disposed" : "Show disposed"),
<%= link_to (@show_disposed ? t(".hide_disposed") : t(".show_disposed")),
aircraft_components_path(@aircraft, disposed: (@show_disposed ? nil : 1)), class: "link text-sm" %>
<% if owner? %><%= link_to "+ Add Component", new_aircraft_component_path(@aircraft), class: "btn-primary" %><% end %>
<% if owner? %><%= link_to t(".add_component"), new_aircraft_component_path(@aircraft), class: "btn-primary" %><% end %>
</div>
</div>
<% if @rows.empty? %>
<%= empty_state "No components yet. Add the engine, propeller, oil filter, ELT battery, etc." %>
<%= empty_state t(".no_components_yet_add_the") %>
<% else %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr>
<th>Component</th><th>Make / Model</th><th>Status</th>
<th class="text-right">In service</th><th class="text-right">Since OH/svc</th>
<th>Limit</th><th>Life</th><th></th>
<th><%= t(".component") %></th><th><%= t(".make_model") %></th><th><%= t(".status") %></th>
<th class="text-right"><%= t(".in_service") %></th><th class="text-right"><%= t(".since_oh_svc") %></th>
<th><%= t(".limit") %></th><th><%= t(".life") %></th><th></th>
</tr></thead>
<tbody>
<% @rows.each do |c, depth| %>
@@ -32,16 +32,16 @@
<td class="text-right tabular-nums"><%= hours(c.hours_since_overhaul) %></td>
<td class="text-xs text-slate-600">
<% if c.replacement_critical? && (c.replacement_hours || c.replacement_calendar?) %>
Replace: <%= [c.replacement_hours && "#{c.replacement_hours} h", c.replacement_interval_label].compact.join(" / ") %><%= " since installed" if c.replacement_from_install? %><br>
<%= t(".replace_html", interval: ([c.replacement_hours && "#{c.replacement_hours} h", c.replacement_interval_label].compact.join(" / ")), installed: (t(".since_installed") if c.replacement_from_install?)) %>
<% end %>
<% if c.tbo_critical? && c.tbo_hours %>TBO: <%= c.tbo_hours %> h<%= " (on condition)" if c.on_condition? %><br><% end %>
<% if c.expires_on %>Expires: <%= fmt_date(c.expires_on) %><% end %>
<% if c.tbo_critical? && c.tbo_hours %><%= t(".tbo_h_html", tbo_hours: c.tbo_hours, on_condition: (t(".on_condition") if c.on_condition?)) %><% end %>
<% if c.expires_on %><%= t(".expires_html", expires_on: (fmt_date(c.expires_on))) %><% end %>
</td>
<td><%= life_badge(c.life_status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Edit", edit_aircraft_component_path(@aircraft, c), class: "btn-secondary btn-sm" %>
<%= link_to "Service", aircraft_component_path(@aircraft, c, anchor: "service"), class: "btn-secondary btn-sm" %>
<%= link_to t(".edit"), edit_aircraft_component_path(@aircraft, c), class: "btn-secondary btn-sm" %>
<%= link_to t(".service"), aircraft_component_path(@aircraft, c, anchor: "service"), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
+1 -1
View File
@@ -1,3 +1,3 @@
<% content_for :title, "Add Component" %>
<% content_for :title, t(".add_component") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, component: @component %>
+29 -29
View File
@@ -6,30 +6,30 @@
<h2 class="card-title"><%= @component %> <%= life_badge(@component.life_status) %></h2>
<% if owner? %>
<div class="flex gap-2">
<%= link_to "+ Sub-component", new_aircraft_component_path(@aircraft, parent_id: @component.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_component_path(@aircraft, @component), class: "btn-secondary btn-sm" %>
<%= link_to t(".sub_component"), new_aircraft_component_path(@aircraft, parent_id: @component.id), class: "btn-secondary btn-sm" %>
<%= link_to t(".edit"), edit_aircraft_component_path(@aircraft, @component), class: "btn-secondary btn-sm" %>
</div>
<% end %>
</div>
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Manufacturer</dt><dd><%= @component.manufacturer %></dd>
<dt class="text-slate-500">Model</dt><dd><%= @component.model %></dd>
<dt class="text-slate-500">Serial</dt><dd><%= @component.serial_number.presence || "—" %></dd>
<dt class="text-slate-500">Status</dt><dd><%= @component.status_label %></dd>
<dt class="text-slate-500">Parent</dt><dd><%= @component.parent_component ? link_to(@component.parent_component, aircraft_component_path(@aircraft, @component.parent_component), class: "link") : "—" %></dd>
<dt class="text-slate-500">Location</dt><dd><%= @component.install_location.presence || "—" %></dd>
<dt class="text-slate-500">In service since</dt><dd><%= fmt_date(@component.date_in_service) %></dd>
<dt class="text-slate-500">Last OH / service</dt><dd><%= fmt_date(@component.overhaul_date) %></dd>
<dt class="text-slate-500">Hours in service</dt><dd><%= hours(@component.hours_in_service) %></dd>
<dt class="text-slate-500">Since OH / service</dt><dd><%= hours(@component.hours_since_overhaul) %></dd>
<dt class="text-slate-500">TBO</dt><dd><%= @component.tbo_hours ? "#{@component.tbo_hours} h (#{hours(@component.hours_to_tbo)} remaining)" : "—" %></dd>
<dt class="text-slate-500">Replacement</dt><dd>
<%= [@component.replacement_hours && "#{@component.replacement_hours} h", @component.replacement_interval_label].compact.join(" / ").presence&.then { @component.replacement_from_install? ? "#{_1} since installed" : _1 } || "—" %>
<% if (d = @component.next_replacement_date) %><div class="text-xs text-slate-500">Next by <%= fmt_date(d) %></div><% end %>
<dt class="text-slate-500"><%= t(".manufacturer") %></dt><dd><%= @component.manufacturer %></dd>
<dt class="text-slate-500"><%= t(".model") %></dt><dd><%= @component.model %></dd>
<dt class="text-slate-500"><%= t(".serial") %></dt><dd><%= @component.serial_number.presence || "—" %></dd>
<dt class="text-slate-500"><%= t(".status") %></dt><dd><%= @component.status_label %></dd>
<dt class="text-slate-500"><%= t(".parent") %></dt><dd><%= @component.parent_component ? link_to(@component.parent_component, aircraft_component_path(@aircraft, @component.parent_component), class: "link") : "—" %></dd>
<dt class="text-slate-500"><%= t(".location") %></dt><dd><%= @component.install_location.presence || "—" %></dd>
<dt class="text-slate-500"><%= t(".in_service_since") %></dt><dd><%= fmt_date(@component.date_in_service) %></dd>
<dt class="text-slate-500"><%= t(".last_oh_service") %></dt><dd><%= fmt_date(@component.overhaul_date) %></dd>
<dt class="text-slate-500"><%= t(".hours_in_service") %></dt><dd><%= hours(@component.hours_in_service) %></dd>
<dt class="text-slate-500"><%= t(".since_oh_service") %></dt><dd><%= hours(@component.hours_since_overhaul) %></dd>
<dt class="text-slate-500"><%= t(".tbo") %></dt><dd><%= @component.tbo_hours ? t(".h_remaining", tbo_hours: @component.tbo_hours, hours_to_tbo: (hours(@component.hours_to_tbo))) : "—" %></dd>
<dt class="text-slate-500"><%= t(".replacement") %></dt><dd>
<%= [@component.replacement_hours && "#{@component.replacement_hours} h", @component.replacement_interval_label].compact.join(" / ").presence&.then { @component.replacement_from_install? ? t(".since_installed", interval: _1) : _1 } || "—" %>
<% if (d = @component.next_replacement_date) %><div class="text-xs text-slate-500"><%= t(".next_by_html", d: (fmt_date(d))) %></div><% end %>
</dd>
<dt class="text-slate-500">Flags</dt>
<dt class="text-slate-500"><%= t(".flags") %></dt>
<dd class="col-span-3 flex flex-wrap gap-1">
<% { tbo_critical: "TBO critical", replacement_critical: "Replacement critical", on_condition: "On condition" }.each do |flag, label| %>
<% { tbo_critical: t(".tbo_critical"), replacement_critical: t(".replacement_critical"), on_condition: t(".on_condition") }.each do |flag, label| %>
<% if @component.public_send("#{flag}?") %><span class="badge-blue"><%= label %></span><% end %>
<% end %>
</dd>
@@ -39,15 +39,15 @@
<% if owner? %>
<section class="card" id="service">
<div class="card-header"><h2 class="card-title">Service / Replace</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".service_replace") %></h2></div>
<%= form_with url: reset_service_aircraft_component_path(@aircraft, @component), method: :post, class: "card-body space-y-3",
data: { turbo_confirm: "Reset hours for #{@component}?" } do |f| %>
<p class="text-sm text-slate-600">Resets <strong>hours since overhaul</strong> to 0 and sets the service date to today.</p>
data: { turbo_confirm: t(".reset_hours_for", component: @component) } do |f| %>
<p class="text-sm text-slate-600"><%= t(".resets_hours_since_overhaul_to_html") %></p>
<label class="flex items-start gap-2 text-sm">
<%= f.check_box :reset_in_service, class: "mt-0.5 h-4 w-4" %>
<span>Part was physically <strong>replaced</strong> — also reset hours in service and in-service date.</span>
<span><%= t(".part_was_physically_replaced_also_html") %></span>
</label>
<%= f.submit "Record Service", class: "btn-primary" %>
<%= f.submit t(".record_service"), class: "btn-primary" %>
<% end %>
</section>
<% end %>
@@ -56,16 +56,16 @@
<% if @inspection_rows.any? || owner? %>
<section class="card mt-5" id="inspections">
<div class="card-header">
<h2 class="card-title">Inspections of this component</h2>
<% if owner? %><%= link_to "+ Inspection", new_aircraft_inspection_type_path(@aircraft, component_id: @component.id), class: "btn-secondary btn-sm" %><% end %>
<h2 class="card-title"><%= t(".inspections_of_this_component") %></h2>
<% if owner? %><%= link_to t(".inspection"), new_aircraft_inspection_type_path(@aircraft, component_id: @component.id), class: "btn-secondary btn-sm" %><% end %>
</div>
<% if @inspection_rows.any? %>
<table class="table">
<thead><tr><th>Inspection</th><th>Interval</th><th>Last done</th><th>Next due</th><th>Status</th></tr></thead>
<thead><tr><th><%= t(".inspection_2") %></th><th><%= t(".interval") %></th><th><%= t(".last_done") %></th><th><%= t(".next_due") %></th><th><%= t(".status") %></th></tr></thead>
<tbody>
<% @inspection_rows.each do |row| %>
<tr>
<td class="font-medium"><%= row.type.name %><%= tag.span(" advisory", class: "text-xs text-slate-500") if row.type.advisory? %></td>
<td class="font-medium"><%= row.type.name %><%= tag.span(t(".advisory"), class: "text-xs text-slate-500") if row.type.advisory? %></td>
<td class="text-xs"><%= row.type.interval_description %></td>
<td class="text-xs"><%= row.latest ? "#{fmt_date(row.latest.date)} @ #{hours(row.latest.hours_at_inspection)} h" : "—" %></td>
<td class="text-xs"><%= [row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %></td>
@@ -75,14 +75,14 @@
</tbody>
</table>
<% else %>
<p class="card-body text-sm text-slate-500">None. Add one for a recurring inspection of this part (e.g. a 500-hour magneto inspection); it's tracked on the Inspections tab and can be completed from a logbook entry.</p>
<p class="card-body text-sm text-slate-500"><%= t(".none_add_one_for_a") %></p>
<% end %>
</section>
<% end %>
<% if @squawks.any? %>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Squawks on this component</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".squawks_on_this_component") %></h2></div>
<%= render "squawks/table", squawks: @squawks, aircraft: @aircraft %>
</section>
<% end %>
+8 -8
View File
@@ -1,15 +1,15 @@
<%= form_with model: [aircraft, record], class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :record_type, as: :select, label: "Type", collection: ConsumableRecord::TYPES.invert %>
<%= f.field :record_type, as: :select, label: t(".type"), collection: ConsumableRecord::TYPES.invert %>
<%= f.field :date, as: :date %>
<%= f.field :quantity_added, as: :number, step: 0.01, label: "Quantity added (qt / gal)" %>
<%= f.field :level_after, as: :number, step: 0.01, label: "Level after" %>
<%= f.field :consumable_type, label: "Product", placeholder: "Aeroshell W100 / 100LL" %>
<%= f.field :flight_hours, as: :number, step: 0.1, label: "Tach at time of record" %>
<%= f.field :quantity_added, as: :number, step: 0.01, label: t(".quantity_added_qt_gal") %>
<%= f.field :level_after, as: :number, step: 0.01, label: t(".level_after") %>
<%= f.field :consumable_type, label: t(".product"), placeholder: t(".aeroshell_w100_100ll") %>
<%= f.field :flight_hours, as: :number, step: 0.1, label: t(".tach_at_time_of_record") %>
</div>
<%= f.field :notes, as: :textarea, rows: 2 %>
<%= f.field :excluded_from_averages, as: :checkbox, label: "Exclude from averages", hint: "Use for oil changes: the quantity added is ignored in consumption rates." %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_consumable_records_path(aircraft), class: "btn-secondary" %></div>
<%= f.field :excluded_from_averages, as: :checkbox, label: t(".exclude_from_averages"), hint: t(".use_for_oil_changes_the") %>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_consumable_records_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_consumable_record_path(aircraft, record) %></div><% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button t(".delete_record"), aircraft_consumable_record_path(aircraft, record) %></div><% end %>
@@ -8,7 +8,7 @@
<col class="w-28"><col class="w-24"><col class="w-24"><col class="w-24"><col><col class="w-24"><col><col class="w-20">
</colgroup>
<% if page == 1 %>
<thead><tr><th>Date</th><th>Type</th><th class="text-right">Added</th><th class="text-right">Level after</th><th>Product</th><th class="text-right">Tach</th><th>Notes</th><th></th></tr></thead>
<thead><tr><th><%= t(".date") %></th><th><%= t(".type") %></th><th class="text-right"><%= t(".added") %></th><th class="text-right"><%= t(".level_after") %></th><th><%= t(".product") %></th><th class="text-right"><%= t(".tach") %></th><th><%= t(".notes") %></th><th></th></tr></thead>
<% end %>
<tbody>
<% records.each do |r| %>
@@ -19,8 +19,8 @@
<td class="text-right tabular-nums" data-label="Level after"><%= r.level_after ? "#{r.level_after} #{r.unit}" : "" %></td>
<td class="truncate" data-label="Product"><%= r.consumable_type %></td>
<td class="text-right tabular-nums" data-label="Tach"><%= hours(r.flight_hours) %></td>
<td class="text-xs text-slate-500 break-words"><%= r.notes %><%= " (excluded from average)" if r.excluded_from_averages? %></td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_consumable_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
<td class="text-xs text-slate-500 break-words"><%= r.notes %><%= t(".excluded_from_average") if r.excluded_from_averages? %></td>
<td class="text-right"><% if owner? %><%= link_to t(".edit"), edit_aircraft_consumable_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
@@ -29,7 +29,7 @@
<% if more %>
<%= turbo_frame_tag "consumable-records-#{page + 1}", src: aircraft_consumable_records_path(@aircraft, page: page + 1), loading: :lazy, target: "_top", class: "block" do %>
<p class="px-4 py-4 text-center text-sm text-slate-500">
Loading earlier records… <%= link_to "Load more", aircraft_consumable_records_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "consumable-records-#{page + 1}" } %>
<%= t(".loading_earlier_records_html", link: (link_to t(".load_more"), aircraft_consumable_records_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "consumable-records-#{page + 1}" })) %>
</p>
<% end %>
<% end %>
+9 -9
View File
@@ -1,24 +1,24 @@
<% content_for :title, "#{@aircraft.tail_number} Oil & Fuel" %>
<% content_for :title, t(".oil_fuel", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "shared/oil_subnav", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-2">
<% [@oil, @fuel].each do |stats| %>
<section class="card">
<div class="card-header">
<h2 class="card-title"><%= stats.oil? ? "Oil Consumption" : "Fuel Burn" %></h2>
<%= link_to "+ Add #{stats.oil? ? 'Oil' : 'Fuel'}", new_aircraft_consumable_record_path(@aircraft, type: stats.record_type), class: "btn-secondary btn-sm" %>
<h2 class="card-title"><%= stats.oil? ? t(".oil_consumption") : t(".fuel_burn") %></h2>
<%= link_to t(stats.oil? ? ".add_oil" : ".add_fuel"), new_aircraft_consumable_record_path(@aircraft, type: stats.record_type), class: "btn-secondary btn-sm" %>
</div>
<div class="card-body">
<div class="mb-3 flex flex-wrap gap-x-6 gap-y-1 text-sm">
<div><span class="text-2xl font-semibold"><%= stats.recent || "—" %></span> <span class="text-slate-500"><%= stats.metric_label %>, last ~<%= stats.recent_window_hours %> hrs</span></div>
<div><span class="text-lg"><%= stats.lifetime || "—" %></span> <span class="text-slate-500">lifetime</span></div>
<div><span class="text-2xl font-semibold"><%= stats.recent || "—" %></span> <span class="text-slate-500"><%= t(".last_hrs_html", metric_label: stats.metric_label, recent_window_hours: stats.recent_window_hours) %></span></div>
<div><span class="text-lg"><%= stats.lifetime || "—" %></span> <span class="text-slate-500"><%= t(".lifetime") %></span></div>
</div>
<% if stats.points.size >= 2 %>
<%= line_chart stats.chart_data, xtitle: "Tach hours", ytitle: stats.metric_label, height: "220px", curve: false, points: false,
library: { scales: { x: { type: "linear" } } }, colors: [stats.oil? ? "#b45309" : "#0369a1"] %>
<p class="hint">Rolling <%= stats.chart_window_hours %>-hour window: total <%= stats.oil? ? "oil" : "fuel" %> added ÷ hours flown, so partial fills average out.<%= " Higher is better." if stats.oil? %></p>
<p class="hint"><%= t(".rolling_hour_window_total_added_html", chart_window_hours: stats.chart_window_hours, fuel: (stats.oil? ? "oil" : "fuel"), oil: (t(".higher_is_better") if stats.oil?)) %></p>
<% else %>
<%= empty_state "Not enough history yet (need more than #{stats.chart_window_hours} tach hours of records)." %>
<%= empty_state t(".not_enough_history_yet_need", chart_window_hours: stats.chart_window_hours) %>
<% end %>
</div>
</section>
@@ -26,10 +26,10 @@
</div>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">Records</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".records") %></h2></div>
<% if @records.any? %>
<%= render "consumable_records/records", records: @records, page: @page, more: @more %>
<% else %>
<%= empty_state "No oil or fuel records yet." %>
<%= empty_state t(".no_oil_or_fuel_records") %>
<% end %>
</section>
@@ -2,8 +2,8 @@
<%= f.errors_summary %>
<%= f.field :name, required: true %>
<%= f.field :description, as: :textarea, rows: 2 %>
<%= f.field :visibility, as: :select, label: "Share-link visibility", collection: DocumentCollection::VISIBILITIES.invert %>
<%= f.field :starred, as: :checkbox, label: "Starred (shown first)" %>
<div class="flex gap-2"><%= f.submit "Save Collection" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<%= f.field :visibility, as: :select, label: t(".share_link_visibility"), collection: DocumentCollection::VISIBILITIES.invert %>
<%= f.field :starred, as: :checkbox, label: t(".starred_shown_first") %>
<div class="flex gap-2"><%= f.submit t(".save_collection") %><%= link_to t(".cancel"), aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if collection.persisted? %><div class="mt-4"><%= delete_button "Delete collection and its documents", aircraft_document_collection_path(aircraft, collection) %></div><% end %>
<% if collection.persisted? %><div class="mt-4"><%= delete_button t(".delete_collection_and_its_documents"), aircraft_document_collection_path(aircraft, collection) %></div><% end %>
+4 -4
View File
@@ -1,13 +1,13 @@
<li class="flex items-center justify-between gap-3 px-4 py-2">
<div>
<%= link_to doc.name, aircraft_document_path(aircraft, doc), class: "link font-medium" %>
<span class="ml-2 text-xs text-slate-500"><%= doc.type_label %> · <%= pluralize(doc.pages.size, "file") %></span>
<% if doc.legacy_record? %><span class="ml-1 badge-gray" title="Scan of the paper (legacy) records">Legacy record</span><% end %>
<% if doc.expires_on %><span class="ml-1 <%= doc.expired? ? 'badge-red' : (Date.current + doc.expiry_warning_days >= doc.expires_on ? 'badge-orange' : 'badge-gray') %>"><%= doc.expired? ? "Expired" : "Expires" %> <%= fmt_date(doc.expires_on) %></span><% end %>
<span class="ml-2 text-xs text-slate-500"><%= doc.type_label %> · <%= t("counts.file", count: doc.pages.size) %></span>
<% if doc.legacy_record? %><span class="ml-1 badge-gray" title="<%= t(".scan_of_the_paper_legacy") %>"><%= t(".legacy_record") %></span><% end %>
<% if doc.expires_on %><span class="ml-1 <%= doc.expired? ? 'badge-red' : (Date.current + doc.expiry_warning_days >= doc.expires_on ? 'badge-orange' : 'badge-gray') %>"><%= doc.expired? ? t(".expired") : t(".expires") %> <%= fmt_date(doc.expires_on) %></span><% end %>
<% if doc.description.present? %><div class="text-xs text-slate-500"><%= doc.description.truncate(120) %></div><% end %>
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(doc.effective_visibility) %>
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(aircraft, doc), class: "btn-secondary btn-sm" %><% end %>
<% if owner? %><%= link_to t(".edit"), edit_aircraft_document_path(aircraft, doc), class: "btn-secondary btn-sm" %><% end %>
</div>
</li>
+15 -15
View File
@@ -2,30 +2,30 @@
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :name, required: true %>
<%= f.field :doc_type, as: :select, label: "Type", collection: Document::TYPES.invert %>
<%= f.field :document_collection_id, as: :select, label: "Collection",
collection: [["— None —", nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
<%= f.field :visibility, as: :select, label: "Share-link visibility",
collection: [["Inherit from collection", nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
<%= f.field :doc_type, as: :select, label: t(".type"), collection: Document::TYPES.invert %>
<%= f.field :document_collection_id, as: :select, label: t(".collection"),
collection: [[t(".none"), nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
<%= f.field :visibility, as: :select, label: t(".share_link_visibility"),
collection: [[t(".inherit_from_collection"), nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
</div>
<%= f.field :legacy_record, as: :checkbox, label: "Legacy record (a scan of the paper logbooks or records)",
hint: "Records from before the electronic records began. Keep the paper originals." %>
<%= f.field :expires_on, as: :date, label: "Expires on", wrapper: { class: "max-w-xs" },
hint: "Optional. Registration (good for 7 years, 14 CFR 47.40), insurance, radio license… You'll be reminded before it expires; an expired registration shows the aircraft grounded." %>
<%= f.field :legacy_record, as: :checkbox, label: t(".legacy_record_a_scan_of"),
hint: t(".records_from_before_the_electronic") %>
<%= f.field :expires_on, as: :date, label: t(".expires_on"), wrapper: { class: "max-w-xs" },
hint: t(".optional_registration_good_for_7") %>
<%= f.field :description, as: :textarea, rows: 2 %>
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? "Add files" : "Files",
hint: "Images, PDFs or text, up to #{Setting.max_upload_mb} MB each. Each file is a page in the viewer, in upload order." %>
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? t(".add_files") : t(".files"),
hint: t(".images_pdfs_or_text_up", max_upload_mb: Setting.max_upload_mb) %>
<% if document.persisted? && document.pages.any? %>
<div>
<p class="label">Remove existing files</p>
<p class="label"><%= t(".remove_existing_files") %></p>
<% document.pages.each do |p| %>
<label class="flex items-center gap-2 text-sm"><%= check_box_tag "remove_page_ids[]", p.id, false %> <%= p.filename %></label>
<% end %>
</div>
<% end %>
<% unless document.persisted? %>
<p class="text-sm text-slate-500">Lots of files? <%= link_to "Bulk upload", new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link" %> makes a document from each one.</p>
<p class="text-sm text-slate-500"><%= t(".lots_of_files_makes_a_html", link: (link_to t(".bulk_upload"), new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link")) %></p>
<% end %>
<div class="flex gap-2"><%= f.submit "Save Document" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save_document") %><%= link_to t(".cancel"), aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if document.persisted? %><div class="mt-4"><%= delete_button "Delete document", aircraft_document_path(aircraft, document) %></div><% end %>
<% if document.persisted? %><div class="mt-4"><%= delete_button t(".delete_document"), aircraft_document_path(aircraft, document) %></div><% end %>
+5 -5
View File
@@ -1,13 +1,13 @@
<%# Multi-page viewer: one attachment per "page", with prev/next. %>
<% pages = document.pages.to_a %>
<% if pages.empty? %>
<%= empty_state "No files uploaded." %>
<%= empty_state t(".no_files_uploaded") %>
<% else %>
<% current = pages[page - 1] %>
<div class="mb-3 flex items-center justify-between text-sm">
<%= link_to "← Prev", url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
<span>Page <%= page %> of <%= pages.size %> · <%= link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link" %></span>
<%= link_to "Next →", url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
<%= link_to t(".prev"), url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
<span><%= t(".page_of_html", page: page, pages: pages.size, link: (link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link")) %></span>
<%= link_to t(".next"), url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
</div>
<div class="flex justify-center rounded bg-slate-50 p-2">
<% if current.image? %>
@@ -15,7 +15,7 @@
<% elsif current.content_type == "application/pdf" %>
<iframe src="<%= rails_blob_path(current, disposition: :inline) %>" class="h-[80vh] w-full"></iframe>
<% else %>
<p class="p-6 text-sm"><%= link_to "Download #{current.filename}", rails_blob_path(current, disposition: :attachment), class: "link" %></p>
<p class="p-6 text-sm"><%= link_to t(".download", filename: current.filename), rails_blob_path(current, disposition: :attachment), class: "link" %></p>
<% end %>
</div>
<% end %>
+17 -17
View File
@@ -1,12 +1,12 @@
<% content_for :title, "#{@aircraft.tail_number} Bulk Upload" %>
<% content_for :title, t(".bulk_upload", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% file_classes = "block w-full 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" %>
<%= form_with url: bulk_aircraft_documents_path(@aircraft), multipart: true, class: "card card-body max-w-3xl space-y-4",
data: { controller: "bulk-upload", bulk_upload_url_value: rails_direct_uploads_path,
bulk_upload_max_bytes_value: UploadValidation.max_size, action: "submit->bulk-upload#submit" } do %>
<div>
<h2 class="card-title">Bulk upload</h2>
<p class="text-sm text-slate-500">Each file becomes its own document, named after the file. Give files the same name to combine them, in order, as the pages of one document.</p>
<h2 class="card-title"><%= t(".bulk_upload_2") %></h2>
<p class="text-sm text-slate-500"><%= t(".each_file_becomes_its_own") %></p>
</div>
<% if @bulk_error %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @bulk_error %></div>
@@ -14,37 +14,37 @@
<div class="grid gap-4 sm:grid-cols-2">
<div>
<%= label_tag :doc_type, "Type", class: "label" %>
<%= label_tag :doc_type, t(".type"), class: "label" %>
<%= select_tag :doc_type, options_for_select(Document::TYPES.invert, @bulk[:doc_type]), class: "input" %>
</div>
<div>
<%= label_tag :visibility, "Share-link visibility", class: "label" %>
<%= select_tag :visibility, options_for_select([ [ "Inherit from collection", "" ] ] + DocumentCollection::VISIBILITIES.invert.to_a, @bulk[:visibility]), class: "input" %>
<%= label_tag :visibility, t(".share_link_visibility"), class: "label" %>
<%= select_tag :visibility, options_for_select([ [ t(".inherit_from_collection"), "" ] ] + DocumentCollection::VISIBILITIES.invert.to_a, @bulk[:visibility]), class: "input" %>
</div>
<div>
<%= label_tag :document_collection_id, "Collection", class: "label" %>
<%= label_tag :document_collection_id, t(".collection"), class: "label" %>
<%= select_tag :document_collection_id,
options_for_select([ [ "— None —", "" ] ] + @aircraft.document_collections.ordered.map { [ _1.name, _1.id ] }, @bulk[:document_collection_id]), class: "input" %>
options_for_select([ [ t(".none"), "" ] ] + @aircraft.document_collections.ordered.map { [ _1.name, _1.id ] }, @bulk[:document_collection_id]), class: "input" %>
</div>
<div>
<%= label_tag :new_collection, "…or a new collection", class: "label" %>
<%= text_field_tag :new_collection, @bulk[:new_collection], class: "input", placeholder: "e.g. 2025 Annual" %>
<%= label_tag :new_collection, t(".or_a_new_collection"), class: "label" %>
<%= text_field_tag :new_collection, @bulk[:new_collection], class: "input", placeholder: t(".e_g_2025_annual") %>
</div>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<div>
<%= label_tag :files, "Files", class: "label" %>
<%= label_tag :files, t(".files"), class: "label" %>
<%= file_field_tag "files[]", id: "files", multiple: true, class: file_classes,
data: { bulk_upload_target: "input", action: "change->bulk-upload#add" } %>
</div>
<div data-bulk-upload-target="folderField" hidden>
<%= label_tag :folder, "…or a whole folder", class: "label" %>
<%= label_tag :folder, t(".or_a_whole_folder"), class: "label" %>
<input type="file" id="folder" webkitdirectory multiple class="<%= file_classes %>"
data-bulk-upload-target="folder" data-action="change->bulk-upload#add">
</div>
</div>
<p class="hint !mt-1">Images, PDFs or text, up to <%= Setting.max_upload_mb %> MB each and <%= DocumentsController::MAX_BULK_FILES %> at a time.</p>
<p class="hint !mt-1"><%= t(".images_pdfs_or_text_up_html", max_upload_mb: Setting.max_upload_mb, max_files: (DocumentsController::MAX_BULK_FILES)) %></p>
<div data-bulk-upload-target="panel" hidden class="space-y-2">
<div class="flex flex-wrap items-center justify-between gap-2">
@@ -52,17 +52,17 @@
<div class="flex flex-wrap items-center gap-3">
<label class="flex items-center gap-2 text-sm text-slate-700" data-bulk-upload-target="groupField" hidden>
<input type="checkbox" class="h-4 w-4 rounded border-slate-300" data-bulk-upload-target="group" data-action="bulk-upload#regroup">
One document per folder
<%= t(".one_document_per_folder") %>
</label>
<button type="button" class="btn-secondary btn-sm" data-action="bulk-upload#clear">Clear</button>
<button type="button" class="btn-secondary btn-sm" data-action="bulk-upload#clear"><%= t(".clear") %></button>
</div>
</div>
<ul class="divide-y divide-slate-100 rounded-md ring-1 ring-slate-200" data-bulk-upload-target="list"></ul>
</div>
<div class="flex flex-wrap items-center gap-2">
<button type="submit" class="btn-primary" data-bulk-upload-target="submit">Upload</button>
<%= link_to "Cancel", aircraft_documents_path(@aircraft), class: "btn-secondary" %>
<button type="submit" class="btn-primary" data-bulk-upload-target="submit"><%= t(".upload") %></button>
<%= link_to t(".cancel"), aircraft_documents_path(@aircraft), class: "btn-secondary" %>
<p class="text-sm text-slate-500" data-bulk-upload-target="status" role="status"></p>
</div>
<% end %>
+9 -9
View File
@@ -1,16 +1,16 @@
<% content_for :title, "#{@aircraft.tail_number} Documents" %>
<% content_for :title, t(".documents", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="mb-4 flex flex-wrap justify-end gap-2">
<% if owner? %>
<%= more_menu do %>
<%= link_to "Upload several files", new_bulk_aircraft_documents_path(@aircraft), class: "menu-item" %>
<%= link_to "New collection", new_aircraft_document_collection_path(@aircraft), class: "menu-item" %>
<%= link_to t(".upload_several_files"), new_bulk_aircraft_documents_path(@aircraft), class: "menu-item" %>
<%= link_to t(".new_collection"), new_aircraft_document_collection_path(@aircraft), class: "menu-item" %>
<% end %>
<%= link_to "+ Upload Document", new_aircraft_document_path(@aircraft), class: "btn-primary" %>
<%= link_to t(".upload_document"), new_aircraft_document_path(@aircraft), class: "btn-primary" %>
<% end %>
</div>
<% if @collections.empty? && @uncollected.empty? %>
<div class="card"><%= empty_state "No documents yet. Upload logbook scans, 337s, weight & balance, receipts…" %></div>
<div class="card"><%= empty_state t(".no_documents_yet_upload_logbook") %></div>
<% end %>
<div class="space-y-5">
<% @collections.each do |col| %>
@@ -26,14 +26,14 @@
<div class="flex items-center gap-2">
<%= visibility_badge(col.visibility) %>
<% if owner? %>
<%= link_to "+ Document", new_aircraft_document_path(@aircraft, collection_id: col.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
<%= link_to t(".document"), new_aircraft_document_path(@aircraft, collection_id: col.id), class: "btn-secondary btn-sm" %>
<%= link_to t(".edit"), edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
<% end %>
</div>
</summary>
<% if col.documents.any? %>
<ul class="divide-y divide-slate-100"><% col.documents.sort_by(&:name).each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
<% else %><%= empty_state "Empty collection." %><% end %>
<% else %><%= empty_state t(".empty_collection") %><% end %>
</details>
<% end %>
<% if @uncollected.any? %>
@@ -41,7 +41,7 @@
<summary class="card-header cursor-pointer list-none border-b-0 group-open:border-b [&::-webkit-details-marker]:hidden">
<div class="flex items-start gap-2">
<span aria-hidden="true" class="mt-0.5 text-slate-400 transition group-open:rotate-90">›</span>
<h2 class="card-title">Uncollected <span class="text-sm font-normal text-slate-500">(<%= @uncollected.size %>)</span></h2>
<h2 class="card-title"><%= t(".uncollected") %> <span class="text-sm font-normal text-slate-500">(<%= @uncollected.size %>)</span></h2>
</div>
</summary>
<ul class="divide-y divide-slate-100"><% @uncollected.each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
+1 -1
View File
@@ -8,7 +8,7 @@
</div>
<div class="flex items-center gap-2">
<%= visibility_badge(@document.effective_visibility) %>
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(@aircraft, @document), class: "btn-secondary btn-sm" %><% end %>
<% if owner? %><%= link_to t(".edit"), edit_aircraft_document_path(@aircraft, @document), class: "btn-secondary btn-sm" %><% end %>
</div>
</div>
<div class="card-body">
+13 -13
View File
@@ -1,56 +1,56 @@
<%# Signing form: review, certificate, re-authentication, confirm. Locals: entry, url, cancel_path. %>
<section class="card max-w-3xl">
<div class="card-header"><h2 class="card-title">Sign this entry</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".sign_this_entry") %></h2></div>
<div class="card-body space-y-4">
<p class="text-sm text-slate-600">Review the entry: your signature will cover exactly what's shown here, and it can't be changed afterwards. A mistake is fixed with a correction entry. <%= link_to "How signing works", records_help_path, class: "link", target: "_blank" %></p>
<p class="text-sm text-slate-600"><%= t(".review_the_entry_your_signature_html", link: (link_to t(".how_signing_works"), records_help_path, class: "link", target: "_blank")) %></p>
<%= render "logbook_entries/content", entry: entry %>
<% if @signing_error %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @signing_error %></div>
<% end %>
<% if @certificates.empty? %>
<p class="rounded-md bg-amber-50 p-3 text-sm text-amber-900 ring-1 ring-amber-200">
To sign, add your certificate on <%= link_to "your profile", edit_profile_path(anchor: "certificates"), class: "link" %>.
<%= t(".to_sign_add_your_certificate_html", link: (link_to t(".your_profile"), edit_profile_path(anchor: "certificates"), class: "link")) %>
</p>
<% else %>
<%= form_with url: url, method: :post, class: "space-y-4" do %>
<fieldset class="space-y-2">
<legend class="label">Sign with</legend>
<legend class="label"><%= t(".sign_with") %></legend>
<% @certificates.each_with_index do |c, i| %>
<% problems = entry.signing_problems(c) %>
<label class="flex items-start gap-2 rounded-md p-2 text-sm ring-1 ring-slate-200 <%= 'opacity-60' if problems.any? %>">
<%= radio_button_tag :certificate_id, c.id, params[:certificate_id].to_s == c.id.to_s || (params[:certificate_id].blank? && i.zero? && problems.empty?),
disabled: problems.any?, class: "mt-1" %>
<span><strong><%= current_user.display_name %>, <%= c.kind_label %> <%= c.number %></strong>
<% if problems.any? %><span class="block text-xs text-red-700">Can't sign: <%= problems.to_sentence %>.</span>
<% else %><span class="block text-slate-600"><%= EntrySignature::LABEL %>: “<%= entry.certification_statement(c.kind) %>”</span><% end %></span>
<% if problems.any? %><span class="block text-xs text-red-700"><%= t(".can_t_sign_html", to_sentence: problems.to_sentence) %></span>
<% else %><span class="block text-slate-600"><%= EntrySignature.label %>: “<%= entry.certification_statement(c.kind) %>”</span><% end %></span>
</label>
<% end %>
</fieldset>
<% if Sso.password_login? || !current_user.sso_uid? %>
<div class="max-w-xs">
<%= label_tag :password, "Your password", class: "label" %>
<%= label_tag :password, t(".your_password"), class: "label" %>
<%= password_field_tag :password, nil, class: "input", autocomplete: "current-password" %>
<p class="hint">Proves it's you signing, not someone at your keyboard.<%= " Or sign in again with #{Sso.label} below." if Sso.enabled? && current_user.sso_uid? %></p>
<p class="hint"><%= t(".proves_it_s_you_signing_html", sso_uid: (t(".or_sign_in_again_with_2", so: Sso.label) if Sso.enabled? && current_user.sso_uid?)) %></p>
</div>
<% if current_user.otp_enabled? %>
<div class="max-w-xs">
<%= label_tag :otp_code, "Authenticator code", class: "label" %>
<%= label_tag :otp_code, t(".authenticator_code"), class: "label" %>
<%= text_field_tag :otp_code, nil, class: "input w-32 tracking-widest", autocomplete: "one-time-code", inputmode: "numeric", maxlength: 20 %>
</div>
<% end %>
<% end %>
<% if Sso.enabled? && current_user.sso_uid? %>
<% fresh = session[:reauthenticated_at] && Time.zone.at(session[:reauthenticated_at]) > EntrySigner::REAUTH_WINDOW.ago %>
<p class="text-sm <%= fresh ? 'text-emerald-700' : 'text-slate-600' %>"><%= fresh ? "Signed in again with #{Sso.label}: you can sign now." : "Or sign in again with #{Sso.label} first (button below the form)." %></p>
<p class="text-sm <%= fresh ? 'text-emerald-700' : 'text-slate-600' %>"><%= fresh ? t(".signed_in_again_with_you", so: Sso.label) : t(".or_sign_in_again_with", so: Sso.label) %></p>
<% end %>
<label class="flex items-start gap-2 text-sm">
<%= check_box_tag :confirm, "1", false, class: "mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300" %>
<span>I am signing this entry myself, with the intent to sign it, and certify the statement above.</span>
<span><%= t(".i_am_signing_this_entry") %></span>
</label>
<div class="flex gap-2"><%= submit_tag "Sign entry", class: "btn-primary" %><%= link_to "Cancel", cancel_path, class: "btn-secondary" %></div>
<div class="flex gap-2"><%= submit_tag t(".sign_entry"), class: "btn-primary" %><%= link_to t(".cancel"), cancel_path, class: "btn-secondary" %></div>
<% end %>
<% if Sso.enabled? && current_user.sso_uid? %>
<%= button_to "Sign in again with #{Sso.label}", "/auth/#{Sso::PROVIDER}", params: { prompt: "login" }, class: "btn-secondary btn-sm", data: { turbo: false } %>
<%= button_to t(".sign_in_again_with", so: Sso.label), "/auth/#{Sso::PROVIDER}", params: { prompt: "login" }, class: "btn-secondary btn-sm", data: { turbo: false } %>
<% end %>
<% end %>
</div>
+1 -1
View File
@@ -1,4 +1,4 @@
<% content_for :title, "Sign logbook entry" %>
<% content_for :title, t(".sign_logbook_entry") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "entry_signatures/form", entry: @entry, url: aircraft_logbook_entry_signature_path(@aircraft, @entry),
cancel_path: aircraft_logbook_entry_path(@aircraft, @entry) %>
+3 -3
View File
@@ -1,5 +1,5 @@
<div class="card mx-auto max-w-lg card-body text-center">
<h1 class="text-lg font-semibold">Not found</h1>
<p class="mt-2 text-sm text-slate-600">That page doesn't exist, or you don't have access to it.</p>
<% if current_user %><p class="mt-4"><%= link_to "Back to fleet", root_path, class: "btn-secondary" %></p><% end %>
<h1 class="text-lg font-semibold"><%= t(".not_found") %></h1>
<p class="mt-2 text-sm text-slate-600"><%= t(".that_page_doesn_t_exist") %></p>
<% if current_user %><p class="mt-4"><%= link_to t(".back_to_fleet"), root_path, class: "btn-secondary" %></p><% end %>
</div>
+2 -2
View File
@@ -6,11 +6,11 @@
<span><%= e.event_name %></span>
<span class="badge-gray"><%= AircraftEvent::CATEGORIES[e.category] %></span>
</div>
<div class="text-xs text-slate-500"><%= e.user&.display_name || "System" %> · <%= time_ago_in_words(e.created_at) %> ago</div>
<div class="text-xs text-slate-500"><%= t(".ago_html", who: (e.user&.display_name || t(".system")), created_at: (time_ago_in_words(e.created_at))) %></div>
<% if e.notes.present? && local_assigns[:full] %><div class="mt-1 text-xs text-slate-600"><%= e.notes %></div><% end %>
</li>
<% end %>
</ul>
<% else %>
<%= empty_state "No activity yet." %>
<%= empty_state t(".no_activity_yet") %>
<% end %>
+4 -4
View File
@@ -1,12 +1,12 @@
<% content_for :title, "#{@aircraft.tail_number} Activity" %>
<% content_for :title, t(".activity", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Activity Log</h2>
<h2 class="card-title"><%= t(".activity_log") %></h2>
<div class="flex flex-wrap items-center gap-2">
<%= link_to "Record history", aircraft_record_versions_path(@aircraft), class: "btn-secondary btn-sm", title: "Every change to the maintenance records, field by field" %>
<%= link_to t(".record_history"), aircraft_record_versions_path(@aircraft), class: "btn-secondary btn-sm", title: t(".every_change_to_the_maintenance") %>
<%= form_with url: aircraft_events_path(@aircraft), method: :get, class: "flex gap-2" do |f| %>
<%= f.select :category, AircraftEvent::CATEGORIES.invert, { include_blank: "All categories", selected: @category }, class: "input", data: { submit_on_change: true } %>
<%= f.select :category, AircraftEvent::CATEGORIES.invert, { include_blank: t(".all_categories"), selected: @category }, class: "input", data: { submit_on_change: true } %>
<% end %>
</div>
</div>
+18 -18
View File
@@ -1,40 +1,40 @@
<% content_for :title, "Import Flights" %>
<% content_for :title, t(".import_flights") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="grid gap-5 lg:grid-cols-3">
<%= form_with url: aircraft_flight_import_path(@aircraft), multipart: true, class: "card card-body space-y-4 lg:col-span-2" do |f| %>
<h2 class="card-title">Import flights from a spreadsheet</h2>
<h2 class="card-title"><%= t(".import_flights_from_a_spreadsheet") %></h2>
<div>
<%= f.label :file, "Spreadsheet (.xlsx or .csv)", class: "label" %>
<%= f.label :file, t(".spreadsheet_xlsx_or_csv"), class: "label" %>
<%= f.file_field :file, accept: ".xlsx,.csv", 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" %>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<div>
<%= f.label :starting_tach, "Tach before the first flight (optional)", class: "label" %>
<%= f.label :starting_tach, t(".tach_before_the_first_flight"), class: "label" %>
<%= f.number_field :starting_tach, step: 0.1, class: "input" %>
<p class="hint">E.g. the tach at purchase. Without it, the first row's time comes from a Flight Time column, if you have one.</p>
<p class="hint"><%= t(".e_g_the_tach_at") %></p>
</div>
<div>
<%= f.label :starting_hobbs, "Hobbs before the first flight (optional)", class: "label" %>
<%= f.label :starting_hobbs, t(".hobbs_before_the_first_flight"), class: "label" %>
<%= f.number_field :starting_hobbs, step: 0.1, class: "input" %>
</div>
</div>
<%= f.submit "Upload & Preview", class: "btn-primary" %>
<p class="hint">Nothing is saved until you confirm on the next page.</p>
<%= f.submit t(".upload_preview"), class: "btn-primary" %>
<p class="hint"><%= t(".nothing_is_saved_until_you") %></p>
<% end %>
<section class="card card-body text-sm text-slate-700 space-y-2">
<h3 class="font-semibold">Expected layout</h3>
<p>One row per flight, with the meter readings <em>at the end</em> of the flight. Columns are matched by header name, in any order:</p>
<h3 class="font-semibold"><%= t(".expected_layout") %></h3>
<p><%= t(".one_row_per_flight_with_html") %></p>
<ul class="list-disc pl-5 text-xs">
<li><strong>Date</strong> (required)</li>
<li><strong>Tach</strong> / Tach Time (required)</li>
<li>From, To</li>
<li>Hobbs / Hobbs Time</li>
<li>Oil Added (qt), Fuel Added (gal); “N” or blank = none</li>
<li>Flight Time (used only for the first row)</li>
<li><%= t(".date_required_html") %></li>
<li><%= t(".tach_tach_time_required_html") %></li>
<li><%= t(".from_to") %></li>
<li><%= t(".hobbs_hobbs_time") %></li>
<li><%= t(".oil_added_qt_fuel_added") %></li>
<li><%= t(".flight_time_used_only_for") %></li>
</ul>
<p class="text-xs">Each flight's time is the difference from the row above. Rows are kept in file order.</p>
<p class="text-xs">Importing records history only. It doesn't add time to components.</p>
<p class="text-xs"><%= t(".each_flight_s_time_is") %></p>
<p class="text-xs"><%= t(".importing_records_history_only_it") %></p>
</section>
</div>
+22 -22
View File
@@ -1,4 +1,4 @@
<% content_for :title, "Import Preview" %>
<% content_for :title, t(".import_preview") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% rows = @import.rows %>
<% problems = rows.select { _1.status.in?(%i[error warning]) } %>
@@ -6,20 +6,20 @@
<section class="card mb-5">
<div class="card-header">
<h2 class="card-title">Preview: <%= @filename %></h2>
<span class="text-xs text-slate-500">Columns found: <%= @import.columns.keys.map { _1.to_s.humanize }.join(", ") %></span>
<h2 class="card-title"><%= t(".preview_html", filename: @filename) %></h2>
<span class="text-xs text-slate-500"><%= t(".columns_found_html", columns: (@import.columns.keys.map { _1.to_s.humanize }.join(", "))) %></span>
</div>
<div class="card-body grid grid-cols-2 gap-4 text-center sm:grid-cols-5">
<div><div class="text-2xl font-semibold"><%= @import.importable.size %></div><div class="text-xs text-slate-500">flights to import</div></div>
<div><div class="text-2xl font-semibold"><%= hours(@import.total_tach_hours) %></div><div class="text-xs text-slate-500">tach hours</div></div>
<div><div class="text-2xl font-semibold text-amber-700"><%= @import.count(:warning) %></div><div class="text-xs text-slate-500">warnings (imported)</div></div>
<div><div class="text-2xl font-semibold text-red-700"><%= @import.count(:error) %></div><div class="text-xs text-slate-500">errors (skipped)</div></div>
<div><div class="text-2xl font-semibold text-slate-500"><%= @import.count(:duplicate) %></div><div class="text-xs text-slate-500">already imported</div></div>
<div><div class="text-2xl font-semibold"><%= @import.importable.size %></div><div class="text-xs text-slate-500"><%= t(".flights_to_import") %></div></div>
<div><div class="text-2xl font-semibold"><%= hours(@import.total_tach_hours) %></div><div class="text-xs text-slate-500"><%= t(".tach_hours") %></div></div>
<div><div class="text-2xl font-semibold text-amber-700"><%= @import.count(:warning) %></div><div class="text-xs text-slate-500"><%= t(".warnings_imported") %></div></div>
<div><div class="text-2xl font-semibold text-red-700"><%= @import.count(:error) %></div><div class="text-xs text-slate-500"><%= t(".errors_skipped") %></div></div>
<div><div class="text-2xl font-semibold text-slate-500"><%= @import.count(:duplicate) %></div><div class="text-xs text-slate-500"><%= t(".already_imported") %></div></div>
</div>
<% if @import.importable.any? %>
<%= form_with url: confirm_aircraft_flight_import_path(@aircraft), class: "space-y-3 border-t border-slate-100 p-4",
data: { turbo_confirm: "Import #{@import.importable.size} flights?" } do |f| %>
data: { turbo_confirm: t(".import_flights", importable: @import.importable.size) } do |f| %>
<%= hidden_field_tag :token, @token %>
<%= hidden_field_tag :filename, @filename %>
<%= hidden_field_tag :starting_tach, @starting_tach %>
@@ -27,35 +27,35 @@
<% if last && last.tach_in > @aircraft.tach_time %>
<label class="flex items-start gap-2 text-sm">
<%= check_box_tag :update_aircraft_hours, "1", true, class: "mt-0.5 h-4 w-4" %>
<span>Also update <%= @aircraft.tail_number %>'s tach from <%= hours(@aircraft.tach_time) %> to <strong><%= hours(last.tach_in) %></strong>
<%= "and hobbs to #{hours(last.hobbs_in)}" if last.hobbs_in && last.hobbs_in >= @aircraft.hobbs_time %>.
<span class="block text-xs text-slate-500">Works like a normal hours update: the difference (<%= hours(last.tach_in - @aircraft.tach_time) %> hrs) is added to in-service components. Leave unchecked if component times are already current.</span></span>
<span><%= t(".also_update_s_tach_from_html", tail_number: @aircraft.tail_number, tach_time: (hours(@aircraft.tach_time)), tach_in: (hours(last.tach_in))) %>
<%= t(".and_hobbs_to", hobbs_in: (hours(last.hobbs_in))) if last.hobbs_in && last.hobbs_in >= @aircraft.hobbs_time %>.
<span class="block text-xs text-slate-500"><%= t(".works_like_a_normal_hours_html", tach_time: (hours(last.tach_in - @aircraft.tach_time))) %></span></span>
</label>
<% elsif last %>
<p class="text-xs text-slate-500">The aircraft's tach (<%= hours(@aircraft.tach_time) %>) is already at or past the last reading (<%= hours(last.tach_in) %>), so its hours won't change.</p>
<p class="text-xs text-slate-500"><%= t(".the_aircraft_s_tach_is_html", tach_time: (hours(@aircraft.tach_time)), tach_in: (hours(last.tach_in))) %></p>
<% end %>
<div class="flex gap-2">
<%= f.submit "Import #{@import.importable.size} Flights", class: "btn-primary" %>
<%= link_to "Upload a different file", new_aircraft_flight_import_path(@aircraft), class: "btn-secondary" %>
<%= f.submit t(".import_flights_2", importable: @import.importable.size), class: "btn-primary" %>
<%= link_to t(".upload_a_different_file"), new_aircraft_flight_import_path(@aircraft), class: "btn-secondary" %>
</div>
<% if @import.count(:error) > 0 %><p class="hint">Rows with errors are skipped. The next good row absorbs their time, so total hours stay correct. To include them, fix the spreadsheet and upload it again. Rows already imported are skipped automatically.</p><% end %>
<% if @import.count(:error) > 0 %><p class="hint"><%= t(".rows_with_errors_are_skipped") %></p><% end %>
<% end %>
<% else %>
<p class="border-t border-slate-100 p-4 text-sm">Nothing to import. <%= link_to "Upload a different file", new_aircraft_flight_import_path(@aircraft), class: "link" %></p>
<p class="border-t border-slate-100 p-4 text-sm"><%= t(".nothing_to_import_html", link: (link_to t(".upload_a_different_file"), new_aircraft_flight_import_path(@aircraft), class: "link")) %></p>
<% end %>
</section>
<% if problems.any? %>
<section class="card mb-5">
<div class="card-header"><h2 class="card-title">Rows needing attention</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".rows_needing_attention") %></h2></div>
<table class="table">
<thead><tr><th>Row</th><th>Date</th><th>Route</th><th class="text-right">Tach</th><th>Issue</th></tr></thead>
<thead><tr><th><%= t(".row") %></th><th><%= t(".date") %></th><th><%= t(".route") %></th><th class="text-right"><%= t(".tach") %></th><th><%= t(".issue") %></th></tr></thead>
<tbody>
<% problems.each do |r| %>
<tr>
<td><%= r.line %></td><td class="whitespace-nowrap"><%= r.date || "—" %></td>
<td><%= [r.from, r.to].compact.join(" → ") %></td><td class="text-right"><%= r.tach_in %></td>
<td><%= tag.span(r.status == :error ? "Skipped" : "Warning", class: r.status == :error ? "badge-red" : "badge-orange") %> <span class="text-xs"><%= r.messages.join("; ") %></span></td>
<td><%= tag.span(r.status == :error ? t(".skipped") : t(".warning"), class: r.status == :error ? "badge-red" : "badge-orange") %> <span class="text-xs"><%= r.messages.join("; ") %></span></td>
</tr>
<% end %>
</tbody>
@@ -64,10 +64,10 @@
<% end %>
<details class="card">
<summary class="card-header cursor-pointer"><span class="card-title">All <%= rows.size %> rows</span></summary>
<summary class="card-header cursor-pointer"><span class="card-title"><%= t(".all_rows_html", rows: rows.size) %></span></summary>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Row</th><th>Date</th><th>From</th><th>To</th><th class="text-right">Tach</th><th class="text-right">Tach hrs</th><th class="text-right">Hobbs</th><th class="text-right">Hobbs hrs</th><th class="text-right">Oil</th><th class="text-right">Fuel</th><th></th></tr></thead>
<thead><tr><th><%= t(".row") %></th><th><%= t(".date") %></th><th><%= t(".from") %></th><th><%= t(".to") %></th><th class="text-right"><%= t(".tach") %></th><th class="text-right"><%= t(".tach_hrs") %></th><th class="text-right"><%= t(".hobbs") %></th><th class="text-right"><%= t(".hobbs_hrs") %></th><th class="text-right"><%= t(".oil") %></th><th class="text-right"><%= t(".fuel") %></th><th></th></tr></thead>
<tbody>
<% rows.each do |r| %>
<tr class="<%= 'opacity-50' unless r.importable? %>">
+12 -12
View File
@@ -7,30 +7,30 @@
<% days.each do |day| %>
<details class="group flight-day border-b border-slate-100">
<summary class="flex cursor-pointer list-none flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-slate-50 sm:grid sm:grid-cols-[9.5rem_1fr_repeat(4,5rem)_1.25rem] [&::-webkit-details-marker]:hidden">
<span class="font-medium whitespace-nowrap"><%= day.date.strftime("%a %b %-d, %Y") %><span class="block text-xs font-normal text-slate-500"><%= pluralize(day.flights.size, "flight") %></span></span>
<span class="font-medium whitespace-nowrap"><%= l(day.date, format: :weekday) %><span class="block text-xs font-normal text-slate-500"><%= t("counts.flight", count: day.flights.size) %></span></span>
<span class="min-w-0 basis-full sm:basis-auto">
<%= day.route.presence || blank %>
<% if day.track_log? %><span class="ml-1" role="img" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
<% if day.engine_data? %><span class="ml-1" role="img" title="Engine data attached" aria-label="Engine data attached">📈</span><% end %>
<% if day.track_log? %><span class="ml-1" role="img" title="<%= t(".gps_track_attached") %>" aria-label="<%= t(".gps_track_attached") %>">📍</span><% end %>
<% if day.engine_data? %><span class="ml-1" role="img" title="<%= t(".engine_data_attached") %>" aria-label="<%= t(".engine_data_attached") %>">📈</span><% end %>
<% if day.pilots.any? %><span class="block text-xs text-slate-500"><%= day.pilots.to_sentence %></span><% end %>
</span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Tach </span><%= day.tach_time ? hours(day.tach_time) : blank %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Hobbs </span><%= day.hobbs_time ? hours(day.hobbs_time) : blank %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Fuel </span><%= qty.(day.fuel_added) %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden">Oil </span><%= qty.(day.oil_added) %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".tach") %> </span><%= day.tach_time ? hours(day.tach_time) : blank %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".hobbs") %> </span><%= day.hobbs_time ? hours(day.hobbs_time) : blank %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".fuel") %> </span><%= qty.(day.fuel_added) %></span>
<span class="text-sm tabular-nums sm:text-right"><span class="text-xs text-slate-500 sm:hidden"><%= t(".oil") %> </span><%= qty.(day.oil_added) %></span>
<span aria-hidden="true" class="ml-auto text-slate-400 transition group-open:rotate-90">›</span>
</summary>
<div class="overflow-x-auto bg-slate-50/60 px-2 pb-3 sm:px-4">
<table class="table">
<thead><tr><th>Leg</th><th>Route</th><th class="text-right">Tach</th><th class="text-right">Hobbs</th><th class="text-right">Fuel (gal)</th><th class="text-right">Oil (qt)</th><th class="pl-6">Pilot</th></tr></thead>
<thead><tr><th><%= t(".leg") %></th><th><%= t(".route") %></th><th class="text-right"><%= t(".tach") %></th><th class="text-right"><%= t(".hobbs") %></th><th class="text-right"><%= t(".fuel_gal") %></th><th class="text-right"><%= t(".oil_qt") %></th><th class="pl-6"><%= t(".pilot") %></th></tr></thead>
<tbody>
<% day.flights.each_with_index do |fl, i| %>
<tr>
<td class="whitespace-nowrap" data-label=""><%= link_to "Leg #{i + 1}", aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
<td class="whitespace-nowrap" data-label=""><%= link_to t(".leg_2", i: i + 1), aircraft_flight_log_path(@aircraft, fl), class: "link" %></td>
<td class="whitespace-nowrap" data-label="Route">
<%= fl.route_summary.presence || blank %>
<% if fl.track_log.attached? %><span class="ml-1" role="img" title="GPS track attached" aria-label="GPS track attached">📍</span><% end %>
<% if fl.engine_data.attached? %><span class="ml-1" role="img" title="Engine data attached" aria-label="Engine data attached">📈</span><% end %>
<% if fl.track_log.attached? %><span class="ml-1" role="img" title="<%= t(".gps_track_attached") %>" aria-label="<%= t(".gps_track_attached") %>">📍</span><% end %>
<% if fl.engine_data.attached? %><span class="ml-1" role="img" title="<%= t(".engine_data_attached") %>" aria-label="<%= t(".engine_data_attached") %>">📈</span><% end %>
</td>
<td class="text-right tabular-nums" data-label="Tach"><%= fl.tach_time ? hours(fl.tach_time) : blank %></td>
<td class="text-right tabular-nums" data-label="Hobbs"><%= fl.hobbs_time ? hours(fl.hobbs_time) : blank %></td>
@@ -47,7 +47,7 @@
<% if more %>
<%= turbo_frame_tag "flight-days-#{page + 1}", src: aircraft_flight_logs_path(@aircraft, page: page + 1), loading: :lazy, target: "_top", class: "block" do %>
<p class="px-4 py-4 text-center text-sm text-slate-500">
Loading earlier flights… <%= link_to "Load more", aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" } %>
<%= t(".loading_earlier_flights_html", link: (link_to t(".load_more"), aircraft_flight_logs_path(@aircraft, page: page + 1), class: "link", data: { turbo_frame: "flight-days-#{page + 1}" })) %>
</p>
<% end %>
<% end %>
+32 -32
View File
@@ -1,11 +1,11 @@
<%# 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">Engine data</h2>
<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 "Remove", engine_data_aircraft_flight_log_path(@aircraft, flight_log), confirm: "Remove the engine data file from this flight?" %><% end %>
<% 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>
@@ -15,33 +15,33 @@
<% 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">This recording is from <strong><%= tail %></strong>, not <%= @aircraft.tail_number %>.</p>
<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 grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Recorded</dt>
<dd class="col-span-3"><%= recording.local(recording.started_at).strftime("%Y-%m-%d %H:%M") %>–<%= recording.local(recording.ended_at).strftime("%H:%M") %> monitor time
<span class="text-xs text-slate-500">· <%= recording.format %><%= " flight ##{recording.metadata[:flight_number]}" if recording.metadata[:flight_number] %> · <%= number_with_delimiter(recording.samples) %> samples</span></dd>
<dt class="text-slate-500">Engine run</dt><dd><%= recording.engine_start ? run_duration(recording.run_time) : "Engine not run" %></dd>
<dt class="text-slate-500">Fuel burned</dt><dd><%= engine_value(recording.fuel_burned, "gal", precision: 1) %></dd>
<dt class="text-slate-500">Tach</dt><dd class="tabular-nums"><%= hours_line.(:tach, 2) %></dd>
<dt class="text-slate-500">Engine hrs</dt><dd class="tabular-nums"><%= hours_line.(:engine_hours, 2) %></dd>
<% if (flt = recording.last(:flight_hours)) %><dt class="text-slate-500">Airborne</dt><dd><%= flt.zero? ? "No (ground run)" : "#{number_with_precision(flt, precision: 2)} hrs" %></dd><% end %>
<dt class="text-slate-500"><%= t(".recorded") %></dt>
<dd class="col-span-3"><%= 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>
<dt class="text-slate-500"><%= t(".engine_run") %></dt><dd><%= recording.engine_start ? run_duration(recording.run_time) : t(".engine_not_run") %></dd>
<dt class="text-slate-500"><%= t(".fuel_burned") %></dt><dd><%= engine_value(recording.fuel_burned, "gal", precision: 1) %></dd>
<dt class="text-slate-500"><%= t(".tach") %></dt><dd class="tabular-nums"><%= hours_line.(:tach, 2) %></dd>
<dt class="text-slate-500"><%= t(".engine_hrs") %></dt><dd class="tabular-nums"><%= hours_line.(:engine_hours, 2) %></dd>
<% if (flt = recording.last(:flight_hours)) %><dt class="text-slate-500"><%= t(".airborne") %></dt><dd><%= flt.zero? ? t(".no_ground_run") : "#{number_with_precision(flt, precision: 2)} hrs" %></dd><% end %>
</dl>
<div class="overflow-x-auto border-t border-slate-100">
<table class="table">
<thead><tr><th>Peak (engine running)</th><th class="text-right">Value</th><th class="text-right">At</th></tr></thead>
<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" ],
[ "Manifold pressure", recording.max(:map), "inHg", 1 ],
[ (egt ? "EGT (cyl #{egt[:cylinder]})" : "EGT"), egt && [ egt[:value], egt[:at] ], "°F" ],
[ (cht ? "CHT (cyl #{cht[:cylinder]})" : "CHT"), cht && [ cht[:value], cht[:at] ], "°F" ],
[ 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" ],
[ "Oil temp", recording.max(:oil_t), "°F" ],
[ "Oil pressure", recording.max(:oil_p), "psi" ],
[ "Fuel flow", recording.max(:fuel_flow), "gph", 1 ],
[ "Volts (low)", recording.min(:volts), "V", 1 ]
[ 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>
@@ -53,7 +53,7 @@
<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">Click a chart to explore it: zoom into any part of the flight and read exact values.</p>
<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) %>
@@ -64,39 +64,39 @@
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">⤢ Explore</span>
<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="Engine data viewer"
<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="Close">✕</button>
<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">· Drag across the chart to zoom in, double-click to reset.</span>
<span class="sm:hidden">· Drag to zoom.</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>Zoom out</button>
<button type="button" data-engine-chart-target="reset" data-action="engine-chart#resetZoom" class="btn-secondary btn-sm" disabled>Reset zoom</button>
<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">Loading…</p>
<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>Series <span class="font-normal normal-case text-slate-500">(visible range)</span></th><th class="text-right">Min</th><th class="text-right">Avg</th><th class="text-right">Max</th></tr></thead>
<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>
@@ -109,10 +109,10 @@
<% 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: "Attach engine monitor data", hint: "CGR-30P / CGR-30C flight recording (.csv).", accept: ".csv,text/csv" %>
<%= f.submit "Upload", class: "btn-secondary" %>
<%= 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 "No engine data for this flight." %>
<%= empty_state t(".no_engine_data_for_this") %>
<% end %>
</section>
+18 -18
View File
@@ -1,39 +1,39 @@
<%# Flying metrics. "Flight time" = Hobbs where recorded, else tach. %>
<% periods = stats.periods %>
<div class="mb-5 grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4">
<% [ [ "Past 30 days", periods[0] ], [ "This year", periods[2] ], [ "Past 12 months", periods[1] ], [ "Since #{fmt_date(stats.first_date)}", periods[4] ] ].each do |title, p| %>
<% [ [ t(".past_30_days"), periods[0] ], [ t(".this_year"), periods[2] ], [ t(".past_12_months"), periods[1] ], [ t(".since", first_date: (fmt_date(stats.first_date))), periods[4] ] ].each do |title, p| %>
<section class="card p-3 sm:p-4">
<div class="text-xs font-medium uppercase tracking-wide text-slate-500"><%= title %></div>
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= hours(p.flight) %> <span class="text-sm font-normal text-slate-500">hrs</span></div>
<div class="mt-1 text-xs text-slate-600"><%= pluralize(p.flights, "flight") %> · <%= hours(p.tach) %> tach · <%= number_with_delimiter(p.fuel) %> gal</div>
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= hours(p.flight) %> <span class="text-sm font-normal text-slate-500"><%= t(".hrs") %></span></div>
<div class="mt-1 text-xs text-slate-600"><%= t(".tach_gal_html", count: p.flights, tach: (hours(p.tach)), fuel: (number_with_delimiter(p.fuel))) %></div>
</section>
<% end %>
</div>
<div class="mb-5 grid gap-5 lg:grid-cols-3">
<section class="card lg:col-span-2">
<div class="card-header"><h2 class="card-title">Flight hours by month</h2>
<span class="text-xs text-slate-500">Avg <%= hours(stats.monthly_average_past_year) %> hrs/month over the past year</span></div>
<div class="card-header"><h2 class="card-title"><%= t(".flight_hours_by_month") %></h2>
<span class="text-xs text-slate-500"><%= t(".avg_hrs_month_over_the_html", monthly_average_past_year: (hours(stats.monthly_average_past_year))) %></span></div>
<div class="card-body">
<%= column_chart stats.flight_hours_by_month, height: "220px", colors: [ "#0369a1" ], ytitle: "hrs", library: { plugins: { legend: { display: false } } } %>
</div>
</section>
<section class="card">
<div class="card-header"><h2 class="card-title">Totals</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".totals") %></h2></div>
<dl class="card-body grid grid-cols-2 gap-x-3 gap-y-2 text-sm">
<dt class="text-slate-500">Flights logged</dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.count) %></dd>
<dt class="text-slate-500">Flight time</dt><dd class="text-right tabular-nums"><%= hours(stats.total_flight) %> hrs</dd>
<dt class="text-slate-500">Tach time</dt><dd class="text-right tabular-nums"><%= hours(stats.total_tach) %> hrs</dd>
<dt class="text-slate-500">Average flight</dt><dd class="text-right tabular-nums"><%= hours(stats.average_flight) %> hrs</dd>
<dt class="text-slate-500">Longest flight</dt><dd class="text-right tabular-nums"><%= hours(stats.longest_flight) %> hrs</dd>
<dt class="text-slate-500">Fuel</dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.total_fuel) %> gal</dd>
<dt class="text-slate-500">Fuel burn</dt><dd class="text-right tabular-nums"><%= stats.gph || "—" %> gal/hr</dd>
<dt class="text-slate-500">Airports visited</dt><dd class="text-right tabular-nums"><%= stats.airports_visited %></dd>
<dt class="text-slate-500"><%= t(".flights_logged") %></dt><dd class="text-right tabular-nums"><%= number_with_delimiter(stats.count) %></dd>
<dt class="text-slate-500"><%= t(".flight_time") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_2_html", total_flight: (hours(stats.total_flight))) %></dd>
<dt class="text-slate-500"><%= t(".tach_time") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_3_html", total_tach: (hours(stats.total_tach))) %></dd>
<dt class="text-slate-500"><%= t(".average_flight") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_4_html", average_flight: (hours(stats.average_flight))) %></dd>
<dt class="text-slate-500"><%= t(".longest_flight") %></dt><dd class="text-right tabular-nums"><%= t(".hrs_5_html", longest_flight: (hours(stats.longest_flight))) %></dd>
<dt class="text-slate-500"><%= t(".fuel") %></dt><dd class="text-right tabular-nums"><%= t(".gal_html", total_fuel: (number_with_delimiter(stats.total_fuel))) %></dd>
<dt class="text-slate-500"><%= t(".fuel_burn") %></dt><dd class="text-right tabular-nums"><%= t(".gal_hr_html", gph: (stats.gph || "—")) %></dd>
<dt class="text-slate-500"><%= t(".airports_visited") %></dt><dd class="text-right tabular-nums"><%= stats.airports_visited %></dd>
</dl>
<% if stats.top_airports.any? %>
<div class="border-t border-slate-100 px-4 py-3 text-xs text-slate-600">
<span class="font-medium text-slate-700">Most visited:</span>
<span class="font-medium text-slate-700"><%= t(".most_visited") %></span>
<%= stats.top_airports.map { |code, n| "#{code} (#{n})" }.join(" · ") %>
</div>
<% end %>
@@ -42,9 +42,9 @@
<% if stats.by_year.size > 1 %>
<details class="card group mb-5">
<summary class="card-header cursor-pointer list-none [&::-webkit-details-marker]:hidden"><span class="card-title">By year</span><span aria-hidden="true" class="text-slate-500 transition group-open:rotate-180">▾</span></summary>
<summary class="card-header cursor-pointer list-none [&::-webkit-details-marker]:hidden"><span class="card-title"><%= t(".by_year") %></span><span aria-hidden="true" class="text-slate-500 transition group-open:rotate-180">▾</span></summary>
<table class="table">
<thead><tr><th>Year</th><th class="text-right">Flights</th><th class="text-right">Flight hrs</th><th class="text-right">Tach hrs</th><th class="text-right">Fuel (gal)</th><th class="text-right">Avg flight</th></tr></thead>
<thead><tr><th><%= t(".year") %></th><th class="text-right"><%= t(".flights") %></th><th class="text-right"><%= t(".flight_hrs") %></th><th class="text-right"><%= t(".tach_hrs") %></th><th class="text-right"><%= t(".fuel_gal") %></th><th class="text-right"><%= t(".avg_flight") %></th></tr></thead>
<tbody>
<% stats.by_year.each do |y| %>
<tr>
@@ -58,6 +58,6 @@
<% end %>
</tbody>
</table>
<p class="px-4 pb-3 hint">Flight time is Hobbs time where recorded, otherwise tach time.</p>
<p class="px-4 pb-3 hint"><%= t(".flight_time_is_hobbs_time") %></p>
</details>
<% end %>
+7 -7
View File
@@ -1,23 +1,23 @@
<% content_for :title, "#{@aircraft.tail_number} Flights" %>
<% content_for :title, t(".flights", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% if @stats.any? %><%= render "flight_logs/stats", stats: @stats %><% end %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Flight Log</h2>
<h2 class="card-title"><%= t(".flight_log") %></h2>
<%= more_menu do %>
<% if owner? %><%= link_to "Import from spreadsheet", new_aircraft_flight_import_path(@aircraft), class: "menu-item" %><% end %>
<%= link_to "Export for AirTrail", new_aircraft_air_trail_export_path(@aircraft), class: "menu-item" %>
<% if owner? %><%= link_to "Standardize airport codes", aircraft_airport_codes_path(@aircraft), class: "menu-item" %><% end %>
<% if owner? %><%= link_to t(".import_from_spreadsheet"), new_aircraft_flight_import_path(@aircraft), class: "menu-item" %><% end %>
<%= link_to t(".export_for_airtrail"), new_aircraft_air_trail_export_path(@aircraft), class: "menu-item" %>
<% if owner? %><%= link_to t(".standardize_airport_codes"), aircraft_airport_codes_path(@aircraft), class: "menu-item" %><% end %>
<% end %>
</div>
<% if @days.any? %>
<div class="hidden grid-cols-[9.5rem_1fr_repeat(4,5rem)_1.25rem] gap-3 border-b border-slate-200 bg-slate-50 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 sm:grid">
<span>Date</span><span>Route</span><span class="text-right">Tach</span><span class="text-right">Hobbs</span><span class="text-right">Fuel (gal)</span><span class="text-right">Oil (qt)</span><span></span>
<span><%= t(".date") %></span><span><%= t(".route") %></span><span class="text-right"><%= t(".tach") %></span><span class="text-right"><%= t(".hobbs") %></span><span class="text-right"><%= t(".fuel_gal") %></span><span class="text-right"><%= t(".oil_qt") %></span><span></span>
</div>
<div>
<%= render "flight_logs/days", days: @days, page: @page, more: @more %>
</div>
<% else %>
<%= empty_state "No flights logged yet." %>
<%= empty_state t(".no_flights_logged_yet") %>
<% end %>
</section>
+22 -22
View File
@@ -1,4 +1,4 @@
<% content_for :title, "Log Flight" %>
<% content_for :title, t(".log_flight") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with model: [@aircraft, @flight_log], class: "card card-body space-y-5 max-w-3xl",
data: { controller: "offline-flight", offline_flight_tail_value: @aircraft.tail_number,
@@ -8,36 +8,36 @@
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :date, as: :date, required: true %>
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: "From", aircraft: @aircraft, placeholder: "KOQU" %>
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: "To", aircraft: @aircraft, placeholder: "Code or name" %>
<%= render "shared/airport_field", f: f, attribute: :departure_location, label: t(".from"), aircraft: @aircraft, placeholder: t(".koqu") %>
<%= render "shared/airport_field", f: f, attribute: :destination_location, label: t(".to"), aircraft: @aircraft, placeholder: t(".code_or_name") %>
</div>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Tach (required)</legend>
<%= f.field :tach_out, as: :number, step: 0.1, label: "Tach out" %>
<%= f.field :tach_in, as: :number, step: 0.1, label: "Tach in" %>
<%= f.field :tach_time, as: :number, step: 0.1, label: "…or duration", hint: "Calculated from out/in if blank." %>
<legend class="mb-2 text-sm font-semibold"><%= t(".tach_required") %></legend>
<%= f.field :tach_out, as: :number, step: 0.1, label: t(".tach_out") %>
<%= f.field :tach_in, as: :number, step: 0.1, label: t(".tach_in") %>
<%= f.field :tach_time, as: :number, step: 0.1, label: t(".or_duration"), hint: t(".calculated_from_out_in_if") %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Hobbs (optional)</legend>
<%= f.field :hobbs_out, as: :number, step: 0.1, label: "Hobbs out" %>
<%= f.field :hobbs_in, as: :number, step: 0.1, label: "Hobbs in" %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: "…or duration" %>
<legend class="mb-2 text-sm font-semibold"><%= t(".hobbs_optional") %></legend>
<%= f.field :hobbs_out, as: :number, step: 0.1, label: t(".hobbs_out") %>
<%= f.field :hobbs_in, as: :number, step: 0.1, label: t(".hobbs_in") %>
<%= f.field :hobbs_time, as: :number, step: 0.1, label: t(".or_duration") %>
</fieldset>
<fieldset class="grid gap-4 sm:grid-cols-3">
<legend class="mb-2 text-sm font-semibold">Oil & fuel added</legend>
<%= f.field :oil_added, as: :number, step: 0.25, label: "Oil added (qt)" %>
<%= f.field :oil_level_after, as: :number, step: 0.25, label: "Oil level after (qt)" %>
<%= f.field :oil_added_type, label: "Oil type", placeholder: "Aeroshell W100" %>
<%= f.field :fuel_added, as: :number, step: 0.1, label: "Fuel added (gal)" %>
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: "Fuel level after (gal)" %>
<%= f.field :fuel_added_type, label: "Fuel type", placeholder: "100LL" %>
<legend class="mb-2 text-sm font-semibold"><%= t(".oil_fuel_added") %></legend>
<%= f.field :oil_added, as: :number, step: 0.25, label: t(".oil_added_qt") %>
<%= f.field :oil_level_after, as: :number, step: 0.25, label: t(".oil_level_after_qt") %>
<%= f.field :oil_added_type, label: t(".oil_type"), placeholder: t(".aeroshell_w100") %>
<%= f.field :fuel_added, as: :number, step: 0.1, label: t(".fuel_added_gal") %>
<%= f.field :fuel_level_after, as: :number, step: 0.1, label: t(".fuel_level_after_gal") %>
<%= f.field :fuel_added_type, label: t(".fuel_type"), placeholder: t(".n100ll") %>
</fieldset>
<%= f.field :route, as: :textarea, rows: 2 %>
<%= f.field :notes, as: :textarea, rows: 2 %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :track_log, as: :file, label: "Track log (GPX/KML/CSV)" %>
<%= f.field :engine_data, as: :file, label: "Engine monitor data", hint: "CGR-30P / CGR-30C flight recording (.csv).", accept: ".csv,text/csv" %>
<%= f.field :track_log, as: :file, label: t(".track_log_gpx_kml_csv") %>
<%= f.field :engine_data, as: :file, label: t(".engine_monitor_data"), hint: t(".cgr_30p_cgr_30c_flight"), accept: ".csv,text/csv" %>
</div>
<p class="hint">Saving adds the tach time to the aircraft and all in-service components, and records any oil/fuel added.</p>
<div class="flex gap-2"><%= f.submit "Log Flight" %><%= link_to "Cancel", aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
<p class="hint"><%= t(".saving_adds_the_tach_time") %></p>
<div class="flex gap-2"><%= f.submit t(".log_flight") %><%= link_to t(".cancel"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %></div>
<% end %>
+14 -14
View File
@@ -1,24 +1,24 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<div class="space-y-6">
<section class="card max-w-3xl">
<div class="card-header"><h2 class="card-title">Flight on <%= fmt_date(@flight_log.date) %></h2>
<% if owner? %><%= delete_button "Delete", aircraft_flight_log_path(@aircraft, @flight_log), confirm: "Delete this flight log? Aircraft and component hours will NOT be rolled back." %><% end %></div>
<div class="card-header"><h2 class="card-title"><%= t(".flight_on_html", date: (fmt_date(@flight_log.date))) %></h2>
<% if owner? %><%= delete_button t(".delete"), aircraft_flight_log_path(@aircraft, @flight_log), confirm: t(".delete_this_flight_log_aircraft") %><% end %></div>
<dl class="card-body grid grid-cols-2 gap-x-4 gap-y-2 text-sm sm:grid-cols-4">
<dt class="text-slate-500">Tach</dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd>
<dt class="text-slate-500">Hobbs</dt><dd><%= hours(@flight_log.hobbs_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %></span></dd>
<dt class="text-slate-500">Route</dt><dd class="col-span-3"><%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %></dd>
<dt class="text-slate-500">Oil added</dt><dd><%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %></dd>
<dt class="text-slate-500">Fuel added</dt><dd><%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %></dd>
<dt class="text-slate-500">Pilot</dt><dd><%= @flight_log.user&.display_name || "—" %></dd>
<dt class="text-slate-500">Track log</dt><dd class="col-span-3"><%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %>
<% if @track %><span class="text-xs text-slate-500"> · <%= number_with_delimiter(@track.points) %> GPS points<%= " · max #{number_with_delimiter(@track.max_altitude_ft)} ft" if @track.max_altitude_ft %></span>
<dt class="text-slate-500"><%= t(".tach") %></dt><dd><%= hours(@flight_log.tach_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %></span></dd>
<dt class="text-slate-500"><%= t(".hobbs") %></dt><dd><%= hours(@flight_log.hobbs_time) %> <span class="text-xs text-slate-500"><%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %></span></dd>
<dt class="text-slate-500"><%= t(".route") %></dt><dd class="col-span-3"><%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %></dd>
<dt class="text-slate-500"><%= t(".oil_added") %></dt><dd><%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %></dd>
<dt class="text-slate-500"><%= t(".fuel_added") %></dt><dd><%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %></dd>
<dt class="text-slate-500"><%= t(".pilot") %></dt><dd><%= @flight_log.user&.display_name || "—" %></dd>
<dt class="text-slate-500"><%= t(".track_log") %></dt><dd class="col-span-3"><%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %>
<% if @track %><span class="text-xs text-slate-500"> <%= t(".gps_points_html", points: (number_with_delimiter(@track.points)), max_altitude_ft: (t(".max_ft", max_altitude_ft: (number_with_delimiter(@track.max_altitude_ft))) if @track.max_altitude_ft)) %></span>
<% elsif @track_error %><span class="text-xs text-amber-700"> · <%= @track_error %></span><% end %></dd>
<% if @air_trail_sync || @air_trail_connection %>
<dt class="text-slate-500">AirTrail</dt>
<dt class="text-slate-500"><%= t(".airtrail") %></dt>
<dd class="col-span-3 text-xs">
<% if @air_trail_sync&.status == "synced" %><span class="badge-green">Synced</span> <%= time_ago_in_words(@air_trail_sync.synced_at) %> ago
<% elsif @air_trail_sync&.status == "error" %><span class="badge-red">Not synced</span> <%= @air_trail_sync.last_error %>
<% else %><span class="badge-gray">Pending</span><% end %>
<% if @air_trail_sync&.status == "synced" %><span class="badge-green"><%= t(".synced") %></span> <%= t(".ago_html", synced_at: (time_ago_in_words(@air_trail_sync.synced_at))) %>
<% elsif @air_trail_sync&.status == "error" %><span class="badge-red"><%= t(".not_synced") %></span> <%= @air_trail_sync.last_error %>
<% else %><span class="badge-gray"><%= t(".pending") %></span><% end %>
</dd>
<% end %>
</dl>
+3 -3
View File
@@ -1,8 +1,8 @@
<% content_for :title, "Help: #{@page.title}" %>
<% content_for :title, t(".help", title: @page.title) %>
<div class="grid gap-5 lg:grid-cols-[14rem_1fr]">
<nav aria-label="Help pages" class="lg:order-none">
<nav aria-label="<%= t(".help_pages") %>" class="lg:order-none">
<details class="card lg:hidden">
<summary class="card-header cursor-pointer"><span class="card-title">Help: <%= @page.title %></span></summary>
<summary class="card-header cursor-pointer"><span class="card-title"><%= t(".help_html", title: @page.title) %></span></summary>
<ul class="p-2 text-sm"><% @pages.each do |p| %><li><%= link_to p.title, help_page_url_for(p.slug), class: [ "block rounded px-3 py-2 hover:bg-slate-100", ("bg-slate-100 font-semibold text-sky-700" if p == @page) ] %></li><% end %></ul>
</details>
<ul class="sticky top-4 hidden space-y-0.5 text-sm lg:block">
+6 -6
View File
@@ -3,17 +3,17 @@
<%= form_with model: record, url: record.new_record? ? aircraft_inspection_records_path(aircraft) : aircraft_inspection_record_path(aircraft, record),
class: "card card-body space-y-4 max-w-2xl", data: { controller: "next-due", next_due_rules_value: rules.to_json } do |f| %>
<%= f.errors_summary %>
<%= f.field :inspection_type_id, as: :select, label: "Inspection", collection: types.map { [_1.name, _1.id] },
<%= f.field :inspection_type_id, as: :select, label: t(".inspection"), collection: types.map { [_1.name, _1.id] },
data: { next_due_target: "rule", action: "change->next-due#changed" } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date, as: :date, data: { next_due_target: "date", action: "change->next-due#changed" } %>
<%= f.field :aircraft_hours, as: :number, step: 0.1, label: "Aircraft hours (tach)",
<%= f.field :aircraft_hours, as: :number, step: 0.1, label: t(".aircraft_hours_tach"),
data: { next_due_target: "hours", action: "input->next-due#changed" } %>
<%= f.field :component_id, as: :select, label: "Component (if component-level)", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
<%= f.field :component_id, as: :select, label: t(".component_if_component_level"), collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: t(".logbook_entry"), collection: logbook_options(aircraft) %>
</div>
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200" data-next-due-target="preview" hidden></p>
<%= f.field :notes, as: :textarea, rows: 2 %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_inspection_record_path(aircraft, record) %></div><% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button t(".delete_record"), aircraft_inspection_record_path(aircraft, record) %></div><% end %>
+15 -15
View File
@@ -2,29 +2,29 @@
<%= f.errors_summary %>
<% if @major_record %>
<%= hidden_field_tag :major_record_id, @major_record.id %>
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200">For the Instructions for Continued Airworthiness of <strong><%= @major_record.title %></strong><%= " (STC #{@major_record.stc_number})" if @major_record.stc_number.present? %>. Set the interval the ICA gives.<%= " ICA notes: #{@major_record.ica_notes}" if @major_record.ica_notes.present? %></p>
<p class="rounded-md bg-sky-50 px-3 py-2 text-sm text-sky-900 ring-1 ring-sky-200"><%= t(".for_the_instructions_for_continued_html", title: @major_record.title, stc: (t(".stc", stc_number: @major_record.stc_number) if @major_record.stc_number.present?), notes: (t(".ica_notes", ica_notes: @major_record.ica_notes) if @major_record.ica_notes.present?)) %></p>
<% end %>
<%= f.field :name, required: true, placeholder: "Annual Inspection" %>
<%= f.field :effect, as: :select, label: "When overdue", collection: InspectionType::EFFECTS.invert,
hint: "An overdue pitot-static check (91.411) only rules out IFR, and an overdue transponder check (91.413) only rules out using the transponder. Neither grounds the aircraft." %>
<%= f.field :recurring, as: :checkbox, label: "Recurring" %>
<%= f.field :name, required: true, placeholder: t(".annual_inspection") %>
<%= f.field :effect, as: :select, label: t(".when_overdue"), collection: InspectionType::EFFECTS.invert,
hint: t(".an_overdue_pitot_static_check") %>
<%= f.field :recurring, as: :checkbox, label: t(".recurring") %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :recurring_hours, as: :number, step: 0.1, label: "Every (hours)" %>
<%= f.interval :recurring, label: "Every", wrapper: { class: "sm:col-span-2" },
hint: "Months and years are calendar months: due at the end of the month (an annual done March 10 is due by the end of next March)." %>
<%= f.field :recurring_hours, as: :number, step: 0.1, label: t(".every_hours") %>
<%= f.interval :recurring, label: t(".every"), wrapper: { class: "sm:col-span-2" },
hint: t(".months_and_years_are_calendar") %>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :hours_tolerance, as: :number, step: 0.1, min: 0, label: "Overrun allowance (hours)",
hint: "For the 100-hour: 10. Done late within this, the next one counts from when it was due (91.409(b))." %>
<%= f.field :hours_tolerance, as: :number, step: 0.1, min: 0, label: t(".overrun_allowance_hours"),
hint: t(".for_the_100_hour_10") %>
<% others = aircraft.applicable_inspection_types.ordered.where.not(id: inspection_type.id) %>
<%= f.field :satisfies_id, as: :select, label: "Also counts as", include_blank: "— Nothing else —",
<%= f.field :satisfies_id, as: :select, label: t(".also_counts_as"), include_blank: t(".nothing_else"),
collection: others.map { [ _1.name, _1.id ] },
hint: "An annual also counts as the 100-hour (91.409(b))." %>
hint: t(".an_annual_also_counts_as") %>
</div>
<%= render "shared/applicability_fields", aircraft: aircraft, record: inspection_type, applies_to_airframe: @applies_to_airframe %>
<% if inspection_type.persisted? && inspection_type.aircraft.count > 1 %>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800">This inspection type is shared with other aircraft; interval changes affect them too.</p>
<p class="rounded bg-amber-50 p-2 text-xs text-amber-800"><%= t(".this_inspection_type_is_shared") %></p>
<% end %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_inspections_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if inspection_type.persisted? %><div class="mt-4"><%= delete_button "Remove from #{aircraft.tail_number}", aircraft_inspection_type_path(aircraft, inspection_type) %></div><% end %>
<% if inspection_type.persisted? %><div class="mt-4"><%= delete_button t(".remove_from", tail_number: aircraft.tail_number), aircraft_inspection_type_path(aircraft, inspection_type) %></div><% end %>
+12 -12
View File
@@ -1,25 +1,25 @@
<% content_for :title, "#{@aircraft.tail_number} Inspections" %>
<% content_for :title, t(".inspections", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header"><h2 class="card-title">Inspection Status</h2>
<% if owner? %><div class="flex flex-wrap gap-2"><%= more_menu do %><%= link_to "Add standard inspections", new_aircraft_standard_inspections_path(@aircraft), class: "menu-item" %><% end %><%= link_to "+ Inspection Type", new_aircraft_inspection_type_path(@aircraft), class: "btn-primary" %></div><% end %></div>
<div class="card-header"><h2 class="card-title"><%= t(".inspection_status") %></h2>
<% if owner? %><div class="flex flex-wrap gap-2"><%= more_menu do %><%= link_to t(".add_standard_inspections"), new_aircraft_standard_inspections_path(@aircraft), class: "menu-item" %><% end %><%= link_to t(".inspection_type"), new_aircraft_inspection_type_path(@aircraft), class: "btn-primary" %></div><% end %></div>
<% if @rows.any? %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th>Inspection</th><th>Interval</th><th>Last done</th><th>Next due</th><th>Status</th><th></th></tr></thead>
<thead><tr><th><%= t(".inspection") %></th><th><%= t(".interval") %></th><th><%= t(".last_done") %></th><th><%= t(".next_due") %></th><th><%= t(".status") %></th><th></th></tr></thead>
<tbody>
<% @rows.each do |row| %>
<tr>
<td class="font-medium"><%= row.type.name %><%= tag.span(" #{row.type.advisory? ? 'advisory' : row.type.limitation.to_s.downcase + ' if overdue'}", class: "text-xs text-slate-500") if row.type.advisory? || row.type.limitation %>
<% if row.type.satisfies %><div class="text-xs text-slate-500">Also counts as <%= row.type.satisfies.name %></div><% end %></td>
<% if row.type.satisfies %><div class="text-xs text-slate-500"><%= t(".also_counts_as_html", satisfies: row.type.satisfies.name) %></div><% end %></td>
<td class="text-xs"><%= row.type.interval_description %></td>
<td class="text-xs"><%= row.latest ? "#{fmt_date(row.latest.date)} @ #{hours(row.latest.hours_at_inspection)} h" : "—" %></td>
<td class="text-xs"><%= [row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} h"].compact.join(" / ").presence || "—" %></td>
<td><%= compliance_badge(row.status) %></td>
<td class="whitespace-nowrap text-right">
<% if owner? %>
<%= link_to "Record", new_aircraft_inspection_record_path(@aircraft, inspection_type_id: row.type.id), class: "btn-secondary btn-sm" %>
<%= link_to "Edit", edit_aircraft_inspection_type_path(@aircraft, row.type), class: "btn-secondary btn-sm" %>
<%= link_to t(".record"), new_aircraft_inspection_record_path(@aircraft, inspection_type_id: row.type.id), class: "btn-secondary btn-sm" %>
<%= link_to t(".edit"), edit_aircraft_inspection_type_path(@aircraft, row.type), class: "btn-secondary btn-sm" %>
<% end %>
</td>
</tr>
@@ -28,15 +28,15 @@
</table>
</div>
<% else %>
<%= empty_state "No inspections tracked. Add Annual, 100-hour, transponder (91.413), pitot-static (91.411), ELT (91.207)…" %>
<%= empty_state t(".no_inspections_tracked_add_annual") %>
<% end %>
</section>
<section class="card mt-5">
<div class="card-header"><h2 class="card-title">History</h2></div>
<div class="card-header"><h2 class="card-title"><%= t(".history") %></h2></div>
<% if @history.any? %>
<table class="table">
<thead><tr><th>Date</th><th>Inspection</th><th class="text-right">Hours</th><th>Notes</th><th></th></tr></thead>
<thead><tr><th><%= t(".date") %></th><th><%= t(".inspection") %></th><th class="text-right"><%= t(".hours") %></th><th><%= t(".notes") %></th><th></th></tr></thead>
<tbody>
<% @history.each do |r| %>
<tr>
@@ -44,12 +44,12 @@
<td><%= r.inspection_type.name %><%= " (#{r.component})" if r.component %></td>
<td class="text-right"><%= hours(r.hours_at_inspection) %></td>
<td class="text-xs"><%= r.notes %><% if r.logbook_entry %> <%= link_to "logbook", aircraft_logbook_entry_path(@aircraft, r.logbook_entry), class: "link" %><% end %></td>
<td class="text-right"><% if owner? %><%= link_to "Edit", edit_aircraft_inspection_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
<td class="text-right"><% if owner? %><%= link_to t(".edit"), edit_aircraft_inspection_record_path(@aircraft, r), class: "btn-secondary btn-sm" %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state "No inspections recorded." %>
<%= empty_state t(".no_inspections_recorded") %>
<% end %>
</section>
+3 -3
View File
@@ -1,5 +1,5 @@
<% content_for :title, "Invitation not found" %>
<% content_for :title, t(".invitation_not_found") %>
<div class="mx-auto max-w-md card card-body">
<h1 class="card-title">This signing link has expired or was already used</h1>
<p class="mt-1 text-sm text-slate-600">Ask the aircraft's owner to send a new one.</p>
<h1 class="card-title"><%= t(".this_signing_link_has_expired") %></h1>
<p class="mt-1 text-sm text-slate-600"><%= t(".ask_the_aircraft_s_owner") %></p>
</div>
+6 -6
View File
@@ -1,15 +1,15 @@
<% content_for :title, "Sign logbook entry" %>
<% content_for :title, t(".sign_logbook_entry") %>
<% if @certificates.empty? %>
<section class="card card-body mb-5 max-w-3xl space-y-3">
<h2 class="card-title">Add your certificate</h2>
<h2 class="card-title"><%= t(".add_your_certificate") %></h2>
<%= form_with model: UserCertificate.new, url: certificates_path(return_to: request.path), class: "grid gap-2 sm:grid-cols-[1fr_10rem_auto]" do |f| %>
<%= f.select :kind, UserCertificate::KINDS.invert, {}, class: "input", "aria-label": "Kind of certificate" %>
<%= f.text_field :number, class: "input", placeholder: "Number", required: true, "aria-label": "Certificate number" %>
<%= f.submit "Add", class: "btn-secondary" %>
<%= f.select :kind, UserCertificate::KINDS.invert, {}, class: "input", "aria-label": t(".kind_of_certificate") %>
<%= f.text_field :number, class: "input", placeholder: t(".number"), required: true, "aria-label": t(".certificate_number") %>
<%= f.submit t(".add"), class: "btn-secondary" %>
<% end %>
</section>
<% end %>
<%= render "entry_signatures/form", entry: @entry, url: invited_signing_path(params[:token]), cancel_path: root_path %>
<% unless current_user.otp_enabled? %>
<p class="mx-auto mt-4 max-w-3xl text-sm text-slate-600">Recommended: <%= link_to "add an authenticator app", new_two_factor_path(return_to: request.path), class: "link" %> to your account, so your signature can't be made with a stolen password alone.</p>
<p class="mx-auto mt-4 max-w-3xl text-sm text-slate-600"><%= t(".recommended_to_your_account_so_html", link: (link_to t(".add_an_authenticator_app"), new_two_factor_path(return_to: request.path), class: "link")) %></p>
<% end %>
+2 -2
View File
@@ -1,6 +1,6 @@
<% content_for :title, "Logbook entry signed" %>
<% content_for :title, t(".logbook_entry_signed") %>
<div class="mx-auto max-w-3xl space-y-4">
<h1 class="text-2xl font-bold">Entry signed</h1>
<h1 class="text-2xl font-bold"><%= t(".entry_signed") %></h1>
<%= render "logbook_entries/signature", entry: @entry %>
<%= render "logbook_entries/content", entry: @entry %>
</div>
+10 -10
View File
@@ -1,19 +1,19 @@
<% content_for :title, "Sign a logbook entry" %>
<% content_for :title, t(".sign_a_logbook_entry") %>
<div class="mx-auto max-w-md space-y-4">
<h1 class="text-2xl font-bold">Sign a logbook entry</h1>
<p class="text-sm text-slate-600">You've been asked to sign the <%= fmt_date(@entry.date) %> <%= LogbookEntry::LOG_TYPES[@entry.log_type].downcase %> log entry for <%= @entry.aircraft.tail_number %>. First, sign in as <strong><%= @invitation.email %></strong>.</p>
<h1 class="text-2xl font-bold"><%= t(".sign_a_logbook_entry") %></h1>
<p class="text-sm text-slate-600"><%= t(".you_ve_been_asked_to_html", date: (fmt_date(@entry.date)), log_type: (LogbookEntry::LOG_TYPES[@entry.log_type].downcase), tail_number: @entry.aircraft.tail_number, email: @invitation.email) %></p>
<div class="card card-body space-y-3">
<%= link_to "I have an account: sign in", new_session_path, class: "btn-primary w-full justify-center" %>
<%= link_to t(".i_have_an_account_sign"), new_session_path, class: "btn-primary w-full justify-center" %>
</div>
<% if Sso.password_login? && !User.exists?(email_address: @invitation.email) %>
<%= form_with url: account_invited_signing_path(params[:token]), class: "card card-body space-y-3" do %>
<h2 class="card-title">Or create an account</h2>
<h2 class="card-title"><%= t(".or_create_an_account") %></h2>
<% if @account_errors.present? %><div class="rounded-md bg-red-50 p-2 text-sm text-red-700"><%= @account_errors.to_sentence %></div><% end %>
<div><label class="label">Email</label><input class="input" value="<%= @invitation.email %>" disabled></div>
<div><%= label_tag :name, "Your name", class: "label" %><%= text_field_tag :name, params[:name], class: "input", required: true %></div>
<div><%= label_tag :password, "Password", class: "label" %><%= password_field_tag :password, nil, class: "input", required: true, autocomplete: "new-password", minlength: User::PASSWORD_MIN, maxlength: 72 %><p class="hint">At least <%= User::PASSWORD_MIN %> characters; not one known from a data breach.</p></div>
<div><%= label_tag :password_confirmation, "Confirm password", class: "label" %><%= password_field_tag :password_confirmation, nil, class: "input", required: true, autocomplete: "new-password" %></div>
<%= submit_tag "Create account", class: "btn-secondary" %>
<div><label class="label"><%= t(".email") %></label><input class="input" value="<%= @invitation.email %>" disabled></div>
<div><%= label_tag :name, t(".your_name"), class: "label" %><%= text_field_tag :name, params[:name], class: "input", required: true %></div>
<div><%= label_tag :password, t(".password"), class: "label" %><%= password_field_tag :password, nil, class: "input", required: true, autocomplete: "new-password", minlength: User::PASSWORD_MIN, maxlength: 72 %><p class="hint"><%= t(".at_least_characters_not_one_html", min: (User::PASSWORD_MIN)) %></p></div>
<div><%= label_tag :password_confirmation, t(".confirm_password"), class: "label" %><%= password_field_tag :password_confirmation, nil, class: "input", required: true, autocomplete: "new-password" %></div>
<%= submit_tag t(".create_account"), class: "btn-secondary" %>
<% end %>
<% end %>
</div>
@@ -1,6 +1,6 @@
<% content_for :title, "Sign a logbook entry" %>
<% content_for :title, t(".sign_a_logbook_entry") %>
<div class="mx-auto max-w-md card card-body space-y-3">
<h1 class="card-title">Wrong account</h1>
<p class="text-sm text-slate-600">This invitation is for <strong><%= @invitation.email %></strong>, but you're signed in as <%= current_user.email_address %>. Sign out and sign in with the invited address.</p>
<%= button_to "Sign out", session_path, method: :delete, class: "btn-secondary" %>
<h1 class="card-title"><%= t(".wrong_account") %></h1>
<p class="text-sm text-slate-600"><%= t(".this_invitation_is_for_but_html", email: @invitation.email, email_address: current_user.email_address) %></p>
<%= button_to t(".sign_out"), session_path, method: :delete, class: "btn-secondary" %>
</div>
+22 -21
View File
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="en" class="h-full bg-page">
<html lang="<%= I18n.locale %>" class="h-full bg-page">
<head>
<meta charset="utf-8">
<%= render "shared/theme_script" %>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<title><%= [content_for(:title), t(".simple_aircraft_manager")].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
@@ -18,61 +18,62 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<script type="application/json" id="i18n" nonce="<%= content_security_policy_nonce %>"><%= json_escape(t("js").to_json).html_safe %></script>
</head>
<body class="min-h-full text-slate-800" data-controller="offline-sync">
<a href="#main" class="skip-link">Skip to content</a>
<%= t(".skip_to_content_html") %>
<div class="hidden space-y-1 bg-amber-50 px-4 py-2 text-center text-sm text-amber-900 ring-1 ring-amber-200" data-offline-sync-target="banner" role="status"></div>
<header class="bg-header text-white">
<div class="mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-3">
<%= link_to root_path, class: "flex items-center gap-2 font-semibold tracking-tight whitespace-nowrap" do %>
<span class="text-xl">✈</span> <span class="hidden sm:inline">Simple Aircraft Manager</span><span class="sm:hidden" aria-label="Simple Aircraft Manager">SAM</span>
<span class="text-xl">✈</span> <span class="hidden sm:inline"><%= t(".simple_aircraft_manager") %></span><span class="sm:hidden" aria-label="<%= t(".simple_aircraft_manager") %>"><%= t(".sam") %></span>
<% end %>
<% if current_user %>
<%# Phones: Fleet, theme and one menu for the rest. %>
<nav class="flex items-center gap-1 text-sm sm:hidden" aria-label="Main">
<%= link_to "Fleet", root_path, class: "rounded px-3 py-2 hover:bg-white/10" %>
<nav class="flex items-center gap-1 text-sm sm:hidden" aria-label="<%= t(".main") %>">
<%= link_to t(".fleet"), root_path, class: "rounded px-3 py-2 hover:bg-white/10" %>
<%= render "shared/theme_toggle" %>
<details class="relative" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
<summary class="flex cursor-pointer list-none items-center rounded px-3 py-2 text-lg leading-none hover:bg-white/10 [&::-webkit-details-marker]:hidden" aria-label="Menu">☰</summary>
<summary class="flex cursor-pointer list-none items-center rounded px-3 py-2 text-lg leading-none hover:bg-white/10 [&::-webkit-details-marker]:hidden" aria-label="<%= t(".menu") %>">☰</summary>
<div class="absolute right-0 z-30 mt-2 w-56 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
<p class="truncate px-4 pt-2 pb-1 text-xs text-slate-500"><%= current_user.email_address %></p>
<%= link_to "Profile", edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<%= link_to "Search", search_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<%= link_to "Help", help_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<%= link_to t(".profile"), edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<%= link_to t(".search"), search_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<%= link_to t(".help"), help_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<% if current_user.admin? %>
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500">Admin</p>
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "Logbook Templates", admin_logbook_templates_path ], [ "Settings", edit_admin_settings_path ], [ "Off-site Backup", admin_offsite_backup_path ], [ "Recordkeeping Procedures", admin_procedures_path ], [ "Records Audits", admin_audits_path ], [ "About", admin_about_path ] ].each do |label, path| %>
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500"><%= t(".admin") %></p>
<% [ [ t(".users"), admin_users_path ], [ t(".component_types"), admin_component_types_path ], [ t(".airports"), admin_airports_path ], [ t(".logbook_templates"), admin_logbook_templates_path ], [ t(".settings"), edit_admin_settings_path ], [ t(".off_site_backup"), admin_offsite_backup_path ], [ t(".recordkeeping_procedures"), admin_procedures_path ], [ t(".records_audits"), admin_audits_path ], [ t(".about"), admin_about_path ] ].each do |label, path| %>
<%= link_to label, path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
<% end %>
<% end %>
<div class="border-t border-slate-100"><%= button_to "Sign out", session_path, method: :delete, class: "block w-full px-4 py-2.5 text-left hover:bg-slate-100" %></div>
<div class="border-t border-slate-100"><%= button_to t(".sign_out"), session_path, method: :delete, class: "block w-full px-4 py-2.5 text-left hover:bg-slate-100" %></div>
</div>
</details>
</nav>
<nav class="hidden items-center gap-4 text-sm sm:flex" aria-label="Main">
<nav class="hidden items-center gap-4 text-sm sm:flex" aria-label="<%= t(".main") %>">
<%= form_with url: search_path, method: :get, class: "hidden md:block", html: { role: "search" } do %>
<%= search_field_tag :q, params[:q], placeholder: "Search…", "aria-label": "Search the records",
<%= search_field_tag :q, params[:q], placeholder: t(".search_2"), "aria-label": t(".search_the_records"),
class: "w-40 rounded bg-white/10 px-2 py-1 text-sm text-white placeholder:text-white/60 focus:w-56 focus:bg-white/20 focus:outline-none transition-all lg:w-48" %>
<% end %>
<%= link_to "Search", search_path, class: "hover:text-sky-300 md:hidden" %>
<%= link_to "Fleet", root_path, class: "hover:text-sky-300" %>
<%= link_to t(".search"), search_path, class: "hover:text-sky-300 md:hidden" %>
<%= link_to t(".fleet"), root_path, class: "hover:text-sky-300" %>
<% if current_user.admin? %>
<details class="relative" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
<summary class="flex cursor-pointer list-none items-center gap-1 hover:text-sky-300 [&::-webkit-details-marker]:hidden">
Admin <span aria-hidden="true" class="text-xs">▾</span>
<%= t(".admin") %> <span aria-hidden="true" class="text-xs">▾</span>
</summary>
<div class="absolute right-0 z-30 mt-2 w-48 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "Logbook Templates", admin_logbook_templates_path ], [ "Settings", edit_admin_settings_path ], [ "Off-site Backup", admin_offsite_backup_path ], [ "Recordkeeping Procedures", admin_procedures_path ], [ "Records Audits", admin_audits_path ], [ "About", admin_about_path ] ].each do |label, path| %>
<% [ [ t(".users"), admin_users_path ], [ t(".component_types"), admin_component_types_path ], [ t(".airports"), admin_airports_path ], [ t(".logbook_templates"), admin_logbook_templates_path ], [ t(".settings"), edit_admin_settings_path ], [ t(".off_site_backup"), admin_offsite_backup_path ], [ t(".recordkeeping_procedures"), admin_procedures_path ], [ t(".records_audits"), admin_audits_path ], [ t(".about"), admin_about_path ] ].each do |label, path| %>
<%= link_to label, path, class: [ "block px-4 py-2 text-sm hover:bg-slate-100", ("font-semibold text-sky-700" if current_page?(path)) ] %>
<% end %>
</div>
</details>
<% end %>
<%= link_to "Help", help_path, class: "hover:text-sky-300" %>
<%= link_to t(".help"), help_path, class: "hover:text-sky-300" %>
<%= link_to current_user.display_name, edit_profile_path, class: "text-white/70 hover:text-sky-300 hidden sm:inline" %>
<%= render "shared/theme_toggle" %>
<%= button_to "Sign out", session_path, method: :delete, class: "rounded bg-white/10 px-2 py-1 hover:bg-white/20" %>
<%= button_to t(".sign_out"), session_path, method: :delete, class: "rounded bg-white/10 px-2 py-1 hover:bg-white/20" %>
</nav>
<% end %>
</div>
+1 -1
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="<%= I18n.locale %>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
+5 -4
View File
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="en" class="h-full bg-page">
<html lang="<%= I18n.locale %>" class="h-full bg-page">
<head>
<meta charset="utf-8">
<%= render "shared/theme_script" %>
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<title><%= [content_for(:title), t(".simple_aircraft_manager")].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<%= csrf_meta_tags %>
@@ -16,11 +16,12 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<script type="application/json" id="i18n" nonce="<%= content_security_policy_nonce %>"><%= json_escape(t("js").to_json).html_safe %></script>
</head>
<body class="min-h-full text-slate-800">
<a href="#main" class="skip-link">Skip to content</a>
<%= t(".skip_to_content_html") %>
<header class="bg-header text-white">
<div class="mx-auto flex max-w-7xl items-center justify-between px-4 py-3"><span class="font-semibold"><span class="text-xl">✈</span> Simple Aircraft Manager</span><%= render "shared/theme_toggle" %></div>
<div class="mx-auto flex max-w-7xl items-center justify-between px-4 py-3"><span class="font-semibold"><span class="text-xl">✈</span> <%= t(".simple_aircraft_manager") %></span><%= render "shared/theme_toggle" %></div>
</header>
<main id="main" tabindex="-1" class="mx-auto max-w-7xl px-4 py-6 focus:outline-none">
<%= render "shared/flash" %>
+2 -2
View File
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html lang="en" class="bg-white" data-theme="light">
<html lang="<%= I18n.locale %>" class="bg-white" data-theme="light">
<head>
<meta charset="utf-8">
<title><%= [content_for(:title), "Simple Aircraft Manager"].compact.join(" · ") %></title>
<title><%= [content_for(:title), t(".simple_aircraft_manager")].compact.join(" · ") %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<%= csrf_meta_tags %>
+20 -20
View File
@@ -1,49 +1,49 @@
<% content_for :title, "#{@aircraft.tail_number} Loading setup" %>
<% content_for :title, t(".loading_setup", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% stations = @setup.stations + Array.new([ 8 - @setup.stations.size, 2 ].max) { nil } %>
<% points = @setup.entered_envelope + Array.new([ 10 - @setup.envelope.size, 2 ].max) { nil } %>
<%= form_with url: aircraft_loading_setup_path(@aircraft), method: :patch, class: "card card-body max-w-3xl space-y-5" do %>
<div>
<h2 class="card-title">Loading setup</h2>
<p class="mt-1 text-sm text-slate-600">From the POH's weight and balance section. Arms are inches aft of the datum.</p>
<h2 class="card-title"><%= t(".loading_setup_2") %></h2>
<p class="mt-1 text-sm text-slate-600"><%= t(".from_the_poh_s_weight") %></p>
</div>
<% if @setup.errors.any? %>
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><ul class="list-disc pl-5"><% @setup.errors.full_messages.each do |m| %><li><%= m %></li><% end %></ul></div>
<% end %>
<fieldset>
<legend class="label">Stations</legend>
<div class="grid grid-cols-[1fr_5rem_5rem_3.5rem] gap-2 text-xs text-slate-500 sm:grid-cols-[1fr_6rem_6rem_4rem]"><span>Name</span><span>Arm (in)</span><span>Max (lb/gal)</span><span class="text-center">Fuel</span></div>
<legend class="label"><%= t(".stations") %></legend>
<div class="grid grid-cols-[1fr_5rem_5rem_3.5rem] gap-2 text-xs text-slate-500 sm:grid-cols-[1fr_6rem_6rem_4rem]"><span><%= t(".name") %></span><span><%= t(".arm_in") %></span><span><%= t(".max_lb_gal") %></span><span class="text-center"><%= t(".fuel") %></span></div>
<% stations.each_with_index do |st, i| %>
<div class="mt-1 grid grid-cols-[1fr_5rem_5rem_3.5rem] items-center gap-2 sm:grid-cols-[1fr_6rem_6rem_4rem]">
<%= text_field_tag "setup[stations][#{i}][name]", st&.name, class: "input", placeholder: ("Front seats" if i.zero?), "aria-label": "Station #{i + 1} name" %>
<%= text_field_tag "setup[stations][#{i}][arm]", st&.arm&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Station #{i + 1} arm" %>
<%= text_field_tag "setup[stations][#{i}][max]", st&.max&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Station #{i + 1} maximum" %>
<%= check_box_tag "setup[stations][#{i}][fuel]", "1", st&.fuel, class: "mx-auto block h-4 w-4", "aria-label": "Station #{i + 1} is fuel" %>
<%= text_field_tag "setup[stations][#{i}][name]", st&.name, class: "input", placeholder: (t(".front_seats") if i.zero?), "aria-label": t(".station_name", i: (i + 1)) %>
<%= text_field_tag "setup[stations][#{i}][arm]", st&.arm&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".station_arm", i: (i + 1)) %>
<%= text_field_tag "setup[stations][#{i}][max]", st&.max&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".station_maximum", i: (i + 1)) %>
<%= check_box_tag "setup[stations][#{i}][fuel]", "1", st&.fuel, class: "mx-auto block h-4 w-4", "aria-label": t(".station_is_fuel", i: (i + 1)) %>
</div>
<% end %>
<p class="hint">Tick "Fuel" for fuel tanks: their quantity is entered in gallons and the max is the usable capacity in gallons. Other maximums are in pounds.</p>
<p class="hint"><%= t(".tick_fuel_for_fuel_tanks") %></p>
</fieldset>
<div class="max-w-xs">
<%= label_tag "setup[fuel_lb_per_gal]", "Fuel weight (lb per gallon)", class: "label" %>
<%= label_tag "setup[fuel_lb_per_gal]", t(".fuel_weight_lb_per_gallon"), class: "label" %>
<%= text_field_tag "setup[fuel_lb_per_gal]", @setup.fuel_lb_per_gal.to_s.sub(/\.0\z/, ""), class: "input", inputmode: "decimal" %>
<p class="hint">6 for avgas, 6.7 for Jet-A.</p>
<p class="hint"><%= t(".n6_for_avgas_6_7") %></p>
</div>
<fieldset>
<legend class="label">CG envelope</legend>
<p class="hint !mt-0 mb-2">The corners of the normal-category envelope, in order around it (e.g. forward limit at low weight, forward limit at gross, aft limit at gross, aft limit at low weight).</p>
<legend class="label"><%= t(".cg_envelope") %></legend>
<p class="hint !mt-0 mb-2"><%= t(".the_corners_of_the_normal") %></p>
<div class="mb-3 max-w-xs">
<%= label_tag "setup[envelope_unit]", "Envelope values are", class: "label" %>
<%= label_tag "setup[envelope_unit]", t(".envelope_values_are"), class: "label" %>
<%= select_tag "setup[envelope_unit]", options_for_select(LoadingSetup::ENVELOPE_UNITS.invert, @setup.envelope_unit), class: "input" %>
<p class="hint">Use the same units as your source: a POH “moment envelope” chart or Garmin Pilot give moment in lb-in/1000 (e.g. 2300 lb at 104.5). Moments are converted to CG (moment × 1000 ÷ weight) when saved. Changing this and saving reads the numbers below in the new units, so it also fixes moments typed in as CG.</p>
<p class="hint"><%= t(".use_the_same_units_as") %></p>
</div>
<div class="grid max-w-md grid-cols-3 gap-2 text-xs text-slate-500"><span>Weight (lb)</span><span><%= @setup.moment? ? "Moment (lb-in/1000)" : "CG (in)" %></span><span><%= "= CG (in)" if @setup.moment? %></span></div>
<div class="grid max-w-md grid-cols-3 gap-2 text-xs text-slate-500"><span><%= t(".weight_lb") %></span><span><%= @setup.moment? ? t(".moment_lb_in_1000") : t(".cg_in_2") %></span><span><%= t(".cg_in") if @setup.moment? %></span></div>
<% points.each_with_index do |pt, i| %>
<div class="mt-1 grid max-w-md grid-cols-3 items-center gap-2">
<%= text_field_tag "setup[envelope][#{i}][weight]", pt&.first&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Envelope point #{i + 1} weight" %>
<%= text_field_tag "setup[envelope][#{i}][cg]", pt&.last&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Envelope point #{i + 1} #{@setup.moment? ? 'moment' : 'CG'}" %>
<%= text_field_tag "setup[envelope][#{i}][weight]", pt&.first&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".envelope_point_weight", i: (i + 1)) %>
<%= text_field_tag "setup[envelope][#{i}][cg]", pt&.last&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": t(".envelope_point", i: (i + 1), moment: (@setup.moment? ? 'moment' : 'CG')) %>
<span class="text-sm text-slate-600"><%= "#{@setup.envelope[i].last.round(2)} in" if @setup.moment? && @setup.envelope[i] %></span>
</div>
<% end %>
</fieldset>
<div class="flex gap-2"><%= submit_tag "Save", class: "btn-primary" %><%= link_to "Cancel", aircraft_weight_balance_records_path(@aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= submit_tag t(".save"), class: "btn-primary" %><%= link_to t(".cancel"), aircraft_weight_balance_records_path(@aircraft), class: "btn-secondary" %></div>
<% end %>
@@ -2,19 +2,19 @@
<% comps = aircraft.components.where.not(status: "DISPOSED").includes(:component_type).order(:install_location) %>
<div class="grid gap-4 sm:grid-cols-3">
<div>
<%= f.label :component_id, "Component", class: "label" %>
<%= f.select :component_id, options_for_select([ [ "— None —", "" ] ] + comps.map { |c|
[ "#{c} · #{c.manufacturer} #{c.model}#{" · S/N #{c.serial_number}" if c.serial_number.present?}", c.id,
<%= f.label :component_id, t(".component"), class: "label" %>
<%= f.select :component_id, options_for_select([ [ t(".none"), "" ] ] + comps.map { |c|
[ "#{c} · #{c.manufacturer} #{c.model}#{" · #{t('.serial_short', serial: c.serial_number)}" if c.serial_number.present?}", c.id,
{ "data-total" => c.hours_in_service.to_f, "data-since" => c.hours_since_overhaul.to_f,
"data-kind" => (c.engine? ? "ENG" : c.propeller? ? "PROP" : ""), "data-abbr" => c.since_overhaul_abbreviation } ] }, f.object.component_id),
{}, class: "input", data: { component_times_target: "component", action: "component-times#componentChanged" } %>
<p class="hint">For engine and propeller logs: printed with its serial number and times.</p>
<p class="hint"><%= t(".for_engine_and_propeller_logs") %></p>
</div>
<%= f.field :component_hours_at_entry, as: :number, step: 0.1, label: "Component total time",
<%= f.field :component_hours_at_entry, as: :number, step: 0.1, label: t(".component_total_time"),
data: { component_times_target: "total", action: "input->component-times#markManual" } %>
<%= f.field :component_since_overhaul_at_entry, as: :number, step: 0.1, label: "Since overhaul",
<%= f.field :component_since_overhaul_at_entry, as: :number, step: 0.1, label: t(".since_overhaul"),
data: { component_times_target: "since", action: "input->component-times#markManual" },
hint: "Worked out from the component's current times and the airframe total time above; edit them if they differ." %>
hint: t(".worked_out_from_the_component") %>
</div>
<%# Sub-components of the chosen component (oil filter, magnetos…): tick to include them with their times. %>
<% children = comps.select(&:parent_component_id) %>
@@ -22,7 +22,7 @@
<% parts = f.object.parts.index_by(&:component_id) %>
<% selected = f.object.component %>
<fieldset class="space-y-2" data-component-times-target="partsBox" <%= "hidden" unless selected && (children.map(&:id) & selected.descendant_ids).any? %>>
<legend class="label">Sub-components</legend>
<legend class="label"><%= t(".sub_components") %></legend>
<% children.each do |c| %>
<% part = parts[c.id] %>
<% ancestors = c.ancestor_ids %>
@@ -35,19 +35,19 @@
data: { action: "component-times#partToggled" } %>
<span><%= c %> · <%= c.manufacturer %> <%= c.model %><%= " · S/N #{c.serial_number}" if c.serial_number.present? %></span>
</label>
<div><label class="text-xs text-slate-500" for="part_<%= c.id %>_hours">Total time</label>
<div><label class="text-xs text-slate-500" for="part_<%= c.id %>_hours"><%= t(".total_time") %></label>
<%= number_field_tag "#{field}[hours]", part&.hours_at_entry, id: "part_#{c.id}_hours", step: 0.1, class: "input",
data: { role: "hours", action: "input->component-times#partEdited" } %></div>
<div><label class="text-xs text-slate-500" for="part_<%= c.id %>_since"><%= c.since_overhaul_abbreviation.capitalize %></label>
<%= number_field_tag "#{field}[since]", part&.since_overhaul_at_entry, id: "part_#{c.id}_since", step: 0.1, class: "input",
data: { role: "since", action: "input->component-times#partEdited" } %></div>
<% if f.object.new_record? %>
<div><label class="text-xs text-slate-500" for="part_<%= c.id %>_service">On the Components tab</label>
<%= select_tag "#{field}[service]", options_for_select([ [ "Not changed", "" ], [ "Serviced", "serviced" ], [ "Replaced", "replaced" ] ], params.dig(:logbook_entry, :parts, c.id.to_s, :service)),
<div><label class="text-xs text-slate-500" for="part_<%= c.id %>_service"><%= t(".on_the_components_tab") %></label>
<%= select_tag "#{field}[service]", options_for_select([ [ t(".not_changed"), "" ], [ t(".serviced"), "serviced" ], [ t(".replaced"), "replaced" ] ], params.dig(:logbook_entry, :parts, c.id.to_s, :service)),
id: "part_#{c.id}_service", class: "input" %></div>
<% end %>
</div>
<% end %>
<p class="hint">Their times are worked out the same way as the component's. Sub-components are set up on the Components tab (a part's "Parent component").<%= " “Serviced” or “Replaced” also records it on the Components tab (e.g. an oil and filter change), dated to this entry." if f.object.new_record? %></p>
<p class="hint"><%= t(f.object.new_record? ? ".their_times_new_html" : ".their_times_are_worked_out_html") %></p>
</fieldset>
<% end %>
+9 -9
View File
@@ -1,19 +1,19 @@
<%# Everything a signature covers, as the signer reviews it (AC 120-78B 2.2.4). %>
<dl class="grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[10rem_1fr]">
<dt class="text-slate-500">Aircraft</dt><dd><%= entry.aircraft.tail_number %> <%= [ entry.aircraft.make, entry.aircraft.model ].compact_blank.join(" ") %><%= " · S/N #{entry.aircraft.serial_number}" if entry.aircraft.serial_number.present? %></dd>
<dt class="text-slate-500">Date</dt><dd><%= fmt_date(entry.date) %></dd>
<dt class="text-slate-500">Logbook</dt><dd><%= LogbookEntry::LOG_TYPES[entry.log_type] %> · <%= LogbookEntry::ENTRY_TYPES[entry.entry_type] %></dd>
<dt class="text-slate-500">Airframe total time</dt><dd><%= hours(entry.aircraft_hours_at_entry) %> (<%= entry.aircraft.time_basis %>)</dd>
<dt class="text-slate-500"><%= t(".aircraft") %></dt><dd><%= entry.aircraft.tail_number %> <%= [ entry.aircraft.make, entry.aircraft.model ].compact_blank.join(" ") %><%= " · S/N #{entry.aircraft.serial_number}" if entry.aircraft.serial_number.present? %></dd>
<dt class="text-slate-500"><%= t(".date") %></dt><dd><%= fmt_date(entry.date) %></dd>
<dt class="text-slate-500"><%= t(".logbook") %></dt><dd><%= LogbookEntry::LOG_TYPES[entry.log_type] %> · <%= LogbookEntry::ENTRY_TYPES[entry.entry_type] %></dd>
<dt class="text-slate-500"><%= t(".airframe_total_time") %></dt><dd><%= hours(entry.aircraft_hours_at_entry) %> (<%= entry.aircraft.time_basis %>)</dd>
<% if (c = entry.component) %>
<dt class="text-slate-500"><%= c.component_type&.name %></dt>
<dd><%= c.manufacturer %> <%= c.model %><%= " · S/N #{c.serial_number}" if c.serial_number.present? %> · <%= hours(entry.component_hours_at_entry) %> total, <%= hours(entry.component_since_overhaul_at_entry) %> <%= c.since_overhaul_abbreviation %></dd>
<dd><%= t(".total_html", manufacturer: c.manufacturer, model: c.model, present: (" · S/N #{c.serial_number}" if c.serial_number.present?), component_hours_at_entry: (hours(entry.component_hours_at_entry)), component_since_overhaul_at_entry: (hours(entry.component_since_overhaul_at_entry)), since_overhaul_abbreviation: c.since_overhaul_abbreviation) %></dd>
<% end %>
<% entry.parts.each do |part| %>
<dt class="text-slate-500"><%= part.component.component_type&.name %></dt>
<dd><%= part.component.manufacturer %> <%= part.component.model %><%= " · S/N #{part.component.serial_number}" if part.component.serial_number.present? %> · <%= hours(part.hours_at_entry) %> total, <%= hours(part.since_overhaul_at_entry) %> <%= part.component.since_overhaul_abbreviation.downcase %></dd>
<dd><%= t(".total_2_html", manufacturer: part.component.manufacturer, model: part.component.model, present: (" · S/N #{part.component.serial_number}" if part.component.serial_number.present?), hours_at_entry: (hours(part.hours_at_entry)), since_overhaul_at_entry: (hours(part.since_overhaul_at_entry)), since_overhaul_abbreviation: part.component.since_overhaul_abbreviation.downcase) %></dd>
<% end %>
<% if entry.inspection_result %><dt class="text-slate-500">Result</dt><dd><%= entry.inspection_result_label %></dd><% end %>
<% if entry.signoff_location.present? %><dt class="text-slate-500">Location</dt><dd><%= entry.signoff_location %></dd><% end %>
<% if entry.supersedes %><dt class="text-slate-500">Corrects</dt><dd>The <%= fmt_date(entry.supersedes.date) %> entry</dd><% end %>
<% if entry.inspection_result %><dt class="text-slate-500"><%= t(".result") %></dt><dd><%= entry.inspection_result_label %></dd><% end %>
<% if entry.signoff_location.present? %><dt class="text-slate-500"><%= t(".location") %></dt><dd><%= entry.signoff_location %></dd><% end %>
<% if entry.supersedes %><dt class="text-slate-500"><%= t(".corrects") %></dt><dd><%= t(".the_entry_html", date: (fmt_date(entry.supersedes.date))) %></dd><% end %>
</dl>
<div class="mt-3 whitespace-pre-wrap rounded bg-slate-50 p-3 font-mono text-sm"><%= entry.text %></div>
+23 -23
View File
@@ -3,41 +3,41 @@
<% if entry.supersedes %>
<%= f.hidden_field :supersedes_id %>
<p class="rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
Correcting the signed <%= link_to "#{fmt_date(entry.supersedes.date)} entry", aircraft_logbook_entry_path(aircraft, entry.supersedes), class: "link" %>.
Change what's wrong, save, then sign it: the original's signature is then marked superseded (it's kept, not deleted).
<%= t(".correcting_the_signed_html", link: (link_to t(".entry", date: fmt_date(entry.supersedes.date)), aircraft_logbook_entry_path(aircraft, entry.supersedes), class: "link")) %>
<%= t(".change_what_s_wrong_save") %>
</p>
<% end %>
<% templates = entry.new_record? ? LogbookTemplate.ordered.to_a : [] %>
<% if templates.any? %>
<div>
<%= label_tag :template, "Template", class: "label" %>
<%= label_tag :template, t(".template"), class: "label" %>
<select id="template" class="input" data-entry-template-target="template" data-action="entry-template#apply">
<option value="">— Write it yourself —</option>
<option value=""><%= t(".write_it_yourself") %></option>
<% templates.each do |t| %>
<option value="<%= t.id %>" data-text="<%= t.text %>" data-entry-type="<%= t.entry_type %>" data-log-type="<%= t.log_type %>"
data-certificate="<%= t.certificate_type %>"><%= t.label %></option>
<% end %>
</select>
<p class="hint">Fill in the blanks (__). The built-in ones are for a pilot doing preventive maintenance on an aircraft they own or operate (14 CFR 43.3(g)); their wording is paraphrased from Part 43 Appendix A(c), which sets each item's limits.<% if current_user.admin? %> <%= link_to "Edit templates", admin_logbook_templates_path, class: "link" %><% end %></p>
<p class="hint"><%= t(".fill_in_the_blanks_the") %><% if current_user.admin? %> <%= link_to t(".edit_templates"), admin_logbook_templates_path, class: "link" %><% end %></p>
</div>
<% end %>
<div class="grid gap-4 sm:grid-cols-4">
<%= f.field :date, as: :date %>
<%= f.field :log_type, as: :select, label: "Logbook", collection: LogbookEntry::LOG_TYPES.invert,
<%= f.field :log_type, as: :select, label: t(".logbook"), collection: LogbookEntry::LOG_TYPES.invert,
data: { component_times_target: "logType", entry_template_target: "logType", action: "component-times#logTypeChanged" } %>
<%= f.field :entry_type, as: :select, label: "Entry type", collection: LogbookEntry::ENTRY_TYPES.invert, data: { entry_template_target: "entryType" } %>
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: "Airframe total time",
<%= f.field :entry_type, as: :select, label: t(".entry_type"), collection: LogbookEntry::ENTRY_TYPES.invert, data: { entry_template_target: "entryType" } %>
<%= f.field :aircraft_hours_at_entry, as: :number, step: 0.1, label: t(".airframe_total_time"),
data: { component_times_target: "airframe", action: "input->component-times#airframeChanged" } %>
</div>
<%= render "logbook_entries/component_fields", f: f, aircraft: aircraft %>
<%= f.field :text, as: :textarea, label: "Entry text", rows: 8, data: { entry_template_target: "text" } %>
<p class="hint !mt-1">A maintenance entry needs a description of the work, the date, and the name, signature, certificate number and kind of certificate of whoever approved the return to service (14 CFR 43.9). An inspection entry also needs the type and extent of the inspection, the aircraft's time in service, and the result (43.11).</p>
<%= f.field :text, as: :textarea, label: t(".entry_text"), rows: 8, data: { entry_template_target: "text" } %>
<p class="hint !mt-1"><%= t(".a_maintenance_entry_needs_a") %></p>
<%= render "shared/sign_as" %>
<% if entry.new_record? && (types = aircraft.applicable_inspection_types.order(:name)).any? %>
<%# Recurring items this work completes (e.g. an oil change): recorded on the Inspections tab, dated to this entry. %>
<% ticked = Array(params.dig(:logbook_entry, :inspection_type_ids)).map(&:to_s) %>
<fieldset>
<legend class="label">Inspections completed</legend>
<legend class="label"><%= t(".inspections_completed") %></legend>
<div class="grid gap-x-4 gap-y-1 sm:grid-cols-3">
<% types.each do |t| %>
<label class="flex items-center gap-2 text-sm">
@@ -47,25 +47,25 @@
</label>
<% end %>
</div>
<p class="hint">Ticked ones are recorded as done on the Inspections tab, at this entry's date and airframe time, linked to this entry.</p>
<p class="hint"><%= t(".ticked_ones_are_recorded_as") %></p>
</fieldset>
<% end %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :signoff_person, label: "Signed off by", placeholder: "Name", data: { signer_target: "name" } %>
<%= f.field :signoff_certificate_type, as: :select, label: "Kind of certificate", include_blank: "—",
<%= f.field :signoff_person, label: t(".signed_off_by"), placeholder: t(".name"), data: { signer_target: "name" } %>
<%= f.field :signoff_certificate_type, as: :select, label: t(".kind_of_certificate"), include_blank: "—",
collection: LogbookEntry::CERTIFICATE_TYPES.invert, data: { entry_template_target: "certificate", signer_target: "kind" } %>
<%= f.field :signoff_certificate_number, label: "Certificate number", placeholder: "e.g. 1234567", data: { signer_target: "number" } %>
<%= f.field :signoff_certificate_number, label: t(".certificate_number"), placeholder: "e.g. 1234567", data: { signer_target: "number" } %>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :inspection_result, as: :select, label: "Inspection result", include_blank: "— Not an inspection —",
collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: "For inspection entries (43.11)." %>
<%= f.field :signoff_location, label: "Location / shop" %>
<%= f.field :document_id, as: :select, label: "Scanned page document", collection: document_options(aircraft) %>
<%= f.field :page_number, as: :number, label: "Page # in document" %>
<%= f.field :inspection_result, as: :select, label: t(".inspection_result"), include_blank: t(".not_an_inspection"),
collection: LogbookEntry::INSPECTION_RESULTS.invert, hint: t(".for_inspection_entries_43_11") %>
<%= f.field :signoff_location, label: t(".location_shop") %>
<%= f.field :document_id, as: :select, label: t(".scanned_page_document"), collection: document_options(aircraft) %>
<%= f.field :page_number, as: :number, label: t(".page_in_document") %>
</div>
<% if entry.persisted? && !entry.verified_was %>
<%= f.field :verified, as: :checkbox, label: "I've checked this against the scan", hint: "Transcribed by Claude; it stays marked unverified until someone checks it." %>
<%= f.field :verified, as: :checkbox, label: t(".i_ve_checked_this_against"), hint: t(".transcribed_by_claude_it_stays") %>
<% end %>
<div class="flex gap-2"><%= f.submit "Save Entry" %><%= link_to "Cancel", aircraft_logbook_entries_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save_entry") %><%= link_to t(".cancel"), aircraft_logbook_entries_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if entry.persisted? %><div class="mt-4"><%= delete_button "Delete entry", aircraft_logbook_entry_path(aircraft, entry) %></div><% end %>
<% if entry.persisted? %><div class="mt-4"><%= delete_button t(".delete_entry"), aircraft_logbook_entry_path(aircraft, entry) %></div><% end %>
@@ -3,12 +3,12 @@
<% box, title = { valid: [ "bg-emerald-50 ring-emerald-200", "text-emerald-900" ], superseded: [ "bg-amber-50 ring-amber-200", "text-amber-900" ],
altered: [ "bg-red-50 ring-red-200", "text-red-900" ] }.fetch(sig.imported? ? :valid : sig.status) %>
<div class="rounded-md p-3 text-sm ring-1 <%= box %>">
<div class="font-medium <%= title %>"><%= EntrySignature::LABEL %> <%= sig.signer_name %>, <%= sig.certificate_label %> <%= sig.certificate_number %></div>
<div class="text-slate-700">Signed electronically <%= sig.signed_at.utc.strftime("%Y-%m-%d %H:%M UTC") %><%= " (#{EntrySignature::AUTH_METHODS[sig.auth_method]})" if EntrySignature::AUTH_METHODS[sig.auth_method] %></div>
<div class="font-medium <%= title %>"><%= EntrySignature.label %> <%= sig.signer_name %>, <%= sig.certificate_label %> <%= sig.certificate_number %></div>
<div class="text-slate-700"><%= t(".signed_electronically_html", d: (sig.signed_at.utc.strftime("%Y-%m-%d %H:%M UTC")), auth_method: (" (#{EntrySignature::AUTH_METHODS[sig.auth_method]})" if EntrySignature::AUTH_METHODS[sig.auth_method])) %></div>
<div class="mt-1 italic text-slate-700">“<%= sig.statement %>”</div>
<div class="mt-1 text-xs text-slate-500">
Status: <strong><%= sig.imported? ? "Signed on #{sig.origin} (imported)" : sig.status_label %></strong>
· Fingerprint <span class="font-mono"><%= sig.content_digest.first(16) %>…</span>
<% if entry.superseded_by %> · Corrected by <%= link_to "the #{fmt_date(entry.superseded_by.date)} entry", aircraft_logbook_entry_path(entry.aircraft, entry.superseded_by), class: "link" %><% end %>
<%= t(".status_html", status_label: (sig.imported? ? t(".signed_on_imported", origin: sig.origin) : sig.status_label)) %>
<%= t(".fingerprint") %> <span class="font-mono"><%= sig.content_digest.first(16) %>…</span>
<% if entry.superseded_by %> <%= t(".corrected_by_html", link: (link_to t(".the_entry", date: fmt_date(entry.superseded_by.date)), aircraft_logbook_entry_path(entry.aircraft, entry.superseded_by), class: "link")) %><% end %>
</div>
</div>
+15 -15
View File
@@ -1,21 +1,21 @@
<% content_for :title, "#{@aircraft.tail_number} Logbook" %>
<% content_for :title, t(".logbook", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card">
<div class="card-header">
<h2 class="card-title">Maintenance Logbook <%= link_to "How records and signing work", records_help_path, class: "link ml-2 text-xs font-normal" %></h2>
<h2 class="card-title"><%= t(".maintenance_logbook_html", link: (link_to t(".how_records_and_signing_work"), records_help_path, class: "link ml-2 text-xs font-normal")) %></h2>
<div class="flex flex-wrap items-center gap-2">
<%= form_with url: aircraft_logbook_entries_path(@aircraft), method: :get, class: "flex w-full flex-wrap gap-2 sm:w-auto" do |f| %>
<%= f.search_field :q, value: @query, placeholder: "Search entries…", class: "input min-w-0 flex-1 sm:w-48 sm:flex-none" %>
<%= f.select :log_type, LogbookEntry::LOG_TYPES.invert, { include_blank: "All logs", selected: @log_type }, class: "input w-32", data: { submit_on_change: true } %>
<%= f.search_field :q, value: @query, placeholder: t(".search_entries"), class: "input min-w-0 flex-1 sm:w-48 sm:flex-none" %>
<%= f.select :log_type, LogbookEntry::LOG_TYPES.invert, { include_blank: t(".all_logs"), selected: @log_type }, class: "input w-32", data: { submit_on_change: true } %>
<% if @unverified_count.positive? || @unverified_only %>
<label class="flex items-center gap-1 text-sm text-slate-700"><%= f.check_box :unverified, { checked: @unverified_only, data: { submit_on_change: true } }, "1", nil %> Unverified (<%= @unverified_count %>)</label>
<label class="flex items-center gap-1 text-sm text-slate-700"><%= t(".unverified_html", checkbox: (f.check_box :unverified, { checked: @unverified_only, data: { submit_on_change: true } }, "1", nil), unverified_count: @unverified_count) %></label>
<% end %>
<%= f.submit "Filter", class: "sr-only" %>
<%= f.submit t(".filter"), class: "sr-only" %>
<% end %>
<% if @entries.any? %><button type="submit" form="print-entries" class="btn-secondary" hidden data-needs-selection="print-entries" title="Print the ticked entries on labels or pages for the paper logbook">Print selected</button><% end %>
<% if @entries.any? %><button type="submit" form="print-entries" class="btn-secondary" hidden data-needs-selection="print-entries" title="<%= t(".print_the_ticked_entries_on") %>"><%= t(".print_selected") %></button><% end %>
<% if owner? %>
<%= more_menu do %><%= link_to "Import scans", new_aircraft_logbook_import_path(@aircraft), class: "menu-item" %><% end %>
<%= link_to "+ New Entry", new_aircraft_logbook_entry_path(@aircraft), class: "btn-primary" %>
<%= more_menu do %><%= link_to t(".import_scans"), new_aircraft_logbook_import_path(@aircraft), class: "menu-item" %><% end %>
<%= link_to t(".new_entry"), new_aircraft_logbook_entry_path(@aircraft), class: "btn-primary" %>
<% end %>
</div>
</div>
@@ -23,7 +23,7 @@
<%= form_with url: new_aircraft_logbook_print_path(@aircraft), method: :get, id: "print-entries" do %><% end %>
<div class="overflow-x-auto">
<table class="table">
<thead><tr><th><input type="checkbox" class="mr-1 align-middle" aria-label="Select all entries" data-check-all> Date</th><th>Log</th><th>Type</th><th class="text-right">Hours</th><th>Entry</th><th>Signed off</th></tr></thead>
<thead><tr><th><input type="checkbox" class="mr-1 align-middle" aria-label="<%= t(".select_all_entries") %>" data-check-all> <%= t(".date") %></th><th><%= t(".log") %></th><th><%= t(".type") %></th><th class="text-right"><%= t(".hours") %></th><th><%= t(".entry") %></th><th><%= t(".signed_off") %></th></tr></thead>
<tbody>
<% @entries.each do |e| %>
<tr>
@@ -31,17 +31,17 @@
<td><span class="badge-gray"><%= LogbookEntry::LOG_TYPES[e.log_type] %></span></td>
<td class="text-xs"><%= LogbookEntry::ENTRY_TYPES[e.entry_type] %></td>
<td class="text-right tabular-nums"><%= hours(e.aircraft_hours_at_entry) %></td>
<td class="max-w-xl"><%= e.text.truncate(220) %> <% if e.document %><span role="img" title="Has a scanned page" aria-label="Has a scanned page">📄</span><% end %>
<% unless e.verified? %><span class="badge-orange" title="Transcribed by Claude<%= " (#{e.transcription_confidence} confidence)" if e.transcription_confidence %>; check it against the scan">Unverified</span><% end %></td>
<td class="max-w-xl"><%= e.text.truncate(220) %> <% if e.document %><span role="img" title="<%= t(".has_a_scanned_page") %>" aria-label="<%= t(".has_a_scanned_page") %>">📄</span><% end %>
<% unless e.verified? %><span class="badge-orange" title="Transcribed by Claude<%= t(".confidence", transcription_confidence: e.transcription_confidence) if e.transcription_confidence %>; check it against the scan"><%= t(".unverified_2") %></span><% end %></td>
<td class="text-xs text-slate-500"><%= e.signoff_person %><%= " ##{e.signoff_certificate_number}" if e.signoff_certificate_number %><% if e.signoff_location.present? %><br><%= e.signoff_location %><% end %>
<% if e.signature %><br><span class="<%= e.superseded? ? 'badge-orange' : 'badge-green' %>" title="Signed electronically by <%= e.signature.signer_name %>"><%= e.superseded? ? "Superseded" : "Signed" %></span>
<% elsif (missing = e.missing_record_items).any? %><br><span class="badge-orange" title="Missing: <%= missing.to_sentence %>">Incomplete</span><% end %></td>
<% if e.signature %><br><span class="<%= e.superseded? ? 'badge-orange' : 'badge-green' %>" title="Signed electronically by <%= e.signature.signer_name %>"><%= e.superseded? ? t(".superseded") : t(".signed") %></span>
<% elsif (missing = e.missing_record_items).any? %><br><span class="badge-orange" title="Missing: <%= missing.to_sentence %>"><%= t(".incomplete") %></span><% end %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<%= empty_state(@query.present? ? "No entries match “#{@query}”." : "No logbook entries yet.") %>
<%= empty_state(@query.present? ? t(".no_entries_match", query: @query) : t(".no_logbook_entries_yet")) %>
<% end %>
</section>
+21 -21
View File
@@ -1,19 +1,19 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card max-w-4xl">
<div class="card-header">
<h2 class="card-title"><%= LogbookEntry::LOG_TYPES[@entry.log_type] %> log — <%= fmt_date(@entry.date) %></h2>
<h2 class="card-title"><%= t(".log_html", log_type: (LogbookEntry::LOG_TYPES[@entry.log_type]), date: (fmt_date(@entry.date))) %></h2>
<div class="flex gap-2">
<% if @entry.signed? %>
<%= link_to "Print for logbook", new_aircraft_logbook_print_path(@aircraft, ids: [ @entry.id ]), class: "btn-secondary btn-sm" %>
<%= link_to t(".print_for_logbook"), new_aircraft_logbook_print_path(@aircraft, ids: [ @entry.id ]), class: "btn-secondary btn-sm" %>
<% if owner? && !@entry.superseded? && !@entry.superseded_by %>
<%= more_menu(small: true) do %><%= link_to "Correct this entry", new_aircraft_logbook_entry_path(@aircraft, supersedes: @entry.id), class: "menu-item" %><% end %>
<%= more_menu(small: true) do %><%= link_to t(".correct_this_entry"), new_aircraft_logbook_entry_path(@aircraft, supersedes: @entry.id), class: "menu-item" %><% end %>
<% end %>
<% else %>
<%= link_to "Sign", new_aircraft_logbook_entry_signature_path(@aircraft, @entry), class: "btn-primary btn-sm" %>
<% if owner? %><%= link_to "Edit", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary btn-sm" %><% end %>
<%= link_to t(".sign"), new_aircraft_logbook_entry_signature_path(@aircraft, @entry), class: "btn-primary btn-sm" %>
<% if owner? %><%= link_to t(".edit"), edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "btn-secondary btn-sm" %><% end %>
<%= more_menu(small: true) do %>
<% if owner? %><%= link_to "Ask someone to sign", new_aircraft_logbook_entry_signing_invitation_path(@aircraft, @entry), class: "menu-item" %><% end %>
<%= link_to "Print for logbook", new_aircraft_logbook_print_path(@aircraft, ids: [ @entry.id ]), class: "menu-item" %>
<% if owner? %><%= link_to t(".ask_someone_to_sign"), new_aircraft_logbook_entry_signing_invitation_path(@aircraft, @entry), class: "menu-item" %><% end %>
<%= link_to t(".print_for_logbook"), new_aircraft_logbook_print_path(@aircraft, ids: [ @entry.id ]), class: "menu-item" %>
<% end %>
<% end %>
</div>
@@ -21,43 +21,43 @@
<div class="card-body space-y-3">
<% if @entry.signed? %><%= render "logbook_entries/signature", entry: @entry %>
<% elsif LogbookEntry::RECORD_TYPES.include?(@entry.entry_type) %>
<p class="rounded-md bg-slate-50 px-3 py-2 text-sm text-slate-600 ring-1 ring-slate-200">Not signed electronically.<%= " Pending correction of the #{fmt_date(@entry.supersedes.date)} entry." if @entry.supersedes %> Sign it here, or print it and sign the paper copy.</p>
<p class="rounded-md bg-slate-50 px-3 py-2 text-sm text-slate-600 ring-1 ring-slate-200"><%= t(".not_signed_electronically_sign_it_html", supersedes: (t(".pending_correction_of_the_entry", date: (fmt_date(@entry.supersedes.date))) if @entry.supersedes)) %></p>
<% end %>
<% unless @entry.verified? %>
<div class="flex flex-wrap items-center justify-between gap-2 rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
<span>Transcribed by Claude<%= " (#{@entry.transcription_confidence} confidence)" if @entry.transcription_confidence %> and not yet checked. Compare it with the scan<%= @entry.document ? "" : " or the paper logbook" %> before relying on it.</span>
<% if owner? %><%= button_to "Matches the scan: mark verified", verify_aircraft_logbook_entry_path(@aircraft, @entry), method: :patch, class: "btn-secondary btn-sm" %><% end %>
<span><%= t(".transcribed_by_claude_and_not_html", transcription_confidence: (t(".confidence", transcription_confidence: @entry.transcription_confidence) if @entry.transcription_confidence), logbook: (@entry.document ? "" : t(".or_the_paper_logbook"))) %></span>
<% if owner? %><%= button_to t(".matches_the_scan_mark_verified"), verify_aircraft_logbook_entry_path(@aircraft, @entry), method: :patch, class: "btn-secondary btn-sm" %><% end %>
</div>
<% end %>
<div class="flex flex-wrap gap-4 text-sm text-slate-600">
<span>Type: <%= LogbookEntry::ENTRY_TYPES[@entry.entry_type] %></span>
<span>Airframe total time: <%= hours(@entry.aircraft_hours_at_entry) %></span>
<span><%= t(".type_html", entry_type: (LogbookEntry::ENTRY_TYPES[@entry.entry_type])) %></span>
<span><%= t(".airframe_total_time_html", aircraft_hours_at_entry: (hours(@entry.aircraft_hours_at_entry))) %></span>
<% if (c = @entry.component) %>
<span><%= c %> <%= c.model %><%= " S/N #{c.serial_number}" if c.serial_number.present? %>:
<%= hours(@entry.component_hours_at_entry) %> total, <%= hours(@entry.component_since_overhaul_at_entry) %> <%= c.since_overhaul_abbreviation %></span>
<%= t(".total_html", component_hours_at_entry: (hours(@entry.component_hours_at_entry)), component_since_overhaul_at_entry: (hours(@entry.component_since_overhaul_at_entry)), since_overhaul_abbreviation: c.since_overhaul_abbreviation) %></span>
<% end %>
<% @entry.parts.each do |part| %>
<% pc = part.component %>
<span><%= pc %> <%= pc.model %><%= " S/N #{pc.serial_number}" if pc.serial_number.present? %>:
<%= hours(part.hours_at_entry) %> total, <%= hours(part.since_overhaul_at_entry) %> <%= pc.since_overhaul_abbreviation.downcase %></span>
<%= t(".total_2_html", hours_at_entry: (hours(part.hours_at_entry)), since_overhaul_at_entry: (hours(part.since_overhaul_at_entry)), since_overhaul_abbreviation: pc.since_overhaul_abbreviation.downcase) %></span>
<% end %>
</div>
<div class="whitespace-pre-wrap rounded bg-slate-50 p-3 font-mono text-sm"><%= @entry.text %></div>
<div class="text-sm text-slate-600">
Signed off: <%= @entry.signoff_person.presence || "—" %>
<%= t(".signed_off_html", signoff_person: (@entry.signoff_person.presence || "—")) %>
<%= ", #{@entry.certificate_label}" if @entry.certificate_label %><%= " ##{@entry.signoff_certificate_number}" if @entry.signoff_certificate_number %>
<%= "(#{@entry.signoff_location})" if @entry.signoff_location.present? %>
</div>
<% if @entry.inspection_result %><div class="text-sm text-slate-600">Result: <%= @entry.inspection_result_label %></div><% end %>
<% if @entry.inspection_result %><div class="text-sm text-slate-600"><%= t(".result_html", inspection_result_label: @entry.inspection_result_label) %></div><% end %>
<% if (missing = @entry.missing_record_items).any? %>
<p class="rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 ring-1 ring-amber-200">
Missing for <%= @entry.entry_type == "INSPECTION" ? "43.11" : "43.9" %>: <%= missing.to_sentence %>.
<%= link_to("Fill in", edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "link") if owner? %>
(Check against the signed logbook.)
<%= t(".missing_for_html", entry_type: (@entry.entry_type == "INSPECTION" ? "43.11" : "43.9"), items: missing.to_sentence) %>
<%= link_to(t(".fill_in"), edit_aircraft_logbook_entry_path(@aircraft, @entry), class: "link") if owner? %>
<%= t(".check_against_the_signed_logbook") %>
</p>
<% end %>
<% if @entry.document %>
<p class="text-sm">Scan: <%= link_to @entry.document.name, aircraft_document_path(@aircraft, @entry.document, page: @entry.page_number), class: "link" %><%= " (page #{@entry.page_number})" if @entry.page_number %></p>
<p class="text-sm"><%= t(".scan_html", link: (link_to @entry.document.name, aircraft_document_path(@aircraft, @entry.document, page: @entry.page_number), class: "link"), page_number: (t(".page", page_number: @entry.page_number) if @entry.page_number)) %></p>
<% end %>
</div>
</section>
@@ -65,7 +65,7 @@
<% history = (@entry.versions.to_a + @entry.parts.flat_map { _1.versions.to_a } + (@entry.signature ? @entry.signature.versions.to_a : [])).sort_by(&:id).reverse %>
<% if history.any? %>
<details class="card mt-5 max-w-4xl">
<summary class="card-header cursor-pointer"><span class="card-title">Change history (<%= history.size %>)</span></summary>
<summary class="card-header cursor-pointer"><span class="card-title"><%= t(".change_history_html", history: history.size) %></span></summary>
<%= render "record_versions/list", versions: history %>
</details>
<% end %>
+21 -21
View File
@@ -1,39 +1,39 @@
<% content_for :title, "#{@aircraft.tail_number} Import Logbook Pages" %>
<% content_for :title, t(".import_logbook_pages", tail_number: @aircraft.tail_number) %>
<%= 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>
<h2 class="card-title"><%= t(".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 %>
<%= t(".the_pages_are_saved_as") %>
<% if ai %><%= t(".claude_can_also_read_them") %><% else %>
<%= t(".to_have_entries_transcribed_automatically_html") %><% end %>
</p>
</div>
<div>
<%= f.label :pages, "Scanned pages", class: "label" %>
<%= f.label :pages, t(".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>
<p class="hint mt-1"><%= t(".jpeg_png_webp_or_pdf") %></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 ] },
<%= f.label :collection_id, t(".collection"), class: "label" %>
<%= f.select :collection_id, [ [ t(".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" %>
<%= f.label :collection_name, t(".new_collection_name"), class: "label" %>
<%= f.text_field :collection_name, value: params[:collection_name], placeholder: t(".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" %>
<%= f.label :document_name, t(".document_name"), class: "label" %>
<%= f.text_field :document_name, value: params[:document_name], placeholder: t(".same_as_the_collection"), class: "input" %>
</div>
<div>
<%= f.label :doc_type, "Document type", class: "label" %>
<%= f.label :doc_type, t(".document_type"), class: "label" %>
<%= f.select :doc_type, Document::TYPES.invert, { selected: params[:doc_type] || "LOG" }, class: "input" %>
</div>
</div>
@@ -41,18 +41,18 @@
<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>
<span><%= t(".transcribe_with_claude_html") %>
<span class="hint"><%= t(".each_entry_becomes_a_logbook") %></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>
<%= f.label :log_type, t(".log"), class: "label" %>
<%= f.select :log_type, [ [ t(".detect_for_each_entry"), "" ] ] + LogbookEntry::LOG_TYPES.invert.to_a, { selected: params[:log_type] }, class: "input", disabled: !ai %>
<p class="hint mt-1"><%= t(".pick_one_when_the_whole") %></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" %>
<%= f.submit ai ? t(".upload_transcribe") : t(".upload_pages"), class: "btn-primary" %>
<%= link_to t(".cancel"), aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>
+12 -13
View File
@@ -1,44 +1,43 @@
<% content_for :title, "#{@aircraft.tail_number} Logbook Import" %>
<% content_for :title, t(".logbook_import", tail_number: @aircraft.tail_number) %>
<% 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>
<h2 class="card-title"><%= @import.document&.name || t(".logbook_pages") %></h2>
<span class="text-xs text-slate-500"><%= t("counts.page", count: @import.pages_total) %><%= t(".read_by", model: @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><%= @import.transcribe ? t(".claude_is_reading_the_pages") : t(".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>
<p class="hint mt-2"><%= t(".so_far_this_page_updates_html", entry: (t("counts.entry", count: @import.entries_created))) %></p>
</div>
<% elsif @import.done? %>
<p class="font-medium text-emerald-700">
<%= @import.transcribe ? "Done: #{pluralize(@import.entries_created, 'logbook entry')} added." : "Pages saved." %>
<%= @import.transcribe ? t(".done_added", entry: (t("counts.logbook_entry", count: @import.entries_created))) : t(".pages_saved") %>
</p>
<% if @import.transcribe && @import.entries_created.positive? %>
<p class="text-slate-600">The new entries are marked unverified until someone checks them against the scans, since handwriting isn't always read perfectly.
<%= link_to "Check them now", aircraft_logbook_entries_path(@aircraft, unverified: 1), class: "link" %></p>
<p class="text-slate-600"><%= t(".the_new_entries_are_marked_html", link: (link_to t(".check_them_now"), aircraft_logbook_entries_path(@aircraft, unverified: 1), class: "link")) %></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 %>
<p class="font-medium text-red-700"><%= t(".the_import_stopped_html", error: @import.error) %></p>
<% if @import.entries_created.positive? %><p class="text-slate-600"><%= t(".were_added_before_it_stopped_html", entry: (t("counts.entry", count: @import.entries_created))) %></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 %>
<%= link_to t(".logbook"), aircraft_logbook_entries_path(@aircraft), class: "btn-secondary btn-sm" %>
<% if @import.document %><%= link_to t(".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>
<p class="mb-1 text-xs font-semibold text-slate-500"><%= t("counts.note", count: @import.warnings.size) %></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 %>
+9 -9
View File
@@ -1,29 +1,29 @@
<% content_for :title, "Print logbook entries" %>
<% content_for :title, t(".print_logbook_entries") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with url: aircraft_logbook_print_path(@aircraft, format: :pdf), method: :get, class: "card card-body max-w-2xl space-y-4",
data: { turbo: false }, html: { target: "_blank" } do %>
<div>
<h2 class="card-title">Print for the logbook</h2>
<p class="mt-1 text-sm text-slate-600">A PDF of <%= pluralize(@entries.size, "entry") %> to print on adhesive labels or paper and put in <%= @aircraft.tail_number %>'s logbook. Each one has a blank line to sign by hand: a printed entry isn't valid until it's signed.</p>
<h2 class="card-title"><%= t(".print_for_the_logbook") %></h2>
<p class="mt-1 text-sm text-slate-600"><%= t(".a_pdf_of_to_print_html", entry: (t("counts.entry", count: @entries.size)), tail_number: @aircraft.tail_number) %></p>
</div>
<% @entries.each do |e| %><%= hidden_field_tag "ids[]", e.id, id: nil %><% end %>
<ul class="max-h-48 space-y-1 overflow-y-auto rounded-md bg-slate-50 p-3 text-sm">
<% @entries.each do |e| %>
<li><span class="font-medium"><%= fmt_date(e.date) %></span> · <%= LogbookEntry::LOG_TYPES[e.log_type] %> · <%= e.text.truncate(90) %>
<% if (missing = e.missing_record_items).any? %><span class="text-xs text-amber-700">(missing <%= missing.to_sentence %>)</span><% end %></li>
<% if (missing = e.missing_record_items).any? %><span class="text-xs text-amber-700"><%= t(".missing_html", to_sentence: missing.to_sentence) %></span><% end %></li>
<% end %>
</ul>
<fieldset class="space-y-2 text-sm">
<legend class="label">Paper</legend>
<legend class="label"><%= t(".paper") %></legend>
<% LogbookEntryPdf::LAYOUTS.each do |l| %>
<label class="flex items-center gap-2"><%= radio_button_tag :layout, l.key, @layout == l.key %> <%= l.label %></label>
<% end %>
</fieldset>
<div class="max-w-xs">
<%= label_tag :start_at, "Start at label", class: "label" %>
<%= label_tag :start_at, t(".start_at_label"), class: "label" %>
<%= number_field_tag :start_at, 1, min: 1, max: 10, class: "input w-24" %>
<p class="hint">On a partly used label sheet, the first free label, counting across then down.</p>
<p class="hint"><%= t(".on_a_partly_used_label") %></p>
</div>
<p class="hint">Print at 100% (“Actual size”), not “Fit to page”, so labels line up. Try a plain sheet first and hold it against the labels.</p>
<div class="flex gap-2"><%= submit_tag "Open PDF", class: "btn-primary" %><%= link_to "Back", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %></div>
<p class="hint"><%= t(".print_at_100_actual_size") %></p>
<div class="flex gap-2"><%= submit_tag t(".open_pdf"), class: "btn-primary" %><%= link_to t(".back"), aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %></div>
<% end %>
+44 -44
View File
@@ -1,6 +1,6 @@
<% a = @report.aircraft %>
<% clock = a.time_basis_label.downcase %>
<% content_for :title, "#{a.tail_number} Maintenance Status" %>
<% content_for :title, t(".maintenance_status", tail_number: a.tail_number) %>
<% section = "mt-6 break-inside-avoid-page" %>
<% th = "border-b border-slate-300 py-1 pr-3 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-500" %>
<% td = "border-b border-slate-100 py-1 pr-3 align-top" %>
@@ -8,32 +8,32 @@
<% unless @standalone %>
<div class="mb-4 flex flex-wrap items-center justify-between gap-2 print:hidden">
<% back = @share ? shared_path(@share.token) : aircraft_path(a) %>
<%= link_to "← Back", back, class: "link text-sm" %>
<button type="button" class="btn-primary" data-print>Print or save as PDF</button>
<%= link_to t(".back"), back, class: "link text-sm" %>
<button type="button" class="btn-primary" data-print><%= t(".print_or_save_as_pdf") %></button>
</div>
<% end %>
<header class="flex flex-wrap items-end justify-between gap-4 border-b-2 border-slate-800 pb-3">
<div>
<p class="text-xs uppercase tracking-wide text-slate-500">Maintenance status · 14 CFR 91.417(a)(2)</p>
<p class="text-xs uppercase tracking-wide text-slate-500"><%= t(".maintenance_status_14_cfr_91") %></p>
<h1 class="text-2xl font-bold"><%= a.tail_number %> <span class="text-lg font-normal text-slate-600"><%= [ a.make, a.model ].compact_blank.join(" ") %></span></h1>
<p class="text-sm text-slate-600">Serial number <%= a.serial_number.presence || "—" %></p>
<p class="text-sm text-slate-600"><%= t(".serial_number_html", serial_number: (a.serial_number.presence || "—")) %></p>
</div>
<dl class="grid grid-cols-2 gap-x-6 text-sm">
<dt class="text-slate-500">Prepared</dt><dd><%= l(@report.generated_at.to_date, format: :long) %></dd>
<dt class="text-slate-500">Airframe time in service</dt><dd class="font-semibold"><%= hours(@report.time_in_service) %> hrs (<%= clock %>)</dd>
<dt class="text-slate-500">Tach / Hobbs</dt><dd><%= hours(a.tach_time) %> / <%= hours(a.hobbs_time) %></dd>
<dt class="text-slate-500">Status</dt><dd><%= airworthiness_badge(@report.airworthiness) %></dd>
<dt class="text-slate-500">Electronic records since</dt><dd><%= a.electronic_records_since || "—" %></dd>
<dt class="text-slate-500"><%= t(".prepared") %></dt><dd><%= l(@report.generated_at.to_date, format: :long) %></dd>
<dt class="text-slate-500"><%= t(".airframe_time_in_service") %></dt><dd class="font-semibold"><%= t(".hrs_html", time_in_service: (hours(@report.time_in_service)), clock: clock) %></dd>
<dt class="text-slate-500"><%= t(".tach_hobbs") %></dt><dd><%= hours(a.tach_time) %> / <%= hours(a.hobbs_time) %></dd>
<dt class="text-slate-500"><%= t(".status") %></dt><dd><%= airworthiness_badge(@report.airworthiness) %></dd>
<dt class="text-slate-500"><%= t(".electronic_records_since") %></dt><dd><%= a.electronic_records_since || "—" %></dd>
</dl>
</header>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Total time in service: engines and propellers</h2>
<h2 class="text-base font-semibold"><%= t(".total_time_in_service_engines") %></h2>
<% majors = @report.engines + @report.propellers %>
<% if majors.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Make / model</th><th class="<%= th %>">Serial</th><th class="<%= th %> text-right">Total time</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Overhauled</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".item") %></th><th class="<%= th %>"><%= t(".make_model") %></th><th class="<%= th %>"><%= t(".serial") %></th><th class="<%= th %> text-right"><%= t(".total_time") %></th><th class="<%= th %> text-right"><%= t(".since_overhaul") %></th><th class="<%= th %>"><%= t(".overhauled") %></th></tr></thead>
<tbody>
<% majors.each do |c| %>
<tr><td class="<%= td %>"><%= c %></td><td class="<%= td %>"><%= [ c.manufacturer, c.model ].compact_blank.join(" ") %></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
@@ -41,70 +41,70 @@
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No engines or propellers recorded as components.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".no_engines_or_propellers_recorded") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Life-limited parts</h2>
<h2 class="text-base font-semibold"><%= t(".life_limited_parts") %></h2>
<% if @report.life_limited.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Part</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Limit</th><th class="<%= th %> text-right">Used</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Status</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".part") %></th><th class="<%= th %>"><%= t(".serial") %></th><th class="<%= th %>"><%= t(".limit") %></th><th class="<%= th %> text-right"><%= t(".used") %></th><th class="<%= th %>"><%= t(".remaining") %></th><th class="<%= th %>"><%= t(".status") %></th></tr></thead>
<tbody>
<% @report.life_limited.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.replacement_hours && "#{hours(c.replacement_hours)} hrs"), c.replacement_interval_label, (c.expires_on && "expires #{fmt_date(c.expires_on)}") ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %> text-right tabular-nums"><%= t(".hrs_2_html", hours_since_overhaul: (hours(c.hours_since_overhaul))) %></td>
<td class="<%= td %>"><%= [ (c.hours_to_replacement && "#{hours(c.hours_to_replacement)} hrs"), (c.next_replacement_date && "by #{fmt_date(c.next_replacement_date)}") ].compact.join(", ") %></td>
<td class="<%= td %>"><%= life_badge(c.life_status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".none_recorded") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Time since overhaul</h2>
<h2 class="text-base font-semibold"><%= t(".time_since_overhaul") %></h2>
<% if @report.overhaul_items.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Item</th><th class="<%= th %>">Serial</th><th class="<%= th %>">Overhaul interval</th><th class="<%= th %> text-right">Since overhaul</th><th class="<%= th %>">Remaining</th><th class="<%= th %>">Tracked as</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".item") %></th><th class="<%= th %>"><%= t(".serial") %></th><th class="<%= th %>"><%= t(".overhaul_interval") %></th><th class="<%= th %> text-right"><%= t(".since_overhaul") %></th><th class="<%= th %>"><%= t(".remaining") %></th><th class="<%= th %>"><%= t(".tracked_as") %></th></tr></thead>
<tbody>
<% @report.overhaul_items.each do |c| %>
<tr><td class="<%= td %>"><%= c %> <span class="text-slate-500"><%= c.model %></span></td><td class="<%= td %>"><%= c.serial_number.presence || "—" %></td>
<td class="<%= td %>"><%= [ (c.tbo_hours && "#{hours(c.tbo_hours)} hrs"), c.tbo_interval_label ].compact.join(" / ") %></td>
<td class="<%= td %> text-right tabular-nums"><%= hours(c.hours_since_overhaul) %> hrs</td>
<td class="<%= td %> text-right tabular-nums"><%= t(".hrs_2_html", hours_since_overhaul: (hours(c.hours_since_overhaul))) %></td>
<td class="<%= td %>"><%= c.hours_to_tbo ? "#{hours(c.hours_to_tbo)} hrs" : "—" %></td>
<td class="<%= td %> text-xs"><%= c.on_condition? ? "On condition (Part 91)" : (c.tbo_critical? ? "Hard limit" : "Recommended") %></td></tr>
<td class="<%= td %> text-xs"><%= c.on_condition? ? t(".on_condition_part_91") : (c.tbo_critical? ? t(".hard_limit") : t(".recommended")) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".none_recorded") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Inspection status</h2>
<h2 class="text-base font-semibold"><%= t(".inspection_status") %></h2>
<% if @report.inspections.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Inspection</th><th class="<%= th %>">Interval</th><th class="<%= th %>">Last done</th><th class="<%= th %> text-right">Since</th><th class="<%= th %>">Next due</th><th class="<%= th %>">Status</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".inspection") %></th><th class="<%= th %>"><%= t(".interval") %></th><th class="<%= th %>"><%= t(".last_done") %></th><th class="<%= th %> text-right"><%= t(".since") %></th><th class="<%= th %>"><%= t(".next_due") %></th><th class="<%= th %>"><%= t(".status") %></th></tr></thead>
<tbody>
<% @report.inspections.each do |row| %>
<% last = row.latest %>
<tr><td class="<%= td %>"><%= row.type.name %><% if row.type.satisfies %><div class="text-xs text-slate-500">Also counts as <%= row.type.satisfies.name %></div><% end %></td>
<tr><td class="<%= td %>"><%= row.type.name %><% if row.type.satisfies %><div class="text-xs text-slate-500"><%= t(".also_counts_as_html", satisfies: row.type.satisfies.name) %></div><% end %></td>
<td class="<%= td %> text-xs"><%= row.type.interval_description %></td>
<td class="<%= td %>"><%= last ? "#{fmt_date(last.date)}#{" @ #{hours(last.hours_at_inspection)}" if last.hours_at_inspection}" : "Never" %><%= " (#{last.inspection_type.name})" if last && last.inspection_type != row.type %></td>
<td class="<%= td %>"><%= last ? "#{fmt_date(last.date)}#{" @ #{hours(last.hours_at_inspection)}" if last.hours_at_inspection}" : t(".never") %><%= " (#{last.inspection_type.name})" if last && last.inspection_type != row.type %></td>
<td class="<%= td %> text-right tabular-nums"><%= last&.hours_at_inspection ? "#{hours(@report.time_in_service - last.hours_at_inspection)} hrs" : "—" %></td>
<td class="<%= td %>"><%= [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "—" %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No inspections tracked.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".no_inspections_tracked") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Airworthiness directives</h2>
<h2 class="text-base font-semibold"><%= t(".airworthiness_directives") %></h2>
<% if @report.ads.any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">AD</th><th class="<%= th %>">Revision complied with</th><th class="<%= th %>">Method of compliance</th><th class="<%= th %>">Complied</th><th class="<%= th %>">Recurring / next due</th><th class="<%= th %>">Status</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".ad") %></th><th class="<%= th %>"><%= t(".revision_complied_with") %></th><th class="<%= th %>"><%= t(".method_of_compliance") %></th><th class="<%= th %>"><%= t(".complied") %></th><th class="<%= th %>"><%= t(".recurring_next_due") %></th><th class="<%= th %>"><%= t(".status") %></th></tr></thead>
<tbody>
<% @report.ads.each do |row| %>
<% c = row.latest %>
@@ -112,50 +112,50 @@
<td class="<%= td %> text-xs"><%= c&.ad_revision.presence || "—" %></td>
<td class="<%= td %> text-xs"><%= c ? c.method_label : "—" %><% if c&.compliance_notes.present? %><div class="text-slate-500"><%= c.compliance_notes.truncate(90) %></div><% end %></td>
<td class="<%= td %>"><%= c ? "#{c.date_complied}#{" @ #{hours(c.aircraft_hours_at_compliance)}" if c.aircraft_hours_at_compliance}" : "—" %></td>
<td class="<%= td %> text-xs"><%= if c&.closed? then "No further action"
elsif row.ad.recurring? then [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || "Recurring"
else "One-time" end %></td>
<td class="<%= td %> text-xs"><%= if c&.closed? then t(".no_further_action")
elsif row.ad.recurring? then [ row.next_due_date&.to_s, row.next_due_hours && "#{hours(row.next_due_hours)} hrs" ].compact.join(" / ").presence || t(".recurring")
else t(".one_time") end %></td>
<td class="<%= td %>"><%= compliance_badge(row.status) %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">No ADs tracked.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".no_ads_tracked") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Major repairs and alterations</h2>
<h2 class="text-base font-semibold"><%= t(".major_repairs_and_alterations") %></h2>
<% if (majors = @report.major_records.to_a).any? %>
<table class="mt-2 w-full text-sm">
<thead><tr><th class="<%= th %>">Date</th><th class="<%= th %>">Type</th><th class="<%= th %>">Description</th><th class="<%= th %>">STC</th><th class="<%= th %>">Form 337</th></tr></thead>
<thead><tr><th class="<%= th %>"><%= t(".date") %></th><th class="<%= th %>"><%= t(".type") %></th><th class="<%= th %>"><%= t(".description") %></th><th class="<%= th %>"><%= t(".stc") %></th><th class="<%= th %>"><%= t(".form_337") %></th></tr></thead>
<tbody>
<% majors.each do |m| %>
<tr><td class="<%= td %>"><%= fmt_date(m.date_performed) %></td><td class="<%= td %> text-xs"><%= m.type_label %></td>
<td class="<%= td %>"><%= m.title %><%= " · #{m.component}" if m.component %></td>
<td class="<%= td %> text-xs"><%= [ m.stc_number, m.stc_holder ].compact_blank.join(", ").presence || "—" %></td>
<td class="<%= td %> text-xs"><%= m.form_337_document ? "On file" : "—" %></td></tr>
<td class="<%= td %> text-xs"><%= m.form_337_document ? t(".on_file") : "—" %></td></tr>
<% end %>
</tbody>
</table>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".none_recorded") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Weight and balance</h2>
<h2 class="text-base font-semibold"><%= t(".weight_and_balance") %></h2>
<% if (wb = a.current_weight_balance) %>
<p class="mt-1 text-sm">Empty weight <strong><%= number_with_precision(wb.empty_weight, precision: 1, delimiter: ",") %> lb</strong>, CG <strong><%= number_with_precision(wb.empty_arm, precision: 2) %> in</strong><%= ", useful load #{number_with_precision(wb.useful_load, precision: 1, delimiter: ',')} lb" if wb.useful_load %>, as of <%= fmt_date(wb.date) %><%= " (#{wb.reason})" if wb.reason.present? %>.</p>
<% else %><p class="mt-1 text-sm text-slate-500">None recorded.</p><% end %>
<p class="mt-1 text-sm"><%= t(".empty_weight_lb_cg_in_html", delimiter: (number_with_precision(wb.empty_weight, precision: 1, delimiter: ",")), precision: (number_with_precision(wb.empty_arm, precision: 2)), useful_load: (t(".useful_load_lb", delimiter: (number_with_precision(wb.useful_load, precision: 1, delimiter: ','))) if wb.useful_load), date: (fmt_date(wb.date)), present: (" (#{wb.reason})" if wb.reason.present?)) %></p>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".none_recorded") %></p><% end %>
</section>
<section class="<%= section %>">
<h2 class="text-base font-semibold">Open discrepancies</h2>
<h2 class="text-base font-semibold"><%= t(".open_discrepancies") %></h2>
<% if (squawks = @report.open_squawks.to_a).any? %>
<ul class="mt-2 space-y-1 text-sm">
<% squawks.each do |s| %><li><%= squawk_priority_badge(s) %> <%= s.issue_reported %><%= " · #{s.component}" if s.component %> <span class="text-xs text-slate-500">(<%= fmt_date(s.created_at.to_date) %>)</span></li><% end %>
</ul>
<% else %><p class="mt-1 text-sm text-slate-500">None open.</p><% end %>
<% else %><p class="mt-1 text-sm text-slate-500"><%= t(".none_open") %></p><% end %>
</section>
<footer class="mt-8 border-t border-slate-300 pt-2 text-xs text-slate-500">
Prepared <%= l(@report.generated_at, format: :long) %> from the records kept in Simple Aircraft Manager. Times are in hours of <%= clock %> time.
This summary doesn't replace the aircraft's signed maintenance records. <%= Airworthiness::DISCLAIMER %>
<%= t(".prepared_from_the_records_kept_html", time: (l(@report.generated_at, format: :long)), clock: clock) %>
<%= t(".this_summary_doesn_t_replace_html", disclaimer: (Airworthiness.disclaimer)) %>
</footer>
+11 -11
View File
@@ -1,7 +1,7 @@
<%= form_with model: [aircraft, record], class: "card card-body space-y-4 max-w-3xl" do |f| %>
<%= f.errors_summary %>
<div class="grid gap-4 sm:grid-cols-3">
<%= f.field :record_type, as: :select, label: "Type", collection: MajorRecord::RECORD_TYPES.invert %>
<%= f.field :record_type, as: :select, label: t(".type"), collection: MajorRecord::RECORD_TYPES.invert %>
<%= f.field :date_performed, as: :date %>
<%= f.field :aircraft_hours, as: :number, step: 0.1 %>
</div>
@@ -9,16 +9,16 @@
<%= f.field :description, as: :textarea, rows: 4 %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :performed_by %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :form_337_document_id, as: :select, label: "Form 337 document", collection: document_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
<%= f.field :stc_number, label: "STC number" %>
<%= f.field :stc_holder, label: "STC holder" %>
<%= f.field :stc_document_id, as: :select, label: "STC document", collection: document_options(aircraft) %>
<%= f.field :component_id, as: :select, label: t(".component"), collection: component_options(aircraft) %>
<%= f.field :form_337_document_id, as: :select, label: t(".form_337_document"), collection: document_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: t(".logbook_entry"), collection: logbook_options(aircraft) %>
<%= f.field :stc_number, label: t(".stc_number") %>
<%= f.field :stc_holder, label: t(".stc_holder") %>
<%= f.field :stc_document_id, as: :select, label: t(".stc_document"), collection: document_options(aircraft) %>
</div>
<%= f.field :has_ica, as: :checkbox, label: "Includes Instructions for Continued Airworthiness" %>
<%= f.field :ica_notes, as: :textarea, rows: 2, label: "ICA notes" %>
<%= f.field :has_ica, as: :checkbox, label: t(".includes_instructions_for_continued_airworthines") %>
<%= f.field :ica_notes, as: :textarea, rows: 2, label: t(".ica_notes") %>
<%= f.field :notes, as: :textarea, rows: 2 %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_major_records_path(aircraft), class: "btn-secondary" %></div>
<div class="flex gap-2"><%= f.submit t(".save") %><%= link_to t(".cancel"), aircraft_major_records_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_major_record_path(aircraft, record) %></div><% end %>
<% if record.persisted? %><div class="mt-4"><%= delete_button t(".delete_record"), aircraft_major_record_path(aircraft, record) %></div><% end %>
Loaded 100 of 313 files, more files were not shown because too many files have changed in this diff. Show more