{% extends "base.html" %}

{% block title %} | Applications{% endblock %}

{% block main %}
        <div class="page-header">
            <div class="container">
                <h1>Applications</h1>
            </div>
        </div>

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

            <div class="row">
                <div class="col-md-4">
                    <div class="panel panel-default">
                        <div class="list-group">
                            <a href="{% url 'admin:app_overview' %}" class="list-group-item active">Registered applications</a>
                            <a href="{% url 'admin:app_connected' %}" class="list-group-item">Connected applications</a>
                        </div>
                    </div>

                    <div class="alert alert-info">
                        <h5><strong>Learn more about:</strong></h5>
                        <ul>
                            <li><a href="http://geokey.org.uk/help/getting-started-with-oauth.html">How to use OAuth to authenticate users with your application.</a></li>
                            <li><a href="http://geokey.org.uk/docs/">The GeoKey API.</a></li>
                        </ul>
                    </div>
                </div>

                <div class="col-md-8">
                    <h3 class="header">
                        Your registered applications
                        {% if apps %}<a href="{% url 'admin:app_register' %}" class="pull-right btn btn-sm btn-success"><span class="glyphicon glyphicon-plus"></span> Create new application</a>{% endif %}
                    </h3>

                    {% for app in apps %}
                    {% if forloop.first %}
                    <ul class="list-unstyled overview-list">
                    {% endif %}

                    <li>
                        <h3><a href="{% url 'admin:app_settings' app.id %}">{{app.name}}</a></h3>
                        {% if app.description %}<p>{{app.description}}</p>{% endif %}
                        <p class="meta">Client ID: <span class="lower-case">{{ app.client_id }}</span></p>
                        <p class="meta">Client secret: <span class="lower-case">{{ app.client_secret }}</span></p>
                    </li>

                    {% if forloop.last %}
                    </ul>
                    {% endif %}
                    {% empty %}
                        <div class="well empty-list">
                            <p class="lead">You haven't registered an application yet.</p>
                            <p>If you plan to develop an application using our API, developers need to register their application to obtain OAuth security tokens for the applications.</p>
                            <a href="{% url 'admin:app_register' %}" class="btn btn-success btn-lg">Register a new application</a>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
{% endblock %}

{% block libraries %}
            <script src="/static/js/admin.ui.forms.validate.js"></script>
{% endblock %}
