cantino/huginn

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

Summary

Maintainability
Test Coverage
<% content_for :title, "Event " + @event.id.to_s -%>

<div class='container'>
  <div class='row'>
    <div class='col-md-12'>
      <div class="page-header">
        <span class='h2'>
          Event from <%= @event.agent.name %>
        </span>
        <%= render 'agents/mini_action_menu', agent: @event.agent, return_to: event_path(@event) %>
      </div>

      <p>
        <b>Expires in:</b>
        <%= @event.expires_at ? time_ago_in_words(@event.expires_at) : 'never' %>
      </p>

      <p>
        <b>Payload:</b>
        <pre><%= Utils.pretty_jsonify @event.payload || {} %></pre>
      </p>

      <% if @event.lat && @event.lng %>
        <% content_for :head do -%>
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=#{@event.agent.options[:api_key]}" %>
<%= javascript_include_tag "map_marker" %>
        <% end -%>

        <p>
          <b>Lat:</b>
          <%= @event.lat %>
          <br/>
          <b>Lng:</b>
          <%= @event.lng %>
        </p>

        <div id="map_canvas" style="width:400px; height:300px"></div>

        <script type="text/javascript">
          var mapOptions = {
            center: new google.maps.LatLng(<%= @event.lat %>, <%= @event.lng %>),
            zoom:15,
            mapTypeId:google.maps.MapTypeId.ROADMAP
          };

          var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

          map_marker(map, <%= Utils.jsonify(@event.location) %>);
        </script>
      <% end %>

      <br />
      <div class="btn-group">
        <%= link_to icon_tag('glyphicon-chevron-left') + ' Back'.html_safe, filtered_agent_return_link || events_path, class: "btn btn-default" %>
        <%= link_to icon_tag('glyphicon-refresh') + ' 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 icon_tag('glyphicon-remove', class: 'color-danger') + ' Delete', event_path(@event), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-default" %>
      </div>
    </div>
  </div>
</div>