Skip to content

Commit

Permalink
Fixes #22107 - Add hosts count to subnet page
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrisker authored and dLobatog committed Jan 2, 2018
1 parent 406b3fb commit 7f85b5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/subnet.rb
Expand Up @@ -223,6 +223,10 @@ def as_json(options = {})
super({:methods => [:to_label, :type]}.merge(options))
end

def hosts_count
hosts.authorized(:view_hosts).size
end

private

def validate_ranges
Expand Down
4 changes: 3 additions & 1 deletion app/views/subnets/index.html.erb
Expand Up @@ -6,11 +6,12 @@
<table class="<%= table_css_classes 'table-two-pane table-fixed' %>">
<thead>
<tr>
<th class="col-md-3"><%= sort :name, :as => s_("Subnet|Name") %></th>
<th class="col-md-2"><%= sort :name, :as => s_("Subnet|Name") %></th>
<th class="col-md-2"><%= sort :network, :as => s_("Subnet|Network") %></th>
<th class="col-md-3"><%= _("Domains") %></th>
<th class="col-md-1"><%= sort :vlanid, :as => s_('Subnet|Vlanid') %></th>
<th class="col-md-2"><%= _("DHCP Proxy") %></th>
<th class="col-md-1"><%= _("Hosts") %></th>
<th><%= _('Actions') %></th>
</tr>
</thead>
Expand All @@ -22,6 +23,7 @@
<td class="ellipsis"><%=subnet.domains.map(&:name).to_sentence %></td>
<td><%=subnet.vlanid %></td>
<td class="ellipsis"><%=subnet.dhcp %></td>
<td><%= link_to subnet.hosts_count, hosts_path(:search => "subnet.name=\"#{subnet}\"") %>
<td class="col-md-1">
<%= action_buttons(display_delete_if_authorized(
hash_for_subnet_path(:id => subnet).
Expand Down

0 comments on commit 7f85b5c

Please sign in to comment.