index.html.erb 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <% content_for :title, "Jobs" -%>
  2. <div class='container'>
  3. <div class='row'>
  4. <div class='col-md-12'>
  5. <div class="page-header">
  6. <h2>
  7. Background Jobs
  8. </h2>
  9. </div>
  10. <div class='table-responsive'>
  11. <table class='table table-striped events'>
  12. <tr>
  13. <th>Status</th>
  14. <th>Agent / Job</th>
  15. <th>Created</th>
  16. <th>Next Run</th>
  17. <th>Attempts</th>
  18. <th>Last Error</th>
  19. <th></th>
  20. </tr>
  21. <% @jobs.each do |job| %>
  22. <tr>
  23. <td><%= status(job) %></td>
  24. <td><% case agent = agent_from_job(job)
  25. when Agent
  26. %><%= link_to(agent.name, agent_path(agent)) %><%
  27. when String
  28. %><%= agent %><%
  29. when false
  30. %>(system)<%
  31. when nil
  32. %>(deleted)<%
  33. else
  34. %>(unknown)<%
  35. end %></td>
  36. <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago<% if user = agent.try(:user) %> for <%= user.username %><% end %></td>
  37. <td title='<%= job.run_at %>'>
  38. <% if !job.failed_at %>
  39. <%= relative_distance_of_time_in_words job.run_at %>
  40. <% end %>
  41. </td>
  42. <td><%= job.attempts %></td>
  43. <td>
  44. <a data-toggle="modal" data-target="#error<%= job.id %>"><%= truncate job.last_error, :length => 90, :omission => "", :separator => "\n" %></a>
  45. <div class="modal fade" id="error<%= job.id %>" tabindex="-1" role="dialog" aria-labelledby="#<%= "error#{job.id}" %>" aria-hidden="true">
  46. <div class="modal-dialog big-modal-dialog">
  47. <div class="modal-content">
  48. <div class="modal-header">
  49. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  50. <h4 class="modal-title" id="myModalLabel">Error Backtrace</h4>
  51. </div>
  52. <div class="modal-body">
  53. <pre>
  54. <%= raw html_escape(job.last_error).split("\n").join('<br/>') %>
  55. </pre>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </td>
  61. <td>
  62. <% if (!job.locked_at && !job.locked_by) || job.failed_at.present? %>
  63. <div class="btn-group btn-group-xs" style="float: right">
  64. <% if (job.run_at > Time.now) || job.failed_at.present? %>
  65. <%= link_to 'Run now', run_job_path(job), class: "btn btn-default", method: :put %>
  66. <% end %>
  67. <%= link_to 'Delete', job_path(job), class: "btn btn-danger", method: :delete, data: { confirm: 'Really delete this job?' } %>
  68. </div>
  69. <% end %>
  70. </td>
  71. </tr>
  72. <% end %>
  73. </table>
  74. </div>
  75. <%= paginate @jobs, :theme => 'twitter-bootstrap-3' %>
  76. <br />
  77. <div class="btn-group">
  78. <%= link_to destroy_failed_jobs_path, class: "btn btn-default", method: :delete do %>
  79. <span class="glyphicon glyphicon-trash"></span> Remove failed jobs
  80. <% end %>
  81. <%= link_to retry_queued_jobs_path, class: "btn btn-default", method: :post do %>
  82. <span class="glyphicon glyphicon-refresh"></span> Retry queued jobs
  83. <% end %>
  84. <%= link_to destroy_all_jobs_path, class: "btn btn-default", method: :delete, data: { confirm: "Are you sure you want to delete ALL pending jobs for all Huginn users?" } do %>
  85. <span class="glyphicon glyphicon-remove"></span> Remove all jobs
  86. <% end %>
  87. </div>
  88. </div>
  89. </div>
  90. </div>