Skip to content

Commit

Permalink
Merge pull request mhfs#41 from tobiassvn/erb
Browse files Browse the repository at this point in the history
Add ERB template for Sidekiq >= 2.14.0.
  • Loading branch information
mhfs committed Sep 5, 2013
2 parents 8496fac + a0cfa21 commit ed74d45
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
60 changes: 60 additions & 0 deletions lib/sidekiq/failures/views/failures.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<header class="row">
<div class="span5">
<h3>Failed Jobs</h3>
</div>
<div class="span4">
<% if @messages.size > 0 %>
<%= erb :_paging, :locals => { :url => "#{root_path}failures#@name" } %>
<% end %>
</div>
</header>

<% if @messages.size > 0 %>
<table class="table table-striped table-bordered table-white" style="width: 100%; margin: 0; table-layout:fixed;">
<thead>
<th style="width: 25%">Worker, Args</th>
<th style="width: 10%">Queue</th>
<th style="width: 15%">Failed At</th>
<th style="width: 50%">Exception</th>
</thead>
<% @messages.each do |msg| %>
<tr>
<td style="overflow: hidden; text-overflow: ellipsis;">
<%= msg['worker'] %>
<br />
<%= msg['payload']['args'].inspect[0..100] %>
</td>
<td><%= msg['queue'] %></td>
<td>
<time datetime="<%= "#{Time.parse(msg['failed_at']).getutc.iso8601}" %>">
<%= msg['failed_at'] %>
</time>
</td>
<td style="overflow: auto; padding: 10px;">
<a class="backtrace" href="#" onclick="$(this).next().toggle(); return false">
<%= msg['exception'] %>: <%= msg['error'] %>
</a>
<pre style="display: none; background: none; border: 0; width: 100%; max-height: 30em; font-size: 0.8em; white-space: nowrap;">
<%= msg['backtrace'].join("<br />") %>
</pre>
<p>
<span>Processor: <%= msg['processor'] %></span>
</p>
</td>
</tr>
<% end %>
</table>
<div class="row">
<div class="span5">
<form class="form-inline" action="<%= "#{root_path}failures/remove" %>" method="post" style="margin: 20px 0">
<input class="btn btn-danger btn-small" type="submit" name="delete" value="Clear All" />
<label class="checkbox">
<input type="checkbox" name="counter" value="true" />
reset failed counter
</label>
</form>
</div>
</div>
<% else %>
<div class="alert alert-success">No failed jobs found.</div>
<% end %>
6 changes: 5 additions & 1 deletion lib/sidekiq/failures/web_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def self.registered(app)
(@current_page, @total_size, @messages) = page("failed", params[:page], @count)
@messages = @messages.map { |msg| Sidekiq.load_json(msg) }

render(:slim, File.read(File.join(view_path, "failures.slim")))
if Sidekiq::VERSION < "2.14.0"
render(:slim, File.read(File.join(view_path, "failures.slim")))
else
render(:erb, File.read(File.join(view_path, "failures.erb")))
end
end

app.post "/failures/remove" do
Expand Down

0 comments on commit ed74d45

Please sign in to comment.