Commit 27b23403

mo khan <mo@mokhan.ca>
2014-09-24 02:46:47
add retry button to jobs.
1 parent 8b8b6c2
Changed files (4)
app
controllers
views
config
app/controllers/admin/jobs_controller.rb
@@ -13,6 +13,12 @@ module Admin
       @job = @repository.find(params[:id])
     end
 
+    def update
+      @job = @repository.find(params[:id])
+      @job.invoke_job
+      redirect_to admin_jobs_path
+    end
+
     def destroy
       @job = @repository.find(params[:id])
       @job.destroy
app/views/admin/jobs/index.html.erb
@@ -23,14 +23,17 @@
           <tr>
             <td><%= link_to job.id, admin_job_path(job) %></td>
             <td><%= job.attempts %></td>
-            <td><%= job.last_error.present? ? link_to('FAILED', admin_job_path(job)) : 'Succeeded' %></td>
+            <td><%= job.last_error.present? ? link_to('FAILED', admin_job_path(job)) : '' %></td>
             <td><%= job.locked_by %> </td>
             <td><%= job.queue %></td>
             <td><%= time_ago_in_words(job.run_at) if job.run_at %></td>
             <td><%= time_ago_in_words(job.locked_at) if job.locked_at %></td>
             <td><%= time_ago_in_words(job.created_at) %></td>
             <td><%= time_ago_in_words(job.updated_at) %></td>
-            <td><%= link_to "Destroy", admin_job_path(job), method: :delete, class: 'btn btn-danger' %></td>
+            <td>
+              <%= link_to "Retry", admin_job_path(job), method: :put, class: 'btn', disable_with: 'Retrying...' %>
+              <%= link_to "Destroy", admin_job_path(job), method: :delete, class: 'btn btn-danger', disable_with: 'Deleting...' %>
+            </td>
           </tr>
         <% end %>
       </tbody>
app/views/admin/photos/index.html.erb
@@ -7,8 +7,6 @@
     <table class="table table-condensed">
       <thead>
         <tr>
-          <th>id</th>
-          <th>processing</th>
           <th>filename</th>
           <th>content type</th>
           <th>geolocation</th>
@@ -19,9 +17,7 @@
       <tbody>
         <% @photos.each do |photo| %>
           <tr>
-            <td><%= link_to photo.id, admin_photo_path(photo.id) %></td>
-            <td><%= photo.image_processing %></td>
-            <td><%= photo.image %></td>
+            <td><%= link_to photo.image, admin_photo_path(photo.id) %></td>
             <td><%= photo.content_type %></td>
             <td><%= photo.latitude %> <%= photo.longitude %></td>
             <td><%= time_ago_in_words(photo.created_at) %> ago</td>
config/routes.rb
@@ -72,7 +72,7 @@ Cake::Application.routes.draw do
   namespace :admin do
     root :to => "users#index"
     resources :users, only: [:index, :show]
-    resources :jobs, only: [:index, :show, :destroy]
+    resources :jobs, only: [:index, :show, :update, :destroy]
     resources :activities, only: [:index]
     resources :subscriptions, only: [:index]
     resources :photos, only: [:index, :show]