index.html.erb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. <tr>
  22. <td><%= status(job) %></td>
  23. <td><% case agent = agent_from_job(job)
  24. when Agent
  25. %><%= link_to(agent.name, agent_path(agent)) %><%
  26. when false
  27. %>(system)<%
  28. when nil
  29. %>(deleted)<%
  30. else
  31. %>(unknown)<%
  32. end %></td>
  33. <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago<% if user = agent.try(:user) %> for <%= user.username %><% end %></td>
  34. <td title='<%= job.run_at %>'>
  35. <% if !job.failed_at %>
  36. <%= relative_distance_of_time_in_words job.run_at %>
  37. <% end %>
  38. </td>
  39. <td><%= job.attempts %></td>
  40. <td>
  41. <a data-toggle="modal" data-target="#error<%= job.id %>"><%= truncate job.last_error, :length => 90, :omission => "", :separator => "\n" %></a>
  42. <div class="modal fade" id="error<%= job.id %>" tabindex="-1" role="dialog" aria-labelledby="#<%= "error#{job.id}" %>" aria-hidden="true">
  43. <div class="modal-dialog big-modal-dialog">
  44. <div class="modal-content">
  45. <div class="modal-header">
  46. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  47. <h4 class="modal-title" id="myModalLabel">Error Backtrace</h4>
  48. </div>
  49. <div class="modal-body">
  50. <pre>
  51. <%= raw html_escape(job.last_error).split("\n").join('<br/>') %>
  52. </pre>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </td>
  58. <td>
  59. <% if (!job.locked_at && !job.locked_by) || job.failed_at.present? %>
  60. <div class="btn-group btn-group-xs" style="float: right">
  61. <% if (job.run_at > Time.now) || job.failed_at.present? %>
  62. <%= link_to 'Run now', run_job_path(job), class: "btn btn-default", method: :put %>
  63. <% end %>
  64. <%= link_to 'Delete', job_path(job), class: "btn btn-danger", method: :delete, data: { confirm: 'Really delete this job?' } %>
  65. </div>
  66. <% end %>
  67. </td>
  68. </tr>
  69. <% end %>
  70. </table>
  71. </div>
  72. <%= paginate @jobs, :theme => 'twitter-bootstrap-3' %>
  73. <br />
  74. <div class="btn-group">
  75. <%= link_to destroy_failed_jobs_path, class: "btn btn-default", method: :delete do %>
  76. <span class="glyphicon glyphicon-trash"></span> Remove failed jobs
  77. <% end %>
  78. <%= 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 %>
  79. <span class="glyphicon glyphicon-remove"></span> Remove all jobs
  80. <% end %>
  81. </div>
  82. </div>
  83. </div>
  84. </div>