diff --git a/app/views/hosts/_list.html.erb b/app/views/hosts/_list.html.erb
index 5918e9a0b1f..60c246d94f2 100644
--- a/app/views/hosts/_list.html.erb
+++ b/app/views/hosts/_list.html.erb
@@ -7,14 +7,8 @@
<% if power_status_visible? %>
<%= _('Power') %> |
<% end %>
- <%= sort :name, :as => _('Name') %> |
- <%= sort :os_title, :as => _("Operating system") %> |
- <%= sort :model, :as => _('Model') %> |
- <%= sort :owner, :as => _('Owner') %> |
- <%= sort :hostgroup, :as => _("Host group") %> |
- <%= sort :last_report, :as => _('Last report'), :default => 'DESC' %> |
+ <%= render_selected_column_ths %>
<%= render_pagelets_for(:hosts_table_column_header) %>
- <%= sort :comment, :as => _('Comment') %> |
<%= _('Actions') %> |
@@ -29,15 +23,8 @@
<%= react_component('PowerStatus', id: host.id, url: power_api_host_path(host)) %>
<% end %>
- <%= name_column(host) %>
- |
- <%= (icon(host.operatingsystem, :size => "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem %> |
- <%= host.compute_resource_or_model %> |
- <%= host_owner_column(host) %> |
- <%= label_with_link host.hostgroup, 23, @hostgroup_authorizer %> |
- <%= last_report_column(host) %> |
+ <%= render_selected_column_tds(host) %>
<%= render_pagelets_for(:hosts_table_column_content, :subject => host) %>
- <%= icon_text('comment', '') unless host.comment.empty? %> |
<%= action_buttons(
display_link_if_authorized(_("Edit"), hash_for_edit_host_path(:id => host).merge(:auth_object => host, :authorizer => authorizer)),
diff --git a/config/initializers/foreman_register.rb b/config/initializers/foreman_register.rb
index 8e8fa9e956e..1750f365de6 100644
--- a/config/initializers/foreman_register.rb
+++ b/config/initializers/foreman_register.rb
@@ -4,3 +4,26 @@
partial: 'hosts/init_config_tab',
priority: 100
end
+
+Foreman::SelectableColumns::Storage.define(:hosts) do
+ common_th_class = 'hidden-tablet hidden-xs'
+ common_td_class = common_th_class + ' ellipsis'
+ category :general, default: true do
+ column :name, th: { label: _('Name'), sortable: true, width: '25%' },
+ td: { class: 'ellipsis', callback: ->(host) { name_column(host) } }
+ column :os_title, th: { label: _('Operating system'), sortable: true, width: '17%', class: 'hidden-xs' },
+ td: { class: 'hidden-xs ellipsis', callback: ->(host) { (icon(host.operatingsystem, size: "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem } }
+ column :model, th: { label: _('Model'), sortable: true, width: '10%', class: common_th_class },
+ td: { class: common_td_class, callback: ->(host) { host.compute_resource_or_model } }
+ column :owner, th: { label: _('Owner'), sortable: true, width: '8%', class: common_th_class },
+ td: { class: common_td_class, callback: ->(host) { host_owner_column(host) } }
+ column :hostgroup, th: { label: _('Host group'), sortable: true, width: '15%', class: common_th_class },
+ td: { class: common_th_class, callback: ->(host) { label_with_link host.hostgroup, 23, @hostgroup_authorizer } }
+ column :last_report, th: { label: _('Last report'), sortable: true, default_sort: 'DESC', width: '10%', class: common_th_class },
+ td: { class: common_td_class, callback: ->(host) { last_report_column(host) } }
+ column :comment, th: { label: _('Comment'), sortable: true, width: '7%', class: common_th_class },
+ td: { class: common_th_class + ' ca',
+ attr_callbacks: { title: ->(host) { host.comment&.truncate(255) } },
+ callback: ->(host) { icon_text('comment', '') unless host.comment.empty? } }
+ end
+end
|