mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Interactive engine data charts: click to zoom, crosshair readout, range stats
Clicking a chart opens a viewer with higher-resolution data (new JSON endpoint, fetched once): drag to zoom, tabs keep the zoom across metrics, legend toggles, and min/avg/max for the visible range in monitor time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b6329843d
commit
2d068e1a63
8 files changed
+498
-16
No files matched your search
@@ -1,7 +1,7 @@
|
||||
class FlightLogsController < ApplicationController
|
||||
include AircraftScoped
|
||||
before_action :require_owner!, only: :destroy
|
||||
before_action :set_flight_log, only: %i[show attach_engine_data remove_engine_data]
|
||||
before_action :set_flight_log, only: %i[show engine_data_series attach_engine_data remove_engine_data]
|
||||
before_action :require_engine_data_access!, only: %i[attach_engine_data remove_engine_data]
|
||||
helper_method :manage_engine_data?
|
||||
|
||||
@@ -25,6 +25,15 @@ class FlightLogsController < ApplicationController
|
||||
@air_trail_sync = @flight_log.air_trail_syncs.first
|
||||
end
|
||||
|
||||
# JSON for the interactive engine chart viewer (loaded when a chart is clicked).
|
||||
def engine_data_series
|
||||
recording = EngineDataParser.parse_attachment(@flight_log.engine_data) or return head(:not_found)
|
||||
return unless stale?(etag: [ @flight_log.engine_data.blob.key, EngineDataParser::CACHE_VERSION ], public: false)
|
||||
render json: recording.detail.merge(groups: helpers.engine_chart_groups(recording))
|
||||
rescue EngineDataParser::Error, ActiveStorage::FileNotFoundError => e
|
||||
render json: { error: e.message }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def new
|
||||
# Aircraft almost always depart from where they last landed.
|
||||
last = @aircraft.flight_logs.where.not(destination_location: [ nil, "" ]).recent_first.first
|
||||
|
||||
Reference in new issue
Block a user