{% extends 'base/layout.html' %}

{% block title %}Site Mappings{% endblock %}

{% block content %}
<div class="card">
  <div class="card-header d-flex justify-content-between align-items-center">
    <strong>Site Mappings</strong>
    <a href="{% url 'plugins:netbox_unifi_sync:mapping_add' %}" class="btn btn-sm btn-primary">Add mapping</a>
  </div>
  <div class="table-responsive">
    <table class="table table-hover mb-0">
      <thead>
        <tr><th>Controller</th><th>UniFi site</th><th>NetBox site</th><th>Enabled</th><th></th></tr>
      </thead>
      <tbody>
      {% for row in mappings %}
        <tr>
          <td>{% if row.controller %}{{ row.controller.name }}{% else %}<span class="text-muted">Global</span>{% endif %}</td>
          <td>{{ row.unifi_site }}</td>
          <td>{{ row.netbox_site }}</td>
          <td>{{ row.enabled }}</td>
          <td class="text-end">
            <a href="{% url 'plugins:netbox_unifi_sync:mapping_edit' row.pk %}" class="btn btn-sm btn-outline-primary">Edit</a>
            <a href="{% url 'plugins:netbox_unifi_sync:mapping_delete' row.pk %}" class="btn btn-sm btn-outline-danger">Delete</a>
          </td>
        </tr>
      {% empty %}
        <tr><td colspan="5" class="text-muted">No mappings configured.</td></tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}
