{% extends "base.html" %}

{% block title %}{{ t(key="songs-title", lang=lang | default(value='sk')) }}{% endblock title %}
{% block crumb %}audio/tracks{% endblock crumb %}

{% block content %}
{% if logged_in_admin %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="songs-title", lang=lang | default(value='sk')) }}</h1>
    <p class="term-sub">// {{ tracks | length }} {{ t(key="songs-sub", lang=lang | default(value='sk')) }}</p>
  </div>
  <div class="term-cmd-actions">
    {% if tracks | length > 0 %}
    <button type="button" class="uw-play-album btn btn-primary btn-sm"
      data-tracks-from="#uw-songs-list">{{ t(key="songs-play-all", lang=lang | default(value='sk')) }}</button>
    {% endif %}
    <a href="/audio/albums" class="btn btn-outline btn-sm">[ {{ t(key="songs-albums", lang=lang | default(value='sk')) }} ]</a>
  </div>
</header>

<div class="card">
  <div class="term-head">
    <span class="term-head-name">~/audio/playlist.m3u</span>
    <span class="term-head-meta term-tag is-green">{{ tracks | length }} tracks</span>
  </div>
  <div class="card-body" id="uw-songs-list">
    {% if tracks | length > 0 %}
      {% for track in tracks %}
      <div class="term-track">
        <button type="button" class="uw-play btn btn-primary btn-sm"
          data-src="/audio/tracks/{{ track.id }}/stream" data-title="{{ track.title }}">{{ t(key="audio-play", lang=lang | default(value='sk')) }}</button>
        <span class="term-track-name"><span class="t-green">▸</span> {{ track.title }}</span>
      </div>
      {% endfor %}
    {% else %}
      <p class="term-empty-cmd">{{ t(key="songs-no-tracks", lang=lang | default(value='sk')) }}</p>
    {% endif %}
  </div>
</div>
{% else %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="songs-title", lang=lang | default(value='sk')) }}</h1>
    <p class="term-sub">{{ tracks | length }} {{ t(key="songs-sub", lang=lang | default(value='sk')) }}</p>
  </div>
  <div class="term-cmd-actions">
    {% if tracks | length > 0 %}
    <button type="button" class="uw-play-album btn btn-primary btn-sm"
      data-tracks-from="#uw-songs-list">{{ t(key="songs-play-all", lang=lang | default(value='sk')) }}</button>
    {% endif %}
    <a href="/audio/albums" class="btn btn-outline btn-sm">[ {{ t(key="songs-albums", lang=lang | default(value='sk')) }} ]</a>
  </div>
</header>

<div class="card">
  <div class="term-head">
    <span class="term-head-name">~/audio/playlist.m3u</span>
    <span class="term-head-meta term-tag is-green">{{ tracks | length }} tracks</span>
  </div>
  <div class="card-body" id="uw-songs-list">
    {% if tracks | length > 0 %}
      {% for track in tracks %}
      <div class="term-track">
        <button type="button" class="uw-play btn btn-primary btn-sm"
          data-src="/audio/tracks/{{ track.id }}/stream" data-title="{{ track.title }}">{{ t(key="audio-play", lang=lang | default(value='sk')) }}</button>
        <span class="term-track-name">{{ track.title }}</span>
      </div>
      {% endfor %}
    {% else %}
      <p class="term-empty-cmd">{{ t(key="songs-no-tracks", lang=lang | default(value='sk')) }}</p>
    {% endif %}
  </div>
</div>
{% endif %}
{% endblock content %}
