Class: OmahaReportsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/omaha_reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/omaha_reports_controller.rb', line 36

def destroy
  @omaha_report = resource_base.find(params[:id])
  if @omaha_report.destroy
    process_success(
      :success_msg => _('Successfully deleted report.'),
      :success_redirect => omaha_reports_path
    )
  else
    process_error
  end
end

#indexObject



12
13
14
15
# File 'app/controllers/omaha_reports_controller.rb', line 12

def index
  @host = resource_finder(Host.authorized(:view_hosts), params[:host_id]) if params[:host_id]
  @omaha_reports = resource_base_search_and_page(:host)
end

#model_of_controllerObject



8
9
10
# File 'app/controllers/omaha_reports_controller.rb', line 8

def model_of_controller
  ::ForemanOmaha::OmahaReport
end

#showObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/omaha_reports_controller.rb', line 17

def show
  # are we searching for the last report?
  if params[:id] == 'last'
    conditions = if params[:host_id].present?
                   {
                     :host_id => resource_finder(Host.authorized(:view_hosts), params[:host_id]).try(:id)
                   }
                 else
                   {}
                 end
    params[:id] = resource_base.where(conditions).maximum(:id)
  end

  return not_found if params[:id].blank?

  @omaha_report = resource_base.includes(:logs => [:message, :source]).find(params[:id])
  @offset = @omaha_report.reported_at - @omaha_report.created_at
end