{% extends request.is_ajax|yesno:'bajax.html,base.html' %}
{% load i18n dpagination %}

{% block title %}{% trans 'Devices without group' %}{% endblock %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><span class="glyphicon glyphicon-home"></span></li>
        <li><a href="{% url 'devapp:group_list' %}">{% trans 'Groups' %}</a></li>
        <li class="active">{% trans 'Devices' %}</li>
    </ol>
{% endblock %}

{% block page-header %}
    {% trans 'Devices without group' %}
{% endblock %}

{% block main %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>
                    <a href="{% url 'devapp:devices_null_group' %}?{% url_order_by request order_by='ip_address' %}">
                        {% trans 'Ip address' %}
                    </a>
                    {% if order_by == 'ip_address' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
                </th>
                <th>
                    <a href="{% url 'devapp:devices_null_group' %}?{% url_order_by request order_by='comment' %}">
                        {% trans 'Comment' %}
                    </a>
                    {% if order_by == 'comment' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
                </th>
                <th width="250">
                    <a href="{% url 'devapp:devices_null_group' %}?{% url_order_by request order_by='devtype' %}">
                        {% trans 'Device type' %}
                    </a>
                    {% if order_by == 'devtype' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
                </th>
                <th width="100">Do</th>
            </tr>
            </thead>

            <tbody>
            {% with can_del_dev=perms.devapp.delete_device can_change_dev=perms.devapp.change_device %}
            {% for dev in devices %}
                <tr>
                    <td><a href="{% url 'devapp:view' 0 dev.pk %}">{{ dev.ip_address|default:'-' }}</a></td>
                    <td>{{ dev.comment }}</td>
                    <td>{{ dev.get_devtype_display }}</td>
                    <td class="btn-group btn-group-sm">
                        {% if can_del_dev %}
                            <a href="{% url 'devapp:del' 0 dev.pk %}" class="btn btn-danger btn-modal">
                                <span class="glyphicon glyphicon-remove"></span>
                            </a>
                        {% endif %}
                        {% if can_change_dev %}
                            <a href="{% url 'devapp:edit' 0 dev.pk %}" class="btn btn-default">
                                <span class="glyphicon glyphicon-edit"></span>
                            </a>
                        {% endif %}
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="4">{% trans 'Devices does not found' %}. <a href="{% url 'devapp:add' 0 %}">{% trans 'Create' %}</a></td>
                </tr>
            {% endfor %}
            {% endwith %}
            </tbody>

            <tfoot>
            <tr>
                <td colspan="4">
                    <a href="{% url 'devapp:add' 0 %}" class="btn btn-success btn-sm">
                        <span class="glyphicon glyphicon-plus"></span> {% trans 'Create' %}
                    </a>
                </td>
            </tr>
            </tfoot>

        </table>
    </div>
{% endblock %}
