{% extends '_base.html' %}
{% load helpers %}

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

{% block header %}
    <div class="row">
        <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>
    {% if perms.dcim.change_devicetype or perms.dcim.delete_devicetype %}
        <div class="pull-right">
            {% 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:devicetype_add_consoleport' pk=devicetype.pk %}">Console Ports</a></li>{% endif %}
                        {% if perms.dcim.add_consoleserverporttemplate %}<li><a href="{% url 'dcim:devicetype_add_consoleserverport' pk=devicetype.pk %}">Console Server Ports</a></li>{% endif %}
                        {% if perms.dcim.add_powerporttemplate %}<li><a href="{% url 'dcim:devicetype_add_powerport' pk=devicetype.pk %}">Power Ports</a></li>{% endif %}
                        {% if perms.dcim.add_poweroutlettemplate %}<li><a href="{% url 'dcim:devicetype_add_poweroutlet' pk=devicetype.pk %}">Power Outlets</a></li>{% endif %}
                        {% if perms.dcim.add_interfacetemplate %}<li><a href="{% url 'dcim:devicetype_add_interface' pk=devicetype.pk %}">Interfaces</a></li>{% endif %}
                        {% if perms.dcim.add_frontporttemplate %}<li><a href="{% url 'dcim:devicetype_add_frontport' pk=devicetype.pk %}">Front Ports</a></li>{% endif %}
                        {% if perms.dcim.add_rearporttemplate %}<li><a href="{% url 'dcim:devicetype_add_rearport' pk=devicetype.pk %}">Rear Ports</a></li>{% endif %}
                        {% if perms.dcim.add_devicebaytemplate %}<li><a href="{% url 'dcim:devicetype_add_devicebay' pk=devicetype.pk %}">Device Bays</a></li>{% endif %}
                    </ul>
                </div>
                <a href="{% url 'dcim:devicetype_edit' pk=devicetype.pk %}" class="btn btn-warning">
                    <span class="fa fa-pencil" aria-hidden="true"></span>
                    Edit this device type
                </a>
            {% endif %}
          {% if perms.dcim.delete_devicetype %}
              <a href="{% url 'dcim:devicetype_delete' pk=devicetype.pk %}" class="btn btn-danger">
                <span class="fa fa-trash" aria-hidden="true"></span>
                Delete this device type
              </a>
          {% endif %}
        </div>
    {% endif %}
    <h1>{{ devicetype.manufacturer }} {{ devicetype.model }}</h1>
    {% include 'inc/created_updated.html' with obj=devicetype %}
    <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>
        <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
            <a href="{% url 'dcim:devicetype_changelog' pk=devicetype.pk %}">Changelog</a>
        </li>
    </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>
                        {% if devicetype.subdevice_role == True %}
                            <label class="label label-primary">Parent</label>
                        {% elif devicetype.subdevice_role == False %}
                            <label class="label label-info">Child</label>
                        {% 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 }}">{{ devicetype.instances.count }}</a></td>
                </tr>
            </table>
        </div>
    </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|gfm }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
    </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:devicetype_add_consoleport' delete_url='dcim:devicetype_delete_consoleport' %}
        </div>
        <div class="col-md-6">
             {% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' add_url='dcim:devicetype_add_powerport' delete_url='dcim:devicetype_delete_powerport' %}
        </div>
    </div>
{% endif %}
{% 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:devicetype_add_devicebay' delete_url='dcim:devicetype_delete_devicebay' %}
        </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:devicetype_add_consoleserverport' delete_url='dcim:devicetype_delete_consoleserverport' %}
        </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:devicetype_add_poweroutlet' delete_url='dcim:devicetype_delete_poweroutlet' %}
        </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:devicetype_add_interface' delete_url='dcim:devicetype_delete_interface' %}
        </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:devicetype_add_frontport' delete_url='dcim:devicetype_delete_frontport' %}
        </div>
        <div class="col-md-6">
            {% include 'dcim/inc/devicetype_component_table.html' with table=rear_port_table title='Rear Ports' add_url='dcim:devicetype_add_rearport' delete_url='dcim:devicetype_delete_rearport' %}
        </div>
    </div>
{% endif %}
{% endblock %}
