Skip to content

Business intelligence made simple

Added tables to dashboards

Andrew Kane9cf855af0802
diff --git a/app/assets/stylesheets/blazer/application.css b/app/assets/stylesheets/blazer/application.css
index 78049951..095e3cb7 100644
--- a/app/assets/stylesheets/blazer/application.css
+++ b/app/assets/stylesheets/blazer/application.css
@@ -16,11 +16,11 @@ body {
padding-bottom: 20px;
}
-#results th {
+.results-table th {
cursor: pointer;
}
-#results thead {
+.results-table thead {
background-color: #fff;
}
@@ -77,6 +77,9 @@ input.search:focus {
flex-direction: column;
}
-.chart .alert {
- display: inline-block;
+.chart > .results-container {
+ height: 300px;
+ border: solid 1px #ddd;
+ overflow: scroll;
+ text-align: left;
}
diff --git a/app/views/blazer/dashboards/show.html.erb b/app/views/blazer/dashboards/show.html.erb
index c4b85fac..9a80dd11 100644
--- a/app/views/blazer/dashboards/show.html.erb
+++ b/app/views/blazer/dashboards/show.html.erb
@@ -136,6 +136,7 @@
<script>
$.post("<%= run_queries_path %>", <%= json_escape({statement: query.statement, query_id: query.id, only_chart: true}.to_json).html_safe %>, function (data) {
$("#chart-<%= i %>").html(data);
+ $("#chart-<%= i %> table").stupidtable();
});
</script>
<% end %>
diff --git a/app/views/blazer/queries/run.html.erb b/app/views/blazer/queries/run.html.erb
index efc92104..2a0c63f3 100644
--- a/app/views/blazer/queries/run.html.erb
+++ b/app/views/blazer/queries/run.html.erb
@@ -22,53 +22,55 @@
<% elsif values.size == 2 && values.first.is_a?(String) && values.last.is_a?(Numeric) %>
<%= pie_chart @rows.map(&:values), library: {sliceVisibilityThreshold: 1 / 40.0}, id: chart_id %>
<% elsif @only_chart %>
- <div class="alert alert-danger">No chart</div>
+ <% @no_chart = true %>
<% end %>
- <% unless @only_chart %>
+ <% unless @only_chart && !@no_chart %>
<% header_width = 100 / @rows.first.keys.size.to_f %>
- <table class="table">
- <thead>
- <tr>
- <% @columns.each do |key, type| %>
- <th style="width: <%= header_width %>%;" data-sort="<%= type %>">
- <div style="min-width: <%= @min_width_types.include?(key) ? 180 : 60 %>px;">
- <%= key %>
- </div>
- </th>
- <% end %>
- </tr>
- </thead>
- <tbody>
- <% @rows.each do |row| %>
+ <div class="results-container">
+ <table class="table results-table" style="margin-bottom: 0;">
+ <thead>
<tr>
- <% row.each do |k, v| %>
- <td>
- <% if v.is_a?(Time) %>
- <% v = v.in_time_zone(Blazer.time_zone) %>
- <% end %>
-
- <% unless v.nil? %>
- <% if v == "" %>
- <div class="text-muted">empty string</div>
- <% elsif @linked_columns[k] %>
- <%= link_to format_value(k, v), @linked_columns[k].gsub("{value}", u(v.to_s)), target: "_blank" %>
- <% else %>
- <%= format_value(k, v) %>
+ <% @columns.each do |key, type| %>
+ <th style="width: <%= header_width %>%;" data-sort="<%= type %>">
+ <div style="min-width: <%= @min_width_types.include?(key) ? 180 : 60 %>px;">
+ <%= key %>
+ </div>
+ </th>
+ <% end %>
+ </tr>
+ </thead>
+ <tbody>
+ <% @rows.each do |row| %>
+ <tr>
+ <% row.each do |k, v| %>
+ <td>
+ <% if v.is_a?(Time) %>
+ <% v = v.in_time_zone(Blazer.time_zone) %>
<% end %>
- <% if v2 = (@boom[k] || {})[v] %>
- <div class="text-muted"><%= v2 %></div>
+ <% unless v.nil? %>
+ <% if v == "" %>
+ <div class="text-muted">empty string</div>
+ <% elsif @linked_columns[k] %>
+ <%= link_to format_value(k, v), @linked_columns[k].gsub("{value}", u(v.to_s)), target: "_blank" %>
+ <% else %>
+ <%= format_value(k, v) %>
+ <% end %>
+
+ <% if v2 = (@boom[k] || {})[v] %>
+ <div class="text-muted"><%= v2 %></div>
+ <% end %>
<% end %>
- <% end %>
- </td>
- <% end %>
- </tr>
- <% end %>
- </tbody>
- </table>
+ </td>
+ <% end %>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
<% end %>
<% elsif @only_chart %>
- <p>No rows</p>
+ <p class="text-muted">No rows</p>
<% end %>
<% end %>