ip search: add quick links & improve usability

#2530
This commit is contained in:
Toks
2015-10-08 01:14:48 -04:00
parent f92cfe3b43
commit 643ab7b2c6
8 changed files with 56 additions and 22 deletions

View File

@@ -16,6 +16,10 @@ div#c-moderator-dashboards {
div#ip-addr-search {
margin-bottom: 2em;
.hint {
display: block;
}
}
div#activity-search {

View File

@@ -4,6 +4,7 @@ module Moderator
def index
@search = IpAddrSearch.new(params[:search])
@results = @search.execute
end
def search

View File

@@ -9,11 +9,11 @@ module Moderator
def execute
if params[:user_id].present?
search_by_user_id(params[:user_id].split(/,/))
search_by_user_id(params[:user_id].split(/,/).map(&:strip))
elsif params[:user_name].present?
search_by_user_name(params[:user_name].split(/,/))
search_by_user_name(params[:user_name].split(/,/).map(&:strip))
elsif params[:ip_addr].present?
search_by_ip_addr(params[:ip_addr].split(/,/))
search_by_ip_addr(params[:ip_addr].split(/,/).map(&:strip))
else
[]
end

View File

@@ -2,6 +2,7 @@
<div class="input">
<label for="user_ids">Search IPs</label>
<%= text_field_tag "search[ip_addr]", params[:ip_addrs] %>
<span class="hint">Separate with commas</span>
</div>
<%= submit_tag "Search" %>
@@ -9,8 +10,9 @@
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
<div class="input">
<label for="user_ids">Search User IDs</label>
<%= text_field_tag "search[user_id]", params[:user_ids] %>
<label for="user_names">Search User Names</label>
<%= text_field_tag "search[user_name]", params[:user_names] %>
<span class="hint">Separate with commas</span>
</div>
<%= submit_tag "Search" %>

View File

@@ -0,0 +1,18 @@
<%= link_to "Perform another search for accounts associated with these IP addresses", moderator_ip_addrs_path(:search => {:ip_addr => @results.map{|k, count| k}.join(",")}) %>
<table class="striped">
<thead>
<tr>
<th>IP Address</th>
<th>Number of Occurrences</th>
</tr>
</thead>
<tbody>
<% @results.each do |ip_address, count| %>
<tr>
<td><%= ip_address %></td>
<td><%= count %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -0,0 +1,20 @@
<%= link_to "Perform another search for IP addresses associated with these accounts", moderator_ip_addrs_path(:search => {:user_id => @results.map{|k, count| k}.join(",")}) %>
<table class="striped">
<thead>
<tr>
<th>User</th>
<th>User ID</th>
<th>Number of Occurrences</th>
</tr>
</thead>
<tbody>
<% @results.each do |user_id, count| %>
<tr>
<td><%= link_to_user User.find(user_id) %></td>
<td><%= user_id %></td>
<td><%= count %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -2,22 +2,11 @@
<div id="a-index">
<h1>IP Addresses</h1>
<table class="striped">
<thead>
<tr>
<th>Key</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<% @search.execute.each do |k, count| %>
<tr>
<td><%= k %></td>
<td><%= count %></td>
</tr>
<% end %>
</tbody>
</table>
<% if params[:search][:user_id].present? || params[:search][:user_name].present? %>
<%= render "ip_listing" %>
<% else %>
<%= render "user_listing" %>
<% end %>
</div>
</div>

View File

@@ -2,7 +2,7 @@
<div id="a-search">
<h1>Search IP Addresses</h1>
<%= form_tag(moderator_ip_addrs_path, :class => "simple_form") do %>
<%= form_tag(moderator_ip_addrs_path, :method => :get, :class => "simple_form") do %>
<%= search_field "user_name", :label => "User" %>
<%= search_field "ip_addr", :label => "IP Addr" %>
<%= submit_tag "Search" %>