{% extends 'generic/object.html' %}
{% load helpers %}
{% load humanize %}
{% load plugins %}

{% block title %}{{ object.name }}{% endblock %}

{% block breadcrumbs %}
  {{ block.super }}
  {% if object.manufacturer %}
    <li class="breadcrumb-item">
      <a href="{% url 'plugins:netbox_firmware:firmware_list' %}?manufacturer_id={{ object.manufacturer.id }}">
        {{ object.manufacturer }}
      </a>
    </li>
  {% endif %}
{% endblock %}

{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">Firmware</h5>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">Name</th>
            <td>{{ object.name|placeholder }}</td>
          </tr>

          <tr>
            <th scope="row">Manufacturer</th>
            <td>
            {% if object.manufacturer %}
              <a href="{{ object.manufacturer.get_absolute_url }}">{{ object.manufacturer }}</a>
            {% else %}
              &mdash;
            {% endif %}
            </td>
          </tr>

          <tr>
            <th scope="row">Status</th>
            <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
          </tr>

          <tr>
            <th scope="row">File name</th>
            <td>{{ object.file_name|placeholder }}</td>
          </tr>

          <tr>
            <th scope="row">File</th>
            <td>
              {% if object.file %}
                <a href="{{ object.file.url }}" download>{{ object.file.name }}</a>
              {% else %}
                &mdash;
              {% endif %}
          </tr>
        </table>
      </div>

    <div class="card">
      <h5 class="card-header">Hardware</h5>
      <table class="table table-hover attr-table">

        {% if object.has_device_type %}
          <tr>
            <th scope="row">Device Types</th>
            <td>
              {% for dt in object.device_type.all %}
                <a href="{{ dt.get_absolute_url }}">{{ dt }}</a>{% if not forloop.last %}, {% endif %}
              {% endfor %}
            </td>
          </tr>
        {% elif object.has_module_type %}
          <tr>
            <th scope="row">Module Types</th>
            <td>
              {% for mt in object.module_type.all %}
                <a href="{{ mt.get_absolute_url }}">{{ mt }}</a>{% if not forloop.last %}, {% endif %}
              {% endfor %}
            </td>
          </tr>
        {% else %}
          <tr>
            <th scope="row">Hardware</th>
            <td>&mdash;</td>
          </tr>
        {% endif %}

      </table>
    </div>



      {% include 'inc/panels/custom_fields.html' %}
      {% plugin_left_page object %}
    </div>
    <div class="col col-md-6">
      {% include 'inc/panels/comments.html' %}
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row mb-3">
    <div class="col col-md-12">
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock content %}