Skip to content

Business intelligence made simple

Added navbar

Andrew Kane8c4f69dd5340
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f40cdc00..8f46a3a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,9 @@
## 2.0.1 [unreleased]
+- Added navbar
- Added favicon
- Added Trend anomaly detection
+- Added search for checks and schema
- Improved docs for new installs
- Fixed error with canceling queries
diff --git a/app/assets/javascripts/blazer/routes.js b/app/assets/javascripts/blazer/routes.js
index 404abd41..f1a14936 100644
--- a/app/assets/javascripts/blazer/routes.js
+++ b/app/assets/javascripts/blazer/routes.js
@@ -6,6 +6,9 @@ var Routes = {
return rootPath + "queries/cancel"
},
schema_queries_path: function(params) {
+ return rootPath + "queries/schema?" + $.param(params)
+ },
+ docs_queries_path: function(params) {
return rootPath + "queries/docs?" + $.param(params)
},
tables_queries_path: function(params) {
diff --git a/app/assets/stylesheets/blazer/application.css b/app/assets/stylesheets/blazer/application.css
index a9165145..b43dde87 100644
--- a/app/assets/stylesheets/blazer/application.css
+++ b/app/assets/stylesheets/blazer/application.css
@@ -12,7 +12,6 @@ pre {
}
body {
- padding-top: 20px;
padding-bottom: 20px;
}
@@ -141,14 +140,8 @@ input.search:focus {
color: #000;
}
-.topbar {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- background-color: whitesmoke;
- height: 60px;
- z-index: 1001;
+.navbar-default {
+ border: none;
}
.glyphicon-remove {
@@ -201,6 +194,17 @@ input.search:focus {
color: red;
}
+.small-form {
+ margin-right: auto;
+ margin-left: auto;
+ max-width: 400px;
+}
+
+h1, h2, h3, p, hr, .table, .navbar, #header, .alert, .form-group {
+ margin-top: 0;
+ margin-bottom: 15px;
+}
+
h1 {
font-size: 32px;
}
@@ -208,3 +212,7 @@ h1 {
h2 {
font-size: 24px;
}
+
+.schema-table {
+ max-width: 500px;
+}
diff --git a/app/controllers/blazer/dashboards_controller.rb b/app/controllers/blazer/dashboards_controller.rb
index 38564356..98a214bb 100644
--- a/app/controllers/blazer/dashboards_controller.rb
+++ b/app/controllers/blazer/dashboards_controller.rb
@@ -2,10 +2,6 @@ module Blazer
class DashboardsController < BaseController
before_action :set_dashboard, only: [:show, :edit, :update, :destroy, :refresh]
- def index
- redirect_to root_path(filter: "dashboards")
- end
-
def new
@dashboard = Blazer::Dashboard.new
end
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rb
index 4d882ac3..4405b810 100644
--- a/app/controllers/blazer/queries_controller.rb
+++ b/app/controllers/blazer/queries_controller.rb
@@ -1,16 +1,12 @@
module Blazer
class QueriesController < BaseController
before_action :set_query, only: [:show, :edit, :update, :destroy, :refresh]
- before_action :set_data_source, only: [:tables, :docs, :cancel]
+ before_action :set_data_source, only: [:tables, :docs, :schema, :cancel]
def home
- if params[:filter] == "dashboards"
- @queries = []
- else
- set_queries(1000)
- end
+ set_queries(1000)
- if params[:filter] && params[:filter] != "dashboards"
+ if params[:filter]
@dashboards = [] # TODO show my dashboards
else
@dashboards = Blazer::Dashboard.order(:name)
@@ -181,12 +177,15 @@ module Blazer
end
def docs
- @schema = @data_source.schema
@smart_variables = @data_source.smart_variables
@linked_columns = @data_source.linked_columns
@smart_columns = @data_source.smart_columns
end
+ def schema
+ @schema = @data_source.schema
+ end
+
def cancel
@data_source.cancel(blazer_run_id)
head :ok
diff --git a/app/views/blazer/_nav.html.erb b/app/views/blazer/_nav.html.erb
deleted file mode 100644
index a9d76f1f..00000000
--- a/app/views/blazer/_nav.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<div class="btn-group" style="vertical-align: top; margin-right: 5px;">
- <%= link_to "Home", root_path, class: "btn btn-primary" %>
- <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- <span class="caret"></span>
- <span class="sr-only">Toggle Dropdown</span>
- </button>
- <ul class="dropdown-menu">
- <li><%= link_to "Dashboards", dashboards_path %></li>
- <li><%= link_to "Checks", checks_path %></li>
- <li role="separator" class="divider"></li>
- <li><%= link_to "New Query", new_query_path %></li>
- <li><%= link_to "New Dashboard", new_dashboard_path %></li>
- <% check_params = @query ? {query_id: @query.id} : {} %>
- <li><%= link_to "New Check", new_check_path(check_params) %></li>
- </ul>
-</div>
diff --git a/app/views/blazer/_variables.html.erb b/app/views/blazer/_variables.html.erb
index d0d962fc..ce72e401 100644
--- a/app/views/blazer/_variables.html.erb
+++ b/app/views/blazer/_variables.html.erb
@@ -8,7 +8,7 @@
return moment.tz(time.format(format), timeZone)
}
</script>
- <form id="bind" method="get" action="<%= action %>" class="form-inline" style="margin-bottom: 10px;">
+ <form id="bind" method="get" action="<%= action %>" class="form-inline" style="margin-bottom: 15px;">
<% date_vars = ["start_time", "end_time"] %>
<% if (date_vars - @bind_vars).empty? %>
<% @bind_vars = @bind_vars - date_vars %>
diff --git a/app/views/blazer/checks/_form.html.erb b/app/views/blazer/checks/_form.html.erb
index ac7c6a73..1f15c324 100644
--- a/app/views/blazer/checks/_form.html.erb
+++ b/app/views/blazer/checks/_form.html.erb
@@ -1,12 +1,12 @@
-<% unless @check.respond_to?(:check_type) || @check.respond_to?(:invert) %>
- <p class="text-muted">Checks are designed to identify bad data. A check fails if there are any results.</p>
-<% end %>
+<%= form_for @check, html: {class: "small-form"} do |f| %>
+ <% unless @check.respond_to?(:check_type) || @check.respond_to?(:invert) %>
+ <p class="text-muted">Checks are designed to identify bad data. A check fails if there are any results.</p>
+ <% end %>
-<% if @check.errors.any? %>
- <div class="alert alert-danger"><%= @check.errors.full_messages.first %></div>
-<% end %>
+ <% if @check.errors.any? %>
+ <div class="alert alert-danger"><%= @check.errors.full_messages.first %></div>
+ <% end %>
-<%= form_for @check do |f| %>
<div class="form-group">
<%= f.label :query_id, "Query" %>
<div class="hide">
@@ -74,6 +74,5 @@
<%= link_to "Delete", check_path(@check), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %>
<% end %>
<%= f.submit "Save", class: "btn btn-success" %>
- <%= link_to "Back", :back, class: "btn btn-link" %>
</p>
<% end %>
diff --git a/app/views/blazer/checks/index.html.erb b/app/views/blazer/checks/index.html.erb
index f733174b..07e04f3e 100644
--- a/app/views/blazer/checks/index.html.erb
+++ b/app/views/blazer/checks/index.html.erb
@@ -1,9 +1,10 @@
<% blazer_title "Checks" %>
-<p style="float: right;"><%= link_to "New Check", new_check_path, class: "btn btn-info" %></p>
-<%= render partial: "blazer/nav" %>
+<div id="header">
+ <input id="search" type="text" placeholder="Start typing a query or state" style="width: 300px; display: inline-block;" class="search form-control" />
+</div>
-<table class="table">
+<table id="checks" class="table">
<thead>
<tr>
<th>Query</th>
@@ -41,3 +42,12 @@
<% end %>
</tbody>
</table>
+
+<script>
+ $("#search").on("keyup", function() {
+ var value = $(this).val().toLowerCase()
+ $("#checks tbody tr").filter( function() {
+ $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
+ })
+ }).focus()
+</script>
diff --git a/app/views/blazer/dashboards/_form.html.erb b/app/views/blazer/dashboards/_form.html.erb
index 3651b066..b697fb28 100644
--- a/app/views/blazer/dashboards/_form.html.erb
+++ b/app/views/blazer/dashboards/_form.html.erb
@@ -1,8 +1,8 @@
-<% if @dashboard.errors.any? %>
- <div class="alert alert-danger"><%= @dashboard.errors.full_messages.first %></div>
-<% end %>
+<%= form_for @dashboard, url: (@dashboard.persisted? ? dashboard_path(@dashboard, variable_params) : dashboards_path(variable_params)), html: {id: "app", class: "small-form"} do |f| %>
+ <% if @dashboard.errors.any? %>
+ <div class="alert alert-danger"><%= @dashboard.errors.full_messages.first %></div>
+ <% end %>
-<%= form_for @dashboard, url: (@dashboard.persisted? ? dashboard_path(@dashboard, variable_params) : dashboards_path(variable_params)), html: {id: "app"} do |f| %>
<div class="form-group">
<%= f.label :name %>
<%= f.text_field :name, class: "form-control" %>
@@ -26,7 +26,6 @@
<%= link_to "Delete", dashboard_path(@dashboard), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger"%>
<% end %>
<%= f.submit "Save", class: "btn btn-success" %>
- <%= link_to "Back", :back, class: "btn btn-link" %>
</p>
<% end %>
diff --git a/app/views/blazer/dashboards/show.html.erb b/app/views/blazer/dashboards/show.html.erb
index 1f673223..c1138261 100644
--- a/app/views/blazer/dashboards/show.html.erb
+++ b/app/views/blazer/dashboards/show.html.erb
@@ -1,23 +1,14 @@
<% blazer_title @dashboard.name %>
-<div class="topbar">
- <div class="container">
- <div class="row" style="padding-top: 13px;">
- <div class="col-sm-9">
- <%= render partial: "blazer/nav" %>
- <h3 style="margin: 0; line-height: 34px; display: inline;">
- <%= @dashboard.name %>
- </h3>
- </div>
- <div class="col-sm-3 text-right">
- <%= link_to "Edit", edit_dashboard_path(@dashboard, variable_params), class: "btn btn-info" %>
- </div>
- </div>
+<div class="row">
+ <div class="col-sm-9">
+ <h3 style="line-height: 34px;"><%= @dashboard.name %></h3>
+ </div>
+ <div class="col-sm-3 text-right">
+ <%= link_to "Edit", edit_dashboard_path(@dashboard, variable_params), class: "btn btn-info" %>
</div>
</div>
-<div style="margin-bottom: 60px;"></div>
-
<% if @data_sources.any? { |ds| ds.cache_mode != "off" } %>
<p class="text-muted" style="float: right;">
Some queries may be cached
@@ -25,6 +16,8 @@
</p>
<% end %>
+<hr style="margin-top: 0;" />
+
<%= render partial: "blazer/variables", locals: {action: dashboard_path(@dashboard)} %>
<% @queries.each_with_index do |query, i| %>
diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erb
index 99206b11..71ac9bae 100644
--- a/app/views/blazer/queries/_form.html.erb
+++ b/app/views/blazer/queries/_form.html.erb
@@ -13,10 +13,10 @@
</div>
</div>
<div class="form-group text-right">
- <div class="pull-left" style="margin-top: 9px;">
- <%= link_to "Back", :back %>
+ <div class="pull-left" style="margin-top: 8px;">
+ <a :href="schemaPath" target="_blank" style="margin-right: 40px;">Schema</a>
+ <a :href="docsPath" target="_blank">Docs</a>
</div>
- <a :href="dataSourcePath" target="_blank" style="margin-right: 10px;">Docs</a>
<%= f.select :data_source, Blazer.data_sources.values.select { |ds| q = @query.dup; q.data_source = ds.id; q.editable?(blazer_user) }.map { |ds| [ds.name, ds.id] }, {}, class: ("hide" if Blazer.data_sources.size <= 1), style: "width: 140px;" %>
<div id="tables" style="display: inline-block; width: 250px; margin-right: 10px;">
<select id="table_names" style="width: 240px;" placeholder="Preview table"></select>
@@ -79,8 +79,11 @@
editorHeight: "180px"
},
computed: {
- dataSourcePath: function() {
+ schemaPath: function() {
return Routes.schema_queries_path({data_source: this.dataSource})
+ },
+ docsPath: function() {
+ return Routes.docs_queries_path({data_source: this.dataSource})
}
},
methods: {
diff --git a/app/views/blazer/queries/docs.html.erb b/app/views/blazer/queries/docs.html.erb
index 1cbb211b..9d33c656 100644
--- a/app/views/blazer/queries/docs.html.erb
+++ b/app/views/blazer/queries/docs.html.erb
@@ -1,6 +1,8 @@
-<% blazer_title @data_source.name %>
+<% blazer_title "Docs: #{@data_source.name}" %>
-<h1><%= @data_source.name %></h1>
+<h1 style="margin-top: 0;">Docs: <%= @data_source.name %></h1>
+
+<hr />
<h2>Smart Variables</h2>
@@ -123,28 +125,3 @@
</table>
<p>Use the column name <code>target</code> to draw a line for goals.</p>
-
-<h2>Schema</h2>
-
-<% @schema.each do |table| %>
- <table class="table" style="max-width: 500px;">
- <thead>
- <tr>
- <th colspan="2">
- <%= table[:table] %>
- <% if table[:schema] != "public" %>
- <span class="text-muted" style="font-weight: normal;"><%= table[:schema] %></span>
- <% end %>
- </th>
- </tr>
- </thead>
- <tbody>
- <% table[:columns].each do |column| %>
- <tr>
- <td style="width: 60%;"><%= column[:name] %></td>
- <td class="text-muted"><%= column[:data_type] %></td>
- </tr>
- <% end %>
- </tbody>
- </table>
-<% end %>
diff --git a/app/views/blazer/queries/home.html.erb b/app/views/blazer/queries/home.html.erb
index dcecbf24..ae512985 100644
--- a/app/views/blazer/queries/home.html.erb
+++ b/app/views/blazer/queries/home.html.erb
@@ -1,6 +1,6 @@
<div id="queries">
- <div id="header" style="margin-bottom: 20px;">
- <div class="pull-right">
+ <div id="header">
+ <div class="pull-right" style="line-height: 34px;">
<% if blazer_user %>
<%= link_to "All", root_path, class: !params[:filter] ? "active" : nil, style: "margin-right: 40px;" %>
@@ -8,24 +8,10 @@
<%= link_to "Viewed", root_path(filter: "viewed"), class: params[:filter] == "viewed" ? "active" : nil, style: "margin-right: 40px;" %>
<% end %>
- <%= link_to "Mine", root_path(filter: "mine"), class: params[:filter] == "mine" ? "active" : nil, style: "margin-right: 40px;" %>
+ <%= link_to "Mine", root_path(filter: "mine"), class: params[:filter] == "mine" ? "active" : nil %>
<% end %>
- <div class="btn-group">
- <%= link_to "New Query", new_query_path, class: "btn btn-info" %>
- <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- <span class="caret"></span>
- <span class="sr-only">Toggle Dropdown</span>
- </button>
- <ul class="dropdown-menu">
- <li><%= link_to "Dashboards", dashboards_path %></li>
- <li><%= link_to "Checks", checks_path %></li>
- <li role="separator" class="divider"></li>
- <li><%= link_to "New Dashboard", new_dashboard_path %></li>
- <li><%= link_to "New Check", new_check_path %></li>
- </ul>
- </div>
</div>
- <input type="text" v-model="searchTerm" placeholder="Start typing a query or person" style="width: 300px; display: inline-block;" autofocus=true class="search form-control" />
+ <input type="text" v-model="searchTerm" placeholder="Start typing a query, dashboard, or person" style="width: 300px; display: inline-block;" v-focus class="search form-control" />
</div>
<table class="table">
@@ -147,6 +133,13 @@
return Routes.query_path(item.to_param)
}
}
+ },
+ directives: {
+ focus: {
+ inserted: function (el) {
+ el.focus()
+ }
+ }
}
})
</script>
diff --git a/app/views/blazer/queries/schema.html.erb b/app/views/blazer/queries/schema.html.erb
new file mode 100644
index 00000000..a953747c
--- /dev/null
+++ b/app/views/blazer/queries/schema.html.erb
@@ -0,0 +1,58 @@
+<% blazer_title "Schema: #{@data_source.name}" %>
+
+<h1 style="margin-top: 0;">Schema: <%= @data_source.name %></h1>
+
+<hr />
+
+<div id="header">
+ <input id="search" type="text" placeholder="Start typing a table or column" style="width: 300px; display: inline-block;" class="search form-control" />
+</div>
+
+<% @schema.each do |table| %>
+ <table class="table schema-table">
+ <thead>
+ <tr>
+ <th colspan="2">
+ <%= table[:table] %>
+ <% if table[:schema] != "public" %>
+ <span class="text-muted" style="font-weight: normal;"><%= table[:schema] %></span>
+ <% end %>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <% table[:columns].each do |column| %>
+ <tr>
+ <td style="width: 60%;"><%= column[:name] %></td>
+ <td class="text-muted"><%= column[:data_type] %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+<% end %>
+
+<script>
+ $("#search").on("keyup", function() {
+ var value = $(this).val().toLowerCase()
+ $(".schema-table").filter(function() {
+ // if found in table name, show entire table
+ // if just found in rows, show row
+
+ var found = $(this).find("thead").text().toLowerCase().indexOf(value) > -1
+
+ if (found) {
+ $(this).find("tbody tr").toggle(true)
+ } else {
+ $(this).find("tbody tr").filter(function() {
+ var found2 = $(this).text().toLowerCase().indexOf(value) > -1
+ $(this).toggle(found2)
+ if (found2) {
+ found = true
+ }
+ })
+ }
+
+ $(this).toggle(found)
+ })
+ }).focus()
+</script>
diff --git a/app/views/blazer/queries/show.html.erb b/app/views/blazer/queries/show.html.erb
index ab28dbf0..84e68026 100644
--- a/app/views/blazer/queries/show.html.erb
+++ b/app/views/blazer/queries/show.html.erb
@@ -1,28 +1,19 @@
<% blazer_title @query.name %>
-<div class="topbar">
- <div class="container">
- <div class="row" style="padding-top: 13px;">
- <div class="col-sm-9">
- <%= render partial: "blazer/nav" %>
- <h3 style="margin: 0; line-height: 34px; display: inline;">
- <%= @query.name %>
- </h3>
- </div>
- <div class="col-sm-3 text-right">
- <%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default", disabled: [email protected]?(blazer_user) %>
- <%= link_to "Fork", new_query_path(variable_params.merge(fork_query_id: @query.id, data_source: @query.data_source, name: @query.name)), class: "btn btn-info" %>
+<div class="row">
+ <div class="col-sm-9">
+ <h3 style="line-height: 34px;"><%= @query.name %></h3>
+ </div>
+ <div class="col-sm-3 text-right">
+ <%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default", disabled: [email protected]?(blazer_user) %>
+ <%= link_to "Fork", new_query_path(variable_params.merge(fork_query_id: @query.id, data_source: @query.data_source, name: @query.name)), class: "btn btn-info" %>
- <% if !@error && @success %>
- <%= button_to "Download", run_queries_path(query_id: @query.id, format: "csv"), params: {statement: @statement}, class: "btn btn-primary" %>
- <% end %>
- </div>
- </div>
+ <% if !@error && @success %>
+ <%= button_to "Download", run_queries_path(query_id: @query.id, format: "csv"), params: {statement: @statement}, class: "btn btn-primary" %>
+ <% end %>
</div>
</div>
-<div style="margin-bottom: 60px;"></div>
-
<% if @sql_errors.any? %>
<div class="alert alert-danger">
<ul>
@@ -37,6 +28,10 @@
<p><%= @query.description %></p>
<% end %>
+<% if @bind_vars.any? %>
+ <hr style="margin-top: 0;" />
+<% end %>
+
<%= render partial: "blazer/variables", locals: {action: query_path(@query)} %>
<pre id="code"><code><%= @statement %></code></pre>
@@ -49,7 +44,7 @@
<script>
function showRun(data) {
$("#results").html(data)
- $("#results table").stupidtable().stickyTableHeaders({fixedOffset: 60})
+ $("#results table").stupidtable().stickyTableHeaders({fixedOffset: 0})
}
function showError(message) {
diff --git a/app/views/layouts/blazer/application.html.erb b/app/views/layouts/blazer/application.html.erb
index 6cf09664..c8748d52 100644
--- a/app/views/layouts/blazer/application.html.erb
+++ b/app/views/layouts/blazer/application.html.erb
@@ -17,6 +17,20 @@
<%= csrf_meta_tags %>
</head>
<body>
+ <nav class="navbar navbar-default">
+ <div class="container">
+ <ul class="nav navbar-nav">
+ <li><%= link_to "Blazer", root_path, class: "navbar-brand" %></li>
+ <li><%= link_to "Checks", checks_path %></li>
+ </ul>
+ <ul class="nav navbar-nav navbar-right">
+ <li class="navbar-text" style="font-weight: bold; padding-left: 15px;">Create</li>
+ <li><%= link_to "Query", new_query_path %></li>
+ <li><%= link_to "Dashboard", new_dashboard_path %></li>
+ <li><%= link_to "Check", new_check_path(query_id: @query.try(:id)) %></li>
+ </ul>
+ </div>
+ </nav>
<div class="container">
<%= yield %>
</div>
diff --git a/config/routes.rb b/config/routes.rb
index af586630..b9c94bb7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,13 +4,17 @@ Blazer::Engine.routes.draw do
post :cancel, on: :collection
post :refresh, on: :member
get :tables, on: :collection
+ get :schema, on: :collection
get :docs, on: :collection
end
+
resources :checks, except: [:show] do
get :run, on: :member
end
- resources :dashboards do
+
+ resources :dashboards, except: [:index] do
post :refresh, on: :member
end
+
root to: "queries#home"
end