BathHacked/energy-sparks

View on GitHub
app/views/schools/solar_feeds_configuration/_solar_edge_feeds.html.erb

Summary

Maintainability
Test Coverage
<% if solar_edge_installations.any? %>
  <table class="table table-sm">
    <tbody>
      <tr>
        <th>Mpan (or Id)</th>
        <th>Site Id</th>
        <th>API Key</th>
        <th>Last updated</th>
        <th>Actions</th>
      </tr>
      <% solar_edge_installations.each do |installation| %>
        <tr>
          <td><%= link_to installation.mpan, school_solar_edge_installation_path(school, installation) %></td>
          <td><%= installation.site_id %></td>
          <td><%= installation.api_key %></td>
          <td><%= nice_date_times(installation.updated_at) %></td>
          <td>
            <div class="btn-group">
              <%= link_to 'Edit', edit_school_solar_edge_installation_path(school, installation), class: 'btn' %>
              <%= link_to 'Delete', school_solar_edge_installation_path(school, installation), method: :delete, data: { confirm: 'Are you sure? This will delete the meters' }, class: 'btn btn-danger' %>
              <%= link_to "#{fa_icon('circle-question')} Check API".html_safe, check_school_solar_edge_installation_path(school, installation), id: "solar-edge-#{installation.id}-test", method: :post, remote: true, class: 'btn check-button' %>

              <%= form_tag submit_job_school_solar_edge_installation_path(school, installation), method: :post do %>
                <%= button_tag(type: 'submit', id: "solar-edge-#{installation.id}-run-load", class: 'btn') do %>
                  <%= fa_icon('upload') %> Run Loader
                <% end %>
              <% end %>
            </div>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <p>This school has no Solar Edge sites</p>
<% end %>

<p><%= link_to 'New Solar Edge API feed', new_school_solar_edge_installation_path, class: 'btn' %></p>