{% extends 'base.html' %}

{% block headtitle %}Sources{% endblock %}

{% block content %}
<div class="row">
  <div class="col s12">
    <h1 class="truncate">Sources</h1>
  </div>
</div>
{% include 'infobox.html' with message=message %}
<div class="row">
  <div class="col m12 xl4 margin-bottom">
    <a href="{% url 'sync:validate-source' source_type='youtube-channel' %}" class="btn">Add a YouTube channel <i class="fab fa-youtube"></i></a>
  </div>
  <div class="col m12 xl4 margin-bottom">
    <a href="{% url 'sync:validate-source' source_type='youtube-channel-id' %}" class="btn">Add a YouTube channel by ID <i class="fab fa-youtube"></i></a>
  </div>
  <div class="col m12 xl4 margin-bottom">
    <a href="{% url 'sync:validate-source' source_type='youtube-playlist' %}" class="btn">Add a YouTube playlist <i class="fab fa-youtube"></i></a>
  </div>
</div>
<div class="row no-margin-bottom">
  <div class="col s12">
    <div class="collection">
    {% for source in sources %}
      <a href="{% url 'sync:source' pk=source.pk %}" class="collection-item">
        {{ source.icon|safe }} <strong>{{ source.name }}</strong> ({{ source.get_source_type_display }} &quot;{{ source.key }}&quot;)<br>
        {{ source.format_summary }}<br>
        {% if source.has_failed %}
        <span class="error-text"><i class="fas fa-exclamation-triangle"></i> <strong>Source has permanent failures</strong></span>
        {% else %}
        <strong>{{ source.media_count }}</strong> media items, <strong>{{ source.downloaded_count }}</strong> downloaded{% if source.delete_old_media and source.days_to_keep > 0 %}, keeping {{ source.days_to_keep }} days of media{% endif %}
        {% endif %}
      </a>
    {% empty %}
      <span class="collection-item no-items"><i class="fas fa-info-circle"></i> You haven't added any sources.</span>
    {% endfor %}
    </div>
  </div>
</div>
{% include 'pagination.html' with pagination=sources.paginator %}
{% endblock %}
