{% load i18n %}

<div class="list-group">
  <div class="list-group-item">
    <div class="row">
      <div class="col-sm-6">
        <a href="{% url "dashboard.views.store-upload"%}?directory={{ current|urlencode }}"
          class="btn btn-info btn-xs js-hidden">
          {% trans "Upload" %}
        </a>
        <form action="" data-action="{% url "dashboard.views.store-upload-url" %}"
          method="POST" enctype="multipart/form-data" class="no-js-hidden"
          id="store-upload-form">
          {% csrf_token %}
          <input type="hidden" name="current_dir" value="{{ current|urlencode }}"/>
          <input type="hidden" name="next" value="{{ next_url }}"/>
          <div class="input-group" style="max-width: 350px;">
            <span class="input-group-btn" id="store-upload-browse">
              <span class="btn btn-primary btn-xs">
                {% trans "Browse..." %}
              </span>
            </span>
            <input type="text" class="form-control input-tags"
             id="store-upload-filename"/>
            <span class="input-group-btn">
              <button type="submit" class="btn btn-primary btn-xs" disabled>
                <i class="fa fa-cloud-upload"></i> {% trans "Upload" %}
              </button>
            </span>
          </div>
          <input id="store-upload-file" name="data" type="file" style="display:none">
        </form>
      </div><!-- .col-sm-6 upload -->

      <div class="col-sm-6">
        <a href="{% url "dashboard.views.store-remove" %}?path={{ current|urlencode }}"
          class="btn btn-danger btn-xs pull-right store-action-button"
          title="{% trans "Remove directory" %}">
          <i class="fa fa-times"></i>
        </a>
        <a href="{% url "dashboard.views.store-download" %}?path={{ current|urlencode }}"
          class="btn btn-primary btn-xs pull-right store-action-button"
          title="{% trans "Download directory" %}">
          <i class="fa fa-cloud-download"></i>
        </a>

        <form method="POST" action="{% url "dashboard.views.store-new-directory" %}">
          {% csrf_token %}
          <input type="hidden" name="path" value="{{ current }}"/>
          <div class="input-group" style="max-width: 300px;">
            <span class="input-group-addon input-tags" title="{% trans "New directory" %}">
              <i class="fa fa-folder-open"></i>
            </span>
            <input type="text" class="form-control input-tags" name="name"
             placeholder="{% trans "Name "%}" required/>
            <span class="input-group-btn">
              <input type="submit" class="btn btn-success btn-xs" value="{% trans "Create" %}"/>
            </span>
          </div>
        </form>
      </div><!-- .col-sm-6 -->
    </div><!-- .row -->
  </div><!-- .list-group-item -->
</div><!-- .list-group -->

<div class="list-group" id="store-list-list">
  <a href="{% url "dashboard.views.store-list" %}?directory={{ up_url|urlencode }}"
    class="list-group-item store-list-item" data-item-type="D">
    {% if current == "/" %}
      <div class="store-list-item-icon">
        <i class="fa fa-refresh" id="store-list-up-icon"></i>
      </div>
      {% trans "Refresh" %}
    {% else %}
      <div class="store-list-item-icon">
        <i class="fa fa-reply" id="store-list-up-icon"></i>
      </div>
      ..
    {% endif %}

    <div class="pull-right">
      {{ current }}
    </div>
  </a>

  {% for f in root %}
  <a class="list-group-item store-list-item" data-item-type="{{ f.TYPE }}"
    href="{% if f.TYPE == "D" %}{% url "dashboard.views.store-list" %}?directory={{ f.path|urlencode }}{% else %}
    {% url "dashboard.views.store-download" %}?path={{ f.path|urlencode }}{% endif %}"
    >
    <div class="store-list-item-icon">
      <i class="
        fa fa-{{ f.icon }}{% if f.TYPE == "D" %} store-list-item-icon-directory{% endif %}"
        ></i>
    </div>
    <div class="store-list-item-name">
      {{ f.NAME }}
    </div>
    <div class="store-list-item-new">
      {% if f.is_new and f.TYPE == "F" %}
        <span class="badge badge-pulse">{% trans "new" %}</span>
      {% endif %}
    </div>

    <div class="store-list-item-size">
      {{ f.human_readable_size }}
    </div>
    <div class="clearfix"></div>
  </a>
  <div class="store-list-file-infos">
    <div class="row">
      <div class="col-sm-10">
        <dl class="dl-horizontal" style="margin: 0; padding: 0;">
          <dt>{% trans "Filename" %}</dt>
          <dd>{{ f.NAME }}</dd>

          <dt>{% trans "Size" %}</dt>
          <dd>{{ f.human_readable_size }}</dd>

          <dt>{% trans "Latest modification" %}</dt>
          <dd>{{ f.human_readable_date }}</dd>
        </dl>
      </div>
      <div class="col-sm-2" style="text-align: right;">
        <a href="{% url "dashboard.views.store-download" %}?path={{ f.path|urlencode }}"
          class="btn btn-primary btn-sm store-download-button">
          <i class="fa fa-download"></i>
          {% trans "Download" %}
        </a>
        <a href="{% url "dashboard.views.store-remove" %}?path={{ f.path|urlencode }}"
          class="btn btn-danger btn-xs store-remove-button">
          <i class="fa fa-times"></i>
          {% trans "Remove" %}
        </a>
      </div>
    </div><!-- .row -->
  </div>
  {% empty %}
  <a class="list-group-item">
    {% trans "This folder is empty." %}
  </a>
  {% endfor %}
</div><!-- closing list-group -->
