cantino/huginn

View on GitHub
app/views/events/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, (@agent ? @agent.name + "'s " : "") + "Events" -%>

<div class='container'>
  <div class='row'>
    <div class='col-md-12'>
      <div class="page-header">
        <span class='h2'>
          Your Events
          <% if @agent %>
            from <%= @agent.name %>
          <% end %>
        </span>
        <% if @agent %>
          <%= render 'agents/mini_action_menu', agent: @agent, return_to: request.path %>
        <% end %>
      </div>

      <div class='table-responsive'>
        <table class='table table-striped events'>
          <tr>
            <% unless @agent %>
              <th>Source</th>
            <% end %>
            <th>Created</th>
            <th>Payload</th>
            <th></th>
          </tr>

        <% @events.each do |event| %>
          <% next unless event.agent %>
          <%= content_tag :tr, class: (highlighted?(event.id) ? 'hl' : nil) do %>
            <% unless @agent %>
              <td><%= link_to event.agent.name, agent_path(event.agent, return: request.fullpath) %></td>
            <% end %>
            <td title='<%= event.created_at %>'><%= 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 btn-group-xs">
                <%= link_to 'Show', event_path(event, return: request.fullpath), class: "btn btn-default" %>
                <%= 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-default" %>
                <%= link_to 'Delete', event_path(event), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-default" %>
              </div>
            </td>
          <% end %>
        <% end %>
        </table>
      </div>

      <%= paginate @events, params: params.to_unsafe_h.slice(:hl), theme: 'twitter-bootstrap-3' %>

      <br />

      <% if @agent %>
        <div class="btn-group">
          <%= link_to icon_tag('glyphicon-chevron-left') + ' Back'.html_safe, filtered_agent_return_link || agents_path, class: "btn btn-default" %>
          <%= link_to icon_tag('glyphicon-random') + ' See all events'.html_safe, events_path, class: "btn btn-default" %>
        </div>
      <% end %>
    </div>
  </div>
</div>