mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Initial commit: Rails port of Simple Aircraft Manager
Rails 8.1 + SQLite rewrite of marbindrakon/simple-aircraft-manager, designed to self-host as a single container (Solid Queue/Cache/Cable, Active Storage on disk, Hotwire + importmap, Tailwind). - Airworthiness engine ported from health/services.py (ADs, grounding squawks, inspection recurrency, component replacement) - Hours updates and flight logs cascading to in-service components, optional airworthiness enforcement - Components, squawks, ADs, inspections, logbook, documents, major records, oil/fuel consumption stats and charts, activity log - Admin/owner/pilot RBAC and public share links (status/maintenance) - Docker Compose and Kamal deployment, env-driven production config - Service and integration tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
38df19c331
264 files changed
+8365
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<%= form_with model: aircraft, 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 :tail_number, required: true, autofocus: true %>
|
||||
<%= f.field :make %>
|
||||
<%= f.field :model %>
|
||||
<%= f.field :serial_number %>
|
||||
<%= f.field :purchased, as: :date %>
|
||||
<%= f.field :status, as: :select, collection: Aircraft::STATUSES.invert %>
|
||||
</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" %>
|
||||
<% end %>
|
||||
<%= f.field :tach_time_offset, as: :number, step: 0.1, hint: "Subtracted from tach for compliance math (e.g. after a tach replacement)." %>
|
||||
<%= f.field :hobbs_time_offset, as: :number, step: 0.1 %>
|
||||
</div>
|
||||
<% unless aircraft.new_record? %>
|
||||
<p class="hint">To change hours use “Update Hours” on the overview, so component times stay in sync.</p>
|
||||
<% end %>
|
||||
<%= f.field :picture, as: :file, accept: "image/*" %>
|
||||
<%= f.field :airworthiness_enforcement, as: :checkbox, label: "Enforce airworthiness",
|
||||
hint: "Block flight logs and hours updates while the aircraft is red." %>
|
||||
<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" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,9 @@
|
||||
<% content_for :title, "Edit #{@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" %>
|
||||
</div>
|
||||
@@ -0,0 +1,48 @@
|
||||
<% content_for :title, "Fleet" %>
|
||||
<div class="mb-5 flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold tracking-tight">Fleet</h1>
|
||||
<%= link_to "+ Add Aircraft", new_aircraft_path, class: "btn-primary" %>
|
||||
</div>
|
||||
|
||||
<% 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>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<% @aircraft_list.each do |aircraft| %>
|
||||
<% aw = aircraft.airworthiness %>
|
||||
<%= 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" %>
|
||||
<% else %>
|
||||
<span class="text-5xl text-slate-400">✈</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div>
|
||||
<div class="text-lg font-bold"><%= aircraft.tail_number %></div>
|
||||
<div class="text-sm text-slate-500"><%= [aircraft.make, aircraft.model].compact_blank.join(" ").presence || "—" %></div>
|
||||
</div>
|
||||
<%= 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>
|
||||
<%= aircraft_status_badge(aircraft) %>
|
||||
</div>
|
||||
<% if aw.issues.any? %>
|
||||
<ul class="mt-3 space-y-1 text-xs">
|
||||
<% aw.issues.first(3).each do |issue| %>
|
||||
<li class="<%= issue.severity == 'RED' ? 'text-red-700' : 'text-amber-700' %>">• <%= issue.title %></li>
|
||||
<% end %>
|
||||
<% if aw.issues.size > 3 %><li class="text-slate-500">+ <%= aw.issues.size - 3 %> more</li><% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<% content_for :title, "Add Aircraft" %>
|
||||
<h1 class="mb-4 text-2xl font-bold">Add Aircraft</h1>
|
||||
<%= render "form", aircraft: @aircraft %>
|
||||
@@ -0,0 +1,109 @@
|
||||
<% content_for :title, @aircraft.tail_number %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<div class="space-y-5 lg:col-span-2">
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Airworthiness</h2>
|
||||
<%= airworthiness_badge(@airworthiness, large: true) %>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<% if @airworthiness.issues.empty? %>
|
||||
<p class="text-sm text-emerald-700">No open issues. All tracked ADs, inspections, components and squawks are current.</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.severity == 'RED' ? 'badge-red' : 'badge-orange' %> mt-0.5"><%= issue.category %></span>
|
||||
<div>
|
||||
<div class="text-sm font-medium"><%= issue.title %></div>
|
||||
<div class="text-xs text-slate-500"><%= issue.description %></div>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if @aircraft.airworthiness_enforcement? %>
|
||||
<p class="hint mt-3">Airworthiness enforcement is on: flights and hours updates are blocked while the status is red.</p>
|
||||
<% end %>
|
||||
</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" %>
|
||||
</div>
|
||||
<% if @active_squawks.any? %>
|
||||
<%= render "squawks/table", squawks: @active_squawks, aircraft: @aircraft %>
|
||||
<% else %>
|
||||
<%= empty_state "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-body grid grid-cols-2 gap-4 text-center">
|
||||
<div><div class="text-2xl font-semibold"><%= @oil.average || "—" %></div><div class="text-xs text-slate-500">Avg oil, hrs/qt</div></div>
|
||||
<div><div class="text-2xl font-semibold"><%= @fuel.average || "—" %></div><div class="text-xs text-slate-500">Avg fuel burn, gal/hr</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>
|
||||
<%= 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" %>
|
||||
<%= 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" %>
|
||||
<%= 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" %>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<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 %>
|
||||
</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>
|
||||
</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>
|
||||
<% end %>
|
||||
</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>
|
||||
<% if @notes.any? %>
|
||||
<ul class="divide-y divide-slate-100">
|
||||
<% @notes.each do |note| %>
|
||||
<li class="px-4 py-2 text-sm">
|
||||
<div><%= note.text.truncate(200) %></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>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<%= empty_state "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>
|
||||
<%= render "events/list", events: @recent_events %>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user