Open-Source-Access-Control-.../app/views/macs/index.html.erb

70 lines
2.6 KiB
Plaintext
Raw Normal View History

2013-09-29 01:55:22 +00:00
<% if can? :read_details, Mac %>
2013-09-28 11:59:19 +00:00
<% if @mac_time_start_date.present? %>
<b>Most Active Machine Last <%= distance_of_time_in_words DateTime.now, @mac_time_start_date %>:</b>
<span title="<%= @most_active_mac.mac %><%= " - "+@most_active_mac.ip.to_s if can? :read_details, @most_active_mac %>">
<%= @most_active_mac.user.name unless @most_active_mac.user.blank? %>
<%= "("+@most_active_mac.note+")" unless @most_active_mac.note.blank? %>
- <%= (@most_active.last[:time] / 1.hour).round %> hrs
</span>
<br/>
<b>Runner Up:</b>
<span title="<%= @runner_up_mac.mac %><%= " - "+@runner_up_mac.ip.to_s if can? :read_details, @runner_up_mac %>">
<%= @runner_up_mac.user.name unless @runner_up_mac.user.blank? %>
<%= "("+@runner_up_mac.note+")" unless @runner_up_mac.note.blank? %>
- <%= (@runner_up.last[:time] / 1.hour).round %> hrs
</span>
2013-09-28 11:59:19 +00:00
<% end %>
2013-09-29 01:55:22 +00:00
<% end %>
<h2>What machines are on our network?</h2>
<%= link_to "New MAC registration", new_mac_path if can? :create, Mac %>
<ul class="mac_list">
<%
@active_macs.each do |mac|
Rails.logger.info mac.inspect %>
<li>
<span title="<%= mac.mac if user_signed_in? %><%= " - "+mac.ip.to_s if can? :read_details, mac %><%= " - "+((Time.now - mac.since) / 1.hour).round(1).to_s+" hours" if can? :manage, mac %>">
<%= mac.user.name unless mac.user.blank? %>
2013-02-09 09:08:29 +00:00
<%= mac.mac if mac.user.blank? %>
<%= "("+mac.note+")" unless mac.note.blank? %></span>
<%= link_to ' Edit', edit_mac_path(mac) if can? :update, mac %> <br/>
</li>
<% end %>
</ul>
2013-09-29 01:55:22 +00:00
<% unless can? :read_details, Mac %>
<p>To see more or register your own, login!</p>
<% end %>
<% if can? :read_details, Mac %>
<ul class="mac_list hidden">
2013-02-01 05:39:33 +00:00
<% @hidden_macs.each do |mac| %>
<li>
<span title="<%= mac.mac %><%= " - "+mac.ip.to_s if can? :read_details, mac %><%= " - "+((Time.now - mac.since) / 1.hour).round(1).to_s+" hours" if can? :manage, mac %>">
<%= mac.user.name unless mac.user.blank? %>
<%= "("+mac.note+")" unless mac.note.blank? %></span>
<%= link_to ' Edit', edit_mac_path(mac) if can? :update, mac %> <br/>
</li>
2013-02-01 05:39:33 +00:00
<% end %>
</ul>
<% end %>
<% if can? :manage, Mac %>
<h3>All MACs</h3>
<table>
<% @all_macs.each do |mac| %>
<tr <%= raw('class="hidden"') if mac.hidden? %>>
<td><%= mac.mac.downcase %> </td>
<td><%= mac.user.name unless mac.user.blank? %></td>
<td><%= "("+mac.note+")" unless mac.note.blank? %></td>
<td><%= if mac.active? then raw("<strong>Here</strong>") else "Gone" end %></td>
<td><%= ((Time.now - mac.since) / 1.hour).round(1).to_s+" hours" unless mac.since.blank? %></td>
<td><%= link_to 'Edit', edit_mac_path(mac) %></td>
</tr>
<% end %>
</table>
2013-02-01 05:39:33 +00:00
<% end %>