Module: RoundhouseUi::NavHelper

Defined in:
app/helpers/roundhouse_ui/nav_helper.rb

Instance Method Summary collapse

Instance Method Details

A sidebar nav item with active state and an optional live-updating badge (filled client-side from /stats via the poll in the layout).



5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/roundhouse_ui/nav_helper.rb', line 5

def nav_link(label, path, icon:, badge: nil, badge_class: nil)
  here = request.path == path || (path != root_path && request.path.start_with?(path))
  link_to path, class: "rh-nav#{' is-active' if here}" do
    safe_join([
      (:span, icon, class: "rh-ico"),
      (:span, label, class: "rh-lbl"),
      badge ? (:span, "", class: "rh-badge #{badge_class}", data: { nav: badge }) : "".html_safe
    ])
  end
end

#queue_state(latency, paused: false) ⇒ Object

Health label for a queue from its latency (oldest-job age, in seconds).



17
18
19
20
21
22
# File 'app/helpers/roundhouse_ui/nav_helper.rb', line 17

def queue_state(latency, paused: false)
  return [ "Paused", "rh-st-paused" ] if paused
  return [ "Stuck", "rh-st-crit" ]   if latency > 600
  return [ "At risk", "rh-st-warn" ] if latency > 60
  [ "Healthy", "rh-st-ok" ]
end