Class: ArfReportsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ArfReportsController
- Includes:
- Foreman::Controller::AutoCompleteSearch, ForemanOpenscap::ArfReportsControllerCommonExtensions
- Defined in:
- app/controllers/arf_reports_controller.rb
Instance Method Summary collapse
- #delete_multiple ⇒ Object
- #destroy ⇒ Object
- #download_html ⇒ Object
- #index ⇒ Object
- #model_of_controller ⇒ Object
- #parse_bzip ⇒ Object
- #parse_html ⇒ Object
- #show ⇒ Object
- #show_html ⇒ Object
- #show_log ⇒ Object
- #submit_delete_multiple ⇒ Object
Methods included from ForemanOpenscap::ArfReportsControllerCommonExtensions
Instance Method Details
#delete_multiple ⇒ Object
61 62 |
# File 'app/controllers/arf_reports_controller.rb', line 61 def delete_multiple end |
#destroy ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/controllers/arf_reports_controller.rb', line 53 def destroy if @arf_report.destroy process_success(:success_msg => _("Successfully deleted ARF report."), :success_redirect => arf_reports_path) else process_error(:error_msg => _("Failed to delete ARF Report for host %{host_name} reported at %{reported_at}") % { :host_name => @arf_report.host.name, :reported_at => @arf_report.reported_at }) end end |
#download_html ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/arf_reports_controller.rb', line 42 def download_html begin response = @arf_report.to_html send_data response, :filename => "#{format_filename}.html", :type => 'text/html', :disposition => 'attachement' rescue => e process_error(:error_msg => _("Failed to downloaded ARF report in HTML: %s") % e., :error_redirect => arf_report_path(@arf_report.id)) end end |
#index ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/arf_reports_controller.rb', line 12 def index @arf_reports = resource_base.includes(:policy, :openscap_proxy, :host => %i[policies last_report_object host_statuses]) .search_for(params[:search], :order => params[:order]) .paginate(:page => params[:page], :per_page => params[:per_page]) end |
#model_of_controller ⇒ Object
8 9 10 |
# File 'app/controllers/arf_reports_controller.rb', line 8 def model_of_controller ::ForemanOpenscap::ArfReport end |
#parse_bzip ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/arf_reports_controller.rb', line 32 def parse_bzip begin response = @arf_report.to_bzip send_data response, :filename => "#{format_filename}.xml.bz2", :type => 'application/octet-stream', :disposition => 'attachement' rescue => e process_error(:error_msg => (_("Failed to downloaded ARF report as bzip: %s") % e.), :error_redirect => arf_report_path(@arf_report.id)) end end |
#parse_html ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/controllers/arf_reports_controller.rb', line 24 def parse_html begin self.response_body = @arf_report.to_html rescue => e render :plain => _(e.) end end |
#show ⇒ Object
18 19 |
# File 'app/controllers/arf_reports_controller.rb', line 18 def show end |
#show_html ⇒ Object
21 22 |
# File 'app/controllers/arf_reports_controller.rb', line 21 def show_html end |
#show_log ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/arf_reports_controller.rb', line 75 def show_log return not_found unless @arf_report # TODO: use Message/Log model directly instead? log = @arf_report.logs.find(params[:log_id]) return not_found unless log respond_to do |format| format.json do render json: { log: { source: log.source, message: { value: log..value, fixes: log..fixes, } }, }, status: :ok end end end |
#submit_delete_multiple ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/arf_reports_controller.rb', line 64 def submit_delete_multiple failed_deletes = @arf_reports.reject(&:destroy).count if failed_deletes > 0 process_error(:error_msg => (_("Failed to delete %s compliance reports") % failed_deletes), :error_redirect => arf_reports_path) else process_success(:success_msg => (_("Successfully deleted %s compliance reports") % @arf_reports.size), :success_redirect => arf_reports_path) end end |