Files
danbooru/app/components/time_series_component/time_series_component.html.erb
evazion 0d835983ce reports: fix error when report is empty.
Fix an exception when a report is empty, for example when performing a
tag search that returns no results:

* https://betabooru.donmai.us/reports/posts?search[group]=uploader&search[tags]=does_not_exist
2022-10-23 21:55:06 -05:00

41 lines
1.2 KiB
Plaintext

<div class="flex justify-end text-xs mb-2">
<% if mode == :table %>
<%= link_to "Chart", current_page_path(search: { **search_params, mode: "chart" }) %>
<% else %>
<%= link_to "Table", current_page_path(search: { **search_params, mode: "table" }) %>
<% end %>
</div>
<% if dataframe.empty? %>
<p>No results found. Try modifying your search or expanding your time range.</p>
<% elsif mode == :chart && x_axis.present? %>
<div class="line-chart" style="width: 100%; height: max(90vh, <%= chart_height.to_i %>px);"></div>
<script type="text/javascript">
var chart = new Danbooru.TimeSeriesComponent({
container: $(".line-chart").get(0),
options: <%= raw chart_options.to_json %>,
});
</script>
<% else %>
<table class="striped autofit" width="100%">
<thead>
<% dataframe.types.keys.each do |column| %>
<%= tag.th(column.to_s.titleize, class: ("col-expand" if column == dataframe.types.keys.last)) %>
<% end %>
</thead>
<tbody>
<% dataframe.each_row do |row| %>
<tr>
<% dataframe.types.keys.each do |column| %>
<td>
<%= row[column] %>
</td>
<% end %>
<tr>
<% end %>
</tbody>
</table>
<% end %>