Skip to content

Commit

Permalink
Use Rails plugin generator and adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
cseelus committed Feb 10, 2021
1 parent 9b9193e commit d53520b
Show file tree
Hide file tree
Showing 22 changed files with 385 additions and 106 deletions.
197 changes: 145 additions & 52 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,170 @@ PATH
remote: .
specs:
crono (1.1.2)
activerecord (>= 4.0)
activesupport (>= 4.0)
rails (>= 4.0)
rspec (>= 3.0)

GEM
remote: https://rubygems.org/
specs:
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
actioncable (6.1.2)
actionpack (= 6.1.2)
activesupport (= 6.1.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.2)
actionpack (= 6.1.2)
activejob (= 6.1.2)
activerecord (= 6.1.2)
activestorage (= 6.1.2)
activesupport (= 6.1.2)
mail (>= 2.7.1)
actionmailer (6.1.2)
actionpack (= 6.1.2)
actionview (= 6.1.2)
activejob (= 6.1.2)
activesupport (= 6.1.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.2)
actionview (= 6.1.2)
activesupport (= 6.1.2)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.2)
actionpack (= 6.1.2)
activerecord (= 6.1.2)
activestorage (= 6.1.2)
activesupport (= 6.1.2)
nokogiri (>= 1.8.5)
actionview (6.1.2)
activesupport (= 6.1.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.2)
activesupport (= 6.1.2)
globalid (>= 0.3.6)
activemodel (6.1.2)
activesupport (= 6.1.2)
activerecord (6.1.2)
activemodel (= 6.1.2)
activesupport (= 6.1.2)
activestorage (6.1.2)
actionpack (= 6.1.2)
activejob (= 6.1.2)
activerecord (= 6.1.2)
activesupport (= 6.1.2)
marcel (~> 0.3.1)
mimemagic (~> 0.3.2)
activesupport (6.1.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
byebug (9.0.6)
concurrent-ruby (1.0.2)
daemons (1.2.4)
diff-lcs (1.2.5)
haml (4.0.7)
tilt
i18n (0.7.0)
minitest (5.9.1)
rack (1.6.5)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (11.3.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.8)
crass (1.0.6)
daemons (1.3.1)
diff-lcs (1.4.4)
erubi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.8)
concurrent-ruby (~> 1.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mini_mime (1.0.2)
minitest (5.14.3)
nio4r (2.5.5)
nokogiri (1.11.1-arm64-darwin)
racc (~> 1.4)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.2)
actioncable (= 6.1.2)
actionmailbox (= 6.1.2)
actionmailer (= 6.1.2)
actionpack (= 6.1.2)
actiontext (= 6.1.2)
actionview (= 6.1.2)
activejob (= 6.1.2)
activemodel (= 6.1.2)
activerecord (= 6.1.2)
activestorage (= 6.1.2)
activesupport (= 6.1.2)
bundler (>= 1.15.0)
railties (= 6.1.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.1.2)
actionpack (= 6.1.2)
activesupport (= 6.1.2)
method_source
rake (>= 0.8.7)
thor (~> 1.0)
rake (13.0.3)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sqlite3 (1.3.12)
thread_safe (0.3.5)
tilt (2.0.5)
timecop (0.8.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0)
timecop (0.9.4)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.2)

PLATFORMS
ruby
arm64-darwin-20

DEPENDENCIES
bundler (>= 1.0.0)
byebug
crono!
daemons
haml
rack-test
rake (>= 10.0)
rspec (>= 3.0)
sinatra
sqlite3
timecop (>= 0.7)

BUNDLED WITH
1.13.6
2.2.7
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,13 @@ There are "start", "stop", and "restart" commands.

## Web UI

Crono comes with a Sinatra application that can display the current state of Crono jobs.
Add `sinatra` and `haml` to your Gemfile

```ruby
gem 'haml'
gem 'sinatra', require: nil
```
Crono can display the current state of Crono jobs.

Add the following to your `config/routes.rb`:

```ruby
Rails.application.routes.draw do
mount Crono::Web, at: '/crono'
mount Crono::Engine, at: '/crono'
...
```

Expand Down
7 changes: 3 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'bundler/gem_tasks'
require "bundler/setup"

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new('spec')
load "rails/tasks/statistics.rake"

task default: :spec
require "bundler/gem_tasks"
6 changes: 6 additions & 0 deletions app/assets/javascripts/crono/materialize.min.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions app/assets/stylesheets/crono/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
nav {
position: relative;
z-index: 2;
}
nav .brand-logo {
font-size: 1.75em;
letter-spacing: -0.05em;
}

main {
position: relative;
z-index: 1;
padding: 20px;
}

main .page-footer {
margin: 0 -20px -20px -20px;
}

.page-footer > .footer-copyright {
padding: 20px;
}

.responsive-overflow {
overflow-x: auto;
}
31 changes: 31 additions & 0 deletions app/assets/stylesheets/crono/materialize.min.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/controllers/crono/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Crono
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
end
11 changes: 11 additions & 0 deletions app/controllers/crono/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Crono
class JobsController < ApplicationController
def index
@jobs = Crono::CronoJob.all
end

def show
@job = Crono::CronoJob.find(params[:id])
end
end
end
54 changes: 54 additions & 0 deletions app/views/crono/jobs/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<header>
<h4>Running Jobs</h4>
</header>

<div class="responsive-overflow">
<table id="job_list">
<tr>
<th>Job</th>
<th>Last performed at</th>
<th>Status</th>
<th></th>
</tr>
<% @jobs.each do |job| %>
<tr>
<td>
<%= job.job_id %>
</td>
<td>
<%= job.last_performed_at || 'Never performed yet' %>
</td>
<td>
<% if job.last_performed_at.nil? %>
<span class="grey-text darken-3" title="This job has never been performed yet.">
<i class="mdi-device-access-time"></i>
Pending
</span>
<% elsif job.healthy %>
<a href="<%= job_path(job) %>">
<span class="green-text darken-3" title="This job was performed successfully.">
<i class="mdi-action-done"></i>
Success
</span>
</a>
<% else %>
<a href="<%= job_path(job) %>">
<span class="red-text" title="There were problems with this job. Follow the link to check the log.">
<i class="mdi-alert-warning"></i>
Error
</span>
</a>
<% end %>
</td>
<td>
<% if job.last_performed_at %>
<a href="<%= job_path(job) %>" class="right">
Log
<i class="mdi-navigation-chevron-right"></i>
</a>
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
17 changes: 17 additions & 0 deletions app/views/crono/jobs/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<header class="blue-grey lighten-4 grey-text text-darken-4">
<a href="<%= root_url %>">
<i class="mdi-navigation-chevron-left"></i>
&lsaquo; Back to Home
</a>
<h4>Last log of <i><%= @job.job_id %></i>:</h4>
</header>
<% if @job.healthy == false %>
<div class="row red-text">
<div class="s12 center-align">
<i class="mdi-alert-warning"></i>
An error occurs during the last execution of this job.
Check the log below for details.
</div>
</div>
<% end %>
<pre class="responsive-overflow"><%= @job.log %></pre>
Loading

0 comments on commit d53520b

Please sign in to comment.