index.html.erb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <div class='container'>
  2. <div class='row'>
  3. <div class='col-md-12'>
  4. <div class="page-header">
  5. <h2>
  6. Background Jobs
  7. </h2>
  8. </div>
  9. <div class='table-responsive'>
  10. <table class='table table-striped events'>
  11. <tr>
  12. <th>Status</th>
  13. <th>Agent</th>
  14. <th>Created</th>
  15. <th>Next Run</th>
  16. <th>Attempts</th>
  17. <th>Last Error</th>
  18. <th></th>
  19. </tr>
  20. <% @jobs.each do |job| %>
  21. <% agent = Agent.find(YAML.load(job.handler).args[0]) %>
  22. <tr>
  23. <td><%= status(job) %></td>
  24. <td><%= link_to agent.name, agent_path(agent) %></td>
  25. <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago for <%= agent.user.username %></td>
  26. <td title='<%= job.run_at %>'>
  27. <% if !job.failed_at %>
  28. <%= relative_distance_of_time_in_words job.run_at %>
  29. <% end %>
  30. </td>
  31. <td><%= job.attempts %></td>
  32. <td>
  33. <a data-toggle="modal" data-target="#error<%= job.id %>"><%= truncate job.last_error, :length => 90, :omission => "", :separator => "\n" %></a>
  34. <div class="modal fade" id="error<%= job.id %>" tabindex="-1" role="dialog" aria-labelledby="#<%= "error#{job.id}" %>" aria-hidden="true">
  35. <div class="modal-dialog big-modal-dialog">
  36. <div class="modal-content">
  37. <div class="modal-header">
  38. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  39. <h4 class="modal-title" id="myModalLabel">Error Backtrace</h4>
  40. </div>
  41. <div class="modal-body">
  42. <pre>
  43. <%= raw html_escape(job.last_error).split("\n").join('<br/>') %>
  44. </pre>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </td>
  50. <td>
  51. <% if (!job.locked_at && !job.locked_by) || job.failed_at.present? %>
  52. <div class="btn-group btn-group-xs" style="float: right">
  53. <% if (job.run_at > Time.now) || job.failed_at.present? %>
  54. <%= link_to 'Run now', run_job_path(job), class: "btn btn-default", method: :put %>
  55. <% end %>
  56. <%= link_to 'Delete', job_path(job), class: "btn btn-danger", method: :delete, data: { confirm: 'Really delete this job?' } %>
  57. </div>
  58. <% end %>
  59. </td>
  60. </tr>
  61. <% end %>
  62. </table>
  63. </div>
  64. <%= paginate @jobs, :theme => 'twitter-bootstrap-3' %>
  65. <br />
  66. <div class="btn-group">
  67. <%= link_to destroy_failed_jobs_path, class: "btn btn-default", method: :delete do %>
  68. <span class="glyphicon glyphicon-trash"></span> Remove failed jobs
  69. <% end %>
  70. </div>
  71. </div>
  72. </div>
  73. </div>