BathHacked/energy-sparks

View on GitHub
app/views/admin/weather_stations/index.html.erb

Summary

Maintainability
Test Coverage
<h1>Weather Stations</h1>

<p>
The following table lists all of the locations for which we are loading temperature data. For more historical data see <%= link_to "Dark Sky Areas", admin_dark_sky_areas_path %>.
</p>

<% if @weather_stations.any? %>
<table class="table table-sorted">
  <thead>
    <tr>
      <th>Title</th>
      <th>Description</th>
      <th>Location</th>
      <th>Readings</th>
      <th>Earliest date</th>
      <th>Latest date</th>
      <th title="Number of years of historical data to backfill">Backfill Years</th>
      <th title="Is data for this station being loaded?">Loading?</th>
      <th>Actions</th>
    </tr>
  </thead>
  <tbody>
    <% @weather_stations.each do |station| %>
      <tr>
        <td><%= link_to "#{station.title}", data_feeds_weather_observations_path(station.id) %></td>
        <td><%= station.description %></td>
        <td>
          <%= link_to "#{station.latitude}, #{station.longitude}", "https://www.openstreetmap.org/?mlat=#{station.latitude}&mlon=#{station.longitude}", target: "_blank" %>
        <td><%= station.observation_count %></td>
        <td><%= station.first_observation_date %></td>
        <td><%= station.last_observation_date %></td>
        <td><%= station.back_fill_years %></td>
        <td><%= station.active? %></td>
        <td>
          <div class='btn-group'>
            <%= link_to 'Edit', edit_admin_weather_station_path(station), class: 'btn btn-sm' %>
            <%= link_to "Report", data_feeds_weather_observations_path(station.id), class: 'btn btn-sm' %>
            <%= link_to "CSV", data_feeds_weather_observations_path(station.id, format: "csv"), class: 'btn btn-sm' %>
          </div>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<% else %>
  <p>There are no Weather Stations</p>
<% end %>

<%= link_to 'New Weather Station', new_admin_weather_station_path, class: 'btn' %>