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. -
#fd_ui_font ⇒ Object
The host's configured typeface, stamped on so the first paint is already correct.
- #fd_ui_font_options ⇒ Object
-
#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
73 74 75 76 77 78 |
# File 'app/helpers/flightdeck/application_helper.rb', line 73 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
67 68 69 70 71 |
# File 'app/helpers/flightdeck/application_helper.rb', line 67 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.
46 47 48 49 50 51 |
# File 'app/helpers/flightdeck/application_helper.rb', line 46 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
59 60 61 |
# File 'app/helpers/flightdeck/application_helper.rb', line 59 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.
55 56 57 |
# File 'app/helpers/flightdeck/application_helper.rb', line 55 def fd_nav_queue_count nav_count("queues") { Flightdeck::QueueStats.new.rows.size } end |
#fd_nav_recurring_count ⇒ Object
63 64 65 |
# File 'app/helpers/flightdeck/application_helper.rb', line 63 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 |
#fd_ui_font ⇒ Object
The host's configured typeface, stamped on so the first paint is already correct. A user's own choice replaces it once the font controller connects.
35 36 37 |
# File 'app/helpers/flightdeck/application_helper.rb', line 35 def fd_ui_font Flightdeck.config.ui_font end |
#fd_ui_font_options ⇒ Object
39 40 41 |
# File 'app/helpers/flightdeck/application_helper.rb', line 39 def Flightdeck::UiFonts. 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
86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/flightdeck/application_helper.rb', line 86 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
80 81 82 83 84 |
# File 'app/helpers/flightdeck/application_helper.rb', line 80 def nav_count(name, &block) Flightdeck::Cache.fetch("nav", name, expires_in: Flightdeck.config.poll_interval, &block) rescue ActiveRecord::ActiveRecordError "—" end |