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

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

 Distributed under terms of the GNU AGPLv3 license.
-#}
{% extends "layout.html" %}
{% block navbar_folders %}
<a class="nav-link active" aria-current="page" href="{{ url_for('frontend.folder_index') }}">Folders</a>
{% endblock %}
{% block body %}
<h2 class="mt-4 pb-2 border-bottom">Music folders</h2>
<div class="table-responsive">
  <table class="table table-striped table-hover align-middle">
    <thead>
      <tr><th>Name</th><th>Path</th><th></th>{% if allow_scan %}<th></th>{% endif %}</tr>
    </thead>
    <tbody>
      {% for folder in folders %}
      <tr>
        <td>{{ folder.name }}</td><td>{{ folder.path }}</td>
        <td><button class="btn btn-outline-danger btn-sm" data-href="{{ url_for('frontend.del_folder', id = folder.id) }}" data-bs-toggle="modal" data-bs-target="#confirm-delete" aria-label="Delete folder">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-square bi-va-fix" aria-hidden="true" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Delete folder" viewBox="0 0 16 16">
              <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>
              <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>
            </svg></button></td>
        {%if allow_scan %}<td><a class="btn btn-outline-secondary btn-sm" href="{{ url_for('frontend.scan_folder', id = folder.id) }}" aria-label="Scan folder">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search bi-va-fix" aria-hidden="true" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Scan folder" viewBox="0 0 16 16">
              <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
            </svg></a></td>{% endif %}
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
<a href="{{ url_for('frontend.add_folder_form') }}" class="btn btn-light">Add new folder</a>
{% if allow_scan %}<a href="{{ url_for('frontend.scan_folder') }}" class="btn btn-light">Scan all folders</a>{% endif %}
<div class="modal fade" id="confirm-delete" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="confirm-delete-label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="confirm-delete-label">Are you sure?</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <p>Are you sure that you want to delete folder?</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Nope</button>
        <a type="button" class="btn btn-danger btn-ok">Yes, delete!</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
