{% extends "layout.html" %}
{% from 'macros.html' import alert_dismiss with context %}

{% block content %}
    <br>
    {% if alerta %}
        {{ alert_dismiss(alerta) }}
    {% endif %}
    <div class="container-fluid">
        <div style="display: flex; align-items: center; justify-content: space-between;">
            <span class="float-xs-left"><h4>{{ titulo|safe }}</h4></span>

            {% if file_content|length > 1 %}

            <span class="float-xs-left">
                <a class="btn btn-primary btn-sm"
                   href="{{ url_for('download_file', file_id=file_id, as_attachment=True) }}"
                   download="{{ url_for('download_file', file_id=file_id, as_attachment=True) }}" role="button">
                    <i class="fa fa-download" aria-hidden="true"></i> Download
                </a>
                {% if is_logfile %}
                    <a class="btn btn-danger btn-sm"
                       href="{{ url_for('showfile', delete=True, file=file_id) }}" role="button">
                        <i class="fa fa-trash" aria-hidden="true"></i> Delete
                    </a>
                {% else %}
                    <a class="btn btn-warning btn-sm"
                       href="{{ url_for('editfile', file=file_id) }}" role="button">
                        <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit
                    </a>
                {% endif %}
            </span>
            {% endif %}
        </div>
        {% if subtitulo %}
            <h5 style="word-wrap:break-word; overflow-wrap: break-word;">{{ subtitulo|safe }}</h5>
        {% endif %}
        {% if filename %}
            <h6>Contents of file <code>{{ filename }}</code>:</h6>
        {% endif %}
    </div>
    <div class="container-fluid alert-warning">
        <br>
{#    <div class="container-fluid container-fluid-table">#}
        {% if file_content %}
            <pre>{% for line in file_content %}{% if line|count > 0 %}{{ line|safe }}
            {% endif %}{% endfor %}</pre>
        {% else %}
            <div class="alert alert-danger" role="alert">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                <span class="sr-only">Error:</span>
                File not found!!
            </div>
        {% endif %}
    </div>
{#            <br>#}
{#        <h3>Nuevo acceso a fichero en disco:</h3>#}
{#        <div class="col-lg-6">#}
{#            {% from 'logs/logs_macros.html' import form_filename %}#}
{#            {{ form_filename(False) }}#}
{#        </div>#}
{#    </div>#}
{% endblock %}
