diff --git a/app/controllers/moderator/ip_addrs_controller.rb b/app/controllers/moderator/ip_addrs_controller.rb index 2add8f756..26f36d1ef 100644 --- a/app/controllers/moderator/ip_addrs_controller.rb +++ b/app/controllers/moderator/ip_addrs_controller.rb @@ -1,10 +1,12 @@ module Moderator class IpAddrsController < ApplicationController before_action :moderator_only + respond_to :html, :json def index @search = IpAddrSearch.new(params[:search]) @results = @search.execute + respond_with(@results) end def search diff --git a/app/views/moderator/ip_addrs/_ip_listing.erb b/app/views/moderator/ip_addrs/_ip_listing.html.erb similarity index 100% rename from app/views/moderator/ip_addrs/_ip_listing.erb rename to app/views/moderator/ip_addrs/_ip_listing.html.erb diff --git a/app/views/moderator/ip_addrs/_ip_listing.json.erb b/app/views/moderator/ip_addrs/_ip_listing.json.erb new file mode 100644 index 000000000..bb9f4c563 --- /dev/null +++ b/app/views/moderator/ip_addrs/_ip_listing.json.erb @@ -0,0 +1 @@ +<%= raw @results.map {|ip_addr, count| {ip_addr: ip_addr.to_s, count: count}}.to_json %> \ No newline at end of file diff --git a/app/views/moderator/ip_addrs/_user_listing.json.erb b/app/views/moderator/ip_addrs/_user_listing.json.erb new file mode 100644 index 000000000..e08079c16 --- /dev/null +++ b/app/views/moderator/ip_addrs/_user_listing.json.erb @@ -0,0 +1 @@ +<%= raw @results.map {|user, count| {user_id: user.id, count: count}}.to_json %> \ No newline at end of file diff --git a/app/views/moderator/ip_addrs/index.json.erb b/app/views/moderator/ip_addrs/index.json.erb new file mode 100644 index 000000000..75017df8c --- /dev/null +++ b/app/views/moderator/ip_addrs/index.json.erb @@ -0,0 +1,5 @@ +<% if params[:search][:user_id].present? || params[:search][:user_name].present? %> + <%= render "ip_listing.json" %> +<% else %> + <%= render "user_listing.json" %> +<% end %>