{#-
 This file is part of Supysonic.
 Supysonic is a Python implementation of the Subsonic server API.

 Copyright (C) 2013-2018 Alban 'spl0k' Féron
               2017-2024 Óscar García Amor

 Distributed under terms of the GNU AGPLv3 license.
-#}
{% extends "layout.html" %}
{% block navbar_playlists %}
<a class="nav-link active" aria-current="page" href="{{ url_for('frontend.playlist_index') }}">Playlists</a>
{% endblock %}
{% block body %}
<h2 class="mt-4 pb-2 border-bottom">Playlist "{{ playlist.name }}"</h2>
{% if playlist.user.id == request.user.id %}
<h3>Edit</h3>
<form method="post">
  <div class="table-responsive">
    <table id="playlist" class="table align-middle">
      <thead>
        <tr><th>Name</th><th>Public</th><th></th></tr>
      </thead>
      <tbody>
        <tr>
          <td><input type="text" class="form-control" name="name" value="{{ playlist.name }}" /></td>
          <td><div class="form-switch"><input type="checkbox" class="form-check-input" role="switch" name="public" {% if playlist.public %}checked="true"{% endif %} /></div></td>
          <td><button class="btn btn-light" type="submit">Update</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</form>
{% endif %}
<h3>Tracks</h3>
<div class="table-responsive">
  <table class="table table-striped">
    <thead>
      <tr><th>Artist</th><th>Title</th><th>Album</th><th>Length</th></tr>
    </thead>
    <tbody>
      {% for t in playlist.get_tracks() %}
      <tr><td>{{ t.album.artist.name }}</td><td>{{ t.title }}</td><td>{{ t.album.name }}</td><td>{{ t.duration_str() }}</td></tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}
