dj_mon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +51 -0
- data/app/assets/javascripts/dj_mon.js +11 -1
- data/app/assets/stylesheets/dj_mon.css.scss +10 -0
- data/app/controllers/dj_mon/{delayed_jobs_controller.rb → dj_reports_controller.rb} +9 -6
- data/app/models/dj_mon/dj_report.rb +75 -0
- data/app/views/dj_mon/{delayed_jobs → dj_reports}/index.html.haml +7 -7
- data/app/views/layouts/dj_mon.html.haml +12 -1
- data/config/routes.rb +3 -2
- metadata +7 -6
- data/README.rdoc +0 -14
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# DJ Mon
|
2
|
+
|
3
|
+
A Rails engine based frontend for Delayed Job.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dj_mon'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dj_mon
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
If you are using Rails =< 3.1, or if `config.assets.initialize_on_precompile` is set to false, then add this to `config/environments/production.rb`.
|
22
|
+
|
23
|
+
config.assets.precompile += %w( dj_mon.js dj_mon.css)
|
24
|
+
|
25
|
+
Mount it in `routes.rb`
|
26
|
+
|
27
|
+
mount DjMon::Engine => 'dj_mon'
|
28
|
+
|
29
|
+
This uses http basic auth for authentication. Set the credentials in an initializer - `config/initializers/dj_mon.rb`
|
30
|
+
|
31
|
+
YourApp::Application.config.dj_mon.username = "dj_mon"
|
32
|
+
YourApp::Application.config.dj_mon.password = "password"
|
33
|
+
|
34
|
+
If the credentials are not set, then the username and password are assumed to be the above mentioned.
|
35
|
+
|
36
|
+
Now visit `http://localhost:3000/dj_mon` and profit!
|
37
|
+
|
38
|
+
## ROADMAP
|
39
|
+
|
40
|
+
* Filter by queue.
|
41
|
+
* Option to periodically auto refresh views.
|
42
|
+
* `rake` tasks to know job status from command line.
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
@@ -10,16 +10,26 @@ $(function(){
|
|
10
10
|
var dataUrl = tabContent.data('url');
|
11
11
|
|
12
12
|
$.getJSON(dataUrl).success(function(data){
|
13
|
-
var template = $('#
|
13
|
+
var template = $('#dj_reports_template').html();
|
14
14
|
if(data.length > 0)
|
15
15
|
var output = Mustache.render(template, data);
|
16
16
|
else
|
17
17
|
var output = "<div class='alert alert-info centered'>No Jobs</div>";
|
18
18
|
tabContent.html(output);
|
19
19
|
});
|
20
|
+
|
20
21
|
})
|
21
22
|
|
22
23
|
$('.nav.nav-tabs li.active a[data-toggle="tab"]').trigger('shown');
|
23
24
|
|
25
|
+
(function refreshCount() {
|
26
|
+
$.getJSON('/dj_mon/dj_reports/dj_counts/').success(function(data){
|
27
|
+
var template = $('#dj_counts_template').html();
|
28
|
+
var output = Mustache.render(template, data);
|
29
|
+
$('#dj-counts-view').html(output);
|
30
|
+
setTimeout(refreshCount, 5000);
|
31
|
+
});
|
32
|
+
})();
|
33
|
+
|
24
34
|
})
|
25
35
|
|
@@ -1,28 +1,31 @@
|
|
1
1
|
module DjMon
|
2
|
-
class
|
2
|
+
class DjReportsController < ActionController::Base
|
3
3
|
respond_to :json
|
4
4
|
layout 'dj_mon'
|
5
5
|
|
6
6
|
before_filter :authenticate
|
7
7
|
|
8
8
|
def index
|
9
|
-
@delayed_jobs = []
|
10
9
|
end
|
11
10
|
|
12
11
|
def all
|
13
|
-
respond_with
|
12
|
+
respond_with DjReport.all
|
14
13
|
end
|
15
14
|
|
16
15
|
def failed
|
17
|
-
respond_with
|
16
|
+
respond_with DjReport.failed
|
18
17
|
end
|
19
18
|
|
20
19
|
def active
|
21
|
-
respond_with
|
20
|
+
respond_with DjReport.active
|
22
21
|
end
|
23
22
|
|
24
23
|
def queued
|
25
|
-
respond_with
|
24
|
+
respond_with DjReport.queued
|
25
|
+
end
|
26
|
+
|
27
|
+
def dj_counts
|
28
|
+
respond_with DjReport.dj_counts
|
26
29
|
end
|
27
30
|
|
28
31
|
protected
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module DjMon
|
2
|
+
class DjReport
|
3
|
+
attr_accessor :delayed_job
|
4
|
+
|
5
|
+
def initialize delayed_job
|
6
|
+
self.delayed_job = delayed_job
|
7
|
+
end
|
8
|
+
|
9
|
+
def as_json(options={})
|
10
|
+
{
|
11
|
+
id: delayed_job.id,
|
12
|
+
priority: delayed_job.priority,
|
13
|
+
attempts: delayed_job.attempts,
|
14
|
+
queue: delayed_job.queue,
|
15
|
+
last_error: delayed_job.last_error,
|
16
|
+
failed_at: l_date(delayed_job.failed_at),
|
17
|
+
run_at: l_date(delayed_job.run_at),
|
18
|
+
created_at: l_date(delayed_job.created_at)
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
def all_reports
|
25
|
+
reports_for all
|
26
|
+
end
|
27
|
+
|
28
|
+
def failed_reports
|
29
|
+
reports_for failed
|
30
|
+
end
|
31
|
+
|
32
|
+
def active_reports
|
33
|
+
reports_for active
|
34
|
+
end
|
35
|
+
|
36
|
+
def queued_reports
|
37
|
+
reports_for queued
|
38
|
+
end
|
39
|
+
|
40
|
+
def dj_counts
|
41
|
+
{
|
42
|
+
failed: failed.size,
|
43
|
+
active: active.size,
|
44
|
+
queued: queued.size
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def all
|
49
|
+
Delayed::Job.all
|
50
|
+
end
|
51
|
+
|
52
|
+
def failed
|
53
|
+
Delayed::Job.where('delayed_jobs.failed_at IS NOT NULL')
|
54
|
+
end
|
55
|
+
|
56
|
+
def active
|
57
|
+
Delayed::Job.where('delayed_jobs.locked_by IS NOT NULL')
|
58
|
+
end
|
59
|
+
|
60
|
+
def queued
|
61
|
+
Delayed::Job.where('delayed_jobs.failed_at IS NULL AND delayed_jobs.locked_by IS NULL')
|
62
|
+
end
|
63
|
+
|
64
|
+
def reports_for jobs
|
65
|
+
jobs.collect { |job| DjReport.new(job) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def l_date date
|
72
|
+
date.present? ? I18n.l(date) : ""
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -12,13 +12,13 @@
|
|
12
12
|
= link_to "Active", "#active", "data-toggle" => "tab"
|
13
13
|
|
14
14
|
.tab-content
|
15
|
-
.tab-pane#all.active{ 'data-url' =>
|
16
|
-
.tab-pane#failed{ 'data-url'=>
|
17
|
-
.tab-pane#active{ 'data-url'=>
|
18
|
-
.tab-pane#queued{ 'data-url'=>
|
15
|
+
.tab-pane#all.active{ 'data-url' => all_dj_reports_url }
|
16
|
+
.tab-pane#failed{ 'data-url'=> failed_dj_reports_url }
|
17
|
+
.tab-pane#active{ 'data-url'=> active_dj_reports_url }
|
18
|
+
.tab-pane#queued{ 'data-url'=> queued_dj_reports_url }
|
19
19
|
|
20
|
-
%script#
|
21
|
-
%table.table.table-striped
|
20
|
+
%script#dj_reports_template{ :type=> "text/x-handlebars-template" }
|
21
|
+
%table.table.table-striped
|
22
22
|
%thead
|
23
23
|
%tr
|
24
24
|
%th
|
@@ -56,4 +56,4 @@
|
|
56
56
|
{{job.run_at}}
|
57
57
|
%td.date
|
58
58
|
{{created_at}}
|
59
|
-
{{/.}}
|
59
|
+
{{/.}}
|
@@ -9,9 +9,20 @@
|
|
9
9
|
.navbar.navbar-fixed-top
|
10
10
|
.navbar-inner
|
11
11
|
.container
|
12
|
-
|
12
|
+
.pull-left
|
13
|
+
= link_to "DJ Mon", dj_reports_url, class: "brand"
|
14
|
+
.pull-right
|
15
|
+
#dj-counts-view
|
13
16
|
|
14
17
|
.container
|
15
18
|
= yield
|
16
19
|
|
17
20
|
= javascript_include_tag "dj_mon.js"
|
21
|
+
|
22
|
+
%script#dj_counts_template{ :type=> "text/x-handlebars-template" }
|
23
|
+
%span.badge.badge-warning
|
24
|
+
{{active}} active
|
25
|
+
%span.badge.badge-info
|
26
|
+
{{queued}} queued
|
27
|
+
%span.badge.badge-important
|
28
|
+
{{failed}} failed
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
DjMon::Engine.routes.draw do
|
2
2
|
|
3
|
-
resources :
|
3
|
+
resources :dj_reports, :only=> [ :index ] do
|
4
4
|
collection do
|
5
5
|
get :all
|
6
6
|
get :failed
|
7
7
|
get :active
|
8
8
|
get :queued
|
9
|
+
get :dj_counts
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
|
-
root :to => '
|
13
|
+
root :to => 'dj_reports#index'
|
13
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dj_mon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -101,8 +101,9 @@ files:
|
|
101
101
|
- app/assets/javascripts/dj_mon.js
|
102
102
|
- app/assets/javascripts/mustache.js
|
103
103
|
- app/assets/stylesheets/dj_mon.css.scss
|
104
|
-
- app/controllers/dj_mon/
|
105
|
-
- app/
|
104
|
+
- app/controllers/dj_mon/dj_reports_controller.rb
|
105
|
+
- app/models/dj_mon/dj_report.rb
|
106
|
+
- app/views/dj_mon/dj_reports/index.html.haml
|
106
107
|
- app/views/layouts/dj_mon.html.haml
|
107
108
|
- lib/dj_mon/engine.rb
|
108
109
|
- lib/dj_mon.rb
|
@@ -110,8 +111,8 @@ files:
|
|
110
111
|
- MIT-LICENSE
|
111
112
|
- Rakefile
|
112
113
|
- Gemfile
|
113
|
-
- README.
|
114
|
-
homepage:
|
114
|
+
- README.md
|
115
|
+
homepage: http://portfolio.akshay.cc/dj_mon/
|
115
116
|
licenses: []
|
116
117
|
post_install_message:
|
117
118
|
rdoc_options: []
|
data/README.rdoc
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
= DJ Mon
|
2
|
-
|
3
|
-
A Rails engine based frontend for Delayed Job.
|
4
|
-
|
5
|
-
Coming very soon.
|
6
|
-
|
7
|
-
= Notes
|
8
|
-
|
9
|
-
- app.config.assets.precompile += ['dj_mon.js', 'dj_mon.css'] for apps <= 3.1 or if config.assets.initialize_on_precompile is set to false
|
10
|
-
- gem install dj_mon
|
11
|
-
- mount DjMon::Engine => 'dj_mon'
|
12
|
-
- basic auth using initializers
|
13
|
-
--MyApp::Application.config.dj_mon.username = "foo"
|
14
|
-
--MyApp::Application.config.dj_mon.password = "bar"
|