{% extends 'base.html' %}
{% load project_attributes %}

{% block title %} | Dashboard{% endblock %}

{% block main %}
<div class="page-header">
    <div class="container">
        <h1>Welcome, {{ user.display_name }}.</h1>
    </div>
</div>

<div class="container">
    {% include 'snippets/messages.html' %}

    <div class="row">
        <div class="col-md-8">
            <h3 class="header">
                Manage your projects
                {% if projects %}
                    <a href="{% url 'admin:project_create' %}" class="pull-right btn btn-sm btn-success">
                        <span class="glyphicon glyphicon-plus"></span>
                        Create new Project
                    </a>
                {% endif %}
            </h3>
            {% for project in projects %}
                {% if forloop.first %}
                    <ul class="list-unstyled overview-list">
                {% endif %}

                <li>
                    <h3>
                        {% if project.islocked %}<span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}
                        <a href="{% url 'admin:project_overview' project.id %}">{{ project.name }}</a>
                    </h3>

                    {% if project.description %}<p>{{ project.description }}</p>{% endif %}
                    {% project_attributes project %}
                </li>

                {% if forloop.last %}
                    </ul>
                {% endif %}
            {% empty %}
                <div class="well empty-list">
                    <p class="lead">We couldn't find any projects you are eligible to manage.</p>
                    <p>You can create a new project if you want to start your own map.</p>
                    <a href="{% url 'admin:project_create' %}" class="btn btn-success btn-lg">Create a new project</a>
                </div>
            {% endfor %}
        </div>

        <div class="col-md-4">
            <div class="panel panel-default">
                <div class="list-group">
                    <a class="list-group-item" href="{% url 'admin:app_overview' %}">Your applications</a>
                    {% if user.is_superuser %}<a class="list-group-item" href="{% url 'admin:superusertools_index' %}">Superuser tools</a>{% endif %}
                    <a class="list-group-item" href="{% url 'admin:projects_involved' %}">Other projects</a>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Extensions</h3>
                </div>

                <div class="list-group">
                    {% for extension in extensions %}
                        <a href="{% url extension.index_url %}" class="list-group-item clearfix">
                            {{ extension.name }}
                            {% if extension.version %}<span class="text-muted pull-right">v{{ extension.version }}</span>{% endif %}
                        </a>
                    {% empty %}
                        <div class="list-group-item">
                            No extensions have been installed.
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
