Module: ReportsHelper

Defined in:
app/helpers/reports_helper.rb

Instance Method Summary collapse

Instance Method Details

#logs_showObject


40
41
42
43
44
45
46
47
# File 'app/helpers/reports_helper.rb', line 40

def logs_show
 return unless @report.logs.size > 0
 form_tag @report, :id => 'level_filter', :method => :get do
   (:span, _("Show log messages:") + ' ') +
   select(nil, 'level', [[_('All messages'), 'notice'],[_('Warnings and errors'), 'warning'],[_('Errors only'), 'error']],
          {}, {:class => "input-medium", :onchange =>"filter_by_level(this);"})
 end
end

#metric(m) ⇒ Object


22
23
24
# File 'app/helpers/reports_helper.rb', line 22

def metric m
  m.round(4) rescue _("N/A")
end

#report_event_column(event, style = "") ⇒ Object


8
9
10
11
# File 'app/helpers/reports_helper.rb', line 8

def report_event_column(event, style = "")
  style = "" if event == 0
  (:span, event, :class=>'label ' + style)
end

#report_tag(level) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/reports_helper.rb', line 26

def report_tag level
  tag = case level
        when :notice
          "info"
        when :warning
          "warning"
        when :err
          "important"
        else
          "default"
        end
  "class='label label-#{tag}'".html_safe
end

#reported_at_column(record) ⇒ Object


4
5
6
# File 'app/helpers/reports_helper.rb', line 4

def reported_at_column(record)
  link_to(_("%s ago") % time_ago_in_words(record.reported_at.getlocal), report_path(record))
end

#reports_since(builder) ⇒ Object


13
14
15
16
17
18
19
20
# File 'app/helpers/reports_helper.rb', line 13

def reports_since builder
  choices = [30,60,90].map{|i| OpenStruct.new :name => n_("%s minute ago", "%s minutes ago", i) % i, :value => i.minutes.ago }
  choices += (1..7).map{|i| OpenStruct.new :name => n_("%s day ago", "%s days ago", i) % i, :value => i.days.ago }
  choices += (1..3).map{|i| OpenStruct.new :name => n_("%s week ago", "%s weeks ago", i) % i, :value => i.week.ago }
  choices += (1..3).map{|i| OpenStruct.new :name => n_("%s month ago", "%s months ago", i) % i, :value => i.month.ago }
  choices += [OpenStruct.new(:name => _("All Reports"), :value =>  Report.first(:select => "created_at").created_at)]
  builder.collection_select :reported_at_gt, choices, :value, :name, {:include_blank => _("Select a period")}
end