Class: HostReportsController

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

Instance Method Summary collapse

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/host_reports_controller.rb', line 6

def show
  @host_report = resource_scope.find(params[:id])

  return not_found unless @host_report

  respond_to do |format|
    format.html do
      render '/react/index'
    end
    format.json do
      render json: {
        host_report: {
          id: @host_report.id,
          body: JSON.parse(@host_report.body),
          format: @host_report.format,
          host: {
            id: @host_report.host.id,
            name: @host_report.host.name,
          },
          proxy: {
            id: @host_report.proxy&.id,
            name: @host_report.proxy&.name,
          },
          reported_at: @host_report.reported_at,
        },
        permissions: {
          can_delete: authorized_for(auth_object: @host_report, authorizer: authorizer, permission: "destroy_#{controller_permission}"),
          can_view: authorized_for(auth_object: @host_report, authorizer: authorizer, permission: "view_#{controller_permission}"),
        },
      }, status: :ok
    end
  end
end