Skip to content

Commit

Permalink
Release v6.0.7_patched
Browse files Browse the repository at this point in the history
- Updated Queues.erb to show queue state - non work hours only
- Updated Locales to include new buttons
- Updated API path for queue post call for new actions
  • Loading branch information
jatin-apolloio committed Sep 15, 2022
1 parent e3c5551 commit 833232c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
19 changes: 14 additions & 5 deletions lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,24 @@ def self.set(key, val)

erb(:queue)
end

post "/queues/:name" do
post '/queues/:name' do
queue = Sidekiq::Queue.new(route_params[:name])

if Sidekiq.pro? && params["pause"]
unless Sidekiq.pro?
queue.clear
redirect "#{root_path}queues"
end

if params['pause']
queue.pause!
elsif Sidekiq.pro? && params["unpause"]
elsif params['unpause']
queue.unpause!
else
elsif params['set_non_work_hour']
queue.set_non_work_hour_only!
elsif params['unset_non_work_hour']
queue.unset_non_work_hour_only!
elsif params['delete']
queue.clear
end

Expand Down
3 changes: 3 additions & 0 deletions web/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ en: # <---- change this to your locale code
AddToQueue: Add to queue
AreYouSureDeleteJob: Are you sure you want to delete this job?
AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue?
AreYouSureNonWorkHourQueue: Are you sure? This will pause the queue - %{queue} and will auto resume during non-work hours!
AreYouSureUnpauseNonWorkHourQueue: Are you sure? This will unpause the queue - %{queue} and will start executing immediately!
DeleteQueueTooltip: This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future.
Queues: Queues
Size: Size
Actions: Actions
Expand Down
41 changes: 31 additions & 10 deletions web/views/queues.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
<h3><%= t('Queues') %></h3>

<div class="table_container">
<table class="queues table table-hover table-bordered table-striped table-white">
<style>
.btn-warning {
color: #fff !important;
background-color: #f0ad4e !important;
border-color: #eea236 !important;
background-image: none !important;
}

.btn-warning:hover {
color: #000 !important;
background-image: none !important;
background-color: #ddd !important;
}
</style>
<table class="queues table table-hover table-bordered table-striped">
<thead>
<th><%= t('Queue') %></th>
<th><%= t('Size') %></th>
<th><%= t('Latency') %></th>
<th><%= t('Actions') %></th>
<th class="col-md-3"><%= t('Actions') %></th>
</thead>
<% @queues.each do |queue| %>
<tr>
Expand All @@ -15,21 +28,29 @@
<% if queue.paused? %>
<span class="label label-danger"><%= t('Paused') %></span>
<% end %>
<% if queue.is_non_work_hour_only? %>
<span class="label label-warning">Non Work Hours Only</span>
<% end %>
</td>
<td><%= number_with_delimiter(queue.size) %> </td>
<td><% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> </td>
<td>
<% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> </td>
<td class="delete-confirm">
<form action="<%=root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
<form action="<%= root_path %>queues/<%= CGI.escape(queue.name) %>" method="post">
<%= csrf_tag %>
<input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>" />

<% if Sidekiq.pro? %>
<% if queue.is_non_work_hour_only? %>
<input class="btn btn-warning btn-xs" type="submit" name="unset_non_work_hour" value="Start execution" data-confirm="<%= t('AreYouSureUnpauseNonWorkHourQueue', :queue => h(queue.name)) %>"/>
<% else %>
<input class="btn btn-warning btn-xs" type="submit" name="set_non_work_hour" value="Pause till non-work hours" data-confirm="<%= t('AreYouSureNonWorkHourQueue', :queue => h(queue.name)) %>"/>
<% end %>
<% unless queue.is_non_work_hour_only? %>
<% if queue.paused? %>
<input class="btn btn-danger btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>" />
<input class="btn btn-warning btn-xs" type="submit" name="unpause" value="<%= t('Unpause') %>"/>
<% else %>
<input class="btn btn-danger btn-xs" type="submit" name="pause" value="<%= t('Pause') %>" />
<input class="btn btn-warning btn-xs" type="submit" name="pause" value="<%= t('Pause') %>"/>
<% end %>
<% end %>
<input class="btn btn-danger btn-xs" type="submit" name="delete" title="<%= t('DeleteQueueTooltip') %>" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteQueue', :queue => h(queue.name)) %>"/>
</form>
</td>
</tr>
Expand Down

0 comments on commit 833232c

Please sign in to comment.