{% extends "base.html" %}

{% block right_nav %}
    {% if sketches.all() %}
        <form action="{{ url_for('home_views.home') }}" method="post">
            {{ form.name }}
            {{ form.description }}
            <button type="submit" class="btn btn-success"><i class="fa fa-plus"></i>Sketch</button>
            {{ form.csrf_token }}
        </form>
    {% endif %}
{% endblock %}

{% block main %}
    {% if not sketches.all() %}
        <div style="text-align: center">
            <br><br>
            <h3>Welcome to Timesketch</h3>
            <form action="{{ url_for('home_views.home') }}" method="post">
                {{ form.name }}
                {{ form.description }}
                <button type="submit" class="btn btn-success btn-lg"><i class="fa fa-plus"></i>Sketch</button>
                {{ form.csrf_token }}
            </form>
        </div>
    {% else %}
        <div class="card">
            {% if sketches.all() %}
                <div>
                    <ul class="content-list">
                        {% for sketch in sketches.all() %}
                            <li class="content-item" style="padding:15px;">
                                <div class="pull-right" style="margin-top:10px;">
                                    <span style="margin-right:20px;">{{ sketch.user.username }}</span>
                                    <span style="margin-right:10px;"><i class="fa fa-clock-o"></i> {{ sketch.timelines|count }}</span>
                                    <span><i class="fa fa-eye"></i> {{ sketch.get_named_views|count }}</span>
                                </div>
                                <div class="title">
                                    <a style="text-decoration: none; font-weight: 500;font-size: 1.2em;" href="{{ url_for('sketch_views.overview', sketch_id=sketch.id) }}">{{ sketch.name }}</a>
                                    <br>
                                    Last activity {{ sketch.updated_at.strftime('%Y-%m-%d') }}
                                </div>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            {% endif %}
        </div>
    {% endif %}

{% endblock %}
