run.html.erb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <% if @error %>
  2. <div class="alert alert-danger"><%= @error %></div>
  3. <% elsif !@success %>
  4. <div class="alert alert-info">Can’t run queries with variables yet</div>
  5. <% else %>
  6. <p class="text-muted"><%= pluralize(@rows.size, "row") %></p>
  7. <% if @rows.any? %>
  8. <% header_width = 100 / @rows.first.keys.size.to_f %>
  9. <table class="table">
  10. <thead>
  11. <tr>
  12. <% @columns.each do |key, type| %>
  13. <th style="width: <%= header_width %>%;" data-sort="<%= type %>">
  14. <div style="min-width: <%= @min_width_types.include?(key) ? 180 : 60 %>px;">
  15. <%= key %>
  16. </div>
  17. </th>
  18. <% end %>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <% @rows.each do |row| %>
  23. <tr>
  24. <% row.each do |k, v| %>
  25. <td>
  26. <% if v.is_a?(Time) %>
  27. <% v = v.in_time_zone(Blazer.time_zone) %>
  28. <% end %>
  29. <% unless v.nil? %>
  30. <% if v == "" %>
  31. <div class="text-muted">empty string</div>
  32. <% elsif @linked_columns[k] %>
  33. <%= link_to format_value(k, v), @linked_columns[k].gsub("{value}", u(v.to_s)), target: "_blank" %>
  34. <% else %>
  35. <%= format_value(k, v) %>
  36. <% end %>
  37. <% if v2 = (@boom[k] || {})[v] %>
  38. <div class="text-muted"><%= v2 %></div>
  39. <% end %>
  40. <% end %>
  41. </td>
  42. <% end %>
  43. </tr>
  44. <% end %>
  45. </tbody>
  46. </table>
  47. <% end %>
  48. <% end %>