{% extends "base.html" %}

{% block content %}

  <h4 style="text-align: center;">fHDHR Streams</h4>

  <div class="container">
    <table class="table-medium center action-col">
      <tbody>
	      <tr>
          <th>Status</th>
          <th>Channel</th>
          <th>Method</th>
          <th>Time Active</th>
          <th>Total Downloaded</th>
          <th>Options</th>
          <th>Action</th>
        </tr>

        {% for tuner_dict in tuner_list %}
          <tr>
            <td>{{ tuner_dict["number"] }}</td>
            <td>{{ tuner_dict["status"] }}</td>
            {% if tuner_dict["status"] in ["Active", "Acquired"] %}
              <td>{{ tuner_dict["channel_number"] }}</td>
            {% else %}
              <td>N/A</td>
            {% endif %}
            {% if tuner_dict["status"] == "Active" %}
              <td>{{ tuner_dict["method"] }}</td>
              <td>{{ tuner_dict["play_duration"] }}</td>
              <td>{{ tuner_dict["downloaded"] }}</td>
            {% else %}
              <td>N/A</td>
              <td>N/A</td>
              <td>N/A</td>
            {% endif %}
            <td>
              {% if tuner_dict["status"] != "Inactive" %}
                <button onclick="location.href='/api/tuners?method=close&tuner={{ tuner_dict["number"] }}&redirect=/tuners'" type="button">Close</button>
              {% endif %}
              {% if not tuner_scanning and tuner_dict["status"] == "Inactive" %}
                <button onclick="location.href='/api/tuners?method=scan&tuner={{ tuner_dict["number"] }}&redirect=/tuners'" type="button">Channel Scan</button>
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

{% endblock %}
