Skip to content

Commit

Permalink
Merge pull request #149 from bensheldon/engine_documentation
Browse files Browse the repository at this point in the history
Add documentation for Dashboard Rails::Engine
  • Loading branch information
bensheldon authored Sep 23, 2020
2 parents f57209e + e15a9b3 commit 1e92550
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 10 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
- [`good_job cleanup_preserved_jobs`](#good_job-cleanup_preserved_jobs)
- [Adapter options](#adapter-options)
- [Global options](#global-options)
- [Dashboard](#dashboard)
- [Go deeper](#go-deeper)
- [Exceptions, retries, and reliability](#exceptions-retries-and-reliability)
- [Exceptions](#exceptions)
Expand Down Expand Up @@ -221,6 +222,41 @@ GoodJob.reperform_jobs_on_standard_error = false
GoodJob.on_thread_error = -> (exception) { Raven.capture_exception(exception) }
```
### Dashboard
_🚧 GoodJob's dashboard is a work in progress. Please contribute ideas and code on [Github](https://github.com/bensheldon/good_job/issues)._

GoodJob includes a Dashboard as a mountable `Rails::Engine`.

1. Explicitly require the Engine code at the top of your `config/application.rb` file, immediately after Rails is required. This is necessary because the mountable engine is an optional feature of GoodJob.

```ruby
# config/application.rb
require_relative 'boot'
require 'rails/all'
require 'good_job/engine' # <= Add this line
# ...
```

1. Mount the engine in your `config/routes.rb` file. The following will mount it at `http://example.com/good_job`.

```ruby
# config/routes.rb
# ...
mount GoodJob::Engine => 'good_job'
```

Because jobs can potentially contain sensitive information, you should authorize access. For example, using Devise's `authenticate` helper, that might look like:
```ruby
# config/routes.rb
# ...
authenticate :user, ->(user) { user.admin? } do
mount GoodJob::Engine => 'good_job'
end
```
## Go deeper
### Exceptions, retries, and reliability
Expand Down
31 changes: 21 additions & 10 deletions engine/app/views/layouts/good_job/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,34 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<%= link_to "All jobs", root_path, class: ["nav-link", ("active" if current_page?(root_path))] %>
</li>
<li class="nav-item">
<%= link_to "Upcoming Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
</li>
<li class="nav-item">
<%= link_to "Finished Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
</li>
<li class="nav-item">
<%= link_to "Errored Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
<%= link_to root_path, class: ["nav-link", ("active" if current_page?(root_path))] do %>
All jobs <span class="badge badge-secondary">More views coming soon</span>
<% end %>
</li>

<!-- Coming Soon
<li class="nav-item">
<%= link_to "Upcoming Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
</li>
<li class="nav-item">
<%= link_to "Finished Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
</li>
<li class="nav-item">
<%= link_to "Errored Jobs", 'todo', class: ["nav-link", ("active" if current_page?('todo'))] %>
</li>
-->
</ul>
</div>
</div>
</nav>

<div class="container">
<div class="card border-warning text-dark my-3">
<div class="card-body">
<p class="card-text">🚧 GoodJob's dashboard is a work in progress. Please contribute ideas and code on <a href="https://github.com/bensheldon/good_job/issues" target="_blank" rel="nofollow noopener noreferrer">Github</a>.</p>
</div>
</div>

<%= yield %>
</div>
</body>
Expand Down

0 comments on commit 1e92550

Please sign in to comment.