Overview
FlightsShellComponent is the primary orchestration container for the flight tracking application. It manages the interaction between the map view, flight list, and detail panels, while handling responsive behavior for desktop and mobile viewports.
Location: src/app/features/flights/flights-shell/flights-shell.component.ts
Responsibilities
The shell component coordinates multiple aspects of the flight tracking UI:- Component Orchestration: Manages child components (FlightsMapComponent, FlightsListComponent, FlightsFilterMenuComponent)
- Viewport Detection: Switches between desktop overlay and mobile bottom sheet based on screen size
- Detail View Management: Opens/closes flight detail UI when flights are selected
- Data Polling: Initializes smart polling for flight data updates
- Photo Loading: Fetches aircraft photos from the API when flights are selected
- Selection Sync: Auto-clears selection when filtered flights change
Architecture
Component Tree
Dependency Injection
Viewport Detection
The component uses Angular effects to reactively respond to viewport changes:Desktop Mode
Whenviewport.isDesktop() returns true:
- Creates a CDK Overlay positioned at bottom-left
- Renders
FlightDetailPanelComponentin the overlay - Overlay configuration:
- Position:
left('30px').bottom('5%') - Size:
width: '310px', height: '80%' - No backdrop (allows map interaction)
- Position:
Mobile Mode
When on mobile viewport:- Opens Material bottom sheet
- Renders
FlightDetailBottomSheetComponent - No backdrop (allows map interaction)
- Tracks dismiss reason to determine if selection should be cleared
Flight Photo Loading
When a flight is selected, the component fetches aircraft photos:Lifecycle
Initialization
Selection Filtering Effect
Auto-clears selection when the selected flight is no longer visible due to filters:UI State Management
The component maintains references to active UI elements:Usage Example
The shell component is typically used as the main route component:Key Features
Responsive Design
- Automatically switches between desktop panel and mobile bottom sheet
- No configuration required—driven by viewport service
Smart UI Management
- Cleans up previous detail views before opening new ones
- Prevents memory leaks through proper subscription cleanup
- Handles rapid selection changes gracefully
Error Handling
- Gracefully handles photo loading failures
- Continues to display flight details even when photos are unavailable
- Logs warnings for invalid photo data
Related Components
- FlightsMapComponent - Map visualization
- FlightsListComponent - Flight table
- FlightDetailPanelComponent - Desktop detail view
Services Used
- FlightsStoreService - State management for flights and selection
- FlightsApiService - API calls for flight data and photos
- ViewportService - Viewport size detection (desktop/mobile)
- Overlay (CDK) - Desktop overlay management
- MatBottomSheet - Mobile bottom sheet management
