mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15: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,50 @@
|
||||
<%= form_with model: [aircraft, component], class: "card card-body space-y-5 max-w-4xl" do |f| %>
|
||||
<%= 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" %>
|
||||
</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 :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] } %>
|
||||
</div>
|
||||
|
||||
<fieldset class="grid gap-4 sm:grid-cols-4">
|
||||
<legend class="mb-2 text-sm font-semibold text-slate-900">Time</legend>
|
||||
<%= f.field :date_in_service, as: :date, required: true %>
|
||||
<%= f.field :hours_in_service, as: :number, step: 0.1 %>
|
||||
<%= 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" %>
|
||||
</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.field :replacement_days, as: :number, label: "Replace every (days)" %>
|
||||
<%= f.field :replacement_critical, as: :checkbox, label: "Replacement critical", hint: "Overdue replacement grounds the aircraft (oil, filters, ELT battery…)." %>
|
||||
<%= f.field :tbo_hours, as: :number, label: "TBO (hrs)" %>
|
||||
<%= f.field :tbo_days, as: :number, label: "TBO (days)" %>
|
||||
<div class="space-y-2">
|
||||
<%= f.field :tbo_critical, as: :checkbox, label: "TBO critical" %>
|
||||
<%= f.field :on_condition, as: :checkbox, label: "On condition (Part 91)" %>
|
||||
</div>
|
||||
<%= f.field :inspection_hours, as: :number, label: "Inspect every (hrs)" %>
|
||||
<%= f.field :inspection_days, as: :number, label: "Inspect every (days)" %>
|
||||
<%= f.field :inspection_critical, as: :checkbox, label: "Inspection critical" %>
|
||||
</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" %>
|
||||
</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>
|
||||
<% end %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<% content_for :title, "Edit Component" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<%= render "form", aircraft: @aircraft, component: @component %>
|
||||
@@ -0,0 +1,52 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Components" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<section class="card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Components</h2>
|
||||
<div class="flex items-center gap-3">
|
||||
<%= link_to (@show_disposed ? "Hide disposed" : "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 %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @rows.empty? %>
|
||||
<%= empty_state "No components yet. Add the engine, propeller, oil filter, ELT battery, etc." %>
|
||||
<% 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>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% @rows.each do |c, depth| %>
|
||||
<tr>
|
||||
<td style="padding-left: <%= 0.75 + depth * 1.25 %>rem">
|
||||
<%= "↳ " if depth > 0 %><%= link_to c.component_type.name, aircraft_component_path(@aircraft, c), class: "link font-medium" %>
|
||||
<% if c.install_location.present? %><div class="text-xs text-slate-500"><%= c.install_location %></div><% end %>
|
||||
</td>
|
||||
<td><%= c.manufacturer %> <%= c.model %><% if c.serial_number.present? %><div class="text-xs text-slate-500">S/N <%= c.serial_number %></div><% end %></td>
|
||||
<td><%= tag.span c.status_label, class: { "IN-USE" => "badge-green", "SPARE" => "badge-gray", "DISPOSED" => "badge-gray" }[c.status] %></td>
|
||||
<td class="text-right tabular-nums"><%= hours(c.hours_in_service) %></td>
|
||||
<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_days) %>
|
||||
Replace: <%= [c.replacement_hours && "#{c.replacement_hours} h", c.replacement_days && "#{c.replacement_days} d"].compact.join(" / ") %><br>
|
||||
<% end %>
|
||||
<% if c.tbo_critical? && c.tbo_hours %>TBO: <%= c.tbo_hours %> h<%= " (on condition)" if c.on_condition? %><% 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" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -0,0 +1,3 @@
|
||||
<% content_for :title, "Add Component" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<%= render "form", aircraft: @aircraft, component: @component %>
|
||||
@@ -0,0 +1,61 @@
|
||||
<% content_for :title, @component.to_s %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="grid gap-5 lg:grid-cols-3">
|
||||
<section class="card lg:col-span-2">
|
||||
<div class="card-header">
|
||||
<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" %>
|
||||
</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_days && "#{@component.replacement_days} d"].compact.join(" / ").presence || "—" %>
|
||||
<% if (d = @component.next_replacement_date) %><div class="text-xs text-slate-500">Next by <%= fmt_date(d) %></div><% end %>
|
||||
</dd>
|
||||
<dt class="text-slate-500">Flags</dt>
|
||||
<dd class="col-span-3 flex flex-wrap gap-1">
|
||||
<% { tbo_critical: "TBO critical", replacement_critical: "Replacement critical", inspection_critical: "Inspection critical", on_condition: "On condition" }.each do |flag, label| %>
|
||||
<% if @component.public_send("#{flag}?") %><span class="badge-blue"><%= label %></span><% end %>
|
||||
<% end %>
|
||||
</dd>
|
||||
</dl>
|
||||
<% if @component.notes.present? %><div class="border-t border-slate-100 px-4 py-3 text-sm"><%= simple_format @component.notes %></div><% end %>
|
||||
</section>
|
||||
|
||||
<% if owner? %>
|
||||
<section class="card" id="service">
|
||||
<div class="card-header"><h2 class="card-title">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>
|
||||
<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>
|
||||
</label>
|
||||
<%= f.submit "Record Service", class: "btn-primary" %>
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @squawks.any? %>
|
||||
<section class="card mt-5">
|
||||
<div class="card-header"><h2 class="card-title">Squawks on this component</h2></div>
|
||||
<%= render "squawks/table", squawks: @squawks, aircraft: @aircraft %>
|
||||
</section>
|
||||
<% end %>
|
||||
Reference in new issue
Block a user