{% extends "page.html" %}

{% block breadcrumb_content %}
    <li class="active">
        <a href="{{ request.path }}">{{ _("Logs Dashboard") }}</a>
    </li>
{% endblock %}

{% block secondary %}
{% endblock %}

{% block primary %}
    <div class="primary col-12 px-3" role="main">
        {% block page_content %}
        <div class="py-3">
            <div class="p-4 mb-3 bg-light border rounded">
                <p>
                    <strong>{{ _("Log directory") }}:</strong>
                    <span>{{ logs_folder }}</span>
                </p>
                <p class="mb-0">
                    <strong>{{ _("Total size") }}:</strong>
                    <span>{{ (total_size / 1024 / 1024) | round(2) }} MB</span>
                </p>
            </div>

            <div class="logs-actions">
                <a class="btn btn-primary" href="{{ h.url_for('logs.download') }}">
                    <i class="fa fa-download"></i> {{ _("Download All Logs (ZIP)") }}
                </a>
            </div>

            <hr>

            <table class="table table-striped table-bordered mb-0">
                <colgroup>
                    <col style="width: 25%;">
                    <col style="width: 25%;">
                    <col style="width: 25%;">
                    <col style="width: 25%;">
                </colgroup>
                <thead>
                    <tr>
                        <th>{{ _("File Name") }}</th>
                        <th>{{ _("Size") }}</th>
                        <th>{{ _("Last Modified") }}</th>
                        <th>{{ _("Action") }}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for f in logs_files %}
                        <tr>
                            <td>{{ f.name }}</td>
                            <td>{{ h.logs_printable_file_size(logs_sizes[f.name]) }}</td>
                            <td>{{ f.mtime.strftime("%Y-%m-%d %H:%M:%S") }}</td>
                            <td>
                                <a class="btn btn-sm btn-outline-primary"
                                    href="{{ h.url_for('logs.table', table_name='logs', log_file=f.name) }}">
                                    <i class="fa fa-table"></i> {{ _("View") }}
                                </a>

                                <a class="btn btn-sm btn-outline-primary"
                                    href="{{ h.url_for('logs.export_log_file', log_file=f.name) }}">
                                    <i class="fa fa-download"></i> {{ _("Download") }}
                                </a>
                            </td>
                        </tr>
                    {% else %}
                        <tr>
                            <td colspan="4" class="text-center text-muted">{{ _("No log files found.")}}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% endblock page_content %}
    </div>
{% endblock %}
