Add button to download filtered domains

This commit is contained in:
Alex Sherman 2021-01-22 16:57:37 +05:00
parent b6df415fb9
commit b65a2ca924
4 changed files with 18 additions and 1 deletions

View file

@ -8,6 +8,8 @@ $(window).load ->
$('[data-toggle="popover"]').popover() $('[data-toggle="popover"]').popover()
$('[data-toggle="tooltip"]').tooltip()
# doublescroll # doublescroll
$('[data-doublescroll]').doubleScroll({ $('[data-doublescroll]').doubleScroll({
onlyIfScroll: false, onlyIfScroll: false,

View file

@ -27,8 +27,17 @@ module Admin
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
end end
end end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive? @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
respond_to do |format|
format.html do
@domains
end
format.csv do
raw_csv = @domains.to_csv
send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
end
end
end end
def show def show

View file

@ -64,6 +64,11 @@
<span class="glyphicon glyphicon-search"></span> <span class="glyphicon glyphicon-search"></span>
&nbsp; &nbsp;
</button> </button>
<button class="btn">
<%= link_to "", admin_domains_path(format: :csv),
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
class: 'glyphicon glyphicon-list-alt' %>
</button>
<%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %> <%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %>
</div> </div>
</div> </div>

View file

@ -11,6 +11,7 @@ en:
search_form: search_form:
reset_btn: Reset reset_btn: Reset
download_csv_btn: "Download CSV"
form: form:
pending_delete: &pending_delete pending_delete: &pending_delete