Skip to content

Commit

Permalink
Fixes #26667 - Add pagination to policy dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Prazak committed Apr 24, 2019
1 parent e53652c commit 10b7f9e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/foreman_openscap/policy_dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#latest-arf-reports-table .content-view-pf-pagination.table-view-pf-pagination {
margin-bottom: 30px;
}
5 changes: 5 additions & 0 deletions app/controllers/policy_dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ def prefetch_data
@policy = ::ForemanOpenscap::Policy.find(params[:id])
dashboard = ForemanOpenscap::PolicyDashboard::Data.new(@policy, params[:search])
@report = dashboard.report
@latest_reports = ForemanOpenscap::ArfReport
.includes(:host)
.of_policy(@policy.id)
.latest
.paginate(:page => params[:page], :per_page => params[:per_page])
end
end
49 changes: 27 additions & 22 deletions app/views/policy_dashboard/_policy_reports.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<table class="<%= table_css_classes('ellipsis') %>">
<tr>
<th><%= _('Host') %></th>
<th><%= _("Date") %></th>
<th><%= _("Passed") %></th>
<th><%= _("Failed") %></th>
<th><%= _("Other") %></th>
<th><%= _('Actions') %></th>
</tr>
<% for arf_report in @policy.arf_reports.latest %>
<% stylesheet 'foreman_openscap/policy_dashboard'%>

<div id="latest-arf-reports-table">
<table class="<%= table_css_classes('ellipsis') %>">
<tr>
<td><%= name_column(arf_report.host) %></td>
<td><%= date_time_relative_value(arf_report.reported_at) %></td>
<td><%= report_arf_column(arf_report.passed, "label-info") %></th>
<td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
<td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
<td>
<%= action_buttons(
link_to(_("View Report"), hash_for_arf_report_path(:id => arf_report.id))
) %>
</td>
<th><%= _('Host') %></th>
<th><%= _("Date") %></th>
<th><%= _("Passed") %></th>
<th><%= _("Failed") %></th>
<th><%= _("Other") %></th>
<th><%= _('Actions') %></th>
</tr>
<% end %>
</table>
<% @latest_reports.each do |arf_report| %>
<tr>
<td><%= name_column(arf_report.host) %></td>
<td><%= date_time_relative_value(arf_report.reported_at) %></td>
<td><%= report_arf_column(arf_report.passed, "label-info") %></th>
<td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
<td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
<td>
<%= action_buttons(
link_to(_("View Report"), hash_for_arf_report_path(:id => arf_report.id))
) %>
</td>
</tr>
<% end %>
</table>
<%= will_paginate_with_info @latest_reports %>
</div>

0 comments on commit 10b7f9e

Please sign in to comment.