mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Status report readable in dark mode and Back no longer breaks the theme; drop the Overview's Coming due card
The report layout now always loads as a full page (turbo-visit-control reload) and without Turbo (an inline Print handler), so the app's dark theme isn't carried onto the white report and the report's styles aren't left behind on Back. Coming due repeated the Airworthiness card, so it's gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
31ac991bab
commit
ac10ae5f32
8 files changed
+21
-46
No files matched your search
+1
-1
@@ -20,7 +20,7 @@ The first numbered release. Highlights of what Simple Aircraft Manager does as o
|
||||
- Airworthiness status from ADs, inspections, squawks, components and documents, with Part 91 rules (annual as 100-hour, overruns, IFR and transponder limits).
|
||||
- ADs: FAA DRS import with an AD baseline per model, and a weekly search for newly published ADs covering the aircraft, engine, propeller and every installed component.
|
||||
- Logbook: templates, engine and propeller times, sub-components (a new entry can also record them serviced or replaced), printable entries for the paper logbook, and AI transcription of scanned pages.
|
||||
- The Overview shows what's coming due in the next 30 days or 10 hours, and the last day's flying.
|
||||
- The Overview shows the last day's flying: route, meters, fuel and oil left.
|
||||
- Intervals are entered as a number of days, months or years: no converting months to days.
|
||||
- Calendar feed of everything coming due, with dates projected from recent flying for hour-based items.
|
||||
- Weight and balance with a loading calculator (CG envelope in inches or lb-in/1000).
|
||||
|
||||
@@ -14,7 +14,6 @@ class AircraftController < ApplicationController
|
||||
@notes = @aircraft.notes.recent_first.includes(:user).limit(5)
|
||||
@oil = ConsumptionStats.new(@aircraft, "oil")
|
||||
@fuel = ConsumptionStats.new(@aircraft, "fuel")
|
||||
@coming_due = DueList.new(@aircraft).soon
|
||||
last = @aircraft.flight_logs.recent_first.first
|
||||
@last_day = last && @aircraft.flight_logs.where(date: last.date).order(:created_at).to_a
|
||||
end
|
||||
|
||||
@@ -9,10 +9,6 @@ class DueList
|
||||
end
|
||||
|
||||
# Hours flown per day over the past year (nil when it hasn't flown).
|
||||
# What counts as coming up soon (Overview).
|
||||
SOON_DAYS = 30
|
||||
SOON_HOURS = 10
|
||||
|
||||
def self.daily_rate(aircraft, today: Date.current)
|
||||
hours = aircraft.flight_logs.where(date: (today - 365)..today).sum(:tach_time).to_f
|
||||
hours.positive? ? hours / 365.0 : nil
|
||||
@@ -30,13 +26,6 @@ class DueList
|
||||
(inspections + ads + components + documents).compact.sort_by { [ _1.date, _1.title ] }
|
||||
end
|
||||
|
||||
# Due in the next SOON_DAYS days or SOON_HOURS hours (or overdue).
|
||||
def soon
|
||||
horizon = @today + SOON_DAYS
|
||||
hours_limit = @now_hours + SOON_HOURS
|
||||
items.select { |i| i.date <= horizon || (i.due_hours && i.due_hours <= hours_limit) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# The date it's due: the calendar date, or when the hours run out at the
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<%# What's due in the next few weeks or hours (Overview). %>
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Coming due</h2>
|
||||
<span class="text-xs text-slate-500">next <%= DueList::SOON_DAYS %> days or <%= DueList::SOON_HOURS %> hrs</span>
|
||||
</div>
|
||||
<% if due.any? %>
|
||||
<ul class="divide-y divide-slate-100">
|
||||
<% due.each do |item| %>
|
||||
<li class="flex items-baseline justify-between gap-3 px-4 py-2 text-sm">
|
||||
<%= link_to item.title, item.path, class: [ "hover:underline", ("font-medium text-red-700" if item.overdue?) ] %>
|
||||
<span class="shrink-0 text-right text-xs text-slate-500 tabular-nums">
|
||||
<% if item.overdue? %>overdue<% else %><%= "~" if item.projected %><%= fmt_date(item.date) %><% end %><%= " · at #{hours(item.due_hours)} hrs" if item.due_hours %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if due.any?(&:projected) %><p class="hint px-4 pb-3">"~" dates are estimated from the last year's flying.</p><% end %>
|
||||
<% else %>
|
||||
<%= empty_state "Nothing coming due soon." %>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -46,8 +46,6 @@
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<%= render "aircraft/coming_due", aircraft: @aircraft, due: @coming_due %>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -7,9 +7,15 @@
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<%# Always a full page load: a Turbo visit would keep the app's dark theme
|
||||
on this white page, and leave this page's styles behind on Back. %>
|
||||
<meta name="turbo-visit-control" content="reload">
|
||||
<% unless @standalone %><link rel="icon" href="/favicon.svg" type="image/svg+xml"><% end %>
|
||||
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
|
||||
<%= javascript_importmap_tags %>
|
||||
<%# No Turbo here (Back is then an ordinary page load); just the Print button. %>
|
||||
<script nonce="<%= content_security_policy_nonce %>">
|
||||
document.addEventListener("click", (e) => { if (e.target.closest?.("[data-print]")) window.print() })
|
||||
</script>
|
||||
<style>
|
||||
html, body { background: #fff; }
|
||||
@page { margin: 0.5in; }
|
||||
|
||||
@@ -10,7 +10,6 @@ The **Overview** tab shows:
|
||||
|
||||
- **Airworthiness**: the overall status and each reason for it.
|
||||
- **Active squawks**, **Consumption** (oil and fuel rates), **Notes** and **Recent activity**.
|
||||
- **Coming due**: anything due in the next 30 days or 10 hours. Dates marked "~" are estimated from the last year's flying.
|
||||
- **Last flight**: the most recent day's legs as one route, the meters at the end, and the fuel and oil left.
|
||||
- **Update Hours**: enter the current meter readings (see [Flights and hours](flights.md)).
|
||||
- **Details** and the **Status report** link.
|
||||
|
||||
+13
-7
@@ -1,8 +1,8 @@
|
||||
require "test_helper"
|
||||
|
||||
# The Overview's Last flight and Coming due cards, and intervals entered as
|
||||
# days, months or years.
|
||||
class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
# The Overview's Last flight card, intervals entered as days, months or years,
|
||||
# and the status report opening as its own page.
|
||||
class OverviewAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@owner = create_user("owner@example.com")
|
||||
@pilot = create_user("pilot@example.com")
|
||||
@@ -17,7 +17,7 @@ class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
replacement_hours: 500, hours_since_overhaul: 100, overhaul_date: Date.current - 30)
|
||||
end
|
||||
|
||||
test "the overview shows the last day's flying and what's coming due" do
|
||||
test "the overview shows the last day's flying" do
|
||||
sign_in @pilot
|
||||
get aircraft_path(@a)
|
||||
assert_response :success
|
||||
@@ -26,8 +26,6 @@ class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
assert_includes body, "2 legs"
|
||||
assert_includes body, "18 gal"
|
||||
assert_includes body, "5 qt"
|
||||
assert_includes body, "Replace Oil" # 4 hrs left
|
||||
assert_not_includes body, "Replace Magneto" # 400 hrs left
|
||||
end
|
||||
|
||||
test "the overview copes with nothing logged" do
|
||||
@@ -36,7 +34,6 @@ class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
get aircraft_path(bare)
|
||||
assert_response :success
|
||||
assert_includes response.body, "No flights logged yet."
|
||||
assert_includes response.body, "Nothing coming due soon."
|
||||
end
|
||||
|
||||
test "hours already run out count as overdue; an inspection covering a component replaces its own interval" do
|
||||
@@ -101,4 +98,13 @@ class OverviewDueAndIntervalsTest < ActionDispatch::IntegrationTest
|
||||
assert_equal [ 0, 24 ], [ ad.recurring_days, ad.recurring_months ]
|
||||
assert_equal "2 years", ad.recurring_interval_label
|
||||
end
|
||||
|
||||
test "the status report always opens as a full page, without Turbo" do
|
||||
sign_in @pilot
|
||||
get aircraft_report_path(@a)
|
||||
assert_response :success
|
||||
assert_select "meta[name='turbo-visit-control'][content='reload']"
|
||||
assert_select "script[type='importmap']", false
|
||||
assert_select "button[data-print]"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user