Add historical flight track functionality

- Store track history with position, altitude, speed, and timestamp
- Automatic track point collection every 30 seconds when position changes
- API endpoint /api/aircraft/{hex}/history for individual aircraft tracks
- Frontend "Show History" button to display historical flight paths
- Click aircraft markers to show their historical track (dashed red line)
- Track cleanup: keep last 200 points per aircraft, 24-hour retention
- Add aircraft type badges in table view with color coding
- Start/end markers for historical tracks with timestamps

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-23 22:52:16 +02:00
commit 55710614da
6 changed files with 215 additions and 16 deletions

View file

@ -61,6 +61,7 @@ func New(cfg *config.Config, staticFiles embed.FS, ctx context.Context) http.Han
apiRouter := router.PathPrefix("/api").Subrouter()
apiRouter.HandleFunc("/aircraft", s.getAircraft).Methods("GET")
apiRouter.HandleFunc("/aircraft/{hex}/history", s.getAircraftHistory).Methods("GET")
apiRouter.HandleFunc("/stats", s.getStats).Methods("GET")
apiRouter.HandleFunc("/config", s.getConfig).Methods("GET")
@ -122,6 +123,27 @@ func (s *Server) getStats(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(stats)
}
func (s *Server) getAircraftHistory(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
hex := vars["hex"]
data := s.dump1090.GetAircraftData()
aircraft, exists := data.Aircraft[hex]
if !exists {
http.Error(w, "Aircraft not found", http.StatusNotFound)
return
}
response := map[string]interface{}{
"hex": aircraft.Hex,
"flight": aircraft.Flight,
"track_history": aircraft.TrackHistory,
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
}
func (s *Server) getConfig(w http.ResponseWriter, r *http.Request) {
configData := map[string]interface{}{
"origin": map[string]interface{}{