{% extends 'generic/object.html' %}
{% load buttons %}
{% load helpers %}
{% load perms %}

{% block controls %}
  <div class="controls">
    <div class="control-group">
      {% if request.user|can_delete:object %}
        {% delete_button object %}
      {% endif %}
    </div>
  </div>
{% endblock controls %}

{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">Snapshot Information</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <th scope="row">Name</th>
              <td>{{ object.name|placeholder }}</td>
            </tr>
            <tr>
              <th scope="row">Snapshot ID</th>
              <td>{{ object.snapshot_id|placeholder }}</td>
            </tr>
            <tr>
                <th scope="row">Source</th>
                <td>
                    <a href="{% url 'plugins:ipfabric_netbox:ipfabricsource' pk=object.source.pk %}">{{ object.source }}</a>
                </td>
              </tr>
            <tr>
              <th scope="row">Last Updated</th>
              <td>{{ object.last_updated|placeholder }}</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <div class="col col-md-6">
        <div class="card">
            <h5 class="card-header">Statistics</h5>
            <div class="card-body">
              <table class="table table-hover attr-table">
                <tr>
                    <th scope="row">Version</th>
                    <td>{{ object.data.version|placeholder }}</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">Site Count</th>
                    <td>{{ object.data.sites|length|placeholder }}</td>
                </tr>
                <tr>
                    <th scope="row">Sites</th>
                    <td>
                        {% if object.data.sites %}
                            {% for site in object.data.sites %}
                                <span class="badge bg-info mt-1">
                                    {{ site }}
                                </span>
                            {% endfor %}
                        {% else %}
                            {{ ''|placeholder }}
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <th scope="row">Device Count</th>
                    <td>{{ object.data.total_dev_count|placeholder }}</td>
                </tr>
                <tr>
                    <th scope="row">Interface Count</th>
                    <td>{{ object.data.interface_count|placeholder }}</td>
                </tr>
                <tr>
                    <th scope="row">Note</th>
                    <td>
                        <pre>{{ object.data.note|placeholder }}</pre>
                    </td>
                </tr>
              </table>
            </div>
          </div>
    </div>
  </div>
  <div class="row">
    <div class="col col-12">
      <div class="card">
        <h5 class="card-header">Data</h5>
        <div class="card-body">
            <pre class="block">{{ object.data | json }}</pre>
        </div>
      </div>
    </div>
  </div>
{% endblock %}
