{% extends "allianceauth/base.html" %}
{% load staticfiles %}
{% load i18n %}

{% block page_title %}{% trans "Dashboard" %}{% endblock %}

{% block content %}
    <h1 class="page-header text-center">{% trans "Dashboard" %}</h1>
    {% if user.is_staff %}
        {% include 'allianceauth/admin-status/include.html' %}
    {% endif %}
    <div class="col-sm-12">
        <div class="row vertical-flexbox-row">
            <div class="col-sm-6 text-center">
                <div class="panel panel-primary" style="height:100%">
                    <div class="panel-heading"><h3 class="panel-title">{% trans "Main Character" %}</h3></div>
                    <div class="panel-body">
                        {% if request.user.profile.main_character %}
                        {% with request.user.profile.main_character as main %}
                        <div class="col-lg-4 col-sm-2">
                            <table class="table">
                                <tr>
                                    <td class="text-center"><img class="ra-avatar"
                                                                 src="{{ main.portrait_url_128 }}">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text-center">{{ main.character_name }}</td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-lg-4 col-sm-2">
                            <table class="table">
                                <tr>
                                    <td class="text-center"><img class="ra-avatar"
                                                                 src="https://image.eveonline.com/Corporation/{{ main.corporation_id }}_128.png">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text-center">{{ main.corporation_name }}</td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-lg-4 col-sm-2">
                            {% if main.alliance_id %}
                            <table class="table">
                                <tr>
                                    <td class="text-center"><img class="ra-avatar"
                                                                 src="https://image.eveonline.com/Alliance/{{ main.alliance_id }}_128.png">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text-center">{{ main.alliance_name }}</td>
                                <tr>
                            </table>
                            {% endif %}
                        </div>
                        {% endwith %}
                        {% else %}
                        <div class="alert alert-danger" role="alert">{% trans "No main character set." %}</div>
                        {% endif %}
                        <div class="clearfix"></div>
                        <div class="col-xs-6">
                            <a href="{% url 'authentication:add_character' %}" class="btn btn-block btn-info"
                               title="Add Character">{% trans 'Add Character' %}</a>
                        </div>
                        <div class="col-xs-6">
                            <a href="{% url 'authentication:change_main_character' %}" class="btn btn-block btn-info"
                               title="Change Main Character">{% trans "Change Main" %}</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6 text-center">
                <div class="panel panel-success" style="height:100%">
                    <div class="panel-heading"><h3 class="panel-title">{% trans "Groups" %}</h3></div>
                    <div class="panel-body">
                        <div style="height: 240px;overflow:-moz-scrollbars-vertical;overflow-y:auto;">
                            <table class="table table-striped">
                                {% for group in user.groups.all %}
                                <tr>
                                    <td>{{ group.name }}</td>
                                </tr>
                                {% endfor %}
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="panel panel-default">
            <div class="panel-heading" style="display:flex;"><h3 class="panel-title">{% trans 'Characters' %}</h3></div>
            <div class="panel-body">
                <table class="table table-hover">
                    <tr>
                        <th class="text-center"></th>
                        <th class="text-center">{% trans 'Name' %}</th>
                        <th class="text-center">{% trans 'Corp' %}</th>
                        <th class="text-center">{% trans 'Alliance' %}</th>
                    </tr>
                    {% for ownership in request.user.character_ownerships.all %}
                    {% with ownership.character as char %}
                    <tr>
                        <td class="text-center"><img class="ra-avatar img-circle" src="{{ char.portrait_url_32 }}">
                        </td>
                        <td class="text-center">{{ char.character_name }}</td>
                        <td class="text-center">{{ char.corporation_name }}</td>
                        <td class="text-center">{{ char.alliance_name }}</td>
                    </tr>
                    {% endwith %}
                    {% endfor %}
                </table>
            </div>
        </div>
    </div>
{% endblock %}
