Skip to content

Commit

Permalink
Closes sidekiq#1120 Removed slim.
Browse files Browse the repository at this point in the history
  • Loading branch information
Locke23rus committed Aug 21, 2013
1 parent 45de5a4 commit 0a7e8ea
Show file tree
Hide file tree
Showing 35 changed files with 542 additions and 390 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fix more race conditions in Web UI actions
- Don't reset Job enqueued\_at when retrying
- Timestamp tooltips in the Web UI should use UTC
- Removed slim dependency [Locke23rus, #1120]


2.13.1
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
source 'http://rubygems.org'
gemspec

gem 'slim', '1.1.0' # earliest verson supported

gem 'sqlite3', :platform => :mri

group :test do
Expand Down
20 changes: 8 additions & 12 deletions lib/sidekiq/web.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
require 'yaml'
require 'sinatra/base'
require 'slim'

raise "The Sidekiq Web UI requires slim 1.1.0 or greater. You have slim v#{Slim::VERSION}" if Gem::Version.new(Slim::VERSION) < Gem::Version.new('1.1.0')

require 'sidekiq'
require 'sidekiq/api'
Expand All @@ -16,7 +13,6 @@ class Web < Sinatra::Base
set :public_folder, Proc.new { "#{root}/assets" }
set :views, Proc.new { "#{root}/views" }
set :locales, Proc.new { "#{root}/locales" }
set :slim, :pretty => true

helpers do
def strings
Expand Down Expand Up @@ -164,12 +160,12 @@ def redis_keys
end

get "/workers" do
slim :index
erb :index
end

get "/queues" do
@queues = Sidekiq::Queue.all
slim :queues
erb :queues
end

get "/queues/:name" do
Expand All @@ -178,7 +174,7 @@ def redis_keys
@name = params[:name]
(@current_page, @total_size, @messages) = page("queue:#{@name}", params[:page], @count)
@messages = @messages.map {|msg| Sidekiq.load_json(msg) }
slim :queue
erb :queue
end

post "/reset" do
Expand All @@ -200,14 +196,14 @@ def redis_keys
@count = (params[:count] || 25).to_i
(@current_page, @total_size, @retries) = page("retry", params[:page], @count)
@retries = @retries.map {|msg, score| [Sidekiq.load_json(msg), score] }
slim :retries
erb :retries
end

get "/retries/:key" do
halt 404 unless params['key']
@retry = Sidekiq::RetrySet.new.fetch(*parse_params(params['key'])).first
redirect "#{root_path}retries" if @retry.nil?
slim :retry
erb :retry
end

post '/retries' do
Expand Down Expand Up @@ -252,14 +248,14 @@ def redis_keys
@count = (params[:count] || 25).to_i
(@current_page, @total_size, @scheduled) = page("schedule", params[:page], @count)
@scheduled = @scheduled.map {|msg, score| [Sidekiq.load_json(msg), score] }
slim :scheduled
erb :scheduled
end

get "/scheduled/:key" do
halt 404 unless params['key']
@job = Sidekiq::ScheduledSet.new.fetch(*parse_params(params['key'])).first
redirect "#{root_path}scheduled" if @job.nil?
slim :scheduled_job_info
erb :scheduled_job_info
end

post '/scheduled' do
Expand Down Expand Up @@ -296,7 +292,7 @@ def redis_keys
stats_history = Sidekiq::Stats::History.new((params[:days] || 30).to_i)
@processed_history = stats_history.processed
@failed_history = stats_history.failed
slim :dashboard
erb :dashboard
end

get '/dashboard/stats' do
Expand Down
1 change: 0 additions & 1 deletion myapp/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ gem 'sidekiq', :path => '..'
gem 'capistrano'

# sidekiq-web dependencies
gem 'slim', '1.1.0'
gem 'sinatra'

gem 'shotgun'
1 change: 0 additions & 1 deletion sidekiq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Gem::Specification.new do |gem|
gem.add_dependency 'celluloid', '>= 0.14.1'
gem.add_dependency 'json'
gem.add_development_dependency 'sinatra'
gem.add_development_dependency 'slim', '>= 1.1.0'
gem.add_development_dependency 'minitest', '~> 5'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'actionmailer'
Expand Down
76 changes: 76 additions & 0 deletions web/views/_job_info.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<header>
<h3><%= t('Job') %></h3>
</header>

<table class="table table-bordered table-striped">
<tbody>
<tr>
<th><%= t('Queue') %></th>
<td>
<a href="<%= root_path %>queues/<%= job['queue'] %>"><%= job['queue'] %></a>
</td>
</tr>
<tr>
<th><%= t('Class') %></th>
<td>
<code><%= job['class'] %></code>
</td>
</tr>
<tr>
<th><%= t('Arguments') %></th>
<td>
<code>
<!-- We don't want to truncate any job arguments when viewing a single job's status page -->
<div class="args-extended"><%= display_args(job['args'], nil) %></div>
</code>
</td>
</tr>
<tr>
<th>JID</th>
<td>
<code><%= job.jid %></code>
</td>
</tr>
<tr>
<th><%= t('Enqueued') %></th>
<td><%= relative_time(job.enqueued_at) %></td>
</tr>
<% unless retry_extra_items(job).empty? %>
<tr>
<th><%= t('Extras') %></th>
<td>
<code>
<%= retry_extra_items(job).inspect %>
</code>
</td>
</tr>
<% end %>
<% if type == :retry %>
<% if job['retry_count'] && job['retry_count'] > 0 %>
<tr>
<th><%= t('RetryCount') %></th>
<td><%= job['retry_count'] %></td>
</tr>
<tr>
<th><%= t('LastRetry') %></th>
<td><%= relative_time(job['retried_at'].is_a?(Numeric) ? Time.at(job['retried_at']) : Time.parse(job['retried_at'])) %></td>
</tr>
<% else %>
<tr>
<th><%= t('OriginallyFailed') %></th>
<td><%= relative_time(job['failed_at'].is_a?(Numeric) ? Time.at(job['failed_at']) : Time.parse(job['failed_at'])) %></td>
</tr>
<% end %>
<tr>
<th><%= t('NextRetry') %></th>
<td><%= relative_time(job.at) %></td>
</tr>
<% end %>
<% if type == :scheduled %>
<tr>
<th><%= t('Scheduled') %></th>
<td><%= relative_time(job.at) %></td>
</tr>
<% end %>
</tbody>
</table>
51 changes: 0 additions & 51 deletions web/views/_job_info.slim

This file was deleted.

23 changes: 23 additions & 0 deletions web/views/_nav.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="navbar-inner">
<div class="container">
<a class="brand" href="<%= root_path %>"><%= Sidekiq::NAME %></a>
<ul class="nav">
<% tabs.each do |title, url| %>
<% if url == '' %>
<li class="<%= current_path == url ? 'active' : '' %>">
<a href="<%= root_path %><%= url %>"><%= t(title) %></a>
</li>
<% else %>
<li class="<%= current_path.start_with?(url) ? 'active' : '' %>">
<a href="<%= root_path %><%= url %>"><%= t(title) %></a>
</li>
<% end %>
<% end %>
<% custom_tabs.each do |title, url| %>
<li class="<%= current_path.start_with?(url) ? 'active' : '' %>">
<a href="<%= root_path %><%= url %>"><%= t(title) %></a>
</li>
<% end %>
</ul>
</div>
</div>
16 changes: 0 additions & 16 deletions web/views/_nav.slim

This file was deleted.

25 changes: 25 additions & 0 deletions web/views/_paging.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% if @total_size > @count %>
<div class="pagination pagination-right">
<ul>
<li class="<%= 'disabled' if @current_page == 1 %>">
<a href="<%= url %>?page=1">«</a>
</li>
<% if @current_page > 1 %>
<li>
<a href="<%= url %>?page=<%= @current_page - 1 %>"><%= @current_page - 1 %></a>
</li>
<% end %>
<li class="disabled">
<a href="<%= url %>?page=<%= @current_page %>"><%= @current_page %></a>
</li>
<% if @total_size > @current_page * @count %>
<li>
<a href="<%= url %>?page=<%= @current_page + 1 %>"><%= @current_page + 1 %></a>
</li>
<% end %>
<li class="<%= 'disabled' if @total_size <= @current_page * @count %>">
<a href="<%= url %>?page=<%= (@total_size.to_f / @count).ceil %>">»</a>
</li>
</ul>
</div>
<% end %>
15 changes: 0 additions & 15 deletions web/views/_paging.slim

This file was deleted.

4 changes: 4 additions & 0 deletions web/views/_status.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class="status">
<i class="status-sprite status-<%= current_status %>"></i>
<% t(current_status) %>
</span>
3 changes: 0 additions & 3 deletions web/views/_status.slim

This file was deleted.

26 changes: 26 additions & 0 deletions web/views/_summary.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<ul class="unstyled summary row">
<li class="processed span2">
<span class="count"><%= number_with_delimiter(stats.processed) %></span>
<span class="desc"><%= t('Processed') %></span>
</li>
<li class="failed span2">
<span class="count"><%= number_with_delimiter(stats.failed) %></span>
<span class="desc"><%= t('Failed') %></span>
</li>
<li class="busy span2">
<span class="count"><%= number_with_delimiter(workers_size) %></span>
<span class="desc"><%= t('Busy') %></span>
</li>
<li class="scheduled span2">
<span class="count"><%= number_with_delimiter(stats.scheduled_size) %></span>
<span class="desc"><%= t('Scheduled') %></span>
</li>
<li class="retries span2">
<span class="count"><%= number_with_delimiter(stats.retry_size) %></span>
<span class="desc"><%= t('Retries') %></span>
</li>
<li class="enqueued span2">
<span class="count"><%= number_with_delimiter(stats.enqueued) %></span>
<span class="desc"><%= t('Enqueued') %></span>
</li>
</ul>
19 changes: 0 additions & 19 deletions web/views/_summary.slim

This file was deleted.

Loading

0 comments on commit 0a7e8ea

Please sign in to comment.