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

{% block content %}
<div class="row">
	<div class="col col-12 col-md-4">
    <div class="card">
      <h2 class="card-header">{% trans "Virtual Chassis" %}</h2>
      <table class="table table-hover attr-table">
        <tr>
          <th scope="row">{% trans "Domain" %}</th>
          <td>{{ object.domain|placeholder }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Master" %}</th>
          <td>{{ object.master|linkify }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Description" %}</th>
          <td>{{ object.description|placeholder }}</td>
        </tr>
        <tr>
          <th scope="row">Members</th>
          <td>
            {% if object.member_count %}
              <a href="{% url 'dcim:device_list' %}?virtual_chassis_id={{ object.pk }}">{{ object.member_count }}</a>
            {% else %}
              {{ object.member_count }}
            {% endif %}
          </td>
        </tr>
      </table>
    </div>
    {% include 'inc/panels/tags.html' %}
    {% include 'inc/panels/custom_fields.html' %}
    {% plugin_left_page object %}
    </div>
    <div class="col col-12 col-md-8">
      <div class="card">
        <h2 class="card-header">
          {% trans "Members" %}
          {% if perms.dcim.change_virtualchassis %}
            <div class="card-actions">
              <a href="{% url 'dcim:virtualchassis_add_member' pk=object.pk %}?site={{ object.master.site.pk }}&rack={{ object.master.rack.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
                <i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Member" %}
              </a>
            </div>
          {% endif %}
        </h2>
        <table class="table table-hover object-list">
          <thead>
            <tr>
              <th>{% trans "Device" %}</th>
              <th>{% trans "Position" %}</th>
              <th>{% trans "Master" %}</th>
              <th>{% trans "Priority" %}</th>
            </tr>
          </thead>
          {% for vc_member in members %}
            <tr{% if vc_member == device %} class="info"{% endif %}>
              <td>
                {{ vc_member|linkify }}
              </td>
              <td>
                {% badge vc_member.vc_position show_empty=True %}
              </td>
              <td>
                {% if object.master == vc_member %}
                  {% checkmark True %}
                {% endif %}
              </td>
              <td>
                {{ vc_member.vc_priority|placeholder }}
              </td>
            </tr>
          {% endfor %}
        </table>
      </div>
      {% include 'inc/panels/comments.html' %}
      {% plugin_right_page object %}
	</div>
</div>
<div class="row">
  <div class="col col-md-12">
    {% plugin_full_width_page object %}
  </div>
</div>
{% endblock %}
