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,33 @@
|
||||
module AircraftHelper
|
||||
# Tabs on the aircraft pages: [label, path, controller names that highlight it, owner_only]
|
||||
def aircraft_tabs(aircraft)
|
||||
[
|
||||
[ "Overview", aircraft_path(aircraft), %w[aircraft] ],
|
||||
[ "Components", aircraft_components_path(aircraft), %w[components] ],
|
||||
[ "Squawks", aircraft_squawks_path(aircraft), %w[squawks] ],
|
||||
[ "Flights", aircraft_flight_logs_path(aircraft), %w[flight_logs] ],
|
||||
[ "Oil & Fuel", aircraft_consumable_records_path(aircraft), %w[consumable_records] ],
|
||||
[ "Logbook", aircraft_logbook_entries_path(aircraft), %w[logbook_entries] ],
|
||||
[ "Inspections", aircraft_inspections_path(aircraft), %w[inspections inspection_types inspection_records] ],
|
||||
[ "ADs", aircraft_airworthiness_directives_path(aircraft), %w[airworthiness_directives ad_compliances] ],
|
||||
[ "Documents", aircraft_documents_path(aircraft), %w[documents document_collections] ],
|
||||
[ "Major Records", aircraft_major_records_path(aircraft), %w[major_records] ],
|
||||
[ "Notes", aircraft_notes_path(aircraft), %w[notes] ],
|
||||
[ "Activity", aircraft_events_path(aircraft), %w[events] ],
|
||||
([ "Access & Sharing", aircraft_aircraft_roles_path(aircraft), %w[aircraft_roles share_tokens] ] if owner?)
|
||||
].compact
|
||||
end
|
||||
|
||||
def component_options(aircraft, include_blank: true)
|
||||
opts = aircraft.components.where.not(status: "DISPOSED").includes(:component_type).map { [ _1.to_s, _1.id ] }
|
||||
include_blank ? [ [ "— None —", nil ] ] + opts : opts
|
||||
end
|
||||
|
||||
def document_options(aircraft)
|
||||
[ [ "— None —", nil ] ] + aircraft.documents.ordered.map { [ _1.name, _1.id ] }
|
||||
end
|
||||
|
||||
def logbook_options(aircraft)
|
||||
[ [ "— None —", nil ] ] + aircraft.logbook_entries.recent_first.limit(300).map { [ "#{_1.date} – #{_1.text.truncate(60)}", _1.id ] }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,64 @@
|
||||
module ApplicationHelper
|
||||
def hours(value)
|
||||
return "—" if value.nil?
|
||||
number_with_precision(value, precision: 1, delimiter: ",")
|
||||
end
|
||||
|
||||
def fmt_date(value)
|
||||
value ? l(value.to_date, format: :long) : "—"
|
||||
end
|
||||
|
||||
def airworthiness_badge(status, large: false)
|
||||
color = { "RED" => "red", "ORANGE" => "orange", "GREEN" => "green" }[status.status]
|
||||
tag.span(status.label, class: [ "badge-#{color}", ("text-sm px-3 py-1" if large) ])
|
||||
end
|
||||
|
||||
def airworthiness_dot(status)
|
||||
color = { "RED" => "bg-red-500", "ORANGE" => "bg-amber-400", "GREEN" => "bg-emerald-500" }[status.status]
|
||||
tag.span(class: "inline-block h-3 w-3 rounded-full #{color}", title: status.label)
|
||||
end
|
||||
|
||||
COMPLIANCE_BADGES = {
|
||||
"compliant" => [ "green", "Compliant" ], "due_soon" => [ "orange", "Due Soon" ],
|
||||
"overdue" => [ "red", "Overdue" ], "no_compliance" => [ "red", "No Record" ],
|
||||
"never_completed" => [ "red", "Never Completed" ], "conditional" => [ "gray", "Conditional" ]
|
||||
}.freeze
|
||||
|
||||
def compliance_badge(status)
|
||||
color, text = COMPLIANCE_BADGES.fetch(status, [ "gray", status.to_s.humanize ])
|
||||
tag.span(text, class: "badge-#{color}")
|
||||
end
|
||||
|
||||
def life_badge(status)
|
||||
return "" unless status
|
||||
color, text = { overdue: [ "red", "Overdue" ], due_soon: [ "orange", "Due Soon" ], ok: [ "green", "OK" ] }[status]
|
||||
tag.span(text, class: "badge-#{color}")
|
||||
end
|
||||
|
||||
def squawk_priority_badge(squawk)
|
||||
tag.span(squawk.priority_label, class: "badge-#{squawk.priority_color}")
|
||||
end
|
||||
|
||||
def aircraft_status_badge(aircraft)
|
||||
color = { "AVAILABLE" => "green", "MX" => "orange", "GROUND" => "red", "UNAVAILABLE" => "gray" }[aircraft.status]
|
||||
tag.span(aircraft.status_label, class: "badge-#{color}")
|
||||
end
|
||||
|
||||
def visibility_badge(visibility)
|
||||
color = { "private" => "gray", "status" => "green", "maintenance" => "blue" }[visibility]
|
||||
tag.span(DocumentCollection::VISIBILITIES[visibility], class: "badge-#{color}")
|
||||
end
|
||||
|
||||
def delete_button(label, path, confirm: "Are you sure?", **opts)
|
||||
button_to label, path, method: :delete, form: { data: { turbo_confirm: confirm }, class: "inline" },
|
||||
class: opts[:class] || "btn-danger btn-sm"
|
||||
end
|
||||
|
||||
def empty_state(text)
|
||||
tag.p(text, class: "py-6 text-center text-sm text-slate-500")
|
||||
end
|
||||
|
||||
def nav_tab(label, path, active)
|
||||
link_to label, path, class: [ "tab", ("tab-active" if active) ]
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user