{% extends base_template %}

{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block main_panel %}
    <div class="w100 ovhd">
        <h2 class="fleft">{{repo.props.name}} {% trans "'s trash" %}</h2>
        <button data="{% url 'repo' repo.id %}" class="fright" id="back">{% trans "Back to Library" %}</button>
    </div>

    <div class="repo-file-list-outer-container">
        <div class="repo-file-list-inner-container">
            <div class="repo-file-list-topbar">
                <span class="path">
                {% trans "Current path: " %}
		<a href="{% url 'repo_recycle_view' repo.id %}?days={{days}}">{{repo.props.name}} {% trans "'s trash" %}</a>
		{% if not show_recycle_root %}
                    {% for name, link in zipped %}
                        {% if not forloop.last %}
                        / <a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ link|urlencode }}&days={{days}}">{{ name }}</a>
                        {% else %}
                        / {{ name }}
                        {% endif %}
                    {% endfor %}
		{% endif %}
                </span>

		{% if show_recycle_root %}
		<span class="fright">
		    {% if days != 7 %}
		    <a href="{% url 'repo_recycle_view' repo.id %}?days=7">{% trans "a week" %}</a> /
		    {% else %}
		    {% trans "a week" %} /
		    {% endif %}
		    {% if days != 30 %}
		    <a href="{% url 'repo_recycle_view' repo.id %}?days=30">{% trans "a month" %}</a> /
		    {% else %}
		    {% trans "a month" %} /
		    {% endif %}
		    {% if days != 0 %}
		    <a href="{% url 'repo_recycle_view' repo.id %}?days=0">{% trans "all" %}</a>
		    {% else %}
		    {% trans "all" %}
		    {% endif %}
		</span>
		{% endif %}
            </div>
            <!-- /.repo-file-list-topbar -->
            <table class="repo-file-list">
                <tr>
                    <th width="5%"></th>
                    <th width="60%">{% trans "Name" %}</th>
                    <th width="15%">{% trans "Delete Time" %}</th>
                    <th width="10%">{% trans "Size" %}</th>
                    <th width="10%">{% trans "Operations" %}</th>
                </tr>

                {% for dirent in dir_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory" %}" /></td>
                    {% if show_recycle_root %}
                    <td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td>{{ dirent.delete_time|translate_seahub_time }}</td>
                    <td></td>
                    <td><a class="op vh" href="{% url 'repo_revert_dir' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}">{% trans "Restore" %}</a></td>
                    {% else %}
                    <td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    {% endif %}
                </tr>
                {% endfor %}

                {% for dirent in file_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File" %}" /></td>
                    {% if show_recycle_root %}
                    <td><a class="normal" href="{% url 'view_trash_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td>{{ dirent.delete_time|translate_seahub_time }}</td>
                    <td>{{ dirent.file_size|filesizeformat }}</td>
                    <td><a class="op vh" href="{% url 'repo_revert_file' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}&from=recycle">{% trans "Restore" %}</a></td>
                    {% else %}
                    <td><a class="normal" href="{% url 'view_trash_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.props.obj_name }}</a></td>
                    <td></td>
                    <td>{{ dirent.file_size|filesizeformat }}</td>
                    <td></td>
                    {% endif %}
                </tr>
                {% endfor %}
            </table>
        </div>
    </div>
    {% endblock %}

{% block extra_script %}
<script type="text/javascript">
$('#back').click(function() {
    location.href = $(this).attr('data');
});
</script>
{% endblock %}
