summaryrefslogtreecommitdiff
path: root/app/helpers/runners_helper.rb
blob: 9fb42487a75e6a2ddcc7d44c04ce29d14f00bf0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module RunnersHelper
  def runner_status_icon(runner)
    status = runner.status
    case status
    when :not_connected
      content_tag :i, nil,
                  class: "fa fa-warning",
                  title: "New runner. Has not connected yet"

    when :online, :offline, :paused
      content_tag :i, nil,
                  class: "fa fa-circle runner-status-#{status}",
                  title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
    end
  end

  def runner_link(runner)
    display_name = truncate(runner.display_name, length: 15)
    id = "\##{runner.id}"

    if current_user && current_user.admin
      link_to admin_runner_path(runner) do
        display_name + id
      end
    else
      display_name + id
    end
  end
end