{% extends 'fittings/base.html' %}
{% load i18n %}
{% load humanize %}
{% load filters %}
{% block extra_css %}
    {% include 'bundles/datatables-css.html' %}
{% endblock %}


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

{% block fittings_block %}
    {% if msg %}
            <div class="alert alert-{{ msg.0 }} alert-dismissible" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="close">
                        <span aria-hidden="true">&times</span>
                    </button>
                    {% if msg.0 != 'warning' %}<h4>{% if msg.0 == 'danger' %}Oh No!{% elif msg.0 == 'success' %}Success!{% endif %}</h4>{% endif %}
                    <p>{{ msg.1 }}</p>
                </div>
        {% endif %}
    <div class="container col-sm-12">
        <h2>
            Doctrine List
        </h2>
        <div class="panel panel-default">
            <div class="panel-heading">
                Doctrines
            </div>
            <div class="panel-body">
                <table class="table table-hover dataTable" id="docTable">
                    <thead>
                        <th> </th>
                        <th>Name</th>
                        <th>Description</th>
                        <th>Ships</th>
                    </thead>
                    <tbody>
                        {% if not docs %}
                            <tr>
                                <td colspan="4">
                                    <div class="alert alert-warning" style="text-align: center"> No Doctrines Found </div>
                                </td>
                            </tr>
                        {% else %}
                            {% for doc in docs %}
                                <tr>
                                    <td> <a href="{% url 'fittings:view_doctrine' doc.pk %}"><img src="{{ doc.icon_url }}" class="img-circle" style="display: block; margin: auto;"/> </a></td>
                                    <td> <a href="{% url 'fittings:view_doctrine' doc.pk %}">{{ doc.name }}</a> </td>
                                    <td> {{ doc.description }} </td>
                                    <td>
                                        {% for fitting in doc_dict|get_item:doc.pk %}
                                            <img src="https://imageserver.eveonline.com/Type/{{ fitting.ship_type_type_id }}_64.png" class="img-circle" style="height: 32px; width: 32px;" data-toggle="tooltip" data-placement="bottom" title="{{ fitting.ship_type.type_name }}"/>
                                        {% endfor %}
                                    </td>
                                </tr>
                            {% endfor %}
                        {% endif %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}

{% block extra_javascript %}
    {% include 'bundles/datatables-js.html' %}
{% endblock %}

{% block extra_script %}
    $(document).ready(function(){
        $('#docTable').DataTable();
        $('[data-toggle="tooltip"]').tooltip();
    })
{% endblock %}
