mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- Service worker keeps the Log Flight form when opened via Turbo, serves the offline page's script and icon, and treats 502/503/504 as offline; the offline page only links forms actually kept - Serviced sub-components restart from the airframe time flown since the entry - New logbook entries can complete inspections (recorded and linked to the entry) - Components: replacement limit can count from installation (life limit) - Component-level "Inspect every" / "Inspection critical" removed; a migration converts any unlinked settings into inspection types with a first record; component page lists its inspections Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
982 B
JavaScript
21 lines
982 B
JavaScript
// The offline page: reload when the connection is back, and link to the Log
|
|
// Flight forms this device has kept (so a flight can be logged offline).
|
|
window.addEventListener("online", function () { location.reload() })
|
|
try {
|
|
var forms = JSON.parse(localStorage.getItem("sam-offline-forms") || "{}")
|
|
var box = document.getElementById("forms")
|
|
Object.keys(forms).forEach(function (path) {
|
|
if (!/^\/aircraft\/\d+\/flight_logs\/new$/.test(path)) return
|
|
// Only offer forms the service worker actually kept; others just loop back here.
|
|
var kept = window.caches ? caches.open("sam-flight-forms").then(function (c) { return c.match(location.origin + path) }) : Promise.resolve(null)
|
|
kept.then(function (hit) {
|
|
if (!hit) return
|
|
var a = document.createElement("a")
|
|
a.href = path
|
|
a.textContent = "Log a flight: " + forms[path]
|
|
box.appendChild(a)
|
|
box.hidden = false
|
|
}).catch(function () {})
|
|
})
|
|
} catch (e) { /* storage off */ }
|