Skip to content

Commit

Permalink
fixes #10985 - Use dataTables on puppetca#index and autosign#index
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomizadok committed Jul 8, 2015
1 parent 55fd94a commit e9ccb02
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 21 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/application.js
Expand Up @@ -77,7 +77,8 @@ function onContentLoad(){
$('[data-table=inline]').not('.dataTable').dataTable(
{
"sDom": "<'row'<'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
"sPaginationType": "bootstrap"
"sPaginationType": "bootstrap",
"order": [[ 0, 'asc' ]] // Set default order for the first column
}
);

Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.scss
Expand Up @@ -316,10 +316,12 @@ table {

.sorting_asc {
background: url('sort_asc.png') no-repeat center right;
color: #0099d3;
}

.sorting_desc {
background: url('sort_desc.png') no-repeat center right;
color: #0099d3;
}

.sorting_asc_disabled {
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/autosign_controller.rb
Expand Up @@ -3,8 +3,7 @@ def index
@proxy = SmartProxy.authorized(:view_smart_proxies_autosign).find(params[:smart_proxy_id])
setup_proxy

autosign = @api.autosign
@autosign = autosign.paginate :page => params[:page], :per_page => Setting::General.entries_per_page
@autosign = @api.autosign
end

def new
Expand Down
14 changes: 1 addition & 13 deletions app/controllers/puppetca_controller.rb
Expand Up @@ -3,8 +3,7 @@ def index
@proxy = find_proxy
# expire cache if forced
Rails.cache.delete("ca_#{@proxy.id}") if params[:expire_cache] == "true"
certs = find_certs
@certificates = certs.sort.paginate :page => params[:page], :per_page => Setting::General.entries_per_page
@certificates = SmartProxies::PuppetCA.all(@proxy)
end

def update
Expand Down Expand Up @@ -33,15 +32,4 @@ def destroy
def find_proxy(permission = :view_smart_proxies_puppetca)
SmartProxy.authorized(permission).find(params[:smart_proxy_id])
end

def find_certs
if params[:state].blank?
SmartProxies::PuppetCA.find_by_state(@proxy, "valid") +
SmartProxies::PuppetCA.find_by_state(@proxy, "pending")
elsif params[:state] == "all"
SmartProxies::PuppetCA.all @proxy
else
SmartProxies::PuppetCA.find_by_state @proxy, params[:state]
end
end
end
3 changes: 1 addition & 2 deletions app/views/autosign/index.html.erb
@@ -1,7 +1,7 @@
<% title _("Autosign entries for %s") % @proxy %>
<% title_actions display_link_if_authorized(_("Certificates"), hash_for_smart_proxy_puppetca_index_path(:smart_proxy_id => @proxy).merge(:auth_object => @proxy, :permission => 'view_smart_proxies_puppetca')),
autosign_form %>
<table class='table table-bordered table-striped table-condensed'>
<table class="table table-bordered table-striped table-condensed" data-table="inline">
<thead>
<tr>
<th><%= _("Name") %></th>
Expand All @@ -20,4 +20,3 @@
<% end %>
</tbody>
</table>
<%= will_paginate_with_info @autosign %>
4 changes: 1 addition & 3 deletions app/views/puppetca/index.html.erb
@@ -1,7 +1,6 @@
<% title _("PuppetCA on %s") % @proxy.name %>
<% search_bar _("Filter by state: %s") % state_filter %>
<% title_actions display_link_if_authorized(_("Autosign Entries"), hash_for_smart_proxy_autosign_index_path(:smart_proxy_id => @proxy)) %>
<table class='table table-bordered table-striped table-condensed'>
<table class="table table-bordered table-striped table-condensed" data-table="inline">
<thead>
<tr>
<th><%= _("Certificate Name") %></th>
Expand Down Expand Up @@ -35,4 +34,3 @@
<% end %>
</tbody>
</table>
<%= will_paginate_with_info @certificates %>

0 comments on commit e9ccb02

Please sign in to comment.