<div class='container'>
  <div class='row'>
    <div class='span12'>
      <div class="page-header">
        <h2>
          Your Events <%= @agent && "from #{@agent.name}" %>
        </h2>
      </div>

      <table class='table table-striped events'>
        <tr>
          <th>Source</th>
          <th>Created</th>
          <th>Payload</th>
          <th></th>
        </tr>

      <% @events.each do |event| %>
        <% next unless event.agent %>
        <tr>
          <td><%= link_to event.agent.name, agent_path(event.agent) %></td>
          <td><%= time_ago_in_words event.created_at %> ago</td>
          <td class='payload'><%= truncate event.payload.to_json, :length => 90, :omission => "" %></td>
          <td>
            <div class="btn-group">
              <%= link_to 'Show', event_path(event), class: "btn btn-mini" %>
              <%= link_to 'Re-emit', reemit_event_path(event), method: :post, data: { confirm: 'Are you sure you want to duplicate this event and emit the new one now?' }, class: "btn btn-mini" %>
              <%= link_to 'Delete', event_path(event), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-mini" %>
            </div>
          </td>
        </tr>
      <% end %>
      </table>

      <%= paginate @events, :theme => 'twitter-bootstrap' %>

      <br />

      <% if @agent %>
        <div class="btn-group">
          <%= link_to '<i class="icon-chevron-left"></i> Back'.html_safe, agents_path, class: "btn" %>
          <%= link_to '<i class="icon-random""></i> See all events'.html_safe, events_path, class: "btn" %>
        </div>
      <% end %>
    </div>
  </div>
</div>

