Class: HostReportsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HostReportsController
- Includes:
- Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/host_reports_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/host_reports_controller.rb', line 5 def index respond_to do |format| format.html do render '/react/index' end format.json do reports = resource_base_search_and_page render json: { itemCount: reports.count, reports: reports.map do |r| r.attributes.except('body').merge( keywords: r.report_keywords.map(&:name), can_delete: can_delete?(r), can_view: can_view?(r), status: r.status ) end, }, status: :ok end end end |
#show ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/host_reports_controller.rb', line 28 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: can_delete?(@host_report), can_view: can_view?(@host_report), }, }, status: :ok end end end |