{% extends 'base.html' %}
{% load buttons %}
{% load custom_links %}
{% load helpers %}
{% load plugins %}

{% block title %}{{ devicetype.manufacturer }} {{ devicetype.model }}{% endblock %}

{% block header %}
    <div class="row noprint">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li><a href="{% url 'dcim:devicetype_list' %}">Device Types</a></li>
                <li><a href="{% url 'dcim:devicetype_list' %}?manufacturer={{ devicetype.manufacturer.slug }}">{{ devicetype.manufacturer }}</a></li>
                <li>{{ devicetype.model }}</li>
            </ol>
        </div>
    </div>
    <div class="pull-right noprint">
        {% plugin_buttons devicetype %}
        {% if perms.dcim.change_devicetype %}
            <div class="btn-group">
                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Components <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    {% if perms.dcim.add_consoleporttemplate %}<li><a href="{% url 'dcim:consoleporttemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Console Ports</a></li>{% endif %}
                    {% if perms.dcim.add_consoleserverporttemplate %}<li><a href="{% url 'dcim:consoleserverporttemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Console Server Ports</a></li>{% endif %}
                    {% if perms.dcim.add_powerporttemplate %}<li><a href="{% url 'dcim:powerporttemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Power Ports</a></li>{% endif %}
                    {% if perms.dcim.add_poweroutlettemplate %}<li><a href="{% url 'dcim:poweroutlettemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Power Outlets</a></li>{% endif %}
                    {% if perms.dcim.add_interfacetemplate %}<li><a href="{% url 'dcim:interfacetemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Interfaces</a></li>{% endif %}
                    {% if perms.dcim.add_frontporttemplate %}<li><a href="{% url 'dcim:frontporttemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Front Ports</a></li>{% endif %}
                    {% if perms.dcim.add_rearporttemplate %}<li><a href="{% url 'dcim:rearporttemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Rear Ports</a></li>{% endif %}
                    {% if perms.dcim.add_devicebaytemplate %}<li><a href="{% url 'dcim:devicebaytemplate_add' %}?device_type={{ devicetype.pk }}&return_url={{ devicetype.get_absolute_url }}">Device Bays</a></li>{% endif %}
                </ul>
            </div>
        {% endif %}
        {% if perms.dcim.add_devicetype %}
            {% clone_button devicetype %}
        {% endif %}
        {% if perms.dcim.change_devicetype %}
            {% edit_button devicetype use_pk=True %}
        {% endif %}
        {% if perms.dcim.delete_devicetype %}
            {% delete_button devicetype use_pk=True %}
        {% endif %}
    </div>
    <h1>{{ devicetype.manufacturer }} {{ devicetype.model }}</h1>
    {% include 'inc/created_updated.html' with obj=devicetype %}
    <div class="pull-right noprint">
        {% custom_links devicetype %}
    </div>
    <ul class="nav nav-tabs">
        <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
            <a href="{{ devicetype.get_absolute_url }}">Device Type</a>
        </li>
        {% if perms.extras.view_objectchange %}
            <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
                <a href="{% url 'dcim:devicetype_changelog' pk=devicetype.pk %}">Change Log</a>
            </li>
        {% endif %}
    </ul>
{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Chassis</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Manufacturer</td>
                    <td><a href="{% url 'dcim:devicetype_list' %}?manufacturer={{ devicetype.manufacturer.slug }}">{{ devicetype.manufacturer }}</a></td>
                </tr>
                <tr>
                    <td>Model Name</td>
                    <td>
                        {{ devicetype.model }}<br/>
                        <small class="text-muted">{{ devicetype.slug }}</small>
                    </td>
                </tr>
                <tr>
                    <td>Part Number</td>
                    <td>{{ devicetype.part_number|placeholder }}</td>
                </tr>
                <tr>
                    <td>Height (U)</td>
                    <td>{{ devicetype.u_height }}</td>
                </tr>
                <tr>
                    <td>Full Depth</td>
                    <td>
                        {% if devicetype.is_full_depth %}
                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
                        {% else %}
                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Parent/Child</td>
                    <td>
                        {{ devicetype.get_subdevice_role_display|placeholder }}
                    </td>
                </tr>
                <tr>
                    <td>Front Image</td>
                    <td>
                        {% if devicetype.front_image %}
                            <a href="{{ devicetype.front_image.url }}">
                                <img src="{{ devicetype.front_image.url }}" alt="{{ devicetype.front_image.name }}" class="img-responsive" />
                            </a>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Rear Image</td>
                    <td>
                        {% if devicetype.rear_image %}
                            <a href="{{ devicetype.rear_image.url }}">
                                <img src="{{ devicetype.rear_image.url }}" alt="{{ devicetype.rear_image.name }}" class="img-responsive" />
                            </a>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Instances</td>
                    <td><a href="{% url 'dcim:device_list' %}?device_type_id={{ devicetype.pk }}">{{ instance_count }}</a></td>
                </tr>
            </table>
        </div>
        {% plugin_left_page devicetype %}
    </div>
    <div class="col-md-6">
        {% include 'inc/custom_fields_panel.html' with obj=devicetype %}
        {% include 'extras/inc/tags_panel.html' with tags=devicetype.tags.all url='dcim:devicetype_list' %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body rendered-markdown">
                {% if devicetype.comments %}
                    {{ devicetype.comments|render_markdown }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
        {% plugin_right_page devicetype %}
    </div>
</div>
{% if devicetype.consoleport_templates.exists or devicetype.powerport_templates.exists %}
    <div class="row">
        <div class="col-md-6">
            {% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' add_url='dcim:consoleporttemplate_add' edit_url='dcim:consoleporttemplate_bulk_edit' delete_url='dcim:consoleporttemplate_bulk_delete' %}
        </div>
        <div class="col-md-6">
             {% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' add_url='dcim:powerporttemplate_add' edit_url='dcim:powerporttemplate_bulk_edit' delete_url='dcim:powerporttemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
<div class="row">
    <div class="col-md-12">
        {% plugin_full_width_page devicetype %}
    </div>
</div>
{% if devicetype.is_parent_device or devicebay_table.rows %}
    <div class="row">
        <div class="col-md-12">
            {% include 'dcim/inc/devicetype_component_table.html' with table=devicebay_table title='Device Bays' add_url='dcim:devicebaytemplate_add' edit_url=None delete_url='dcim:devicebaytemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
{% if devicetype.consoleserverport_templates.exists %}
    <div class="row">
        <div class="col-md-12">
            {% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' add_url='dcim:consoleserverporttemplate_add' edit_url='dcim:consoleserverporttemplate_bulk_edit' delete_url='dcim:consoleserverporttemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
{% if devicetype.poweroutlet_templates.exists %}
    <div class="row">
        <div class="col-md-12">
            {% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' add_url='dcim:poweroutlettemplate_add' edit_url='dcim:poweroutlettemplate_bulk_edit' delete_url='dcim:poweroutlettemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
{% if devicetype.interface_templates.exists %}
    <div class="row">
        <div class="col-md-12">
            {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' add_url='dcim:interfacetemplate_add' edit_url='dcim:interfacetemplate_bulk_edit' delete_url='dcim:interfacetemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
{% if devicetype.frontport_templates.exists or devicetype.rearport_templates.exists %}
    <div class="row">
        <div class="col-md-6">
            {% include 'dcim/inc/devicetype_component_table.html' with table=front_port_table title='Front Ports' add_url='dcim:frontporttemplate_add' edit_url='dcim:frontporttemplate_bulk_edit' delete_url='dcim:frontporttemplate_bulk_delete' %}
        </div>
        <div class="col-md-6">
            {% include 'dcim/inc/devicetype_component_table.html' with table=rear_port_table title='Rear Ports' add_url='dcim:rearporttemplate_add' edit_url='dcim:rearporttemplate_bulk_edit' delete_url='dcim:rearporttemplate_bulk_delete' %}
        </div>
    </div>
{% endif %}
{% endblock %}
