Skip to content

Business intelligence made simple

Show check state on query page

Andrew Kane35dd44bbbeeb
diff --git a/app/assets/stylesheets/blazer/application.css b/app/assets/stylesheets/blazer/application.css
index 7bc1a3fb..ade4ffb3 100644
--- a/app/assets/stylesheets/blazer/application.css
+++ b/app/assets/stylesheets/blazer/application.css
@@ -100,3 +100,31 @@ input.search:focus {
.vars {
color: #ccc;
}
+
+.check-state {
+ font-weight: bold;
+}
+
+.check-state a {
+ color: inherit;
+}
+
+.check-state.failing {
+ color: red;
+}
+
+.check-state.passing {
+ color: #5cb85c;
+}
+
+.check-state.error {
+ color: #666;
+}
+
+.check-state.timed_out {
+ color: orange;
+}
+
+.check-state.disabled {
+ color: #000;
+}
diff --git a/app/controllers/blazer/checks_controller.rb b/app/controllers/blazer/checks_controller.rb
index 7d9f257c..55bf837e 100644
--- a/app/controllers/blazer/checks_controller.rb
+++ b/app/controllers/blazer/checks_controller.rb
@@ -40,6 +40,7 @@ module Blazer
def run
@query = @check.query
+ redirect_to query_path(@query)
end
private
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rb
index d3def14b..1afab4bc 100644
--- a/app/controllers/blazer/queries_controller.rb
+++ b/app/controllers/blazer/queries_controller.rb
@@ -127,6 +127,8 @@ module Blazer
private
def render_run
+ @checks = @query ? @query.checks : []
+
@first_row = @rows.first || []
@column_types = []
if @rows.any?
diff --git a/app/views/blazer/checks/index.html.erb b/app/views/blazer/checks/index.html.erb
index a1701e36..6ba42124 100644
--- a/app/views/blazer/checks/index.html.erb
+++ b/app/views/blazer/checks/index.html.erb
@@ -3,7 +3,6 @@
<p style="float: right;"><%= link_to "New Check", new_check_path, class: "btn btn-info" %></p>
<%= render partial: "blazer/nav" %>
-<% colors = {failing: "red", passing: "#5cb85c", error: "#666", timed_out: "orange", disabled: "#000"} %>
<table class="table">
<thead>
<tr>
@@ -20,7 +19,7 @@
<td><%= link_to check.query.name, check.query %></td>
<td>
<% if check.state %>
- <small style="font-weight: bold; color: <%= colors[check.state.parameterize("_").to_sym] %>;"><%= check.state.upcase %></small>
+ <small class="check-state <%= check.state.parameterize("_") %>"><%= check.state.upcase %></small>
<% end %>
</td>
<td><%= check.schedule if check.respond_to?(:schedule) %></td>
@@ -33,7 +32,7 @@
</td>
<td style="text-align: right; padding: 1px;">
<%= link_to "Edit", edit_check_path(check), class: "btn btn-info" %>
- <%= link_to "Run Now", run_check_path(check), class: "btn btn-primary" %>
+ <%= link_to "Run Now", run_check_path(check), target: "_blank", class: "btn btn-primary" %>
</td>
</tr>
<% end %>
diff --git a/app/views/blazer/checks/run.html.erb b/app/views/blazer/checks/run.html.erb
deleted file mode 100644
index 51fc5fc2..00000000
--- a/app/views/blazer/checks/run.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<p style="text-muted">Running check...</p>
-
-<script>
- var data = <%= blazer_json_escape({statement: @query.statement, query_id: @query.id, check: true}.to_json).html_safe %>;
-
- runQuery(data, function (data) {
- setTimeout( function () {
- window.location.href = "<%= checks_path %>";
- }, 200);
- });
-</script>
diff --git a/app/views/blazer/queries/run.html.erb b/app/views/blazer/queries/run.html.erb
index 61e5f1c5..a9a80653 100644
--- a/app/views/blazer/queries/run.html.erb
+++ b/app/views/blazer/queries/run.html.erb
@@ -24,7 +24,13 @@
<% end %>
</p>
<% end %>
- <p class="text-muted"><%= pluralize(@rows.size, "row") %></p>
+ <p class="text-muted">
+ <%= pluralize(@rows.size, "row") %>
+
+ <% @checks.each do |check| %>
+ &middot; <small class="check-state <%= check.state.parameterize("_") %>"><%= link_to check.state.upcase, edit_check_path(check) %></small>
+ <% end %>
+ </p>
<% end %>
<% if @rows.any? %>
<% values = @rows.first %>