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

{% block content %}
<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 %}
            <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>{% block title %}{{ devicetype.manufacturer }} {{ devicetype.model }}{% endblock %}</h1>
<div class="row">
    <div class="col-md-5">
        <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 }}</td>
                </tr>
                <tr>
                    <td>Part Number</td>
                    <td>
                        {% if devicetype.part_number %}
                            {{ devicetype.part_number }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </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>Interface Ordering</td>
                    <td>{{ devicetype.get_interface_ordering_display }}</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 class="panel panel-default">
            <div class="panel-heading">
                <strong>Function</strong>
            </div>
            <table class="table table-hover panel-body">
                <tr>
                    <td class="text-right">
                        {% if devicetype.is_console_server %}
                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
                        {% else %}
                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
                        {% endif %}
                    </td>
                    <td>
                        <strong>Console Server</strong><br />
                        <small class="text-muted">This device {% if devicetype.is_console_server %}has{% else %}does not have{% endif %} console server ports</small>
                    </td>
                </tr>
                <tr>
                    <td class="text-right">
                        {% if devicetype.is_pdu %}
                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
                        {% else %}
                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
                        {% endif %}
                    </td>
                    <td>
                        <strong>PDU</strong><br />
                        <small class="text-muted">This device {% if devicetype.is_pdu %}has{% else %}does not have{% endif %} power outlets</small>
                    </td>
                </tr>
                <tr>
                    <td class="text-right">
                        {% if devicetype.is_network_device %}
                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
                        {% else %}
                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
                        {% endif %}
                    </td>
                    <td>
                        <strong>Network Device</strong><br />
                        <small class="text-muted">This device {% if devicetype.is_network_device %}has{% else %}does not have{% endif %} non-management network interfaces</small>
                    </td>
                </tr>
                <tr>
                    <td class="text-right">
                        {% 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 %}
                            <label class="label label-default">None</label>
                        {% endif %}
                    </td>
                    <td>
                        <strong>Parent/Child</strong><br />
                        {% if devicetype.subdevice_role == True %}
                            <small class="text-muted">This device has device bays for mounting child devices</small>
                        {% elif devicetype.subdevice_role == False %}
                            <small class="text-muted">This device can only be mounted in a parent device</small>
                        {% else %}
                            <small class="text-muted">This device does not have device bays</small>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% with devicetype.get_custom_fields as custom_fields %}
            {% include 'inc/custom_fields_panel.html' %}
        {% endwith %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body">
                {% if devicetype.comments %}
                    {{ devicetype.comments|gfm }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
    </div>
    <div class="col-md-7">
        {% 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' %}
        {% 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' %}
        {% if devicetype.is_parent_device or devicebay_table.rows %}
            {% 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' %}
        {% endif %}
        {% if devicetype.is_network_device or interface_table.rows %}
            {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' add_url='dcim:devicetype_add_interface' edit_url='dcim:devicetype_bulkedit_interface' delete_url='dcim:devicetype_delete_interface' %}
        {% endif %}
        {% if devicetype.is_console_server or consoleserverport_table.rows %}
            {% 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' %}
        {% endif %}
        {% if devicetype.is_pdu or poweroutlet_table.rows %}
            {% 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' %}
        {% endif %}
    </div>
</div>
{% endblock %}
