Skip to content

Commit

Permalink
Blazer: add gem to app, configure, routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Sep 8, 2023
1 parent 279b0c0 commit c34940f
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ gem 'jquery-rails'
gem "devise", "4.7.3"
gem 'devise-bootstrap-views', '~> 1.0'
gem 'devise-guests', '~> 0.6'
gem 'devise_invitable', '~> 2.0.0'

# Reporting
gem 'blazer'

gem 'haml'
gem 'chronic'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ GEM
jquery-rails
rails (>= 3.0)
tether-rails
blazer (2.6.5)
activerecord (>= 5)
chartkick (>= 3.2)
railties (>= 5)
safely_block (>= 0.1.1)
bootsnap (1.9.4)
msgpack (~> 1.0)
bootstrap (4.6.2)
Expand Down Expand Up @@ -214,6 +219,7 @@ GEM
activesupport (>= 4.0.0)
mime-types (>= 1.16)
ssrf_filter (~> 1.0, < 1.1.0)
chartkick (5.0.4)
chosen-rails (1.10.0)
coffee-rails (>= 3.2)
railties (>= 3.0)
Expand Down Expand Up @@ -621,6 +627,7 @@ GEM
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
safely_block (0.4.0)
sanitize (6.0.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -761,6 +768,7 @@ DEPENDENCIES
blacklight (~> 7.33.0)
blacklight_advanced_search!
blacklight_range_limit (~> 7.0.0)
blazer
bootsnap (~> 1.9.3)
bootstrap (~> 4.0)
byebug
Expand All @@ -775,6 +783,7 @@ DEPENDENCIES
devise (= 4.7.3)
devise-bootstrap-views (~> 1.0)
devise-guests (~> 0.6)
devise_invitable (~> 2.0.0)
dotenv-rails
down (~> 5.0)
exception_notification (~> 4.4.0)
Expand Down
26 changes: 26 additions & 0 deletions app/views/layouts/blazer/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title><%= blazer_title ? blazer_title : "Blazer" %></title>

<meta charset="utf-8" />

<%= favicon_link_tag "blazer/favicon.png" %>
<%= stylesheet_link_tag "blazer/application" %>
<%= javascript_include_tag "blazer/application" %>
<script>
<%= blazer_js_var "rootPath", root_path %>
</script>
<% if blazer_maps? %>
<%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css", integrity: "sha384-vxzdEt+wZRPNQbhChjmiaFMLWg86IGuq1NGDehJHsD2mphYkxXll/eSs16WWi6Dq", crossorigin: "anonymous" %>
<%= javascript_include_tag "https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js", integrity: "sha384-CTBEiDLiZJ8gkAQ3fYGoeiRp81/ecNiBkGz11jXFALOZ6++rbnqmdo6OImkmr1MO", crossorigin: "anonymous" %>
<% end %>
<%= csrf_meta_tags %>
</head>
<body style="padding:0; !important">
<%= render "shared/navbar_blazer" %>
<div class="container">
<%= yield %>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions app/views/shared/_navbar_blazer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<nav class="navbar navbar-default" style="border-bottom: 1px solid #CCC; box-shadow: 0 10px 16px 0 rgb(0 0 0 / 10%); margin-bottom: 2rem;">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<strong style="color:black;">GBL♦Admin</strong>
</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<%= link_to "Blazer &middot; Business Intelligence Tools".html_safe, '/blazer', {class: 'nav-link'} if current_user %>
</li>
</ul>
</div>
</div>
</nav>
79 changes: 79 additions & 0 deletions config/blazer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# see https://github.com/ankane/blazer for more info

data_sources:
main:
url: <%= ENV["BLAZER_DATABASE_URL"] %>

# statement timeout, in seconds
# none by default
# timeout: 15

# caching settings
# can greatly improve speed
# off by default
# cache:
# mode: slow # or all
# expires_in: 60 # min
# slow_threshold: 15 # sec, only used in slow mode

# wrap queries in a transaction for safety
# not necessary if you use a read-only user
# true by default
# use_transaction: false

smart_variables:
# zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
# period: ["day", "week", "month"]
# status: {0: "Active", 1: "Archived"}

linked_columns:
# user_id: "/admin/users/{value}"

smart_columns:
# user_id: "SELECT id, name FROM users WHERE id IN {value}"

# create audits
audit: true

# change the time zone
# time_zone: "Pacific Time (US & Canada)"

# class name of the user model
# user_class: User

# method name for the current user
# user_method: current_user

# method name for the display name
# user_name: name

# custom before_action to use for auth
# before_action_method: require_admin

# email to send checks from
# from_email: [email protected]

# webhook for Slack
# slack_webhook_url: <%= ENV["BLAZER_SLACK_WEBHOOK_URL"] %>

check_schedules:
- "1 day"
- "1 hour"
- "5 minutes"

# enable anomaly detection
# note: with trend, time series are sent to https://trendapi.org
# anomaly_checks: prophet / trend / anomaly_detection

# enable forecasting
# note: with trend, time series are sent to https://trendapi.org
# forecasting: prophet / trend

# enable map
mapbox_access_token: <%= ENV["MAPBOX_ACCESS_TOKEN"] %>

# enable uploads
uploads:
url: <%= ENV["BLAZER_DATABASE_URL"] %>
schema: blazer_uploads
data_source: main
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@
mount ActionCable.server => "/cable"

# @TODO
# authenticate :user, ->(user) { user } do
# mount Blazer::Engine, at: "blazer"
# end
authenticate :user, ->(user) { user } do
mount Blazer::Engine, at: "blazer"
end
end

# Blog redirects
Expand Down

0 comments on commit c34940f

Please sign in to comment.