Files
danbooru/app/views/ip_addresses/index.html.erb
2022-03-19 21:14:37 -05:00

36 lines
2.0 KiB
Plaintext

<%= render "secondary_links" %>
<div id="c-ip-addresses">
<div id="a-index">
<% if @ip_address %>
<h1>IP Address: <%= @ip_address.ip_addr %></h1>
<% else %>
<h1>IP Addresses</h1>
<% end %>
<%= search_form_for(ip_addresses_path) do |f| %>
<%= f.input :user_id, label: "User ID", input_html: { value: params[:search][:user_id] }, hint: "Separate with spaces" %>
<%= f.input :user_name, label: "User Name", input_html: { "data-autocomplete": "user", value: params[:search][:user_name] } %>
<%= f.input :ip_addr, label: "IP Address", input_html: { value: params[:search][:ip_addr] }, hint: '<a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation">CIDR notation</a> supported.'.html_safe %>
<%= f.input :created_at, label: "Date", input_html: { value: params[:search][:created_at] } %>
<%= f.input :model_type, label: "Source", collection: IpAddress.model_types, include_blank: true, selected: params[:search][:model_type] %>
<%= f.input :group_by, label: "Group By", collection: [["User", "user"], ["IP Address", "ip_addr"]], include_blank: true, selected: params[:search][:group_by] %>
<% if params[:search][:group_by] == "ip_addr" %>
<%= f.input :ipv4_masklen, label: "IPv4 Subnet", collection: [["/32", 32], ["/24", 24], ["/16", 16], ["/8", 8]], include_blank: false, selected: params[:search][:ipv4_masklen], hint: "Lower to group together IPs with the same prefix." %>
<%= f.input :ipv6_masklen, label: "IPv6 Subnet", collection: [["/128", 128], ["/80", 80], ["/64", 64], ["/48", 48]], include_blank: false, selected: params[:search][:ipv6_masklen] %>
<% end %>
<%= f.submit "Search" %>
<% end %>
<% if params[:search][:group_by] == "user" %>
<%= render "index_by_user" %>
<% elsif params[:search][:group_by] == "ip_addr" %>
<%= render "index_by_ip_addr" %>
<% elsif @ip_addresses.present? %>
<%= render "index" %>
<% end %>
<%= numbered_paginator(@ip_addresses) %>
</div>
</div>