Class: SolidWebUi::Ui::RefreshControlsComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- SolidWebUi::Ui::RefreshControlsComponent
- Defined in:
- app/components/solid_web_ui/ui/refresh_controls_component.rb
Overview
Live auto-refresh controls for a dashboard page: a frequency <select>, a countdown to the next refresh and a manual “refresh now” button. The actual polling is driven by the bundled vanilla JS (app/assets/javascripts/ solid_web_ui.js), which reads the data-* attributes emitted here and reloads the turbo-frame named by frame_id. Rendering is pure markup, so the panel works whether or not Turbo is on the page (JS falls back to fetch+replace).
Constant Summary collapse
- STORAGE_KEY =
"swui:refresh-interval"
Instance Method Summary collapse
-
#initialize(frame_id:, default_interval: nil, intervals: nil) ⇒ RefreshControlsComponent
constructor
A new instance of RefreshControlsComponent.
Constructor Details
#initialize(frame_id:, default_interval: nil, intervals: nil) ⇒ RefreshControlsComponent
Returns a new instance of RefreshControlsComponent.
14 15 16 17 18 |
# File 'app/components/solid_web_ui/ui/refresh_controls_component.rb', line 14 def initialize(frame_id:, default_interval: nil, intervals: nil) @frame_id = frame_id @default_interval = (default_interval || SolidWebUi.config.refresh_interval).to_i @intervals = Array(intervals || SolidWebUi.config.refresh_intervals).map(&:to_i) end |