Module: Flightdeck::ApplicationHelper
- Defined in:
- app/helpers/flightdeck/application_helper.rb
Instance Method Summary collapse
- #fd_nav_active?(state) ⇒ Boolean
- #fd_nav_any_dead_processes? ⇒ Boolean
-
#fd_nav_count(state) ⇒ Object
Sidebar counts are capped like every other count, and degrade to "—" rather than taking the whole page down if the queue database is unreachable.
- #fd_nav_process_count ⇒ Object
-
#fd_nav_queue_count ⇒ Object
Infrastructure counts, cached like every other count and degrading to "—" rather than taking the whole page down if the queue database is away.
- #fd_nav_recurring_count ⇒ Object
-
#fd_refresh_frame(id, url:, interval: fd_poll_ms, target: "_top", **options, &block) ⇒ Object
The polling
every panel lives in: the refresh Stimulus controller, its interval, and the URL the frame re-requests. -
#flightdeck_asset_path(logical_name) ⇒ Object
Path to a built asset, resolved through the committed manifest.
- #flightdeck_brand_svg(size: 26) ⇒ Object
- #nav_count(name, &block) ⇒ Object
Instance Method Details
#fd_nav_active?(state) ⇒ Boolean
62 63 64 65 66 67 |
# File 'app/helpers/flightdeck/application_helper.rb', line 62 def fd_nav_active?(state) return false unless controller_name == "jobs" && action_name == "index" current = params[:state].presence&.to_sym || :all current == state end |
#fd_nav_any_dead_processes? ⇒ Boolean
56 57 58 59 60 |
# File 'app/helpers/flightdeck/application_helper.rb', line 56 def fd_nav_any_dead_processes? nav_count("dead_processes") do SolidQueue::Process.where(last_heartbeat_at: ..SolidQueue.process_alive_threshold.ago).exists? end == true end |
#fd_nav_count(state) ⇒ Object
Sidebar counts are capped like every other count, and degrade to "—" rather than taking the whole page down if the queue database is unreachable.
35 36 37 38 39 40 |
# File 'app/helpers/flightdeck/application_helper.rb', line 35 def fd_nav_count(state) query = Flightdeck::JobsQuery.new(state: state) fd_count(query.count, capped: query.count_capped?) rescue ActiveRecord::ActiveRecordError "—" end |
#fd_nav_process_count ⇒ Object
48 49 50 |
# File 'app/helpers/flightdeck/application_helper.rb', line 48 def fd_nav_process_count nav_count("processes") { SolidQueue::Process.count } end |
#fd_nav_queue_count ⇒ Object
Infrastructure counts, cached like every other count and degrading to "—" rather than taking the whole page down if the queue database is away.
44 45 46 |
# File 'app/helpers/flightdeck/application_helper.rb', line 44 def fd_nav_queue_count nav_count("queues") { Flightdeck::QueueStats.new.rows.size } end |
#fd_nav_recurring_count ⇒ Object
52 53 54 |
# File 'app/helpers/flightdeck/application_helper.rb', line 52 def fd_nav_recurring_count nav_count("recurring") { SolidQueue::RecurringTask.count } end |
#fd_refresh_frame(id, url:, interval: fd_poll_ms, target: "_top", **options, &block) ⇒ Object
The polling
target: defaults to "_top" because most frames are lists whose links
leave the frame; the jobs list opts out (target: nil) so its pager can
navigate in place.
13 14 15 16 17 18 19 20 |
# File 'app/helpers/flightdeck/application_helper.rb', line 13 def fd_refresh_frame(id, url:, interval: fd_poll_ms, target: "_top", **, &block) tag.turbo_frame( id: id, target: target, data: { controller: "refresh", refresh_interval_value: interval, refresh_url_value: url }, **, &block ) end |
#flightdeck_asset_path(logical_name) ⇒ Object
Path to a built asset, resolved through the committed manifest. Returns nil when assets have not been built yet (fresh checkout / dev), so the layout can simply omit the tag instead of blowing up.
25 26 27 28 29 30 |
# File 'app/helpers/flightdeck/application_helper.rb', line 25 def flightdeck_asset_path(logical_name) digested = Flightdeck::Assets.digested_name(logical_name) return nil unless digested asset_file_path(name: digested) end |
#flightdeck_brand_svg(size: 26) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/flightdeck/application_helper.rb', line 75 def flightdeck_brand_svg(size: 26) tag.svg(width: size, height: size, viewBox: "0 0 26 26", fill: "none", "aria-hidden": true) do safe_join([ tag.circle(cx: 13, cy: 13, r: 11.5, stroke: "var(--accent-ink)", "stroke-width": 1.6), tag.path(d: "M3 15 C 8 10.5, 18 10.5, 23 15", stroke: "var(--accent-ink)", "stroke-width": 1.6, fill: "none"), tag.path(d: "M9.5 13.2 h7 M13 11.4 v1.8", stroke: "var(--ink)", "stroke-width": 1.6, "stroke-linecap": "round") ]) end end |
#nav_count(name, &block) ⇒ Object
69 70 71 72 73 |
# File 'app/helpers/flightdeck/application_helper.rb', line 69 def nav_count(name, &block) Flightdeck::Cache.fetch("nav", name, expires_in: Flightdeck.config.poll_interval, &block) rescue ActiveRecord::ActiveRecordError "—" end |