Module: RoundhouseUi::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#job_identity(klass, jid, path) ⇒ Object

A job row's identity cell. Class on the first line where the eye lands, jid on a second, dimmer line — one long line of class + hex + link is unreadable once the row also carries squad, queue and error.



6
7
8
9
10
11
# File 'app/helpers/roundhouse_ui/application_helper.rb', line 6

def job_identity(klass, jid, path)
  safe_join([
    link_to(klass, path, class: "rh-joblink"),
    (:div, jid, class: "rh-sub rh-mono rh-jid", title: jid)
  ])
end

#job_time(at, overdue: "now (overdue)") ⇒ Object

Relative time answers "is this soon?", the clock time answers "does that land inside the maintenance window?". Operators need both, so show both rather than making them hover or do the arithmetic.



16
17
18
19
20
21
22
23
24
# File 'app/helpers/roundhouse_ui/application_helper.rb', line 16

def job_time(at, overdue: "now (overdue)")
  return (:span, "", class: "rh-sub") if at.nil?

  relative = at > Time.now ? "in #{distance_of_time_in_words(Time.now, at)}" : overdue
  safe_join([
    (:span, relative),
    (:span, at.strftime("%b %-d, %H:%M"), class: "rh-sub rh-mono")
  ], " · ")
end

#queue_pill(name, link: false) ⇒ Object

Queues carry meaning at a glance (critical vs low), so render them as a pill rather than grey text lost between two columns. On the job sets the pill filters to that queue; link: is off where there's nothing to filter (the Queues index itself, grouped Errors rows).



43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/roundhouse_ui/application_helper.rb', line 43

def queue_pill(name, link: false)
  return (:span, name, class: "rh-pill rh-mono") unless link

  active = @queue_filter == name.to_s
  link_to name, url_for(only_path: true, page: nil, q: @query.presence,
                        tag: params[:tag].presence,
                        queue: (active ? nil : name)),
    class: "rh-pill rh-mono rh-pill-link#{' is-on' if active}",
    title: active ? "Clear queue filter" : "Show only #{name}"
end

#set_heading(label, showing:, total:, query: nil, tag: nil) ⇒ Object

Set heading that tells the truth under a filter. It used to always print the whole-set size, so "Dead set · 19 jobs" sat above four filtered rows.



28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/roundhouse_ui/application_helper.rb', line 28

def set_heading(label, showing:, total:, query: nil, tag: nil)
  filtered = any_filter?(query, tag)
  count = filtered ? "#{number_with_delimiter showing} of #{number_with_delimiter total}" : number_with_delimiter(total)
  (:h2, class: "rh-h2") do
    safe_join([
      "#{label} · #{count} jobs",
      (filtered ? (:span, filter_description(query, tag), class: "hint") : nil)
    ].compact, " ")
  end
end