{% extends "lava_scheduler_app/_content.html" %}

{% block breadcrumbs %}
{{ block.super }}
<li><a href="{% url lava_scheduler_app.views.alljobs %}">All Jobs</a></li>
{% endblock %}


{% block content %}
<h2>All Jobs</h2>

<table class="data display">
  <thead>
    <tr>
      <th class="id">ID</th>
      <th>Status</th>
      <th>Device</th>
      <th>Description</th>
      <th>Submitter</th>
      <th>Submit Time</th>
    </tr>
  </thead>
  <tbody>
    {% for job in jobs %}
    <tr>
      <td><a href="{% url lava_scheduler_app.views.job pk=job.pk %}">{{ job.id }}</a></td>
      <td>{{ job.get_status_display }}</td>
      {% if job.actual_device.pk %}
      <td><a href="{% url lava_scheduler_app.views.device pk=job.actual_device.pk %}">
          {{ job.actual_device }}</a></td>
      {% else %}{% if job.requested_device.pk %}
      <td><a href="{% url lava_scheduler_app.views.device pk=job.requested_device.pk %}">
          <i>{{ job.requested_device }}</i></a></td>
      {% else %}
      <td><i>{{ job.requested_device_type|default:'' }}</i></td>
      {% endif %}{% endif %}
      <td>{{ job.description|default:'' }}</td>
      <td>{{ job.submitter }}</td>
      <td>{{ job.submit_time }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>

<script>
$(document).ready(
  function() {
    $("table.data").dataTable({
      "bJQueryUI": true,
      "aoColumnDefs": [
        { "sType": "num-html", "aTargets": [ "id" ] }
      ],
      "aaSorting": [[0, "desc"]],
      "iDisplayLength": 25
    });
  }
);
</script>

{% endblock %}
