<table class="table table-hover">
  <thead>
    <tr>
      <th>
        {% if all_checked %}
          <input type="checkbox" id="selectPage" onClick="select_page(this, {{ targets|length }})" form="grouping-form" checked/>
        {% else %}
          <input type="checkbox" id="selectPage" onClick="select_page(this, {{ targets|length }})" form="grouping-form" />
        {% endif %}
      </th>
      <th>Name</th>
      <th>Type</th>
      {% if request.GET.type == 'SIDEREAL' %}
      <th>RA</th>
      <th>Dec</th>
      {% endif %}
      <th>Observations</th>
      <th>Saved Data</th>
    </tr>
  </thead>
  <tbody>
    {% for target in targets %}
    <tr>
      <td>
        {% if all_checked %}
          <input type="checkbox" name="selected-target" value="{{ target.id }}" onClick="single_select()" form="grouping-form" checked/>
        {% else %}
          <input type="checkbox" name="selected-target" value="{{ target.id }}" onClick="single_select()" form="grouping-form"/>
        {% endif %}
      </td>
      <td>
          <a href="{% url 'targets:detail' target.id %}" title="{{ target.name }}">{{ target.names|join:", " }}</a>
      </td>
      <td>{{ target.get_type_display }}</td>
      {% if request.GET.type == 'SIDEREAL' %}
      <td>{{ target.ra }}</td>
      <td>{{ target.dec }}</td>
      {% endif %}
      <td>{{ target.observationrecord_set.count }}</td>
      <td>{{ target.dataproduct_set.count }}</td>
    </tr>
    {% empty %}
    <tr>
      <td colspan="5">
        {% if authenticated %}
            {% if empty_database and not query_string %}
                There are no targets in the database.
                You might want to <a href="{% url 'tom_targets:create' %}">create a target manually</a>,
                <a href="{% url 'tom_alerts:list' %}">import one from an alert broker</a>
                or
                <form method="POST" action="{% url 'tom_targets:seed' %}" class="d-inline">
                {% csrf_token %}
                <button class="btn btn-outline-primary" type="submit">add the Messier catalog</button>
                </form>
            {% else %}
                No targets match those filters.
            {% endif %}
        {% else %}
            Please <a href="{% url 'login' %}?next={% url 'targets:list' %}">login</a> to view or create targets.
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
